@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
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
import type { FlattenNode, TreeNodeData, TreeRowProps } from '../tree/interface.js';
|
|
26
26
|
import NodeList from '../tree/node-list.svelte';
|
|
27
27
|
import TreeNode from '../tree/tree-node.svelte';
|
|
28
|
-
import useTreeKeyboard from '../tree/use-tree-keyboard.svelte.js';
|
|
29
28
|
import type { TreeSelectChangeEvent, TreeSelectProps, TreeSelectSearchSnippetProps, TreeSelectSelectedItemSnippetProps, TreeSelectTriggerSnippetProps, TreeSelectValue } from './interface.js';
|
|
30
29
|
|
|
31
30
|
type FoundationEvent = MouseEvent | KeyboardEvent;
|
|
@@ -90,10 +89,9 @@
|
|
|
90
89
|
autoAdjustOverflow = defaults('autoAdjustOverflow', true),
|
|
91
90
|
position = defaults('position'),
|
|
92
91
|
stopPropagation = defaults('stopPropagation', true),
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
classNames = defaults('classNames'),
|
|
93
|
+
styles = defaults('styles'),
|
|
95
94
|
dropdownMatchSelectWidth = defaults('dropdownMatchSelectWidth', true),
|
|
96
|
-
optionListStyle = defaults('optionListStyle'),
|
|
97
95
|
preventScroll = defaults('preventScroll'),
|
|
98
96
|
triggerTagWrap = defaults('triggerTagWrap', false),
|
|
99
97
|
onChange,
|
|
@@ -294,12 +292,7 @@
|
|
|
294
292
|
onLoad?.(keys, node as TreeNodeData);
|
|
295
293
|
},
|
|
296
294
|
notifyClear: (event) => onClear?.(event as TreeSelectChangeEvent),
|
|
297
|
-
notifyVisibleChange: (visible) =>
|
|
298
|
-
if (!visible) {
|
|
299
|
-
keyboard.reset();
|
|
300
|
-
}
|
|
301
|
-
onVisibleChange?.(visible);
|
|
302
|
-
},
|
|
295
|
+
notifyVisibleChange: (visible) => onVisibleChange?.(visible),
|
|
303
296
|
notifyChange: (next, node, event) => {
|
|
304
297
|
echo('value', next);
|
|
305
298
|
value = next as TreeSelectValue;
|
|
@@ -329,38 +322,26 @@
|
|
|
329
322
|
}
|
|
330
323
|
},
|
|
331
324
|
isInTrigger: (node) => node instanceof Node && Boolean(root?.contains(node)),
|
|
332
|
-
|
|
325
|
+
revealRow: (index, key) => {
|
|
326
|
+
if (!nodeList?.scrollToItem(index)) {
|
|
327
|
+
// inside the dropdown, not the document: one in a ShadowRoot is out of document.getElementById's reach
|
|
328
|
+
content?.querySelector(`#${CSS.escape(nodeId(treeId, key))}`)?.scrollIntoView({ block: 'nearest' });
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
}),
|
|
332
|
+
{ context: () => ({ direction: config.direction }) }
|
|
333
333
|
);
|
|
334
334
|
|
|
335
335
|
// State implied by new props renders with them; the pre-effect writes it back for the handlers before render.
|
|
336
336
|
// Not named `derived`: a local of that name turns the `$derived` rune into a store subscription
|
|
337
337
|
const implied = $derived(TreeSelectFoundation.deriveState(foundationProps, states()));
|
|
338
338
|
const view = $derived<BasicTreeSelectInnerData>(implied ? { ...states(), ...implied } : states());
|
|
339
|
-
|
|
340
|
-
const reveal = (index: number, key: string) => {
|
|
341
|
-
if (!nodeList?.scrollToItem(index)) {
|
|
342
|
-
// inside the dropdown, not the document: one in a ShadowRoot is out of document.getElementById's reach
|
|
343
|
-
content?.querySelector(`#${CSS.escape(nodeId(treeId, key))}`)?.scrollIntoView({ block: 'nearest' });
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
const keyboard = useTreeKeyboard({
|
|
348
|
-
rows: () => view.flattenNodes as FlattenNode[],
|
|
349
|
-
// an APG combobox opens without an active option
|
|
350
|
-
defaultIndex: () => -1,
|
|
351
|
-
rowProps: (node) => rowProps(node),
|
|
352
|
-
hasLoadData: () => Boolean(loadData),
|
|
353
|
-
rtl: () => config.direction === 'rtl',
|
|
354
|
-
editing: (event) => isTextEditor(event.target),
|
|
355
|
-
select: foundation.handleNodeSelect,
|
|
356
|
-
expand: foundation.handleNodeExpand,
|
|
357
|
-
reveal,
|
|
358
|
-
});
|
|
359
|
-
|
|
360
339
|
const selectionKeys = $derived(TreeSelectFoundation.getTriggerKeys(foundationProps, view));
|
|
361
340
|
const hasValue = $derived(TreeSelectFoundation.hasValue(foundationProps, view));
|
|
362
341
|
const clearable = $derived(TreeSelectFoundation.isClearable(foundationProps, view));
|
|
363
|
-
const
|
|
342
|
+
const activeIndex = $derived(TreeSelectFoundation.getActiveIndex(view));
|
|
343
|
+
const activeKey = $derived(view.flattenNodes[activeIndex]?.key);
|
|
344
|
+
const activeDescendant = $derived(activeKey === undefined ? undefined : nodeId(treeId, activeKey));
|
|
364
345
|
|
|
365
346
|
const comboboxAttrs = $derived({
|
|
366
347
|
...attrs.control,
|
|
@@ -434,18 +415,9 @@
|
|
|
434
415
|
},
|
|
435
416
|
dragOverNodeKey: null,
|
|
436
417
|
dropPosition: null,
|
|
437
|
-
onNodeExpand:
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
},
|
|
441
|
-
onNodeSelect: (event, row) => {
|
|
442
|
-
keyboard.activate(row.key);
|
|
443
|
-
foundation.handleNodeSelect(event, row);
|
|
444
|
-
},
|
|
445
|
-
onNodeCheck: (event, row) => {
|
|
446
|
-
keyboard.activate(row.key);
|
|
447
|
-
foundation.handleNodeSelect(event, row);
|
|
448
|
-
},
|
|
418
|
+
onNodeExpand: foundation.handleNodeExpand,
|
|
419
|
+
onNodeSelect: foundation.handleNodeSelect,
|
|
420
|
+
onNodeCheck: foundation.handleNodeSelect,
|
|
449
421
|
});
|
|
450
422
|
|
|
451
423
|
const getNodeData = (key: string) => getTreeNodeData(key, view.keyEntities, foundationProps) as TreeNodeData | undefined;
|
|
@@ -527,20 +499,16 @@
|
|
|
527
499
|
}
|
|
528
500
|
};
|
|
529
501
|
|
|
530
|
-
const handleTreeKeyDown = (event: KeyboardEvent) => view.isOpen && keyboard.handleKeyDown(event);
|
|
531
|
-
|
|
532
502
|
const handleKeyDown = (event: KeyboardEvent & { currentTarget: EventTarget & HTMLDivElement }) => {
|
|
533
503
|
rest.onkeydown?.(event);
|
|
534
|
-
if (!isInnerControlKey(event) && !
|
|
535
|
-
|
|
536
|
-
keyboard.handleKeyDown(event);
|
|
537
|
-
}
|
|
504
|
+
if (!isInnerControlKey(event) && !foundation.handleRowKeyDown(event)) {
|
|
505
|
+
foundation.handleSelectionKeyDown(event);
|
|
538
506
|
}
|
|
539
507
|
foundation.handleKeyDown(event);
|
|
540
508
|
};
|
|
541
509
|
|
|
542
510
|
const handleContentKeyDown = (event: KeyboardEvent) => {
|
|
543
|
-
|
|
511
|
+
foundation.handleRowKeyDown(event);
|
|
544
512
|
foundation.handleKeyDown(event);
|
|
545
513
|
};
|
|
546
514
|
|
|
@@ -587,14 +555,6 @@
|
|
|
587
555
|
}
|
|
588
556
|
};
|
|
589
557
|
|
|
590
|
-
// a key that opens the popup sets the row before the list mounts, so opening scrolls to it again
|
|
591
|
-
const handleOpen = () => {
|
|
592
|
-
foundation.handlePopoverOpen();
|
|
593
|
-
if (keyboard.activeKey !== undefined) {
|
|
594
|
-
reveal(keyboard.activeIndex, keyboard.activeKey);
|
|
595
|
-
}
|
|
596
|
-
};
|
|
597
|
-
|
|
598
558
|
$effect.pre(() => {
|
|
599
559
|
if (implied) {
|
|
600
560
|
foundation.syncDerivedState(implied);
|
|
@@ -626,8 +586,8 @@
|
|
|
626
586
|
}
|
|
627
587
|
});
|
|
628
588
|
|
|
629
|
-
// blur comes from a click outside, so it is listened to while focused
|
|
630
|
-
useClickOutside([() => root, () => content], foundation.handleClickOutside, () => view.
|
|
589
|
+
// blur comes from a click outside, so it is listened to while focused; while open the Popover reports it
|
|
590
|
+
useClickOutside([() => root, () => content], foundation.handleClickOutside, () => view.isFocus && !view.isOpen, nestedPopups);
|
|
631
591
|
|
|
632
592
|
/** Searches as if `value` were typed, opening the dropdown first; needs `filterTreeNode` */
|
|
633
593
|
export function search(input: string) {
|
|
@@ -847,7 +807,7 @@
|
|
|
847
807
|
{/snippet}
|
|
848
808
|
|
|
849
809
|
{#snippet panel()}
|
|
850
|
-
<div bind:this={content} class={[
|
|
810
|
+
<div bind:this={content} class={[`${cls}-popover`, classNames?.dropdown]} style={styles?.dropdown} onfocusin={foundation.handleTriggerFocus} onfocusout={handleFocusOut} onkeydown={handleContentKeyDown} onmousedown={keepFocusOnPress}>
|
|
851
811
|
<div class={`${treeCls}-wrapper`}>
|
|
852
812
|
{#if outerTopSlot}
|
|
853
813
|
{@render outerTopSlot()}
|
|
@@ -858,7 +818,7 @@
|
|
|
858
818
|
{/if}
|
|
859
819
|
{#if noData}
|
|
860
820
|
<!-- the combobox's aria-controls needs an element while there is no tree -->
|
|
861
|
-
<div class={listClass} id={treeId} role="none" style={
|
|
821
|
+
<div class={[listClass, classNames?.optionList]} id={treeId} role="none" style={styles?.optionList}>
|
|
862
822
|
{#if !emptyHidden}
|
|
863
823
|
<ul class={[`${treeCls}-option`, `${treeCls}-option-empty`]}>
|
|
864
824
|
<li class={[`${treeCls}-option-label`, `${treeCls}-option-label-empty`]} x-semi-prop="emptyContent">
|
|
@@ -872,12 +832,12 @@
|
|
|
872
832
|
{/if}
|
|
873
833
|
</div>
|
|
874
834
|
{:else}
|
|
875
|
-
<ul id={treeId} {...nameAttrs} aria-multiselectable={multiple} class={listClass} role="tree" style={
|
|
835
|
+
<ul id={treeId} {...nameAttrs} aria-multiselectable={multiple} class={[listClass, classNames?.optionList]} role="tree" style={styles?.optionList}>
|
|
876
836
|
<NodeList bind:this={nodeList} flattenList={view.cachedFlattenNodes as FlattenNode[] | undefined} flattenNodes={view.flattenNodes as FlattenNode[]} motion={motionExpand} motionKeys={view.motionKeys} motionType={view.motionType} {searchTargetIsDeep} {virtualize}>
|
|
877
837
|
{#snippet children({ node, style })}
|
|
878
838
|
{@const row = rowProps(node)}
|
|
879
839
|
{#if row}
|
|
880
|
-
<TreeNode {expandIcon} focused={row.key ===
|
|
840
|
+
<TreeNode {expandIcon} focused={row.key === activeKey} {fullLabel} {icon} id={nodeId(treeId, row.key)} {label} {row} rowStyle={style} {showLine} />
|
|
881
841
|
{/if}
|
|
882
842
|
{/snippet}
|
|
883
843
|
</NodeList>
|
|
@@ -898,8 +858,9 @@
|
|
|
898
858
|
content={panel}
|
|
899
859
|
disableArrowKeyDown
|
|
900
860
|
{motion}
|
|
861
|
+
onClickOutSide={foundation.handleClickOutside}
|
|
901
862
|
onEscKeyDown={foundation.close}
|
|
902
|
-
onOpen={
|
|
863
|
+
onOpen={foundation.handlePopoverOpen}
|
|
903
864
|
position={position ?? (config.direction === 'rtl' ? 'bottomRight' : 'bottomLeft')}
|
|
904
865
|
role="presentation"
|
|
905
866
|
{stopPropagation}
|
|
@@ -331,7 +331,7 @@
|
|
|
331
331
|
{#snippet decorate(index: number, description: string | undefined)}
|
|
332
332
|
{#if index < decorations.length}
|
|
333
333
|
{@const tag = decorations[index]}
|
|
334
|
-
<svelte:element this={tag.tag} aria-describedby={tag.tag === 'a' ? description : undefined}
|
|
334
|
+
<svelte:element this={tag.tag} {...tag.attrs} aria-describedby={tag.attrs['aria-describedby'] ?? (tag.tag === 'a' ? description : undefined)}>{@render decorate(index + 1, description)}</svelte:element>
|
|
335
335
|
{:else}
|
|
336
336
|
<!-- Adjacent blocks share a line: whitespace between them would become a visible space inside the text -->
|
|
337
337
|
{#if icon}<span {@attach sizeIcons} bind:this={iconBox} class={`${prefix}-icon`} x-semi-prop="icon">{@render icon()}</span>{/if}{#if linkClass}<span class={linkClass}>{@render body()}</span>{:else}{@render body()}{/if}
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
{@render fileValidateMessage(slotProps())}
|
|
176
176
|
{:else if typeof message === 'string'}
|
|
177
177
|
{#if file.status === strings.FILE_STATUS_VALIDATING}
|
|
178
|
-
<Spin
|
|
178
|
+
<Spin class={`${prefix}-file-card-icon-loading`} size="small" />
|
|
179
179
|
{:else}
|
|
180
180
|
<IconAlertCircle class={`${prefix}-file-card-icon-error`} />
|
|
181
181
|
{/if}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import type { strings } from '@fibrae/semi-foundation/components/upload/constants';
|
|
2
|
+
import type { ClassValue, HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { strings, UploadPart } from '@fibrae/semi-foundation/components/upload/constants';
|
|
4
4
|
import type { AfterUploadResult as FoundationAfterUploadResult, BaseFileItem, BeforeUploadObjectResult as FoundationBeforeUploadObjectResult, CustomFile } from '@fibrae/semi-foundation/components/upload/foundation';
|
|
5
5
|
import type { ArrayElement } from '@fibrae/semi-foundation/utils';
|
|
6
6
|
import type { ValidateStatus } from '../input/interface.js';
|
|
@@ -84,6 +84,7 @@ export interface UploadFileItemSlotProps {
|
|
|
84
84
|
picWidth?: string | number;
|
|
85
85
|
picHeight?: string | number;
|
|
86
86
|
validateMessage?: string;
|
|
87
|
+
class?: ClassValue;
|
|
87
88
|
style?: string;
|
|
88
89
|
onRemove: () => void;
|
|
89
90
|
onRetry: () => void;
|
|
@@ -134,6 +135,7 @@ export interface UploadProps extends Omit<HTMLAttributes<HTMLDivElement>, 'oncha
|
|
|
134
135
|
beforeRemove?: (file: FileItem, fileList: FileItem[]) => boolean | Promise<boolean>;
|
|
135
136
|
beforeUpload?: (object: BeforeUploadProps) => BeforeUploadObjectResult | Promise<BeforeUploadObjectResult> | boolean;
|
|
136
137
|
capture?: boolean | 'user' | 'environment';
|
|
138
|
+
classNames?: Partial<Record<UploadPart, ClassValue>>;
|
|
137
139
|
/** `true` crops with the defaults; an object configures the cropper */
|
|
138
140
|
crop?: boolean | UploadCropProps;
|
|
139
141
|
cropModalProps?: UploadCropModalProps;
|
|
@@ -149,7 +151,6 @@ export interface UploadProps extends Omit<HTMLAttributes<HTMLDivElement>, 'oncha
|
|
|
149
151
|
headers?: Record<string, any> | ((file: File) => Record<string, string>);
|
|
150
152
|
/** Where the picture wall's add button sits */
|
|
151
153
|
hotSpotLocation?: 'start' | 'end';
|
|
152
|
-
itemStyle?: string;
|
|
153
154
|
limit?: number;
|
|
154
155
|
listType?: UploadListType;
|
|
155
156
|
/** KB */
|
|
@@ -168,6 +169,7 @@ export interface UploadProps extends Omit<HTMLAttributes<HTMLDivElement>, 'oncha
|
|
|
168
169
|
/** Tooltip of a truncated file name; its custom popup is the `ellipsisTooltip` snippet */
|
|
169
170
|
showTooltip?: boolean | ShowTooltip;
|
|
170
171
|
showUploadList?: boolean;
|
|
172
|
+
styles?: Partial<Record<UploadPart, string>>;
|
|
171
173
|
transformFile?: (file: File) => File;
|
|
172
174
|
uploadTrigger?: 'auto' | 'custom';
|
|
173
175
|
validateStatus?: ValidateStatus;
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
beforeRemove = defaults('beforeRemove'),
|
|
37
37
|
beforeUpload = defaults('beforeUpload'),
|
|
38
38
|
capture = defaults('capture'),
|
|
39
|
+
classNames = defaults('classNames'),
|
|
39
40
|
crop = defaults('crop', false),
|
|
40
41
|
cropModalProps = defaults('cropModalProps'),
|
|
41
42
|
customRequest = defaults('customRequest'),
|
|
@@ -46,7 +47,6 @@
|
|
|
46
47
|
fileName = defaults('fileName'),
|
|
47
48
|
headers = defaults('headers'),
|
|
48
49
|
hotSpotLocation = defaults('hotSpotLocation', 'end'),
|
|
49
|
-
itemStyle = defaults('itemStyle'),
|
|
50
50
|
limit = defaults('limit'),
|
|
51
51
|
listType = defaults('listType', 'list'),
|
|
52
52
|
maxSize = defaults('maxSize'),
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
showRetry = defaults('showRetry', true),
|
|
64
64
|
showTooltip = defaults('showTooltip', true),
|
|
65
65
|
showUploadList = defaults('showUploadList', true),
|
|
66
|
+
styles = defaults('styles'),
|
|
66
67
|
transformFile = defaults('transformFile'),
|
|
67
68
|
uploadTrigger = defaults('uploadTrigger', 'auto'),
|
|
68
69
|
validateStatus = defaults('validateStatus'),
|
|
@@ -240,7 +241,7 @@
|
|
|
240
241
|
|
|
241
242
|
// `capture` works by presence, and Svelte writes `false` on a non-boolean attribute as the string "false"
|
|
242
243
|
const captureAttr = $derived((capture === true ? '' : capture || undefined) as 'user' | 'environment' | undefined);
|
|
243
|
-
const cropModalRest = $derived(omit(cropModalProps ?? {}, ['style', '
|
|
244
|
+
const cropModalRest = $derived(omit(cropModalProps ?? {}, ['style', 'styles', 'width']));
|
|
244
245
|
const pictureAddStyle = $derived([picHeight !== undefined && `height: ${toCssLength(picHeight)}`, picWidth !== undefined && `width: ${toCssLength(picWidth)}`].filter(Boolean).join(';') || undefined);
|
|
245
246
|
|
|
246
247
|
const dragListeners = {
|
|
@@ -283,7 +284,8 @@
|
|
|
283
284
|
picWidth,
|
|
284
285
|
picHeight,
|
|
285
286
|
validateMessage: UploadFoundation.getFallbackValidateMessage(file, locale().locale),
|
|
286
|
-
|
|
287
|
+
class: classNames?.item,
|
|
288
|
+
style: styles?.item,
|
|
287
289
|
onRemove: () => foundation.handleRemove(file),
|
|
288
290
|
onRetry: () => foundation.retry(file),
|
|
289
291
|
onReplace: () => foundation.startReplace(file.uid),
|
|
@@ -482,12 +484,12 @@
|
|
|
482
484
|
{/if}
|
|
483
485
|
<Modal
|
|
484
486
|
{...cropModalRest}
|
|
485
|
-
bodyStyle={['height: 400px', cropModalProps?.bodyStyle].filter(Boolean).join(';')}
|
|
486
487
|
cancelText={cropConfig.modalCancelText}
|
|
487
488
|
okText={cropConfig.modalOkText}
|
|
488
489
|
onCancel={foundation.cancelCrop}
|
|
489
490
|
onOk={foundation.confirmCrop}
|
|
490
491
|
style={['height: 500px', cropModalProps?.style].filter(Boolean).join(';')}
|
|
492
|
+
styles={{ ...cropModalProps?.styles, body: ['height: 400px', cropModalProps?.styles?.body].filter(Boolean).join(';') }}
|
|
491
493
|
title={cropConfig.modalTitle || locale().locale.cropTitle}
|
|
492
494
|
visible={states().cropperVisible}
|
|
493
495
|
width={cropModalProps?.width ?? 600}
|
|
@@ -164,7 +164,21 @@
|
|
|
164
164
|
{@const item = step}
|
|
165
165
|
{@const args = { item, index: currentIndex }}
|
|
166
166
|
{#if mode === 'modal'}
|
|
167
|
-
<Modal
|
|
167
|
+
<Modal
|
|
168
|
+
aria-labelledby={hasTitle ? titleId : undefined}
|
|
169
|
+
bind:visible={() => true, () => {}}
|
|
170
|
+
centered
|
|
171
|
+
class={[modalPrefix, className, item.class]}
|
|
172
|
+
footer={null}
|
|
173
|
+
{getPopupContainer}
|
|
174
|
+
header={null}
|
|
175
|
+
mask={showMask}
|
|
176
|
+
maskClosable={false}
|
|
177
|
+
onCancel={foundation.handleSkip}
|
|
178
|
+
{style}
|
|
179
|
+
styles={{ body: 'padding: 0' }}
|
|
180
|
+
{zIndex}
|
|
181
|
+
>
|
|
168
182
|
{#if item.cover}
|
|
169
183
|
<div class={`${modalPrefix}-cover`} x-semi-prop="cover">{@render item.cover(args)}</div>
|
|
170
184
|
<div aria-hidden="true" class={`${modalPrefix}-indicator`}>
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export { default as useClickOutside } from './use-click-outside.svelte.js';
|
|
|
3
3
|
export { default as useCopied } from './use-copied.svelte.js';
|
|
4
4
|
export { default as useNoticeClose } from './use-notice-close.js';
|
|
5
5
|
export * from './use-notice-close.js';
|
|
6
|
+
export { default as useOverlayResources } from './use-overlay-resources.svelte.js';
|
|
6
7
|
export { default as useStoreSnapshot } from './use-store-snapshot.svelte.js';
|
|
7
8
|
export { default as watch } from './watch.svelte.js';
|
package/dist/hooks/index.js
CHANGED
|
@@ -4,5 +4,6 @@ export { default as useClickOutside } from './use-click-outside.svelte.js';
|
|
|
4
4
|
export { default as useCopied } from './use-copied.svelte.js';
|
|
5
5
|
export { default as useNoticeClose } from './use-notice-close.js';
|
|
6
6
|
export * from './use-notice-close.js';
|
|
7
|
+
export { default as useOverlayResources } from './use-overlay-resources.svelte.js';
|
|
7
8
|
export { default as useStoreSnapshot } from './use-store-snapshot.svelte.js';
|
|
8
9
|
export { default as watch } from './watch.svelte.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface OverlayFoundation {
|
|
2
|
+
recordFocus: () => void;
|
|
3
|
+
beforeShow: () => void;
|
|
4
|
+
afterHide: () => void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Holds the page resources of a Modal-family overlay (its foundation's ModalResources): records the opener when
|
|
8
|
+
* `visible` turns true, before the DOM updates and anything inside takes focus in its mount effects; takes the layer,
|
|
9
|
+
* scroll lock and focus while `shown`, and releases them when `shown` turns false or the component is destroyed.
|
|
10
|
+
* `shown` is the host's own gate for a dialog that is in the document and displayed.
|
|
11
|
+
*/
|
|
12
|
+
export default function useOverlayResources(foundation: OverlayFoundation, visible: () => boolean | undefined, shown: () => boolean): void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { untrack } from 'svelte';
|
|
2
|
+
/**
|
|
3
|
+
* Holds the page resources of a Modal-family overlay (its foundation's ModalResources): records the opener when
|
|
4
|
+
* `visible` turns true, before the DOM updates and anything inside takes focus in its mount effects; takes the layer,
|
|
5
|
+
* scroll lock and focus while `shown`, and releases them when `shown` turns false or the component is destroyed.
|
|
6
|
+
* `shown` is the host's own gate for a dialog that is in the document and displayed.
|
|
7
|
+
*/
|
|
8
|
+
export default function useOverlayResources(foundation, visible, shown) {
|
|
9
|
+
$effect.pre(() => {
|
|
10
|
+
if (visible()) {
|
|
11
|
+
untrack(foundation.recordFocus);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
$effect(() => {
|
|
15
|
+
if (!shown())
|
|
16
|
+
return;
|
|
17
|
+
untrack(foundation.beforeShow);
|
|
18
|
+
return foundation.afterHide;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -18,12 +18,19 @@
|
|
|
18
18
|
/** Key of a row; the index when absent */
|
|
19
19
|
itemKey?: (index: number) => PropertyKey;
|
|
20
20
|
overscan?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Height of content rendered in `before`, such as a sticky header: rows start this far down, and a row scrolled
|
|
23
|
+
* to the start lands below it
|
|
24
|
+
*/
|
|
25
|
+
scrollMargin?: number;
|
|
21
26
|
/** Attributes of the element that holds the rows */
|
|
22
27
|
innerAttrs?: HTMLAttributes<HTMLElement>;
|
|
23
28
|
/** Tag of the element that holds the rows; `ul` when the rows are `li` */
|
|
24
29
|
innerTag?: 'div' | 'ul';
|
|
25
30
|
/** Attributes of a div between the scroll container and the row holder, for styles that select the row holder as its direct child */
|
|
26
31
|
wrapperAttrs?: HTMLAttributes<HTMLDivElement>;
|
|
32
|
+
/** Rendered inside the scroll container before the rows */
|
|
33
|
+
before?: Snippet;
|
|
27
34
|
/** Rendered inside the scroll container after the rows, such as an empty placeholder */
|
|
28
35
|
after?: Snippet;
|
|
29
36
|
/** Renders one row; `style` positions it and goes on the row's element */
|
|
@@ -34,7 +41,7 @@
|
|
|
34
41
|
* Attributes land on the scroll container; lists whose rows take no focus pass `tabindex={-1}` so Chrome does not
|
|
35
42
|
* make the container a second tab stop.
|
|
36
43
|
*/
|
|
37
|
-
let { height, width = '100%', itemCount, itemSize, itemKey, overscan = 2, innerAttrs, innerTag = 'div', wrapperAttrs, after, children, ...rest }: VirtualListProps = $props();
|
|
44
|
+
let { height, width = '100%', itemCount, itemSize, itemKey, overscan = 2, scrollMargin = 0, innerAttrs, innerTag = 'div', wrapperAttrs, before, after, children, ...rest }: VirtualListProps = $props();
|
|
38
45
|
|
|
39
46
|
let scroller = $state<HTMLDivElement>();
|
|
40
47
|
let reportRect: ((rect: Rect) => void) | null = null;
|
|
@@ -44,6 +51,8 @@
|
|
|
44
51
|
getScrollElement: () => scroller ?? null,
|
|
45
52
|
estimateSize: (index: number) => (typeof itemSize === 'number' ? itemSize : itemSize(index)),
|
|
46
53
|
overscan,
|
|
54
|
+
scrollMargin,
|
|
55
|
+
scrollPaddingStart: scrollMargin,
|
|
47
56
|
// The viewport size is the height prop: measuring would read 0 in jsdom and needs a ResizeObserver to follow a
|
|
48
57
|
// prop change
|
|
49
58
|
initialRect: { width: 0, height },
|
|
@@ -97,6 +106,7 @@
|
|
|
97
106
|
</script>
|
|
98
107
|
|
|
99
108
|
<div bind:this={scroller} {...rest} style="position: relative; height: {toCssLength(height)}; width: {toCssLength(width)}; overflow: auto;{rest.style ?? ''}">
|
|
109
|
+
{@render before?.()}
|
|
100
110
|
{#snippet rows()}
|
|
101
111
|
<svelte:element this={innerTag} {...innerAttrs} style="height: {$virtualizer.getTotalSize()}px; width: 100%">
|
|
102
112
|
{#each $virtualizer.getVirtualItems() as item (itemKey ? itemKey(item.index) : item.index)}
|
|
@@ -11,12 +11,19 @@ interface VirtualListProps extends Omit<HTMLAttributes<HTMLDivElement>, 'childre
|
|
|
11
11
|
/** Key of a row; the index when absent */
|
|
12
12
|
itemKey?: (index: number) => PropertyKey;
|
|
13
13
|
overscan?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Height of content rendered in `before`, such as a sticky header: rows start this far down, and a row scrolled
|
|
16
|
+
* to the start lands below it
|
|
17
|
+
*/
|
|
18
|
+
scrollMargin?: number;
|
|
14
19
|
/** Attributes of the element that holds the rows */
|
|
15
20
|
innerAttrs?: HTMLAttributes<HTMLElement>;
|
|
16
21
|
/** Tag of the element that holds the rows; `ul` when the rows are `li` */
|
|
17
22
|
innerTag?: 'div' | 'ul';
|
|
18
23
|
/** Attributes of a div between the scroll container and the row holder, for styles that select the row holder as its direct child */
|
|
19
24
|
wrapperAttrs?: HTMLAttributes<HTMLDivElement>;
|
|
25
|
+
/** Rendered inside the scroll container before the rows */
|
|
26
|
+
before?: Snippet;
|
|
20
27
|
/** Rendered inside the scroll container after the rows, such as an empty placeholder */
|
|
21
28
|
after?: Snippet;
|
|
22
29
|
/** Renders one row; `style` positions it and goes on the row's element */
|