@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { cssClasses } from '@fibrae/semi-foundation/components/popover/constants';
|
|
3
3
|
import type { ArrowProps } from './interface.js';
|
|
4
4
|
|
|
5
|
-
let { position = '', arrowStyle, popStyle }: ArrowProps = $props();
|
|
5
|
+
let { position = '', arrowStyle, class: className, popStyle }: ArrowProps = $props();
|
|
6
6
|
|
|
7
7
|
const vertical = $derived(position.startsWith('top') || position.startsWith('bottom'));
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
const backgroundColor = $derived(arrowStyle?.backgroundColor ?? readStyle('background-color'));
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
|
-
<svg aria-hidden="true" class={cssClasses.ARROW} height="8" width="24" xmlns="http://www.w3.org/2000/svg">
|
|
15
|
+
<svg aria-hidden="true" class={[cssClasses.ARROW, className]} height="8" width="24" xmlns="http://www.w3.org/2000/svg">
|
|
16
16
|
{#if vertical}
|
|
17
17
|
<path d="M0 0.5L0 1.5C4 1.5, 5.5 3, 7.5 5S10,8 12,8S14.5 7, 16.5 5S20,1.5 24,1.5L24 0.5L0 0.5z" style:fill={borderColor} style:opacity={arrowStyle?.borderOpacity} />
|
|
18
18
|
<path d="M0 0L0 1C4 1, 5.5 2, 7.5 4S10,7 12,7S14.5 6, 16.5 4S20,1 24,1L24 0L0 0z" style:fill={backgroundColor} />
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ClassValue } from 'svelte/elements';
|
|
2
|
+
import type { PopoverPart } from '@fibrae/semi-foundation/components/popover/constants';
|
|
2
3
|
import type { TooltipProps } from '../tooltip/index.js';
|
|
3
4
|
export interface ArrowStyle {
|
|
4
5
|
borderColor?: string;
|
|
@@ -7,8 +8,9 @@ export interface ArrowStyle {
|
|
|
7
8
|
}
|
|
8
9
|
export interface ArrowProps {
|
|
9
10
|
position?: string;
|
|
11
|
+
class?: ClassValue;
|
|
10
12
|
arrowStyle?: ArrowStyle;
|
|
11
|
-
/** The popup's style string; its `background-color` and `border-color` color the arrow without
|
|
13
|
+
/** The popup's style string; its `background-color` and `border-color` color the arrow without styles.arrow */
|
|
12
14
|
popStyle?: string;
|
|
13
15
|
}
|
|
14
16
|
export interface PopoverProps {
|
|
@@ -36,14 +38,17 @@ export interface PopoverProps {
|
|
|
36
38
|
mouseEnterDelay?: number;
|
|
37
39
|
mouseLeaveDelay?: number;
|
|
38
40
|
trigger?: TooltipProps['trigger'];
|
|
39
|
-
|
|
41
|
+
classNames?: Partial<Record<PopoverPart, ClassValue>>;
|
|
40
42
|
showArrow?: boolean;
|
|
41
43
|
spacing?: number | {
|
|
42
44
|
x: number;
|
|
43
45
|
y: number;
|
|
44
46
|
};
|
|
45
47
|
stopPropagation?: boolean | string;
|
|
46
|
-
|
|
48
|
+
styles?: {
|
|
49
|
+
content?: string;
|
|
50
|
+
arrow?: ArrowStyle;
|
|
51
|
+
};
|
|
47
52
|
arrowPointAtCenter?: boolean;
|
|
48
53
|
closeOnEsc?: boolean;
|
|
49
54
|
guardFocus?: boolean;
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
role = defaults('role'),
|
|
30
30
|
mouseEnterDelay = defaults('mouseEnterDelay'),
|
|
31
31
|
mouseLeaveDelay = defaults('mouseLeaveDelay'),
|
|
32
|
-
|
|
32
|
+
classNames = defaults('classNames'),
|
|
33
33
|
spacing = defaults('spacing'),
|
|
34
34
|
stopPropagation = defaults('stopPropagation'),
|
|
35
|
-
|
|
35
|
+
styles = defaults('styles'),
|
|
36
36
|
arrowPointAtCenter = defaults('arrowPointAtCenter'),
|
|
37
37
|
clickToHide = defaults('clickToHide'),
|
|
38
38
|
disableArrowKeyDown = defaults('disableArrowKeyDown'),
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
</script>
|
|
76
76
|
|
|
77
77
|
{#snippet card(slotProps: RenderContentProps)}
|
|
78
|
-
<div class={[prefixCls,
|
|
78
|
+
<div class={[prefixCls, classNames?.content]} style={styles?.content}>
|
|
79
79
|
<div class={`${prefixCls}-content`}>
|
|
80
80
|
{@render content?.(slotProps)}
|
|
81
81
|
</div>
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
{/snippet}
|
|
84
84
|
|
|
85
85
|
{#snippet popArrow()}
|
|
86
|
-
<Arrow {
|
|
86
|
+
<Arrow arrowStyle={styles?.arrow} class={classNames?.arrow} popStyle={style} {position} />
|
|
87
87
|
{/snippet}
|
|
88
88
|
|
|
89
89
|
<Tooltip
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ClassValue, HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
|
|
3
|
+
import type { RadioPart } from '@fibrae/semi-foundation/components/radio/constants';
|
|
3
4
|
export type RadioValue = string | number | boolean;
|
|
4
5
|
export type RadioType = 'default' | 'button' | 'card' | 'pureCard';
|
|
5
6
|
export type RadioMode = 'advanced' | '';
|
|
@@ -25,8 +26,8 @@ export interface RadioProps extends Omit<HTMLAttributes<HTMLLabelElement>, 'onch
|
|
|
25
26
|
displayMode?: RadioDisplayMode;
|
|
26
27
|
mode?: RadioMode;
|
|
27
28
|
type?: RadioType;
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
classNames?: Partial<Record<RadioPart, ClassValue>>;
|
|
30
|
+
styles?: Partial<Record<RadioPart, string>>;
|
|
30
31
|
addonId?: string;
|
|
31
32
|
extraId?: string;
|
|
32
33
|
preventScroll?: boolean;
|
|
@@ -42,8 +43,8 @@ export interface RadioOptionItem {
|
|
|
42
43
|
class?: string;
|
|
43
44
|
style?: string;
|
|
44
45
|
addonId?: string;
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
classNames?: Partial<Record<RadioPart, ClassValue>>;
|
|
47
|
+
styles?: Partial<Record<RadioPart, string>>;
|
|
47
48
|
extraId?: string;
|
|
48
49
|
}
|
|
49
50
|
export interface RadioGroupOptionSnippetParams {
|
|
@@ -133,15 +133,15 @@
|
|
|
133
133
|
{#if extra}{@render extra({ option, index })}{:else}{option.extra}{/if}
|
|
134
134
|
{/snippet}
|
|
135
135
|
<Radio
|
|
136
|
-
addonClassName={option.addonClass}
|
|
137
136
|
addonId={option.addonId}
|
|
138
|
-
addonStyle={option.addonStyle}
|
|
139
137
|
children={option.label !== undefined || label ? optionLabel : undefined}
|
|
140
138
|
class={option.class}
|
|
139
|
+
classNames={option.classNames}
|
|
141
140
|
disabled={option.disabled || disabled}
|
|
142
141
|
extra={option.extra !== undefined || extra ? optionExtra : undefined}
|
|
143
142
|
extraId={option.extraId}
|
|
144
143
|
style={option.style}
|
|
144
|
+
styles={option.styles}
|
|
145
145
|
value={option.value}
|
|
146
146
|
/>
|
|
147
147
|
{/each}
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
displayMode = defaults('displayMode'),
|
|
24
24
|
mode = defaults('mode', ''),
|
|
25
25
|
type = defaults('type', 'default'),
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
classNames = defaults('classNames'),
|
|
27
|
+
styles = defaults('styles'),
|
|
28
28
|
addonId,
|
|
29
29
|
extraId,
|
|
30
30
|
preventScroll = defaults('preventScroll'),
|
|
@@ -210,7 +210,6 @@
|
|
|
210
210
|
{#if children}
|
|
211
211
|
<span
|
|
212
212
|
class={[
|
|
213
|
-
addonClassName,
|
|
214
213
|
{
|
|
215
214
|
[`${prefix}-addon`]: !view.isButtonRadio,
|
|
216
215
|
[`${prefix}-addon-buttonRadio`]: view.isButtonRadio,
|
|
@@ -218,9 +217,10 @@
|
|
|
218
217
|
[`${prefix}-addon-buttonRadio-disabled`]: view.isButtonRadio && view.disabled,
|
|
219
218
|
[`${prefix}-addon-buttonRadio-${view.buttonSize}`]: view.isButtonRadio && view.buttonSize,
|
|
220
219
|
},
|
|
220
|
+
classNames?.addon,
|
|
221
221
|
]}
|
|
222
222
|
id={addonDomId}
|
|
223
|
-
style={
|
|
223
|
+
style={styles?.addon}
|
|
224
224
|
x-semi-prop="children"
|
|
225
225
|
>
|
|
226
226
|
{@render children()}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { ClassValue, HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { SelectPart } from '@fibrae/semi-foundation/components/select/constants';
|
|
3
4
|
import type { Size } from '@fibrae/semi-foundation/utils';
|
|
4
5
|
import type { InputProps, ValidateStatus } from '../input/index.js';
|
|
5
6
|
import type { PopoverProps } from '../popover/index.js';
|
|
@@ -110,8 +111,8 @@ export interface SelectProps extends Omit<HTMLAttributes<HTMLDivElement>, Native
|
|
|
110
111
|
showClear?: boolean;
|
|
111
112
|
insetLabelId?: string;
|
|
112
113
|
inputProps?: SelectInputProps;
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
classNames?: Partial<Record<SelectPart, ClassValue>>;
|
|
115
|
+
styles?: Partial<Record<SelectPart, string>>;
|
|
115
116
|
dropdownMatchSelectWidth?: boolean;
|
|
116
117
|
position?: Position;
|
|
117
118
|
spacing?: number | {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
{:else if label !== undefined}
|
|
67
67
|
<div class={`${prefixCls}-text`}>
|
|
68
68
|
{#if inputValue}
|
|
69
|
-
<Highlight
|
|
69
|
+
<Highlight classNames={{ highlight: `${prefixCls}-keyword` }} searchWords={[inputValue]} sourceString={String(label)} />
|
|
70
70
|
{:else}
|
|
71
71
|
{label}
|
|
72
72
|
{/if}
|
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
import { FocusTrapHandle } from '@fibrae/semi-foundation/base';
|
|
5
5
|
import { comboboxName } from '@fibrae/semi-foundation/components/select/combobox-name';
|
|
6
6
|
import { cssClasses, numbers, strings } from '@fibrae/semi-foundation/components/select/constants';
|
|
7
|
-
import SelectFoundation, { type SelectAdapter, type SelectBaseProps, type SelectBaseState
|
|
7
|
+
import SelectFoundation, { type SelectAdapter, type SelectBaseProps, type SelectBaseState } from '@fibrae/semi-foundation/components/select/foundation';
|
|
8
8
|
import { type BasicOptionProps, type OptionRecord as BaseOptionRecord, getOptionRuns, toOptionRecord } from '@fibrae/semi-foundation/components/select/option-foundation';
|
|
9
9
|
import { cssClasses as tagCssClasses } from '@fibrae/semi-foundation/components/tag/constants';
|
|
10
|
-
import { isTextEditor, joinIds, toCssLength, getDataAttr } from '@fibrae/semi-foundation/utils';
|
|
10
|
+
import { getOptionId, isTextEditor, joinIds, toCssLength, getDataAttr } from '@fibrae/semi-foundation/utils';
|
|
11
11
|
import '@fibrae/semi-foundation/components/select/select.css';
|
|
12
12
|
import { IconChevronDown, IconClear, IconSearch } from '@fibrae/semi-icons-svelte';
|
|
13
13
|
import { useDefaultProps, useFoundation } from '../../base/index.js';
|
|
14
|
-
import { useClickOutside } from '../../hooks/index.js';
|
|
15
14
|
import { VirtualList } from '../../internal/index.js';
|
|
16
15
|
import { splitControlAttrs, type SlotKind, trackSlotKind } from '../../utils/index.js';
|
|
17
16
|
import { useConfig } from '../config-provider/index.js';
|
|
@@ -23,7 +22,6 @@
|
|
|
23
22
|
import { Space } from '../space/index.js';
|
|
24
23
|
import { Spin } from '../spin/index.js';
|
|
25
24
|
import { Tag, type TagCloseEvent, TagGroup } from '../tag/index.js';
|
|
26
|
-
import { useNestedPopups } from '../tooltip/context.js';
|
|
27
25
|
import type { TooltipTriggerProps } from '../tooltip/index.js';
|
|
28
26
|
import { TypographyText } from '../typography/index.js';
|
|
29
27
|
import type { SelectCreateItemSnippetProps, SelectOptionGroup, SelectOptionItemSnippetProps, SelectOptionProps, SelectProps, SelectSelectedItemSnippetProps, SelectTriggerSnippetProps, SelectValue } from './interface.js';
|
|
@@ -70,8 +68,8 @@
|
|
|
70
68
|
// no global default: a global id would repeat on every instance
|
|
71
69
|
insetLabelId,
|
|
72
70
|
inputProps = defaults('inputProps'),
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
classNames = defaults('classNames'),
|
|
72
|
+
styles = defaults('styles'),
|
|
75
73
|
dropdownMatchSelectWidth = defaults('dropdownMatchSelectWidth', true),
|
|
76
74
|
position = defaults('position'),
|
|
77
75
|
spacing = defaults('spacing'),
|
|
@@ -128,8 +126,6 @@
|
|
|
128
126
|
let previous: OptionRecord[] | undefined;
|
|
129
127
|
const comboboxKeys = new Set(['aria-label', 'aria-labelledby', 'aria-describedby', 'aria-errormessage', 'aria-invalid', 'aria-required']);
|
|
130
128
|
|
|
131
|
-
const nestedPopups = useNestedPopups();
|
|
132
|
-
|
|
133
129
|
// an InputGroup supplies size and disabled when the control is given none; the controls inside this one must not read it again
|
|
134
130
|
const group = getInputGroupInScope();
|
|
135
131
|
const disabled = $derived(disabledProp ?? group?.disabled ?? defaults('disabled') ?? false);
|
|
@@ -261,7 +257,7 @@
|
|
|
261
257
|
...attrs.control,
|
|
262
258
|
role: 'combobox',
|
|
263
259
|
'aria-activedescendant': activeDescendant,
|
|
264
|
-
'aria-controls': listboxId,
|
|
260
|
+
'aria-controls': states().isOpen ? listboxId : undefined,
|
|
265
261
|
'aria-expanded': states().isOpen,
|
|
266
262
|
'aria-haspopup': 'listbox' as const,
|
|
267
263
|
...nameAttrs,
|
|
@@ -309,8 +305,8 @@
|
|
|
309
305
|
return `${group?.key ?? ''}:${rowKey(rows[0].option)}`;
|
|
310
306
|
};
|
|
311
307
|
|
|
312
|
-
const joinStyles = (...
|
|
313
|
-
return
|
|
308
|
+
const joinStyles = (...parts: (string | undefined)[]) => {
|
|
309
|
+
return parts.filter(Boolean).join('; ') || undefined;
|
|
314
310
|
};
|
|
315
311
|
|
|
316
312
|
const handleInputChange = (keyword: string, event?: Event) => {
|
|
@@ -419,8 +415,6 @@
|
|
|
419
415
|
// OverflowList shows the first overflowed item collapsed, so every other one is hidden; [] means all fit
|
|
420
416
|
const handleOverflow = (items: SelectOptionProps[]) => foundation.updateOverflowItemCount(Math.max(items.length - 1, 0));
|
|
421
417
|
|
|
422
|
-
useClickOutside([() => root, () => optionContainer], foundation.handleClickOutside, () => states().isOpen, nestedPopups);
|
|
423
|
-
|
|
424
418
|
// An option list change re-resolves the selection; the first run records the options the initial state read
|
|
425
419
|
$effect(() => {
|
|
426
420
|
const next = collectedOptions;
|
|
@@ -744,7 +738,7 @@
|
|
|
744
738
|
{/snippet}
|
|
745
739
|
|
|
746
740
|
{#snippet panel()}
|
|
747
|
-
<div bind:this={optionContainer} class={[{ [`${cls}-option-list-wrapper`]: !(visibleOptions.length === 0 && emptyHidden) },
|
|
741
|
+
<div bind:this={optionContainer} class={[{ [`${cls}-option-list-wrapper`]: !(visibleOptions.length === 0 && emptyHidden) }, classNames?.dropdown]} style={styles?.dropdown} onkeydown={foundation.handleContainerKeyDown} onmousedown={keepFocusOnPress}>
|
|
748
742
|
{#if outerTopSlot}
|
|
749
743
|
<div class={`${cls}-option-list-outer-top-slot`} onmouseenter={foundation.handleSlotMouseEnter}>
|
|
750
744
|
{@render outerTopSlot()}
|
|
@@ -841,6 +835,7 @@
|
|
|
841
835
|
content={panel}
|
|
842
836
|
disableArrowKeyDown
|
|
843
837
|
{motion}
|
|
838
|
+
onClickOutSide={foundation.handleClickOutside}
|
|
844
839
|
onEscKeyDown={foundation.handleEscKeyDown}
|
|
845
840
|
onOpen={foundation.scrollToSelection}
|
|
846
841
|
position={resolvedPosition}
|
|
@@ -1,32 +1,33 @@
|
|
|
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 { SideSheetPart } from '@fibrae/semi-foundation/components/side-sheet/constants';
|
|
3
4
|
import type { Placement } from '@fibrae/semi-foundation/components/side-sheet/side-sheet-foundation';
|
|
4
5
|
/**
|
|
5
6
|
* `aria-*` and `style` land on the `role="dialog"` element, `class` and the other attributes on the outer
|
|
6
7
|
* `.semi-sidesheet` element.
|
|
7
8
|
*/
|
|
8
9
|
export interface SideSheetProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'style' | 'title'> {
|
|
9
|
-
/** true once
|
|
10
|
+
/** true once the enter animation ends; false once hidden, after the leave animation, or on unmount while shown */
|
|
10
11
|
afterVisibleChange?: (isVisible: boolean) => void;
|
|
11
|
-
bodyStyle?: string;
|
|
12
12
|
/** Lets `width` apply to a top or bottom sheet, which otherwise spans the full width. */
|
|
13
13
|
canVerticalSetWidth?: boolean;
|
|
14
|
+
/** `content` is the role="dialog" element. Merged after the built-in class names of the part's element. */
|
|
15
|
+
classNames?: Partial<Record<SideSheetPart, ClassValue>>;
|
|
14
16
|
closable?: boolean;
|
|
15
17
|
closeOnEsc?: boolean;
|
|
16
18
|
disableScroll?: boolean;
|
|
17
19
|
getPopupContainer?: () => HTMLElement;
|
|
18
|
-
headerStyle?: string;
|
|
19
20
|
height?: number | string;
|
|
20
21
|
keepDOM?: boolean;
|
|
21
22
|
mask?: boolean;
|
|
22
23
|
maskClosable?: boolean;
|
|
23
|
-
maskStyle?: string;
|
|
24
24
|
motion?: boolean;
|
|
25
25
|
/** Close button, mask click and Escape (native KeyboardEvent); `visible` is written back to false first. */
|
|
26
26
|
onCancel?: (event: MouseEvent | KeyboardEvent) => void;
|
|
27
27
|
placement?: Placement;
|
|
28
28
|
size?: 'small' | 'medium' | 'large';
|
|
29
29
|
style?: string;
|
|
30
|
+
styles?: Partial<Record<SideSheetPart, string>>;
|
|
30
31
|
/** A string is the plain-text title, so `title="x"` does not become a native tooltip on the outer element. */
|
|
31
32
|
title?: Snippet | string;
|
|
32
33
|
visible?: boolean;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount, tick, untrack } from 'svelte';
|
|
3
|
+
import { isNil, omitBy } from 'es-toolkit';
|
|
3
4
|
import { cssClasses } from '@fibrae/semi-foundation/components/side-sheet/constants';
|
|
4
5
|
import SideSheetFoundation, { type SideSheetAdapter, type SideSheetProps as SideSheetBaseProps, type SideSheetState } from '@fibrae/semi-foundation/components/side-sheet/side-sheet-foundation';
|
|
5
|
-
import {
|
|
6
|
+
import { toCssLength } from '@fibrae/semi-foundation/utils';
|
|
6
7
|
import '@fibrae/semi-foundation/components/side-sheet/side-sheet.css';
|
|
7
8
|
import { IconClose } from '@fibrae/semi-icons-svelte';
|
|
8
9
|
import { useDefaultProps, useFoundation } from '../../base/index.js';
|
|
9
|
-
import { watch } from '../../hooks/index.js';
|
|
10
|
+
import { useOverlayResources, watch } from '../../hooks/index.js';
|
|
10
11
|
import { Portal } from '../../internal/index.js';
|
|
11
12
|
import { isAriaKey, splitControlAttrs } from '../../utils/index.js';
|
|
12
13
|
import { getConfigContext } from '../config-provider/context.js';
|
|
@@ -22,25 +23,24 @@
|
|
|
22
23
|
// No fallback on `visible`: a bound `undefined` would throw with one, and undefined means closed
|
|
23
24
|
let {
|
|
24
25
|
afterVisibleChange,
|
|
25
|
-
bodyStyle = defaults('bodyStyle'),
|
|
26
26
|
canVerticalSetWidth = defaults('canVerticalSetWidth'),
|
|
27
|
+
classNames = defaults('classNames'),
|
|
27
28
|
closable = defaults('closable', true),
|
|
28
29
|
closeIcon = defaults('closeIcon'),
|
|
29
30
|
closeOnEsc = defaults('closeOnEsc', false),
|
|
30
31
|
disableScroll = defaults('disableScroll', true),
|
|
31
32
|
footer = defaults('footer'),
|
|
32
33
|
getPopupContainer = defaults('getPopupContainer'),
|
|
33
|
-
headerStyle = defaults('headerStyle'),
|
|
34
34
|
height = defaults('height'),
|
|
35
35
|
keepDOM = defaults('keepDOM', false),
|
|
36
36
|
mask = defaults('mask', true),
|
|
37
37
|
maskClosable = defaults('maskClosable', true),
|
|
38
|
-
maskStyle = defaults('maskStyle'),
|
|
39
38
|
motion = defaults('motion', true),
|
|
40
39
|
onCancel,
|
|
41
40
|
placement = defaults('placement', 'right'),
|
|
42
41
|
size = defaults('size', 'small'),
|
|
43
42
|
style = defaults('style'),
|
|
43
|
+
styles = defaults('styles'),
|
|
44
44
|
title = defaults('title'),
|
|
45
45
|
visible = $bindable(),
|
|
46
46
|
width = defaults('width'),
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
const shouldRender = $derived(Boolean(visible) || keepDOM || (motion && !hidden));
|
|
65
65
|
const hasTitle = $derived(typeof title === 'string' ? title !== '' : Boolean(title));
|
|
66
66
|
const sheetSize = $derived(SideSheetFoundation.getSheetSize({ placement, canVerticalSetWidth, width, height, mask }));
|
|
67
|
-
const attrs = $derived(splitControlAttrs(rest, isAriaKey));
|
|
67
|
+
const attrs = $derived(splitControlAttrs(omitBy(rest, isNil), isAriaKey));
|
|
68
68
|
const horizontal = $derived(placement === 'top' || placement === 'bottom');
|
|
69
69
|
const maskAnimation = $derived(animating ? `${prefix}-animation-mask_${animating}` : undefined);
|
|
70
70
|
const dialogAnimation = $derived(animating ? `${prefix}-animation-content_${animating}_${placement}` : undefined);
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
);
|
|
104
104
|
|
|
105
105
|
// aria-* go to the dialog (F12); the title names it unless the caller does, since a generated reference would
|
|
106
|
-
// shadow aria-label
|
|
106
|
+
// shadow aria-label. `attrs` drops attributes bound to undefined, which count as unset and keep these defaults.
|
|
107
107
|
const dialogAttrs = (inBody: boolean) => ({
|
|
108
108
|
'aria-labelledby': !attrs.control['aria-label'] && hasTitle ? `${uid}-title` : undefined,
|
|
109
109
|
'aria-modal': SideSheetFoundation.isModal({ mask, inBody }) ? true : undefined,
|
|
@@ -130,18 +130,17 @@
|
|
|
130
130
|
displayNone = true;
|
|
131
131
|
}
|
|
132
132
|
animating = undefined;
|
|
133
|
+
foundation.handleAnimationEnd();
|
|
133
134
|
};
|
|
134
135
|
|
|
135
|
-
// Before the DOM updates, so the
|
|
136
|
-
//
|
|
137
|
-
// a leave one.
|
|
136
|
+
// Before the DOM updates, so the classes of the new run are in the first render. The initial run is the mount: shown
|
|
137
|
+
// with an enter animation, or hidden without a leave one.
|
|
138
138
|
$effect.pre(() => {
|
|
139
139
|
const open = visible;
|
|
140
140
|
untrack(() => {
|
|
141
141
|
if (open) {
|
|
142
142
|
displayNone = false;
|
|
143
143
|
animating = motion ? 'show' : undefined;
|
|
144
|
-
foundation.recordFocus();
|
|
145
144
|
} else if (started) {
|
|
146
145
|
animating = motion ? 'hide' : undefined;
|
|
147
146
|
}
|
|
@@ -166,19 +165,22 @@
|
|
|
166
165
|
});
|
|
167
166
|
});
|
|
168
167
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
untrack(() => {
|
|
175
|
-
foundation.beforeShow();
|
|
176
|
-
warnIfDialogUnnamed(element, 'SideSheet');
|
|
177
|
-
});
|
|
178
|
-
return foundation.afterHide;
|
|
179
|
-
});
|
|
168
|
+
useOverlayResources(
|
|
169
|
+
foundation,
|
|
170
|
+
() => visible,
|
|
171
|
+
() => Boolean(dialogEl && !hidden && rootEl)
|
|
172
|
+
);
|
|
180
173
|
|
|
181
|
-
watch(
|
|
174
|
+
watch(
|
|
175
|
+
() => hidden,
|
|
176
|
+
(isHidden) => {
|
|
177
|
+
foundation.handleHiddenChange(isHidden);
|
|
178
|
+
// no animation ends a showing without motion
|
|
179
|
+
if (!motion) {
|
|
180
|
+
foundation.handleAnimationEnd();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
);
|
|
182
184
|
|
|
183
185
|
onMount(() => () => foundation.handleHiddenChange(true));
|
|
184
186
|
|
|
@@ -209,21 +211,21 @@
|
|
|
209
211
|
>
|
|
210
212
|
{#if mask}
|
|
211
213
|
<!-- Pointer-only surface: the keyboard closes the sheet with its close button and Escape -->
|
|
212
|
-
<div aria-hidden="true" class={[`${prefix}-mask`, maskAnimation]} style={
|
|
214
|
+
<div aria-hidden="true" class={[`${prefix}-mask`, maskAnimation, classNames?.mask]} style={styles?.mask} onclick={onMaskClick}></div>
|
|
213
215
|
{/if}
|
|
214
216
|
<div
|
|
215
217
|
{...dialogAttrs(inBody)}
|
|
216
218
|
bind:this={dialogEl}
|
|
217
|
-
class={[`${prefix}-inner`, `${prefix}-inner-wrap`, `${prefix}-size-${size}`, dialogAnimation]}
|
|
219
|
+
class={[`${prefix}-inner`, `${prefix}-inner-wrap`, `${prefix}-size-${size}`, dialogAnimation, classNames?.content]}
|
|
218
220
|
role="dialog"
|
|
219
|
-
{style}
|
|
221
|
+
style={[style, styles?.content].filter(Boolean).join('; ') || undefined}
|
|
220
222
|
style:height={toCssLength(sheetSize.dialogHeight)}
|
|
221
223
|
style:width={toCssLength(sheetSize.dialogWidth)}
|
|
222
224
|
tabindex="-1"
|
|
223
225
|
onanimationend={onAnimationEnd}
|
|
224
226
|
>
|
|
225
227
|
<div class={`${prefix}-content`}>
|
|
226
|
-
<div class={`${prefix}-header
|
|
228
|
+
<div class={[`${prefix}-header`, classNames?.header]} style={styles?.header}>
|
|
227
229
|
{#if hasTitle}
|
|
228
230
|
<div aria-level="2" class={`${prefix}-title`} id={`${uid}-title`} role="heading" x-semi-prop="title">
|
|
229
231
|
{#if typeof title === 'string'}{title}{:else}{@render title?.()}{/if}
|
|
@@ -237,11 +239,11 @@
|
|
|
237
239
|
</IconButton>
|
|
238
240
|
{/if}
|
|
239
241
|
</div>
|
|
240
|
-
<div class={`${prefix}-body
|
|
242
|
+
<div class={[`${prefix}-body`, classNames?.body]} style={styles?.body} x-semi-prop="children">
|
|
241
243
|
{@render body?.()}
|
|
242
244
|
</div>
|
|
243
245
|
{#if footer}
|
|
244
|
-
<div class={`${prefix}-footer
|
|
246
|
+
<div class={[`${prefix}-footer`, classNames?.footer]} style={styles?.footer} x-semi-prop="footer">
|
|
245
247
|
{@render footer()}
|
|
246
248
|
</div>
|
|
247
249
|
{/if}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ClassValue, HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
|
|
3
|
+
import type { SliderPart } from '@fibrae/semi-foundation/components/slider/constants';
|
|
3
4
|
import type { HandleDot } from '@fibrae/semi-foundation/components/slider/foundation';
|
|
4
5
|
export type { HandleDot, SliderState } from '@fibrae/semi-foundation/components/slider/foundation';
|
|
5
6
|
export interface SliderMarkSnippetProps {
|
|
@@ -30,7 +31,8 @@ export interface SliderProps extends Omit<HTMLAttributes<HTMLDivElement>, Native
|
|
|
30
31
|
showBoundary?: boolean;
|
|
31
32
|
vertical?: boolean;
|
|
32
33
|
verticalReverse?: boolean;
|
|
33
|
-
|
|
34
|
+
classNames?: Partial<Record<SliderPart, ClassValue>>;
|
|
35
|
+
styles?: Partial<Record<SliderPart, string>>;
|
|
34
36
|
handleDot?: HandleDot | HandleDot[];
|
|
35
37
|
/** Names the first handle's input, so a `<label for>` focuses the slider */
|
|
36
38
|
id?: string;
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
showBoundary = defaults('showBoundary', false),
|
|
45
45
|
vertical = defaults('vertical', false),
|
|
46
46
|
verticalReverse = defaults('verticalReverse', false),
|
|
47
|
-
|
|
47
|
+
classNames = defaults('classNames'),
|
|
48
|
+
styles = defaults('styles'),
|
|
48
49
|
handleDot = defaults('handleDot'),
|
|
49
50
|
// no global default: a global id would repeat on every instance
|
|
50
51
|
id,
|
|
@@ -299,7 +300,7 @@
|
|
|
299
300
|
foundation.handleWrapperLeave();
|
|
300
301
|
}}
|
|
301
302
|
>
|
|
302
|
-
<div class={`${prefix}-rail
|
|
303
|
+
<div class={[`${prefix}-rail`, classNames?.rail]} style={styles?.rail} onclick={foundation.handleWrapClick}></div>
|
|
303
304
|
<div class={cssClasses.TRACK} style={trackStyle} onclick={foundation.handleWrapClick}></div>
|
|
304
305
|
{#if markList.length}
|
|
305
306
|
<div class={cssClasses.DOTS}>
|
|
@@ -1,12 +1,13 @@
|
|
|
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 { SpinPart } from '@fibrae/semi-foundation/components/spin/constants';
|
|
3
4
|
export type SpinSize = 'small' | 'large' | 'middle';
|
|
4
5
|
export interface SpinProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
6
|
size?: SpinSize;
|
|
6
7
|
spinning?: boolean;
|
|
7
8
|
delay?: number;
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
classNames?: Partial<Record<SpinPart, ClassValue>>;
|
|
10
|
+
styles?: Partial<Record<SpinPart, string>>;
|
|
10
11
|
indicator?: Snippet;
|
|
11
12
|
tip?: Snippet;
|
|
12
13
|
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
type Adapter = SpinAdapter<SpinProps>;
|
|
13
13
|
|
|
14
14
|
const defaults = useDefaultProps('Spin');
|
|
15
|
-
let { size = defaults('size', 'middle'), spinning = defaults('spinning', true), delay = defaults('delay', 0),
|
|
15
|
+
let { size = defaults('size', 'middle'), spinning = defaults('spinning', true), delay = defaults('delay', 0), classNames = defaults('classNames'), styles = defaults('styles'), indicator = defaults('indicator'), tip = defaults('tip'), children, ...rest }: SpinProps = $props();
|
|
16
16
|
|
|
17
17
|
const locale = useLocale('Spin');
|
|
18
18
|
|
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
aria-busy={blocked ? true : undefined}
|
|
49
49
|
class={[
|
|
50
50
|
prefixCls,
|
|
51
|
-
wrapperClassName,
|
|
52
51
|
rest.class,
|
|
53
52
|
{
|
|
54
53
|
[`${prefixCls}-${size}`]: size,
|
|
@@ -70,7 +69,7 @@
|
|
|
70
69
|
{/if}
|
|
71
70
|
</output>
|
|
72
71
|
{/if}
|
|
73
|
-
<div class={`${prefixCls}-children
|
|
72
|
+
<div class={[`${prefixCls}-children`, classNames?.child]} inert={blocked} style={styles?.child} x-semi-prop="children">
|
|
74
73
|
{@render children?.()}
|
|
75
74
|
</div>
|
|
76
75
|
</div>
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
style={[rest.style, tooltip?.pointerEventsNone && 'pointer-events: none'].filter(Boolean).join(';') || undefined}
|
|
80
80
|
>
|
|
81
81
|
{#if loading}
|
|
82
|
-
<Spin size={size === 'default' ? 'middle' : size}
|
|
82
|
+
<Spin class={cssClasses.LOADING_SPIN} size={size === 'default' ? 'middle' : size} />
|
|
83
83
|
{:else}
|
|
84
84
|
<div aria-hidden="true" class={cssClasses.KNOB}></div>
|
|
85
85
|
{/if}
|
|
@@ -34,7 +34,8 @@ export interface TableContextValue {
|
|
|
34
34
|
readonly anyColumnFixed: boolean;
|
|
35
35
|
readonly flattenedColumns: ColumnProps[];
|
|
36
36
|
readonly headWidths: BaseHeadWidth[][];
|
|
37
|
-
readonly
|
|
37
|
+
readonly classNames?: TableProps['classNames'];
|
|
38
|
+
readonly styles?: TableProps['styles'];
|
|
38
39
|
readonly rowSpanHover: boolean;
|
|
39
40
|
/** The header and the body are separate elements, so their container is the table */
|
|
40
41
|
readonly splitTable: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes, HTMLTdAttributes, HTMLThAttributes } from 'svelte/elements';
|
|
3
|
-
import type { strings } from '@fibrae/semi-foundation/components/table/constants';
|
|
2
|
+
import type { ClassValue, HTMLAttributes, HTMLTdAttributes, HTMLThAttributes } from 'svelte/elements';
|
|
3
|
+
import type { strings, TablePart } from '@fibrae/semi-foundation/components/table/constants';
|
|
4
4
|
import type { BaseAlign, BaseChangeInfoFilter, BaseChangeInfoSorter, BaseEllipsis, BaseFixed, BaseIncludeGroupRecord, BasePageData, CheckRelation, OnChangeExtra } from '@fibrae/semi-foundation/components/table/foundation';
|
|
5
5
|
import type { Locale } from '@fibrae/semi-foundation/locale';
|
|
6
6
|
import type { CheckboxProps } from '../checkbox/interface.js';
|
|
@@ -262,6 +262,7 @@ export interface TableVirtualizedScrollArgs {
|
|
|
262
262
|
export interface TableProps<R extends AnyRecord = AnyRecord> extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'onchange' | 'onscroll' | 'children'> {
|
|
263
263
|
bordered?: boolean;
|
|
264
264
|
childrenRecordName?: string;
|
|
265
|
+
classNames?: Partial<Record<TablePart, ClassValue>>;
|
|
265
266
|
clickGroupedRowToExpand?: boolean;
|
|
266
267
|
columns?: ColumnProps<R>[];
|
|
267
268
|
components?: TableComponents;
|
|
@@ -286,7 +287,6 @@ export interface TableProps<R extends AnyRecord = AnyRecord> extends Omit<HTMLAt
|
|
|
286
287
|
footer?: string | Snippet<[TableTitleSnippetProps<R>]>;
|
|
287
288
|
groupBy?: TableGroupBy<R>;
|
|
288
289
|
groupSectionColumn?: (groupKey: string | number, group: (string | number)[]) => Omit<ColumnProps<R>, 'title' | 'children' | 'dataIndex'>;
|
|
289
|
-
headerStyle?: string;
|
|
290
290
|
hideExpandedColumn?: boolean;
|
|
291
291
|
indentSize?: number;
|
|
292
292
|
keepDOM?: boolean;
|
|
@@ -303,6 +303,7 @@ export interface TableProps<R extends AnyRecord = AnyRecord> extends Omit<HTMLAt
|
|
|
303
303
|
showHeader?: boolean;
|
|
304
304
|
size?: TableSize;
|
|
305
305
|
sticky?: TableSticky;
|
|
306
|
+
styles?: Partial<Record<TablePart, string>>;
|
|
306
307
|
title?: string | Snippet<[TableTitleSnippetProps<R>]>;
|
|
307
308
|
virtualized?: TableVirtualized;
|
|
308
309
|
onChange?: (changeInfo: TableChangeInfo<R>) => void;
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
rowspan,
|
|
79
79
|
class: [
|
|
80
80
|
`${table.prefixCls}-row-head`,
|
|
81
|
+
table.classNames?.header,
|
|
81
82
|
column.class,
|
|
82
83
|
customClass,
|
|
83
84
|
{
|
|
@@ -91,7 +92,7 @@
|
|
|
91
92
|
[`${table.prefixCls}-row-head-clickSort`]: flags.clickToSort,
|
|
92
93
|
},
|
|
93
94
|
],
|
|
94
|
-
style: joinStyles(table.
|
|
95
|
+
style: joinStyles(table.styles?.header, customStyle as string | undefined, textAlign && `text-align: ${textAlign}`, stickyOffset && `position: sticky; ${stickyOffset.side}: ${toCssLength(stickyOffset.offset)}`),
|
|
95
96
|
// a role="none" table no longer gives colspan and rowspan their table meaning
|
|
96
97
|
'aria-colspan': table.splitTable && colspan && colspan > 1 ? colspan : undefined,
|
|
97
98
|
'aria-rowspan': table.splitTable && rowspan && rowspan > 1 ? rowspan : undefined,
|