@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
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
{#snippet cells(item: DescriptionsData, index: number, span: number | undefined)}
|
|
24
24
|
{#if align === 'plain'}
|
|
25
25
|
<td class={`${prefixCls}-item`} colspan={span || 1}>
|
|
26
|
-
<span class={`${prefixCls}-key
|
|
26
|
+
<span class={[`${prefixCls}-key`, item.classNames?.key]} style={item.styles?.key}>
|
|
27
27
|
{#if itemKey}{@render itemKey({ item, index })}{:else}{item.key}{/if}:</span
|
|
28
28
|
>
|
|
29
29
|
<span class={`${prefixCls}-value`}>
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
</td>
|
|
33
33
|
{:else}
|
|
34
34
|
<th class={[`${prefixCls}-item`, `${prefixCls}-item-th`]}>
|
|
35
|
-
<span class={`${prefixCls}-key
|
|
35
|
+
<span class={[`${prefixCls}-key`, item.classNames?.key]} style={item.styles?.key}>
|
|
36
36
|
{#if itemKey}{@render itemKey({ item, index })}{:else}{item.key}{/if}
|
|
37
37
|
</span>
|
|
38
38
|
</th>
|
|
@@ -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 { DescriptionsItemPart } from '@fibrae/semi-foundation/components/descriptions/constants';
|
|
3
4
|
export type DescriptionsAlign = 'center' | 'justify' | 'left' | 'plain';
|
|
4
5
|
export type DescriptionsLayout = 'horizontal' | 'vertical';
|
|
5
6
|
export type DescriptionsSize = 'small' | 'medium' | 'large';
|
|
@@ -8,7 +9,8 @@ export interface DescriptionsData {
|
|
|
8
9
|
value?: string | number;
|
|
9
10
|
hidden?: boolean;
|
|
10
11
|
span?: number;
|
|
11
|
-
|
|
12
|
+
classNames?: Partial<Record<DescriptionsItemPart, ClassValue>>;
|
|
13
|
+
styles?: Partial<Record<DescriptionsItemPart, string>>;
|
|
12
14
|
}
|
|
13
15
|
export interface DescriptionsSnippetArgs {
|
|
14
16
|
item: DescriptionsData;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount, type Snippet } from 'svelte';
|
|
3
|
+
import type { ClassValue } from 'svelte/elements';
|
|
3
4
|
import type { FocusTarget, RenderContentProps } from '../tooltip/index.js';
|
|
4
5
|
import { type DropdownContext, setDropdownContext } from './context.js';
|
|
5
6
|
|
|
6
7
|
interface Props {
|
|
7
8
|
context: DropdownContext;
|
|
8
9
|
prefixCls: string;
|
|
9
|
-
contentClass?:
|
|
10
|
+
contentClass?: ClassValue;
|
|
10
11
|
style?: string;
|
|
11
12
|
initialFocusRef: RenderContentProps['initialFocusRef'];
|
|
12
13
|
focusTarget: FocusTarget;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type Snippet } from 'svelte';
|
|
2
|
+
import type { ClassValue } from 'svelte/elements';
|
|
2
3
|
import type { FocusTarget, RenderContentProps } from '../tooltip/index.js';
|
|
3
4
|
import { type DropdownContext } from './context.js';
|
|
4
5
|
interface Props {
|
|
5
6
|
context: DropdownContext;
|
|
6
7
|
prefixCls: string;
|
|
7
|
-
contentClass?:
|
|
8
|
+
contentClass?: ClassValue;
|
|
8
9
|
style?: string;
|
|
9
10
|
initialFocusRef: RenderContentProps['initialFocusRef'];
|
|
10
11
|
focusTarget: FocusTarget;
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
menu = defaults('menu'),
|
|
36
36
|
class: className = defaults('class'),
|
|
37
37
|
style = defaults('style'),
|
|
38
|
-
|
|
38
|
+
classNames = defaults('classNames'),
|
|
39
|
+
styles = defaults('styles'),
|
|
39
40
|
selectionMode = defaults('selectionMode'),
|
|
40
41
|
showTick = defaults('showTick', false),
|
|
41
42
|
motion = defaults('motion', true),
|
|
@@ -58,7 +59,6 @@
|
|
|
58
59
|
stopPropagation = defaults('stopPropagation'),
|
|
59
60
|
preventScroll = defaults('preventScroll'),
|
|
60
61
|
wrapperId,
|
|
61
|
-
wrapperClassName = defaults('wrapperClassName'),
|
|
62
62
|
'aria-label': ariaLabel = defaults('aria-label'),
|
|
63
63
|
'aria-labelledby': ariaLabelledby = defaults('aria-labelledby'),
|
|
64
64
|
'aria-describedby': ariaDescribedby = defaults('aria-describedby'),
|
|
@@ -140,7 +140,6 @@
|
|
|
140
140
|
stopPropagation,
|
|
141
141
|
preventScroll,
|
|
142
142
|
wrapperId,
|
|
143
|
-
wrapperClassName,
|
|
144
143
|
'aria-label': ariaLabel,
|
|
145
144
|
'aria-labelledby': ariaLabelledby,
|
|
146
145
|
'aria-describedby': ariaDescribedby,
|
|
@@ -246,14 +245,14 @@
|
|
|
246
245
|
{@render child({ props })}
|
|
247
246
|
{:else}
|
|
248
247
|
<!-- Tooltip's own span would be out of reach of the keydown listener -->
|
|
249
|
-
<span {...props} class={[`${tooltipClasses.PREFIX}-trigger-wrapper`,
|
|
248
|
+
<span {...props} class={[`${tooltipClasses.PREFIX}-trigger-wrapper`, classNames?.wrapper, props.class]} style={[textOnly ? undefined : 'display: inline-block', styles?.wrapper].filter(Boolean).join('; ') || undefined} tabindex={focusableInside ? -1 : 0}>
|
|
250
249
|
{@render children?.()}
|
|
251
250
|
</span>
|
|
252
251
|
{/if}
|
|
253
252
|
{/snippet}
|
|
254
253
|
|
|
255
254
|
{#snippet popup({ initialFocusRef }: RenderContentProps)}
|
|
256
|
-
<DropdownPopup contentClass={
|
|
255
|
+
<DropdownPopup contentClass={classNames?.content} {context} {focusTarget} {initialFocusRef} {prefixCls} style={[style, styles?.content].filter(Boolean).join('; ') || undefined}>
|
|
257
256
|
{#if content}
|
|
258
257
|
{@render content()}
|
|
259
258
|
{:else if menu}
|
|
@@ -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 { DropdownPart } from '@fibrae/semi-foundation/components/dropdown/constants';
|
|
3
4
|
import type { DropdownSelectionMode } from '@fibrae/semi-foundation/components/dropdown/menu-foundation';
|
|
4
5
|
import type { TooltipProps, TooltipTriggerProps } from '../tooltip/index.js';
|
|
5
6
|
/**
|
|
@@ -19,7 +20,7 @@ export interface DropdownMenuIconArgs {
|
|
|
19
20
|
* No arrow and no arrow-key option: the Dropdown alone moves focus with Up and Down. No `wrapWhenSpecial`: Tooltip
|
|
20
21
|
* wraps a special trigger only in its own span, and Dropdown always renders the trigger itself. No element props: F11.
|
|
21
22
|
*/
|
|
22
|
-
export interface DropdownProps extends Omit<TooltipProps, 'showArrow' | 'arrowPointAtCenter' | 'disableArrowKeyDown' | 'arrow' | 'child' | 'children' | 'content' | 'wrapWhenSpecial'> {
|
|
23
|
+
export interface DropdownProps extends Omit<TooltipProps, 'showArrow' | 'arrowPointAtCenter' | 'disableArrowKeyDown' | 'arrow' | 'child' | 'children' | 'classNames' | 'content' | 'styles' | 'wrapWhenSpecial'> {
|
|
23
24
|
children?: Snippet;
|
|
24
25
|
/** Renders the trigger element itself, which takes `props`; use it for a button, a link or a parent `DropdownItem` */
|
|
25
26
|
child?: Snippet<[{
|
|
@@ -29,8 +30,8 @@ export interface DropdownProps extends Omit<TooltipProps, 'showArrow' | 'arrowPo
|
|
|
29
30
|
content?: Snippet;
|
|
30
31
|
/** Icon of each `node: 'item'` entry of `menu`; the icon container is rendered even when the snippet outputs nothing */
|
|
31
32
|
menuIcon?: Snippet<[DropdownMenuIconArgs]>;
|
|
32
|
-
/**
|
|
33
|
-
|
|
33
|
+
/** `content` is the menu container `.semi-dropdown`, as `style` is; `class` goes on the popup `.semi-dropdown-wrapper` */
|
|
34
|
+
classNames?: Partial<Record<DropdownPart, ClassValue>>;
|
|
34
35
|
menu?: DropdownMenuItem[];
|
|
35
36
|
/**
|
|
36
37
|
* How the items of this menu are selected (a submenu takes its own Dropdown's value); `active` marks the selected
|
|
@@ -41,6 +42,7 @@ export interface DropdownProps extends Omit<TooltipProps, 'showArrow' | 'arrowPo
|
|
|
41
42
|
*/
|
|
42
43
|
selectionMode?: DropdownSelectionMode;
|
|
43
44
|
showTick?: boolean;
|
|
45
|
+
styles?: Partial<Record<DropdownPart, string>>;
|
|
44
46
|
}
|
|
45
47
|
export interface DropdownHandle {
|
|
46
48
|
focusTrigger: () => void;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { EmptyProps } from './interface.js';
|
|
7
7
|
|
|
8
8
|
const defaults = useDefaultProps('Empty');
|
|
9
|
-
const { layout = defaults('layout', 'vertical'),
|
|
9
|
+
const { layout = defaults('layout', 'vertical'), classNames = defaults('classNames'), styles = defaults('styles'), title = defaults('title'), image = defaults('image'), darkModeImage = defaults('darkModeImage'), description, children, ...rest }: EmptyProps = $props();
|
|
10
10
|
|
|
11
11
|
// Read after mount only: server render and hydration see null, so the markup matches
|
|
12
12
|
let themeMode = $state<string | null>(null);
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
</script>
|
|
34
34
|
|
|
35
35
|
<div {...rest} class={[prefixCls, rest.class, { [`${prefixCls}-${layout}`]: layout }]}>
|
|
36
|
-
<div class={`${prefixCls}-image
|
|
36
|
+
<div class={[`${prefixCls}-image`, classNames?.image]} style={styles?.image} x-semi-prop="image,darkModeImage">
|
|
37
37
|
{#if shownSnippet}
|
|
38
38
|
{@render shownSnippet()}
|
|
39
39
|
{:else if src}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import type { strings } from '@fibrae/semi-foundation/components/empty/constants';
|
|
2
|
+
import type { ClassValue, HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { EmptyPart, strings } from '@fibrae/semi-foundation/components/empty/constants';
|
|
4
4
|
export type EmptyLayout = (typeof strings.LAYOUT)[number];
|
|
5
5
|
export interface EmptySvgNode {
|
|
6
6
|
id: string;
|
|
@@ -9,7 +9,8 @@ export interface EmptySvgNode {
|
|
|
9
9
|
export type EmptyImage = string | EmptySvgNode | Snippet;
|
|
10
10
|
export interface EmptyProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
11
11
|
layout?: EmptyLayout;
|
|
12
|
-
|
|
12
|
+
classNames?: Partial<Record<EmptyPart, ClassValue>>;
|
|
13
|
+
styles?: Partial<Record<EmptyPart, string>>;
|
|
13
14
|
title?: string | Snippet;
|
|
14
15
|
image?: EmptyImage;
|
|
15
16
|
/** Shown instead of `image` while the page is in dark mode */
|
|
@@ -27,12 +27,14 @@
|
|
|
27
27
|
afterVisibleChange = defaults('afterVisibleChange'),
|
|
28
28
|
cancelButtonProps = defaults('cancelButtonProps'),
|
|
29
29
|
checkboxGroupProps = defaults('checkboxGroupProps'),
|
|
30
|
+
classNames = defaults('classNames'),
|
|
30
31
|
mode = defaults('mode', 'popup'),
|
|
31
32
|
okButtonProps = defaults('okButtonProps'),
|
|
32
33
|
onCancel = defaults('onCancel'),
|
|
33
34
|
onOk = defaults('onOk'),
|
|
34
35
|
onValueChange = defaults('onValueChange'),
|
|
35
36
|
radioGroupProps = defaults('radioGroupProps'),
|
|
37
|
+
styles = defaults('styles'),
|
|
36
38
|
textAreaProps = defaults('textAreaProps'),
|
|
37
39
|
title = defaults('title'),
|
|
38
40
|
type = defaults('type', 'emoji'),
|
|
@@ -185,6 +187,7 @@
|
|
|
185
187
|
cancelButtonProps={modalCancelProps}
|
|
186
188
|
children={body}
|
|
187
189
|
class={[prefix, `${prefix}-${type}`, rest.class]}
|
|
190
|
+
{classNames}
|
|
188
191
|
{closeIcon}
|
|
189
192
|
{footer}
|
|
190
193
|
{header}
|
|
@@ -193,6 +196,7 @@
|
|
|
193
196
|
okButtonProps={modalOkProps}
|
|
194
197
|
onCancel={foundation.handleModalCancel}
|
|
195
198
|
onOk={foundation.handleModalOk}
|
|
199
|
+
{styles}
|
|
196
200
|
{title}
|
|
197
201
|
/>
|
|
198
202
|
{:else}
|
|
@@ -209,9 +213,11 @@
|
|
|
209
213
|
bind:visible={() => open, () => {}}
|
|
210
214
|
children={body}
|
|
211
215
|
class={[prefix, `${prefix}-${type}`, rest.class]}
|
|
216
|
+
{classNames}
|
|
212
217
|
{closeIcon}
|
|
213
218
|
footer={footer === undefined ? popupFooter : (footer ?? undefined)}
|
|
214
219
|
onCancel={foundation.handleCancel}
|
|
220
|
+
{styles}
|
|
215
221
|
{title}
|
|
216
222
|
/>
|
|
217
223
|
{/if}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ClassValue } from 'svelte/elements';
|
|
2
3
|
import type { CheckboxValue } from '@fibrae/semi-foundation/components/checkbox/checkbox-group-foundation';
|
|
4
|
+
import type { FeedbackPart } from '@fibrae/semi-foundation/components/feedback/constants';
|
|
3
5
|
import type { EmojiResult, FeedbackValue } from '@fibrae/semi-foundation/components/feedback/foundation';
|
|
4
6
|
import type { CheckboxGroupOptionSnippetProps, CheckboxGroupProps } from '../checkbox/interface.js';
|
|
5
7
|
import type { TextAreaChangeEvent, TextAreaProps } from '../input/interface.js';
|
|
@@ -23,6 +25,9 @@ export interface FeedbackContentSnippetProps {
|
|
|
23
25
|
export interface FeedbackOwnProps {
|
|
24
26
|
mode?: FeedbackMode;
|
|
25
27
|
type?: FeedbackType;
|
|
28
|
+
/** Forwarded to the Modal or SideSheet of the current mode. */
|
|
29
|
+
classNames?: Partial<Record<FeedbackPart, ClassValue>>;
|
|
30
|
+
styles?: Partial<Record<FeedbackPart, string>>;
|
|
26
31
|
/** Bindable. The cancel paths (cancel button, close button, Escape, and for a modal the mask click) write `false`; the ok button never closes. */
|
|
27
32
|
visible?: boolean;
|
|
28
33
|
/** Plain text or a snippet. A string is declared here so `title="x"` is not a native tooltip. */
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
caseSensitive = defaults('caseSensitive', false),
|
|
15
15
|
autoEscape = defaults('autoEscape', true),
|
|
16
16
|
component = defaults('component', 'mark'),
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
classNames = defaults('classNames'),
|
|
18
|
+
styles = defaults('styles'),
|
|
19
19
|
}: HighlightProps = $props();
|
|
20
20
|
|
|
21
21
|
// plain-text chunks are never adjacent, so hydration cannot merge their text nodes
|
|
@@ -28,16 +28,15 @@
|
|
|
28
28
|
})
|
|
29
29
|
);
|
|
30
30
|
|
|
31
|
-
const toStyle = (
|
|
32
|
-
|
|
33
|
-
.flatMap((style) => Object.entries(style ?? {}))
|
|
31
|
+
const toStyle = (style: HighlightStyle | undefined) =>
|
|
32
|
+
Object.entries(style ?? {})
|
|
34
33
|
.map(([key, value]) => `${key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)}: ${value};`)
|
|
35
|
-
.join(' ')
|
|
34
|
+
.join(' ');
|
|
36
35
|
</script>
|
|
37
36
|
|
|
38
37
|
{#each chunks as chunk, index (index)}
|
|
39
38
|
{#if chunk.highlight}
|
|
40
|
-
<svelte:element this={component || 'mark'} class={[`${cssClasses.PREFIX}-tag`,
|
|
39
|
+
<svelte:element this={component || 'mark'} class={[`${cssClasses.PREFIX}-tag`, classNames?.highlight, chunk.class]} style={[styles?.highlight, toStyle(chunk.style)].filter(Boolean).join('; ') || undefined}>{chunk.text}</svelte:element>
|
|
41
40
|
{:else}
|
|
42
41
|
{chunk.text}
|
|
43
42
|
{/if}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ClassValue } from 'svelte/elements';
|
|
2
|
+
import type { HighlightPart } from '@fibrae/semi-foundation/components/highlight/constants';
|
|
1
3
|
import type { HighlightStyle } from '@fibrae/semi-foundation/components/highlight/foundation';
|
|
2
4
|
export type { HighlightStyle } from '@fibrae/semi-foundation/components/highlight/foundation';
|
|
3
5
|
export interface ComplexSearchWord {
|
|
@@ -12,8 +14,7 @@ export interface HighlightProps {
|
|
|
12
14
|
caseSensitive?: boolean;
|
|
13
15
|
sourceString?: string;
|
|
14
16
|
searchWords?: string | SearchWords;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
highlightClassName?: string;
|
|
17
|
+
classNames?: Partial<Record<HighlightPart, ClassValue>>;
|
|
18
|
+
styles?: Partial<Record<HighlightPart, string>>;
|
|
18
19
|
component?: string;
|
|
19
20
|
}
|
|
@@ -11,14 +11,15 @@
|
|
|
11
11
|
|
|
12
12
|
let {
|
|
13
13
|
block = defaults('block', false),
|
|
14
|
+
classNames = defaults('classNames'),
|
|
14
15
|
colorful,
|
|
15
|
-
contentClassName = defaults('contentClassName'),
|
|
16
16
|
disabled,
|
|
17
17
|
htmlType = defaults('htmlType', 'button'),
|
|
18
18
|
iconPosition = defaults('iconPosition', strings.DEFAULT_ICON_POSITION),
|
|
19
19
|
loading = defaults('loading', false),
|
|
20
20
|
noHorizontalPadding = defaults('noHorizontalPadding', false),
|
|
21
21
|
size,
|
|
22
|
+
styles = defaults('styles'),
|
|
22
23
|
theme,
|
|
23
24
|
type,
|
|
24
25
|
...rest
|
|
@@ -40,5 +41,5 @@
|
|
|
40
41
|
);
|
|
41
42
|
</script>
|
|
42
43
|
|
|
43
|
-
<!--
|
|
44
|
-
<Button {...rest} {...looks} {block}
|
|
44
|
+
<!-- Empty classNames and styles stop the inner Button from falling back to its own global keys -->
|
|
45
|
+
<Button {...rest} {...looks} {block} classNames={classNames ?? {}} {htmlType} {iconPosition} {loading} {noHorizontalPadding} styles={styles ?? {}} />
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
fallback = defaults('fallback'),
|
|
30
30
|
placeholder = defaults('placeholder'),
|
|
31
31
|
preview = defaults('preview', true),
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
classNames = defaults('classNames'),
|
|
33
|
+
styles = defaults('styles'),
|
|
34
34
|
setDownloadName = defaults('setDownloadName'),
|
|
35
35
|
onLoad,
|
|
36
36
|
onError,
|
|
@@ -123,12 +123,12 @@
|
|
|
123
123
|
{...attrs.control}
|
|
124
124
|
{@attach lazy}
|
|
125
125
|
{alt}
|
|
126
|
-
class={[`${prefixCls}-img`, { [`${prefixCls}-img-preview`]: canOpen, [`${prefixCls}-img-error`]: loadStatus === 'error' },
|
|
126
|
+
class={[`${prefixCls}-img`, { [`${prefixCls}-img-preview`]: canOpen, [`${prefixCls}-img-error`]: loadStatus === 'error' }, classNames?.img]}
|
|
127
127
|
crossorigin={crossOrigin}
|
|
128
128
|
data-src={src}
|
|
129
129
|
{height}
|
|
130
130
|
src={group?.lazyLoad ? undefined : src}
|
|
131
|
-
style={
|
|
131
|
+
style={styles?.img}
|
|
132
132
|
{width}
|
|
133
133
|
onerror={foundation.handleError}
|
|
134
134
|
onload={foundation.handleLoaded}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes, HTMLImgAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ClassValue, HTMLAttributes, HTMLImgAttributes } from 'svelte/elements';
|
|
3
|
+
import type { ImagePart, ImagePreviewPart } from '@fibrae/semi-foundation/components/image/constants';
|
|
3
4
|
import type { RatioType } from '@fibrae/semi-foundation/components/image/preview-inner-foundation';
|
|
4
5
|
export type { RatioType, RotateDirection, SwitchDirection } from '@fibrae/semi-foundation/components/image/preview-inner-foundation';
|
|
5
6
|
export interface PreviewOptions {
|
|
@@ -29,8 +30,8 @@ export interface PreviewOptions {
|
|
|
29
30
|
disableDownload?: boolean;
|
|
30
31
|
initialZoom?: number;
|
|
31
32
|
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
classNames?: Partial<Record<ImagePreviewPart, ClassValue>>;
|
|
34
|
+
styles?: Partial<Record<ImagePreviewPart, string>>;
|
|
34
35
|
prevTip?: string;
|
|
35
36
|
nextTip?: string;
|
|
36
37
|
zoomInTip?: string;
|
|
@@ -123,8 +124,8 @@ export interface ImageProps extends Omit<HTMLImgAttributes, ImgNativeKeys>, Prev
|
|
|
123
124
|
fallback?: string | Snippet;
|
|
124
125
|
placeholder?: Snippet;
|
|
125
126
|
preview?: boolean | ImagePreviewProps;
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
classNames?: Partial<Record<ImagePart, ClassValue>>;
|
|
128
|
+
styles?: Partial<Record<ImagePart, string>>;
|
|
128
129
|
setDownloadName?: (src: string) => string;
|
|
129
130
|
onLoad?: (event: Event) => void;
|
|
130
131
|
onError?: (event: Event) => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { untrack } from 'svelte';
|
|
3
2
|
import { cssClasses } from '@fibrae/semi-foundation/components/image/constants';
|
|
4
3
|
import PreviewInnerFoundation, { type PreviewInnerAdapter, type PreviewInnerBaseProps, type PreviewInnerState } from '@fibrae/semi-foundation/components/image/preview-inner-foundation';
|
|
5
4
|
import { IconArrowLeft, IconArrowRight } from '@fibrae/semi-icons-svelte';
|
|
6
5
|
import { useFoundation } from '../../../base/index.js';
|
|
6
|
+
import { useOverlayResources } from '../../../hooks/index.js';
|
|
7
7
|
import { Portal } from '../../../internal/index.js';
|
|
8
8
|
import { getConfigContext } from '../../config-provider/context.js';
|
|
9
9
|
import useLocale from '../../locale/use-locale.svelte.js';
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
alts,
|
|
33
33
|
previewTitle,
|
|
34
34
|
titles,
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
classNames,
|
|
36
|
+
styles,
|
|
37
37
|
getPopupContainer,
|
|
38
38
|
setDownloadName,
|
|
39
39
|
crossOrigin,
|
|
@@ -174,19 +174,11 @@
|
|
|
174
174
|
const handleNext = () => foundation.handleSwitchImage('next');
|
|
175
175
|
|
|
176
176
|
// Recorded before the preview renders, or its own focus would be recorded
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
$effect(() => {
|
|
184
|
-
if (!visible || !wrapEl) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
untrack(() => foundation.beforeShow());
|
|
188
|
-
return foundation.afterHide;
|
|
189
|
-
});
|
|
177
|
+
useOverlayResources(
|
|
178
|
+
foundation,
|
|
179
|
+
() => visible,
|
|
180
|
+
() => Boolean(visible && wrapEl)
|
|
181
|
+
);
|
|
190
182
|
</script>
|
|
191
183
|
|
|
192
184
|
{#if visible}
|
|
@@ -197,9 +189,9 @@
|
|
|
197
189
|
aria-labelledby={hasTitle ? `${uid}-title` : undefined}
|
|
198
190
|
aria-modal={inBody ? 'true' : undefined}
|
|
199
191
|
bind:this={wrapEl}
|
|
200
|
-
class={[cls, { [`${cls}-popup`]: !inBody },
|
|
192
|
+
class={[cls, { [`${cls}-popup`]: !inBody }, classNames?.preview]}
|
|
201
193
|
role="dialog"
|
|
202
|
-
style={
|
|
194
|
+
style={styles?.preview}
|
|
203
195
|
tabindex="-1"
|
|
204
196
|
onfocusin={foundation.handleKeyboardActivity}
|
|
205
197
|
onmousedown={foundation.handleMouseDown}
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
disableDownload = defaults('disableDownload', previewDefaults.disableDownload),
|
|
40
40
|
initialZoom = defaults('initialZoom'),
|
|
41
41
|
crossOrigin = defaults('crossOrigin'),
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
classNames = defaults('classNames'),
|
|
43
|
+
styles = defaults('styles'),
|
|
44
44
|
prevTip = defaults('prevTip'),
|
|
45
45
|
nextTip = defaults('nextTip'),
|
|
46
46
|
zoomInTip = defaults('zoomInTip'),
|
|
@@ -126,6 +126,7 @@
|
|
|
126
126
|
<PreviewInner
|
|
127
127
|
{adaptiveTip}
|
|
128
128
|
{alts}
|
|
129
|
+
{classNames}
|
|
129
130
|
{closable}
|
|
130
131
|
{closeIcon}
|
|
131
132
|
{closeOnEsc}
|
|
@@ -155,9 +156,7 @@
|
|
|
155
156
|
{preLoad}
|
|
156
157
|
{preLoadGap}
|
|
157
158
|
{prevTip}
|
|
158
|
-
{previewCls}
|
|
159
159
|
{previewMenu}
|
|
160
|
-
{previewStyle}
|
|
161
160
|
{previewTitle}
|
|
162
161
|
{rightIcon}
|
|
163
162
|
{rotateTip}
|
|
@@ -165,6 +164,7 @@
|
|
|
165
164
|
{setDownloadName}
|
|
166
165
|
{showTooltip}
|
|
167
166
|
src={srcList}
|
|
167
|
+
{styles}
|
|
168
168
|
{title}
|
|
169
169
|
{titles}
|
|
170
170
|
{viewerVisibleDelay}
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
minlength,
|
|
38
38
|
placeholder = defaults('placeholder'),
|
|
39
39
|
validateStatus = defaults('validateStatus', 'default'),
|
|
40
|
-
|
|
40
|
+
classNames = defaults('classNames'),
|
|
41
|
+
styles = defaults('styles'),
|
|
41
42
|
insetLabelId,
|
|
42
43
|
getValueLength = defaults('getValueLength'),
|
|
43
44
|
onChange,
|
|
@@ -312,13 +313,14 @@
|
|
|
312
313
|
[`${prefixCls}-sibling-clearbtn`]: allowClear,
|
|
313
314
|
[`${prefixCls}-sibling-modebtn`]: mode === 'password',
|
|
314
315
|
},
|
|
316
|
+
classNames?.input,
|
|
315
317
|
]}
|
|
316
318
|
disabled={isDisabled}
|
|
317
319
|
maxlength={InputFoundation.getNativeMaxLength({ maxLength: maxlength, getValueLength })}
|
|
318
320
|
minlength={InputFoundation.getNativeMinLength({ minLength: minlength, getValueLength }, shown)}
|
|
319
321
|
placeholder={placeholder?.toString()}
|
|
320
322
|
readonly={readonly || readOnly}
|
|
321
|
-
style={
|
|
323
|
+
style={styles?.input}
|
|
322
324
|
type={InputFoundation.getInputType(type, mode, states().eyeClosed)}
|
|
323
325
|
value={text}
|
|
324
326
|
oncompositionend={handleCompositionEnd}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes, HTMLInputAttributes, HTMLTextareaAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ClassValue, HTMLAttributes, HTMLInputAttributes, HTMLTextareaAttributes } from 'svelte/elements';
|
|
3
3
|
import type { ValidateStatus } from '@fibrae/semi-foundation/base';
|
|
4
|
+
import type { InputPart, TextAreaPart } from '@fibrae/semi-foundation/components/input/constants';
|
|
4
5
|
import type { Size } from '@fibrae/semi-foundation/utils';
|
|
5
6
|
import type { LabelProps } from '../form/interface.js';
|
|
6
7
|
export type InputSize = Size;
|
|
@@ -40,7 +41,8 @@ export interface InputProps extends Omit<HTMLInputAttributes, NativeInputKeys> {
|
|
|
40
41
|
minlength?: number;
|
|
41
42
|
placeholder?: string | number;
|
|
42
43
|
validateStatus?: ValidateStatus;
|
|
43
|
-
|
|
44
|
+
classNames?: Partial<Record<InputPart, ClassValue>>;
|
|
45
|
+
styles?: Partial<Record<InputPart, string>>;
|
|
44
46
|
insetLabelId?: string;
|
|
45
47
|
getValueLength?: (value: string) => number;
|
|
46
48
|
onChange?: (value: string, event: InputChangeEvent) => void;
|
|
@@ -89,9 +91,8 @@ export interface TextAreaProps extends Omit<HTMLTextareaAttributes, NativeTextAr
|
|
|
89
91
|
disabledEnterStartNewLine?: boolean;
|
|
90
92
|
showLineNumber?: boolean;
|
|
91
93
|
lineNumberStart?: number;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
textareaStyle?: string;
|
|
94
|
+
classNames?: Partial<Record<TextAreaPart, ClassValue>>;
|
|
95
|
+
styles?: Partial<Record<TextAreaPart, string>>;
|
|
95
96
|
/** Only takes effect when given; ignored with autosize */
|
|
96
97
|
resize?: 'none' | 'both' | 'horizontal' | 'vertical' | 'block' | 'inline';
|
|
97
98
|
maxlength?: number;
|
|
@@ -41,9 +41,8 @@
|
|
|
41
41
|
disabledEnterStartNewLine = defaults('disabledEnterStartNewLine'),
|
|
42
42
|
showLineNumber = defaults('showLineNumber', false),
|
|
43
43
|
lineNumberStart = defaults('lineNumberStart', 1),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
textareaStyle = defaults('textareaStyle'),
|
|
44
|
+
classNames = defaults('classNames'),
|
|
45
|
+
styles = defaults('styles'),
|
|
47
46
|
resize = defaults('resize'),
|
|
48
47
|
maxlength,
|
|
49
48
|
minlength,
|
|
@@ -111,7 +110,7 @@
|
|
|
111
110
|
const counterId = `${uid}-counter`;
|
|
112
111
|
const hasCounter = $derived(showCounter || Boolean(maxCount));
|
|
113
112
|
const attrs = $derived(splitControlAttrs(rest, isNotClassOrStyle));
|
|
114
|
-
const lineNumberPanelStyle = $derived([
|
|
113
|
+
const lineNumberPanelStyle = $derived([styles?.lineNumber, lineLayout.height ? `height: ${lineLayout.height}px; max-height: ${lineLayout.height}px` : undefined].filter(Boolean).join(';') || undefined);
|
|
115
114
|
|
|
116
115
|
const sizeStyle = $derived(
|
|
117
116
|
Object.entries(TextAreaFoundation.getSizeStyle({ autosize, resize, rows }))
|
|
@@ -279,6 +278,7 @@
|
|
|
279
278
|
[`${prefixCls}-textarea-autosize`]: Boolean(autosize),
|
|
280
279
|
[`${prefixCls}-textarea-showClear`]: showClear,
|
|
281
280
|
},
|
|
281
|
+
classNames?.textarea,
|
|
282
282
|
]}
|
|
283
283
|
{cols}
|
|
284
284
|
{disabled}
|
|
@@ -287,7 +287,7 @@
|
|
|
287
287
|
placeholder={placeholder || undefined}
|
|
288
288
|
{readonly}
|
|
289
289
|
{rows}
|
|
290
|
-
style={[
|
|
290
|
+
style={[styles?.textarea, sizeStyle].filter(Boolean).join(';') || undefined}
|
|
291
291
|
value={text}
|
|
292
292
|
oncompositionend={handleCompositionEnd}
|
|
293
293
|
oncompositionstart={foundation.handleCompositionStart}
|
|
@@ -321,7 +321,7 @@
|
|
|
321
321
|
>
|
|
322
322
|
{#if showLineNumber}
|
|
323
323
|
<!-- the numbers only mirror the text rows, so assistive technology skips them -->
|
|
324
|
-
<div aria-hidden="true" bind:this={lineNumber} class={[`${prefixCls}-textarea-lineNumber`,
|
|
324
|
+
<div aria-hidden="true" bind:this={lineNumber} class={[`${prefixCls}-textarea-lineNumber`, classNames?.lineNumber]} style={lineNumberPanelStyle}>
|
|
325
325
|
{#each lines as _, index (index)}
|
|
326
326
|
<div class={`${prefixCls}-textarea-lineNumber-item`}>{lineNumberStart + index}</div>
|
|
327
327
|
{/each}
|
|
@@ -56,7 +56,8 @@
|
|
|
56
56
|
validateStatus = defaults('validateStatus'),
|
|
57
57
|
maxlength = defaults('maxlength'),
|
|
58
58
|
minlength = defaults('minlength'),
|
|
59
|
-
|
|
59
|
+
classNames = defaults('classNames'),
|
|
60
|
+
styles = defaults('styles'),
|
|
60
61
|
// the global type leaves out per-instance ids, so there is no default to read
|
|
61
62
|
insetLabelId,
|
|
62
63
|
onChange,
|
|
@@ -261,11 +262,11 @@
|
|
|
261
262
|
bind:this={input}
|
|
262
263
|
bind:value={() => states().value ?? '', () => {}}
|
|
263
264
|
{borderless}
|
|
265
|
+
classNames={classNames ?? {}}
|
|
264
266
|
{clearIcon}
|
|
265
267
|
{composition}
|
|
266
268
|
disabled={isDisabled}
|
|
267
269
|
{hideSuffix}
|
|
268
|
-
{inputStyle}
|
|
269
270
|
{insetLabel}
|
|
270
271
|
{insetLabelId}
|
|
271
272
|
{maxlength}
|
|
@@ -278,6 +279,7 @@
|
|
|
278
279
|
showClear={showClear ?? false}
|
|
279
280
|
size={shownSize}
|
|
280
281
|
{step}
|
|
282
|
+
styles={styles ?? {}}
|
|
281
283
|
suffix={showInnerButtons ? innerButtonsSuffix : suffix}
|
|
282
284
|
{validateStatus}
|
|
283
285
|
{...valueNow}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import type { ClassValue } from 'svelte/elements';
|
|
2
|
+
import type { InputNumberPart } from '@fibrae/semi-foundation/components/input-number/constants';
|
|
1
3
|
import type { BaseInputNumberState, ScientificNotationConfig } from '@fibrae/semi-foundation/components/input-number/foundation';
|
|
2
4
|
import type { InputChangeEvent, InputProps } from '../input/interface.js';
|
|
3
5
|
export type { ScientificNotationConfig };
|
|
4
6
|
/** What changed the value: typing, a step button press, a step or bound key, or the blur that reformats the text */
|
|
5
7
|
export type InputNumberChangeEvent = InputChangeEvent | PointerEvent | KeyboardEvent | FocusEvent;
|
|
6
|
-
type InputOnlyKeys = 'value' | 'type' | 'mode' | 'getValueLength' | 'showClearIgnoreDisabled' | 'onChange' | 'min' | 'max' | 'step';
|
|
8
|
+
type InputOnlyKeys = 'value' | 'type' | 'mode' | 'getValueLength' | 'showClearIgnoreDisabled' | 'onChange' | 'min' | 'max' | 'step' | 'classNames' | 'styles';
|
|
7
9
|
/** InputNumber's own props plus the Input props it passes on to the Input inside */
|
|
8
10
|
export interface InputNumberProps extends Omit<InputProps, InputOnlyKeys> {
|
|
11
|
+
classNames?: Partial<Record<InputNumberPart, ClassValue>>;
|
|
12
|
+
styles?: Partial<Record<InputNumberPart, string>>;
|
|
9
13
|
/** Bindable; leave it out for an uncontrolled input. `bind:value={get, set}` makes it fully controlled */
|
|
10
14
|
value?: number | string;
|
|
11
15
|
currency?: boolean | string;
|