@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
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { getDefaultFormatTokenByType } from "./get-default-format-token.js";
|
|
2
2
|
// src/date-picker/_utils/get-inset-input-format-token.ts
|
|
3
3
|
/**
|
|
4
|
-
* Get the placeholder of the insetInput input
|
|
5
|
-
*
|
|
6
4
|
* If type is time related, we only recognize the format like `dateFormat timeFormat`
|
|
7
5
|
* - 'yyyy-MM-dd HH:mm:ss' // ok
|
|
8
6
|
* - 'yyyy-MM-dd HH:mm:ss' // bad format
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { isValid, parse, parseISO } from "date-fns";
|
|
2
2
|
// src/date-picker/_utils/parser.ts
|
|
3
|
-
/**
|
|
4
|
-
* @file
|
|
5
|
-
* Various date-related analysis methods
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Parsing value to Date object
|
|
9
|
-
*/
|
|
10
3
|
function compatibleParse(value, formatToken, baseDate, locale) {
|
|
11
4
|
let result = null;
|
|
12
5
|
if (value) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Type } from "../input-foundation.js";
|
|
2
|
-
/** dateRange, dateTimeRange and monthRange select a start and an end */
|
|
3
2
|
export declare function isRangeType(type?: Type): boolean;
|
|
4
3
|
/** `multiple` applies to the date type only; the other types ignore it */
|
|
5
4
|
export declare function isMultiple({ type, multiple }: {
|
|
@@ -12,7 +11,6 @@ export declare function needConfirm({ type, needConfirm: confirm }: {
|
|
|
12
11
|
type?: Type;
|
|
13
12
|
needConfirm?: boolean;
|
|
14
13
|
}): boolean;
|
|
15
|
-
/** These types pick in the year and month panel instead of the day grid */
|
|
16
14
|
export declare function isYearOrMonthType(type?: Type): type is "month" | "year" | "monthRange";
|
|
17
15
|
/** monthRange shows its range in one trigger input; the other range types split it into a start and an end input */
|
|
18
16
|
export declare function isSplitRangeInputs(type?: Type): boolean;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import isValidDate from "./is-valid-date.js";
|
|
2
2
|
// src/date-picker/_utils/picker-type.ts
|
|
3
|
-
/** dateRange, dateTimeRange and monthRange select a start and an end */
|
|
4
3
|
function isRangeType(type) {
|
|
5
4
|
return typeof type === "string" && type.endsWith("Range");
|
|
6
5
|
}
|
|
@@ -15,7 +14,6 @@ function isDateTimeType(type) {
|
|
|
15
14
|
function needConfirm({ type, needConfirm: confirm }) {
|
|
16
15
|
return isDateTimeType(type) && confirm === true;
|
|
17
16
|
}
|
|
18
|
-
/** These types pick in the year and month panel instead of the day grid */
|
|
19
17
|
function isYearOrMonthType(type) {
|
|
20
18
|
return type === "year" || type === "month" || type === "monthRange";
|
|
21
19
|
}
|
|
@@ -5,7 +5,6 @@ import { Type } from "../input-foundation.js";
|
|
|
5
5
|
* zonedTimeToUtc(a, "+09:00") turns it into 21:00 (+8), i.e. 22:00 in +9.
|
|
6
6
|
*/
|
|
7
7
|
export declare function toCallbackDates(value: Date | Date[], timeZone?: string | number): Date[];
|
|
8
|
-
/** Builds the date and string arguments of the callbacks, with the dates converted by `toCallbackDates` */
|
|
9
8
|
export default function toCallbackArgs(value: Date | Date[], options: {
|
|
10
9
|
type?: Type;
|
|
11
10
|
format?: string;
|
|
@@ -13,7 +13,6 @@ function toCallbackDates(value, timeZone) {
|
|
|
13
13
|
const dates = Array.isArray(value) ? value : value && [value] || [];
|
|
14
14
|
return isValidTimeZone(timeZone) ? dates.map((date) => zonedTimeToUtc(date, timeZone)) : dates;
|
|
15
15
|
}
|
|
16
|
-
/** Builds the date and string arguments of the callbacks, with the dates converted by `toCallbackDates` */
|
|
17
16
|
function toCallbackArgs(value, options) {
|
|
18
17
|
const { type, format: format$1, timeZone, dateFnsLocale } = options;
|
|
19
18
|
const dates = toCallbackDates(value, timeZone);
|
|
@@ -94,7 +94,6 @@ $module-list: #{$prefix}-scrolllist;
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
// With a left or right preset panel and no inset input, the month panel gets a fixed height
|
|
98
97
|
&[x-preset-position='left'][x-insetinput='false'],
|
|
99
98
|
&[x-preset-position='right'][x-insetinput='false'] {
|
|
100
99
|
.#{$module}-month {
|
|
@@ -1229,7 +1228,6 @@ $module-list: #{$prefix}-scrolllist;
|
|
|
1229
1228
|
}
|
|
1230
1229
|
}
|
|
1231
1230
|
|
|
1232
|
-
// Keeps the year/month ScrollList from scrolling when the number of weeks changes the height
|
|
1233
1231
|
&[x-panel-yearandmonth-open-type='left'],
|
|
1234
1232
|
&[x-panel-yearandmonth-open-type='right'] {
|
|
1235
1233
|
.#{$module}-weeks {
|
|
@@ -1604,7 +1602,6 @@ $module-list: #{$prefix}-scrolllist;
|
|
|
1604
1602
|
|
|
1605
1603
|
&-dateTimeRange {
|
|
1606
1604
|
width: max-content;
|
|
1607
|
-
// Capped at the viewport limit so min-width never exceeds max-width (forced overflow)
|
|
1608
1605
|
min-width: min(#{$width-datepicker_panel_compact * 2}, #{$compact-max-width});
|
|
1609
1606
|
max-width: $compact-max-width;
|
|
1610
1607
|
|
|
@@ -25,9 +25,6 @@ export type DayStatusType = {
|
|
|
25
25
|
export type DisabledDateOptions = {
|
|
26
26
|
rangeStart?: string;
|
|
27
27
|
rangeEnd?: string;
|
|
28
|
-
/**
|
|
29
|
-
* current select of range type
|
|
30
|
-
*/
|
|
31
28
|
rangeInputFocus?: 'rangeStart' | 'rangeEnd' | false;
|
|
32
29
|
};
|
|
33
30
|
/** `null` start and end make a preset that clears the value */
|
|
@@ -135,10 +132,7 @@ export interface DatePickerFoundationProps extends ElementProps, RenderProps, Ev
|
|
|
135
132
|
/** filled by the framework from the LocaleProvider, not a component prop */
|
|
136
133
|
dateFnsLocale?: any;
|
|
137
134
|
rangeSeparator?: string;
|
|
138
|
-
/**
|
|
139
|
-
* Only for UI render. Keep `semi-foundation` framework-agnostic (no React types).
|
|
140
|
-
* `semi-ui-react` layer should declare this as `React.ReactNode`.
|
|
141
|
-
*/
|
|
135
|
+
/** `any` keeps the foundation framework-agnostic; each framework package declares its own node type */
|
|
142
136
|
rangeSeparatorNode?: any;
|
|
143
137
|
insetInput?: DateInputFoundationProps['insetInput'];
|
|
144
138
|
preventScroll?: boolean;
|
|
@@ -146,7 +140,7 @@ export interface DatePickerFoundationProps extends ElementProps, RenderProps, Ev
|
|
|
146
140
|
export interface DatePickerFoundationState {
|
|
147
141
|
panelShow: boolean;
|
|
148
142
|
isRange: boolean;
|
|
149
|
-
/**
|
|
143
|
+
/** `null` while the input shows the formatted value */
|
|
150
144
|
inputValue: string | null;
|
|
151
145
|
value: Date[];
|
|
152
146
|
cachedSelectedValue: (Date | null)[];
|
|
@@ -154,7 +148,6 @@ export interface DatePickerFoundationState {
|
|
|
154
148
|
/** `undefined` until a range input is focused or the value is set */
|
|
155
149
|
rangeInputFocus?: RangeInput | false;
|
|
156
150
|
autofocus: boolean;
|
|
157
|
-
/** value of inset input */
|
|
158
151
|
insetInputValue: InsetInputValue | null;
|
|
159
152
|
triggerDisabled: boolean | null;
|
|
160
153
|
/** which range inputs have been focused since the panel opened; a range closes once both have */
|
|
@@ -189,10 +182,6 @@ export interface DatePickerAdapter extends DefaultAdapter<DatePickerFoundationPr
|
|
|
189
182
|
setTriggerFocus: () => void;
|
|
190
183
|
blurFocusedElement: () => void;
|
|
191
184
|
}
|
|
192
|
-
/**
|
|
193
|
-
* Keeps the date value and the input text in sync: a selected date updates the input text, and a valid input text
|
|
194
|
-
* updates the date value; both notify the change.
|
|
195
|
-
*/
|
|
196
185
|
export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapter, DatePickerFoundationProps, DatePickerFoundationState> {
|
|
197
186
|
#private;
|
|
198
187
|
/**
|
|
@@ -230,10 +219,7 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
230
219
|
static disposeDateFn<R>(timeZone: string | number | undefined, fn: (date: any, ...rest: any) => R, date: Date | Date[], ...rest: any[]): R;
|
|
231
220
|
/** A controlled `open` is not copied into state; a disabled picker shows no panel */
|
|
232
221
|
static isPanelShown(props: Pick<DatePickerFoundationProps, 'open' | 'disabled'>, state: Pick<DatePickerFoundationState, 'panelShow'>): boolean;
|
|
233
|
-
/**
|
|
234
|
-
* The props derived from others. The rtl default of `position` stays with the
|
|
235
|
-
* frameworks, which read the direction from their config.
|
|
236
|
-
*/
|
|
222
|
+
/** The rtl default of `position` stays with the frameworks, which read the direction from their config. */
|
|
237
223
|
static normalizeProps<P extends string = Position>({ type, format, rangeSeparator, insetInput, position, spacing }: Pick<DatePickerFoundationProps, 'type' | 'format' | 'rangeSeparator' | 'insetInput' | 'spacing'> & {
|
|
238
224
|
position?: P;
|
|
239
225
|
}): {
|
|
@@ -248,7 +234,6 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
248
234
|
* than `getProp` and `getProps`.
|
|
249
235
|
*
|
|
250
236
|
* @param props the props with the defaults applied and `timeZone` resolved from the ConfigProvider
|
|
251
|
-
* @returns `value`, `cachedSelectedValue`, `rangeInputFocus`, `inputValue` and `prevTimeZone`
|
|
252
237
|
*/
|
|
253
238
|
static getInitialState(props: DatePickerFoundationProps): Pick<DatePickerFoundationState, 'value' | 'cachedSelectedValue' | 'rangeInputFocus' | 'inputValue' | 'prevTimeZone'>;
|
|
254
239
|
init(): void;
|
|
@@ -274,9 +259,6 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
274
259
|
/** Whether the range input other than `currentRangeInput` has been focused since the panel opened */
|
|
275
260
|
hasOtherRangeInputBeenFocused: (currentRangeInput: RangeInput) => boolean;
|
|
276
261
|
handleInputChange: (input: string, e: unknown) => void;
|
|
277
|
-
/**
|
|
278
|
-
* Always updates insetInputValue; inputValue and value are updated only when the text parses to a valid date.
|
|
279
|
-
*/
|
|
280
262
|
handleInsetInputChange: ({ insetInputStr, format, insetInputValue }: {
|
|
281
263
|
insetInputStr: string;
|
|
282
264
|
format: string;
|
|
@@ -313,7 +295,6 @@ export default class DatePickerFoundation extends BaseFoundation<DatePickerAdapt
|
|
|
313
295
|
disabledDisposeDate: (date: Date, ...rest: any[]) => boolean;
|
|
314
296
|
disabledDisposeTime: (date: Date | Date[], ...rest: any[]) => ReturnType<DisabledTimeType>;
|
|
315
297
|
/**
|
|
316
|
-
* Opens the panel on trigger click and, for range types, focuses rangeStart when no range input is focused.
|
|
317
298
|
* Non-range triggers are native inputs that already handle focus. isEventTarget tells a click on the input
|
|
318
299
|
* wrapper itself from one bubbled up from a child, which already handled focus.
|
|
319
300
|
*/
|
|
@@ -17,10 +17,6 @@ import toCallbackArgs, { toCallbackDates } from "./_utils/to-callback-args.js";
|
|
|
17
17
|
import { isEqual } from "es-toolkit";
|
|
18
18
|
import { format, isDate, isEqual as isEqual$1, isSameSecond, isValid, startOfDay } from "date-fns";
|
|
19
19
|
// src/date-picker/foundation.ts
|
|
20
|
-
/**
|
|
21
|
-
* Keeps the date value and the input text in sync: a selected date updates the input text, and a valid input text
|
|
22
|
-
* updates the date value; both notify the change.
|
|
23
|
-
*/
|
|
24
20
|
var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
25
21
|
#focusRecordTimers = /* @__PURE__ */ new Set();
|
|
26
22
|
#initialized = false;
|
|
@@ -189,17 +185,6 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
189
185
|
this.adapter.updateInputValue(null);
|
|
190
186
|
this.adapter.updateInsetInputValue(null);
|
|
191
187
|
}
|
|
192
|
-
/**
|
|
193
|
-
* Parses a multiple input part by part with `parse`; an empty or unparsable part, or more than `max` dates,
|
|
194
|
-
* gives `[]`. `parseInputLoose` as `parse` keeps `null` for a half typed date.
|
|
195
|
-
*
|
|
196
|
-
* @example
|
|
197
|
-
* ```javascript
|
|
198
|
-
* this.#parseMultipleInput('2021-01-01,2021-10-15', parseInputLoose); // [Date, Date];
|
|
199
|
-
* this.#parseMultipleInput('2021-01-01,2021-10-', parseInputLoose); // [Date, null];
|
|
200
|
-
* this.#parseMultipleInput('', parseInputLoose); // [];
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
188
|
#parseMultipleInput(input, parse, { needDedupe = false } = {}) {
|
|
204
189
|
const max = this.getProp("max");
|
|
205
190
|
const result = [];
|
|
@@ -367,10 +352,7 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
367
352
|
static isPanelShown(props, state) {
|
|
368
353
|
return (props.open !== void 0 ? Boolean(props.open) : Boolean(state.panelShow)) && !props.disabled;
|
|
369
354
|
}
|
|
370
|
-
/**
|
|
371
|
-
* The props derived from others. The rtl default of `position` stays with the
|
|
372
|
-
* frameworks, which read the direction from their config.
|
|
373
|
-
*/
|
|
355
|
+
/** The rtl default of `position` stays with the frameworks, which read the direction from their config. */
|
|
374
356
|
static normalizeProps({ type, format, rangeSeparator, insetInput, position, spacing }) {
|
|
375
357
|
const hasNoTime = typeof format === "string" && format && !/[Hhms]+/.test(format);
|
|
376
358
|
const normalizedType = hasNoTime && type === "dateTime" ? "date" : hasNoTime && type === "dateTimeRange" ? "dateRange" : type;
|
|
@@ -388,7 +370,6 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
388
370
|
* than `getProp` and `getProps`.
|
|
389
371
|
*
|
|
390
372
|
* @param props the props with the defaults applied and `timeZone` resolved from the ConfigProvider
|
|
391
|
-
* @returns `value`, `cachedSelectedValue`, `rangeInputFocus`, `inputValue` and `prevTimeZone`
|
|
392
373
|
*/
|
|
393
374
|
static getInitialState(props) {
|
|
394
375
|
const reader = new DatePickerFoundation({
|
|
@@ -515,9 +496,6 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
515
496
|
}
|
|
516
497
|
} else this.adapter.updateInputValue(input);
|
|
517
498
|
};
|
|
518
|
-
/**
|
|
519
|
-
* Always updates insetInputValue; inputValue and value are updated only when the text parses to a valid date.
|
|
520
|
-
*/
|
|
521
499
|
handleInsetInputChange = ({ insetInputStr, format, insetInputValue }) => {
|
|
522
500
|
const _isMultiple = this.#isMultiple();
|
|
523
501
|
const result = _isMultiple ? this.#parseMultipleInput(insetInputStr, (part) => this.parseInput(part, format)) : this.parseInput(insetInputStr, format);
|
|
@@ -686,7 +664,6 @@ var DatePickerFoundation = class DatePickerFoundation extends BaseFoundation {
|
|
|
686
664
|
return DatePickerFoundation.disposeDateFn(this.getProp("timeZone"), this.getProp("disabledTime"), date, ...rest);
|
|
687
665
|
};
|
|
688
666
|
/**
|
|
689
|
-
* Opens the panel on trigger click and, for range types, focuses rangeStart when no range input is focused.
|
|
690
667
|
* Non-range triggers are native inputs that already handle focus. isEventTarget tells a click on the input
|
|
691
668
|
* wrapper itself from one bubbled up from a child, which already handled focus.
|
|
692
669
|
*/
|
|
@@ -3,7 +3,6 @@ import { Locale } from "../locale/interface.js";
|
|
|
3
3
|
import { strings } from "./constants.js";
|
|
4
4
|
import { BaseValueType, ValidateStatus, ValueType } from "./foundation.js";
|
|
5
5
|
export type Type = 'date' | 'dateRange' | 'year' | 'month' | 'dateTime' | 'dateTimeRange' | 'monthRange';
|
|
6
|
-
/** The range input, start or end, that a focus or a value belongs to */
|
|
7
6
|
export type RangeInput = 'rangeStart' | 'rangeEnd';
|
|
8
7
|
export type PanelType = 'left' | 'right';
|
|
9
8
|
export interface DateInputEventHandlerProps {
|
|
@@ -42,10 +41,7 @@ export interface DateInputFoundationProps extends DateInputElementProps, DateInp
|
|
|
42
41
|
validateStatus?: ValidateStatus;
|
|
43
42
|
prefixCls?: string;
|
|
44
43
|
rangeSeparator?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Only for UI render. Keep `semi-foundation` framework-agnostic (no React types).
|
|
47
|
-
* `semi-ui-react` layer should declare this as `React.ReactNode`.
|
|
48
|
-
*/
|
|
44
|
+
/** `any` keeps the foundation framework-agnostic; each framework package declares its own node type */
|
|
49
45
|
rangeSeparatorNode?: any;
|
|
50
46
|
panelType?: PanelType;
|
|
51
47
|
insetInput?: boolean | InsetInputProps;
|
|
@@ -88,9 +84,7 @@ export interface DateInputAdapter extends DefaultAdapter<DateInputFoundationProp
|
|
|
88
84
|
type InputProps = Pick<DateInputFoundationProps, 'type' | 'format' | 'rangeSeparator' | 'dateFnsLocale'>;
|
|
89
85
|
export default class InputFoundation extends BaseFoundation<DateInputAdapter, DateInputFoundationProps, Record<string, never>> {
|
|
90
86
|
#private;
|
|
91
|
-
/** The text the trigger input shows for `value` */
|
|
92
87
|
static formatShowText({ type, dateFnsLocale, format, rangeSeparator }: InputProps, value: BaseValueType[], customFormat?: string): string;
|
|
93
|
-
/** The trigger text: the text being typed, else `value` formatted */
|
|
94
88
|
static getShowText(props: InputProps & {
|
|
95
89
|
inputValue?: string | null;
|
|
96
90
|
value?: BaseValueType[];
|
|
@@ -42,7 +42,6 @@ var InputFoundation = class InputFoundation extends BaseFoundation {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
/** The text the trigger input shows for `value` */
|
|
46
45
|
static formatShowText({ type, dateFnsLocale, format, rangeSeparator }, value, customFormat) {
|
|
47
46
|
const formatToken = customFormat || format || getDefaultFormatTokenByType(type);
|
|
48
47
|
switch (type) {
|
|
@@ -59,7 +58,6 @@ var InputFoundation = class InputFoundation extends BaseFoundation {
|
|
|
59
58
|
default: return "";
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
|
-
/** The trigger text: the text being typed, else `value` formatted */
|
|
63
61
|
static getShowText(props) {
|
|
64
62
|
if (props.inputValue != null) return props.inputValue;
|
|
65
63
|
return props.value?.length ? InputFoundation.formatShowText(props, props.value) : "";
|
|
@@ -26,7 +26,6 @@ export interface MonthFoundationProps {
|
|
|
26
26
|
renderFullDate: RenderFullDateType;
|
|
27
27
|
hoverDay: string;
|
|
28
28
|
rangeInputFocus: string | boolean;
|
|
29
|
-
/** which range inputs have been focused since the panel opened */
|
|
30
29
|
focusRecords: FocusRecords;
|
|
31
30
|
locale: any;
|
|
32
31
|
multiple: boolean;
|
|
@@ -48,10 +47,8 @@ export interface MonthTable {
|
|
|
48
47
|
export type DayStatusOptions = Pick<MonthFoundationProps, 'selected' | 'rangeStart' | 'rangeEnd' | 'offsetRangeStart' | 'offsetRangeEnd' | 'disabledDate' | 'hoverDay' | 'rangeInputFocus' | 'focusRecords'> & {
|
|
49
48
|
todayText: string;
|
|
50
49
|
};
|
|
51
|
-
/** The pure computations behind one month grid of the DatePicker panel */
|
|
52
50
|
export default class CalendarMonthFoundation {
|
|
53
51
|
#private;
|
|
54
|
-
/** The weekday keys of a row, starting from `weekStartsOn` */
|
|
55
52
|
static getWeekdays(weekStartsOn: WeekStartNumber): string[];
|
|
56
53
|
static getMonthTable(month: Date, weekStartsOn: WeekStartNumber): MonthTable;
|
|
57
54
|
/**
|
|
@@ -13,7 +13,6 @@ const MONTH_SWITCHES = {
|
|
|
13
13
|
1: "nextMonth",
|
|
14
14
|
12: "nextYear"
|
|
15
15
|
};
|
|
16
|
-
/** The pure computations behind one month grid of the DatePicker panel */
|
|
17
16
|
var CalendarMonthFoundation = class CalendarMonthFoundation {
|
|
18
17
|
static #getSingleDayStatus(fullDate, { todayText, selected, disabledDate, rangeStart, rangeEnd, rangeInputFocus, focusRecords }) {
|
|
19
18
|
const disabledOptions = {
|
|
@@ -110,7 +109,6 @@ var CalendarMonthFoundation = class CalendarMonthFoundation {
|
|
|
110
109
|
isInOffsetRange
|
|
111
110
|
};
|
|
112
111
|
}
|
|
113
|
-
/** The weekday keys of a row, starting from `weekStartsOn` */
|
|
114
112
|
static getWeekdays(weekStartsOn) {
|
|
115
113
|
return getDayofWeek({ weekStartsOn });
|
|
116
114
|
}
|
|
@@ -95,13 +95,7 @@ export interface MonthsGridAdapter extends DefaultAdapter<MonthsGridFoundationPr
|
|
|
95
95
|
}
|
|
96
96
|
export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapter, MonthsGridFoundationProps, MonthsGridFoundationState> {
|
|
97
97
|
#private;
|
|
98
|
-
/**
|
|
99
|
-
* Shifts the other panel when the panel being changed lands on the other panel's month.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* - panelType=right, target=new Date('2022-09-01') and left panel is in '2022-09' => call it, left panel minus one month to '2022-08'
|
|
103
|
-
* - panelType=left, target=new Date('2021-12-01') and right panel is in '2021-12' => call it, right panel add one month to '2021-01'
|
|
104
|
-
*/
|
|
98
|
+
/** Shifts the other panel when the panel being changed lands on the other panel's month. */
|
|
105
99
|
protected handleSyncChangeMonths({ panelType, target }: {
|
|
106
100
|
panelType: PanelType;
|
|
107
101
|
target: Date;
|
|
@@ -115,7 +109,6 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
|
|
|
115
109
|
/** The time part of `format`, in the tokens the time panel uses */
|
|
116
110
|
static getValidTimeFormat(format?: string): string;
|
|
117
111
|
static getValidDateFormat(props: Pick<MonthsGridFoundationProps, 'format' | 'type'>): string;
|
|
118
|
-
/** The disabled hours, minutes and seconds `disabledTime` gives the time panel of `panelType` */
|
|
119
112
|
static calcDisabledTime({ disabledTime, type }: Pick<MonthsGridFoundationProps, 'disabledTime' | 'type'>, { rangeStart, rangeEnd, monthLeft }: Pick<MonthsGridFoundationState, 'rangeStart' | 'rangeEnd' | 'monthLeft'>, panelType: PanelType): {
|
|
120
113
|
disabledHours?: () => number[];
|
|
121
114
|
disabledMinutes?: (hour: number) => number[];
|
|
@@ -126,11 +119,9 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
|
|
|
126
119
|
* number of weeks makes the scroll list unstable
|
|
127
120
|
*/
|
|
128
121
|
static getYAMOpenType(state: Pick<MonthsGridFoundationState, 'monthLeft' | 'monthRight'>): "left" | "right" | "none" | "both";
|
|
129
|
-
/** The panel shows a scroll list, its year and month picker or its time picker, instead of the month */
|
|
130
122
|
static isYearOrTime(panel: PanelState): boolean;
|
|
131
123
|
/** The `x-open-type` of a panel: what it shows in place of, or beside, its month */
|
|
132
124
|
static getOpenType(panel: PanelState): "time" | "date" | "year";
|
|
133
|
-
/** The title of a month in the navigation, from the locale's `monthText` pattern */
|
|
134
125
|
static formatMonthText(locale: Pick<Locale['DatePicker'], 'monthText' | 'months'>, month?: Date): string;
|
|
135
126
|
/** The texts of a panel's date and time switch; the date is the picked range endpoint, else the shown date */
|
|
136
127
|
static getSwitchTexts({ rangeEndpoint, showDate, dateFormat, format: formatProp, locale, dateFnsLocale }: {
|
|
@@ -295,13 +295,7 @@ var MonthsGridFoundation = class MonthsGridFoundation extends BaseFoundation {
|
|
|
295
295
|
});
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
/**
|
|
299
|
-
* Shifts the other panel when the panel being changed lands on the other panel's month.
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
* - panelType=right, target=new Date('2022-09-01') and left panel is in '2022-09' => call it, left panel minus one month to '2022-08'
|
|
303
|
-
* - panelType=left, target=new Date('2021-12-01') and right panel is in '2021-12' => call it, right panel add one month to '2021-01'
|
|
304
|
-
*/
|
|
298
|
+
/** Shifts the other panel when the panel being changed lands on the other panel's month. */
|
|
305
299
|
handleSyncChangeMonths({ panelType, target }) {
|
|
306
300
|
const { type } = this.adapter.getProps();
|
|
307
301
|
const { monthLeft, monthRight } = this.adapter.getStates();
|
|
@@ -372,7 +366,6 @@ var MonthsGridFoundation = class MonthsGridFoundation extends BaseFoundation {
|
|
|
372
366
|
static getValidDateFormat(props) {
|
|
373
367
|
return props.format || getDefaultFormatToken(props.type);
|
|
374
368
|
}
|
|
375
|
-
/** The disabled hours, minutes and seconds `disabledTime` gives the time panel of `panelType` */
|
|
376
369
|
static calcDisabledTime({ disabledTime, type }, { rangeStart, rangeEnd, monthLeft }, panelType) {
|
|
377
370
|
if (typeof disabledTime === "function" && panelType && isDateTimeType(type)) {
|
|
378
371
|
const selected = [];
|
|
@@ -396,7 +389,6 @@ var MonthsGridFoundation = class MonthsGridFoundation extends BaseFoundation {
|
|
|
396
389
|
else if (rightYearPickerOpen) return "right";
|
|
397
390
|
return "none";
|
|
398
391
|
}
|
|
399
|
-
/** The panel shows a scroll list, its year and month picker or its time picker, instead of the month */
|
|
400
392
|
static isYearOrTime(panel) {
|
|
401
393
|
return Boolean(panel && (panel.isTimePickerOpen || panel.isYearPickerOpen));
|
|
402
394
|
}
|
|
@@ -404,7 +396,6 @@ var MonthsGridFoundation = class MonthsGridFoundation extends BaseFoundation {
|
|
|
404
396
|
static getOpenType(panel) {
|
|
405
397
|
return panel.isYearPickerOpen ? "year" : panel.isTimePickerOpen ? "time" : "date";
|
|
406
398
|
}
|
|
407
|
-
/** The title of a month in the navigation, from the locale's `monthText` pattern */
|
|
408
399
|
static formatMonthText(locale, month) {
|
|
409
400
|
if (!month) return "";
|
|
410
401
|
const monthName = locale.months[month.getMonth() + 1];
|
|
@@ -8,7 +8,6 @@ export interface DragMoveAdapter<P extends DragMoveBaseProps = DragMoveBaseProps
|
|
|
8
8
|
notifyTouchEnd: (e: PointerEvent) => void;
|
|
9
9
|
notifyTouchCancel: (e: PointerEvent) => void;
|
|
10
10
|
}
|
|
11
|
-
/** The props the foundation reads with getProp */
|
|
12
11
|
export interface DragMoveBaseProps {
|
|
13
12
|
handler?: () => HTMLElement | null;
|
|
14
13
|
constrainer?: 'parent' | (() => HTMLElement | null);
|
|
@@ -11,12 +11,10 @@ export interface DropdownAdapter<P extends DropdownBaseProps = DropdownBaseProps
|
|
|
11
11
|
}
|
|
12
12
|
/** The members of a keyboard event the foundation reads; DOM events and React synthetic events both satisfy it */
|
|
13
13
|
type DropdownKeyEvent = Pick<KeyboardEvent, 'defaultPrevented' | 'key' | 'preventDefault' | 'stopPropagation' | 'target'>;
|
|
14
|
-
/** The props the foundation reads */
|
|
15
14
|
export interface DropdownBaseProps {
|
|
16
15
|
trigger?: string;
|
|
17
16
|
visible?: boolean;
|
|
18
17
|
}
|
|
19
|
-
/** The state the foundation reads */
|
|
20
18
|
export interface DropdownBaseState {
|
|
21
19
|
popVisible: boolean;
|
|
22
20
|
}
|
|
@@ -23,7 +23,6 @@ export interface DropdownMenuContext extends DirectionContext {
|
|
|
23
23
|
/** Id of the popup that renders the menu; its trigger carries it as data-popupid */
|
|
24
24
|
getPopupId?: () => string;
|
|
25
25
|
}
|
|
26
|
-
/** The adapter of a foundation that reads DropdownMenuContext */
|
|
27
26
|
export interface DropdownContextAdapter<P = object, S = object> extends DefaultAdapter<P, S, DropdownMenuContext> {}
|
|
28
27
|
/**
|
|
29
28
|
* Keyboard of a menu (WAI-ARIA APG menu pattern): arrows, Home and End move focus between the enabled items of this
|
|
@@ -9,7 +9,6 @@ export type FeedbackValue = CheckboxValue | CheckboxValue[] | EmojiResult;
|
|
|
9
9
|
/** Nothing chosen: null, undefined, an empty string or an empty array. 0 and false are real radio values. */
|
|
10
10
|
export declare function isFeedbackValueEmpty(value?: FeedbackValue | null): boolean;
|
|
11
11
|
type PromiseStatus = 'pending' | 'fulfilled' | 'rejected';
|
|
12
|
-
/** The state the foundation reads with getState */
|
|
13
12
|
export interface FeedbackBaseState {
|
|
14
13
|
value: FeedbackValue | null;
|
|
15
14
|
onOKReturnPromiseStatus?: PromiseStatus;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
@use 'semi:theme' as *;
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
$color-feedback_thank_text: var(--semi-color-text-2); // 感谢文字的文本颜色
|
|
4
4
|
|
|
5
|
-
// width
|
|
6
5
|
$width-feedback: 400px; // 除去文本类型外其他类型的宽度
|
|
7
6
|
$width-feedback_text: 600px; // 文本类型的宽度
|
|
8
7
|
|
|
9
|
-
// spacing
|
|
10
8
|
$spacing-feedback_emoji_container-columnGap: 24px; // emoji容器中emoji的间距
|
|
11
9
|
$spacing-feedback_emoji_container-marginY: 24px; // emoji容器的上下间距
|
|
12
10
|
$spacing-feedback_thank_text-marginTop: 24px; // 感谢文字的文本的顶部间距
|
|
@@ -16,11 +14,9 @@ $spacing-feedback_footer-columnGap: 12px; // 底部按钮的间距
|
|
|
16
14
|
$spacing-feedback_sidesheet_bottom-right: 20px; // 底部弹窗的右间距
|
|
17
15
|
$spacing-feedback_sidesheet_bottom_inner_wrap-bottom: 50px; // 底部弹窗的底部间距
|
|
18
16
|
|
|
19
|
-
// font
|
|
20
17
|
$font-feedback_emoji-fontSize: 36px; // emoji的大小
|
|
21
18
|
$font-feedback_thank_text-fontSize: $font-size-regular; // 感谢文字的文本大小
|
|
22
19
|
$font-feedback_thank_text-lineHeight: 20px; // 感谢文字的文本行高
|
|
23
20
|
$font-feedback_thank_text-fontWeight: $font-weight-regular; // 感谢文字的文本字体粗细
|
|
24
21
|
|
|
25
|
-
// radius
|
|
26
22
|
$radius-feedback_sidesheet_inner: 12px; // 底部弹窗的圆角
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
.semi-floatButton-default.semi-floatButton-round .semi-badge-dot,
|
|
65
65
|
.semi-floatButton-default.semi-floatButton-round .semi-badge-count {
|
|
66
66
|
inset-inline-end: 4.64px;
|
|
67
|
-
/* Badge center sits on the circle's diagonal: 0.29 * R, R = 0.5 * width */
|
|
68
67
|
top: 4.64px;
|
|
69
68
|
}
|
|
70
69
|
.semi-floatButton-small {
|
|
@@ -87,8 +87,6 @@ $moduleGroup: #{$prefix}-floatButtonGroup;
|
|
|
87
87
|
.#{$prefix}-badge-dot,
|
|
88
88
|
.#{$prefix}-badge-count {
|
|
89
89
|
inset-inline-end: calc(0.29 * 0.5 * $width-floatButton);
|
|
90
|
-
|
|
91
|
-
/* Badge center sits on the circle's diagonal: 0.29 * R, R = 0.5 * width */
|
|
92
90
|
top: calc(0.29 * 0.5 * $width-floatButton);
|
|
93
91
|
}
|
|
94
92
|
}
|
package/dist/form/form.scss
CHANGED
|
@@ -50,12 +50,6 @@ $rating: #{$prefix}-rating;
|
|
|
50
50
|
margin: 0;
|
|
51
51
|
overflow: hidden;
|
|
52
52
|
|
|
53
|
-
&[x-label-pos='top'] {
|
|
54
|
-
// .#{$col}-right,
|
|
55
|
-
// .#{$col}-left {
|
|
56
|
-
// width: 100%;
|
|
57
|
-
// }
|
|
58
|
-
}
|
|
59
53
|
.#{$col} {
|
|
60
54
|
&-right {
|
|
61
55
|
display: flex;
|
|
@@ -82,12 +76,6 @@ $rating: #{$prefix}-rating;
|
|
|
82
76
|
}
|
|
83
77
|
}
|
|
84
78
|
}
|
|
85
|
-
|
|
86
|
-
.#{$field}-pure {
|
|
87
|
-
// padding-top: 0;
|
|
88
|
-
// padding-bottom: 0;
|
|
89
|
-
// overflow: inherit;
|
|
90
|
-
}
|
|
91
79
|
}
|
|
92
80
|
|
|
93
81
|
&-field-label {
|
package/dist/form/foundation.js
CHANGED
|
@@ -192,19 +192,6 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
192
192
|
});
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
|
-
/**
|
|
196
|
-
* Case A:
|
|
197
|
-
* All fields: a[0]、a[1]、b.type、b.name[2]、b.name[0]
|
|
198
|
-
* input => output:
|
|
199
|
-
* a => a[0]、a[1]
|
|
200
|
-
* b => b.type、b.name[0]、b.name[2]
|
|
201
|
-
*
|
|
202
|
-
* Case B:
|
|
203
|
-
* All fields: activity.a[0]、activity.a[1]、activity.c、activity.d、other
|
|
204
|
-
* input => output:
|
|
205
|
-
* activity.a => activity.a[0]、activity.a[1]
|
|
206
|
-
*
|
|
207
|
-
*/
|
|
208
195
|
#getNestedField(path) {
|
|
209
196
|
const allRegisterField = this.#fields;
|
|
210
197
|
const allFieldPath = [...allRegisterField].map((item) => item[0]);
|
|
@@ -329,7 +316,6 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
329
316
|
if (!silent) this.#validations.set(field, validation);
|
|
330
317
|
return validation;
|
|
331
318
|
}
|
|
332
|
-
/** Resolves with the field's error value, undefined when valid */
|
|
333
319
|
#validateCustom(registration, value, opts) {
|
|
334
320
|
const { validate } = registration.getValidateOptions();
|
|
335
321
|
const epoch = this.#epoch;
|
|
@@ -508,7 +494,6 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
508
494
|
this.#forceUpdate();
|
|
509
495
|
return updateKey;
|
|
510
496
|
};
|
|
511
|
-
/** Inserts a row holding `rowValue` before `index`, or appends it without one */
|
|
512
497
|
#addArrayFieldRowWithValue = (arrayFieldPath, rowValue, index) => {
|
|
513
498
|
const values = this.#getValue(arrayFieldPath);
|
|
514
499
|
const rows = values ? values.slice() : [];
|
package/dist/form/interface.d.ts
CHANGED
|
@@ -52,35 +52,24 @@ export interface ValidateOptions<K extends keyof any = keyof any> {
|
|
|
52
52
|
silent?: boolean;
|
|
53
53
|
}
|
|
54
54
|
export interface BaseFormApi<T extends object = any> {
|
|
55
|
-
/** get value of field */
|
|
56
55
|
getValue: <P extends FieldPath<T>>(field?: P) => FieldPathValue<T, P>;
|
|
57
|
-
/** set value of field */
|
|
58
56
|
setValue: <K extends FieldPath<T>>(field: K, newFieldValue: any) => void;
|
|
59
|
-
/** get error of field */
|
|
60
57
|
getError: <K extends FieldPath<T>>(field: K) => any;
|
|
61
|
-
/** set error of field */
|
|
62
58
|
setError: <K extends FieldPath<T>>(field: K, fieldError: any) => void;
|
|
63
|
-
/** get touched of field */
|
|
64
59
|
getTouched: <K extends FieldPath<T>>(field: K) => boolean;
|
|
65
|
-
/**
|
|
60
|
+
/** A parent path takes the nested touched object of its fields */
|
|
66
61
|
setTouched: <K extends FieldPath<T>>(field: K, fieldTouch: boolean | Record<string, any>) => void;
|
|
67
|
-
/** judge field exist */
|
|
68
62
|
getFieldExist: <K extends FieldPath<T>>(field: K) => boolean;
|
|
69
|
-
/** get formState of form */
|
|
70
63
|
getFormState: () => FormState<T extends object ? T : object>;
|
|
71
|
-
/** get formProps of form */
|
|
72
64
|
getFormProps: (keys?: Array<string>) => ComponentProps;
|
|
73
|
-
/** submit form manual */
|
|
74
65
|
submitForm: () => void;
|
|
75
|
-
/** reset form manual */
|
|
76
66
|
reset: (fields?: Array<string>) => void;
|
|
77
|
-
/**
|
|
67
|
+
/** Resolves with the form values */
|
|
78
68
|
validate: <K extends FieldPath<T>>(fields?: Array<K> | ValidateOptions<K>) => Promise<T>;
|
|
79
69
|
/** Without a field, returns all the initial values */
|
|
80
70
|
getInitValue: <K extends FieldPath<T>>(field?: K) => any;
|
|
81
71
|
getInitValues: () => any;
|
|
82
72
|
getValues: () => T;
|
|
83
|
-
/** set value of multiple fields */
|
|
84
73
|
setValues: (fieldsValue: Partial<T>, config?: setValuesConfig) => void;
|
|
85
74
|
scrollToField: <K extends FieldPath<T>>(field: K, scrollConfig?: Options) => void;
|
|
86
75
|
scrollToError: <K extends FieldPath<T>>(config?: ScrollToErrorOptions<K>) => void;
|
|
@@ -112,7 +101,6 @@ export interface FieldValidateOptions {
|
|
|
112
101
|
transform?: (value: any) => any;
|
|
113
102
|
stopValidateWithError?: boolean;
|
|
114
103
|
}
|
|
115
|
-
/** A registered field: what the Form keeps per field to validate, reset and restore it */
|
|
116
104
|
export interface FieldRegistration {
|
|
117
105
|
/** Identifies the field component instance, which a remounted field of the same name does not share */
|
|
118
106
|
id: string;
|
|
@@ -143,7 +131,6 @@ export interface ArrayFieldRegistration {
|
|
|
143
131
|
updateKey?: number;
|
|
144
132
|
initValue?: any;
|
|
145
133
|
}
|
|
146
|
-
/** What fields and ArrayFields use to read and write the Form's state and to register themselves */
|
|
147
134
|
export interface FieldBridge {
|
|
148
135
|
register: (field: string, registration: FieldRegistration) => void;
|
|
149
136
|
unRegister: (field: string) => void;
|