@fibrae/semi-ui-svelte 0.7.0 → 0.9.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/cascader/cascader.svelte +5 -5
- package/dist/components/color-picker/data-part.svelte +1 -1
- package/dist/components/date-picker/date-input.svelte +1 -1
- package/dist/components/form/error-message.svelte +1 -1
- 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/input-group.svelte +2 -2
- 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/form/slot.svelte +1 -1
- package/dist/components/input/input.svelte +9 -9
- package/dist/components/input/textarea.svelte +2 -2
- package/dist/components/modal/confirm-modal.svelte +2 -2
- package/dist/components/radio/radio.svelte +3 -3
- package/dist/components/scroll-list/scroll-item.svelte +1 -1
- package/dist/components/select/interface.d.ts +5 -5
- package/dist/components/select/select.svelte +4 -4
- package/dist/components/spin/icon.svelte +1 -1
- package/dist/components/table/body/body.svelte +23 -10
- package/dist/components/table/table-cell.svelte +1 -1
- package/dist/components/table/table-header/head-table.svelte +2 -2
- package/dist/components/table/table-header/table-header-row.svelte +16 -5
- package/dist/components/table/table.svelte +32 -6
- package/dist/components/tag-input/tag-input.svelte +3 -3
- package/dist/components/tree-select/tree-select.svelte +3 -3
- 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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import { controlProps, schemaFieldWarnings, singleItemName, type SchemaFieldKind, type SchemaFieldNode } from '@fibrae/semi-foundation/components/form/json-schema';
|
|
4
|
+
import { formatLocale } from '@fibrae/semi-foundation/locale';
|
|
5
|
+
import { warning } from '@fibrae/semi-foundation/utils';
|
|
6
|
+
import useLocale from '../../locale/use-locale.svelte.js';
|
|
7
|
+
import FormInputNumber from '../fields/form-input-number.svelte';
|
|
8
|
+
import FormInput from '../fields/form-input.svelte';
|
|
9
|
+
import FormSelect from '../fields/form-select.svelte';
|
|
10
|
+
import FormSwitch from '../fields/form-switch.svelte';
|
|
11
|
+
import FormTextArea from '../fields/form-text-area.svelte';
|
|
12
|
+
|
|
13
|
+
let { node }: { node: SchemaFieldNode } = $props();
|
|
14
|
+
|
|
15
|
+
const locale = useLocale('Form');
|
|
16
|
+
|
|
17
|
+
const controls: Partial<Record<SchemaFieldKind, Component<any, any, any>>> = { input: FormInput, textarea: FormTextArea, number: FormInputNumber, switch: FormSwitch, select: FormSelect };
|
|
18
|
+
const Control = $derived(controls[node.kind]);
|
|
19
|
+
const itemName = $derived(singleItemName(node, locale().locale));
|
|
20
|
+
|
|
21
|
+
// Svelte's Input names the native attribute `maxlength`
|
|
22
|
+
const controlAttrs = $derived.by(() => {
|
|
23
|
+
const { maxLength, ...rest } = controlProps(node);
|
|
24
|
+
return node.kind === 'input' ? { ...rest, maxlength: maxLength } : rest;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const label = $derived({ text: node.title ?? formatLocale(locale().locale.item, { index: (node.item?.index ?? 0) + 1 }), required: node.required });
|
|
28
|
+
|
|
29
|
+
$effect(() => {
|
|
30
|
+
warning(!Control, schemaFieldWarnings.unsupported(node.field));
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
{#snippet description()}{node.description}{/snippet}
|
|
35
|
+
|
|
36
|
+
{#if Control}
|
|
37
|
+
{#if itemName === undefined}
|
|
38
|
+
<Control {...controlAttrs} extraText={node.description ? description : undefined} field={node.field} initValue={node.default} {label} />
|
|
39
|
+
{:else}
|
|
40
|
+
<Control {...controlAttrs} aria-label={itemName} field={node.field} initValue={node.default} noLabel />
|
|
41
|
+
{/if}
|
|
42
|
+
{/if}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
import { type SchemaFieldNode } from '@fibrae/semi-foundation/components/form/json-schema';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
node: SchemaFieldNode;
|
|
5
|
+
};
|
|
6
|
+
declare const SemiField: Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type SemiField = ReturnType<typeof SemiField>;
|
|
8
|
+
export default SemiField;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { SchemaArrayContext, SchemaFieldRenderers, SchemaLeafContext, SchemaObjectContext } from '../interface.js';
|
|
3
|
+
import SemiArray from './semi-array.svelte';
|
|
4
|
+
import SemiField from './semi-field.svelte';
|
|
5
|
+
import SemiSection from './semi-section.svelte';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Renders SchemaField with Semi Form controls: objects and arrays as Sections, array rows with move and remove buttons,
|
|
9
|
+
* single-value rows without a label. Spread it to replace one kind: `{ ...semiRenderers, array: myArray }`.
|
|
10
|
+
*/
|
|
11
|
+
export const semiRenderers: Required<SchemaFieldRenderers> = { object, array, field };
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
{#snippet object(context: SchemaObjectContext)}
|
|
15
|
+
<SemiSection node={context.node}>{@render context.content()}</SemiSection>
|
|
16
|
+
{/snippet}
|
|
17
|
+
|
|
18
|
+
{#snippet array(context: SchemaArrayContext)}
|
|
19
|
+
<SemiArray {context} />
|
|
20
|
+
{/snippet}
|
|
21
|
+
|
|
22
|
+
{#snippet field(context: SchemaLeafContext)}
|
|
23
|
+
<SemiField node={context.node} />
|
|
24
|
+
{/snippet}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SchemaFieldRenderers } from '../interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* Renders SchemaField with Semi Form controls: objects and arrays as Sections, array rows with move and remove buttons,
|
|
4
|
+
* single-value rows without a label. Spread it to replace one kind: `{ ...semiRenderers, array: myArray }`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const semiRenderers: Required<SchemaFieldRenderers>;
|
|
7
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
8
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
9
|
+
$$bindings?: Bindings;
|
|
10
|
+
} & Exports;
|
|
11
|
+
(internal: unknown, props: {
|
|
12
|
+
$$events?: Events;
|
|
13
|
+
$$slots?: Slots;
|
|
14
|
+
}): Exports & {
|
|
15
|
+
$set?: any;
|
|
16
|
+
$on?: any;
|
|
17
|
+
};
|
|
18
|
+
z_$$bindings?: Bindings;
|
|
19
|
+
}
|
|
20
|
+
declare const SemiRenderers: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
21
|
+
[evt: string]: CustomEvent<any>;
|
|
22
|
+
}, {}, {}, string>;
|
|
23
|
+
type SemiRenderers = InstanceType<typeof SemiRenderers>;
|
|
24
|
+
export default SemiRenderers;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { SchemaFieldNode } from '@fibrae/semi-foundation/components/form/json-schema';
|
|
4
|
+
import { formatLocale } from '@fibrae/semi-foundation/locale';
|
|
5
|
+
import useLocale from '../../locale/use-locale.svelte.js';
|
|
6
|
+
import FormSection from '../section.svelte';
|
|
7
|
+
|
|
8
|
+
let { node, children, ...rest }: { node: SchemaFieldNode; children: Snippet; 'x-field-id'?: string } = $props();
|
|
9
|
+
|
|
10
|
+
const locale = useLocale('Form');
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
{#snippet text()}{node.title ?? formatLocale(locale().locale.item, { index: (node.item?.index ?? 0) + 1 })}{/snippet}
|
|
14
|
+
|
|
15
|
+
{#snippet extraText()}{node.description}{/snippet}
|
|
16
|
+
|
|
17
|
+
<!-- The root renders no Section: the Form already is its group -->
|
|
18
|
+
{#if node.field === ''}
|
|
19
|
+
{@render children()}
|
|
20
|
+
{:else}
|
|
21
|
+
<FormSection {...rest} extraText={node.description ? extraText : undefined} {text}>{@render children()}</FormSection>
|
|
22
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { SchemaFieldNode } from '@fibrae/semi-foundation/components/form/json-schema';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
node: SchemaFieldNode;
|
|
5
|
+
children: Snippet;
|
|
6
|
+
'x-field-id'?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const SemiSection: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
|
+
type SemiSection = ReturnType<typeof SemiSection>;
|
|
10
|
+
export default SemiSection;
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { cssClasses } from '@fibrae/semi-foundation/components/form/constants';
|
|
3
|
+
import { joinIds } from '@fibrae/semi-foundation/utils';
|
|
3
4
|
import '@fibrae/semi-foundation/components/form/form.css';
|
|
4
5
|
import type { SectionProps } from './interface.js';
|
|
5
6
|
|
|
6
|
-
let { text, children, ...rest }: SectionProps = $props();
|
|
7
|
+
let { text, extraText, children, ...rest }: SectionProps = $props();
|
|
8
|
+
|
|
9
|
+
const extraId = $props.id();
|
|
7
10
|
</script>
|
|
8
11
|
|
|
9
|
-
<fieldset {...rest} class={[`${cssClasses.PREFIX}-section`, rest.class]}>
|
|
12
|
+
<fieldset {...rest} aria-describedby={joinIds(rest['aria-describedby'], extraText && extraId)} class={[`${cssClasses.PREFIX}-section`, rest.class]}>
|
|
10
13
|
<!-- an empty legend would still draw its divider -->
|
|
11
14
|
{#if text}
|
|
12
15
|
<legend class={`${cssClasses.PREFIX}-section-text`}>{@render text()}</legend>
|
|
13
16
|
{/if}
|
|
17
|
+
{#if extraText}
|
|
18
|
+
<div class={`${cssClasses.PREFIX}-section-extra`} id={extraId}>{@render extraText()}</div>
|
|
19
|
+
{/if}
|
|
14
20
|
{@render children?.()}
|
|
15
21
|
</fieldset>
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
// a rendered label names the slot, so the slot becomes a group its content belongs to
|
|
26
26
|
const labelShown = $derived(!noLabel && ((labelConfig.text != null && labelConfig.text !== '') || Boolean(fieldLabel)));
|
|
27
|
-
const labelledby = $derived(joinIds(rest['aria-labelledby']
|
|
27
|
+
const labelledby = $derived(joinIds(rest['aria-labelledby'], labelShown && labelId));
|
|
28
28
|
</script>
|
|
29
29
|
|
|
30
30
|
{#snippet labelView()}
|
|
@@ -238,14 +238,14 @@
|
|
|
238
238
|
`${prefixCls}-wrapper`,
|
|
239
239
|
attrs.root.class,
|
|
240
240
|
{
|
|
241
|
-
[`${prefixCls}-wrapper__with-prefix`]:
|
|
242
|
-
[`${prefixCls}-wrapper__with-suffix`]:
|
|
241
|
+
[`${prefixCls}-wrapper__with-prefix`]: prefix || insetLabel,
|
|
242
|
+
[`${prefixCls}-wrapper__with-suffix`]: suffix,
|
|
243
243
|
[`${prefixCls}-wrapper__with-suffix-hidden`]: allowClear && hideSuffix,
|
|
244
244
|
[`${prefixCls}-wrapper__with-suffix-icon`]: suffixKind === 'icon',
|
|
245
|
-
[`${prefixCls}-wrapper__with-append`]:
|
|
246
|
-
[`${prefixCls}-wrapper__with-prepend`]:
|
|
247
|
-
[`${prefixCls}-wrapper__with-append-only`]:
|
|
248
|
-
[`${prefixCls}-wrapper__with-prepend-only`]:
|
|
245
|
+
[`${prefixCls}-wrapper__with-append`]: addonBefore,
|
|
246
|
+
[`${prefixCls}-wrapper__with-prepend`]: addonAfter,
|
|
247
|
+
[`${prefixCls}-wrapper__with-append-only`]: addonBefore && !addonAfter,
|
|
248
|
+
[`${prefixCls}-wrapper__with-prepend-only`]: !addonBefore && addonAfter,
|
|
249
249
|
[`${prefixCls}-wrapper-readonly`]: readonly,
|
|
250
250
|
[`${prefixCls}-wrapper-disabled`]: isDisabled,
|
|
251
251
|
[`${prefixCls}-wrapper-warning`]: validateStatus === 'warning',
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
[`${prefixCls}-wrapper-clearable`]: showClear,
|
|
255
255
|
[`${prefixCls}-wrapper-modebtn`]: mode === 'password',
|
|
256
256
|
[`${prefixCls}-wrapper-hidden`]: type === 'hidden',
|
|
257
|
-
[`${prefixCls}-wrapper-${shownSize}`]:
|
|
257
|
+
[`${prefixCls}-wrapper-${shownSize}`]: shownSize,
|
|
258
258
|
[`${prefixCls}-borderless`]: borderless,
|
|
259
259
|
},
|
|
260
260
|
]}
|
|
@@ -283,7 +283,7 @@
|
|
|
283
283
|
class={[
|
|
284
284
|
`${prefixCls}-prefix`,
|
|
285
285
|
{
|
|
286
|
-
[`${prefixCls}-inset-label`]:
|
|
286
|
+
[`${prefixCls}-inset-label`]: insetLabel,
|
|
287
287
|
[`${prefixCls}-prefix-text`]: prefixKind === 'text',
|
|
288
288
|
[`${prefixCls}-prefix-icon`]: prefixKind === 'icon',
|
|
289
289
|
},
|
|
@@ -308,7 +308,7 @@
|
|
|
308
308
|
class={[
|
|
309
309
|
prefixCls,
|
|
310
310
|
{
|
|
311
|
-
[`${prefixCls}-${shownSize}`]:
|
|
311
|
+
[`${prefixCls}-${shownSize}`]: shownSize,
|
|
312
312
|
[`${prefixCls}-disabled`]: isDisabled,
|
|
313
313
|
[`${prefixCls}-sibling-clearbtn`]: allowClear,
|
|
314
314
|
[`${prefixCls}-sibling-modebtn`]: mode === 'password',
|
|
@@ -275,7 +275,7 @@
|
|
|
275
275
|
{
|
|
276
276
|
[`${prefixCls}-textarea-disabled`]: disabled,
|
|
277
277
|
[`${prefixCls}-textarea-readonly`]: readonly,
|
|
278
|
-
[`${prefixCls}-textarea-autosize`]:
|
|
278
|
+
[`${prefixCls}-textarea-autosize`]: autosize,
|
|
279
279
|
[`${prefixCls}-textarea-showClear`]: showClear,
|
|
280
280
|
},
|
|
281
281
|
classNames?.textarea,
|
|
@@ -308,7 +308,7 @@
|
|
|
308
308
|
[`${prefixCls}-textarea-borderless`]: borderless,
|
|
309
309
|
[`${prefixCls}-textarea-wrapper-disabled`]: disabled,
|
|
310
310
|
[`${prefixCls}-textarea-wrapper-readonly`]: readonly,
|
|
311
|
-
[`${prefixCls}-textarea-wrapper-${validateStatus}`]:
|
|
311
|
+
[`${prefixCls}-textarea-wrapper-${validateStatus}`]: validateStatus,
|
|
312
312
|
[`${prefixCls}-textarea-wrapper-focus`]: states().isFocus,
|
|
313
313
|
[`${prefixCls}-textarea-wrapper-withLineNumber`]: showLineNumber,
|
|
314
314
|
[`${prefixCls}-textarea-wrapper-resizeX`]: isResizable(['horizontal', 'both', 'inline']),
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
closeIcon={closeIcon ? closeIconSlot : undefined}
|
|
92
92
|
{confirmLoading}
|
|
93
93
|
{dir}
|
|
94
|
-
footer={footer
|
|
95
|
-
header={header
|
|
94
|
+
footer={footer == null ? footer : footerSlot}
|
|
95
|
+
header={header == null ? header : headerSlot}
|
|
96
96
|
icon={icon === null ? undefined : iconSlot}
|
|
97
97
|
role="alertdialog"
|
|
98
98
|
title={title == null ? undefined : titleSlot}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { onMount } from 'svelte';
|
|
3
3
|
import { radioClasses } from '@fibrae/semi-foundation/components/radio/constants';
|
|
4
4
|
import RadioFoundation, { type RadioAdapter, type RadioBaseProps, type RadioBaseState } from '@fibrae/semi-foundation/components/radio/radio-foundation';
|
|
5
|
-
import { joinIds } from '@fibrae/semi-foundation/utils';
|
|
5
|
+
import { isAriaInvalid, joinIds } from '@fibrae/semi-foundation/utils';
|
|
6
6
|
import '@fibrae/semi-foundation/components/radio/radio.css';
|
|
7
7
|
import { IconRadio } from '@fibrae/semi-icons-svelte';
|
|
8
8
|
import { useDefaultProps, useFoundation } from '../../base/index.js';
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
|
|
112
112
|
const view = $derived(RadioFoundation.deriveView(foundationProps, states(), groupView()));
|
|
113
113
|
const hasExtra = $derived(Boolean(extra) && !view.isButtonRadio);
|
|
114
|
-
const describedby = $derived(joinIds(rest['aria-describedby'], hasExtra ? extraDomId : undefined, rest['aria-invalid'] ? rest['aria-errormessage'] : undefined));
|
|
114
|
+
const describedby = $derived(joinIds(rest['aria-describedby'], hasExtra ? extraDomId : undefined, isAriaInvalid(rest['aria-invalid']) ? rest['aria-errormessage'] : undefined));
|
|
115
115
|
|
|
116
116
|
// A native radio checks itself and unchecks its same-name siblings on click. Svelte does not patch a value that did
|
|
117
117
|
// not change, so when the owner refuses the change the DOM is written back by hand.
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
{
|
|
177
177
|
[`${prefix}-disabled`]: view.disabled,
|
|
178
178
|
[`${prefix}-checked`]: view.checked,
|
|
179
|
-
[`${prefix}-${displayMode}`]:
|
|
179
|
+
[`${prefix}-${displayMode}`]: displayMode,
|
|
180
180
|
[`${prefix}-buttonRadioComponent`]: !view.inGroup && view.isButtonRadio,
|
|
181
181
|
[`${prefix}-buttonRadioGroup`]: view.isButtonRadio,
|
|
182
182
|
[`${prefix}-buttonRadioGroup-${view.buttonSize}`]: view.isButtonRadio && view.buttonSize,
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
class: {
|
|
82
82
|
[`${prefix}-item-sel`]: selected && !isWheel,
|
|
83
83
|
[cssClasses.SELECTED]: isWheel && key === states().highlightedKey,
|
|
84
|
-
[`${prefix}-item-disabled`]:
|
|
84
|
+
[`${prefix}-item-disabled`]: item.disabled,
|
|
85
85
|
},
|
|
86
86
|
text: ItemFoundation.getItemText(item, selected, transform),
|
|
87
87
|
};
|
|
@@ -6,7 +6,7 @@ import type { InputProps, ValidateStatus } from '../input/index.js';
|
|
|
6
6
|
import type { PopoverProps } from '../popover/index.js';
|
|
7
7
|
import type { TagCloseEvent } from '../tag/index.js';
|
|
8
8
|
import type { Position } from '../tooltip/index.js';
|
|
9
|
-
export type BasicSelectValue = string | number | Record<string, any>;
|
|
9
|
+
export type BasicSelectValue = string | number | boolean | Record<string, any>;
|
|
10
10
|
export type SelectValue = BasicSelectValue | BasicSelectValue[] | undefined;
|
|
11
11
|
export type SelectSize = Size;
|
|
12
12
|
export interface SelectVirtualize {
|
|
@@ -20,7 +20,7 @@ export interface SelectOptionGroup {
|
|
|
20
20
|
label?: string | number;
|
|
21
21
|
}
|
|
22
22
|
export interface SelectOptionProps {
|
|
23
|
-
value?: string | number;
|
|
23
|
+
value?: string | number | boolean;
|
|
24
24
|
label?: string | number;
|
|
25
25
|
disabled?: boolean;
|
|
26
26
|
showTick?: boolean;
|
|
@@ -36,7 +36,7 @@ export type SelectInputProps = Omit<InputProps, 'value'>;
|
|
|
36
36
|
export interface SelectOptionItemSnippetProps {
|
|
37
37
|
/** Put it on the role="option" element: the combobox's aria-activedescendant points at it */
|
|
38
38
|
id: string;
|
|
39
|
-
value?: string | number;
|
|
39
|
+
value?: string | number | boolean;
|
|
40
40
|
label?: string | number;
|
|
41
41
|
selected: boolean;
|
|
42
42
|
focused: boolean;
|
|
@@ -130,8 +130,8 @@ export interface SelectProps extends Omit<HTMLAttributes<HTMLDivElement>, Native
|
|
|
130
130
|
onDropdownVisibleChange?: (visible: boolean) => void;
|
|
131
131
|
/** No event when called through `search()` or the trigger snippet's `onSearch` */
|
|
132
132
|
onSearch?: (value: string, event?: Event) => void;
|
|
133
|
-
onSelect?: (value: string | number, option: SelectOptionProps) => void;
|
|
134
|
-
onDeselect?: (value: string | number, option: SelectOptionProps) => void;
|
|
133
|
+
onSelect?: (value: string | number | boolean, option: SelectOptionProps) => void;
|
|
134
|
+
onDeselect?: (value: string | number | boolean, option: SelectOptionProps) => void;
|
|
135
135
|
onExceed?: (option: SelectOptionProps) => void;
|
|
136
136
|
onCreate?: (option: SelectOptionProps) => void;
|
|
137
137
|
onClear?: () => void;
|
|
@@ -550,7 +550,7 @@
|
|
|
550
550
|
{/if}
|
|
551
551
|
</div>
|
|
552
552
|
{:else}
|
|
553
|
-
<TagGroup maxTagCount={tagFold.limit} onPlusNMouseEnter={foundation.updateIsFullTags} popoverProps={showRestTagsPopover ? restTagsPopoverProps : undefined} restCount={tagFold.restCount} showPopover={showRestTagsPopover} size={tagSize} tagList={groupTags.map((item) => ({ tagKey: item.value }))}>
|
|
553
|
+
<TagGroup maxTagCount={tagFold.limit} onPlusNMouseEnter={foundation.updateIsFullTags} popoverProps={showRestTagsPopover ? restTagsPopoverProps : undefined} restCount={tagFold.restCount} showPopover={showRestTagsPopover} size={tagSize} tagList={groupTags.map((item) => ({ tagKey: `${item.value}` }))}>
|
|
554
554
|
{#snippet tag({ index }: { index: number })}
|
|
555
555
|
{@render tagItem(selectedItems[index], index, true)}
|
|
556
556
|
{/snippet}
|
|
@@ -607,7 +607,7 @@
|
|
|
607
607
|
`${cls}-selection-text`,
|
|
608
608
|
{
|
|
609
609
|
[`${cls}-selection-placeholder`]: !hasSingleContent,
|
|
610
|
-
[`${cls}-selection-text-hide`]:
|
|
610
|
+
[`${cls}-selection-text-hide`]: states().inputValue && states().showInput && searchInTrigger,
|
|
611
611
|
[`${cls}-selection-text-inactive`]: !states().inputValue && states().showInput && searchInTrigger,
|
|
612
612
|
},
|
|
613
613
|
]}
|
|
@@ -670,8 +670,8 @@
|
|
|
670
670
|
[`${cls}-error`]: validateStatus === 'error',
|
|
671
671
|
[`${cls}-warning`]: validateStatus === 'warning',
|
|
672
672
|
[`${cls}-no-arrow`]: !showArrow,
|
|
673
|
-
[`${cls}-with-prefix`]:
|
|
674
|
-
[`${cls}-with-suffix`]:
|
|
673
|
+
[`${cls}-with-prefix`]: prefix || insetLabel,
|
|
674
|
+
[`${cls}-with-suffix`]: suffix,
|
|
675
675
|
},
|
|
676
676
|
]}
|
|
677
677
|
id={selectId}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
const gradientId = `linearGradient-${uid}`;
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
|
-
<svg aria-hidden="true" data-icon="spin" height="48"
|
|
7
|
+
<svg aria-hidden="true" data-icon="spin" height="48" viewBox="0 0 36 36" width="48" xmlns="http://www.w3.org/2000/svg">
|
|
8
8
|
<defs>
|
|
9
9
|
<linearGradient id={gradientId} x1="0%" x2="100%" y1="100%" y2="100%">
|
|
10
10
|
<stop offset="0%" stop-color="currentColor" stop-opacity="0" />
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
import { getTableContext } from '../context.js';
|
|
27
27
|
import type { ColumnProps, TableVirtualizedScrollArgs } from '../interface.js';
|
|
28
28
|
import TableHeader from '../table-header/table-header.svelte';
|
|
29
|
-
import { joinStyles } from '../utils.js';
|
|
30
29
|
import BaseRow from './base-row.svelte';
|
|
31
30
|
import ExpandedRow from './expanded-row.svelte';
|
|
32
31
|
import SectionRow from './section-row.svelte';
|
|
@@ -54,6 +53,8 @@
|
|
|
54
53
|
let bodyElement = $state<HTMLDivElement>();
|
|
55
54
|
let listElement = $state<HTMLElement>();
|
|
56
55
|
let list = $state<ReturnType<typeof VirtualList>>();
|
|
56
|
+
let listHeader = $state<HTMLDivElement>();
|
|
57
|
+
let listHeaderHeight = $state(0);
|
|
57
58
|
let hoveredRowKey = $state<BaseRowKeyType | null>(null);
|
|
58
59
|
|
|
59
60
|
// whether the body overflows, so it takes keyboard focus to scroll; known after mount
|
|
@@ -98,13 +99,12 @@
|
|
|
98
99
|
if (!table.virtualized) {
|
|
99
100
|
return null;
|
|
100
101
|
}
|
|
102
|
+
// the header measures the widths, so it renders before the rows have any
|
|
101
103
|
const cellWidths = table.getCellWidths(columns);
|
|
102
|
-
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
104
|
+
const hasWidths = cellWidths.length > 0;
|
|
105
105
|
const y = typeof table.scroll?.y === 'number' ? table.scroll.y : numbers.DEFAULT_VIRTUALIZED_BODY_HEIGHT;
|
|
106
|
-
const rowWidth = arrayAdd(cellWidths, 0, columns.length);
|
|
107
|
-
return { rowWidth, height: virtualizedData.length ? y : 0 };
|
|
106
|
+
const rowWidth = hasWidths ? arrayAdd(cellWidths, 0, columns.length) : 0;
|
|
107
|
+
return { rowWidth, itemCount: hasWidths ? virtualizedData.length : 0, height: virtualizedData.length ? y : 0 };
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
// a scrolling body must be keyboard reachable even without a focusable cell
|
|
@@ -185,10 +185,10 @@
|
|
|
185
185
|
untrack(() => list?.measure());
|
|
186
186
|
});
|
|
187
187
|
|
|
188
|
-
//
|
|
188
|
+
// a separate (sticky) header reserves the width of a vertical scrollbar the body shows (#1219)
|
|
189
189
|
$effect(() => {
|
|
190
190
|
const node = scrollElement();
|
|
191
|
-
if (!table.scroll?.y || !node) {
|
|
191
|
+
if (!table.scroll?.y || includeHeader || !node) {
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
194
|
const observer = new ResizeObserver(() => {
|
|
@@ -232,15 +232,27 @@
|
|
|
232
232
|
class="{table.prefixCls}-body"
|
|
233
233
|
height={virtualBody.height}
|
|
234
234
|
innerAttrs={{ class: `${table.prefixCls}-tbody`, role: 'rowgroup' }}
|
|
235
|
-
itemCount={
|
|
235
|
+
itemCount={virtualBody.itemCount}
|
|
236
236
|
itemKey={virtualKey}
|
|
237
237
|
{itemSize}
|
|
238
238
|
overscan={table.virtualizedProps?.overscanCount}
|
|
239
|
+
scrollMargin={includeHeader ? listHeaderHeight : 0}
|
|
239
240
|
style="direction: {table.direction}{virtualizedData.length ? '' : '; height: auto'}"
|
|
240
241
|
tabindex={0}
|
|
241
242
|
wrapperAttrs={{ class: [table.prefixCls, `${table.prefixCls}-fixed`], role: 'none', style: rowStyle }}
|
|
242
243
|
onscroll={handleListScroll}
|
|
243
244
|
>
|
|
245
|
+
{#snippet before()}
|
|
246
|
+
{#if includeHeader}
|
|
247
|
+
<!-- a hidden header stays for its column widths; inert keeps its controls out of the Tab order and the a11y tree; rendered in the list's scroller above the rows, so the browser moves it with them in the same frame -->
|
|
248
|
+
<div {@attach observeResize(() => (listHeaderHeight = listHeader?.offsetHeight ?? 0))} bind:this={listHeader} class="{table.prefixCls}-list-header" inert={!table.showHeader}>
|
|
249
|
+
<svelte:element this={table.components.header.outer} class={[table.prefixCls, `${table.prefixCls}-fixed`]} role="none" style:min-width={toCssLength(minWidth)} style:width={toCssLength(table.scroll?.x)}>
|
|
250
|
+
<ColGroup {columns} prefixCls={table.prefixCls} />
|
|
251
|
+
<TableHeader {columns} hidden={!table.showHeader} />
|
|
252
|
+
</svelte:element>
|
|
253
|
+
</div>
|
|
254
|
+
{/if}
|
|
255
|
+
{/snippet}
|
|
244
256
|
{#snippet children({ index, style })}
|
|
245
257
|
{@const item = virtualItem(index)}
|
|
246
258
|
{#if item.sectionRow}
|
|
@@ -274,7 +286,8 @@
|
|
|
274
286
|
{@attach observeResize(measureOverflow)}
|
|
275
287
|
class={[table.prefixCls, { [`${table.prefixCls}-fixed`]: table.tableLayout === 'fixed' }]}
|
|
276
288
|
role={table.splitTable ? 'none' : 'table'}
|
|
277
|
-
style
|
|
289
|
+
style:min-width={toCssLength(minWidth)}
|
|
290
|
+
style:width={toCssLength(table.scroll?.x)}
|
|
278
291
|
>
|
|
279
292
|
<ColGroup col={table.components.body.colgroup.col} {columns} prefixCls={table.prefixCls} wrapper={table.components.body.colgroup.wrapper} />
|
|
280
293
|
<!-- without a header the fixed columns still need its measured widths for their offsets -->
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
[`${table.prefixCls}-cell-fixed-right`]: right,
|
|
75
75
|
[`${table.prefixCls}-cell-fixed-right-first`]: rightFirst,
|
|
76
76
|
[`${table.prefixCls}-cell-last`]: columnsToEnd != null && (colspan ?? 1) >= columnsToEnd,
|
|
77
|
-
[`${table.prefixCls}-row-cell-ellipsis`]:
|
|
77
|
+
[`${table.prefixCls}-row-cell-ellipsis`]: column.ellipsis,
|
|
78
78
|
},
|
|
79
79
|
],
|
|
80
80
|
// a role="none" table no longer gives colspan and rowspan their table meaning
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
|
|
23
23
|
<div
|
|
24
24
|
bind:this={element}
|
|
25
|
-
class={[`${table.prefixCls}-header`, { [`${table.prefixCls}-header-sticky`]:
|
|
25
|
+
class={[`${table.prefixCls}-header`, { [`${table.prefixCls}-header-sticky`]: table.sticky, [`${table.prefixCls}-header-hidden`]: !table.showHeader }]}
|
|
26
26
|
inert={!table.showHeader}
|
|
27
27
|
style={joinStyles(table.bodyHasScrollbar && 'overflow-y: scroll', `top: ${toCssLength(top)}`)}
|
|
28
28
|
onscroll={table.handleBodyScroll}
|
|
29
29
|
>
|
|
30
|
-
<svelte:element this={table.components.header.outer} class={[table.prefixCls, { [`${table.prefixCls}-fixed`]: table.tableLayout === 'fixed' }]} role="none" style={
|
|
30
|
+
<svelte:element this={table.components.header.outer} class={[table.prefixCls, { [`${table.prefixCls}-fixed`]: table.tableLayout === 'fixed' }]} role="none" style:min-width={toCssLength(minWidth)} style:width={toCssLength(table.scroll?.x)}>
|
|
31
31
|
<ColGroup {columns} prefixCls={table.prefixCls} />
|
|
32
32
|
<TableHeader {columns} />
|
|
33
33
|
</svelte:element>
|
|
@@ -82,13 +82,13 @@
|
|
|
82
82
|
column.class,
|
|
83
83
|
customClass,
|
|
84
84
|
{
|
|
85
|
-
[`${table.prefixCls}-align-${textAlign}`]:
|
|
85
|
+
[`${table.prefixCls}-align-${textAlign}`]: textAlign,
|
|
86
86
|
[`${table.prefixCls}-cell-fixed-left`]: fixedLeft,
|
|
87
87
|
[`${table.prefixCls}-cell-fixed-left-last`]: fixedLeftLast,
|
|
88
88
|
[`${table.prefixCls}-cell-fixed-right`]: fixedRight,
|
|
89
89
|
[`${table.prefixCls}-cell-fixed-right-first`]: fixedRightFirst,
|
|
90
|
-
[`${table.prefixCls}-cell-last`]:
|
|
91
|
-
[`${table.prefixCls}-row-head-ellipsis`]:
|
|
90
|
+
[`${table.prefixCls}-cell-last`]: cell.last,
|
|
91
|
+
[`${table.prefixCls}-row-head-ellipsis`]: column.ellipsis,
|
|
92
92
|
[`${table.prefixCls}-row-head-clickSort`]: flags.clickToSort,
|
|
93
93
|
},
|
|
94
94
|
],
|
|
@@ -124,8 +124,9 @@
|
|
|
124
124
|
return { ...custom, class: [customClass, `${table.prefixCls}-row`] };
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
-
// The measured widths give the sticky offsets of fixed columns; measured when the columns change
|
|
128
|
-
// render, since reading layout after a
|
|
127
|
+
// The measured widths give the sticky offsets of fixed columns; measured when the columns change or the row resizes
|
|
128
|
+
// (a column without a number width follows the table's width), not on every render, since reading layout after a
|
|
129
|
+
// DOM update forces a reflow
|
|
129
130
|
const measure = (node: HTMLElement) => {
|
|
130
131
|
const levelColumns = getColumnsByLevel(columns, index) as ColumnProps[];
|
|
131
132
|
const heads = node.querySelectorAll(`.${table.prefixCls}-row-head`);
|
|
@@ -172,6 +173,16 @@
|
|
|
172
173
|
untrack(() => measure(row));
|
|
173
174
|
}
|
|
174
175
|
});
|
|
176
|
+
|
|
177
|
+
$effect(() => {
|
|
178
|
+
const row = rowElement;
|
|
179
|
+
if (!row) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const observer = new ResizeObserver(() => measure(row));
|
|
183
|
+
observer.observe(row);
|
|
184
|
+
return () => observer.disconnect();
|
|
185
|
+
});
|
|
175
186
|
</script>
|
|
176
187
|
|
|
177
188
|
<svelte:element this={table.components.header.row} bind:this={rowElement} {...rowAttrs} role="row">
|
|
@@ -166,7 +166,13 @@
|
|
|
166
166
|
const showExpandIcon = $derived(expandIcon !== false);
|
|
167
167
|
const fixedHeader = $derived(Boolean(scroll?.y) || Boolean(sticky));
|
|
168
168
|
const isVirtualized = $derived(Boolean(virtualized));
|
|
169
|
-
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Elsewhere the header sits in the body's scroller, so the compositor moves both in the same frame. A header stuck
|
|
172
|
+
* to the page would be trapped by the body's overflow, so it renders as a separate table above the body
|
|
173
|
+
*/
|
|
174
|
+
const headerApart = $derived(Boolean(sticky));
|
|
175
|
+
const splitTable = $derived(headerApart || isVirtualized);
|
|
170
176
|
const mergedComponents = $derived(mergeComponents(components, isVirtualized));
|
|
171
177
|
const paginationPosition = $derived(paginationOptions?.position ?? 'bottom');
|
|
172
178
|
const formatPageText = $derived(paginationOptions?.formatPageText);
|
|
@@ -343,8 +349,13 @@
|
|
|
343
349
|
return;
|
|
344
350
|
}
|
|
345
351
|
const scroller = body?.element();
|
|
346
|
-
if (target
|
|
347
|
-
|
|
352
|
+
if (target === head && scroller && foundation.headerFollowsInCss()) {
|
|
353
|
+
// focus scrolled the clipped header to reveal a cell; the body takes the distance, and the header's
|
|
354
|
+
// animation follows it
|
|
355
|
+
scroller.scrollLeft += target.scrollLeft;
|
|
356
|
+
target.scrollLeft = 0;
|
|
357
|
+
} else if (target.scrollLeft !== lastScrollLeft) {
|
|
358
|
+
if (target === scroller && head && !foundation.headerFollowsInCss()) {
|
|
348
359
|
head.scrollLeft = target.scrollLeft;
|
|
349
360
|
} else if (target === head && scroller) {
|
|
350
361
|
scroller.scrollLeft = target.scrollLeft;
|
|
@@ -591,6 +602,21 @@
|
|
|
591
602
|
return () => observer.disconnect();
|
|
592
603
|
});
|
|
593
604
|
|
|
605
|
+
// the content-box size changes with the body's scrollbar too; columns or rows that widen the table without
|
|
606
|
+
// resizing the body are caught after the update
|
|
607
|
+
$effect(() => {
|
|
608
|
+
void tableColumns;
|
|
609
|
+
void view.dataSource;
|
|
610
|
+
const node = body?.element();
|
|
611
|
+
if (!headerApart || !node) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
untrack(foundation.syncHeaderScrollRange);
|
|
615
|
+
const observer = new ResizeObserver(foundation.syncHeaderScrollRange);
|
|
616
|
+
observer.observe(node);
|
|
617
|
+
return () => observer.disconnect();
|
|
618
|
+
});
|
|
619
|
+
|
|
594
620
|
export function getCurrentPageData(): ReturnType<TableHandle['getCurrentPageData']> {
|
|
595
621
|
return cloneDeep(foundation.getCurrentPageData());
|
|
596
622
|
}
|
|
@@ -615,7 +641,7 @@
|
|
|
615
641
|
[`${prefixCls}-${strings.SIZE_MIDDLE}`]: size === strings.SIZE_MIDDLE,
|
|
616
642
|
[`${prefixCls}-virtualized`]: isVirtualized,
|
|
617
643
|
[`${prefixCls}-bordered`]: bordered,
|
|
618
|
-
[`${prefixCls}-fixed-header`]:
|
|
644
|
+
[`${prefixCls}-fixed-header`]: scroll?.y,
|
|
619
645
|
}}
|
|
620
646
|
>
|
|
621
647
|
{#if mergedPagination && (paginationPosition === 'top' || paginationPosition === 'both')}
|
|
@@ -627,7 +653,7 @@
|
|
|
627
653
|
</div>
|
|
628
654
|
{/if}
|
|
629
655
|
<div {...splitTable ? nameAttrs : {}} aria-rowcount={isVirtualized ? headerRowCount + virtualizedData.length : undefined} class="{prefixCls}-container" role={splitTable ? 'table' : undefined}>
|
|
630
|
-
{#if
|
|
656
|
+
{#if headerApart}
|
|
631
657
|
<HeadTable bind:element={head} columns={tableColumns} />
|
|
632
658
|
{/if}
|
|
633
659
|
<Body
|
|
@@ -636,7 +662,7 @@
|
|
|
636
662
|
dataSource={view.dataSource ?? []}
|
|
637
663
|
expandedRowKeys={view.expandedRowKeys ?? []}
|
|
638
664
|
groups={view.groups}
|
|
639
|
-
includeHeader={!
|
|
665
|
+
includeHeader={!headerApart}
|
|
640
666
|
{onScroll}
|
|
641
667
|
pageDisabledRowKeysSet={view.pageDisabledRowKeysSet ?? EMPTY_KEYS}
|
|
642
668
|
tableAttrs={splitTable ? undefined : nameAttrs}
|
|
@@ -319,8 +319,8 @@
|
|
|
319
319
|
[`${prefixCls}-warning`]: validateStatus === 'warning',
|
|
320
320
|
[`${prefixCls}-small`]: size === 'small',
|
|
321
321
|
[`${prefixCls}-large`]: size === 'large',
|
|
322
|
-
[`${prefixCls}-with-prefix`]:
|
|
323
|
-
[`${prefixCls}-with-suffix`]:
|
|
322
|
+
[`${prefixCls}-with-prefix`]: prefix || insetLabel,
|
|
323
|
+
[`${prefixCls}-with-suffix`]: suffix,
|
|
324
324
|
},
|
|
325
325
|
]}
|
|
326
326
|
role="group"
|
|
@@ -331,7 +331,7 @@
|
|
|
331
331
|
{#if prefix || insetLabel}
|
|
332
332
|
<div
|
|
333
333
|
{@attach trackPrefix}
|
|
334
|
-
class={[`${prefixCls}-prefix`, { [`${prefixCls}-inset-label`]:
|
|
334
|
+
class={[`${prefixCls}-prefix`, { [`${prefixCls}-inset-label`]: insetLabel, [`${prefixCls}-prefix-text`]: prefixKind === 'text', [`${prefixCls}-prefix-icon`]: prefixKind === 'icon' }]}
|
|
335
335
|
id={prefixId}
|
|
336
336
|
x-semi-prop="prefix"
|
|
337
337
|
onclick={foundation.handleClickPrefixOrSuffix}
|