@fibrae/semi-foundation 0.2.0 → 0.3.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/anchor/foundation.d.ts +0 -3
- package/dist/anchor/foundation.js +0 -1
- package/dist/audio-player/foundation.d.ts +0 -3
- package/dist/audio-player/foundation.js +0 -1
- package/dist/auto-complete/foundation.d.ts +0 -2
- package/dist/auto-complete/foundation.js +0 -1
- package/dist/avatar/foundation.d.ts +0 -1
- package/dist/avatar/variables.scss +0 -1
- package/dist/backtop/foundation.d.ts +0 -3
- package/dist/backtop/foundation.js +0 -1
- package/dist/base/auto-close-foundation.d.ts +0 -1
- package/dist/base/foundation.d.ts +0 -1
- package/dist/base/list-store.d.ts +0 -1
- package/dist/calendar/event-util.d.ts +0 -10
- package/dist/calendar/event-util.js +0 -10
- package/dist/calendar/foundation.d.ts +1 -6
- package/dist/calendar/foundation.js +1 -5
- package/dist/calendar/month-foundation.d.ts +0 -1
- package/dist/calendar/month-foundation.js +0 -1
- package/dist/carousel/foundation.d.ts +0 -2
- package/dist/cascader/foundation.d.ts +2 -6
- package/dist/cascader/foundation.js +2 -11
- package/dist/cascader/util.d.ts +1 -8
- package/dist/cascader/util.js +1 -8
- package/dist/checkbox/checkbox-foundation.d.ts +1 -5
- package/dist/checkbox/checkbox-foundation.js +0 -2
- package/dist/checkbox/checkbox-group-foundation.d.ts +0 -1
- package/dist/code-highlight/index.d.ts +0 -1
- package/dist/color-picker/color-picker.scss +0 -2
- package/dist/color-picker/interface.d.ts +0 -1
- package/dist/config-provider/responsive-types.d.ts +0 -16
- package/dist/cropper/foundation.d.ts +0 -1
- package/dist/cropper/foundation.js +0 -1
- package/dist/date-picker/_utils/get-default-picker-date.d.ts +0 -3
- package/dist/date-picker/_utils/get-default-picker-date.js +0 -3
- package/dist/date-picker/_utils/get-inset-input-format-token.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-format-token.js +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.js +0 -2
- package/dist/date-picker/_utils/parser.d.ts +0 -3
- package/dist/date-picker/_utils/parser.js +0 -7
- package/dist/date-picker/_utils/picker-type.d.ts +0 -2
- package/dist/date-picker/_utils/picker-type.js +0 -2
- package/dist/date-picker/_utils/to-callback-args.d.ts +0 -1
- package/dist/date-picker/_utils/to-callback-args.js +0 -1
- package/dist/date-picker/date-picker.scss +0 -3
- package/dist/date-picker/foundation.d.ts +3 -22
- package/dist/date-picker/foundation.js +1 -24
- package/dist/date-picker/input-foundation.d.ts +1 -7
- package/dist/date-picker/input-foundation.js +0 -2
- package/dist/date-picker/month-foundation.d.ts +0 -3
- package/dist/date-picker/month-foundation.js +0 -2
- package/dist/date-picker/months-grid-foundation.d.ts +1 -10
- package/dist/date-picker/months-grid-foundation.js +1 -10
- package/dist/drag-move/foundation.d.ts +0 -1
- package/dist/dropdown/foundation.d.ts +0 -2
- package/dist/dropdown/menu-foundation.d.ts +0 -1
- package/dist/feedback/foundation.d.ts +0 -1
- package/dist/feedback/variables.scss +1 -5
- package/dist/float-button/float-button.css +0 -1
- package/dist/float-button/float-button.scss +0 -2
- package/dist/form/form.scss +0 -12
- package/dist/form/foundation.js +0 -15
- package/dist/form/interface.d.ts +2 -15
- package/dist/form/utils.d.ts +0 -8
- package/dist/form/utils.js +0 -7
- package/dist/form/variables.scss +1 -4
- package/dist/grid/variables.scss +0 -10
- package/dist/highlight/foundation.d.ts +0 -2
- package/dist/highlight/foundation.js +0 -2
- package/dist/hot-keys/foundation.d.ts +0 -1
- package/dist/image/image-foundation.d.ts +0 -2
- package/dist/image/preview-footer-foundation.d.ts +0 -1
- package/dist/image/preview-foundation.d.ts +0 -3
- package/dist/image/preview-image-foundation.d.ts +0 -1
- package/dist/image/preview-inner-foundation.d.ts +0 -1
- package/dist/input/foundation.d.ts +0 -1
- package/dist/input/text-entry-foundation.d.ts +0 -2
- package/dist/input/text-entry-foundation.js +0 -1
- package/dist/input/textarea-foundation.d.ts +0 -1
- package/dist/input-number/caret.d.ts +0 -1
- package/dist/input-number/caret.js +0 -1
- package/dist/input-number/foundation.d.ts +0 -5
- package/dist/input-number/foundation.js +0 -5
- package/dist/json-viewer/foundation.d.ts +0 -2
- package/dist/json-viewer/foundation.js +0 -1
- package/dist/locale/interface.d.ts +0 -3
- package/dist/markdown-render/foundation.d.ts +1 -6
- package/dist/markdown-render/foundation.js +1 -5
- package/dist/navigation/foundation.d.ts +0 -7
- package/dist/navigation/foundation.js +0 -6
- package/dist/navigation/sub-nav-foundation.d.ts +0 -1
- package/dist/notification/notification-list-foundation.d.ts +0 -1
- package/dist/notification/notification-list-foundation.js +0 -1
- package/dist/notification/variables.scss +0 -1
- package/dist/overflow-list/foundation.d.ts +0 -2
- package/dist/overflow-list/foundation.js +0 -1
- package/dist/pagination/foundation.d.ts +0 -2
- package/dist/pincode/foundation.d.ts +1 -4
- package/dist/pincode/foundation.js +1 -4
- package/dist/popconfirm/popconfirm-foundation.d.ts +0 -2
- package/dist/progress/generates.d.ts +1 -4
- package/dist/progress/generates.js +1 -4
- package/dist/progress/utils.d.ts +1 -1
- package/dist/progress/utils.js +1 -1
- package/dist/radio/radio-foundation.d.ts +0 -4
- package/dist/radio/radio-foundation.js +0 -1
- package/dist/radio/radio-group-foundation.d.ts +0 -1
- package/dist/rating/foundation.d.ts +0 -5
- package/dist/rating/foundation.js +0 -3
- package/dist/resizable/group/index.d.ts +0 -4
- package/dist/resizable/group/index.js +0 -4
- package/dist/resizable/resizable.scss +0 -1
- package/dist/resizable/single/index.d.ts +1 -5
- package/dist/resizable/single/index.js +1 -4
- package/dist/scroll-list/item-foundation.d.ts +0 -2
- package/dist/scroll-list/item-foundation.js +0 -1
- package/dist/scroll-list/variables.scss +1 -6
- package/dist/select/foundation.d.ts +0 -1
- package/dist/select/option-foundation.d.ts +2 -3
- package/dist/select/option-foundation.js +0 -1
- package/dist/select/variables.scss +1 -8
- package/dist/side-sheet/side-sheet-foundation.d.ts +1 -6
- package/dist/side-sheet/side-sheet-foundation.js +1 -5
- package/dist/side-sheet/variables.scss +1 -3
- package/dist/slider/foundation.d.ts +1 -12
- package/dist/slider/foundation.js +1 -13
- package/dist/slider/variables.scss +1 -5
- package/dist/spin/foundation.d.ts +0 -2
- package/dist/spin/foundation.js +0 -1
- package/dist/spin/variables.scss +1 -3
- package/dist/switch/foundation.d.ts +0 -1
- package/dist/switch/switch.scss +1 -1
- package/dist/switch/variables.scss +1 -5
- package/dist/table/foundation.d.ts +12 -21
- package/dist/table/foundation.js +51 -15
- package/dist/table/table.scss +0 -1
- package/dist/table/utils.d.ts +0 -8
- package/dist/table/utils.js +0 -13
- package/dist/table/variables.scss +1 -5
- package/dist/tabs/foundation.d.ts +0 -9
- package/dist/tabs/foundation.js +0 -4
- package/dist/tabs/tabs.scss +1 -1
- package/dist/tag/focus.js +0 -1
- package/dist/tag-input/foundation.d.ts +0 -2
- package/dist/tag-input/foundation.js +0 -1
- package/dist/tag-input/tag-input.scss +0 -1
- package/dist/tag-input/utils/tag-focus.d.ts +0 -1
- package/dist/tag-input/utils/tag-focus.js +0 -1
- package/dist/time-picker/combox-foundation.d.ts +3 -11
- package/dist/time-picker/combox-foundation.js +3 -10
- package/dist/time-picker/foundation.d.ts +0 -10
- package/dist/time-picker/foundation.js +0 -9
- package/dist/time-picker/utils/index.d.ts +0 -11
- package/dist/time-picker/utils/index.js +0 -11
- package/dist/tooltip/adjust-position.d.ts +1 -2
- package/dist/tooltip/constants.d.ts +0 -3
- package/dist/tooltip/constants.js +0 -3
- package/dist/tooltip/foundation.d.ts +0 -3
- package/dist/tooltip/foundation.js +0 -2
- package/dist/tooltip/position.scss +0 -1
- package/dist/transfer/foundation.d.ts +0 -4
- package/dist/transfer/foundation.js +0 -1
- package/dist/tree/foundation.d.ts +0 -2
- package/dist/tree/foundation.js +0 -1
- package/dist/tree/shared.d.ts +1 -3
- package/dist/tree/shared.js +0 -2
- package/dist/tree/tree-util.d.ts +0 -5
- package/dist/tree/tree-util.js +0 -5
- package/dist/tree-select/foundation.d.ts +0 -2
- package/dist/tree-select/foundation.js +0 -3
- package/dist/typography/ellipsis.d.ts +1 -3
- package/dist/typography/ellipsis.js +0 -2
- package/dist/typography/typography.scss +0 -1
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +0 -6
- package/dist/upload/foundation.js +1 -11
- package/dist/upload/utils.d.ts +0 -5
- package/dist/upload/utils.js +0 -5
- package/dist/user-guide/foundation.d.ts +0 -2
- package/dist/utils/a11y.d.ts +1 -5
- package/dist/utils/a11y.js +1 -4
- package/dist/utils/array.d.ts +0 -6
- package/dist/utils/array.js +0 -6
- package/dist/utils/date-fns-extra.js +1 -5
- package/dist/utils/dom.d.ts +0 -1
- package/dist/utils/dom.js +0 -1
- package/dist/utils/escape-html.js +0 -3
- package/dist/utils/field-sizing.d.ts +0 -2
- package/dist/utils/field-sizing.js +0 -2
- package/dist/utils/focus-handle.d.ts +0 -1
- package/dist/utils/focus-handle.js +0 -1
- package/dist/utils/focus-scope.d.ts +0 -1
- package/dist/utils/focus-scope.js +0 -1
- package/dist/utils/scroll-lock.d.ts +3 -4
- package/dist/utils/scroll-lock.js +3 -4
- package/dist/utils/tween.d.ts +0 -1
- package/dist/utils/tween.js +0 -1
- package/dist/utils/uuid.d.ts +0 -1
- package/dist/utils/uuid.js +0 -1
- package/dist/utils/warning.d.ts +0 -1
- package/dist/utils/warning.js +0 -1
- package/dist/video-player/progress-foundation.d.ts +0 -1
- package/dist/video-player/progress-foundation.js +0 -1
- package/dist/video-player/variables.scss +1 -1
- package/package.json +2 -2
|
@@ -19,9 +19,7 @@ function toColumn(options, disabledOptions, selected) {
|
|
|
19
19
|
selectedIndex: options.indexOf(selected)
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
/** Pure calculations for one time panel: which columns show, what each lists, and the time a picked item makes */
|
|
23
22
|
var ComboboxFoundation = class ComboboxFoundation {
|
|
24
|
-
/** The columns `format` asks for */
|
|
25
23
|
static getColumns(format) {
|
|
26
24
|
return {
|
|
27
25
|
showHour: /HH|hh|H|h/.test(format),
|
|
@@ -30,8 +28,8 @@ var ComboboxFoundation = class ComboboxFoundation {
|
|
|
30
28
|
};
|
|
31
29
|
}
|
|
32
30
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* Every column reads the shown time (midnight, or noon in a PM panel, while there is no value), the time a picked
|
|
32
|
+
* item is applied to.
|
|
35
33
|
*/
|
|
36
34
|
static getOptions(props) {
|
|
37
35
|
const { timeStampValue, use12Hours, hourStep, disabledMinutes, disabledSeconds, hideDisabledOptions, minuteStep, secondStep } = props;
|
|
@@ -57,10 +55,7 @@ var ComboboxFoundation = class ComboboxFoundation {
|
|
|
57
55
|
second: toColumn(secondOptions, disabledSecondOptions, dateTime.getSeconds())
|
|
58
56
|
};
|
|
59
57
|
}
|
|
60
|
-
/**
|
|
61
|
-
* The time after picking `itemValue` in column `type`. A 12-hour hour keeps the half day `isAM` names; AM/PM moves
|
|
62
|
-
* the time by 12 hours only when it is in the other half day.
|
|
63
|
-
*/
|
|
58
|
+
/** A 12-hour hour keeps the half day `isAM` names; AM/PM moves the time by 12 hours only when it is in the other half day */
|
|
64
59
|
static applyItem(timeStampValue, type, itemValue, use12Hours, isAM) {
|
|
65
60
|
const date = ComboboxFoundation.getDisplayDateFromTimeStamp(timeStampValue, use12Hours && !isAM);
|
|
66
61
|
const hours = date.getHours();
|
|
@@ -83,7 +78,6 @@ var ComboboxFoundation = class ComboboxFoundation {
|
|
|
83
78
|
if (use12Hours && Array.isArray(disabledOptions)) return disabledOptions.filter((h) => h < 12 === Boolean(isAM)).map((h) => h % 12 || 12);
|
|
84
79
|
return disabledOptions;
|
|
85
80
|
}
|
|
86
|
-
/** The half day of the value; `defaultIsAM` applies while there is no value */
|
|
87
81
|
static isAM(timeStamp, defaultIsAM = true) {
|
|
88
82
|
return ComboboxFoundation.hasValue(timeStamp) ? ComboboxFoundation.getDisplayDateFromTimeStamp(timeStamp).getHours() < 12 : defaultIsAM;
|
|
89
83
|
}
|
|
@@ -91,7 +85,6 @@ var ComboboxFoundation = class ComboboxFoundation {
|
|
|
91
85
|
static hasValue(timeStamp) {
|
|
92
86
|
return timeStamp != null && timeStamp !== "" && isValidDate(new Date(timeStamp));
|
|
93
87
|
}
|
|
94
|
-
/** The time a panel shows; without a value, today's midnight, or noon when the panel shows PM */
|
|
95
88
|
static getDisplayDateFromTimeStamp(timeStamp, defaultIsPM = false) {
|
|
96
89
|
if (!ComboboxFoundation.hasValue(timeStamp)) {
|
|
97
90
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -17,7 +17,6 @@ export interface TimePickerAdapter<P extends TimePickerBaseProps = TimePickerBas
|
|
|
17
17
|
/** focuses the input, or the focus target of a custom trigger */
|
|
18
18
|
setTriggerFocus: () => void;
|
|
19
19
|
}
|
|
20
|
-
/** The props the foundation reads with getProp */
|
|
21
20
|
export interface TimePickerBaseProps {
|
|
22
21
|
dateFnsLocale?: Locale;
|
|
23
22
|
disabled?: boolean;
|
|
@@ -53,10 +52,6 @@ export default class TimePickerFoundation<P extends TimePickerBaseProps = TimePi
|
|
|
53
52
|
protected validateDates(dates?: Array<Date>): boolean;
|
|
54
53
|
protected formatValue(dates: Date[]): string;
|
|
55
54
|
protected parseInput(str: string): Date[];
|
|
56
|
-
/**
|
|
57
|
-
* The format in use: the `format` prop when not `undefined`, else the 12- or 24-hour default; a value that is
|
|
58
|
-
* not a string falls back to the 24-hour default
|
|
59
|
-
*/
|
|
60
55
|
static getValidFormat(props: Record<string, any>): string;
|
|
61
56
|
/**
|
|
62
57
|
* The disabled-time callbacks of one panel, as the panel lists and validation both use them. `disabledTime` is
|
|
@@ -67,7 +62,6 @@ export default class TimePickerFoundation<P extends TimePickerBaseProps = TimePi
|
|
|
67
62
|
static getPosition(props: Record<string, any>, direction?: string): Position;
|
|
68
63
|
/** A controlled `open` is not copied into state, so the shown panel comes from props when they carry it; a disabled picker shows none */
|
|
69
64
|
static isPanelShown(props: Record<string, any>, state: Record<string, any>): boolean;
|
|
70
|
-
/** The value and input text of the first render, from `value` or else `defaultValue` */
|
|
71
65
|
static getInitialState(props: Record<string, any>): {
|
|
72
66
|
value: Date[];
|
|
73
67
|
inputValue: string;
|
|
@@ -76,10 +70,6 @@ export default class TimePickerFoundation<P extends TimePickerBaseProps = TimePi
|
|
|
76
70
|
handlePanelChange: (result: {
|
|
77
71
|
timeStampValue: number;
|
|
78
72
|
}, index?: number) => void;
|
|
79
|
-
/**
|
|
80
|
-
* Derives the value, input text and validity state from a `value` prop. With `prevTimeZone`, `value` is the
|
|
81
|
-
* shown value in that zone and is re-zoned into `timeZone`.
|
|
82
|
-
*/
|
|
83
73
|
syncValueFromProps: ({ value, timeZone, prevTimeZone }: {
|
|
84
74
|
value: TimeValue | (TimeValue | undefined)[];
|
|
85
75
|
timeZone?: string | number;
|
|
@@ -101,10 +101,6 @@ var TimePickerFoundation = class TimePickerFoundation extends BaseFoundation {
|
|
|
101
101
|
if (str && typeof str === "string") return str.split(rangeSeparator).map((v) => parseToDate(v, validFormat, dateFnsLocale));
|
|
102
102
|
return [];
|
|
103
103
|
}
|
|
104
|
-
/**
|
|
105
|
-
* The format in use: the `format` prop when not `undefined`, else the 12- or 24-hour default; a value that is
|
|
106
|
-
* not a string falls back to the 24-hour default
|
|
107
|
-
*/
|
|
108
104
|
static getValidFormat(props) {
|
|
109
105
|
let _format = props.format;
|
|
110
106
|
if (_format === void 0) _format = props.use12Hours ? strings.DEFAULT_FORMAT_A : strings.DEFAULT_FORMAT;
|
|
@@ -132,7 +128,6 @@ var TimePickerFoundation = class TimePickerFoundation extends BaseFoundation {
|
|
|
132
128
|
static isPanelShown(props, state) {
|
|
133
129
|
return (props.open !== void 0 ? Boolean(props.open) : Boolean(state.open)) && !props.disabled;
|
|
134
130
|
}
|
|
135
|
-
/** The value and input text of the first render, from `value` or else `defaultValue` */
|
|
136
131
|
static getInitialState(props) {
|
|
137
132
|
const value = props.value === void 0 ? props.defaultValue : props.value;
|
|
138
133
|
const dates = TimePickerFoundation.#parseDates(value, props, props.timeZone);
|
|
@@ -161,10 +156,6 @@ var TimePickerFoundation = class TimePickerFoundation extends BaseFoundation {
|
|
|
161
156
|
if (this.#hasChanged(value, oldValue)) this.#notifyChange(value, inputValue);
|
|
162
157
|
}
|
|
163
158
|
};
|
|
164
|
-
/**
|
|
165
|
-
* Derives the value, input text and validity state from a `value` prop. With `prevTimeZone`, `value` is the
|
|
166
|
-
* shown value in that zone and is re-zoned into `timeZone`.
|
|
167
|
-
*/
|
|
168
159
|
syncValueFromProps = ({ value, timeZone, prevTimeZone }) => {
|
|
169
160
|
const dates = TimePickerFoundation.#parseDates(value, this.getProps(), timeZone, prevTimeZone);
|
|
170
161
|
this.setState({
|
|
@@ -4,15 +4,4 @@ export declare function hourIsDisabled(disabledHours: () => number[], hour: numb
|
|
|
4
4
|
export declare function minuteIsDisabled(disabledMinutes: (hour: number) => number[], hour: number, minute: number): boolean;
|
|
5
5
|
export declare function secondIsDisabled(disabledSeconds: (hour: number, minute: number) => number[], hour: number, minute: number, second: number): boolean;
|
|
6
6
|
export declare function transformToArray<T>(value: T[]): T[];
|
|
7
|
-
/**
|
|
8
|
-
* Determine whether the time length is the same as the format
|
|
9
|
-
* e.g.
|
|
10
|
-
* format | time | return
|
|
11
|
-
* HH:mm | 12:00 | true
|
|
12
|
-
* HH:mm:ss | 12:00:00 | true
|
|
13
|
-
* yyyy HH:mm | 2021 12:00| true
|
|
14
|
-
* HH | 1 | false
|
|
15
|
-
* HH:mm | 12:0 | false
|
|
16
|
-
* HH:mm:ss | 12:00:0 | false
|
|
17
|
-
*/
|
|
18
7
|
export declare function isTimeFormatLike(time: string, formatToken: string): boolean;
|
|
@@ -32,17 +32,6 @@ function secondIsDisabled(disabledSeconds, hour, minute, second) {
|
|
|
32
32
|
function transformToArray(value) {
|
|
33
33
|
return Array.isArray(value) ? [...value] : [];
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Determine whether the time length is the same as the format
|
|
37
|
-
* e.g.
|
|
38
|
-
* format | time | return
|
|
39
|
-
* HH:mm | 12:00 | true
|
|
40
|
-
* HH:mm:ss | 12:00:00 | true
|
|
41
|
-
* yyyy HH:mm | 2021 12:00| true
|
|
42
|
-
* HH | 1 | false
|
|
43
|
-
* HH:mm | 12:0 | false
|
|
44
|
-
* HH:mm:ss | 12:00:0 | false
|
|
45
|
-
*/
|
|
46
35
|
function isTimeFormatLike(time, formatToken) {
|
|
47
36
|
let isLike = true;
|
|
48
37
|
const dateFnsSupportFormatCh = "BDEGHKLMOPQRSTXYabcehimopqstuwxyz";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Only rects and numbers go in (no DOM, window or class instance), so it can be table-tested.
|
|
3
3
|
*/
|
|
4
4
|
export interface AdjustRect {
|
|
5
5
|
left: number;
|
|
@@ -21,7 +21,6 @@ export interface AdjustPositionInput {
|
|
|
21
21
|
triggerRect: AdjustRect;
|
|
22
22
|
/** popup size, nothing is adjusted when width or height is 0 */
|
|
23
23
|
wrapperRect: Pick<AdjustRect, 'width' | 'height'>;
|
|
24
|
-
/** rect of the popup container */
|
|
25
24
|
containerRect: Pick<AdjustRect, 'left' | 'right' | 'top' | 'bottom'>;
|
|
26
25
|
viewport: {
|
|
27
26
|
width: number;
|
|
@@ -8,7 +8,6 @@ export declare const strings: {
|
|
|
8
8
|
readonly STATUS_LOADING: "loading";
|
|
9
9
|
readonly LEAVE_DELAY_WARNING: "[Semi Tooltip] 'mouseLeaveDelay' cannot be less than 'mouseEnterDelay', which may cause the dropdown layer to not be hidden.";
|
|
10
10
|
};
|
|
11
|
-
/** The DOM event names the trigger and popup listeners bind to */
|
|
12
11
|
export declare const TRIGGER_EVENT_NAMES: {
|
|
13
12
|
readonly mouseEnter: "mouseenter";
|
|
14
13
|
readonly mouseLeave: "mouseleave";
|
|
@@ -21,7 +20,6 @@ export declare const TRIGGER_EVENT_NAMES: {
|
|
|
21
20
|
readonly contextMenu: "contextmenu";
|
|
22
21
|
};
|
|
23
22
|
export declare const canRoleCarryPopupState: (role: string) => boolean;
|
|
24
|
-
/** Whether a wrapper around a trigger with this `display` must fill the width */
|
|
25
23
|
export declare const isBlockDisplay: (display?: string) => boolean;
|
|
26
24
|
/**
|
|
27
25
|
* Whether a disabled or loading trigger gets a wrapper span that takes the pointer events: a loading Button
|
|
@@ -30,7 +28,6 @@ export declare const isBlockDisplay: (display?: string) => boolean;
|
|
|
30
28
|
export declare const wrapsSpecialTrigger: (trigger: string | undefined, loading: boolean) => boolean;
|
|
31
29
|
/** The forced light and dark areas; the popup leaves the trigger's subtree, so it copies the innermost one around it */
|
|
32
30
|
export declare const COLOR_SCHEME_SELECTOR = ".semi-always-dark, .semi-always-light";
|
|
33
|
-
/** The class that keeps a popup in the scheme of `area`, the innermost COLOR_SCHEME_SELECTOR element around the trigger */
|
|
34
31
|
export declare const colorSchemeOf: (area?: Element | null) => "semi-always-dark" | "semi-always-light";
|
|
35
32
|
/**
|
|
36
33
|
* Where a popup opened from a trigger in `root` is inserted: the shadow root, else body, so forms, labels and inherited
|
|
@@ -31,7 +31,6 @@ const strings = {
|
|
|
31
31
|
STATUS_LOADING: "loading",
|
|
32
32
|
LEAVE_DELAY_WARNING: "[Semi Tooltip] 'mouseLeaveDelay' cannot be less than 'mouseEnterDelay', which may cause the dropdown layer to not be hidden."
|
|
33
33
|
};
|
|
34
|
-
/** The DOM event names the trigger and popup listeners bind to */
|
|
35
34
|
const TRIGGER_EVENT_NAMES = {
|
|
36
35
|
mouseEnter: "mouseenter",
|
|
37
36
|
mouseLeave: "mouseleave",
|
|
@@ -60,7 +59,6 @@ const BLOCK_DISPLAYS = /* @__PURE__ */ new Set([
|
|
|
60
59
|
"grid"
|
|
61
60
|
]);
|
|
62
61
|
const canRoleCarryPopupState = (role) => POPUP_TRIGGER_ROLES.has(role);
|
|
63
|
-
/** Whether a wrapper around a trigger with this `display` must fill the width */
|
|
64
62
|
const isBlockDisplay = (display) => BLOCK_DISPLAYS.has(display);
|
|
65
63
|
/**
|
|
66
64
|
* Whether a disabled or loading trigger gets a wrapper span that takes the pointer events: a loading Button
|
|
@@ -71,7 +69,6 @@ const alwaysDark = `${BASE_CLASS_PREFIX}-always-dark`;
|
|
|
71
69
|
const alwaysLight = `${BASE_CLASS_PREFIX}-always-light`;
|
|
72
70
|
/** The forced light and dark areas; the popup leaves the trigger's subtree, so it copies the innermost one around it */
|
|
73
71
|
const COLOR_SCHEME_SELECTOR = `.${alwaysDark}, .${alwaysLight}`;
|
|
74
|
-
/** The class that keeps a popup in the scheme of `area`, the innermost COLOR_SCHEME_SELECTOR element around the trigger */
|
|
75
72
|
const colorSchemeOf = (area) => area ? area.classList.contains(alwaysDark) ? alwaysDark : alwaysLight : void 0;
|
|
76
73
|
/**
|
|
77
74
|
* Where a popup opened from a trigger in `root` is inserted: the shadow root, else body, so forms, labels and inherited
|
|
@@ -32,12 +32,10 @@ export interface TooltipAdapter<P extends TooltipBaseProps = TooltipBaseProps, S
|
|
|
32
32
|
getTriggerRect(): DOMRect | null;
|
|
33
33
|
/** The element getTriggerRect measures; null while unknown, and then every scroll repositions the popup */
|
|
34
34
|
getTriggerElement(): Element | null;
|
|
35
|
-
/** Starts observing every trigger element with `observer` */
|
|
36
35
|
observeTrigger(observer: ResizeObserver | IntersectionObserver): void;
|
|
37
36
|
unobserveTrigger(observer: ResizeObserver | IntersectionObserver): void;
|
|
38
37
|
}
|
|
39
38
|
export type Position = ArrayElement<typeof strings.POSITION_SET>;
|
|
40
|
-
/** The props the foundation reads with getProp */
|
|
41
39
|
export interface TooltipBaseProps {
|
|
42
40
|
arrowPointAtCenter?: boolean;
|
|
43
41
|
autoAdjustOverflow?: boolean;
|
|
@@ -62,7 +60,6 @@ export interface TooltipBaseProps {
|
|
|
62
60
|
trigger?: ArrayElement<typeof strings.TRIGGER_SET>;
|
|
63
61
|
visible?: boolean;
|
|
64
62
|
}
|
|
65
|
-
/** The state the foundation reads with getState */
|
|
66
63
|
export interface TooltipBaseState {
|
|
67
64
|
isInsert: boolean;
|
|
68
65
|
transitionState: 'enter' | 'leave' | '';
|
|
@@ -255,7 +255,6 @@ var Tooltip = class Tooltip extends BaseFoundation {
|
|
|
255
255
|
this.#moveWatch?.observer.disconnect();
|
|
256
256
|
this.#moveWatch = null;
|
|
257
257
|
}
|
|
258
|
-
/** Reads the layout: the trigger, the popup size and the placement; null while there is nothing to place */
|
|
259
258
|
#measure(viewport) {
|
|
260
259
|
const popup = this.adapter.getPortalContainer();
|
|
261
260
|
const triggerRect = this.adapter.getTriggerRect();
|
|
@@ -298,7 +297,6 @@ var Tooltip = class Tooltip extends BaseFoundation {
|
|
|
298
297
|
viewport
|
|
299
298
|
};
|
|
300
299
|
}
|
|
301
|
-
/** Writes a measured layout to the popup unless it is already there */
|
|
302
300
|
#apply(layout) {
|
|
303
301
|
const popup = this.adapter.getPortalContainer();
|
|
304
302
|
if (!layout || !popup) return;
|
|
@@ -22,11 +22,9 @@ export interface BasicResolvedDataItem extends BasicDataItem {
|
|
|
22
22
|
_parent?: Omit<BasicGroupItem, 'children'>;
|
|
23
23
|
/** The nodes from the root to this one in treeList mode; underscored so it never collides with the caller's `path` */
|
|
24
24
|
_path?: Array<BasicDataItem>;
|
|
25
|
-
/** Whether the node has no children in treeList mode; underscored for the same reason as `_path` */
|
|
26
25
|
_isLeaf?: boolean;
|
|
27
26
|
}
|
|
28
27
|
export type BasicFilter = boolean | ((searchValue: string, item: BasicDataItem) => boolean);
|
|
29
|
-
/** The props the foundation reads with getProp */
|
|
30
28
|
export interface TransferBaseProps {
|
|
31
29
|
dataSource?: Array<object>;
|
|
32
30
|
defaultValue?: Array<number | string>;
|
|
@@ -39,7 +37,6 @@ export interface TransferBaseProps {
|
|
|
39
37
|
type?: string;
|
|
40
38
|
value?: Array<number | string>;
|
|
41
39
|
}
|
|
42
|
-
/** The state the foundation reads with getState */
|
|
43
40
|
export interface TransferBaseState {
|
|
44
41
|
inputValue: string;
|
|
45
42
|
leftCurrentPage: number;
|
|
@@ -103,7 +100,6 @@ export default class TransferFoundation<P extends TransferBaseProps = TransferBa
|
|
|
103
100
|
};
|
|
104
101
|
/** The item as handed to callbacks: internal fields (`_parent`, `_path`, `_isLeaf`) removed, `fullPath` added */
|
|
105
102
|
static toPublicItem(item: BasicResolvedDataItem, type: string, showPath: boolean): BasicResolvedDataItem;
|
|
106
|
-
/** The treeList path label shown with `showPath`, e.g. "Asia > China > Shanghai" */
|
|
107
103
|
static generatePath({ _path }: BasicResolvedDataItem): string;
|
|
108
104
|
handleInputChange: (inputVal: string, notify: boolean) => void;
|
|
109
105
|
handleAll: (wantAllChecked: boolean) => void;
|
|
@@ -108,7 +108,6 @@ var TransferFoundation = class TransferFoundation extends BaseFoundation {
|
|
|
108
108
|
fullPath
|
|
109
109
|
} : publicItem;
|
|
110
110
|
}
|
|
111
|
-
/** The treeList path label shown with `showPath`, e.g. "Asia > China > Shanghai" */
|
|
112
111
|
static generatePath({ _path = [] }) {
|
|
113
112
|
return _path.map((p) => p.label).join(" > ");
|
|
114
113
|
}
|
|
@@ -67,7 +67,6 @@ export interface BasicFlattenNode {
|
|
|
67
67
|
pos?: string;
|
|
68
68
|
value?: string;
|
|
69
69
|
}
|
|
70
|
-
/** `show` while rows expand, `hide` while they collapse */
|
|
71
70
|
export type TreeMotionType = 'show' | 'hide';
|
|
72
71
|
/** The values and the `smart` rule are those of the adapter's virtual list */
|
|
73
72
|
export type ScrollAlign = 'center' | 'start' | 'end' | 'smart' | 'auto';
|
|
@@ -270,7 +269,6 @@ export default class TreeFoundation<E = unknown> extends BaseFoundation<TreeAdap
|
|
|
270
269
|
* Returns null when nothing changed, so a host that writes the result back settles.
|
|
271
270
|
*/
|
|
272
271
|
static deriveState(props: BasicTreeProps, prevState: BasicTreeInnerData): Partial<BasicTreeInnerData> | null;
|
|
273
|
-
/** The state of a new tree: the empty state with what the props imply */
|
|
274
272
|
static getInitialState(props: BasicTreeProps): BasicTreeInnerData;
|
|
275
273
|
destroy(): void;
|
|
276
274
|
/** Writes the state derived from new props back, so handlers read what was rendered */
|
package/dist/tree/foundation.js
CHANGED
|
@@ -311,7 +311,6 @@ var TreeFoundation = class TreeFoundation extends BaseFoundation {
|
|
|
311
311
|
newState.prevProps = { ...props };
|
|
312
312
|
return newState;
|
|
313
313
|
}
|
|
314
|
-
/** The state of a new tree: the empty state with what the props imply */
|
|
315
314
|
static getInitialState(props) {
|
|
316
315
|
const state = {
|
|
317
316
|
inputValue: "",
|
package/dist/tree/shared.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BasicFlattenNode, BasicTreeInnerData, BasicTreeNodeProps, BasicTreeProps, TreeMotionType } from "./foundation.js";
|
|
2
2
|
import { Typeahead } from "../utils/a11y.js";
|
|
3
3
|
type CheckState = Pick<BasicTreeInnerData, 'keyEntities' | 'checkedKeys' | 'halfCheckedKeys' | 'disabledKeys'>;
|
|
4
|
-
/** The props a tree node renders with */
|
|
5
4
|
export declare function getTreeNodeProps(key: string, { expandedKeys, selectedKeys, checkedKeys, halfCheckedKeys, realCheckedKeys, keyEntities, filteredKeys, inputValue, loadedKeys, loadingKeys, filteredExpandedKeys, filteredShownKeys, disabledKeys, treeData }: Partial<Omit<BasicTreeInnerData, 'prevProps'>>, props: Pick<BasicTreeProps, 'checkRelation' | 'disableStrictly' | 'showFilteredOnly'>): BasicTreeNodeProps | null;
|
|
6
5
|
/** Whether a node renders as a leaf, with no expand arrow; with loadData a node is a branch until it loads empty */
|
|
7
6
|
export declare function isTreeNodeLeaf({ isLeaf, children, loaded }: Pick<BasicTreeNodeProps, 'isLeaf' | 'children' | 'loaded'>, loadData: unknown): boolean;
|
|
@@ -23,13 +22,12 @@ export interface TreeRowAria {
|
|
|
23
22
|
'aria-selected'?: boolean;
|
|
24
23
|
'aria-setsize': number;
|
|
25
24
|
}
|
|
26
|
-
/** The treeitem attributes of a row: a multiple tree states each row's check, a single one its selection */
|
|
27
25
|
export declare function getTreeRowAria(row: BasicTreeNodeProps, { disabled, isLeaf, multiple }: {
|
|
28
26
|
disabled: boolean;
|
|
29
27
|
isLeaf: boolean;
|
|
30
28
|
multiple?: boolean;
|
|
31
29
|
}): TreeRowAria;
|
|
32
|
-
/**
|
|
30
|
+
/** `fullLabel` is whether a custom full label renders the row */
|
|
33
31
|
export interface TreeRowFlags {
|
|
34
32
|
disabled: boolean;
|
|
35
33
|
focused?: boolean;
|
package/dist/tree/shared.js
CHANGED
|
@@ -29,7 +29,6 @@ function getShownSiblings(entity, keyEntities, filteredShownKeys) {
|
|
|
29
29
|
}
|
|
30
30
|
return shown;
|
|
31
31
|
}
|
|
32
|
-
/** The props a tree node renders with */
|
|
33
32
|
function getTreeNodeProps(key, { expandedKeys = /* @__PURE__ */ new Set([]), selectedKeys = [], checkedKeys = /* @__PURE__ */ new Set([]), halfCheckedKeys = /* @__PURE__ */ new Set([]), realCheckedKeys = /* @__PURE__ */ new Set([]), keyEntities = {}, filteredKeys = /* @__PURE__ */ new Set([]), inputValue = "", loadedKeys = /* @__PURE__ */ new Set([]), loadingKeys = /* @__PURE__ */ new Set([]), filteredExpandedKeys = /* @__PURE__ */ new Set([]), filteredShownKeys = /* @__PURE__ */ new Set([]), disabledKeys = /* @__PURE__ */ new Set([]), treeData = [] }, props) {
|
|
34
33
|
const { checkRelation } = props;
|
|
35
34
|
const entity = keyEntities[key];
|
|
@@ -100,7 +99,6 @@ function buildRowProps(node, state, props) {
|
|
|
100
99
|
function nodeId(baseId, key) {
|
|
101
100
|
return `${baseId}-${encodeURIComponent(key)}`;
|
|
102
101
|
}
|
|
103
|
-
/** The treeitem attributes of a row: a multiple tree states each row's check, a single one its selection */
|
|
104
102
|
function getTreeRowAria(row, { disabled, isLeaf, multiple }) {
|
|
105
103
|
return {
|
|
106
104
|
"aria-busy": row.loading || void 0,
|
package/dist/tree/tree-util.d.ts
CHANGED
|
@@ -21,7 +21,6 @@ export interface KeyMapProps {
|
|
|
21
21
|
icon?: string;
|
|
22
22
|
}
|
|
23
23
|
export declare function getPosition(parentPos: string, index: number): string;
|
|
24
|
-
/** Flattens nested tree data into a list, as the virtual list renders it. */
|
|
25
24
|
export declare function flattenTreeData(treeNodeList: any[], expandedKeys: Set<string>, keyMaps: KeyMapProps, filteredShownKeys?: boolean | Set<any>): any[];
|
|
26
25
|
export declare function convertJsonToData(treeJson: TreeDataSimpleJson): any[];
|
|
27
26
|
export interface TraversedNode {
|
|
@@ -53,10 +52,6 @@ export declare function calcMotionKeys(oldKeySet: Set<string>, newKeySet: Set<st
|
|
|
53
52
|
motionType: "show" | "hide";
|
|
54
53
|
motionKeys: string[];
|
|
55
54
|
};
|
|
56
|
-
/**
|
|
57
|
-
* @returns whether option includes searchValue.
|
|
58
|
-
* When filterTreeNode is a function,returns the result of filterTreeNode which called with (searchValue, target, option).
|
|
59
|
-
*/
|
|
60
55
|
export declare function matchTreeNode(searchValue: string, option: any, filterTreeNode: any, filterProps: any): any;
|
|
61
56
|
/** The node field a search keyword is matched against: the default 'label' follows keyMaps.label. */
|
|
62
57
|
export declare function getFilterProp(treeNodeFilterProp: string, keyMaps?: KeyMapProps): string;
|
package/dist/tree/tree-util.js
CHANGED
|
@@ -11,7 +11,6 @@ const DRAG_OFFSET = .45;
|
|
|
11
11
|
function getPosition(parentPos, index) {
|
|
12
12
|
return `${parentPos}-${index}`;
|
|
13
13
|
}
|
|
14
|
-
/** Flattens nested tree data into a list, as the virtual list renders it. */
|
|
15
14
|
function flattenTreeData(treeNodeList, expandedKeys, keyMaps, filteredShownKeys = false) {
|
|
16
15
|
const flattenList = [];
|
|
17
16
|
const filterSearch = Boolean(filteredShownKeys);
|
|
@@ -254,10 +253,6 @@ function calcMotionKeys(oldKeySet, newKeySet, keyEntities) {
|
|
|
254
253
|
motionKeys: diffKeys.length === 1 ? findDescendantKeys(diffKeys, keyEntities, false) : []
|
|
255
254
|
};
|
|
256
255
|
}
|
|
257
|
-
/**
|
|
258
|
-
* @returns whether option includes searchValue.
|
|
259
|
-
* When filterTreeNode is a function,returns the result of filterTreeNode which called with (searchValue, target, option).
|
|
260
|
-
*/
|
|
261
256
|
function matchTreeNode(searchValue, option, filterTreeNode, filterProps) {
|
|
262
257
|
if (!filterTreeNode) return true;
|
|
263
258
|
let filterFn = filterTreeNode;
|
|
@@ -124,7 +124,6 @@ export default class TreeSelectFoundation<P extends BasicTreeSelectProps = Basic
|
|
|
124
124
|
* that writes the result back settles.
|
|
125
125
|
*/
|
|
126
126
|
static deriveState(props: BasicTreeSelectProps, prevState: BasicTreeSelectInnerData): Partial<BasicTreeSelectInnerData> | null;
|
|
127
|
-
/** The state of a new TreeSelect: the empty state with what the props imply */
|
|
128
127
|
static getInitialState(props: BasicTreeSelectProps): BasicTreeSelectInnerData;
|
|
129
128
|
/** The keys the trigger shows: the selection, or in multiple mode the checked keys merged as onChange reports them */
|
|
130
129
|
static getTriggerKeys(props: Pick<BasicTreeSelectProps, 'multiple' | 'checkRelation' | 'autoMergeValue' | 'leafOnly'>, { checkedKeys, realCheckedKeys, keyEntities, selectedKeys }: Pick<BasicTreeSelectInnerData, 'selectedKeys' | 'checkedKeys' | 'realCheckedKeys' | 'keyEntities'>): string[];
|
|
@@ -139,7 +138,6 @@ export default class TreeSelectFoundation<P extends BasicTreeSelectProps = Basic
|
|
|
139
138
|
init(): void;
|
|
140
139
|
/** Writes the state derived from new props back, so handlers read what was rendered */
|
|
141
140
|
syncDerivedState: (derived: Partial<BasicTreeSelectInnerData>) => void;
|
|
142
|
-
/** Searches as if `value` were typed, opening the dropdown first */
|
|
143
141
|
search: (value: string) => void;
|
|
144
142
|
/** Focus entering the trigger (its search input, tags, clear button) or the dropdown from outside */
|
|
145
143
|
handleTriggerFocus: (e: FocusEvent) => void;
|
|
@@ -104,7 +104,6 @@ var TreeSelectFoundation = class TreeSelectFoundation extends BaseFoundation {
|
|
|
104
104
|
this.#blurPending = false;
|
|
105
105
|
this.adapter.notifyBlur(e);
|
|
106
106
|
}
|
|
107
|
-
/** Loads a node's children once, after it is expanded */
|
|
108
107
|
#handleNodeLoad(key, data) {
|
|
109
108
|
const { loadData } = this.getProps();
|
|
110
109
|
const { loadedKeys, loadingKeys } = this.getStates();
|
|
@@ -365,7 +364,6 @@ var TreeSelectFoundation = class TreeSelectFoundation extends BaseFoundation {
|
|
|
365
364
|
newState.prevProps = { ...props };
|
|
366
365
|
return newState;
|
|
367
366
|
}
|
|
368
|
-
/** The state of a new TreeSelect: the empty state with what the props imply */
|
|
369
367
|
static getInitialState(props) {
|
|
370
368
|
const state = {
|
|
371
369
|
inputTriggerFocus: false,
|
|
@@ -437,7 +435,6 @@ var TreeSelectFoundation = class TreeSelectFoundation extends BaseFoundation {
|
|
|
437
435
|
syncDerivedState = (derived) => {
|
|
438
436
|
this.adapter.updateState(derived);
|
|
439
437
|
};
|
|
440
|
-
/** Searches as if `value` were typed, opening the dropdown first */
|
|
441
438
|
search = (value) => {
|
|
442
439
|
if (!this.getState("isOpen")) this.#open();
|
|
443
440
|
this.#handleInputChange(value);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** `showTooltip` carries each framework's own tooltip config */
|
|
2
2
|
export interface EllipsisConfig<Tooltip> {
|
|
3
3
|
collapseText?: string;
|
|
4
4
|
collapsible?: boolean;
|
|
@@ -11,7 +11,6 @@ export interface EllipsisConfig<Tooltip> {
|
|
|
11
11
|
}
|
|
12
12
|
/** An unset field, or one explicitly undefined, takes the default; the expand and collapse texts default only when their button is enabled */
|
|
13
13
|
export declare function getEllipsisOpt<Tooltip>(ellipsis: EllipsisConfig<Tooltip> | boolean, expandStr: string, collapseStr: string): Required<Omit<EllipsisConfig<Tooltip>, 'expandText' | 'collapseText'>> & Pick<EllipsisConfig<Tooltip>, 'expandText' | 'collapseText'>;
|
|
14
|
-
/** Whether CSS can truncate the text; every other option needs the measured JS truncation */
|
|
15
14
|
export declare function canUseCSSEllipsis({ expandable, expandText, pos, suffix }: Pick<EllipsisConfig<unknown>, 'expandable' | 'expandText' | 'pos' | 'suffix'>, copyable: unknown): boolean;
|
|
16
15
|
/** Whether `node` is, or holds, a focusable item; the copy button is not the tab stop, so it does not count */
|
|
17
16
|
export declare function isInsideWidgetItem(node: HTMLElement, copy?: Node | null): boolean;
|
|
@@ -20,7 +19,6 @@ export declare function getRenderText(originEle: HTMLElement, rows: number, cont
|
|
|
20
19
|
expand: Node | null;
|
|
21
20
|
copy: Node | null;
|
|
22
21
|
}, suffix: string, ellipsisPos: string, isStrong: boolean): string;
|
|
23
|
-
/** Whether the text overflows: in width for a single row, in height for several rows */
|
|
24
22
|
export declare function isOverflowing(node: HTMLElement, rows: number): boolean;
|
|
25
23
|
/**
|
|
26
24
|
* The pending measurement frame, and the gate for ResizeObserver reports. The observer reports every newly
|
|
@@ -16,7 +16,6 @@ function getEllipsisOpt(ellipsis, expandStr, collapseStr) {
|
|
|
16
16
|
collapseText: config.collapseText ?? (config.collapsible ? collapseStr : void 0)
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
/** Whether CSS can truncate the text; every other option needs the measured JS truncation */
|
|
20
19
|
function canUseCSSEllipsis({ expandable, expandText, pos, suffix }, copyable) {
|
|
21
20
|
return !expandable && expandText === void 0 && !copyable && pos === "end" && !suffix;
|
|
22
21
|
}
|
|
@@ -115,7 +114,6 @@ function isSingleRowOverflowing(containerNode) {
|
|
|
115
114
|
return acc + range.getBoundingClientRect().width;
|
|
116
115
|
}, 0) > contentAreaWidth;
|
|
117
116
|
}
|
|
118
|
-
/** Whether the text overflows: in width for a single row, in height for several rows */
|
|
119
117
|
function isOverflowing(node, rows) {
|
|
120
118
|
if (!rows || rows < 1) return false;
|
|
121
119
|
return rows <= 1 ? isSingleRowOverflowing(node) : node.scrollHeight > node.offsetHeight;
|
|
@@ -11,7 +11,7 @@ export declare const strings: {
|
|
|
11
11
|
FILE_STATUS_WAIT_UPLOAD: string;
|
|
12
12
|
FILE_LIST_PIC: "picture";
|
|
13
13
|
FILE_LIST_DEFAULT: "list";
|
|
14
|
-
LIST_TYPE: ("
|
|
14
|
+
LIST_TYPE: ("picture" | "list" | "none")[];
|
|
15
15
|
DRAG_AREA_DEFAULT: string;
|
|
16
16
|
DRAG_AREA_LEGAL: string;
|
|
17
17
|
TRIGGER_AUTO: "auto";
|
|
@@ -132,17 +132,13 @@ export interface UploadBaseState {
|
|
|
132
132
|
/** The uid of the item a pending replace will overwrite; the list may change while the user picks the file */
|
|
133
133
|
replaceUid: string;
|
|
134
134
|
cropperVisible: boolean;
|
|
135
|
-
/** The image file currently being cropped */
|
|
136
135
|
cropperFile: File | null;
|
|
137
|
-
/** Object URL for the image currently being cropped */
|
|
138
136
|
cropperSrc: string;
|
|
139
|
-
/** Remaining image files queued for cropping (cropped one at a time) */
|
|
140
137
|
pendingImageFiles: File[];
|
|
141
138
|
/** Non-image files that bypass cropping but are uploaded together */
|
|
142
139
|
nonImageFiles: File[];
|
|
143
140
|
/** Image files already cropped, accumulated until the queue drains */
|
|
144
141
|
croppedFiles: File[];
|
|
145
|
-
/** The round was started by a replace, so the result replaces one item */
|
|
146
142
|
isReplaceOperation: boolean;
|
|
147
143
|
}
|
|
148
144
|
export default class UploadFoundation<P extends UploadBaseProps = UploadBaseProps, S extends UploadBaseState = UploadBaseState, E extends UploadDragEvent = UploadDragEvent> extends BaseFoundation<UploadAdapter<P, S, E>, P, S> {
|
|
@@ -159,13 +155,11 @@ export default class UploadFoundation<P extends UploadBaseProps = UploadBaseProp
|
|
|
159
155
|
protected checkFileFormat(accept: string, file: File): boolean;
|
|
160
156
|
/** Closes the cropper and drops the queue; the files already cropped are discarded */
|
|
161
157
|
cancelCrop: () => void;
|
|
162
|
-
/** Crops the current image, then moves to the next queued one or adds every result once the queue drains */
|
|
163
158
|
confirmCrop: () => Promise<void>;
|
|
164
159
|
/** Keep the synchronous snapshot aligned with an externally controlled fileList. */
|
|
165
160
|
syncLatestFileList: (fileList: Array<BaseFileItem>) => void;
|
|
166
161
|
/** A fileList prop that goes back to undefined clears the list (a form reset) and leaves it uncontrolled */
|
|
167
162
|
handleFileListPropChange: (fileList?: Array<BaseFileItem>) => void;
|
|
168
|
-
/** The list on screen: the fileList prop when controlled, otherwise the fileList state. */
|
|
169
163
|
getFileList(): BaseFileItem[];
|
|
170
164
|
init(): void;
|
|
171
165
|
/** Adds the files of a paste on the page; the host listens only while addOnPasting is on and not disabled */
|
|
@@ -373,10 +373,7 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
373
373
|
this.adapter.updateDragAreaStatus(DRAG_AREA_DEFAULT);
|
|
374
374
|
this.adapter.notifyDrop(e, files, fileList);
|
|
375
375
|
}
|
|
376
|
-
/**
|
|
377
|
-
* Keeps the files accept allows and reports the others. When accept leaves nothing it returns undefined after
|
|
378
|
-
* calling `reset`: a remounted input fires change again when the same file is picked.
|
|
379
|
-
*/
|
|
376
|
+
/** When accept leaves nothing it returns undefined after calling `reset`: a remounted input fires change again when the same file is picked */
|
|
380
377
|
#acceptFiles(files, reset) {
|
|
381
378
|
const { accept } = this.getProps();
|
|
382
379
|
if (typeof accept === "undefined") return files;
|
|
@@ -428,7 +425,6 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
428
425
|
isReplaceOperation
|
|
429
426
|
});
|
|
430
427
|
}
|
|
431
|
-
/** Filters by accept, then crops the images (when `crop` is on and allowed) or adds the files to the list */
|
|
432
428
|
#selectFiles(currentFileList, allowCrop) {
|
|
433
429
|
let files = this.#acceptFiles(currentFileList, () => this.adapter.resetInput());
|
|
434
430
|
if (!files) return;
|
|
@@ -442,10 +438,6 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
442
438
|
}
|
|
443
439
|
this.#addSelected(files);
|
|
444
440
|
}
|
|
445
|
-
/**
|
|
446
|
-
* Pipeline for files that passed accept: transform and assign uid, flag invalid sizes, apply limit, add to the
|
|
447
|
-
* list; with uploadTrigger 'auto', each file with a valid size then goes through beforeUpload and the upload.
|
|
448
|
-
*/
|
|
449
441
|
#addSelected(selected) {
|
|
450
442
|
const { limit } = this.getProps();
|
|
451
443
|
const fileList = this.getFileList();
|
|
@@ -565,7 +557,6 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
565
557
|
this.adapter.resetInput();
|
|
566
558
|
this.adapter.resetReplaceInput();
|
|
567
559
|
};
|
|
568
|
-
/** Crops the current image, then moves to the next queued one or adds every result once the queue drains */
|
|
569
560
|
confirmCrop = async () => {
|
|
570
561
|
const { cropperFile, cropperSrc, pendingImageFiles, nonImageFiles, croppedFiles, isReplaceOperation } = this.getStates();
|
|
571
562
|
const { crop } = this.getProps();
|
|
@@ -608,7 +599,6 @@ var UploadFoundation = class extends BaseFoundation {
|
|
|
608
599
|
handleFileListPropChange = (fileList) => {
|
|
609
600
|
if (fileList === void 0) this.#updateFileListInternal([]);
|
|
610
601
|
};
|
|
611
|
-
/** The list on screen: the fileList prop when controlled, otherwise the fileList state. */
|
|
612
602
|
getFileList() {
|
|
613
603
|
const props = this.getProps();
|
|
614
604
|
return props.fileList === void 0 ? this.getState("fileList") : props.fileList || [];
|
package/dist/upload/utils.d.ts
CHANGED
|
@@ -3,12 +3,7 @@ export declare const byteMB = 1048576;
|
|
|
3
3
|
export declare const addAreaControlAttributes: string[];
|
|
4
4
|
export declare function containsControl(node: HTMLElement): boolean;
|
|
5
5
|
export declare function containsName(node: HTMLElement): boolean;
|
|
6
|
-
/** The position of the card that holds `target`; -1 when it is outside the cards, like the clear button */
|
|
7
6
|
export declare function indexOfCard(cards: ArrayLike<Element>, target: Node): number;
|
|
8
|
-
/**
|
|
9
|
-
* Where focus goes once the control that held it left the list (a card removed, cleared, retried or replaced): the
|
|
10
|
-
* remove button of the card now at `index`, else of the last card, else the add area.
|
|
11
|
-
*/
|
|
12
7
|
export declare function getFocusHandoverTarget(cards: ArrayLike<Element>, index: number, addArea: HTMLElement | null): HTMLElement | null;
|
|
13
8
|
/**
|
|
14
9
|
* Remembers which control in the file list held focus. Removing, clearing, retrying or replacing a file (or disabling
|
package/dist/upload/utils.js
CHANGED
|
@@ -17,14 +17,9 @@ function containsControl(node) {
|
|
|
17
17
|
function containsName(node) {
|
|
18
18
|
return (node.textContent ?? "").trim() !== "" || node.querySelector("[aria-label],[aria-labelledby],[alt]") !== null;
|
|
19
19
|
}
|
|
20
|
-
/** The position of the card that holds `target`; -1 when it is outside the cards, like the clear button */
|
|
21
20
|
function indexOfCard(cards, target) {
|
|
22
21
|
return Array.from(cards).findIndex((card) => card.contains(target));
|
|
23
22
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Where focus goes once the control that held it left the list (a card removed, cleared, retried or replaced): the
|
|
26
|
-
* remove button of the card now at `index`, else of the last card, else the add area.
|
|
27
|
-
*/
|
|
28
23
|
function getFocusHandoverTarget(cards, index, addArea) {
|
|
29
24
|
const card = index >= 0 ? cards[Math.min(index, cards.length - 1)] : void 0;
|
|
30
25
|
const cardTarget = card && (card.querySelector(`.${cssClasses.PREFIX}-file-card-close, .${cssClasses.PREFIX}-picture-file-card-close`) ?? FocusTrapHandle.getFocusableElements(card).find((node) => node instanceof HTMLElement));
|
|
@@ -9,12 +9,10 @@ export interface UserGuideAdapter<P extends UserGuideBaseProps = UserGuideBasePr
|
|
|
9
9
|
disabledBodyScroll: () => void;
|
|
10
10
|
enabledBodyScroll: () => void;
|
|
11
11
|
}
|
|
12
|
-
/** The props the foundation reads */
|
|
13
12
|
export interface UserGuideBaseProps {
|
|
14
13
|
current?: number;
|
|
15
14
|
steps: unknown[];
|
|
16
15
|
}
|
|
17
|
-
/** The state the foundation reads */
|
|
18
16
|
export interface UserGuideBaseState {
|
|
19
17
|
current: number;
|
|
20
18
|
}
|