@fibrae/semi-ui-svelte 0.6.0 → 0.8.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.
Files changed (124) hide show
  1. package/dist/components/auto-complete/auto-complete.svelte +12 -21
  2. package/dist/components/auto-complete/interface.d.ts +3 -2
  3. package/dist/components/badge/badge.svelte +4 -4
  4. package/dist/components/badge/interface.d.ts +4 -3
  5. package/dist/components/button/button.svelte +3 -2
  6. package/dist/components/button/interface.d.ts +4 -2
  7. package/dist/components/card/card.svelte +9 -10
  8. package/dist/components/card/interface.d.ts +4 -4
  9. package/dist/components/cascader/cascader.svelte +11 -18
  10. package/dist/components/cascader/interface.d.ts +3 -2
  11. package/dist/components/cascader/item.svelte +1 -1
  12. package/dist/components/color-picker/color-picker.svelte +16 -1
  13. package/dist/components/cropper/cropper.svelte +4 -4
  14. package/dist/components/cropper/interface.d.ts +4 -3
  15. package/dist/components/date-picker/date-input.svelte +3 -1
  16. package/dist/components/date-picker/date-picker.svelte +9 -10
  17. package/dist/components/date-picker/interface.d.ts +5 -4
  18. package/dist/components/date-picker/internal.d.ts +2 -0
  19. package/dist/components/descriptions/descriptions.svelte +2 -2
  20. package/dist/components/descriptions/interface.d.ts +4 -2
  21. package/dist/components/dropdown/dropdown-popup.svelte +2 -1
  22. package/dist/components/dropdown/dropdown-popup.svelte.d.ts +2 -1
  23. package/dist/components/dropdown/dropdown.svelte +4 -5
  24. package/dist/components/dropdown/interface.d.ts +6 -4
  25. package/dist/components/empty/empty.svelte +2 -2
  26. package/dist/components/empty/interface.d.ts +4 -3
  27. package/dist/components/feedback/feedback.svelte +6 -0
  28. package/dist/components/feedback/interface.d.ts +5 -0
  29. package/dist/components/form/form.svelte +3 -1
  30. package/dist/components/form/index.d.ts +4 -2
  31. package/dist/components/form/index.js +3 -1
  32. package/dist/components/form/interface.d.ts +57 -10
  33. package/dist/components/form/label.svelte +37 -13
  34. package/dist/components/form/schema-form/schema-field.svelte +4 -6
  35. package/dist/components/form/schema-form/schema-form.svelte +2 -2
  36. package/dist/components/form/schema-form/schema-node.svelte +73 -91
  37. package/dist/components/form/schema-form/schema-node.svelte.d.ts +2 -3
  38. package/dist/components/form/schema-form/semi-array.svelte +47 -0
  39. package/dist/components/form/schema-form/semi-array.svelte.d.ts +7 -0
  40. package/dist/components/form/schema-form/semi-field.svelte +42 -0
  41. package/dist/components/form/schema-form/semi-field.svelte.d.ts +8 -0
  42. package/dist/components/form/schema-form/semi-renderers.svelte +24 -0
  43. package/dist/components/form/schema-form/semi-renderers.svelte.d.ts +24 -0
  44. package/dist/components/form/schema-form/semi-section.svelte +22 -0
  45. package/dist/components/form/schema-form/semi-section.svelte.d.ts +10 -0
  46. package/dist/components/form/section.svelte +8 -2
  47. package/dist/components/highlight/highlight.svelte +6 -7
  48. package/dist/components/highlight/interface.d.ts +4 -3
  49. package/dist/components/icon-button/icon-button.svelte +4 -3
  50. package/dist/components/image/image.svelte +4 -4
  51. package/dist/components/image/interface.d.ts +6 -5
  52. package/dist/components/image/preview/preview-image.svelte +1 -1
  53. package/dist/components/image/preview/preview-inner.svelte +10 -18
  54. package/dist/components/image/preview/preview.svelte +4 -4
  55. package/dist/components/input/input.svelte +4 -2
  56. package/dist/components/input/interface.d.ts +6 -5
  57. package/dist/components/input/textarea.svelte +6 -6
  58. package/dist/components/input-number/input-number.svelte +4 -2
  59. package/dist/components/input-number/interface.d.ts +5 -1
  60. package/dist/components/modal/interface.d.ts +5 -3
  61. package/dist/components/modal/modal-content.svelte +26 -32
  62. package/dist/components/modal/modal-content.svelte.d.ts +5 -4
  63. package/dist/components/modal/modal.svelte +4 -4
  64. package/dist/components/navigation/interface.d.ts +8 -4
  65. package/dist/components/navigation/nav-items.svelte +1 -1
  66. package/dist/components/navigation/nav.svelte +3 -2
  67. package/dist/components/navigation/sub-nav.svelte +5 -4
  68. package/dist/components/overflow-list/interface.d.ts +4 -3
  69. package/dist/components/overflow-list/overflow-list.svelte +3 -3
  70. package/dist/components/pagination/interface.d.ts +1 -1
  71. package/dist/components/pagination/pagination.svelte +63 -61
  72. package/dist/components/popconfirm/interface.d.ts +3 -0
  73. package/dist/components/popconfirm/popconfirm.svelte +4 -4
  74. package/dist/components/popover/arrow.svelte +2 -2
  75. package/dist/components/popover/interface.d.ts +8 -3
  76. package/dist/components/popover/popover.svelte +4 -4
  77. package/dist/components/radio/interface.d.ts +6 -5
  78. package/dist/components/radio/radio-group.svelte +2 -2
  79. package/dist/components/radio/radio.svelte +4 -4
  80. package/dist/components/select/interface.d.ts +3 -2
  81. package/dist/components/select/option.svelte +1 -1
  82. package/dist/components/select/select.svelte +9 -14
  83. package/dist/components/side-sheet/interface.d.ts +6 -5
  84. package/dist/components/side-sheet/side-sheet.svelte +31 -29
  85. package/dist/components/slider/interface.d.ts +4 -2
  86. package/dist/components/slider/slider.svelte +3 -2
  87. package/dist/components/spin/icon.svelte +1 -1
  88. package/dist/components/spin/interface.d.ts +4 -3
  89. package/dist/components/spin/spin.svelte +2 -3
  90. package/dist/components/switch/switch.svelte +1 -1
  91. package/dist/components/table/body/body.svelte +21 -8
  92. package/dist/components/table/context.d.ts +2 -1
  93. package/dist/components/table/interface.d.ts +4 -3
  94. package/dist/components/table/table-header/table-header-row.svelte +15 -3
  95. package/dist/components/table/table.svelte +38 -8
  96. package/dist/components/tabs/interface.d.ts +8 -7
  97. package/dist/components/tabs/tab-bar.svelte +12 -2
  98. package/dist/components/tabs/tabs.svelte +7 -8
  99. package/dist/components/time-picker/interface.d.ts +4 -4
  100. package/dist/components/time-picker/time-input.svelte +2 -2
  101. package/dist/components/time-picker/time-picker.svelte +10 -11
  102. package/dist/components/tooltip/interface.d.ts +5 -2
  103. package/dist/components/tooltip/tooltip.svelte +13 -38
  104. package/dist/components/tree/interface.d.ts +4 -3
  105. package/dist/components/tree/node-arrow.svelte +1 -1
  106. package/dist/components/tree/tree-node.svelte +1 -1
  107. package/dist/components/tree/tree.svelte +23 -74
  108. package/dist/components/tree-select/interface.d.ts +4 -5
  109. package/dist/components/tree-select/tree-select.svelte +28 -67
  110. package/dist/components/typography/base.svelte +1 -1
  111. package/dist/components/upload/file-card.svelte +1 -1
  112. package/dist/components/upload/interface.d.ts +5 -3
  113. package/dist/components/upload/upload.svelte +6 -4
  114. package/dist/components/user-guide/user-guide.svelte +15 -1
  115. package/dist/hooks/index.d.ts +1 -0
  116. package/dist/hooks/index.js +1 -0
  117. package/dist/hooks/use-overlay-resources.svelte.d.ts +13 -0
  118. package/dist/hooks/use-overlay-resources.svelte.js +20 -0
  119. package/dist/internal/virtual-list.svelte +11 -1
  120. package/dist/internal/virtual-list.svelte.d.ts +7 -0
  121. package/dist/styles.css +1 -1
  122. package/package.json +3 -3
  123. package/dist/components/tree/use-tree-keyboard.svelte.d.ts +0 -29
  124. package/dist/components/tree/use-tree-keyboard.svelte.js +0 -61
@@ -39,8 +39,8 @@
39
39
  disableDownload = defaults('disableDownload', previewDefaults.disableDownload),
40
40
  initialZoom = defaults('initialZoom'),
41
41
  crossOrigin = defaults('crossOrigin'),
42
- previewCls = defaults('previewCls'),
43
- previewStyle = defaults('previewStyle'),
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
- inputStyle = defaults('inputStyle'),
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={inputStyle}
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
- inputStyle?: string;
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
- lineNumberClassName?: string;
93
- lineNumberStyle?: string;
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
- lineNumberClassName = defaults('lineNumberClassName'),
45
- lineNumberStyle = defaults('lineNumberStyle'),
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([lineNumberStyle, lineLayout.height ? `height: ${lineLayout.height}px; max-height: ${lineLayout.height}px` : undefined].filter(Boolean).join(';') || undefined);
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={[textareaStyle, sizeStyle].filter(Boolean).join(';') || undefined}
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`, lineNumberClassName]} style={lineNumberPanelStyle}>
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
- inputStyle = defaults('inputStyle'),
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;
@@ -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 { type Snippet, untrack } from 'svelte';
3
- import type { HTMLAttributes } from 'svelte/elements';
4
- import { cssClasses } from '@fibrae/semi-foundation/components/modal/constants';
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 { warnIfDialogUnnamed, toCssLength } from '@fibrae/semi-foundation/utils';
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
- bodyStyle?: string;
36
- maskStyle?: string;
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, bodyStyle, maskStyle, centered, closable, closeOnEsc, mask, maskClosable, maskFixed, preventScroll, size, width, height, isFullScreen, contentClass, ...rest }: Props = $props();
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
- const attrs = $derived(splitControlAttrs(rest, (key) => key === 'role' || isAriaKey(key)));
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
- // record before the content's components take focus in their mount effects (an autofocusing Input)
129
- $effect.pre(() => {
130
- if (visible) {
131
- untrack(() => foundation.recordFocus());
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={bodyStyle} x-semi-prop="children">
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: hide() runs after it and still needs the element to decide the focus restore
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`} x-semi-prop="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={maskStyle} style:display={maskAnimation.displayed ? undefined : 'none'}></div>
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 { type Snippet } from 'svelte';
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
- bodyStyle?: string;
22
- maskStyle?: string;
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
- bodyStyle?: string;
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', 'dropdownStyle', 'dropdownProps']);
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
- bodyStyle = defaults('bodyStyle'),
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`} style={bodyStyle}>
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, dropdownStyle, indent, itemKey, level: ownLevel, subDropdownProps, text, children, label, icon, expandIcon, ...rest }: SubNavProps = $props();
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, dropdownStyle beats their style, our onVisibleChange runs first
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
- style: dropdownStyle ?? user?.style,
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, dropdownStyle, indent, itemKey, level: ownLevel, subDropdownProps, text }).filter(([, value]) => value !== undefined)));
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
- wrapperClassName?: string;
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
- wrapperClassName = defaults('wrapperClassName'),
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={[wrapperClassName, cssClasses.SCROLL_WRAPPER]} style={wrapperStyle}>
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<HTMLUListElement>, 'children'> {
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 */