@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.
- 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/form/form.svelte +3 -1
- package/dist/components/form/index.d.ts +4 -2
- package/dist/components/form/index.js +3 -1
- package/dist/components/form/interface.d.ts +57 -10
- package/dist/components/form/label.svelte +37 -13
- package/dist/components/form/schema-form/schema-field.svelte +4 -6
- package/dist/components/form/schema-form/schema-form.svelte +2 -2
- package/dist/components/form/schema-form/schema-node.svelte +73 -91
- package/dist/components/form/schema-form/schema-node.svelte.d.ts +2 -3
- package/dist/components/form/schema-form/semi-array.svelte +47 -0
- package/dist/components/form/schema-form/semi-array.svelte.d.ts +7 -0
- package/dist/components/form/schema-form/semi-field.svelte +42 -0
- package/dist/components/form/schema-form/semi-field.svelte.d.ts +8 -0
- package/dist/components/form/schema-form/semi-renderers.svelte +24 -0
- package/dist/components/form/schema-form/semi-renderers.svelte.d.ts +24 -0
- package/dist/components/form/schema-form/semi-section.svelte +22 -0
- package/dist/components/form/schema-form/semi-section.svelte.d.ts +10 -0
- package/dist/components/form/section.svelte +8 -2
- 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/icon.svelte +1 -1
- 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/body/body.svelte +21 -8
- 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 +15 -3
- package/dist/components/table/table.svelte +38 -8
- 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/internal/virtual-list.svelte +11 -1
- package/dist/internal/virtual-list.svelte.d.ts +7 -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
|
@@ -164,77 +164,79 @@
|
|
|
164
164
|
{/snippet}
|
|
165
165
|
|
|
166
166
|
{#if !view.hidden}
|
|
167
|
-
<
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
<StepButton disabled={disabledState.prevDisabled || disabled} kind="prev" label={text.prev} text={prevText} onclick={foundation.goPrev} />
|
|
173
|
-
</li>
|
|
174
|
-
{#if size === 'small'}
|
|
167
|
+
<nav {...rest} aria-label={rest['aria-label'] ?? text.label} class={[`${prefix}-wrapper`, rest.class]}>
|
|
168
|
+
<ul class={[prefix, { [`${prefix}-small`]: size === 'small', [`${prefix}-disabled`]: disabled }]}>
|
|
169
|
+
{#if showTotal && size !== 'small'}
|
|
170
|
+
<li class={`${prefix}-total`}>{formatLocale(text.total, { total: view.totalPageNum })}</li>
|
|
171
|
+
{/if}
|
|
175
172
|
<li>
|
|
176
|
-
{
|
|
177
|
-
<Popover>
|
|
178
|
-
{#snippet child({ props })}
|
|
179
|
-
<button {...props} class={`${prefix}-item ${prefix}-item-small`} type="button">{smallText}</button>
|
|
180
|
-
{/snippet}
|
|
181
|
-
{#snippet content()}
|
|
182
|
-
<RestPages count={view.totalPageNum} onSelect={foundation.goPage} start={1} />
|
|
183
|
-
{/snippet}
|
|
184
|
-
</Popover>
|
|
185
|
-
{:else}
|
|
186
|
-
<div class={[`${prefix}-item`, `${prefix}-item-small`, { [`${prefix}-item-all-disabled`]: disabled }]}>
|
|
187
|
-
{smallText}
|
|
188
|
-
</div>
|
|
189
|
-
{/if}
|
|
173
|
+
<StepButton disabled={disabledState.prevDisabled || disabled} kind="prev" label={text.prev} text={prevText} onclick={foundation.goPrev} />
|
|
190
174
|
</li>
|
|
191
|
-
|
|
192
|
-
{#each pageData.pageList as page, i (page === '...' ? (i < 3 ? 'rest-left' : 'rest-right') : page)}
|
|
175
|
+
{#if size === 'small'}
|
|
193
176
|
<li>
|
|
194
|
-
{#if
|
|
195
|
-
<Popover
|
|
177
|
+
{#if hoverShowPageSelect && !disabled}
|
|
178
|
+
<Popover>
|
|
196
179
|
{#snippet child({ props })}
|
|
197
|
-
{
|
|
180
|
+
<button {...props} class={`${prefix}-item ${prefix}-item-small`} type="button">{smallText}</button>
|
|
198
181
|
{/snippet}
|
|
199
182
|
{#snippet content()}
|
|
200
|
-
<RestPages {
|
|
183
|
+
<RestPages count={view.totalPageNum} onSelect={foundation.goPage} start={1} />
|
|
201
184
|
{/snippet}
|
|
202
185
|
</Popover>
|
|
203
186
|
{:else}
|
|
204
|
-
{
|
|
187
|
+
<div class={[`${prefix}-item`, `${prefix}-item-small`, { [`${prefix}-item-all-disabled`]: disabled }]}>
|
|
188
|
+
{smallText}
|
|
189
|
+
</div>
|
|
205
190
|
{/if}
|
|
206
191
|
</li>
|
|
207
|
-
{
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
showClear={false}
|
|
228
|
-
value={states().pageSize}
|
|
229
|
-
/>
|
|
230
|
-
</li>
|
|
231
|
-
{/if}
|
|
232
|
-
{#if showQuickJumper}
|
|
233
|
-
<li class={[`${prefix}-quickjump`, { [`${prefix}-quickjump-disabled`]: view.quickJumpDisabled }]}>
|
|
234
|
-
<span>{text.jumpTo}</span>
|
|
235
|
-
<InputNumber aria-label={text.jumpTo} class={`${prefix}-quickjump-input-number`} disabled={view.quickJumpDisabled} hideButtons onBlur={foundation.handleQuickJumpBlur} onChange={foundation.handleQuickJumpNumberChange} onKeyDown={onQuickJumpKeydown} showClear={false} value={states().quickJumpPage} />
|
|
236
|
-
<span>{text.page}</span>
|
|
192
|
+
{:else}
|
|
193
|
+
{#each pageData.pageList as page, i (page === '...' ? (i < 3 ? 'rest-left' : 'rest-right') : page)}
|
|
194
|
+
<li>
|
|
195
|
+
{#if isRest(page)}
|
|
196
|
+
<Popover position={popoverPosition} trigger="hover">
|
|
197
|
+
{#snippet child({ props })}
|
|
198
|
+
{@render pageButton(page, props)}
|
|
199
|
+
{/snippet}
|
|
200
|
+
{#snippet content()}
|
|
201
|
+
<RestPages {...i < 3 ? pageData.restLeftRange : pageData.restRightRange} onSelect={foundation.goPage} />
|
|
202
|
+
{/snippet}
|
|
203
|
+
</Popover>
|
|
204
|
+
{:else}
|
|
205
|
+
{@render pageButton(page)}
|
|
206
|
+
{/if}
|
|
207
|
+
</li>
|
|
208
|
+
{/each}
|
|
209
|
+
{/if}
|
|
210
|
+
<li>
|
|
211
|
+
<StepButton disabled={disabledState.nextDisabled || disabled} kind="next" label={text.next} text={nextText} onclick={foundation.goNext} />
|
|
237
212
|
</li>
|
|
238
|
-
|
|
239
|
-
|
|
213
|
+
{#if view.sizeChangerShown}
|
|
214
|
+
<li class={`${prefix}-switch`}>
|
|
215
|
+
<!-- changePageSize takes one number: global Select defaults must not make it search, create, multiple or object-valued, nor add a clear button -->
|
|
216
|
+
<Select
|
|
217
|
+
allowCreate={false}
|
|
218
|
+
aria-label={text.pageSizeSelector}
|
|
219
|
+
classNames={{ dropdown: `${prefix}-select-dropdown` }}
|
|
220
|
+
clickToHide
|
|
221
|
+
{disabled}
|
|
222
|
+
filter={false}
|
|
223
|
+
multiple={false}
|
|
224
|
+
onChange={changePageSize}
|
|
225
|
+
onChangeWithObject={false}
|
|
226
|
+
optionList={sizeOptions}
|
|
227
|
+
position={view.switchPosition}
|
|
228
|
+
showClear={false}
|
|
229
|
+
value={states().pageSize}
|
|
230
|
+
/>
|
|
231
|
+
</li>
|
|
232
|
+
{/if}
|
|
233
|
+
{#if showQuickJumper}
|
|
234
|
+
<li class={[`${prefix}-quickjump`, { [`${prefix}-quickjump-disabled`]: view.quickJumpDisabled }]}>
|
|
235
|
+
<span>{text.jumpTo}</span>
|
|
236
|
+
<InputNumber aria-label={text.jumpTo} class={`${prefix}-quickjump-input-number`} disabled={view.quickJumpDisabled} hideButtons onBlur={foundation.handleQuickJumpBlur} onChange={foundation.handleQuickJumpNumberChange} onKeyDown={onQuickJumpKeydown} showClear={false} value={states().quickJumpPage} />
|
|
237
|
+
<span>{text.page}</span>
|
|
238
|
+
</li>
|
|
239
|
+
{/if}
|
|
240
|
+
</ul>
|
|
241
|
+
</nav>
|
|
240
242
|
{/if}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ClassValue } from 'svelte/elements';
|
|
3
|
+
import type { PopconfirmPart } from '@fibrae/semi-foundation/components/popconfirm/constants';
|
|
2
4
|
import type { ButtonProps, Type as ButtonType } from '../button/interface.js';
|
|
3
5
|
import type { PopoverProps } from '../popover/index.js';
|
|
4
6
|
import type { RenderContentProps } from '../tooltip/index.js';
|
|
@@ -11,6 +13,7 @@ export interface PopconfirmProps extends Omit<PopoverProps, 'content'> {
|
|
|
11
13
|
cancelButtonProps?: PopconfirmButtonProps;
|
|
12
14
|
cancelText?: string;
|
|
13
15
|
cancelType?: ButtonType;
|
|
16
|
+
classNames?: Partial<Record<PopconfirmPart, ClassValue>>;
|
|
14
17
|
disabled?: boolean;
|
|
15
18
|
okButtonProps?: PopconfirmButtonProps;
|
|
16
19
|
okText?: string;
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
condition = defaults('condition'),
|
|
57
57
|
mouseEnterDelay = defaults('mouseEnterDelay'),
|
|
58
58
|
mouseLeaveDelay = defaults('mouseLeaveDelay'),
|
|
59
|
-
|
|
59
|
+
classNames = defaults('classNames'),
|
|
60
60
|
spacing = defaults('spacing'),
|
|
61
|
-
|
|
61
|
+
styles = defaults('styles'),
|
|
62
62
|
'aria-label': ariaLabel = defaults('aria-label'),
|
|
63
63
|
'aria-labelledby': ariaLabelledby = defaults('aria-labelledby'),
|
|
64
64
|
'aria-describedby': ariaDescribedby = defaults('aria-describedby'),
|
|
@@ -257,18 +257,17 @@
|
|
|
257
257
|
aria-label={ariaLabel}
|
|
258
258
|
aria-labelledby={labelledBy}
|
|
259
259
|
{arrowPointAtCenter}
|
|
260
|
-
{arrowStyle}
|
|
261
260
|
{autoAdjustOverflow}
|
|
262
261
|
bind:this={popover}
|
|
263
262
|
bind:visible={() => !disabled && popoverVisible, (next) => foundation.handleVisibleChange(Boolean(next))}
|
|
264
263
|
{child}
|
|
265
264
|
{children}
|
|
266
265
|
class={cssClasses.POPOVER}
|
|
266
|
+
{classNames}
|
|
267
267
|
{clickToHide}
|
|
268
268
|
{closeOnEsc}
|
|
269
269
|
{condition}
|
|
270
270
|
content={card}
|
|
271
|
-
{contentClassName}
|
|
272
271
|
{disableArrowKeyDown}
|
|
273
272
|
{disableFocusListener}
|
|
274
273
|
{guardFocus}
|
|
@@ -285,5 +284,6 @@
|
|
|
285
284
|
{showArrow}
|
|
286
285
|
{spacing}
|
|
287
286
|
{stopPropagation}
|
|
287
|
+
{styles}
|
|
288
288
|
trigger={disabled ? 'custom' : trigger}
|
|
289
289
|
/>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { cssClasses } from '@fibrae/semi-foundation/components/popover/constants';
|
|
3
3
|
import type { ArrowProps } from './interface.js';
|
|
4
4
|
|
|
5
|
-
let { position = '', arrowStyle, popStyle }: ArrowProps = $props();
|
|
5
|
+
let { position = '', arrowStyle, class: className, popStyle }: ArrowProps = $props();
|
|
6
6
|
|
|
7
7
|
const vertical = $derived(position.startsWith('top') || position.startsWith('bottom'));
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
const backgroundColor = $derived(arrowStyle?.backgroundColor ?? readStyle('background-color'));
|
|
13
13
|
</script>
|
|
14
14
|
|
|
15
|
-
<svg aria-hidden="true" class={cssClasses.ARROW} height="8" width="24" xmlns="http://www.w3.org/2000/svg">
|
|
15
|
+
<svg aria-hidden="true" class={[cssClasses.ARROW, className]} height="8" width="24" xmlns="http://www.w3.org/2000/svg">
|
|
16
16
|
{#if vertical}
|
|
17
17
|
<path d="M0 0.5L0 1.5C4 1.5, 5.5 3, 7.5 5S10,8 12,8S14.5 7, 16.5 5S20,1.5 24,1.5L24 0.5L0 0.5z" style:fill={borderColor} style:opacity={arrowStyle?.borderOpacity} />
|
|
18
18
|
<path d="M0 0L0 1C4 1, 5.5 2, 7.5 4S10,7 12,7S14.5 6, 16.5 4S20,1 24,1L24 0L0 0z" style:fill={backgroundColor} />
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ClassValue } from 'svelte/elements';
|
|
2
|
+
import type { PopoverPart } from '@fibrae/semi-foundation/components/popover/constants';
|
|
2
3
|
import type { TooltipProps } from '../tooltip/index.js';
|
|
3
4
|
export interface ArrowStyle {
|
|
4
5
|
borderColor?: string;
|
|
@@ -7,8 +8,9 @@ export interface ArrowStyle {
|
|
|
7
8
|
}
|
|
8
9
|
export interface ArrowProps {
|
|
9
10
|
position?: string;
|
|
11
|
+
class?: ClassValue;
|
|
10
12
|
arrowStyle?: ArrowStyle;
|
|
11
|
-
/** The popup's style string; its `background-color` and `border-color` color the arrow without
|
|
13
|
+
/** The popup's style string; its `background-color` and `border-color` color the arrow without styles.arrow */
|
|
12
14
|
popStyle?: string;
|
|
13
15
|
}
|
|
14
16
|
export interface PopoverProps {
|
|
@@ -36,14 +38,17 @@ export interface PopoverProps {
|
|
|
36
38
|
mouseEnterDelay?: number;
|
|
37
39
|
mouseLeaveDelay?: number;
|
|
38
40
|
trigger?: TooltipProps['trigger'];
|
|
39
|
-
|
|
41
|
+
classNames?: Partial<Record<PopoverPart, ClassValue>>;
|
|
40
42
|
showArrow?: boolean;
|
|
41
43
|
spacing?: number | {
|
|
42
44
|
x: number;
|
|
43
45
|
y: number;
|
|
44
46
|
};
|
|
45
47
|
stopPropagation?: boolean | string;
|
|
46
|
-
|
|
48
|
+
styles?: {
|
|
49
|
+
content?: string;
|
|
50
|
+
arrow?: ArrowStyle;
|
|
51
|
+
};
|
|
47
52
|
arrowPointAtCenter?: boolean;
|
|
48
53
|
closeOnEsc?: boolean;
|
|
49
54
|
guardFocus?: boolean;
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
role = defaults('role'),
|
|
30
30
|
mouseEnterDelay = defaults('mouseEnterDelay'),
|
|
31
31
|
mouseLeaveDelay = defaults('mouseLeaveDelay'),
|
|
32
|
-
|
|
32
|
+
classNames = defaults('classNames'),
|
|
33
33
|
spacing = defaults('spacing'),
|
|
34
34
|
stopPropagation = defaults('stopPropagation'),
|
|
35
|
-
|
|
35
|
+
styles = defaults('styles'),
|
|
36
36
|
arrowPointAtCenter = defaults('arrowPointAtCenter'),
|
|
37
37
|
clickToHide = defaults('clickToHide'),
|
|
38
38
|
disableArrowKeyDown = defaults('disableArrowKeyDown'),
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
</script>
|
|
76
76
|
|
|
77
77
|
{#snippet card(slotProps: RenderContentProps)}
|
|
78
|
-
<div class={[prefixCls,
|
|
78
|
+
<div class={[prefixCls, classNames?.content]} style={styles?.content}>
|
|
79
79
|
<div class={`${prefixCls}-content`}>
|
|
80
80
|
{@render content?.(slotProps)}
|
|
81
81
|
</div>
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
{/snippet}
|
|
84
84
|
|
|
85
85
|
{#snippet popArrow()}
|
|
86
|
-
<Arrow {
|
|
86
|
+
<Arrow arrowStyle={styles?.arrow} class={classNames?.arrow} popStyle={style} {position} />
|
|
87
87
|
{/snippet}
|
|
88
88
|
|
|
89
89
|
<Tooltip
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ClassValue, HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
|
|
3
|
+
import type { RadioPart } from '@fibrae/semi-foundation/components/radio/constants';
|
|
3
4
|
export type RadioValue = string | number | boolean;
|
|
4
5
|
export type RadioType = 'default' | 'button' | 'card' | 'pureCard';
|
|
5
6
|
export type RadioMode = 'advanced' | '';
|
|
@@ -25,8 +26,8 @@ export interface RadioProps extends Omit<HTMLAttributes<HTMLLabelElement>, 'onch
|
|
|
25
26
|
displayMode?: RadioDisplayMode;
|
|
26
27
|
mode?: RadioMode;
|
|
27
28
|
type?: RadioType;
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
classNames?: Partial<Record<RadioPart, ClassValue>>;
|
|
30
|
+
styles?: Partial<Record<RadioPart, string>>;
|
|
30
31
|
addonId?: string;
|
|
31
32
|
extraId?: string;
|
|
32
33
|
preventScroll?: boolean;
|
|
@@ -42,8 +43,8 @@ export interface RadioOptionItem {
|
|
|
42
43
|
class?: string;
|
|
43
44
|
style?: string;
|
|
44
45
|
addonId?: string;
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
classNames?: Partial<Record<RadioPart, ClassValue>>;
|
|
47
|
+
styles?: Partial<Record<RadioPart, string>>;
|
|
47
48
|
extraId?: string;
|
|
48
49
|
}
|
|
49
50
|
export interface RadioGroupOptionSnippetParams {
|
|
@@ -133,15 +133,15 @@
|
|
|
133
133
|
{#if extra}{@render extra({ option, index })}{:else}{option.extra}{/if}
|
|
134
134
|
{/snippet}
|
|
135
135
|
<Radio
|
|
136
|
-
addonClassName={option.addonClass}
|
|
137
136
|
addonId={option.addonId}
|
|
138
|
-
addonStyle={option.addonStyle}
|
|
139
137
|
children={option.label !== undefined || label ? optionLabel : undefined}
|
|
140
138
|
class={option.class}
|
|
139
|
+
classNames={option.classNames}
|
|
141
140
|
disabled={option.disabled || disabled}
|
|
142
141
|
extra={option.extra !== undefined || extra ? optionExtra : undefined}
|
|
143
142
|
extraId={option.extraId}
|
|
144
143
|
style={option.style}
|
|
144
|
+
styles={option.styles}
|
|
145
145
|
value={option.value}
|
|
146
146
|
/>
|
|
147
147
|
{/each}
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
displayMode = defaults('displayMode'),
|
|
24
24
|
mode = defaults('mode', ''),
|
|
25
25
|
type = defaults('type', 'default'),
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
classNames = defaults('classNames'),
|
|
27
|
+
styles = defaults('styles'),
|
|
28
28
|
addonId,
|
|
29
29
|
extraId,
|
|
30
30
|
preventScroll = defaults('preventScroll'),
|
|
@@ -210,7 +210,6 @@
|
|
|
210
210
|
{#if children}
|
|
211
211
|
<span
|
|
212
212
|
class={[
|
|
213
|
-
addonClassName,
|
|
214
213
|
{
|
|
215
214
|
[`${prefix}-addon`]: !view.isButtonRadio,
|
|
216
215
|
[`${prefix}-addon-buttonRadio`]: view.isButtonRadio,
|
|
@@ -218,9 +217,10 @@
|
|
|
218
217
|
[`${prefix}-addon-buttonRadio-disabled`]: view.isButtonRadio && view.disabled,
|
|
219
218
|
[`${prefix}-addon-buttonRadio-${view.buttonSize}`]: view.isButtonRadio && view.buttonSize,
|
|
220
219
|
},
|
|
220
|
+
classNames?.addon,
|
|
221
221
|
]}
|
|
222
222
|
id={addonDomId}
|
|
223
|
-
style={
|
|
223
|
+
style={styles?.addon}
|
|
224
224
|
x-semi-prop="children"
|
|
225
225
|
>
|
|
226
226
|
{@render children()}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { ClassValue, HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { SelectPart } from '@fibrae/semi-foundation/components/select/constants';
|
|
3
4
|
import type { Size } from '@fibrae/semi-foundation/utils';
|
|
4
5
|
import type { InputProps, ValidateStatus } from '../input/index.js';
|
|
5
6
|
import type { PopoverProps } from '../popover/index.js';
|
|
@@ -110,8 +111,8 @@ export interface SelectProps extends Omit<HTMLAttributes<HTMLDivElement>, Native
|
|
|
110
111
|
showClear?: boolean;
|
|
111
112
|
insetLabelId?: string;
|
|
112
113
|
inputProps?: SelectInputProps;
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
classNames?: Partial<Record<SelectPart, ClassValue>>;
|
|
115
|
+
styles?: Partial<Record<SelectPart, string>>;
|
|
115
116
|
dropdownMatchSelectWidth?: boolean;
|
|
116
117
|
position?: Position;
|
|
117
118
|
spacing?: number | {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
{:else if label !== undefined}
|
|
67
67
|
<div class={`${prefixCls}-text`}>
|
|
68
68
|
{#if inputValue}
|
|
69
|
-
<Highlight
|
|
69
|
+
<Highlight classNames={{ highlight: `${prefixCls}-keyword` }} searchWords={[inputValue]} sourceString={String(label)} />
|
|
70
70
|
{:else}
|
|
71
71
|
{label}
|
|
72
72
|
{/if}
|
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
import { FocusTrapHandle } from '@fibrae/semi-foundation/base';
|
|
5
5
|
import { comboboxName } from '@fibrae/semi-foundation/components/select/combobox-name';
|
|
6
6
|
import { cssClasses, numbers, strings } from '@fibrae/semi-foundation/components/select/constants';
|
|
7
|
-
import SelectFoundation, { type SelectAdapter, type SelectBaseProps, type SelectBaseState
|
|
7
|
+
import SelectFoundation, { type SelectAdapter, type SelectBaseProps, type SelectBaseState } from '@fibrae/semi-foundation/components/select/foundation';
|
|
8
8
|
import { type BasicOptionProps, type OptionRecord as BaseOptionRecord, getOptionRuns, toOptionRecord } from '@fibrae/semi-foundation/components/select/option-foundation';
|
|
9
9
|
import { cssClasses as tagCssClasses } from '@fibrae/semi-foundation/components/tag/constants';
|
|
10
|
-
import { isTextEditor, joinIds, toCssLength, getDataAttr } from '@fibrae/semi-foundation/utils';
|
|
10
|
+
import { getOptionId, isTextEditor, joinIds, toCssLength, getDataAttr } from '@fibrae/semi-foundation/utils';
|
|
11
11
|
import '@fibrae/semi-foundation/components/select/select.css';
|
|
12
12
|
import { IconChevronDown, IconClear, IconSearch } from '@fibrae/semi-icons-svelte';
|
|
13
13
|
import { useDefaultProps, useFoundation } from '../../base/index.js';
|
|
14
|
-
import { useClickOutside } from '../../hooks/index.js';
|
|
15
14
|
import { VirtualList } from '../../internal/index.js';
|
|
16
15
|
import { splitControlAttrs, type SlotKind, trackSlotKind } from '../../utils/index.js';
|
|
17
16
|
import { useConfig } from '../config-provider/index.js';
|
|
@@ -23,7 +22,6 @@
|
|
|
23
22
|
import { Space } from '../space/index.js';
|
|
24
23
|
import { Spin } from '../spin/index.js';
|
|
25
24
|
import { Tag, type TagCloseEvent, TagGroup } from '../tag/index.js';
|
|
26
|
-
import { useNestedPopups } from '../tooltip/context.js';
|
|
27
25
|
import type { TooltipTriggerProps } from '../tooltip/index.js';
|
|
28
26
|
import { TypographyText } from '../typography/index.js';
|
|
29
27
|
import type { SelectCreateItemSnippetProps, SelectOptionGroup, SelectOptionItemSnippetProps, SelectOptionProps, SelectProps, SelectSelectedItemSnippetProps, SelectTriggerSnippetProps, SelectValue } from './interface.js';
|
|
@@ -70,8 +68,8 @@
|
|
|
70
68
|
// no global default: a global id would repeat on every instance
|
|
71
69
|
insetLabelId,
|
|
72
70
|
inputProps = defaults('inputProps'),
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
classNames = defaults('classNames'),
|
|
72
|
+
styles = defaults('styles'),
|
|
75
73
|
dropdownMatchSelectWidth = defaults('dropdownMatchSelectWidth', true),
|
|
76
74
|
position = defaults('position'),
|
|
77
75
|
spacing = defaults('spacing'),
|
|
@@ -128,8 +126,6 @@
|
|
|
128
126
|
let previous: OptionRecord[] | undefined;
|
|
129
127
|
const comboboxKeys = new Set(['aria-label', 'aria-labelledby', 'aria-describedby', 'aria-errormessage', 'aria-invalid', 'aria-required']);
|
|
130
128
|
|
|
131
|
-
const nestedPopups = useNestedPopups();
|
|
132
|
-
|
|
133
129
|
// an InputGroup supplies size and disabled when the control is given none; the controls inside this one must not read it again
|
|
134
130
|
const group = getInputGroupInScope();
|
|
135
131
|
const disabled = $derived(disabledProp ?? group?.disabled ?? defaults('disabled') ?? false);
|
|
@@ -261,7 +257,7 @@
|
|
|
261
257
|
...attrs.control,
|
|
262
258
|
role: 'combobox',
|
|
263
259
|
'aria-activedescendant': activeDescendant,
|
|
264
|
-
'aria-controls': listboxId,
|
|
260
|
+
'aria-controls': states().isOpen ? listboxId : undefined,
|
|
265
261
|
'aria-expanded': states().isOpen,
|
|
266
262
|
'aria-haspopup': 'listbox' as const,
|
|
267
263
|
...nameAttrs,
|
|
@@ -309,8 +305,8 @@
|
|
|
309
305
|
return `${group?.key ?? ''}:${rowKey(rows[0].option)}`;
|
|
310
306
|
};
|
|
311
307
|
|
|
312
|
-
const joinStyles = (...
|
|
313
|
-
return
|
|
308
|
+
const joinStyles = (...parts: (string | undefined)[]) => {
|
|
309
|
+
return parts.filter(Boolean).join('; ') || undefined;
|
|
314
310
|
};
|
|
315
311
|
|
|
316
312
|
const handleInputChange = (keyword: string, event?: Event) => {
|
|
@@ -419,8 +415,6 @@
|
|
|
419
415
|
// OverflowList shows the first overflowed item collapsed, so every other one is hidden; [] means all fit
|
|
420
416
|
const handleOverflow = (items: SelectOptionProps[]) => foundation.updateOverflowItemCount(Math.max(items.length - 1, 0));
|
|
421
417
|
|
|
422
|
-
useClickOutside([() => root, () => optionContainer], foundation.handleClickOutside, () => states().isOpen, nestedPopups);
|
|
423
|
-
|
|
424
418
|
// An option list change re-resolves the selection; the first run records the options the initial state read
|
|
425
419
|
$effect(() => {
|
|
426
420
|
const next = collectedOptions;
|
|
@@ -744,7 +738,7 @@
|
|
|
744
738
|
{/snippet}
|
|
745
739
|
|
|
746
740
|
{#snippet panel()}
|
|
747
|
-
<div bind:this={optionContainer} class={[{ [`${cls}-option-list-wrapper`]: !(visibleOptions.length === 0 && emptyHidden) },
|
|
741
|
+
<div bind:this={optionContainer} class={[{ [`${cls}-option-list-wrapper`]: !(visibleOptions.length === 0 && emptyHidden) }, classNames?.dropdown]} style={styles?.dropdown} onkeydown={foundation.handleContainerKeyDown} onmousedown={keepFocusOnPress}>
|
|
748
742
|
{#if outerTopSlot}
|
|
749
743
|
<div class={`${cls}-option-list-outer-top-slot`} onmouseenter={foundation.handleSlotMouseEnter}>
|
|
750
744
|
{@render outerTopSlot()}
|
|
@@ -841,6 +835,7 @@
|
|
|
841
835
|
content={panel}
|
|
842
836
|
disableArrowKeyDown
|
|
843
837
|
{motion}
|
|
838
|
+
onClickOutSide={foundation.handleClickOutside}
|
|
844
839
|
onEscKeyDown={foundation.handleEscKeyDown}
|
|
845
840
|
onOpen={foundation.scrollToSelection}
|
|
846
841
|
position={resolvedPosition}
|
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { ClassValue, HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { SideSheetPart } from '@fibrae/semi-foundation/components/side-sheet/constants';
|
|
3
4
|
import type { Placement } from '@fibrae/semi-foundation/components/side-sheet/side-sheet-foundation';
|
|
4
5
|
/**
|
|
5
6
|
* `aria-*` and `style` land on the `role="dialog"` element, `class` and the other attributes on the outer
|
|
6
7
|
* `.semi-sidesheet` element.
|
|
7
8
|
*/
|
|
8
9
|
export interface SideSheetProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'style' | 'title'> {
|
|
9
|
-
/** true once
|
|
10
|
+
/** true once the enter animation ends; false once hidden, after the leave animation, or on unmount while shown */
|
|
10
11
|
afterVisibleChange?: (isVisible: boolean) => void;
|
|
11
|
-
bodyStyle?: string;
|
|
12
12
|
/** Lets `width` apply to a top or bottom sheet, which otherwise spans the full width. */
|
|
13
13
|
canVerticalSetWidth?: boolean;
|
|
14
|
+
/** `content` is the role="dialog" element. Merged after the built-in class names of the part's element. */
|
|
15
|
+
classNames?: Partial<Record<SideSheetPart, ClassValue>>;
|
|
14
16
|
closable?: boolean;
|
|
15
17
|
closeOnEsc?: boolean;
|
|
16
18
|
disableScroll?: boolean;
|
|
17
19
|
getPopupContainer?: () => HTMLElement;
|
|
18
|
-
headerStyle?: string;
|
|
19
20
|
height?: number | string;
|
|
20
21
|
keepDOM?: boolean;
|
|
21
22
|
mask?: boolean;
|
|
22
23
|
maskClosable?: boolean;
|
|
23
|
-
maskStyle?: string;
|
|
24
24
|
motion?: boolean;
|
|
25
25
|
/** Close button, mask click and Escape (native KeyboardEvent); `visible` is written back to false first. */
|
|
26
26
|
onCancel?: (event: MouseEvent | KeyboardEvent) => void;
|
|
27
27
|
placement?: Placement;
|
|
28
28
|
size?: 'small' | 'medium' | 'large';
|
|
29
29
|
style?: string;
|
|
30
|
+
styles?: Partial<Record<SideSheetPart, string>>;
|
|
30
31
|
/** A string is the plain-text title, so `title="x"` does not become a native tooltip on the outer element. */
|
|
31
32
|
title?: Snippet | string;
|
|
32
33
|
visible?: boolean;
|