@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.
Files changed (102) 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/highlight/highlight.svelte +6 -7
  30. package/dist/components/highlight/interface.d.ts +4 -3
  31. package/dist/components/icon-button/icon-button.svelte +4 -3
  32. package/dist/components/image/image.svelte +4 -4
  33. package/dist/components/image/interface.d.ts +6 -5
  34. package/dist/components/image/preview/preview-image.svelte +1 -1
  35. package/dist/components/image/preview/preview-inner.svelte +10 -18
  36. package/dist/components/image/preview/preview.svelte +4 -4
  37. package/dist/components/input/input.svelte +4 -2
  38. package/dist/components/input/interface.d.ts +6 -5
  39. package/dist/components/input/textarea.svelte +6 -6
  40. package/dist/components/input-number/input-number.svelte +4 -2
  41. package/dist/components/input-number/interface.d.ts +5 -1
  42. package/dist/components/modal/interface.d.ts +5 -3
  43. package/dist/components/modal/modal-content.svelte +26 -32
  44. package/dist/components/modal/modal-content.svelte.d.ts +5 -4
  45. package/dist/components/modal/modal.svelte +4 -4
  46. package/dist/components/navigation/interface.d.ts +8 -4
  47. package/dist/components/navigation/nav-items.svelte +1 -1
  48. package/dist/components/navigation/nav.svelte +3 -2
  49. package/dist/components/navigation/sub-nav.svelte +5 -4
  50. package/dist/components/overflow-list/interface.d.ts +4 -3
  51. package/dist/components/overflow-list/overflow-list.svelte +3 -3
  52. package/dist/components/pagination/interface.d.ts +1 -1
  53. package/dist/components/pagination/pagination.svelte +63 -61
  54. package/dist/components/popconfirm/interface.d.ts +3 -0
  55. package/dist/components/popconfirm/popconfirm.svelte +4 -4
  56. package/dist/components/popover/arrow.svelte +2 -2
  57. package/dist/components/popover/interface.d.ts +8 -3
  58. package/dist/components/popover/popover.svelte +4 -4
  59. package/dist/components/radio/interface.d.ts +6 -5
  60. package/dist/components/radio/radio-group.svelte +2 -2
  61. package/dist/components/radio/radio.svelte +4 -4
  62. package/dist/components/select/interface.d.ts +3 -2
  63. package/dist/components/select/option.svelte +1 -1
  64. package/dist/components/select/select.svelte +9 -14
  65. package/dist/components/side-sheet/interface.d.ts +6 -5
  66. package/dist/components/side-sheet/side-sheet.svelte +31 -29
  67. package/dist/components/slider/interface.d.ts +4 -2
  68. package/dist/components/slider/slider.svelte +3 -2
  69. package/dist/components/spin/interface.d.ts +4 -3
  70. package/dist/components/spin/spin.svelte +2 -3
  71. package/dist/components/switch/switch.svelte +1 -1
  72. package/dist/components/table/context.d.ts +2 -1
  73. package/dist/components/table/interface.d.ts +4 -3
  74. package/dist/components/table/table-header/table-header-row.svelte +2 -1
  75. package/dist/components/table/table.svelte +7 -3
  76. package/dist/components/tabs/interface.d.ts +8 -7
  77. package/dist/components/tabs/tab-bar.svelte +12 -2
  78. package/dist/components/tabs/tabs.svelte +7 -8
  79. package/dist/components/time-picker/interface.d.ts +4 -4
  80. package/dist/components/time-picker/time-input.svelte +2 -2
  81. package/dist/components/time-picker/time-picker.svelte +10 -11
  82. package/dist/components/tooltip/interface.d.ts +5 -2
  83. package/dist/components/tooltip/tooltip.svelte +13 -38
  84. package/dist/components/tree/interface.d.ts +4 -3
  85. package/dist/components/tree/node-arrow.svelte +1 -1
  86. package/dist/components/tree/tree-node.svelte +1 -1
  87. package/dist/components/tree/tree.svelte +23 -74
  88. package/dist/components/tree-select/interface.d.ts +4 -5
  89. package/dist/components/tree-select/tree-select.svelte +28 -67
  90. package/dist/components/typography/base.svelte +1 -1
  91. package/dist/components/upload/file-card.svelte +1 -1
  92. package/dist/components/upload/interface.d.ts +5 -3
  93. package/dist/components/upload/upload.svelte +6 -4
  94. package/dist/components/user-guide/user-guide.svelte +15 -1
  95. package/dist/hooks/index.d.ts +1 -0
  96. package/dist/hooks/index.js +1 -0
  97. package/dist/hooks/use-overlay-resources.svelte.d.ts +13 -0
  98. package/dist/hooks/use-overlay-resources.svelte.js +20 -0
  99. package/dist/styles.css +1 -1
  100. package/package.json +3 -3
  101. package/dist/components/tree/use-tree-keyboard.svelte.d.ts +0 -29
  102. package/dist/components/tree/use-tree-keyboard.svelte.js +0 -61
@@ -4,11 +4,9 @@
4
4
  import { cssClasses } from '@fibrae/semi-foundation/components/auto-complete/constants';
5
5
  import AutoCompleteFoundation, { type AutoCompleteAdapter, type AutoCompleteBaseProps, type StateOptionItem } from '@fibrae/semi-foundation/components/auto-complete/foundation';
6
6
  import { comboboxName } from '@fibrae/semi-foundation/components/select/combobox-name';
7
- import { getOptionId } from '@fibrae/semi-foundation/components/select/foundation';
8
- import { isInnerControlKey, toCssLength, getDataAttr } from '@fibrae/semi-foundation/utils';
7
+ import { getOptionId, isInnerControlKey, toCssLength, getDataAttr } from '@fibrae/semi-foundation/utils';
9
8
  import '@fibrae/semi-foundation/components/auto-complete/auto-complete.css';
10
9
  import { useDefaultProps, useFoundation } from '../../base/index.js';
11
- import { useClickOutside } from '../../hooks/index.js';
12
10
  import { splitControlAttrs } from '../../utils/index.js';
13
11
  import { useConfig } from '../config-provider/index.js';
14
12
  import { getInputGroupInScope, setInputGroupContext } from '../input/context.js';
@@ -16,7 +14,6 @@
16
14
  import { Popover } from '../popover/index.js';
17
15
  import Option from '../select/option.svelte';
18
16
  import { Spin } from '../spin/index.js';
19
- import { useNestedPopups } from '../tooltip/context.js';
20
17
  import type { TooltipTriggerProps } from '../tooltip/index.js';
21
18
  import type { AutoCompleteDataItem, AutoCompleteItems, AutoCompleteProps, AutoCompleteTriggerSnippetProps } from './interface.js';
22
19
 
@@ -42,9 +39,9 @@
42
39
  defaultActiveFirstOption = defaults('defaultActiveFirstOption', false),
43
40
  defaultOpen = defaults('defaultOpen'),
44
41
  disabled: disabledProp,
45
- dropdownClassName = defaults('dropdownClassName'),
42
+ classNames = defaults('classNames'),
46
43
  dropdownMatchSelectWidth = defaults('dropdownMatchSelectWidth', true),
47
- dropdownStyle = defaults('dropdownStyle'),
44
+ styles = defaults('styles'),
48
45
  // no global default: a global id would repeat on every instance
49
46
  insetLabelId,
50
47
  loading = defaults('loading', false),
@@ -84,8 +81,6 @@
84
81
  let previousData: unknown;
85
82
  const controlKeys = new Set(['id', 'name', 'aria-describedby', 'aria-errormessage', 'aria-invalid', 'aria-label', 'aria-labelledby', 'aria-required']);
86
83
 
87
- const nestedPopups = useNestedPopups();
88
-
89
84
  // an InputGroup supplies size and disabled when the control is given none; the controls inside this one must not read it again
90
85
  const group = getInputGroupInScope();
91
86
  const disabled = $derived(disabledProp ?? group?.disabled ?? defaults('disabled'));
@@ -228,6 +223,12 @@
228
223
  rest.onclick?.(event);
229
224
  };
230
225
 
226
+ const handleClickOutside = (event: MouseEvent) => {
227
+ if (listbox) {
228
+ foundation.handleClickOutside(event);
229
+ }
230
+ };
231
+
231
232
  // A snapshot of the items, so an array changed in place (push, an edited field) is noticed as well; the items are
232
233
  // flat data, nodes go in the item snippet.
233
234
  $effect.pre(() => {
@@ -239,17 +240,6 @@
239
240
  }
240
241
  });
241
242
 
242
- useClickOutside(
243
- [() => root, () => listbox],
244
- (event) => {
245
- if (listbox) {
246
- foundation.handleClickOutside(event);
247
- }
248
- },
249
- () => states().visible,
250
- nestedPopups
251
- );
252
-
253
243
  export function focus(options?: FocusOptions) {
254
244
  input?.focus(options);
255
245
  }
@@ -274,7 +264,7 @@
274
264
  {...inputAttrs}
275
265
  aria-activedescendant={activeDescendant}
276
266
  aria-autocomplete="list"
277
- aria-controls={listId}
267
+ aria-controls={states().visible ? listId : undefined}
278
268
  aria-expanded={states().visible}
279
269
  aria-haspopup="listbox"
280
270
  {autofocus}
@@ -301,7 +291,7 @@
301
291
  {/snippet}
302
292
 
303
293
  {#snippet panel()}
304
- <div bind:this={listbox} id={listId} {...nameAttrs} class={[`${prefixCls}-option-list`, dropdownClassName]} role="listbox" style={[`max-height: ${toCssLength(maxHeight)}`, dropdownStyle].filter(Boolean).join('; ')} onmousedown={keepFocusOnPress}>
294
+ <div bind:this={listbox} id={listId} {...nameAttrs} class={[`${prefixCls}-option-list`, classNames?.dropdown]} role="listbox" style={[`max-height: ${toCssLength(maxHeight)}`, styles?.dropdown].filter(Boolean).join('; ')} onmousedown={keepFocusOnPress}>
305
295
  {#if loading}
306
296
  <div class={`${prefixCls}-loading-wrapper`}>
307
297
  <Spin />
@@ -330,6 +320,7 @@
330
320
  content={panel}
331
321
  disableArrowKeyDown
332
322
  {motion}
323
+ onClickOutSide={handleClickOutside}
333
324
  onEscKeyDown={foundation.handleEscKeyDown}
334
325
  position={resolvedPosition}
335
326
  role="presentation"
@@ -1,5 +1,6 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { ClassValue, HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
3
+ import type { AutoCompletePart } from '@fibrae/semi-foundation/components/auto-complete/constants';
3
4
  import type { Size } from '@fibrae/semi-foundation/utils';
4
5
  import type { ValidateStatus } from '../input/index.js';
5
6
  import type { Position } from '../tooltip/index.js';
@@ -47,9 +48,9 @@ export interface AutoCompleteProps<T extends AutoCompleteItems = AutoCompleteIte
47
48
  /** Opens the list on mount; AutoComplete has no controlled open state */
48
49
  defaultOpen?: boolean;
49
50
  disabled?: boolean;
50
- dropdownClassName?: string;
51
+ classNames?: Partial<Record<AutoCompletePart, ClassValue>>;
51
52
  dropdownMatchSelectWidth?: boolean;
52
- dropdownStyle?: string;
53
+ styles?: Partial<Record<AutoCompletePart, string>>;
53
54
  insetLabelId?: string;
54
55
  loading?: boolean;
55
56
  maxHeight?: string | number;
@@ -14,8 +14,8 @@
14
14
  theme = defaults('theme', 'solid'),
15
15
  position = defaults('position'),
16
16
  overflowCount = defaults('overflowCount'),
17
- countClassName = defaults('countClassName'),
18
- countStyle = defaults('countStyle'),
17
+ classNames = defaults('classNames'),
18
+ styles = defaults('styles'),
19
19
  children,
20
20
  ...rest
21
21
  }: BadgeProps = $props();
@@ -34,7 +34,6 @@
34
34
  {@render children?.()}
35
35
  <span
36
36
  class={[
37
- countClassName,
38
37
  {
39
38
  [`${prefixCls}-${type}`]: !custom,
40
39
  [`${prefixCls}-${theme}`]: !custom,
@@ -44,8 +43,9 @@
44
43
  [`${prefixCls}-count`]: !dot && !custom && count != null,
45
44
  [`${prefixCls}-custom`]: custom,
46
45
  },
46
+ classNames?.count,
47
47
  ]}
48
- style={countStyle}
48
+ style={styles?.count}
49
49
  x-semi-prop="count"
50
50
  >
51
51
  {#if !dot}
@@ -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 { BadgePart } from '@fibrae/semi-foundation/components/badge/constants';
3
4
  export type BadgeType = 'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning' | 'success';
4
5
  export type BadgeTheme = 'solid' | 'light' | 'inverted';
5
6
  export type BadgePosition = 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
@@ -12,7 +13,7 @@ export interface BadgeProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'child
12
13
  /** Defaults to `leftTop` in an RTL ConfigProvider and `rightTop` otherwise */
13
14
  position?: BadgePosition;
14
15
  overflowCount?: number;
15
- countClassName?: string;
16
- countStyle?: string;
16
+ classNames?: Partial<Record<BadgePart, ClassValue>>;
17
+ styles?: Partial<Record<BadgePart, string>>;
17
18
  children?: Snippet;
18
19
  }
@@ -20,14 +20,15 @@
20
20
  // default below, and a fallback would make every button look like it was given a value and hide the group's
21
21
  let {
22
22
  block = defaults('block', false),
23
+ classNames = defaults('classNames'),
23
24
  colorful,
24
- contentClassName = defaults('contentClassName'),
25
25
  disabled,
26
26
  htmlType = defaults('htmlType', 'button'),
27
27
  iconPosition = defaults('iconPosition', strings.DEFAULT_ICON_POSITION),
28
28
  loading = defaults('loading', false),
29
29
  noHorizontalPadding = defaults('noHorizontalPadding', false),
30
30
  size,
31
+ styles = defaults('styles'),
31
32
  theme,
32
33
  type,
33
34
  children,
@@ -129,7 +130,7 @@
129
130
  type={htmlType}
130
131
  onclickcapture={guardLoadingClick}
131
132
  >
132
- <span class={[`${prefix}-content`, contentClassName]} x-semi-prop={iconLayout ? undefined : 'children'}>
133
+ <span class={[`${prefix}-content`, classNames?.content]} style={styles?.content} x-semi-prop={iconLayout ? undefined : 'children'}>
133
134
  {#if iconLayout}
134
135
  {#if iconPosition === 'left' || iconOnly}
135
136
  {@render iconPart()}
@@ -1,5 +1,6 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements';
2
+ import type { ClassValue, HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements';
3
+ import type { ButtonPart } from '@fibrae/semi-foundation/components/button/constants';
3
4
  import type { Size } from '@fibrae/semi-foundation/utils';
4
5
  export type HtmlType = 'button' | 'reset' | 'submit';
5
6
  export type { Size };
@@ -12,8 +13,8 @@ export interface ButtonIconArgs {
12
13
  }
13
14
  export interface ButtonProps extends Omit<HTMLButtonAttributes, 'children' | 'type'> {
14
15
  block?: boolean;
16
+ classNames?: Partial<Record<ButtonPart, ClassValue>>;
15
17
  colorful?: boolean;
16
- contentClassName?: string;
17
18
  disabled?: boolean;
18
19
  htmlType?: HtmlType;
19
20
  iconPosition?: 'left' | 'right';
@@ -21,6 +22,7 @@ export interface ButtonProps extends Omit<HTMLButtonAttributes, 'children' | 'ty
21
22
  /** Only applies to a button that shows an icon or the loading spinner. */
22
23
  noHorizontalPadding?: boolean | HorizontalPaddingType | HorizontalPaddingType[];
23
24
  size?: Size;
25
+ styles?: Partial<Record<ButtonPart, string>>;
24
26
  theme?: Theme;
25
27
  type?: Type;
26
28
  children?: Snippet;
@@ -11,14 +11,13 @@
11
11
  const defaults = useDefaultProps('Card');
12
12
 
13
13
  let {
14
- bodyStyle = defaults('bodyStyle'),
15
14
  bordered = defaults('bordered', true),
15
+ classNames = defaults('classNames'),
16
16
  footerLine = defaults('footerLine', false),
17
- footerStyle = defaults('footerStyle'),
18
17
  headerLine = defaults('headerLine', true),
19
- headerStyle = defaults('headerStyle'),
20
18
  loading = defaults('loading', false),
21
19
  shadows = defaults('shadows'),
20
+ styles = defaults('styles'),
22
21
  title,
23
22
  headerExtraContent,
24
23
  header,
@@ -48,13 +47,13 @@
48
47
  role={namedRole(rest)}
49
48
  >
50
49
  {#if header || headerExtraContent || hasTitle}
51
- <div class={[`${prefixCls}-header`, { [`${prefixCls}-header-bordered`]: headerLine }]} style={headerStyle}>
50
+ <div class={[`${prefixCls}-header`, { [`${prefixCls}-header-bordered`]: headerLine }, classNames?.header]} style={styles?.header}>
52
51
  {#if header}
53
52
  {@render header()}
54
53
  {:else}
55
54
  <div class={`${prefixCls}-header-wrapper`}>
56
55
  {#if hasTitle}
57
- <div class={[`${prefixCls}-header-wrapper-title`, { [`${prefixCls}-header-wrapper-spacing`]: headerExtraContent }]}>
56
+ <div class={[`${prefixCls}-header-wrapper-title`, { [`${prefixCls}-header-wrapper-spacing`]: headerExtraContent }, classNames?.title]} style={styles?.title}>
58
57
  {#if typeof title === 'function'}
59
58
  {@render title()}
60
59
  {:else}
@@ -64,16 +63,16 @@
64
63
  </div>
65
64
  {/if}
66
65
  {#if headerExtraContent}
67
- <div class={`${prefixCls}-header-wrapper-extra`} x-semi-prop="headerExtraContent">{@render headerExtraContent()}</div>
66
+ <div class={[`${prefixCls}-header-wrapper-extra`, classNames?.extra]} style={styles?.extra} x-semi-prop="headerExtraContent">{@render headerExtraContent()}</div>
68
67
  {/if}
69
68
  </div>
70
69
  {/if}
71
70
  </div>
72
71
  {/if}
73
72
  {#if cover}
74
- <div class={`${prefixCls}-cover`} x-semi-prop="cover">{@render cover()}</div>
73
+ <div class={[`${prefixCls}-cover`, classNames?.cover]} style={styles?.cover} x-semi-prop="cover">{@render cover()}</div>
75
74
  {/if}
76
- <div class={`${prefixCls}-body`} style={bodyStyle}>
75
+ <div class={[`${prefixCls}-body`, classNames?.body]} style={styles?.body}>
77
76
  {#if children}
78
77
  <Skeleton active {loading}>
79
78
  {#snippet placeholder()}
@@ -87,7 +86,7 @@
87
86
  </Skeleton>
88
87
  {/if}
89
88
  {#if actions?.length}
90
- <div class={`${prefixCls}-body-actions`}>
89
+ <div class={[`${prefixCls}-body-actions`, classNames?.actions]} style={styles?.actions}>
91
90
  <Space spacing={12}>
92
91
  {#each actions as action, index (index)}
93
92
  <div class={`${prefixCls}-body-actions-item`} x-semi-prop={`actions.${index}`}>{@render action()}</div>
@@ -97,6 +96,6 @@
97
96
  {/if}
98
97
  </div>
99
98
  {#if footer}
100
- <div class={[`${prefixCls}-footer`, { [`${prefixCls}-footer-bordered`]: footerLine }]} style={footerStyle} x-semi-prop="footer">{@render footer()}</div>
99
+ <div class={[`${prefixCls}-footer`, { [`${prefixCls}-footer-bordered`]: footerLine }, classNames?.footer]} style={styles?.footer} x-semi-prop="footer">{@render footer()}</div>
101
100
  {/if}
102
101
  </div>
@@ -1,17 +1,17 @@
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 { CardPart } from '@fibrae/semi-foundation/components/card/constants';
3
4
  import type { SpaceProps } from '../space/interface.js';
4
5
  export type Shadows = 'hover' | 'always';
5
6
  export type CardGroupType = 'grid';
6
7
  export interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
7
- bodyStyle?: string;
8
8
  bordered?: boolean;
9
+ classNames?: Partial<Record<CardPart, ClassValue>>;
9
10
  footerLine?: boolean;
10
- footerStyle?: string;
11
11
  headerLine?: boolean;
12
- headerStyle?: string;
13
12
  loading?: boolean;
14
13
  shadows?: Shadows;
14
+ styles?: Partial<Record<CardPart, string>>;
15
15
  /** A string renders as a 6th-level title with a single-line ellipsis tooltip; a snippet renders as it is */
16
16
  title?: string | Snippet;
17
17
  headerExtraContent?: Snippet;
@@ -9,7 +9,6 @@
9
9
  import '@fibrae/semi-foundation/components/cascader/cascader.css';
10
10
  import { IconChevronDown, IconClear } from '@fibrae/semi-icons-svelte';
11
11
  import { useDefaultProps, useFoundation } from '../../base/index.js';
12
- import { useClickOutside } from '../../hooks/index.js';
13
12
  import { splitControlAttrs, type SlotKind, trackSlotKind } from '../../utils/index.js';
14
13
  import { useConfig } from '../config-provider/index.js';
15
14
  import { getInputGroupInScope, setInputGroupContext } from '../input/context.js';
@@ -18,7 +17,6 @@
18
17
  import { Popover } from '../popover/index.js';
19
18
  import { TagInput, type TagInputTagSnippetProps } from '../tag-input/index.js';
20
19
  import { Tag, type TagCloseEvent } from '../tag/index.js';
21
- import { useNestedPopups } from '../tooltip/context.js';
22
20
  import type { TooltipTriggerProps } from '../tooltip/index.js';
23
21
  import type { CascaderChangeValue, CascaderData, CascaderEntity, CascaderProps, CascaderScrollPanelProps, CascaderTagSnippetProps, CascaderTriggerSnippetProps, CascaderValue } from './interface.js';
24
22
  import Item from './item.svelte';
@@ -72,8 +70,8 @@
72
70
  autoAdjustOverflow = defaults('autoAdjustOverflow'),
73
71
  position = defaults('position'),
74
72
  stopPropagation = defaults('stopPropagation', true),
75
- dropdownClassName = defaults('dropdownClassName'),
76
- dropdownStyle = defaults('dropdownStyle'),
73
+ classNames = defaults('classNames'),
74
+ styles = defaults('styles'),
77
75
  preventScroll = defaults('preventScroll'),
78
76
  virtualizeInSearch = defaults('virtualizeInSearch'),
79
77
  onChange,
@@ -128,8 +126,6 @@
128
126
  const reported = new WeakSet<KeyboardEvent>();
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);
@@ -435,6 +431,12 @@
435
431
  rest.onfocusout?.(event);
436
432
  };
437
433
 
434
+ const handleClickOutside = (event: MouseEvent) => {
435
+ if (contentEl) {
436
+ foundation.handleClickOutside(event);
437
+ }
438
+ };
439
+
438
440
  $effect.pre(() => {
439
441
  const snapshot = $state.snapshot(treeData);
440
442
  untrack(() => {
@@ -459,17 +461,6 @@
459
461
  }
460
462
  });
461
463
 
462
- useClickOutside(
463
- [() => triggerEl, () => contentEl],
464
- (event) => {
465
- if (contentEl) {
466
- foundation.handleClickOutside(event);
467
- }
468
- },
469
- () => states().isOpen,
470
- nestedPopups
471
- );
472
-
473
464
  export function open() {
474
465
  foundation.open();
475
466
  }
@@ -694,7 +685,7 @@
694
685
  {/snippet}
695
686
 
696
687
  {#snippet panel()}
697
- <div bind:this={contentEl} class={[dropdownClassName, `${cls}-popover`]} style={dropdownStyle} onfocusin={foundation.handleFocusEnter} onfocusout={handleFocusOut} onkeydown={handleContentKeyDown} onmousedown={keepFocusOnPress}>
688
+ <div bind:this={contentEl} class={[`${cls}-popover`, classNames?.dropdown]} style={styles?.dropdown} onfocusin={foundation.handleFocusEnter} onfocusout={handleFocusOut} onkeydown={handleContentKeyDown} onmousedown={keepFocusOnPress}>
698
689
  {@render topSlot?.()}
699
690
  <Item
700
691
  activeKeys={view.activeKeys}
@@ -737,7 +728,9 @@
737
728
  bind:visible={() => view.isOpen, () => undefined}
738
729
  child={triggerNode}
739
730
  content={panel}
731
+ disableArrowKeyDown
740
732
  {motion}
733
+ onClickOutSide={handleClickOutside}
741
734
  onEscKeyDown={foundation.close}
742
735
  onOpen={foundation.handlePopoverOpen}
743
736
  position={resolvedPosition}
@@ -1,5 +1,6 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { ClassValue, HTMLAttributes } from 'svelte/elements';
3
+ import type { CascaderPart } from '@fibrae/semi-foundation/components/cascader/constants';
3
4
  import type { BasicCascaderData, BasicEntity, BasicScrollPanelProps, KeyMapProps, Virtualize } from '@fibrae/semi-foundation/components/cascader/foundation';
4
5
  import type { Size } from '@fibrae/semi-foundation/utils';
5
6
  import type { CheckboxEvent } from '../checkbox/index.js';
@@ -123,8 +124,8 @@ export interface CascaderProps extends Omit<HTMLAttributes<HTMLDivElement>, Nati
123
124
  autoAdjustOverflow?: boolean;
124
125
  position?: Position;
125
126
  stopPropagation?: boolean | string;
126
- dropdownClassName?: string;
127
- dropdownStyle?: string;
127
+ classNames?: Partial<Record<CascaderPart, ClassValue>>;
128
+ styles?: Partial<Record<CascaderPart, string>>;
128
129
  preventScroll?: boolean;
129
130
  virtualizeInSearch?: CascaderVirtualize;
130
131
  onChange?: (value: CascaderChangeValue) => void;
@@ -279,7 +279,7 @@
279
279
  {#if isBranch(item)}
280
280
  {#if rowState.loading}
281
281
  <!-- the option carries the state as aria-busy; the spinner's own name would join the option's name -->
282
- <span aria-hidden="true"><Spin wrapperClassName={`${prefix}-spin-icon ${prefix}-icon-left`} /></span>
282
+ <span aria-hidden="true"><Spin class={`${prefix}-spin-icon ${prefix}-icon-left`} /></span>
283
283
  {:else if expandIcon}
284
284
  {@render expandIcon()}
285
285
  {:else}
@@ -40,6 +40,7 @@
40
40
  const locale = useLocale('ColorPicker');
41
41
 
42
42
  let picker = $state<HTMLDivElement>();
43
+ let popover = $state<Popover>();
43
44
 
44
45
  // $bindable needs destructuring, so the foundation reads the props through getters
45
46
  const foundationProps: FoundationProps = {
@@ -111,7 +112,21 @@
111
112
  {/snippet}
112
113
 
113
114
  {#if usePopover}
114
- <Popover {...popoverProps} aria-label={popoverLabel} child={children ? undefined : defaultTrigger} {children} class={popoverClass} content={panel} role={popoverProps?.role ?? 'dialog'} trigger={popoverProps?.trigger ?? 'click'} />
115
+ <Popover
116
+ {...popoverProps}
117
+ aria-label={popoverLabel}
118
+ bind:this={popover}
119
+ child={children ? undefined : defaultTrigger}
120
+ {children}
121
+ class={popoverClass}
122
+ content={panel}
123
+ onOpen={() => {
124
+ ColorPickerFoundation.focusPopup(popover?.getPopup() ?? null);
125
+ popoverProps?.onOpen?.();
126
+ }}
127
+ role={popoverProps?.role ?? 'dialog'}
128
+ trigger={popoverProps?.trigger ?? 'click'}
129
+ />
115
130
  {:else}
116
131
  {@render panel()}
117
132
  {/if}
@@ -18,8 +18,7 @@
18
18
  let {
19
19
  zoom = $bindable(),
20
20
  aspectRatio = defaults('aspectRatio'),
21
- cropperBoxCls = defaults('cropperBoxCls'),
22
- cropperBoxStyle = defaults('cropperBoxStyle'),
21
+ classNames = defaults('classNames'),
23
22
  defaultAspectRatio = defaults('defaultAspectRatio', 1),
24
23
  fill = defaults('fill', 'rgba(0, 0, 0, 0)'),
25
24
  imgProps = defaults('imgProps'),
@@ -30,6 +29,7 @@
30
29
  shape = defaults('shape', 'rect'),
31
30
  showResizeBox = defaults('showResizeBox', true),
32
31
  src = defaults('src'),
32
+ styles = defaults('styles'),
33
33
  zoomStep = defaults('zoomStep', 0.1),
34
34
  onZoomChange,
35
35
  ...rest
@@ -130,9 +130,9 @@
130
130
  aria-describedby="{uid}-help"
131
131
  aria-label={locale().locale.cropArea}
132
132
  aria-roledescription={locale().locale.cropAreaRole}
133
- class={[cssClasses.CROPPER_BOX, cropperBoxCls, { [cssClasses.CROPPER_VIEW_BOX_ROUND]: shape === 'round' }]}
133
+ class={[cssClasses.CROPPER_BOX, { [cssClasses.CROPPER_VIEW_BOX_ROUND]: shape === 'round' }, classNames?.cropperBox]}
134
134
  role="group"
135
- style={[cropperBoxStyle, boxStyle].filter(Boolean).join('; ')}
135
+ style={[styles?.cropperBox, boxStyle].filter(Boolean).join('; ')}
136
136
  tabindex={states().loaded ? 0 : undefined}
137
137
  onkeydown={foundation.handleCropperBoxKeyDown}
138
138
  onlostpointercapture={foundation.handleCropperBoxLostPointerCapture}
@@ -1,4 +1,5 @@
1
- import type { HTMLAttributes, HTMLImgAttributes } from 'svelte/elements';
1
+ import type { ClassValue, HTMLAttributes, HTMLImgAttributes } from 'svelte/elements';
2
+ import type { CropperPart } from '@fibrae/semi-foundation/components/cropper/constants';
2
3
  export type CropperShape = 'rect' | 'round' | 'roundRect';
3
4
  export interface CropperProps extends HTMLAttributes<HTMLDivElement> {
4
5
  src?: string;
@@ -13,8 +14,8 @@ export interface CropperProps extends HTMLAttributes<HTMLDivElement> {
13
14
  /** Image rotation angle; one-way, the cropper never changes it */
14
15
  rotate?: number;
15
16
  showResizeBox?: boolean;
16
- cropperBoxStyle?: string;
17
- cropperBoxCls?: string;
17
+ classNames?: Partial<Record<CropperPart, ClassValue>>;
18
+ styles?: Partial<Record<CropperPart, string>>;
18
19
  fill?: string;
19
20
  maxZoom?: number;
20
21
  minZoom?: number;
@@ -173,6 +173,7 @@
173
173
  autofocus={props.autofocus}
174
174
  bind:value={() => rangeParts.start, () => {}}
175
175
  borderless={props.borderless}
176
+ class={props.inputClassName}
176
177
  disabled={props.disabled}
177
178
  onChange={(next, event) => props.onChange?.(rangeValue(next, rangeParts.end), event)}
178
179
  onEnterPress={(event) => foundation.handleRangeInputEnterPress(event, rangeValue(rangeParts.start, rangeParts.end))}
@@ -208,6 +209,7 @@
208
209
  {...rangeAttrs}
209
210
  bind:value={() => rangeParts.end, () => {}}
210
211
  borderless={props.borderless}
212
+ class={props.inputClassName}
211
213
  disabled={props.disabled}
212
214
  onChange={(next, event) => props.onChange?.(rangeValue(rangeParts.start, next), event)}
213
215
  onEnterPress={(event) => foundation.handleRangeInputEnterPress(event, rangeValue(rangeParts.start, rangeParts.end))}
@@ -240,7 +242,7 @@
240
242
  autofocus={props.autofocus}
241
243
  bind:value={() => text, () => {}}
242
244
  borderless={props.borderless}
243
- class={inputClass}
245
+ class={[inputClass, props.inputClassName]}
244
246
  clearIcon={props.clearIcon}
245
247
  disabled={props.disabled}
246
248
  hideSuffix={props.showClear}
@@ -60,7 +60,6 @@
60
60
  borderless = defaults('borderless', false),
61
61
  showClear = defaults('showClear', true),
62
62
  inputReadOnly = defaults('inputReadOnly', false),
63
- inputStyle = defaults('inputStyle'),
64
63
  insetInput = defaults('insetInput', false),
65
64
  insetLabelId,
66
65
  validateStatus = defaults('validateStatus'),
@@ -81,8 +80,8 @@
81
80
  position: positionProp = defaults('position'),
82
81
  spacing: spacingProp = defaults('spacing'),
83
82
  stopPropagation = defaults('stopPropagation', true),
84
- dropdownClassName = defaults('dropdownClassName'),
85
- dropdownStyle = defaults('dropdownStyle'),
83
+ classNames = defaults('classNames'),
84
+ styles = defaults('styles'),
86
85
  onChange,
87
86
  onOpenChange,
88
87
  onFocus,
@@ -323,7 +322,6 @@
323
322
  borderless,
324
323
  showClear,
325
324
  inputReadOnly,
326
- inputStyle,
327
325
  insetInput,
328
326
  insetLabelId,
329
327
  validateStatus,
@@ -343,8 +341,6 @@
343
341
  position: positionProp,
344
342
  spacing: spacingProp,
345
343
  stopPropagation,
346
- dropdownClassName,
347
- dropdownStyle,
348
344
  },
349
345
  onChange: foundation.handleInputChange,
350
346
  onEnterPress: foundation.handleInputComplete,
@@ -397,6 +393,8 @@
397
393
  }
398
394
  </script>
399
395
 
396
+ <svelte:document onfocusin={(event) => foundation.handleDocumentFocusIn(event, root)} />
397
+
400
398
  {#snippet quickControls()}
401
399
  <QuickControl {insetInput} locale={locale().locale} onPresetClick={foundation.handlePresetClick} {presetPosition} {presets} {type} />
402
400
  {/snippet}
@@ -421,7 +419,7 @@
421
419
  {/snippet}
422
420
 
423
421
  {#snippet content()}
424
- <div bind:this={panelElement} {...{ 'x-type': type }} class={[prefixCls, { [cssClasses.PANEL_YAM]: isYearOrMonth, [`${prefixCls}-compact`]: density === 'compact' }, dropdownClassName]} id={panelId} style={dropdownStyle}>
422
+ <div bind:this={panelElement} {...{ 'x-type': type }} class={[prefixCls, { [cssClasses.PANEL_YAM]: isYearOrMonth, [`${prefixCls}-compact`]: density === 'compact' }, classNames?.dropdown]} id={panelId} style={styles?.dropdown}>
425
423
  <div class={`${prefixCls}-container`}>
426
424
  {#if leftSlot}
427
425
  <div class={`${prefixCls}-leftSlot`} x-semi-prop="leftSlot">{@render leftSlot()}</div>
@@ -528,7 +526,7 @@
528
526
  <div
529
527
  bind:this={combobox}
530
528
  {...props}
531
- aria-controls={isTriggerButton ? panelId : undefined}
529
+ aria-controls={isTriggerButton && panelShow ? panelId : undefined}
532
530
  aria-describedby={isTriggerButton ? (rest['aria-describedby'] as string | undefined) : undefined}
533
531
  aria-disabled={isTriggerButton ? disabled : undefined}
534
532
  aria-errormessage={isTriggerButton ? (rest['aria-errormessage'] as string | undefined) : undefined}
@@ -553,7 +551,7 @@
553
551
  {clearIcon}
554
552
  controlAttrs={{
555
553
  ...attrs.control,
556
- 'aria-controls': panelId,
554
+ 'aria-controls': panelShow ? panelId : undefined,
557
555
  'aria-expanded': panelShow,
558
556
  'aria-haspopup': 'dialog',
559
557
  'aria-label': rest['aria-labelledby'] ? undefined : triggerName,
@@ -563,8 +561,9 @@
563
561
  {defaultPickerValue}
564
562
  disabled={inputDisabled}
565
563
  {format}
564
+ inputClassName={classNames?.input}
566
565
  inputReadOnly={inputReadOnly || Boolean(insetInput)}
567
- {inputStyle}
566
+ inputStyle={styles?.input}
568
567
  inputValue={states().inputValue}
569
568
  {insetLabel}
570
569
  {insetLabelId}
@@ -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 { DatePickerPart } from '@fibrae/semi-foundation/components/date-picker/constants';
3
4
  import type { BaseValueType, DateOffsetType, DayStatusType, DensityType, DisabledDateOptions, DisabledDateType, DisabledTimeType, PresetPosition, PresetType, PresetsType, Type, ValueType, WeekStartNumber } from '@fibrae/semi-foundation/components/date-picker/foundation';
4
5
  import type { InsetInputProps, RangeInput } from '@fibrae/semi-foundation/components/date-picker/input-foundation';
5
6
  import type { InputSize, ValidateStatus } from '../input/index.js';
@@ -66,7 +67,6 @@ interface DatePickerCommonProps extends Omit<HTMLAttributes<HTMLDivElement>, Nat
66
67
  borderless?: boolean;
67
68
  showClear?: boolean;
68
69
  inputReadOnly?: boolean;
69
- inputStyle?: string;
70
70
  insetInput?: boolean | DatePickerInsetInputProps;
71
71
  insetLabelId?: string;
72
72
  validateStatus?: ValidateStatus;
@@ -92,8 +92,9 @@ interface DatePickerCommonProps extends Omit<HTMLAttributes<HTMLDivElement>, Nat
92
92
  /** Defaults to 1 for an `insetInput` panel over the trigger, else the Popover spacing */
93
93
  spacing?: number;
94
94
  stopPropagation?: boolean | string;
95
- dropdownClassName?: string;
96
- dropdownStyle?: string;
95
+ /** `dropdown` is the panel; `input` is the Input's root element (each of the two inputs of a range) */
96
+ classNames?: Partial<Record<DatePickerPart, ClassValue>>;
97
+ styles?: Partial<Record<DatePickerPart, string>>;
97
98
  onOpenChange?: (open: boolean) => void;
98
99
  /**
99
100
  * focusin of an input, or the click or key press on the trigger that focused the range start; `rangeType` is set
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import type { ClassValue } from 'svelte/elements';
2
3
  import type { Locale as DateFnsLocale } from 'date-fns';
3
4
  import type { DisabledTimeType, PresetType, Type, WeekStartNumber } from '@fibrae/semi-foundation/components/date-picker/foundation';
4
5
  import type { InsetInputChangeFoundationProps, InsetInputChangeProps, InsetInputValue, RangeInput } from '@fibrae/semi-foundation/components/date-picker/input-foundation';
@@ -162,6 +163,7 @@ export interface DateInputProps {
162
163
  showClear?: boolean;
163
164
  showClearIgnoreDisabled?: boolean;
164
165
  inputReadOnly?: boolean;
166
+ inputClassName?: ClassValue;
165
167
  inputStyle?: string;
166
168
  insetLabelId?: string;
167
169
  validateStatus?: ValidateStatus;