@fibrae/semi-ui-svelte 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/_base/create-context.js +0 -1
- package/dist/_base/css-animation.js +0 -1
- package/dist/_base/group-role.d.ts +0 -1
- package/dist/_base/group-role.js +0 -1
- package/dist/_base/slot-kind.d.ts +0 -1
- package/dist/_base/slot-kind.js +0 -1
- package/dist/_base/teleport.d.ts +0 -2
- package/dist/_base/teleport.js +0 -2
- package/dist/_base/use-click-outside.svelte.d.ts +2 -2
- package/dist/_base/use-click-outside.svelte.js +2 -2
- package/dist/_base/use-foundation.svelte.js +2 -5
- package/dist/_base/virtual-list.svelte +2 -3
- package/dist/_base/virtual-list.svelte.d.ts +0 -1
- package/dist/_sortable/interface.d.ts +0 -1
- package/dist/anchor/interface.d.ts +0 -3
- package/dist/anchor/link-item.svelte +0 -1
- package/dist/anchor/links.d.ts +0 -1
- package/dist/anchor/links.js +0 -1
- package/dist/audio-player/audio-player.svelte +0 -2
- package/dist/audio-player/audio-slider.svelte +0 -3
- package/dist/auto-complete/auto-complete.svelte +0 -5
- package/dist/auto-complete/interface.d.ts +0 -9
- package/dist/avatar/avatar-group-more.svelte +0 -1
- package/dist/avatar/avatar.svelte +0 -4
- package/dist/avatar/context.d.ts +0 -1
- package/dist/avatar/interface.d.ts +0 -4
- package/dist/backtop/backtop.svelte +0 -2
- package/dist/backtop/interface.d.ts +0 -1
- package/dist/badge/interface.d.ts +0 -1
- package/dist/banner/banner.svelte +1 -1
- package/dist/banner/interface.d.ts +1 -3
- package/dist/breadcrumb/breadcrumb-item.svelte +0 -1
- package/dist/breadcrumb/breadcrumb.svelte +0 -1
- package/dist/breadcrumb/interface.d.ts +0 -7
- package/dist/calendar/calendar.svelte +0 -1
- package/dist/calendar/day-calendar.svelte +0 -3
- package/dist/calendar/interface.d.ts +0 -8
- package/dist/calendar/month-calendar.svelte +0 -4
- package/dist/calendar/time-grid.svelte +0 -2
- package/dist/calendar/time-grid.svelte.d.ts +0 -1
- package/dist/calendar/use-today.svelte.d.ts +0 -1
- package/dist/calendar/use-today.svelte.js +0 -1
- package/dist/card/index.js +0 -1
- package/dist/card/interface.d.ts +0 -3
- package/dist/carousel/carousel.svelte +0 -4
- package/dist/carousel/interface.d.ts +0 -3
- package/dist/cascader/cascader.svelte +0 -6
- package/dist/cascader/interface.d.ts +0 -19
- package/dist/cascader/item.svelte +0 -4
- package/dist/cascader/item.svelte.d.ts +0 -4
- package/dist/checkbox/checkbox-group.svelte +0 -3
- package/dist/checkbox/checkbox.svelte +0 -4
- package/dist/checkbox/index.js +0 -1
- package/dist/checkbox/interface.d.ts +0 -1
- package/dist/code-highlight/interface.d.ts +0 -1
- package/dist/collapse/collapse.svelte +0 -2
- package/dist/collapse/index.js +0 -1
- package/dist/collapse/interface.d.ts +0 -2
- package/dist/collapse/panel.svelte +0 -1
- package/dist/collapsible/collapsible.svelte +0 -2
- package/dist/color-picker/alpha-slider.svelte +0 -1
- package/dist/color-picker/color-choose-area.svelte +0 -1
- package/dist/color-picker/color-slider.svelte +0 -1
- package/dist/color-picker/data-part.svelte +0 -1
- package/dist/cropper/cropper.svelte +0 -1
- package/dist/cropper/interface.d.ts +0 -6
- package/dist/date-picker/date-input.svelte +0 -4
- package/dist/date-picker/date-picker.svelte +0 -7
- package/dist/date-picker/inset-input.svelte +0 -1
- package/dist/date-picker/interface.d.ts +0 -7
- package/dist/date-picker/internal.d.ts +0 -7
- package/dist/date-picker/month.svelte +0 -1
- package/dist/date-picker/months-grid.svelte +0 -6
- package/dist/date-picker/navigation.svelte +0 -1
- package/dist/descriptions/interface.d.ts +0 -1
- package/dist/divider/divider.svelte +0 -1
- package/dist/divider/interface.d.ts +0 -4
- package/dist/drag-move/drag-move.js +0 -1
- package/dist/drag-move/interface.d.ts +0 -3
- package/dist/dropdown/context.d.ts +0 -6
- package/dist/dropdown/context.js +0 -1
- package/dist/dropdown/dropdown-item.svelte +0 -1
- package/dist/dropdown/dropdown.svelte +0 -7
- package/dist/dropdown/interface.d.ts +0 -4
- package/dist/empty/empty.svelte +0 -1
- package/dist/empty/interface.d.ts +0 -3
- package/dist/feedback/feedback.svelte +0 -1
- package/dist/feedback/interface.d.ts +0 -8
- package/dist/float-button/float-button-action.svelte +0 -2
- package/dist/float-button/interface.d.ts +0 -2
- package/dist/form/array-field.svelte +0 -2
- package/dist/form/context.d.ts +0 -2
- package/dist/form/error-message.svelte +0 -1
- package/dist/form/field-grid.svelte +0 -2
- package/dist/form/field-grid.svelte.d.ts +0 -2
- package/dist/form/field-inner.svelte +0 -2
- package/dist/form/field.svelte +0 -1
- package/dist/form/form.svelte +0 -1
- package/dist/form/hooks.d.ts +1 -2
- package/dist/form/hooks.js +1 -2
- package/dist/form/interface.d.ts +0 -7
- package/dist/form/utils.d.ts +0 -1
- package/dist/form/utils.js +0 -2
- package/dist/highlight/interface.d.ts +0 -1
- package/dist/hot-keys/interface.d.ts +0 -1
- package/dist/image/context.d.ts +0 -1
- package/dist/image/footer.d.ts +0 -1
- package/dist/image/interface.d.ts +0 -8
- package/dist/image/preview-image.svelte +0 -3
- package/dist/image/preview-image.svelte.d.ts +0 -1
- package/dist/image/preview-inner.svelte +0 -3
- package/dist/image/preview-inner.svelte.d.ts +0 -1
- package/dist/input/context.d.ts +0 -1
- package/dist/input/interface.d.ts +0 -3
- package/dist/input/textarea.svelte +0 -3
- package/dist/input-number/input-number.svelte +0 -2
- package/dist/input-number/interface.d.ts +0 -1
- package/dist/json-viewer/interface.d.ts +0 -4
- package/dist/json-viewer/json-viewer.svelte +0 -3
- package/dist/layout/interface.d.ts +0 -2
- package/dist/list/interface.d.ts +0 -2
- package/dist/lottie/interface.d.ts +1 -1
- package/dist/markdown-render/code-text.js +0 -1
- package/dist/markdown-render/components/code.svelte +0 -1
- package/dist/markdown-render/components/heading.svelte +0 -1
- package/dist/markdown-render/components/p.svelte +0 -1
- package/dist/markdown-render/components/table.svelte +0 -1
- package/dist/markdown-render/components/tree.d.ts +0 -4
- package/dist/markdown-render/components/tree.js +0 -2
- package/dist/markdown-render/interface.d.ts +0 -1
- package/dist/markdown-render/markdown-children.svelte +0 -2
- package/dist/markdown-render/markdown-render.svelte +0 -1
- package/dist/markdown-render/runtime.js +0 -1
- package/dist/modal/confirm-modal.svelte +0 -1
- package/dist/modal/confirm.svelte.d.ts +0 -1
- package/dist/modal/confirm.svelte.js +0 -1
- package/dist/modal/index.js +0 -1
- package/dist/modal/interface.d.ts +0 -6
- package/dist/modal/modal-content.svelte +0 -4
- package/dist/modal/modal.svelte +0 -1
- package/dist/modal/use-show-hide.svelte.d.ts +0 -2
- package/dist/modal/use-show-hide.svelte.js +0 -4
- package/dist/navigation/context.d.ts +0 -2
- package/dist/navigation/index.js +0 -1
- package/dist/navigation/interface.d.ts +1 -17
- package/dist/navigation/item-shell.svelte +0 -4
- package/dist/navigation/item-shell.svelte.d.ts +0 -3
- package/dist/navigation/nav-footer.svelte +0 -2
- package/dist/navigation/nav-items.svelte +0 -1
- package/dist/navigation/nav.svelte +0 -1
- package/dist/navigation/sub-nav.svelte +0 -5
- package/dist/navigation/wrapper-outlet.svelte +0 -1
- package/dist/notification/context.d.ts +0 -3
- package/dist/notification/interface.d.ts +0 -5
- package/dist/notification/notice-list.svelte +0 -2
- package/dist/notification/notice-list.svelte.d.ts +0 -1
- package/dist/notification/notice.svelte +0 -2
- package/dist/notification/notification-list.svelte +0 -1
- package/dist/notification/static-api.js +0 -1
- package/dist/overflow-list/interface.d.ts +0 -2
- package/dist/overflow-list/overflow-list.svelte +0 -2
- package/dist/pagination/interface.d.ts +0 -1
- package/dist/pagination/pagination.svelte +0 -2
- package/dist/pagination/step-button.svelte +0 -3
- package/dist/pagination/step-button.svelte.d.ts +0 -1
- package/dist/pincode/interface.d.ts +0 -1
- package/dist/pincode/pincode.svelte +0 -3
- package/dist/popconfirm/interface.d.ts +0 -1
- package/dist/popconfirm/popconfirm.svelte +0 -2
- package/dist/popover/interface.d.ts +0 -1
- package/dist/popover/popover.svelte +0 -1
- package/dist/radio/index.js +0 -1
- package/dist/radio/radio-group.svelte +0 -1
- package/dist/radio/radio.svelte +0 -1
- package/dist/rating/interface.d.ts +0 -2
- package/dist/rating/item.svelte +0 -1
- package/dist/rating/rating.svelte +0 -7
- package/dist/resizable/interface.d.ts +0 -2
- package/dist/resizable/resizable.svelte +0 -1
- package/dist/resizable/resize-group.svelte +0 -1
- package/dist/resizable/resize-handler.svelte +0 -1
- package/dist/resize-observer/observe-resize.d.ts +1 -5
- package/dist/resize-observer/observe-resize.js +1 -5
- package/dist/scroll-list/index.js +0 -1
- package/dist/scroll-list/interface.d.ts +0 -2
- package/dist/scroll-list/scroll-item.svelte +0 -2
- package/dist/select/interface.d.ts +0 -14
- package/dist/select/option.svelte +0 -5
- package/dist/select/option.svelte.d.ts +0 -5
- package/dist/select/select.svelte +0 -14
- package/dist/side-sheet/interface.d.ts +0 -1
- package/dist/side-sheet/side-sheet.svelte +0 -9
- package/dist/skeleton/index.js +0 -1
- package/dist/skeleton/interface.d.ts +0 -2
- package/dist/skeleton/skeleton-item.svelte +0 -1
- package/dist/slider/interface.d.ts +0 -5
- package/dist/slider/slider.svelte +0 -7
- package/dist/space/interface.d.ts +0 -1
- package/dist/space/space.svelte +0 -1
- package/dist/steps/context.d.ts +0 -1
- package/dist/steps/interface.d.ts +0 -2
- package/dist/steps/step.svelte +0 -3
- package/dist/switch/switch.svelte +0 -2
- package/dist/table/body/base-row.svelte +0 -4
- package/dist/table/body/base-row.svelte.d.ts +0 -4
- package/dist/table/body/body.svelte +0 -7
- package/dist/table/body/body.svelte.d.ts +0 -5
- package/dist/table/body/expanded-row.svelte +0 -1
- package/dist/table/body/expanded-row.svelte.d.ts +0 -1
- package/dist/table/body/section-row.svelte +0 -2
- package/dist/table/body/section-row.svelte.d.ts +0 -2
- package/dist/table/column-filter-menu.svelte +0 -3
- package/dist/table/column-filter-menu.svelte.d.ts +0 -3
- package/dist/table/column-filter.svelte +0 -2
- package/dist/table/column-filter.svelte.d.ts +0 -2
- package/dist/table/column-selection.svelte +1 -2
- package/dist/table/column-selection.svelte.d.ts +0 -1
- package/dist/table/column-sorter.svelte +1 -6
- package/dist/table/column-sorter.svelte.d.ts +1 -6
- package/dist/table/context.d.ts +0 -10
- package/dist/table/context.js +0 -1
- package/dist/table/custom-expand-icon.svelte +0 -2
- package/dist/table/custom-expand-icon.svelte.d.ts +0 -2
- package/dist/table/head-table.svelte +0 -1
- package/dist/table/head-table.svelte.d.ts +0 -1
- package/dist/table/interface.d.ts +2 -21
- package/dist/table/table-cell.svelte +0 -7
- package/dist/table/table-cell.svelte.d.ts +0 -7
- package/dist/table/table-header-row.svelte +0 -2
- package/dist/table/table-header-row.svelte.d.ts +0 -2
- package/dist/table/table-pagination.svelte +0 -2
- package/dist/table/table-pagination.svelte.d.ts +0 -2
- package/dist/table/table.svelte +0 -5
- package/dist/table/utils.d.ts +1 -13
- package/dist/table/utils.js +1 -11
- package/dist/tabs/index.js +0 -1
- package/dist/tabs/interface.d.ts +0 -13
- package/dist/tabs/tab-bar.svelte +0 -3
- package/dist/tabs/tab-bar.svelte.d.ts +0 -1
- package/dist/tabs/tab-pane.svelte +0 -2
- package/dist/tabs/tabs.svelte +0 -1
- package/dist/tag-input/interface.d.ts +0 -5
- package/dist/tag-input/tag-input.svelte +0 -3
- package/dist/tag-input/tag-item.svelte +0 -1
- package/dist/tag-input/tag-item.svelte.d.ts +0 -1
- package/dist/time-picker/combobox.svelte +0 -1
- package/dist/time-picker/interface.d.ts +0 -9
- package/dist/time-picker/time-picker.svelte +0 -2
- package/dist/timeline/interface.d.ts +0 -4
- package/dist/timeline/timeline.svelte +0 -1
- package/dist/toast/context.d.ts +0 -2
- package/dist/toast/interface.d.ts +0 -2
- package/dist/toast/static-api.js +0 -1
- package/dist/toast/toast.svelte +0 -1
- package/dist/toast/use-toast.js +0 -1
- package/dist/tooltip/context.d.ts +0 -2
- package/dist/tooltip/interface.d.ts +0 -2
- package/dist/tooltip/tooltip.svelte +0 -5
- package/dist/transfer/interface.d.ts +1 -8
- package/dist/transfer/transfer-selected-item.svelte +0 -1
- package/dist/transfer/transfer-selected-item.svelte.d.ts +0 -1
- package/dist/transfer/transfer.svelte +0 -1
- package/dist/tree/auto-sizer.svelte +0 -1
- package/dist/tree/context.d.ts +0 -1
- package/dist/tree/interface.d.ts +0 -9
- package/dist/tree/node-collapsible.svelte +0 -1
- package/dist/tree/node-list.svelte +0 -4
- package/dist/tree/tree-node.svelte +0 -1
- package/dist/tree/tree.svelte +0 -3
- package/dist/tree/use-tree-keyboard.svelte.d.ts +1 -8
- package/dist/tree/use-tree-keyboard.svelte.js +1 -6
- package/dist/tree-select/interface.d.ts +0 -11
- package/dist/tree-select/tree-select.svelte +0 -2
- package/dist/typography/base.svelte +0 -2
- package/dist/typography/index.js +0 -1
- package/dist/typography/interface.d.ts +0 -1
- package/dist/typography/internal.d.ts +0 -2
- package/dist/upload/file-card.svelte +0 -1
- package/dist/upload/index.js +0 -1
- package/dist/upload/interface.d.ts +0 -4
- package/dist/upload/upload.svelte +0 -1
- package/dist/user-guide/interface.d.ts +0 -1
- package/dist/user-guide/user-guide.svelte +0 -1
- package/dist/video-player/video-progress.svelte +0 -2
- package/package.json +3 -3
|
@@ -10,7 +10,6 @@ import type { Locale } from '@fibrae/semi-foundation/locale/interface';
|
|
|
10
10
|
import type { InputSize, ValidateStatus } from '../input/index.js';
|
|
11
11
|
import type { DatePickerDateSnippetProps, DatePickerDensity, DatePickerFullDateSnippetProps, DatePickerInsetInputProps, DatePickerPresetPosition, DatePickerPresetsType, DatePickerTimePickerOpts, DatePickerValueType, DatePickerYearAndMonthOpts } from './interface.js';
|
|
12
12
|
export type DatePickerLocale = Locale['DatePicker'];
|
|
13
|
-
/** What DatePicker focuses: an Input of the trigger, or an inset input of the panel */
|
|
14
13
|
export interface DatePickerFocusTarget {
|
|
15
14
|
focus: (options?: FocusOptions) => void;
|
|
16
15
|
blur: () => void;
|
|
@@ -26,10 +25,8 @@ export interface NavigationProps {
|
|
|
26
25
|
locale: DatePickerLocale;
|
|
27
26
|
monthText?: string;
|
|
28
27
|
density?: DatePickerDensity;
|
|
29
|
-
/** Whether the two panels switch together (syncSwitchMonth) */
|
|
30
28
|
shouldBimonthSwitch?: boolean;
|
|
31
29
|
panelType?: PanelType;
|
|
32
|
-
/** id of the month button, which names the month grid */
|
|
33
30
|
titleId?: string;
|
|
34
31
|
onPrevYear: () => void;
|
|
35
32
|
onPrevMonth: () => void;
|
|
@@ -62,7 +59,6 @@ export interface MonthProps {
|
|
|
62
59
|
hoverDay: string;
|
|
63
60
|
rangeInputFocus: string | boolean;
|
|
64
61
|
focusRecords: FocusRecords;
|
|
65
|
-
/** id of the element naming the grid */
|
|
66
62
|
labelledby?: string;
|
|
67
63
|
date?: Snippet<[DatePickerDateSnippetProps]>;
|
|
68
64
|
fullDate?: Snippet<[DatePickerFullDateSnippetProps]>;
|
|
@@ -123,7 +119,6 @@ export interface MonthsGridProps {
|
|
|
123
119
|
focusRecords?: FocusRecords;
|
|
124
120
|
insetInput: boolean | DatePickerInsetInputProps;
|
|
125
121
|
presetPosition?: DatePickerPresetPosition;
|
|
126
|
-
/** Whether `quickControls` renders presets, which sets the panel's x-preset-position */
|
|
127
122
|
hasPresets?: boolean;
|
|
128
123
|
selectedValue?: (Date | null)[];
|
|
129
124
|
defaultPickerValue?: DatePickerValueType;
|
|
@@ -135,7 +130,6 @@ export interface MonthsGridProps {
|
|
|
135
130
|
quickControls?: Snippet;
|
|
136
131
|
date?: Snippet<[DatePickerDateSnippetProps]>;
|
|
137
132
|
fullDate?: Snippet<[DatePickerFullDateSnippetProps]>;
|
|
138
|
-
/** Whether the range input other than the given one has been focused since the panel opened */
|
|
139
133
|
hasOtherRangeInputBeenFocused?: (currentRangeInput: RangeInput) => boolean;
|
|
140
134
|
onChange: (value: Date[], options?: {
|
|
141
135
|
closePanel?: boolean;
|
|
@@ -180,7 +174,6 @@ export interface DateInputProps {
|
|
|
180
174
|
insetInputValue?: InsetInputValue | null;
|
|
181
175
|
defaultPickerValue?: DatePickerValueType;
|
|
182
176
|
density?: DatePickerDensity;
|
|
183
|
-
/** Attributes of the native input(s): the field state, the combobox role and the popup state */
|
|
184
177
|
controlAttrs?: Record<string, unknown>;
|
|
185
178
|
prefix?: Snippet;
|
|
186
179
|
insetLabel?: Snippet;
|
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
return [cssClasses.DAY, MonthFoundation.getDayClasses(statusOf(day), day.fullDate === activeDate)];
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
// a range keeps its value in rangeStart and rangeEnd, not in `selected`
|
|
66
65
|
const isSelected = (day: MonthDayInfo) => {
|
|
67
66
|
const status = statusOf(day);
|
|
68
67
|
return Boolean(status.isSelected || status.isSelectedStart || status.isSelectedEnd);
|
|
@@ -20,8 +20,6 @@
|
|
|
20
20
|
|
|
21
21
|
const titleId = $props.id();
|
|
22
22
|
let panelHeight = 0;
|
|
23
|
-
|
|
24
|
-
// The values the effects below last saw, to act on changes only
|
|
25
23
|
let syncedPickerValue: { value: MonthsGridProps['defaultPickerValue'] } | undefined;
|
|
26
24
|
let previousCount: number | undefined;
|
|
27
25
|
let panelSize = $state.raw<PanelSize>({ left: { minWidth: '', minHeight: '' }, right: { minWidth: '', minHeight: '' } });
|
|
@@ -59,8 +57,6 @@
|
|
|
59
57
|
const panelTypes = $derived<PanelType[]>(isRange ? [PANEL_TYPE_LEFT, PANEL_TYPE_RIGHT] : [PANEL_TYPE_LEFT]);
|
|
60
58
|
const dateFormat = $derived(MonthsGridFoundation.getValidDateFormat(props));
|
|
61
59
|
const hasTime = $derived(props.type.includes('Time'));
|
|
62
|
-
|
|
63
|
-
// Both panels show year or time lists in a range, which then share a minHeight
|
|
64
60
|
const scrollListCount = $derived(isRange ? Number(isYearOrTime(states().monthLeft)) + Number(isYearOrTime(states().monthRight)) : 0);
|
|
65
61
|
|
|
66
62
|
const detailOf = (panelType: PanelType) => {
|
|
@@ -116,7 +112,6 @@
|
|
|
116
112
|
}
|
|
117
113
|
};
|
|
118
114
|
|
|
119
|
-
// Panels share a minHeight only while both show scroll lists, so only the cached height is updated here
|
|
120
115
|
const handleWeeksRowNumChange = () => {
|
|
121
116
|
if (isRange && !(isYearOrTime(states().monthLeft) && isYearOrTime(states().monthRight))) {
|
|
122
117
|
panelHeight = scrollListHeight();
|
|
@@ -172,7 +167,6 @@
|
|
|
172
167
|
untrack(() => void syncScrollLists(previous, count));
|
|
173
168
|
});
|
|
174
169
|
|
|
175
|
-
// The panel size follows the views each panel shows, measured once the DOM shows them
|
|
176
170
|
$effect(() => {
|
|
177
171
|
void states().monthLeft;
|
|
178
172
|
void states().monthRight;
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
const iconSize = $derived(density === 'compact' ? 'default' : 'large');
|
|
12
12
|
const buttonSize = $derived(density === 'compact' ? 'small' : 'default');
|
|
13
13
|
|
|
14
|
-
// `visibility: hidden` keeps the icons in position
|
|
15
14
|
const hidden = (side: string) => {
|
|
16
15
|
return shouldBimonthSwitch && panelType === side ? 'visibility: hidden' : undefined;
|
|
17
16
|
};
|
|
@@ -3,7 +3,6 @@ import type { HTMLAttributes } from 'svelte/elements';
|
|
|
3
3
|
export type DescriptionsAlign = 'center' | 'justify' | 'left' | 'plain';
|
|
4
4
|
export type DescriptionsLayout = 'horizontal' | 'vertical';
|
|
5
5
|
export type DescriptionsSize = 'small' | 'medium' | 'large';
|
|
6
|
-
/** An item of `data`; nodes for its key and value come from the `itemKey` and `value` snippets */
|
|
7
6
|
export interface DescriptionsData {
|
|
8
7
|
key?: string | number;
|
|
9
8
|
value?: string | number;
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
// A snippet cannot be inspected, so passing children is what makes a horizontal divider carry text
|
|
14
14
|
const withText = $derived(Boolean(children) && layout === 'horizontal');
|
|
15
15
|
|
|
16
|
-
// The user's style goes last so it can override the margin
|
|
17
16
|
const style = $derived.by(() => {
|
|
18
17
|
const length = toCssLength(margin);
|
|
19
18
|
const sides = length === undefined ? [] : layout === 'vertical' ? [`margin-left: ${length}`, `margin-right: ${length}`] : [`margin-top: ${length}`, `margin-bottom: ${length}`];
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
2
|
export interface DividerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'align'> {
|
|
3
|
-
/** The position of title inside divider */
|
|
4
3
|
align?: 'left' | 'right' | 'center';
|
|
5
|
-
/** Space between divider and surroundings */
|
|
6
4
|
margin?: number | string;
|
|
7
|
-
/** Whether line is dashed */
|
|
8
5
|
dashed?: boolean;
|
|
9
|
-
/** The direction type of divider */
|
|
10
6
|
layout?: 'horizontal' | 'vertical';
|
|
11
7
|
}
|
|
@@ -10,7 +10,6 @@ export default function dragMove(options = {}) {
|
|
|
10
10
|
return (element) => {
|
|
11
11
|
const { handler, onMouseDown, onMouseMove, onMouseUp, onTouchStart, onTouchMove, onTouchEnd, onTouchCancel, ...rest } = options;
|
|
12
12
|
const props = { ...rest, handler: typeof handler === 'object' ? () => handler : handler };
|
|
13
|
-
// the foundation reads neither state nor context
|
|
14
13
|
const adapter = {
|
|
15
14
|
getContext: () => undefined,
|
|
16
15
|
getContexts: () => ({}),
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
export interface DragMoveOptions {
|
|
2
|
-
/** The element that starts a drag, or a function returning it; defaults to the dragged element itself */
|
|
3
2
|
handler?: HTMLElement | (() => HTMLElement | null);
|
|
4
3
|
/** The element that bounds the movement; it needs a positioned layout */
|
|
5
4
|
constrainer?: 'parent' | (() => HTMLElement | null);
|
|
6
|
-
/** Whether pressing on a native input or textarea starts a drag */
|
|
7
5
|
allowInputDrag?: boolean;
|
|
8
6
|
/** Called when a pointer goes down: return `false` to not drag */
|
|
9
7
|
allowMove?: (e: PointerEvent, element: HTMLElement) => boolean;
|
|
10
|
-
/** Takes the new position instead of the element's top and left */
|
|
11
8
|
customMove?: (element: HTMLElement, top: number, left: number) => void;
|
|
12
9
|
/** `relative` keeps the element's place in the layout */
|
|
13
10
|
positionStrategy?: 'absolute' | 'relative';
|
|
@@ -2,24 +2,18 @@ import { SvelteMap } from 'svelte/reactivity';
|
|
|
2
2
|
import type { DropdownMenuContext, DropdownSelectionMode } from '@fibrae/semi-foundation/dropdown/menu-foundation';
|
|
3
3
|
import type { Trigger } from '../tooltip/index.js';
|
|
4
4
|
export interface DropdownContextView {
|
|
5
|
-
/** How many menus enclose this point: 1 inside a top-level menu */
|
|
6
5
|
readonly menuDepth: number;
|
|
7
6
|
readonly showTick: boolean;
|
|
8
7
|
readonly selectionMode?: DropdownSelectionMode;
|
|
9
8
|
readonly trigger: Trigger;
|
|
10
9
|
}
|
|
11
|
-
/** What a Dropdown provides to its popup content; its trigger reads the context of the menu around the Dropdown */
|
|
12
10
|
export interface DropdownContext {
|
|
13
|
-
/** Getters over the Dropdown's props, so readers stay reactive */
|
|
14
11
|
readonly view: DropdownContextView;
|
|
15
|
-
/** Closes the popup that renders the menu, without moving focus */
|
|
16
12
|
close: () => void;
|
|
17
|
-
/** Closes that popup and the popups of every enclosing menu */
|
|
18
13
|
closeAll: () => void;
|
|
19
14
|
getPopupId: () => string;
|
|
20
15
|
}
|
|
21
16
|
export declare const getDropdownContext: (caller?: string) => DropdownContext | undefined, setDropdownContext: (value: DropdownContext | undefined) => DropdownContext | undefined;
|
|
22
|
-
/** The foundation context; outside any menu the depth is 0 */
|
|
23
17
|
export declare function menuContext(context?: DropdownContext, direction?: 'ltr' | 'rtl'): DropdownMenuContext;
|
|
24
18
|
/**
|
|
25
19
|
* Each Dropdown.Item's li -> whether it is disabled. A snippet cannot read its child's props, so a Dropdown finds out
|
package/dist/dropdown/context.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SvelteMap } from 'svelte/reactivity';
|
|
2
2
|
import { createContext } from '../_base/create-context.js';
|
|
3
3
|
export const [getDropdownContext, setDropdownContext] = createContext('Dropdown', { optional: true });
|
|
4
|
-
/** The foundation context; outside any menu the depth is 0 */
|
|
5
4
|
export function menuContext(context, direction) {
|
|
6
5
|
return {
|
|
7
6
|
...context?.view,
|
|
@@ -75,8 +75,6 @@
|
|
|
75
75
|
const config = getConfigContext();
|
|
76
76
|
|
|
77
77
|
let tooltip = $state<Tooltip>();
|
|
78
|
-
|
|
79
|
-
// the trigger element: the span below, or the element the `child` snippet spread the trigger props on
|
|
80
78
|
let triggerElement = $state.raw<HTMLElement | null>(null);
|
|
81
79
|
let popupElement = $state<HTMLDivElement>();
|
|
82
80
|
let textOnly = $state(false);
|
|
@@ -100,7 +98,6 @@
|
|
|
100
98
|
() => ({ popVisible: false }),
|
|
101
99
|
(base) => ({
|
|
102
100
|
setPopVisible: (popVisible) => base.setState({ popVisible }),
|
|
103
|
-
// Tooltip has already written the bindable `visible`
|
|
104
101
|
notifyVisibleChange: (next) => onVisibleChange?.(next),
|
|
105
102
|
getPopup: () => popupElement?.closest<HTMLElement>('[popover]') ?? null,
|
|
106
103
|
hidePopup: () => tooltip?.hide(),
|
|
@@ -124,7 +121,6 @@
|
|
|
124
121
|
return ownRole ? canRoleCarryPopupState(ownRole) : element.matches('button, a[href]');
|
|
125
122
|
});
|
|
126
123
|
|
|
127
|
-
// a disabled parent item opens no submenu
|
|
128
124
|
const disabledItem = $derived(triggerElement ? Boolean(menuItems.get(triggerElement)?.()) : false);
|
|
129
125
|
|
|
130
126
|
const tooltipProps: TooltipProps = $derived({
|
|
@@ -185,7 +181,6 @@
|
|
|
185
181
|
getPopupId: () => tooltip?.getPopupId() ?? '',
|
|
186
182
|
};
|
|
187
183
|
|
|
188
|
-
// Moves focus into the menu when Tooltip gives the popup its initial focus.
|
|
189
184
|
const focusTarget = { focus: foundation.handleOpened };
|
|
190
185
|
|
|
191
186
|
// The trigger's own onkeydown goes first: a trigger that clicks itself on Enter (Tag, Avatar) calls preventDefault,
|
|
@@ -218,7 +213,6 @@
|
|
|
218
213
|
return {
|
|
219
214
|
...tooltipTrigger,
|
|
220
215
|
class: popVisible ? `${prefixCls}-showing` : undefined,
|
|
221
|
-
// undefined also drops a value the trigger set itself
|
|
222
216
|
'aria-haspopup': menuButton ? 'menu' : undefined,
|
|
223
217
|
'aria-expanded': menuButton ? popVisible : undefined,
|
|
224
218
|
[triggerKey]: attachTrigger,
|
|
@@ -246,7 +240,6 @@
|
|
|
246
240
|
tooltip?.focusTrigger();
|
|
247
241
|
}
|
|
248
242
|
|
|
249
|
-
/** Repositions the open popup at once; it already follows scrolling, resizing and trigger moves */
|
|
250
243
|
export function rePosition() {
|
|
251
244
|
tooltip?.rePosition();
|
|
252
245
|
}
|
|
@@ -7,7 +7,6 @@ import type { TooltipProps, TooltipTriggerProps } from '../tooltip/index.js';
|
|
|
7
7
|
* caller (`class={[props.class, 'own']}`), and the attachment under a symbol key must survive the spread.
|
|
8
8
|
*/
|
|
9
9
|
export type DropdownTriggerProps = Omit<TooltipTriggerProps, 'aria-haspopup' | 'aria-expanded' | 'aria-controls'> & {
|
|
10
|
-
/** `semi-dropdown-showing` while the menu is open */
|
|
11
10
|
class?: string;
|
|
12
11
|
'aria-haspopup'?: 'menu';
|
|
13
12
|
'aria-expanded'?: boolean;
|
|
@@ -21,7 +20,6 @@ export interface DropdownMenuIconArgs {
|
|
|
21
20
|
* wraps a special trigger only in its own span, and Dropdown always renders the trigger itself. No element props: F11.
|
|
22
21
|
*/
|
|
23
22
|
export interface DropdownProps extends Omit<TooltipProps, 'showArrow' | 'arrowPointAtCenter' | 'disableArrowKeyDown' | 'arrow' | 'child' | 'children' | 'content' | 'wrapWhenSpecial'> {
|
|
24
|
-
/** Wrapped in a span, which takes the trigger attributes */
|
|
25
23
|
children?: Snippet;
|
|
26
24
|
/** Renders the trigger element itself, which takes `props`; use it for a button, a link or a parent `DropdownItem` */
|
|
27
25
|
child?: Snippet<[{
|
|
@@ -45,7 +43,6 @@ export interface DropdownProps extends Omit<TooltipProps, 'showArrow' | 'arrowPo
|
|
|
45
43
|
showTick?: boolean;
|
|
46
44
|
}
|
|
47
45
|
export interface DropdownHandle {
|
|
48
|
-
/** Focuses the trigger (a non-custom trigger only) */
|
|
49
46
|
focusTrigger: () => void;
|
|
50
47
|
/** Repositions the open popup at once; it already follows scrolling, resizing and trigger moves, a move a frame late */
|
|
51
48
|
rePosition: () => void;
|
|
@@ -58,7 +55,6 @@ export interface DropdownItemProps extends HTMLAttributes<HTMLLIElement> {
|
|
|
58
55
|
/** Takes effect only outside a Dropdown; inside one, the Dropdown's showTick applies. */
|
|
59
56
|
showTick?: boolean;
|
|
60
57
|
type?: 'primary' | 'secondary' | 'tertiary' | 'warning' | 'danger';
|
|
61
|
-
/** The icon container is rendered even when the snippet outputs nothing */
|
|
62
58
|
icon?: Snippet;
|
|
63
59
|
}
|
|
64
60
|
export interface DropdownTitleProps extends HTMLAttributes<HTMLLIElement> {
|
package/dist/empty/empty.svelte
CHANGED
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
const sprite = $derived(typeof shown === 'object' && shown ? shown.id : undefined);
|
|
21
21
|
const hasImage = $derived(Boolean(shownSnippet || src || sprite));
|
|
22
22
|
|
|
23
|
-
// Only an Empty with a darkModeImage has anything to switch, so only it observes
|
|
24
23
|
$effect(() => {
|
|
25
24
|
if (!darkModeImage) return;
|
|
26
25
|
const sync = () => {
|
|
@@ -2,7 +2,6 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import type { strings } from '@fibrae/semi-foundation/empty/constants';
|
|
4
4
|
export type EmptyLayout = (typeof strings.LAYOUT)[number];
|
|
5
|
-
/** The id of an SVG sprite symbol on the page, drawn with `<use>` */
|
|
6
5
|
export interface EmptySvgNode {
|
|
7
6
|
id: string;
|
|
8
7
|
}
|
|
@@ -10,13 +9,11 @@ export interface EmptySvgNode {
|
|
|
10
9
|
export type EmptyImage = string | EmptySvgNode | Snippet;
|
|
11
10
|
export interface EmptyProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
12
11
|
layout?: EmptyLayout;
|
|
13
|
-
/** Inline style of the image box */
|
|
14
12
|
imageStyle?: string;
|
|
15
13
|
title?: string | Snippet;
|
|
16
14
|
image?: EmptyImage;
|
|
17
15
|
/** Shown instead of `image` while the page is in dark mode */
|
|
18
16
|
darkModeImage?: EmptyImage;
|
|
19
17
|
description?: Snippet;
|
|
20
|
-
/** Actions below the description */
|
|
21
18
|
children?: Snippet;
|
|
22
19
|
}
|
|
@@ -18,10 +18,8 @@ export type FeedbackCheckboxGroupProps = Omit<CheckboxGroupProps, 'value'>;
|
|
|
18
18
|
export type FeedbackRadioSnippetProps = RadioGroupOptionSnippetParams;
|
|
19
19
|
export type FeedbackCheckboxSnippetProps = CheckboxGroupOptionSnippetProps;
|
|
20
20
|
export interface FeedbackContentSnippetProps {
|
|
21
|
-
/** The built-in content; place it with `{@render content()}`. */
|
|
22
21
|
content: Snippet;
|
|
23
22
|
}
|
|
24
|
-
/** The props Feedback declares itself; the rest go to the Modal or SideSheet of the current mode. */
|
|
25
23
|
export interface FeedbackOwnProps {
|
|
26
24
|
mode?: FeedbackMode;
|
|
27
25
|
type?: FeedbackType;
|
|
@@ -40,11 +38,9 @@ export interface FeedbackOwnProps {
|
|
|
40
38
|
/** Cancel button, close button, Escape and (modal) mask click. `visible` becomes false once it returns, or once a returned Promise fulfills. */
|
|
41
39
|
onCancel?: (event: MouseEvent | KeyboardEvent) => unknown;
|
|
42
40
|
onValueChange?: (value: FeedbackValue) => void;
|
|
43
|
-
/** Called once the dialog has closed. */
|
|
44
41
|
afterClose?: () => void;
|
|
45
42
|
/** Popup only. */
|
|
46
43
|
afterVisibleChange?: (visible: boolean) => void;
|
|
47
|
-
/** Content of type="custom". */
|
|
48
44
|
children?: Snippet;
|
|
49
45
|
/** Wraps or replaces the built-in content, whatever the type. */
|
|
50
46
|
content?: Snippet<[FeedbackContentSnippetProps]>;
|
|
@@ -53,7 +49,6 @@ export interface FeedbackOwnProps {
|
|
|
53
49
|
closeIcon?: Snippet;
|
|
54
50
|
/** Modal only. A snippet replaces the default header; null renders no header. */
|
|
55
51
|
header?: Snippet | null;
|
|
56
|
-
/** Modal only. */
|
|
57
52
|
icon?: Snippet;
|
|
58
53
|
/** Modal only. `modal` is the role="dialog" element; place it with `{@render modal()}`. */
|
|
59
54
|
modal?: Snippet<[{
|
|
@@ -64,11 +59,9 @@ export interface FeedbackOwnProps {
|
|
|
64
59
|
checkboxLabel?: Snippet<[FeedbackCheckboxSnippetProps]>;
|
|
65
60
|
checkboxExtra?: Snippet<[FeedbackCheckboxSnippetProps]>;
|
|
66
61
|
}
|
|
67
|
-
/** What a template can pass for `mode="modal"`: the Modal props. */
|
|
68
62
|
export interface FeedbackModalProps extends Omit<FeedbackOwnProps, 'mode'>, Omit<ModalProps, keyof FeedbackOwnProps> {
|
|
69
63
|
mode: 'modal';
|
|
70
64
|
}
|
|
71
|
-
/** What a template can pass for `mode="popup"`: the SideSheet props. */
|
|
72
65
|
export interface FeedbackSideSheetProps extends FeedbackOwnProps, Omit<SideSheetProps, keyof FeedbackOwnProps> {
|
|
73
66
|
mode?: 'popup';
|
|
74
67
|
}
|
|
@@ -77,7 +70,6 @@ export interface FeedbackSideSheetProps extends FeedbackOwnProps, Omit<SideSheet
|
|
|
77
70
|
* TypeScript cannot index once both carry all the HTML attributes.
|
|
78
71
|
*/
|
|
79
72
|
export type FeedbackProps = FeedbackOwnProps & Omit<ModalProps, keyof FeedbackOwnProps> & Omit<SideSheetProps, keyof FeedbackOwnProps>;
|
|
80
|
-
/** Internal props of FeedbackContent */
|
|
81
73
|
export interface FeedbackContentProps extends Pick<FeedbackOwnProps, 'children' | 'radioLabel' | 'radioExtra' | 'checkboxLabel' | 'checkboxExtra'> {
|
|
82
74
|
type: FeedbackType;
|
|
83
75
|
value: FeedbackValue | null;
|
|
@@ -14,13 +14,11 @@
|
|
|
14
14
|
|
|
15
15
|
let { disabled = false, href, rel, target, onclick, children, ...rest }: Props = $props();
|
|
16
16
|
|
|
17
|
-
// the props are typed for the button; the listeners and attributes a link takes are the same ones
|
|
18
17
|
const linkRest = $derived(rest as HTMLAnchorAttributes);
|
|
19
18
|
|
|
20
19
|
// Chrome still delivers a click from a child of a disabled button.
|
|
21
20
|
const handleClick = (event: MouseEvent & { currentTarget: EventTarget & HTMLElement }) => {
|
|
22
21
|
if (!disabled) {
|
|
23
|
-
// the consumer's handler is typed for the button, the link renders the same props
|
|
24
22
|
onclick?.(event as MouseEvent & { currentTarget: EventTarget & HTMLButtonElement });
|
|
25
23
|
}
|
|
26
24
|
};
|
|
@@ -17,7 +17,6 @@ export interface FloatButtonProps extends Omit<HTMLButtonAttributes, 'children'
|
|
|
17
17
|
shape?: FloatButtonShape;
|
|
18
18
|
size?: FloatButtonSize;
|
|
19
19
|
target?: string;
|
|
20
|
-
/** Custom badge count, in place of `badge.count` */
|
|
21
20
|
badgeCount?: Snippet;
|
|
22
21
|
icon?: Snippet;
|
|
23
22
|
}
|
|
@@ -25,7 +24,6 @@ export interface FloatButtonGroupItem extends Pick<FloatButtonProps, 'badge' | '
|
|
|
25
24
|
/** Accessible name, required when the item shows only an icon */
|
|
26
25
|
'aria-label'?: string;
|
|
27
26
|
class?: string;
|
|
28
|
-
/** Text; richer content is the `content` snippet */
|
|
29
27
|
content?: string | number;
|
|
30
28
|
id?: string;
|
|
31
29
|
/** Called before the group's `onClick` */
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
},
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
// an outside update (formApi.setValue, setValues) renews updateKey
|
|
55
54
|
const syncKeys = () => {
|
|
56
55
|
const updateKey = bridge.getArrayField(field)?.updateKey;
|
|
57
56
|
if (updateKey !== cachedUpdateKey) {
|
|
@@ -75,7 +74,6 @@
|
|
|
75
74
|
// a new key at the position: regenerating by position would keep the old keys, so fields keep stale values
|
|
76
75
|
keys = keys.toSpliced(added.index, 0, createId());
|
|
77
76
|
cachedUpdateKey = added.updateKey;
|
|
78
|
-
// the new row's fields take the given row value, as after syncKeys
|
|
79
77
|
shouldUseInitValue = false;
|
|
80
78
|
}
|
|
81
79
|
};
|
package/dist/form/context.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { FieldBridge, FormState } from '@fibrae/semi-foundation/form/interf
|
|
|
2
2
|
import type { FormApi, FormProps } from './interface.js';
|
|
3
3
|
export interface FormContextValue {
|
|
4
4
|
readonly formState: FormState;
|
|
5
|
-
/** The Form props with their defaults resolved, read by the fields while rendering */
|
|
6
5
|
readonly formProps: FormProps;
|
|
7
6
|
formApi: FormApi;
|
|
8
7
|
bridge: FieldBridge;
|
|
@@ -12,7 +11,6 @@ export interface ArrayFieldContextValue {
|
|
|
12
11
|
/** The values the rows read their initial values from until the ArrayField's own mount write is rendered */
|
|
13
12
|
readonly values?: Record<string, any>;
|
|
14
13
|
}
|
|
15
|
-
/** The ids FormInputGroup adds to each field's own aria references */
|
|
16
14
|
export interface FormInputGroupAria {
|
|
17
15
|
labelledby?: string;
|
|
18
16
|
describedby?: string;
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
<IconAlertTriangle class={iconClass} />
|
|
35
35
|
{/if}
|
|
36
36
|
{/if}
|
|
37
|
-
<!-- the span id is the target of aria-errormessage and aria-describedby -->
|
|
38
37
|
{#if error}
|
|
39
38
|
<span id={errorMessageId}>
|
|
40
39
|
{#if errorContent}{@render errorContent({ error })}{:else}{errorText(error)}{/if}
|
|
@@ -8,14 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
interface FieldGridProps {
|
|
10
10
|
label?: Snippet;
|
|
11
|
-
/** The main content: the control, its messages and extra text */
|
|
12
11
|
children?: Snippet;
|
|
13
12
|
mainClass?: ClassValue;
|
|
14
13
|
labelAlign?: string;
|
|
15
14
|
labelCol?: ColProps;
|
|
16
15
|
wrapperCol?: ColProps;
|
|
17
16
|
labelPosition?: string;
|
|
18
|
-
/** Wraps the columns in their own Row, for a field whose columns the Form does not set */
|
|
19
17
|
row?: boolean;
|
|
20
18
|
}
|
|
21
19
|
|
|
@@ -3,14 +3,12 @@ import type { ClassValue } from 'svelte/elements';
|
|
|
3
3
|
import type { ColProps } from '../grid/interface.js';
|
|
4
4
|
interface FieldGridProps {
|
|
5
5
|
label?: Snippet;
|
|
6
|
-
/** The main content: the control, its messages and extra text */
|
|
7
6
|
children?: Snippet;
|
|
8
7
|
mainClass?: ClassValue;
|
|
9
8
|
labelAlign?: string;
|
|
10
9
|
labelCol?: ColProps;
|
|
11
10
|
wrapperCol?: ColProps;
|
|
12
11
|
labelPosition?: string;
|
|
13
|
-
/** Wraps the columns in their own Row, for a field whose columns the Form does not set */
|
|
14
12
|
row?: boolean;
|
|
15
13
|
}
|
|
16
14
|
declare const FieldGrid: import("svelte").Component<FieldGridProps, {}, "">;
|
|
@@ -60,7 +60,6 @@
|
|
|
60
60
|
...rest
|
|
61
61
|
}: InnerProps = $props();
|
|
62
62
|
|
|
63
|
-
// rendered only inside a Form, see field.svelte
|
|
64
63
|
const form = getFormContext() as FormContextValue;
|
|
65
64
|
const arrayField = getArrayFieldContext();
|
|
66
65
|
const group = getFormInputGroupContext();
|
|
@@ -98,7 +97,6 @@
|
|
|
98
97
|
const ownLayout = $derived(!group && !pure);
|
|
99
98
|
const shellLabel = $derived(ownLayout && !noLabel && shownLabelPosition !== 'inset');
|
|
100
99
|
|
|
101
|
-
// FormInputGroup adds its ids to the field's own references
|
|
102
100
|
const ownAria = $derived.by((): Record<string, unknown> => {
|
|
103
101
|
if (!group) {
|
|
104
102
|
return rest;
|
package/dist/form/field.svelte
CHANGED
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
warning(!bare && !inForm, '[Semi Form]: Field Component must be use inside the Form, please check your dom declaration');
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
// The wrapped control's instance, for calling its own methods (focus, open ...)
|
|
32
31
|
export function getControl() {
|
|
33
32
|
return bareControl ?? inner?.getControl();
|
|
34
33
|
}
|
package/dist/form/form.svelte
CHANGED
|
@@ -53,7 +53,6 @@
|
|
|
53
53
|
const uid = $props.id();
|
|
54
54
|
let formElement = $state<HTMLFormElement>();
|
|
55
55
|
|
|
56
|
-
// The props with their defaults resolved: the foundation reads them through getProps, the fields through the context
|
|
57
56
|
const formProps: FormProps<Values> = {
|
|
58
57
|
get initValues() {
|
|
59
58
|
return initValues;
|
package/dist/form/hooks.d.ts
CHANGED
|
@@ -2,9 +2,8 @@ import type { FieldError, FormApi, FormState } from './interface.js';
|
|
|
2
2
|
type FieldPath = string | (() => string);
|
|
3
3
|
/** The formApi of the enclosing Form; an empty object outside one. Call it during component initialisation. */
|
|
4
4
|
export declare function useFormApi<Values extends Record<string, any> = any>(): FormApi<Values>;
|
|
5
|
-
/**
|
|
5
|
+
/** An empty object outside a Form; call the result in the template to follow the state */
|
|
6
6
|
export declare function useFormState<Values extends Record<string, any> = any>(): () => FormState<Values>;
|
|
7
|
-
/** The formApi methods of one field; a getter path follows its changes */
|
|
8
7
|
export declare function useFieldApi(field: FieldPath): {
|
|
9
8
|
getError: () => any;
|
|
10
9
|
setError: (error: FieldError) => void;
|
package/dist/form/hooks.js
CHANGED
|
@@ -5,12 +5,11 @@ const readPath = (field) => (typeof field === 'function' ? field() : field);
|
|
|
5
5
|
export function useFormApi() {
|
|
6
6
|
return getFormContext()?.formApi ?? {};
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
8
|
+
/** An empty object outside a Form; call the result in the template to follow the state */
|
|
9
9
|
export function useFormState() {
|
|
10
10
|
const form = getFormContext();
|
|
11
11
|
return () => form?.formState ?? {};
|
|
12
12
|
}
|
|
13
|
-
/** The formApi methods of one field; a getter path follows its changes */
|
|
14
13
|
export function useFieldApi(field) {
|
|
15
14
|
const formApi = useFormApi();
|
|
16
15
|
return {
|
package/dist/form/interface.d.ts
CHANGED
|
@@ -16,14 +16,11 @@ export type FieldValidateResult = FieldError;
|
|
|
16
16
|
export interface LabelProps extends Omit<HTMLLabelAttributes, 'children'> {
|
|
17
17
|
/** Content of the label; the `children` snippet takes precedence */
|
|
18
18
|
text?: string | number;
|
|
19
|
-
/** text-align of the label */
|
|
20
19
|
align?: string;
|
|
21
20
|
disabled?: boolean;
|
|
22
21
|
/** Whether to display the required * symbol; hidden while `optional` is true */
|
|
23
22
|
required?: boolean;
|
|
24
|
-
/** Appends the locale's optional text */
|
|
25
23
|
optional?: boolean;
|
|
26
|
-
/** The id of the labeled field, written to the `for` attribute */
|
|
27
24
|
name?: string;
|
|
28
25
|
/** Width of the label; a number is in px */
|
|
29
26
|
width?: number | string;
|
|
@@ -68,7 +65,6 @@ export interface FormProps<Values extends Record<string, any> = any> extends Omi
|
|
|
68
65
|
};
|
|
69
66
|
/** Form-level validation; when set, it replaces the fields' own validation */
|
|
70
67
|
validator?: (values: Values) => FormValidateResult<Values> | Promise<FormValidateResult<Values>>;
|
|
71
|
-
/** The `formApi` returned by `useForm()` */
|
|
72
68
|
form?: FormApi<Values>;
|
|
73
69
|
/** Also written to `x-form-id`; generated when missing */
|
|
74
70
|
id?: string;
|
|
@@ -121,12 +117,10 @@ export interface CommonFieldProps {
|
|
|
121
117
|
id?: string;
|
|
122
118
|
fieldClassName?: string;
|
|
123
119
|
fieldStyle?: string;
|
|
124
|
-
/** Replaces the label text */
|
|
125
120
|
fieldLabel?: Snippet;
|
|
126
121
|
labelExtra?: Snippet;
|
|
127
122
|
/** Shown in the error message's place while the field has no error */
|
|
128
123
|
helpText?: Snippet;
|
|
129
|
-
/** Shown together with the error or the help text */
|
|
130
124
|
extraText?: Snippet;
|
|
131
125
|
/** Renders the error; the default joins the messages with commas */
|
|
132
126
|
error?: Snippet<[{
|
|
@@ -219,7 +213,6 @@ export interface SlotProps extends Omit<HTMLAttributes<HTMLDivElement>, 'childre
|
|
|
219
213
|
noLabel?: boolean;
|
|
220
214
|
error?: FieldError;
|
|
221
215
|
children?: Snippet;
|
|
222
|
-
/** Replaces the label text */
|
|
223
216
|
fieldLabel?: Snippet;
|
|
224
217
|
labelExtra?: Snippet;
|
|
225
218
|
errorContent?: Snippet<[{
|
package/dist/form/utils.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export declare function omitFieldProps(props: Record<string, unknown>): {
|
|
|
4
4
|
};
|
|
5
5
|
/** Deep clone that keeps functions, DOM nodes and errors as they are; the server has no DOM nodes to keep */
|
|
6
6
|
export declare function cloneDeep<T>(value: T): T;
|
|
7
|
-
/** Whether an error has content ErrorMessage renders; a number or a boolean does not */
|
|
8
7
|
export declare function hasErrorContent(error: unknown): boolean;
|
|
9
8
|
export declare function errorText(error: FieldError): string;
|
|
10
9
|
export declare function isLabelConfig<L extends FieldLabel>(label?: string | number | L): label is L;
|
package/dist/form/utils.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { untrack } from 'svelte';
|
|
2
2
|
import { cloneFormValue } from '@fibrae/semi-foundation/form/utils';
|
|
3
|
-
/** The props a field consumes itself; a bare Checkbox or Radio drops them, except id and name */
|
|
4
3
|
const fieldOnlyKeys = new Set([
|
|
5
4
|
'allowEmpty',
|
|
6
5
|
'allowEmptyString',
|
|
@@ -40,7 +39,6 @@ export function omitFieldProps(props) {
|
|
|
40
39
|
export function cloneDeep(value) {
|
|
41
40
|
return cloneFormValue(value, (item) => typeof Node !== 'undefined' && item instanceof Node);
|
|
42
41
|
}
|
|
43
|
-
/** Whether an error has content ErrorMessage renders; a number or a boolean does not */
|
|
44
42
|
export function hasErrorContent(error) {
|
|
45
43
|
if (Array.isArray(error)) {
|
|
46
44
|
return error.some(Boolean);
|
|
@@ -15,6 +15,5 @@ export interface HighlightProps {
|
|
|
15
15
|
/** Camel-case or kebab-case keys; numbers are written as-is, so lengths need a unit string */
|
|
16
16
|
highlightStyle?: HighlightStyle;
|
|
17
17
|
highlightClassName?: string;
|
|
18
|
-
/** Tag of each highlighted chunk */
|
|
19
18
|
component?: string;
|
|
20
19
|
}
|
|
@@ -2,7 +2,6 @@ import type { HTMLAttributes } from 'svelte/elements';
|
|
|
2
2
|
export interface HotKeysProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
3
|
/** Keys that must be pressed together: any number of modifiers and exactly one other key */
|
|
4
4
|
hotKeys: KeyboardEvent['key'][];
|
|
5
|
-
/** Shown instead of `hotKeys` */
|
|
6
5
|
content?: string[];
|
|
7
6
|
preventDefault?: boolean;
|
|
8
7
|
/** Element that listens for keydown; defaults to document.body */
|
package/dist/image/context.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export interface PreviewContextValue {
|
|
|
3
3
|
readonly srcList: string[];
|
|
4
4
|
readonly lazyLoad: boolean;
|
|
5
5
|
readonly lazyLoadMargin: string;
|
|
6
|
-
/** Opens the group preview at `index` */
|
|
7
6
|
open: (index: number) => void;
|
|
8
7
|
}
|
|
9
8
|
export declare const getPreviewContext: (caller?: string) => PreviewContextValue | undefined, setPreviewContext: (value: PreviewContextValue | undefined) => PreviewContextValue | undefined;
|