@fibrae/semi-ui-svelte 0.1.1 → 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-content.svelte +4 -4
- package/dist/feedback/feedback.svelte +0 -1
- package/dist/feedback/interface.d.ts +4 -12
- 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 +9 -5
- package/dist/form/field-inner.svelte.d.ts +3 -1
- package/dist/form/field.svelte +9 -2
- package/dist/form/field.svelte.d.ts +6 -2
- package/dist/form/form-auto-complete.svelte +7 -1
- package/dist/form/form-auto-complete.svelte.d.ts +3 -1
- package/dist/form/form-cascader.svelte +7 -1
- package/dist/form/form-cascader.svelte.d.ts +3 -1
- package/dist/form/form-checkbox-group.svelte +7 -1
- package/dist/form/form-checkbox-group.svelte.d.ts +3 -1
- package/dist/form/form-checkbox.svelte +7 -1
- package/dist/form/form-checkbox.svelte.d.ts +3 -1
- package/dist/form/form-date-picker.svelte +7 -1
- package/dist/form/form-date-picker.svelte.d.ts +3 -1
- package/dist/form/form-input-number.svelte +7 -1
- package/dist/form/form-input-number.svelte.d.ts +3 -1
- package/dist/form/form-input.svelte +7 -1
- package/dist/form/form-input.svelte.d.ts +3 -1
- package/dist/form/form-pin-code.svelte +7 -1
- package/dist/form/form-pin-code.svelte.d.ts +3 -1
- package/dist/form/form-radio-group.svelte +7 -1
- package/dist/form/form-radio-group.svelte.d.ts +3 -1
- package/dist/form/form-radio.svelte +7 -1
- package/dist/form/form-radio.svelte.d.ts +3 -1
- package/dist/form/form-rating.svelte +7 -1
- package/dist/form/form-rating.svelte.d.ts +3 -1
- package/dist/form/form-select.svelte +7 -1
- package/dist/form/form-select.svelte.d.ts +3 -1
- package/dist/form/form-slider.svelte +7 -1
- package/dist/form/form-slider.svelte.d.ts +3 -1
- package/dist/form/form-switch.svelte +7 -1
- package/dist/form/form-switch.svelte.d.ts +3 -1
- package/dist/form/form-tag-input.svelte +7 -1
- package/dist/form/form-tag-input.svelte.d.ts +3 -1
- package/dist/form/form-text-area.svelte +7 -1
- package/dist/form/form-text-area.svelte.d.ts +3 -1
- package/dist/form/form-time-picker.svelte +7 -1
- package/dist/form/form-time-picker.svelte.d.ts +3 -1
- package/dist/form/form-transfer.svelte +7 -1
- package/dist/form/form-transfer.svelte.d.ts +3 -1
- package/dist/form/form-tree-select.svelte +7 -1
- package/dist/form/form-tree-select.svelte.d.ts +3 -1
- package/dist/form/form-upload.svelte +7 -1
- package/dist/form/form-upload.svelte.d.ts +3 -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/icon-button/icon-button.svelte +6 -2
- 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/input-group.svelte +8 -2
- 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 +2 -2
- 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 +4 -5
- 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 +2 -2
- 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 +30 -14
- 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 +14 -11
- 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 +2 -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 +3 -3
- 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 +5 -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
|
}
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
</script>
|
|
26
26
|
|
|
27
27
|
{#if type === 'text'}
|
|
28
|
-
<!-- the handler
|
|
29
|
-
<TextArea placeholder={locale().locale.placeholder} value={typeof value === 'string' ? value : ''}
|
|
28
|
+
<!-- the value and handler come last: the foundation calls the caller's own onChange -->
|
|
29
|
+
<TextArea placeholder={locale().locale.placeholder} {...textAreaProps} onChange={onTextChange} value={typeof value === 'string' ? value : ''} />
|
|
30
30
|
{:else if type === 'emoji'}
|
|
31
31
|
<!-- APG radio group: native radios provide the arrow keys, single Tab stop and checked state -->
|
|
32
32
|
<div aria-label={locale().locale.rating} class={`${prefix}-emoji-container`} role="radiogroup">
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
{/if}
|
|
43
43
|
{:else if type === 'radio'}
|
|
44
44
|
<div class={`${prefix}-radio-container`}>
|
|
45
|
-
<RadioGroup direction="vertical" extra={radioExtra} label={radioLabel}
|
|
45
|
+
<RadioGroup direction="vertical" extra={radioExtra} label={radioLabel} {...radioGroupProps} onChange={onRadioChange} value={radioValue} />
|
|
46
46
|
</div>
|
|
47
47
|
{:else if type === 'checkbox'}
|
|
48
48
|
<div class={`${prefix}-checkbox-container`}>
|
|
49
|
-
<CheckboxGroup direction="vertical" extra={checkboxExtra} label={checkboxLabel} value={Array.isArray(value) ? value : []}
|
|
49
|
+
<CheckboxGroup direction="vertical" extra={checkboxExtra} label={checkboxLabel} {...checkboxGroupProps} onChange={onCheckboxChange} value={Array.isArray(value) ? value : []} />
|
|
50
50
|
</div>
|
|
51
51
|
{:else}
|
|
52
52
|
{@render children?.()}
|
|
@@ -11,17 +11,15 @@ export type FeedbackMode = 'modal' | 'popup';
|
|
|
11
11
|
export type FeedbackType = 'text' | 'emoji' | 'radio' | 'checkbox' | 'custom';
|
|
12
12
|
/** Same shape as the Modal footer buttons; `onclick` runs before the built-in ok or cancel handling. */
|
|
13
13
|
export type FeedbackButtonProps = ModalButtonProps;
|
|
14
|
-
/** `
|
|
15
|
-
export type FeedbackTextAreaProps = TextAreaProps
|
|
16
|
-
export type FeedbackRadioGroupProps = RadioGroupProps
|
|
17
|
-
export type FeedbackCheckboxGroupProps = CheckboxGroupProps
|
|
14
|
+
/** `value` is Feedback's own; `onChange` is called after Feedback has handled the change. */
|
|
15
|
+
export type FeedbackTextAreaProps = Omit<TextAreaProps, 'value'>;
|
|
16
|
+
export type FeedbackRadioGroupProps = Omit<RadioGroupProps, 'value'>;
|
|
17
|
+
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();
|
|
@@ -69,6 +68,7 @@
|
|
|
69
68
|
const uid = $props.id();
|
|
70
69
|
let extraKind = $state<SlotKind>();
|
|
71
70
|
let registered: { field: string; registration: FieldRegistration; leaveGroup?: () => void } | undefined;
|
|
71
|
+
let controlInstance = $state.raw<Record<string, any>>();
|
|
72
72
|
|
|
73
73
|
const Control = $derived(component as Component<Record<string, any>, object, string>);
|
|
74
74
|
const valueKey = $derived(fieldOptions.valueKey ?? 'value');
|
|
@@ -97,7 +97,6 @@
|
|
|
97
97
|
const ownLayout = $derived(!group && !pure);
|
|
98
98
|
const shellLabel = $derived(ownLayout && !noLabel && shownLabelPosition !== 'inset');
|
|
99
99
|
|
|
100
|
-
// FormInputGroup adds its ids to the field's own references
|
|
101
100
|
const ownAria = $derived.by((): Record<string, unknown> => {
|
|
102
101
|
if (!group) {
|
|
103
102
|
return rest;
|
|
@@ -250,6 +249,11 @@
|
|
|
250
249
|
}
|
|
251
250
|
return unregister;
|
|
252
251
|
});
|
|
252
|
+
|
|
253
|
+
// Svelte exports are static, so the wrapped control's own methods (focus, open ...) cannot be re-exported by name
|
|
254
|
+
export function getControl() {
|
|
255
|
+
return controlInstance;
|
|
256
|
+
}
|
|
253
257
|
</script>
|
|
254
258
|
|
|
255
259
|
{#snippet insetText()}
|
|
@@ -271,11 +275,11 @@
|
|
|
271
275
|
...(blurKey && { [blurKey]: handleBlur }),
|
|
272
276
|
}}
|
|
273
277
|
{#if valueKey === 'checked'}
|
|
274
|
-
<Control {...injected} bind:checked={() => snapshot().value, () => {}} />
|
|
278
|
+
<Control {...injected} bind:checked={() => snapshot().value, () => {}} bind:this={controlInstance} />
|
|
275
279
|
{:else if valueKey === 'fileList'}
|
|
276
|
-
<Control {...injected} bind:fileList={() => snapshot().value, () => {}} />
|
|
280
|
+
<Control {...injected} bind:fileList={() => snapshot().value, () => {}} bind:this={controlInstance} />
|
|
277
281
|
{:else}
|
|
278
|
-
<Control {...injected} bind:value={() => snapshot().value, () => {}} />
|
|
282
|
+
<Control {...injected} bind:this={controlInstance} bind:value={() => snapshot().value, () => {}} />
|
|
279
283
|
{/if}
|
|
280
284
|
{/snippet}
|
|
281
285
|
|
|
@@ -7,6 +7,8 @@ type InnerProps = Omit<CommonFieldProps, 'field'> & {
|
|
|
7
7
|
triggerContent?: Snippet<any[]>;
|
|
8
8
|
[key: string]: unknown;
|
|
9
9
|
};
|
|
10
|
-
declare const FieldInner: Component<InnerProps, {
|
|
10
|
+
declare const FieldInner: Component<InnerProps, {
|
|
11
|
+
getControl: () => Record<string, any> | undefined;
|
|
12
|
+
}, "">;
|
|
11
13
|
type FieldInner = ReturnType<typeof FieldInner>;
|
|
12
14
|
export default FieldInner;
|
package/dist/form/field.svelte
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
let props: FormFieldProps<C> = $props();
|
|
10
10
|
|
|
11
|
+
let bareControl = $state.raw<Record<string, any>>();
|
|
12
|
+
let inner = $state.raw<{ getControl: () => Record<string, any> | undefined }>();
|
|
13
|
+
|
|
11
14
|
const inForm = Boolean(getFormContext());
|
|
12
15
|
const shouldInject = $derived(props.fieldOptions?.shouldInject ?? true);
|
|
13
16
|
|
|
@@ -24,10 +27,14 @@
|
|
|
24
27
|
warning(props.field === undefined && shouldInject, "[Semi Form]: 'field' is required, please check your props of Field Component");
|
|
25
28
|
warning(!bare && !inForm, '[Semi Form]: Field Component must be use inside the Form, please check your dom declaration');
|
|
26
29
|
});
|
|
30
|
+
|
|
31
|
+
export function getControl() {
|
|
32
|
+
return bareControl ?? inner?.getControl();
|
|
33
|
+
}
|
|
27
34
|
</script>
|
|
28
35
|
|
|
29
36
|
{#if bare}
|
|
30
|
-
<Control {...bareProps} />
|
|
37
|
+
<Control {...bareProps} bind:this={bareControl} />
|
|
31
38
|
{:else if inForm}
|
|
32
|
-
<FieldInner {...props} />
|
|
39
|
+
<FieldInner {...props} bind:this={inner} />
|
|
33
40
|
{/if}
|
|
@@ -2,7 +2,9 @@ import { type Component } from 'svelte';
|
|
|
2
2
|
import type { FormFieldProps } from './interface.js';
|
|
3
3
|
declare function $$render<C extends Component<any, any, any>>(): {
|
|
4
4
|
props: FormFieldProps<C>;
|
|
5
|
-
exports: {
|
|
5
|
+
exports: {
|
|
6
|
+
getControl: () => Record<string, any> | undefined;
|
|
7
|
+
};
|
|
6
8
|
bindings: "";
|
|
7
9
|
slots: {};
|
|
8
10
|
events: {};
|
|
@@ -12,7 +14,9 @@ declare class __sveltets_Render<C extends Component<any, any, any>> {
|
|
|
12
14
|
events(): ReturnType<typeof $$render<C>>['events'];
|
|
13
15
|
slots(): ReturnType<typeof $$render<C>>['slots'];
|
|
14
16
|
bindings(): "";
|
|
15
|
-
exports(): {
|
|
17
|
+
exports(): {
|
|
18
|
+
getControl: () => Record<string, any> | undefined;
|
|
19
|
+
};
|
|
16
20
|
}
|
|
17
21
|
interface $$IsomorphicComponent {
|
|
18
22
|
new <C extends Component<any, any, any>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<C>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<C>['props']>, ReturnType<__sveltets_Render<C>['events']>, ReturnType<__sveltets_Render<C>['slots']>> & {
|
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
import type { FieldProps } from './interface.js';
|
|
6
6
|
|
|
7
7
|
let props: FieldProps<AutoCompleteProps> = $props();
|
|
8
|
+
|
|
9
|
+
let field: ReturnType<typeof Field> | undefined;
|
|
10
|
+
|
|
11
|
+
export function getControl() {
|
|
12
|
+
return field?.getControl();
|
|
13
|
+
}
|
|
8
14
|
</script>
|
|
9
15
|
|
|
10
|
-
<Field {...props} component={AutoComplete} />
|
|
16
|
+
<Field bind:this={field} {...props} component={AutoComplete} />
|