@lostgradient/cinder 0.16.0 → 0.16.1
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/CHANGELOG.md +6 -0
- package/components.json +1 -1
- package/dist/components/data-table/index.js +88 -31
- package/dist/components/table/index.js +85 -28
- package/dist/components/table/table.css +11 -0
- package/dist/components/table/table.schema.js +10 -1
- package/dist/components/table/table.types.d.ts +24 -1
- package/dist/index.js +272 -215
- package/dist/server/components/data-table/index.js +2 -2
- package/dist/server/components/table/index.js +2 -2
- package/dist/server/index.js +3 -3
- package/dist/server/{index.server-mehav5vs.js → index.server-gwgm8gqg.js} +1 -1
- package/dist/server/{index.server-ne4gzxvz.js → index.server-wasj5rbh.js} +1 -1
- package/dist/server/index.server-xanq9ppe.js +119 -0
- package/package.json +1 -1
- package/src/components/table/table.css +11 -0
- package/src/components/table/table.examples.json +3 -3
- package/src/components/table/table.schema.json +9 -0
- package/src/components/table/table.schema.ts +11 -0
- package/src/components/table/table.svelte +58 -14
- package/src/components/table/table.types.ts +27 -1
- package/dist/server/index.server-mzj20rfz.js +0 -77
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Data_table,
|
|
3
3
|
data_table_default
|
|
4
|
-
} from "../../index.server-
|
|
4
|
+
} from "../../index.server-wasj5rbh.js";
|
|
5
5
|
import"../../index.server-5bxfjsbc.js";
|
|
6
|
-
import"../../index.server-
|
|
6
|
+
import"../../index.server-xanq9ppe.js";
|
|
7
7
|
import"../../index.server-8gv0tm3r.js";
|
|
8
8
|
import"../../index.server-mz7sqkya.js";
|
|
9
9
|
import"../../index.server-d4e6afc0.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Table,
|
|
3
3
|
table_default
|
|
4
|
-
} from "../../index.server-
|
|
5
|
-
import"../../index.server-
|
|
4
|
+
} from "../../index.server-gwgm8gqg.js";
|
|
5
|
+
import"../../index.server-xanq9ppe.js";
|
|
6
6
|
import"../../index.server-8gv0tm3r.js";
|
|
7
7
|
import"../../index.server-mz7sqkya.js";
|
|
8
8
|
import"../../index.server-d4e6afc0.js";
|
package/dist/server/index.js
CHANGED
|
@@ -77,7 +77,7 @@ import {
|
|
|
77
77
|
} from "./index.server-fe41fvr4.js";
|
|
78
78
|
import {
|
|
79
79
|
table_default
|
|
80
|
-
} from "./index.server-
|
|
80
|
+
} from "./index.server-gwgm8gqg.js";
|
|
81
81
|
import {
|
|
82
82
|
table_body_default
|
|
83
83
|
} from "./index.server-7scshbcm.js";
|
|
@@ -484,14 +484,14 @@ import {
|
|
|
484
484
|
import"./index.server-2h3y9v3e.js";
|
|
485
485
|
import {
|
|
486
486
|
data_table_default
|
|
487
|
-
} from "./index.server-
|
|
487
|
+
} from "./index.server-wasj5rbh.js";
|
|
488
488
|
import {
|
|
489
489
|
getFixedVirtualWindow,
|
|
490
490
|
parsePixelLength,
|
|
491
491
|
resolveVirtualItemHeight,
|
|
492
492
|
resolveVirtualOverscan
|
|
493
493
|
} from "./index.server-5bxfjsbc.js";
|
|
494
|
-
import"./index.server-
|
|
494
|
+
import"./index.server-xanq9ppe.js";
|
|
495
495
|
import"./index.server-8gv0tm3r.js";
|
|
496
496
|
import"./index.server-mz7sqkya.js";
|
|
497
497
|
import"./index.server-d4e6afc0.js";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setTableContext
|
|
3
|
+
} from "./index.server-7pdq2w0a.js";
|
|
4
|
+
import {
|
|
5
|
+
useResizeObserver
|
|
6
|
+
} from "./index.server-9w7qdn8h.js";
|
|
7
|
+
import {
|
|
8
|
+
classNames
|
|
9
|
+
} from "./index.server-z7nvkz8v.js";
|
|
10
|
+
|
|
11
|
+
// src/components/table/table.svelte
|
|
12
|
+
import * as $ from "svelte/internal/server";
|
|
13
|
+
function Table($$renderer, $$props) {
|
|
14
|
+
$$renderer.component(($$renderer2) => {
|
|
15
|
+
let {
|
|
16
|
+
sort = undefined,
|
|
17
|
+
caption,
|
|
18
|
+
stickyHeader = false,
|
|
19
|
+
density = "comfortable",
|
|
20
|
+
selectable = false,
|
|
21
|
+
scrollable = false,
|
|
22
|
+
scrollContainerProps,
|
|
23
|
+
class: className,
|
|
24
|
+
children,
|
|
25
|
+
$$slots,
|
|
26
|
+
$$events,
|
|
27
|
+
...rest
|
|
28
|
+
} = $$props;
|
|
29
|
+
const wrapperClassName = $.derived(() => scrollContainerProps?.class);
|
|
30
|
+
const wrapperAriaLabelledBy = $.derived(() => normalizeOptionalAttribute(scrollContainerProps?.["aria-labelledby"]));
|
|
31
|
+
const explicitWrapperAriaLabel = $.derived(() => normalizeOptionalAttribute(scrollContainerProps?.["aria-label"]));
|
|
32
|
+
const explicitWrapperRole = $.derived(() => normalizeOptionalAttribute(scrollContainerProps?.role));
|
|
33
|
+
const normalizedCaption = $.derived(() => normalizeOptionalAttribute(caption));
|
|
34
|
+
const wrapperAriaLabel = $.derived(() => explicitWrapperAriaLabel() ?? (wrapperAriaLabelledBy() ? undefined : normalizedCaption() ? `${normalizedCaption()} table scroll area` : undefined));
|
|
35
|
+
const wrapperRole = $.derived(() => explicitWrapperRole() ?? (wrapperAriaLabel() || wrapperAriaLabelledBy() ? "region" : undefined));
|
|
36
|
+
const wrapperTabindex = $.derived(() => normalizeOptionalTabindex(scrollContainerProps?.tabindex) ?? 0);
|
|
37
|
+
function normalizeOptionalAttribute(value) {
|
|
38
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
39
|
+
}
|
|
40
|
+
function normalizeOptionalTabindex(value) {
|
|
41
|
+
if (typeof value === "number" && Number.isInteger(value))
|
|
42
|
+
return value;
|
|
43
|
+
if (typeof value !== "string")
|
|
44
|
+
return;
|
|
45
|
+
const normalizedValue = value.trim();
|
|
46
|
+
if (!/^-?\d+$/.test(normalizedValue))
|
|
47
|
+
return;
|
|
48
|
+
return Number(normalizedValue);
|
|
49
|
+
}
|
|
50
|
+
let captionHeight = 0;
|
|
51
|
+
const measureCaption = useResizeObserver((entries) => {
|
|
52
|
+
const entry = entries[0];
|
|
53
|
+
if (!entry)
|
|
54
|
+
return;
|
|
55
|
+
captionHeight = entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;
|
|
56
|
+
}, { box: "border-box", enabled: () => stickyHeader });
|
|
57
|
+
function onsortchange(column) {
|
|
58
|
+
if (!sort || sort.column !== column) {
|
|
59
|
+
sort = { column, direction: "ascending" };
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
sort = {
|
|
63
|
+
column,
|
|
64
|
+
direction: sort.direction === "ascending" ? "descending" : "ascending"
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
setTableContext({
|
|
68
|
+
get sort() {
|
|
69
|
+
return sort;
|
|
70
|
+
},
|
|
71
|
+
get selectionEnabled() {
|
|
72
|
+
return selectable;
|
|
73
|
+
},
|
|
74
|
+
onsortchange
|
|
75
|
+
});
|
|
76
|
+
function table($$renderer3) {
|
|
77
|
+
$$renderer3.push(`<table${$.attributes({
|
|
78
|
+
...rest,
|
|
79
|
+
class: $.clsx(classNames("cinder-table", className)),
|
|
80
|
+
"data-cinder-sticky-header": stickyHeader || undefined,
|
|
81
|
+
"data-cinder-density": density,
|
|
82
|
+
"data-cinder-selectable": selectable || undefined
|
|
83
|
+
}, undefined, undefined, {
|
|
84
|
+
"--cinder-table-caption-height": normalizedCaption() ? `${captionHeight}px` : undefined
|
|
85
|
+
})}>`);
|
|
86
|
+
if (normalizedCaption()) {
|
|
87
|
+
$$renderer3.push("<!--[0-->");
|
|
88
|
+
$$renderer3.push(`<caption class="cinder-table__caption">${$.escape(normalizedCaption())}</caption>`);
|
|
89
|
+
} else {
|
|
90
|
+
$$renderer3.push("<!--[-1-->");
|
|
91
|
+
}
|
|
92
|
+
$$renderer3.push(`<!--]-->`);
|
|
93
|
+
children($$renderer3);
|
|
94
|
+
$$renderer3.push(`<!----></table>`);
|
|
95
|
+
}
|
|
96
|
+
if (scrollable) {
|
|
97
|
+
$$renderer2.push("<!--[0-->");
|
|
98
|
+
$$renderer2.push(`<div${$.attributes({
|
|
99
|
+
...scrollContainerProps,
|
|
100
|
+
class: $.clsx(classNames("cinder-table-scroll", wrapperClassName())),
|
|
101
|
+
role: wrapperRole(),
|
|
102
|
+
"aria-label": wrapperAriaLabel(),
|
|
103
|
+
"aria-labelledby": wrapperAriaLabelledBy(),
|
|
104
|
+
tabindex: wrapperTabindex()
|
|
105
|
+
})}>`);
|
|
106
|
+
table($$renderer2);
|
|
107
|
+
$$renderer2.push(`<!----></div>`);
|
|
108
|
+
} else {
|
|
109
|
+
$$renderer2.push("<!--[-1-->");
|
|
110
|
+
table($$renderer2);
|
|
111
|
+
}
|
|
112
|
+
$$renderer2.push(`<!--]-->`);
|
|
113
|
+
$.bind_props($$props, { sort });
|
|
114
|
+
}, Table);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { Table };
|
|
118
|
+
|
|
119
|
+
//# debugId=1DFB296CFE8432E764756E2164756E21
|
package/package.json
CHANGED
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
min-inline-size: max-content;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
.cinder-table-scroll:focus-visible {
|
|
40
|
+
outline: var(--cinder-ring-width) solid transparent;
|
|
41
|
+
box-shadow: var(--_cinder-focus-ring-shadow);
|
|
42
|
+
}
|
|
43
|
+
|
|
39
44
|
.cinder-table__caption {
|
|
40
45
|
caption-side: top;
|
|
41
46
|
text-align: left;
|
|
@@ -163,6 +168,12 @@
|
|
|
163
168
|
}
|
|
164
169
|
|
|
165
170
|
@media (forced-colors: active) {
|
|
171
|
+
.cinder-table-scroll:focus-visible {
|
|
172
|
+
outline: var(--cinder-ring-width) solid ButtonText;
|
|
173
|
+
outline-offset: 3px;
|
|
174
|
+
box-shadow: none;
|
|
175
|
+
}
|
|
176
|
+
|
|
166
177
|
.cinder-table__sort-button:focus-visible {
|
|
167
178
|
outline: var(--cinder-ring-width) solid ButtonText;
|
|
168
179
|
/* 2px is correct here: sort-button has border:none so there is no
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
"examples": [
|
|
6
6
|
{
|
|
7
7
|
"id": "basic",
|
|
8
|
-
"title": "
|
|
9
|
-
"description": "
|
|
10
|
-
"code": "<script lang=\"ts\">\n import { Table } from '@lostgradient/cinder/table';\n const people = [\n {
|
|
8
|
+
"title": "Scrollable table",
|
|
9
|
+
"description": "Hand-composed cells inside the public horizontal scroll wrapper for dense tables.",
|
|
10
|
+
"code": "<script lang=\"ts\">\n import { Table } from '@lostgradient/cinder/table';\n const people = [\n {\n name: 'Ada Lovelace',\n role: 'Mathematician and analytical engine collaborator',\n commits: 142,\n },\n {\n name: 'Grace Hopper',\n role: 'Computer scientist, compiler builder, and systems educator',\n commits: 98,\n },\n {\n name: 'Alan Turing',\n role: 'Cryptanalyst, logician, and theoretical computer scientist',\n commits: 76,\n },\n ];\n</script>\n\n<Table caption=\"Recent contributors\" scrollable>\n <Table.Header>\n <Table.Row>\n <Table.HeaderCell>Name</Table.HeaderCell>\n <Table.HeaderCell>Role</Table.HeaderCell>\n <Table.HeaderCell align=\"right\">Commits</Table.HeaderCell>\n </Table.Row>\n </Table.Header>\n <Table.Body>\n {#each people as person (person.name)}\n <Table.Row>\n <Table.Cell>{person.name}</Table.Cell>\n <Table.Cell>{person.role}</Table.Cell>\n <Table.Cell align=\"right\">{person.commits}</Table.Cell>\n </Table.Row>\n {/each}\n </Table.Body>\n</Table>\n"
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
"id": "empty",
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
"type": "boolean",
|
|
19
19
|
"description": "Enables the leading selection column on the entire table. When true:\n- The single `TableRow` inside `TableHeader` renders a leading `<th>`\n with a select-all checkbox sourced from the header's props.\n- Every `TableRow` inside `TableBody` renders a leading selection cell.\nSelection is strictly controlled — the consumer owns all selection state."
|
|
20
20
|
},
|
|
21
|
+
"scrollable": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"description": "When true, wraps the table in a `.cinder-table-scroll` container that\nenables horizontal overflow scrolling for dense or unknown-width tables.\nUse this instead of manually wrapping Table in `.cinder-table-scroll`.\n\nWhen combined with `stickyHeader`, the generated wrapper is the sticky\nheader's scroll container. Set a bounded block size on `scrollContainerProps`\nwhen the table should scroll vertically inside that wrapper."
|
|
24
|
+
},
|
|
21
25
|
"class": {
|
|
22
26
|
"type": "string",
|
|
23
27
|
"description": "Additional class names merged with `.cinder-table`."
|
|
@@ -32,6 +36,11 @@
|
|
|
32
36
|
"required": true,
|
|
33
37
|
"description": "TableHeader, TableBody, etc."
|
|
34
38
|
},
|
|
39
|
+
{
|
|
40
|
+
"name": "scrollContainerProps",
|
|
41
|
+
"reason": "unknown-shape",
|
|
42
|
+
"description": "Attributes forwarded to the generated `.cinder-table-scroll` wrapper when\n`scrollable` is true. The wrapper is focusable by default so keyboard users\ncan scroll read-only wide tables. When the table has a caption, or when\n`aria-label` or `aria-labelledby` is provided here, the wrapper becomes a\nnamed `region`; pass `role` or `tabindex` here to override those defaults."
|
|
43
|
+
},
|
|
35
44
|
{
|
|
36
45
|
"name": "sort",
|
|
37
46
|
"reason": "unknown-shape",
|
|
@@ -22,6 +22,11 @@ const schema = {
|
|
|
22
22
|
description:
|
|
23
23
|
"Enables the leading selection column on the entire table. When true:\n- The single `TableRow` inside `TableHeader` renders a leading `<th>`\n with a select-all checkbox sourced from the header's props.\n- Every `TableRow` inside `TableBody` renders a leading selection cell.\nSelection is strictly controlled — the consumer owns all selection state.",
|
|
24
24
|
},
|
|
25
|
+
scrollable: {
|
|
26
|
+
type: 'boolean',
|
|
27
|
+
description:
|
|
28
|
+
"When true, wraps the table in a `.cinder-table-scroll` container that\nenables horizontal overflow scrolling for dense or unknown-width tables.\nUse this instead of manually wrapping Table in `.cinder-table-scroll`.\n\nWhen combined with `stickyHeader`, the generated wrapper is the sticky\nheader's scroll container. Set a bounded block size on `scrollContainerProps`\nwhen the table should scroll vertically inside that wrapper.",
|
|
29
|
+
},
|
|
25
30
|
class: {
|
|
26
31
|
type: 'string',
|
|
27
32
|
description: 'Additional class names merged with `.cinder-table`.',
|
|
@@ -36,6 +41,12 @@ const schema = {
|
|
|
36
41
|
required: true,
|
|
37
42
|
description: 'TableHeader, TableBody, etc.',
|
|
38
43
|
},
|
|
44
|
+
{
|
|
45
|
+
name: 'scrollContainerProps',
|
|
46
|
+
reason: 'unknown-shape',
|
|
47
|
+
description:
|
|
48
|
+
'Attributes forwarded to the generated `.cinder-table-scroll` wrapper when\n`scrollable` is true. The wrapper is focusable by default so keyboard users\ncan scroll read-only wide tables. When the table has a caption, or when\n`aria-label` or `aria-labelledby` is provided here, the wrapper becomes a\nnamed `region`; pass `role` or `tabindex` here to override those defaults.',
|
|
49
|
+
},
|
|
39
50
|
{
|
|
40
51
|
name: 'sort',
|
|
41
52
|
reason: 'unknown-shape',
|
|
@@ -6,7 +6,33 @@ export {};
|
|
|
6
6
|
import { setTableContext } from './table.context.ts';
|
|
7
7
|
import { classNames } from '../../utilities/class-names.ts';
|
|
8
8
|
import { useResizeObserver } from '../../utilities/use-resize-observer.svelte.ts';
|
|
9
|
-
let { sort = $bindable(), caption, stickyHeader = false, density = 'comfortable', selectable = false, class: className, children, ...rest } = $props();
|
|
9
|
+
let { sort = $bindable(), caption, stickyHeader = false, density = 'comfortable', selectable = false, scrollable = false, scrollContainerProps, class: className, children, ...rest } = $props();
|
|
10
|
+
const wrapperClassName = $derived(scrollContainerProps?.class);
|
|
11
|
+
const wrapperAriaLabelledBy = $derived(normalizeOptionalAttribute(scrollContainerProps?.['aria-labelledby']));
|
|
12
|
+
const explicitWrapperAriaLabel = $derived(normalizeOptionalAttribute(scrollContainerProps?.['aria-label']));
|
|
13
|
+
const explicitWrapperRole = $derived(normalizeOptionalAttribute(scrollContainerProps?.role));
|
|
14
|
+
const normalizedCaption = $derived(normalizeOptionalAttribute(caption));
|
|
15
|
+
const wrapperAriaLabel = $derived(explicitWrapperAriaLabel ??
|
|
16
|
+
(wrapperAriaLabelledBy
|
|
17
|
+
? undefined
|
|
18
|
+
: normalizedCaption
|
|
19
|
+
? `${normalizedCaption} table scroll area`
|
|
20
|
+
: undefined));
|
|
21
|
+
const wrapperRole = $derived(explicitWrapperRole ?? (wrapperAriaLabel || wrapperAriaLabelledBy ? 'region' : undefined));
|
|
22
|
+
const wrapperTabindex = $derived(normalizeOptionalTabindex(scrollContainerProps?.tabindex) ?? 0);
|
|
23
|
+
function normalizeOptionalAttribute(value) {
|
|
24
|
+
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
|
|
25
|
+
}
|
|
26
|
+
function normalizeOptionalTabindex(value) {
|
|
27
|
+
if (typeof value === 'number' && Number.isInteger(value))
|
|
28
|
+
return value;
|
|
29
|
+
if (typeof value !== 'string')
|
|
30
|
+
return undefined;
|
|
31
|
+
const normalizedValue = value.trim();
|
|
32
|
+
if (!/^-?\d+$/.test(normalizedValue))
|
|
33
|
+
return undefined;
|
|
34
|
+
return Number(normalizedValue);
|
|
35
|
+
}
|
|
10
36
|
// A native <caption> (caption-side: top) renders above the table's border box
|
|
11
37
|
// but inside the same scroll container, so a sticky <thead> pinned at top: 0
|
|
12
38
|
// would overlap it. The caption's height is not knowable in pure CSS — `1lh`
|
|
@@ -46,16 +72,34 @@ setTableContext({
|
|
|
46
72
|
});
|
|
47
73
|
</script>
|
|
48
74
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
75
|
+
{#snippet table()}
|
|
76
|
+
<table
|
|
77
|
+
{...rest}
|
|
78
|
+
class={classNames('cinder-table', className)}
|
|
79
|
+
data-cinder-sticky-header={stickyHeader || undefined}
|
|
80
|
+
data-cinder-density={density}
|
|
81
|
+
data-cinder-selectable={selectable || undefined}
|
|
82
|
+
style:--cinder-table-caption-height={normalizedCaption ? `${captionHeight}px` : undefined}
|
|
83
|
+
>
|
|
84
|
+
{#if normalizedCaption}
|
|
85
|
+
<caption class="cinder-table__caption" {@attach measureCaption}>{normalizedCaption}</caption>
|
|
86
|
+
{/if}
|
|
87
|
+
{@render children()}
|
|
88
|
+
</table>
|
|
89
|
+
{/snippet}
|
|
90
|
+
|
|
91
|
+
{#if scrollable}
|
|
92
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
93
|
+
<div
|
|
94
|
+
{...scrollContainerProps}
|
|
95
|
+
class={classNames('cinder-table-scroll', wrapperClassName)}
|
|
96
|
+
role={wrapperRole}
|
|
97
|
+
aria-label={wrapperAriaLabel}
|
|
98
|
+
aria-labelledby={wrapperAriaLabelledBy}
|
|
99
|
+
tabindex={wrapperTabindex}
|
|
100
|
+
>
|
|
101
|
+
{@render table()}
|
|
102
|
+
</div>
|
|
103
|
+
{:else}
|
|
104
|
+
{@render table()}
|
|
105
|
+
{/if}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { HTMLTableAttributes } from 'svelte/elements';
|
|
2
|
+
import type { HTMLAttributes, HTMLTableAttributes } from 'svelte/elements';
|
|
3
3
|
/** Sort direction. */
|
|
4
4
|
export type SortDirection = 'ascending' | 'descending';
|
|
5
5
|
/** Bound sort state shape. */
|
|
@@ -40,6 +40,14 @@ export type TableContext = {
|
|
|
40
40
|
/** Mirror of Table.selectable. Set synchronously at construction time. */
|
|
41
41
|
readonly selectionEnabled?: boolean;
|
|
42
42
|
};
|
|
43
|
+
/** Attributes forwarded to Table's generated scroll wrapper. */
|
|
44
|
+
export type TableScrollContainerProps = Omit<
|
|
45
|
+
HTMLAttributes<HTMLDivElement>,
|
|
46
|
+
'children' | 'class'
|
|
47
|
+
> & {
|
|
48
|
+
/** Additional class names merged with `.cinder-table-scroll`. */
|
|
49
|
+
class?: string;
|
|
50
|
+
};
|
|
43
51
|
/**
|
|
44
52
|
* Props for the Table component.
|
|
45
53
|
*
|
|
@@ -75,6 +83,24 @@ export type TableProps = Omit<HTMLTableAttributes, 'class'> & {
|
|
|
75
83
|
* Selection is strictly controlled — the consumer owns all selection state.
|
|
76
84
|
*/
|
|
77
85
|
selectable?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* When true, wraps the table in a `.cinder-table-scroll` container that
|
|
88
|
+
* enables horizontal overflow scrolling for dense or unknown-width tables.
|
|
89
|
+
* Use this instead of manually wrapping Table in `.cinder-table-scroll`.
|
|
90
|
+
*
|
|
91
|
+
* When combined with `stickyHeader`, the generated wrapper is the sticky
|
|
92
|
+
* header's scroll container. Set a bounded block size on `scrollContainerProps`
|
|
93
|
+
* when the table should scroll vertically inside that wrapper.
|
|
94
|
+
*/
|
|
95
|
+
scrollable?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Attributes forwarded to the generated `.cinder-table-scroll` wrapper when
|
|
98
|
+
* `scrollable` is true. The wrapper is focusable by default so keyboard users
|
|
99
|
+
* can scroll read-only wide tables. When the table has a caption, or when
|
|
100
|
+
* `aria-label` or `aria-labelledby` is provided here, the wrapper becomes a
|
|
101
|
+
* named `region`; pass `role` or `tabindex` here to override those defaults.
|
|
102
|
+
*/
|
|
103
|
+
scrollContainerProps?: TableScrollContainerProps;
|
|
78
104
|
/** Additional class names merged with `.cinder-table`. */
|
|
79
105
|
class?: string;
|
|
80
106
|
/** TableHeader, TableBody, etc. */
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
setTableContext
|
|
3
|
-
} from "./index.server-7pdq2w0a.js";
|
|
4
|
-
import {
|
|
5
|
-
useResizeObserver
|
|
6
|
-
} from "./index.server-9w7qdn8h.js";
|
|
7
|
-
import {
|
|
8
|
-
classNames
|
|
9
|
-
} from "./index.server-z7nvkz8v.js";
|
|
10
|
-
|
|
11
|
-
// src/components/table/table.svelte
|
|
12
|
-
import * as $ from "svelte/internal/server";
|
|
13
|
-
function Table($$renderer, $$props) {
|
|
14
|
-
$$renderer.component(($$renderer2) => {
|
|
15
|
-
let {
|
|
16
|
-
sort = undefined,
|
|
17
|
-
caption,
|
|
18
|
-
stickyHeader = false,
|
|
19
|
-
density = "comfortable",
|
|
20
|
-
selectable = false,
|
|
21
|
-
class: className,
|
|
22
|
-
children,
|
|
23
|
-
$$slots,
|
|
24
|
-
$$events,
|
|
25
|
-
...rest
|
|
26
|
-
} = $$props;
|
|
27
|
-
let captionHeight = 0;
|
|
28
|
-
const measureCaption = useResizeObserver((entries) => {
|
|
29
|
-
const entry = entries[0];
|
|
30
|
-
if (!entry)
|
|
31
|
-
return;
|
|
32
|
-
captionHeight = entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;
|
|
33
|
-
}, { box: "border-box", enabled: () => stickyHeader });
|
|
34
|
-
function onsortchange(column) {
|
|
35
|
-
if (!sort || sort.column !== column) {
|
|
36
|
-
sort = { column, direction: "ascending" };
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
sort = {
|
|
40
|
-
column,
|
|
41
|
-
direction: sort.direction === "ascending" ? "descending" : "ascending"
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
setTableContext({
|
|
45
|
-
get sort() {
|
|
46
|
-
return sort;
|
|
47
|
-
},
|
|
48
|
-
get selectionEnabled() {
|
|
49
|
-
return selectable;
|
|
50
|
-
},
|
|
51
|
-
onsortchange
|
|
52
|
-
});
|
|
53
|
-
$$renderer2.push(`<table${$.attributes({
|
|
54
|
-
...rest,
|
|
55
|
-
class: $.clsx(classNames("cinder-table", className)),
|
|
56
|
-
"data-cinder-sticky-header": stickyHeader || undefined,
|
|
57
|
-
"data-cinder-density": density,
|
|
58
|
-
"data-cinder-selectable": selectable || undefined
|
|
59
|
-
}, undefined, undefined, {
|
|
60
|
-
"--cinder-table-caption-height": caption ? `${captionHeight}px` : undefined
|
|
61
|
-
})}>`);
|
|
62
|
-
if (caption) {
|
|
63
|
-
$$renderer2.push("<!--[0-->");
|
|
64
|
-
$$renderer2.push(`<caption class="cinder-table__caption">${$.escape(caption)}</caption>`);
|
|
65
|
-
} else {
|
|
66
|
-
$$renderer2.push("<!--[-1-->");
|
|
67
|
-
}
|
|
68
|
-
$$renderer2.push(`<!--]-->`);
|
|
69
|
-
children($$renderer2);
|
|
70
|
-
$$renderer2.push(`<!----></table>`);
|
|
71
|
-
$.bind_props($$props, { sort });
|
|
72
|
-
}, Table);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export { Table };
|
|
76
|
-
|
|
77
|
-
//# debugId=41E2E5C8689DCD7D64756E2164756E21
|