@fibrae/semi-ui-svelte 0.6.0 → 0.7.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/components/auto-complete/auto-complete.svelte +12 -21
- package/dist/components/auto-complete/interface.d.ts +3 -2
- package/dist/components/badge/badge.svelte +4 -4
- package/dist/components/badge/interface.d.ts +4 -3
- package/dist/components/button/button.svelte +3 -2
- package/dist/components/button/interface.d.ts +4 -2
- package/dist/components/card/card.svelte +9 -10
- package/dist/components/card/interface.d.ts +4 -4
- package/dist/components/cascader/cascader.svelte +11 -18
- package/dist/components/cascader/interface.d.ts +3 -2
- package/dist/components/cascader/item.svelte +1 -1
- package/dist/components/color-picker/color-picker.svelte +16 -1
- package/dist/components/cropper/cropper.svelte +4 -4
- package/dist/components/cropper/interface.d.ts +4 -3
- package/dist/components/date-picker/date-input.svelte +3 -1
- package/dist/components/date-picker/date-picker.svelte +9 -10
- package/dist/components/date-picker/interface.d.ts +5 -4
- package/dist/components/date-picker/internal.d.ts +2 -0
- package/dist/components/descriptions/descriptions.svelte +2 -2
- package/dist/components/descriptions/interface.d.ts +4 -2
- package/dist/components/dropdown/dropdown-popup.svelte +2 -1
- package/dist/components/dropdown/dropdown-popup.svelte.d.ts +2 -1
- package/dist/components/dropdown/dropdown.svelte +4 -5
- package/dist/components/dropdown/interface.d.ts +6 -4
- package/dist/components/empty/empty.svelte +2 -2
- package/dist/components/empty/interface.d.ts +4 -3
- package/dist/components/feedback/feedback.svelte +6 -0
- package/dist/components/feedback/interface.d.ts +5 -0
- package/dist/components/highlight/highlight.svelte +6 -7
- package/dist/components/highlight/interface.d.ts +4 -3
- package/dist/components/icon-button/icon-button.svelte +4 -3
- package/dist/components/image/image.svelte +4 -4
- package/dist/components/image/interface.d.ts +6 -5
- package/dist/components/image/preview/preview-image.svelte +1 -1
- package/dist/components/image/preview/preview-inner.svelte +10 -18
- package/dist/components/image/preview/preview.svelte +4 -4
- package/dist/components/input/input.svelte +4 -2
- package/dist/components/input/interface.d.ts +6 -5
- package/dist/components/input/textarea.svelte +6 -6
- package/dist/components/input-number/input-number.svelte +4 -2
- package/dist/components/input-number/interface.d.ts +5 -1
- package/dist/components/modal/interface.d.ts +5 -3
- package/dist/components/modal/modal-content.svelte +26 -32
- package/dist/components/modal/modal-content.svelte.d.ts +5 -4
- package/dist/components/modal/modal.svelte +4 -4
- package/dist/components/navigation/interface.d.ts +8 -4
- package/dist/components/navigation/nav-items.svelte +1 -1
- package/dist/components/navigation/nav.svelte +3 -2
- package/dist/components/navigation/sub-nav.svelte +5 -4
- package/dist/components/overflow-list/interface.d.ts +4 -3
- package/dist/components/overflow-list/overflow-list.svelte +3 -3
- package/dist/components/pagination/interface.d.ts +1 -1
- package/dist/components/pagination/pagination.svelte +63 -61
- package/dist/components/popconfirm/interface.d.ts +3 -0
- package/dist/components/popconfirm/popconfirm.svelte +4 -4
- package/dist/components/popover/arrow.svelte +2 -2
- package/dist/components/popover/interface.d.ts +8 -3
- package/dist/components/popover/popover.svelte +4 -4
- package/dist/components/radio/interface.d.ts +6 -5
- package/dist/components/radio/radio-group.svelte +2 -2
- package/dist/components/radio/radio.svelte +4 -4
- package/dist/components/select/interface.d.ts +3 -2
- package/dist/components/select/option.svelte +1 -1
- package/dist/components/select/select.svelte +9 -14
- package/dist/components/side-sheet/interface.d.ts +6 -5
- package/dist/components/side-sheet/side-sheet.svelte +31 -29
- package/dist/components/slider/interface.d.ts +4 -2
- package/dist/components/slider/slider.svelte +3 -2
- package/dist/components/spin/interface.d.ts +4 -3
- package/dist/components/spin/spin.svelte +2 -3
- package/dist/components/switch/switch.svelte +1 -1
- package/dist/components/table/context.d.ts +2 -1
- package/dist/components/table/interface.d.ts +4 -3
- package/dist/components/table/table-header/table-header-row.svelte +2 -1
- package/dist/components/table/table.svelte +7 -3
- package/dist/components/tabs/interface.d.ts +8 -7
- package/dist/components/tabs/tab-bar.svelte +12 -2
- package/dist/components/tabs/tabs.svelte +7 -8
- package/dist/components/time-picker/interface.d.ts +4 -4
- package/dist/components/time-picker/time-input.svelte +2 -2
- package/dist/components/time-picker/time-picker.svelte +10 -11
- package/dist/components/tooltip/interface.d.ts +5 -2
- package/dist/components/tooltip/tooltip.svelte +13 -38
- package/dist/components/tree/interface.d.ts +4 -3
- package/dist/components/tree/node-arrow.svelte +1 -1
- package/dist/components/tree/tree-node.svelte +1 -1
- package/dist/components/tree/tree.svelte +23 -74
- package/dist/components/tree-select/interface.d.ts +4 -5
- package/dist/components/tree-select/tree-select.svelte +28 -67
- package/dist/components/typography/base.svelte +1 -1
- package/dist/components/upload/file-card.svelte +1 -1
- package/dist/components/upload/interface.d.ts +5 -3
- package/dist/components/upload/upload.svelte +6 -4
- package/dist/components/user-guide/user-guide.svelte +15 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/use-overlay-resources.svelte.d.ts +13 -0
- package/dist/hooks/use-overlay-resources.svelte.js +20 -0
- package/dist/styles.css +1 -1
- package/package.json +3 -3
- package/dist/components/tree/use-tree-keyboard.svelte.d.ts +0 -29
- package/dist/components/tree/use-tree-keyboard.svelte.js +0 -61
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ClassValue, HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import type { ConfirmType } from '@fibrae/semi-foundation/components/modal/confirm';
|
|
4
|
+
import type { ModalPart } from '@fibrae/semi-foundation/components/modal/constants';
|
|
4
5
|
import type { OKType, Size } from '@fibrae/semi-foundation/components/modal/modal-foundation';
|
|
5
6
|
import type { ButtonProps } from '../button/interface.js';
|
|
6
7
|
export type { ModalState, OKType } from '@fibrae/semi-foundation/components/modal/modal-foundation';
|
|
@@ -20,12 +21,13 @@ export interface ModalHandle {
|
|
|
20
21
|
export interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
21
22
|
/** Called once the dialog has closed and its leave animation has ended, or when it unmounts while shown. */
|
|
22
23
|
afterClose?: () => void;
|
|
23
|
-
bodyStyle?: string;
|
|
24
24
|
cancelButtonProps?: ModalButtonProps;
|
|
25
25
|
/** undefined: loading follows the Promise returned by onCancel */
|
|
26
26
|
cancelLoading?: boolean;
|
|
27
27
|
cancelText?: string;
|
|
28
28
|
centered?: boolean;
|
|
29
|
+
/** Merged after the built-in class names of the part's element; replaces the global default as a whole */
|
|
30
|
+
classNames?: Partial<Record<ModalPart, ClassValue>>;
|
|
29
31
|
closable?: boolean;
|
|
30
32
|
closeOnEsc?: boolean;
|
|
31
33
|
/** undefined: loading follows the Promise returned by onOk */
|
|
@@ -40,7 +42,6 @@ export interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'
|
|
|
40
42
|
mask?: boolean;
|
|
41
43
|
maskClosable?: boolean;
|
|
42
44
|
maskFixed?: boolean;
|
|
43
|
-
maskStyle?: string;
|
|
44
45
|
modalContentClass?: string;
|
|
45
46
|
motion?: boolean;
|
|
46
47
|
okButtonProps?: ModalButtonProps;
|
|
@@ -48,6 +49,7 @@ export interface ModalProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'
|
|
|
48
49
|
okType?: OKType;
|
|
49
50
|
preventScroll?: boolean;
|
|
50
51
|
size?: Size;
|
|
52
|
+
styles?: Partial<Record<ModalPart, string>>;
|
|
51
53
|
/** Bindable. Cancel, close button, mask click and Escape write `false` once `onCancel` returns (or its Promise fulfills). */
|
|
52
54
|
visible?: boolean;
|
|
53
55
|
width?: string | number;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
|
-
import {
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ClassValue, HTMLAttributes } from 'svelte/elements';
|
|
4
|
+
import { isNil, omitBy } from 'es-toolkit';
|
|
5
|
+
import { cssClasses, type ModalPart } from '@fibrae/semi-foundation/components/modal/constants';
|
|
5
6
|
import ModalContentFoundation, { type ModalContentAdapter, type ModalContentProps as FoundationProps, isModal } from '@fibrae/semi-foundation/components/modal/modal-content-foundation';
|
|
6
7
|
import type { Size } from '@fibrae/semi-foundation/components/modal/modal-foundation';
|
|
7
8
|
import { cssClasses as typographyClasses } from '@fibrae/semi-foundation/components/typography/constants';
|
|
8
|
-
import {
|
|
9
|
+
import { toCssLength } from '@fibrae/semi-foundation/utils';
|
|
9
10
|
import '@fibrae/semi-foundation/components/typography/typography.css';
|
|
10
11
|
import { IconClose } from '@fibrae/semi-icons-svelte';
|
|
11
12
|
import { useFoundation } from '../../base/index.js';
|
|
13
|
+
import { useOverlayResources } from '../../hooks/index.js';
|
|
12
14
|
import { isAriaKey, splitControlAttrs } from '../../utils/index.js';
|
|
13
15
|
import IconButton from '../icon-button/icon-button.svelte';
|
|
14
16
|
import useLocale from '../locale/use-locale.svelte.js';
|
|
@@ -32,8 +34,8 @@
|
|
|
32
34
|
footer?: Snippet | null;
|
|
33
35
|
children?: Snippet;
|
|
34
36
|
modal?: Snippet<[{ modal: Snippet }]>;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
classNames?: Partial<Record<ModalPart, ClassValue>>;
|
|
38
|
+
styles?: Partial<Record<ModalPart, string>>;
|
|
37
39
|
centered: boolean;
|
|
38
40
|
closable: boolean;
|
|
39
41
|
closeOnEsc: boolean;
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
contentClass?: string;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
let { visible, motion, inBody, onClose, onAfterLeave, initialFocus, title, header, icon, closeIcon, footer, children, modal,
|
|
53
|
+
let { visible, motion, inBody, onClose, onAfterLeave, initialFocus, title, header, icon, closeIcon, footer, children, modal, classNames, styles, centered, closable, closeOnEsc, mask, maskClosable, maskFixed, preventScroll, size, width, height, isFullScreen, contentClass, ...rest }: Props = $props();
|
|
52
54
|
|
|
53
55
|
const locale = useLocale('Modal');
|
|
54
56
|
|
|
@@ -105,8 +107,9 @@
|
|
|
105
107
|
|
|
106
108
|
const idPrefix = `dialog-${uid}`;
|
|
107
109
|
|
|
108
|
-
// F12: aria-* and role go to the dialog element, style to the .semi-modal box, the rest to the outer element
|
|
109
|
-
|
|
110
|
+
// F12: aria-* and role go to the dialog element, style to the .semi-modal box, the rest to the outer element.
|
|
111
|
+
// Attributes bound to undefined are dropped: they count as unset and keep the generated aria-labelledby, aria-modal.
|
|
112
|
+
const attrs = $derived(splitControlAttrs(omitBy(rest, isNil), (key) => key === 'role' || isAriaKey(key)));
|
|
110
113
|
|
|
111
114
|
const rootAttrs = $derived.by(() => {
|
|
112
115
|
const { style: _style, ...others } = attrs.root;
|
|
@@ -125,23 +128,13 @@
|
|
|
125
128
|
const sizeStyle = $derived(isFullScreen ? 'width: 100%; height: 100%; margin: unset' : [width ? `width: ${toCssLength(width)}` : '', height ? `height: ${toCssLength(height)}` : ''].filter(Boolean).join('; '));
|
|
126
129
|
const boxStyle = $derived([userStyle, sizeStyle].filter(Boolean).join(';') || undefined);
|
|
127
130
|
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
// Gated on the dialog being displayed, not on `visible`: it stays displayed through the leave animation, and a
|
|
136
|
-
// keepDOM reopen shows it again before this runs.
|
|
137
|
-
$effect(() => {
|
|
138
|
-
if (!content.displayed || !root || !dialog?.isConnected) return;
|
|
139
|
-
untrack(() => {
|
|
140
|
-
foundation.show();
|
|
141
|
-
warnIfDialogUnnamed(dialog, 'Modal');
|
|
142
|
-
});
|
|
143
|
-
return foundation.hide;
|
|
144
|
-
});
|
|
131
|
+
// Shown is gated on the dialog being displayed, not on `visible`: it stays displayed through the leave animation,
|
|
132
|
+
// and a keepDOM reopen shows it again before the hold runs.
|
|
133
|
+
useOverlayResources(
|
|
134
|
+
foundation,
|
|
135
|
+
() => visible,
|
|
136
|
+
() => Boolean(content.displayed && root && dialog?.isConnected)
|
|
137
|
+
);
|
|
145
138
|
|
|
146
139
|
export function getRoot() {
|
|
147
140
|
return root;
|
|
@@ -157,7 +150,7 @@
|
|
|
157
150
|
{/snippet}
|
|
158
151
|
|
|
159
152
|
{#snippet bodyPart()}
|
|
160
|
-
<div class={[`${prefix}-body`, { [`${prefix}-withIcon`]: icon }]} id={`${idPrefix}-body`} style={
|
|
153
|
+
<div class={[`${prefix}-body`, { [`${prefix}-withIcon`]: icon }, classNames?.body]} id={`${idPrefix}-body`} style={styles?.body} x-semi-prop="children">
|
|
161
154
|
{@render children?.()}
|
|
162
155
|
</div>
|
|
163
156
|
{/snippet}
|
|
@@ -182,12 +175,13 @@
|
|
|
182
175
|
aria-modal={modalDialog ? 'true' : undefined}
|
|
183
176
|
{...attrs.control}
|
|
184
177
|
{@attach (element) => {
|
|
185
|
-
// not cleared on teardown:
|
|
178
|
+
// not cleared on teardown: afterHide() runs after it and still needs the element to decide the focus restore
|
|
186
179
|
dialog = element;
|
|
187
180
|
}}
|
|
188
181
|
{@attach content.attach}
|
|
189
|
-
class={[`${prefix}-content`, contentClass, content.className, { [`${prefix}-content-fullScreen`]: isFullScreen, [`${prefix}-content-height-set`]: heightSet }]}
|
|
182
|
+
class={[`${prefix}-content`, contentClass, content.className, { [`${prefix}-content-fullScreen`]: isFullScreen, [`${prefix}-content-height-set`]: heightSet }, classNames?.content]}
|
|
190
183
|
role={dialogRole}
|
|
184
|
+
style={styles?.content}
|
|
191
185
|
style:display={content.displayed ? undefined : 'none'}
|
|
192
186
|
tabindex="-1"
|
|
193
187
|
>
|
|
@@ -195,7 +189,7 @@
|
|
|
195
189
|
{@render header?.()}
|
|
196
190
|
{@render bodyPart()}
|
|
197
191
|
{:else if hasTitle}
|
|
198
|
-
<div class={`${prefix}-header
|
|
192
|
+
<div class={[`${prefix}-header`, classNames?.header]} style={styles?.header}>
|
|
199
193
|
{@render iconPart()}
|
|
200
194
|
<!-- h5 look, h2 outline: the sheet's title is level 2 as well -->
|
|
201
195
|
<h2 class={[typographyClasses.PREFIX, `${typographyClasses.PREFIX}-h5`, `${prefix}-title`]} id={`${idPrefix}-title`} x-semi-prop="title">
|
|
@@ -216,7 +210,7 @@
|
|
|
216
210
|
</div>
|
|
217
211
|
{/if}
|
|
218
212
|
{#if footer}
|
|
219
|
-
<div class={`${prefix}-footer
|
|
213
|
+
<div class={[`${prefix}-footer`, classNames?.footer]} style={styles?.footer} x-semi-prop="footer">
|
|
220
214
|
{@render footer()}
|
|
221
215
|
</div>
|
|
222
216
|
{/if}
|
|
@@ -236,7 +230,7 @@
|
|
|
236
230
|
]}
|
|
237
231
|
>
|
|
238
232
|
{#if mask}
|
|
239
|
-
<div {@attach maskAnimation.attach} class={[`${prefix}-mask`, maskAnimation.className]} style={
|
|
233
|
+
<div {@attach maskAnimation.attach} class={[`${prefix}-mask`, maskAnimation.className, classNames?.mask]} style={styles?.mask} style:display={maskAnimation.displayed ? undefined : 'none'}></div>
|
|
240
234
|
{/if}
|
|
241
235
|
<div class={[`${prefix}-wrap`, { [`${prefix}-wrap-center`]: centered }]} role="none" onclick={maskClosable ? (event) => foundation.handleMaskClick(event) : undefined} onmouseup={maskClosable ? () => foundation.handleMaskMouseUp() : undefined}>
|
|
242
236
|
<!-- marked only while the mask listens, since only its mouseup clears the mark -->
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ClassValue, HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { type ModalPart } from '@fibrae/semi-foundation/components/modal/constants';
|
|
3
4
|
import type { Size } from '@fibrae/semi-foundation/components/modal/modal-foundation';
|
|
4
5
|
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'children'> {
|
|
5
6
|
visible: boolean;
|
|
@@ -18,8 +19,8 @@ interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'children
|
|
|
18
19
|
modal?: Snippet<[{
|
|
19
20
|
modal: Snippet;
|
|
20
21
|
}]>;
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
classNames?: Partial<Record<ModalPart, ClassValue>>;
|
|
23
|
+
styles?: Partial<Record<ModalPart, string>>;
|
|
23
24
|
centered: boolean;
|
|
24
25
|
closable: boolean;
|
|
25
26
|
closeOnEsc: boolean;
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
let {
|
|
23
23
|
visible = $bindable(),
|
|
24
24
|
afterClose,
|
|
25
|
-
bodyStyle = defaults('bodyStyle'),
|
|
26
25
|
cancelButtonProps = defaults('cancelButtonProps'),
|
|
27
26
|
cancelLoading = defaults('cancelLoading'),
|
|
28
27
|
cancelText = defaults('cancelText'),
|
|
29
28
|
centered = defaults('centered', false),
|
|
29
|
+
classNames = defaults('classNames'),
|
|
30
30
|
closable = defaults('closable', true),
|
|
31
31
|
closeOnEsc = defaults('closeOnEsc', true),
|
|
32
32
|
confirmLoading = defaults('confirmLoading'),
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
mask = defaults('mask', true),
|
|
41
41
|
maskClosable = defaults('maskClosable', true),
|
|
42
42
|
maskFixed = defaults('maskFixed', false),
|
|
43
|
-
maskStyle = defaults('maskStyle'),
|
|
44
43
|
modalContentClass = defaults('modalContentClass'),
|
|
45
44
|
motion = defaults('motion', true),
|
|
46
45
|
okButtonProps = defaults('okButtonProps'),
|
|
@@ -50,6 +49,7 @@
|
|
|
50
49
|
onOk = defaults('onOk'),
|
|
51
50
|
preventScroll = defaults('preventScroll'),
|
|
52
51
|
size = defaults('size', 'small'),
|
|
52
|
+
styles = defaults('styles'),
|
|
53
53
|
title = defaults('title'),
|
|
54
54
|
width = defaults('width'),
|
|
55
55
|
zIndex = defaults('zIndex', 1000),
|
|
@@ -197,10 +197,10 @@
|
|
|
197
197
|
<ModalContent
|
|
198
198
|
{...rest}
|
|
199
199
|
bind:this={contentRef}
|
|
200
|
-
{bodyStyle}
|
|
201
200
|
{centered}
|
|
202
201
|
children={body}
|
|
203
202
|
class={[rest.class, { [`${cssClasses.DIALOG}-displayNone`]: keepDOM && hidden }]}
|
|
203
|
+
{classNames}
|
|
204
204
|
{closable}
|
|
205
205
|
{closeIcon}
|
|
206
206
|
{closeOnEsc}
|
|
@@ -215,13 +215,13 @@
|
|
|
215
215
|
{mask}
|
|
216
216
|
{maskClosable}
|
|
217
217
|
{maskFixed}
|
|
218
|
-
{maskStyle}
|
|
219
218
|
{modal}
|
|
220
219
|
{motion}
|
|
221
220
|
onAfterLeave={() => (displayNone = true)}
|
|
222
221
|
onClose={cancel}
|
|
223
222
|
{preventScroll}
|
|
224
223
|
{size}
|
|
224
|
+
{styles}
|
|
225
225
|
{title}
|
|
226
226
|
visible={open}
|
|
227
227
|
{width}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { ClassValue, HTMLAnchorAttributes, HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { NavPart, SubNavPart } from '@fibrae/semi-foundation/components/navigation/constants';
|
|
3
4
|
import type { ItemKey } from '@fibrae/semi-foundation/components/navigation/item-foundation';
|
|
4
5
|
import type { IconSize } from '@fibrae/semi-icons-svelte';
|
|
5
6
|
import type { DropdownProps } from '../dropdown/index.js';
|
|
@@ -54,13 +55,14 @@ export interface SelectedData {
|
|
|
54
55
|
}
|
|
55
56
|
export type SubDropdownProps = DropdownProps;
|
|
56
57
|
export interface SubNavProps extends Omit<HTMLAttributes<HTMLLIElement>, 'children'> {
|
|
58
|
+
classNames?: Partial<Record<SubNavPart, ClassValue>>;
|
|
57
59
|
disabled?: boolean;
|
|
58
60
|
dropdownProps?: SubDropdownProps;
|
|
59
|
-
/** Wins over the style in dropdownProps */
|
|
60
|
-
dropdownStyle?: string;
|
|
61
61
|
indent?: boolean;
|
|
62
62
|
itemKey?: ItemKey;
|
|
63
63
|
level?: number;
|
|
64
|
+
/** `dropdown` wins over the style in dropdownProps */
|
|
65
|
+
styles?: Partial<Record<SubNavPart, string>>;
|
|
64
66
|
/** Applies when dropdownProps is not given */
|
|
65
67
|
subDropdownProps?: SubDropdownProps;
|
|
66
68
|
text?: string | number;
|
|
@@ -95,15 +97,16 @@ export interface NavCollapseButtonProps {
|
|
|
95
97
|
onToggle: () => void;
|
|
96
98
|
}
|
|
97
99
|
export interface NavItemConfig extends EntryAttributes {
|
|
100
|
+
classNames?: Partial<Record<SubNavPart, ClassValue>>;
|
|
98
101
|
disabled?: boolean;
|
|
99
102
|
dropdownProps?: SubDropdownProps;
|
|
100
|
-
dropdownStyle?: string;
|
|
101
103
|
indent?: boolean;
|
|
102
104
|
isCollapsed?: boolean;
|
|
103
105
|
itemKey?: ItemKey;
|
|
104
106
|
items?: (string | NavItemConfig)[];
|
|
105
107
|
link?: string;
|
|
106
108
|
linkOptions?: NavLinkOptions;
|
|
109
|
+
styles?: Partial<Record<SubNavPart, string>>;
|
|
107
110
|
text?: string | number;
|
|
108
111
|
tooltipHideDelay?: number;
|
|
109
112
|
tooltipShowDelay?: number;
|
|
@@ -146,7 +149,8 @@ export interface NavItemRenderProps {
|
|
|
146
149
|
level: number;
|
|
147
150
|
}
|
|
148
151
|
export interface NavProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
|
|
149
|
-
|
|
152
|
+
classNames?: Partial<Record<NavPart, ClassValue>>;
|
|
153
|
+
styles?: Partial<Record<NavPart, string>>;
|
|
150
154
|
/** Applies in vertical mode only; bindable */
|
|
151
155
|
isCollapsed?: boolean;
|
|
152
156
|
items?: NavItems;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
let { items, level, subDropdownProps, icon, text, toggleIcon, expandIcon }: NavItemsProps = $props();
|
|
20
20
|
|
|
21
21
|
const ITEM_KEYS = new Set(['itemKey', 'text', 'disabled', 'indent', 'link', 'linkOptions', 'tooltipShowDelay', 'tooltipHideDelay']);
|
|
22
|
-
const SUB_KEYS = new Set(['itemKey', 'text', 'disabled', 'indent', '
|
|
22
|
+
const SUB_KEYS = new Set(['itemKey', 'text', 'disabled', 'indent', 'classNames', 'styles', 'dropdownProps']);
|
|
23
23
|
const LI_KEYS = new Set(['class', 'style', 'onmouseenter', 'onmouseleave']);
|
|
24
24
|
|
|
25
25
|
// An entry may carry app data (e.g. `path`); only the declared keys, li attributes, data-* and aria-* reach the item
|
|
@@ -21,10 +21,11 @@
|
|
|
21
21
|
isCollapsed = $bindable(),
|
|
22
22
|
openKeys = $bindable(),
|
|
23
23
|
selectedKeys = $bindable(),
|
|
24
|
-
|
|
24
|
+
classNames = defaults('classNames'),
|
|
25
25
|
items = defaults('items'),
|
|
26
26
|
limitIndent = defaults('limitIndent', true),
|
|
27
27
|
mode = defaults('mode', 'vertical'),
|
|
28
|
+
styles = defaults('styles'),
|
|
28
29
|
subDropdownProps = defaults('subDropdownProps'),
|
|
29
30
|
subNavCloseDelay = defaults('subNavCloseDelay', numbers.DEFAULT_SUBNAV_CLOSE_DELAY),
|
|
30
31
|
subNavMotion = defaults('subNavMotion', true),
|
|
@@ -200,7 +201,7 @@
|
|
|
200
201
|
{:else if header}
|
|
201
202
|
<NavHeader {...header} />
|
|
202
203
|
{/if}
|
|
203
|
-
<div class={`${prefix}-list-wrapper
|
|
204
|
+
<div class={[`${prefix}-list-wrapper`, classNames?.body]} style={styles?.body}>
|
|
204
205
|
<ul class={`${prefix}-list`}>
|
|
205
206
|
{#if formatted.formattedItems.length}
|
|
206
207
|
<NavItems {expandIcon} {icon} items={formatted.formattedItems} level={0} {subDropdownProps} {text} {toggleIcon} />
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
type TitleTriggerProps = Omit<Partial<DropdownTriggerProps>, 'aria-haspopup' | 'aria-expanded'> & { 'aria-haspopup'?: 'menu' | 'dialog'; 'aria-expanded'?: boolean | 'true' | 'false' };
|
|
22
22
|
|
|
23
23
|
// Left undefined when not passed, so `wrapper` receives only what the Sub was given
|
|
24
|
-
let { disabled, dropdownProps,
|
|
24
|
+
let { classNames, disabled, dropdownProps, indent, itemKey, level: ownLevel, styles, subDropdownProps, text, children, label, icon, expandIcon, ...rest }: SubNavProps = $props();
|
|
25
25
|
|
|
26
26
|
const outer = getNavContext('Nav.Sub');
|
|
27
27
|
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
// A disabled Sub opens no Dropdown; collapsed, it shows its hidden text in a tooltip instead
|
|
69
69
|
const titleWrapper = $derived(outer.isCollapsed && disabled ? 'tooltip' : isPopup && !disabled ? 'dropdown' : 'none');
|
|
70
70
|
|
|
71
|
-
// Defaults first: user dropdownProps win,
|
|
71
|
+
// Defaults first: user dropdownProps win, styles.dropdown beats their style, our onVisibleChange runs first
|
|
72
72
|
const dropdown: DropdownProps = $derived.by(() => {
|
|
73
73
|
const user = dropdownProps ?? subDropdownProps;
|
|
74
74
|
return {
|
|
@@ -78,7 +78,8 @@
|
|
|
78
78
|
trigger: 'hover',
|
|
79
79
|
...user,
|
|
80
80
|
class: [outer.isCollapsed ? `${prefix}-popover` : undefined, user?.class].filter(Boolean).join(' ') || undefined,
|
|
81
|
-
|
|
81
|
+
classNames: classNames?.dropdown ? { ...user?.classNames, content: [user?.classNames?.content, classNames.dropdown] } : user?.classNames,
|
|
82
|
+
style: styles?.dropdown ?? user?.style,
|
|
82
83
|
onVisibleChange: (visible: boolean) => {
|
|
83
84
|
foundation.handleDropdownVisibleChange(visible);
|
|
84
85
|
user?.onVisibleChange?.(visible);
|
|
@@ -86,7 +87,7 @@
|
|
|
86
87
|
};
|
|
87
88
|
});
|
|
88
89
|
|
|
89
|
-
const given: NavWrapperArgs['props'] = $derived(Object.fromEntries(Object.entries({ disabled, dropdownProps,
|
|
90
|
+
const given: NavWrapperArgs['props'] = $derived(Object.fromEntries(Object.entries({ classNames, disabled, dropdownProps, indent, itemKey, level: ownLevel, styles, subDropdownProps, text }).filter(([, value]) => value !== undefined)));
|
|
90
91
|
|
|
91
92
|
// aria-* describe the title, which takes focus; the rest reaches the wrapper li
|
|
92
93
|
const attrs = $derived(splitControlAttrs(rest, isAriaKey));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ClassValue, HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { OverflowListPart } from '@fibrae/semi-foundation/components/overflow-list/constants';
|
|
3
4
|
export type OverflowListItem = Record<string, any>;
|
|
4
5
|
export type OverflowListKey = string | number;
|
|
5
6
|
export interface OverflowListItemSnippetProps<T> {
|
|
@@ -24,10 +25,10 @@ export interface OverflowListProps<T> extends Omit<HTMLAttributes<HTMLDivElement
|
|
|
24
25
|
overflowRenderDirection?: 'both' | 'start' | 'end';
|
|
25
26
|
renderMode?: 'collapse' | 'scroll';
|
|
26
27
|
threshold?: number;
|
|
27
|
-
|
|
28
|
+
classNames?: Partial<Record<OverflowListPart, ClassValue>>;
|
|
29
|
+
styles?: Partial<Record<OverflowListPart, string>>;
|
|
28
30
|
/** Attributes of the scroll-mode wrapper that holds the visible items, such as a role that owns them */
|
|
29
31
|
wrapperProps?: HTMLAttributes<HTMLDivElement>;
|
|
30
|
-
wrapperStyle?: string;
|
|
31
32
|
/** Scroll mode wraps each item in a `display: contents` element and observes the first element the snippet renders */
|
|
32
33
|
item?: Snippet<[OverflowListItemSnippetProps<T>]>;
|
|
33
34
|
overflow?: Snippet<[OverflowListOverflowSnippetProps<T>]>;
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
overflowRenderDirection = defaults('overflowRenderDirection', 'both'),
|
|
23
23
|
renderMode = defaults('renderMode', 'collapse'),
|
|
24
24
|
threshold = defaults('threshold', 0.75),
|
|
25
|
-
|
|
25
|
+
classNames = defaults('classNames'),
|
|
26
|
+
styles = defaults('styles'),
|
|
26
27
|
wrapperProps = defaults('wrapperProps'),
|
|
27
|
-
wrapperStyle = defaults('wrapperStyle'),
|
|
28
28
|
item,
|
|
29
29
|
overflow,
|
|
30
30
|
onOverflow,
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
{#if overflowRenderDirection === 'start'}
|
|
175
175
|
{@render overflow?.({ items: scrollOverflow[1], position: 'end' })}
|
|
176
176
|
{/if}
|
|
177
|
-
<div bind:this={wrapper} {...wrapperProps} class={[
|
|
177
|
+
<div bind:this={wrapper} {...wrapperProps} class={[cssClasses.SCROLL_WRAPPER, classNames?.wrapper]} style={styles?.wrapper}>
|
|
178
178
|
{#each scrollItems as entry (entry.key)}
|
|
179
179
|
{@const key = entry.key}
|
|
180
180
|
<span {@attach markScrollItem(key, onScrollElement)} style="display: contents">
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
import type { Position } from '../tooltip/index.js';
|
|
4
|
-
export interface PaginationProps extends Omit<HTMLAttributes<
|
|
4
|
+
export interface PaginationProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
|
|
5
5
|
total?: number;
|
|
6
6
|
showTotal?: boolean;
|
|
7
7
|
/** Bindable; the size changer writes the chosen size back. Leave it out for an uncontrolled size */
|
|
@@ -164,77 +164,79 @@
|
|
|
164
164
|
{/snippet}
|
|
165
165
|
|
|
166
166
|
{#if !view.hidden}
|
|
167
|
-
<
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
<StepButton disabled={disabledState.prevDisabled || disabled} kind="prev" label={text.prev} text={prevText} onclick={foundation.goPrev} />
|
|
173
|
-
</li>
|
|
174
|
-
{#if size === 'small'}
|
|
167
|
+
<nav {...rest} aria-label={rest['aria-label'] ?? text.label} class={[`${prefix}-wrapper`, rest.class]}>
|
|
168
|
+
<ul class={[prefix, { [`${prefix}-small`]: size === 'small', [`${prefix}-disabled`]: disabled }]}>
|
|
169
|
+
{#if showTotal && size !== 'small'}
|
|
170
|
+
<li class={`${prefix}-total`}>{formatLocale(text.total, { total: view.totalPageNum })}</li>
|
|
171
|
+
{/if}
|
|
175
172
|
<li>
|
|
176
|
-
{
|
|
177
|
-
<Popover>
|
|
178
|
-
{#snippet child({ props })}
|
|
179
|
-
<button {...props} class={`${prefix}-item ${prefix}-item-small`} type="button">{smallText}</button>
|
|
180
|
-
{/snippet}
|
|
181
|
-
{#snippet content()}
|
|
182
|
-
<RestPages count={view.totalPageNum} onSelect={foundation.goPage} start={1} />
|
|
183
|
-
{/snippet}
|
|
184
|
-
</Popover>
|
|
185
|
-
{:else}
|
|
186
|
-
<div class={[`${prefix}-item`, `${prefix}-item-small`, { [`${prefix}-item-all-disabled`]: disabled }]}>
|
|
187
|
-
{smallText}
|
|
188
|
-
</div>
|
|
189
|
-
{/if}
|
|
173
|
+
<StepButton disabled={disabledState.prevDisabled || disabled} kind="prev" label={text.prev} text={prevText} onclick={foundation.goPrev} />
|
|
190
174
|
</li>
|
|
191
|
-
|
|
192
|
-
{#each pageData.pageList as page, i (page === '...' ? (i < 3 ? 'rest-left' : 'rest-right') : page)}
|
|
175
|
+
{#if size === 'small'}
|
|
193
176
|
<li>
|
|
194
|
-
{#if
|
|
195
|
-
<Popover
|
|
177
|
+
{#if hoverShowPageSelect && !disabled}
|
|
178
|
+
<Popover>
|
|
196
179
|
{#snippet child({ props })}
|
|
197
|
-
{
|
|
180
|
+
<button {...props} class={`${prefix}-item ${prefix}-item-small`} type="button">{smallText}</button>
|
|
198
181
|
{/snippet}
|
|
199
182
|
{#snippet content()}
|
|
200
|
-
<RestPages {
|
|
183
|
+
<RestPages count={view.totalPageNum} onSelect={foundation.goPage} start={1} />
|
|
201
184
|
{/snippet}
|
|
202
185
|
</Popover>
|
|
203
186
|
{:else}
|
|
204
|
-
{
|
|
187
|
+
<div class={[`${prefix}-item`, `${prefix}-item-small`, { [`${prefix}-item-all-disabled`]: disabled }]}>
|
|
188
|
+
{smallText}
|
|
189
|
+
</div>
|
|
205
190
|
{/if}
|
|
206
191
|
</li>
|
|
207
|
-
{
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
showClear={false}
|
|
228
|
-
value={states().pageSize}
|
|
229
|
-
/>
|
|
230
|
-
</li>
|
|
231
|
-
{/if}
|
|
232
|
-
{#if showQuickJumper}
|
|
233
|
-
<li class={[`${prefix}-quickjump`, { [`${prefix}-quickjump-disabled`]: view.quickJumpDisabled }]}>
|
|
234
|
-
<span>{text.jumpTo}</span>
|
|
235
|
-
<InputNumber aria-label={text.jumpTo} class={`${prefix}-quickjump-input-number`} disabled={view.quickJumpDisabled} hideButtons onBlur={foundation.handleQuickJumpBlur} onChange={foundation.handleQuickJumpNumberChange} onKeyDown={onQuickJumpKeydown} showClear={false} value={states().quickJumpPage} />
|
|
236
|
-
<span>{text.page}</span>
|
|
192
|
+
{:else}
|
|
193
|
+
{#each pageData.pageList as page, i (page === '...' ? (i < 3 ? 'rest-left' : 'rest-right') : page)}
|
|
194
|
+
<li>
|
|
195
|
+
{#if isRest(page)}
|
|
196
|
+
<Popover position={popoverPosition} trigger="hover">
|
|
197
|
+
{#snippet child({ props })}
|
|
198
|
+
{@render pageButton(page, props)}
|
|
199
|
+
{/snippet}
|
|
200
|
+
{#snippet content()}
|
|
201
|
+
<RestPages {...i < 3 ? pageData.restLeftRange : pageData.restRightRange} onSelect={foundation.goPage} />
|
|
202
|
+
{/snippet}
|
|
203
|
+
</Popover>
|
|
204
|
+
{:else}
|
|
205
|
+
{@render pageButton(page)}
|
|
206
|
+
{/if}
|
|
207
|
+
</li>
|
|
208
|
+
{/each}
|
|
209
|
+
{/if}
|
|
210
|
+
<li>
|
|
211
|
+
<StepButton disabled={disabledState.nextDisabled || disabled} kind="next" label={text.next} text={nextText} onclick={foundation.goNext} />
|
|
237
212
|
</li>
|
|
238
|
-
|
|
239
|
-
|
|
213
|
+
{#if view.sizeChangerShown}
|
|
214
|
+
<li class={`${prefix}-switch`}>
|
|
215
|
+
<!-- changePageSize takes one number: global Select defaults must not make it search, create, multiple or object-valued, nor add a clear button -->
|
|
216
|
+
<Select
|
|
217
|
+
allowCreate={false}
|
|
218
|
+
aria-label={text.pageSizeSelector}
|
|
219
|
+
classNames={{ dropdown: `${prefix}-select-dropdown` }}
|
|
220
|
+
clickToHide
|
|
221
|
+
{disabled}
|
|
222
|
+
filter={false}
|
|
223
|
+
multiple={false}
|
|
224
|
+
onChange={changePageSize}
|
|
225
|
+
onChangeWithObject={false}
|
|
226
|
+
optionList={sizeOptions}
|
|
227
|
+
position={view.switchPosition}
|
|
228
|
+
showClear={false}
|
|
229
|
+
value={states().pageSize}
|
|
230
|
+
/>
|
|
231
|
+
</li>
|
|
232
|
+
{/if}
|
|
233
|
+
{#if showQuickJumper}
|
|
234
|
+
<li class={[`${prefix}-quickjump`, { [`${prefix}-quickjump-disabled`]: view.quickJumpDisabled }]}>
|
|
235
|
+
<span>{text.jumpTo}</span>
|
|
236
|
+
<InputNumber aria-label={text.jumpTo} class={`${prefix}-quickjump-input-number`} disabled={view.quickJumpDisabled} hideButtons onBlur={foundation.handleQuickJumpBlur} onChange={foundation.handleQuickJumpNumberChange} onKeyDown={onQuickJumpKeydown} showClear={false} value={states().quickJumpPage} />
|
|
237
|
+
<span>{text.page}</span>
|
|
238
|
+
</li>
|
|
239
|
+
{/if}
|
|
240
|
+
</ul>
|
|
241
|
+
</nav>
|
|
240
242
|
{/if}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ClassValue } from 'svelte/elements';
|
|
3
|
+
import type { PopconfirmPart } from '@fibrae/semi-foundation/components/popconfirm/constants';
|
|
2
4
|
import type { ButtonProps, Type as ButtonType } from '../button/interface.js';
|
|
3
5
|
import type { PopoverProps } from '../popover/index.js';
|
|
4
6
|
import type { RenderContentProps } from '../tooltip/index.js';
|
|
@@ -11,6 +13,7 @@ export interface PopconfirmProps extends Omit<PopoverProps, 'content'> {
|
|
|
11
13
|
cancelButtonProps?: PopconfirmButtonProps;
|
|
12
14
|
cancelText?: string;
|
|
13
15
|
cancelType?: ButtonType;
|
|
16
|
+
classNames?: Partial<Record<PopconfirmPart, ClassValue>>;
|
|
14
17
|
disabled?: boolean;
|
|
15
18
|
okButtonProps?: PopconfirmButtonProps;
|
|
16
19
|
okText?: string;
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
condition = defaults('condition'),
|
|
57
57
|
mouseEnterDelay = defaults('mouseEnterDelay'),
|
|
58
58
|
mouseLeaveDelay = defaults('mouseLeaveDelay'),
|
|
59
|
-
|
|
59
|
+
classNames = defaults('classNames'),
|
|
60
60
|
spacing = defaults('spacing'),
|
|
61
|
-
|
|
61
|
+
styles = defaults('styles'),
|
|
62
62
|
'aria-label': ariaLabel = defaults('aria-label'),
|
|
63
63
|
'aria-labelledby': ariaLabelledby = defaults('aria-labelledby'),
|
|
64
64
|
'aria-describedby': ariaDescribedby = defaults('aria-describedby'),
|
|
@@ -257,18 +257,17 @@
|
|
|
257
257
|
aria-label={ariaLabel}
|
|
258
258
|
aria-labelledby={labelledBy}
|
|
259
259
|
{arrowPointAtCenter}
|
|
260
|
-
{arrowStyle}
|
|
261
260
|
{autoAdjustOverflow}
|
|
262
261
|
bind:this={popover}
|
|
263
262
|
bind:visible={() => !disabled && popoverVisible, (next) => foundation.handleVisibleChange(Boolean(next))}
|
|
264
263
|
{child}
|
|
265
264
|
{children}
|
|
266
265
|
class={cssClasses.POPOVER}
|
|
266
|
+
{classNames}
|
|
267
267
|
{clickToHide}
|
|
268
268
|
{closeOnEsc}
|
|
269
269
|
{condition}
|
|
270
270
|
content={card}
|
|
271
|
-
{contentClassName}
|
|
272
271
|
{disableArrowKeyDown}
|
|
273
272
|
{disableFocusListener}
|
|
274
273
|
{guardFocus}
|
|
@@ -285,5 +284,6 @@
|
|
|
285
284
|
{showArrow}
|
|
286
285
|
{spacing}
|
|
287
286
|
{stopPropagation}
|
|
287
|
+
{styles}
|
|
288
288
|
trigger={disabled ? 'custom' : trigger}
|
|
289
289
|
/>
|