@diegopluna/narvi 0.3.12 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/components/app-shell/AppShellHeader.svelte +15 -2
  2. package/dist/components/app-shell/AppShellStrip.svelte +41 -0
  3. package/dist/components/app-shell/AppShellStrip.svelte.d.ts +10 -0
  4. package/dist/components/app-shell/index.d.ts +3 -1
  5. package/dist/components/app-shell/index.js +2 -1
  6. package/dist/components/approval/Approval.svelte +147 -13
  7. package/dist/components/approval/Approval.svelte.d.ts +22 -0
  8. package/dist/components/avatar/AvatarFallback.svelte +2 -1
  9. package/dist/components/avatar/AvatarRoot.svelte +9 -6
  10. package/dist/components/composer/ComposerTray.svelte +150 -10
  11. package/dist/components/composer/ComposerTray.svelte.d.ts +15 -3
  12. package/dist/components/heading/Heading.svelte +2 -1
  13. package/dist/components/kbd/Kbd.svelte +2 -0
  14. package/dist/components/markdown/MarkdownHtml.svelte +7 -3
  15. package/dist/components/markdown/MarkdownTable.svelte +19 -5
  16. package/dist/components/markdown/styles.d.ts +0 -17
  17. package/dist/components/markdown/styles.js +4 -20
  18. package/dist/components/plan/Plan.svelte +146 -28
  19. package/dist/components/plan/Plan.svelte.d.ts +17 -2
  20. package/dist/components/queued-message/QueuedMessage.svelte +178 -49
  21. package/dist/components/queued-message/QueuedMessage.svelte.d.ts +25 -4
  22. package/dist/components/tab-strip/TabStrip.svelte +120 -12
  23. package/dist/components/tab-strip/TabStrip.svelte.d.ts +17 -0
  24. package/dist/components/table/TableBody.svelte +27 -0
  25. package/dist/components/table/TableBody.svelte.d.ts +10 -0
  26. package/dist/components/table/TableCell.svelte +54 -0
  27. package/dist/components/table/TableCell.svelte.d.ts +17 -0
  28. package/dist/components/table/TableFoot.svelte +39 -0
  29. package/dist/components/table/TableFoot.svelte.d.ts +10 -0
  30. package/dist/components/table/TableHead.svelte +33 -0
  31. package/dist/components/table/TableHead.svelte.d.ts +10 -0
  32. package/dist/components/table/TableHeaderCell.svelte +61 -0
  33. package/dist/components/table/TableHeaderCell.svelte.d.ts +17 -0
  34. package/dist/components/table/TableRoot.svelte +144 -0
  35. package/dist/components/table/TableRoot.svelte.d.ts +22 -0
  36. package/dist/components/table/TableRow.svelte +59 -0
  37. package/dist/components/table/TableRow.svelte.d.ts +12 -0
  38. package/dist/components/table/context.d.ts +14 -0
  39. package/dist/components/table/context.js +15 -0
  40. package/dist/components/table/index.d.ts +16 -0
  41. package/dist/components/table/index.js +8 -0
  42. package/dist/components/table/styles.d.ts +56 -0
  43. package/dist/components/table/styles.js +44 -0
  44. package/dist/components/text/Text.svelte +19 -4
  45. package/dist/components/text/Text.svelte.d.ts +4 -2
  46. package/dist/components/work-fold/WorkFold.svelte +26 -1
  47. package/dist/components/work-fold/WorkFold.svelte.d.ts +5 -0
  48. package/dist/index.d.ts +4 -1
  49. package/dist/index.js +7 -1
  50. package/dist/internal/markers.stylex.d.ts +4 -0
  51. package/dist/internal/markers.stylex.js +2 -0
  52. package/dist/internal/table.d.ts +29 -0
  53. package/dist/internal/table.js +34 -0
  54. package/dist/tokens.stylex.d.ts +2 -0
  55. package/dist/tokens.stylex.js +9 -3
  56. package/dist/typography.d.ts +40 -1
  57. package/dist/typography.js +42 -2
  58. package/package.json +1 -1
  59. package/skills/building-ui/SKILL.md +22 -22
  60. package/skills/building-ui/references/components.md +196 -42
  61. package/skills/markdown/SKILL.md +1 -1
  62. package/skills/setup/SKILL.md +1 -1
  63. package/skills/styling/SKILL.md +21 -5
  64. package/skills/theming/SKILL.md +1 -1
@@ -0,0 +1,27 @@
1
+ <!-- The rows of a Table. Its rows are counted from one, for `rowNumbers`. -->
2
+ <script lang="ts" module>
3
+ import * as stylex from '@stylexjs/stylex';
4
+ import type { Snippet } from 'svelte';
5
+ import type { HTMLAttributes } from 'svelte/elements';
6
+ import { attrs, type Sx } from '../../internal/sx.js';
7
+ import { setTableSection } from './context.js';
8
+
9
+ export type TableBodyProps = Omit<HTMLAttributes<HTMLTableSectionElement>, 'children'> & {
10
+ sx?: Sx | undefined;
11
+ children?: Snippet | undefined;
12
+ };
13
+
14
+ const styles = stylex.create({
15
+ body: { counterReset: 'narvi-table-row' }
16
+ });
17
+ </script>
18
+
19
+ <script lang="ts">
20
+ let { sx, class: className, children, ...rest }: TableBodyProps = $props();
21
+
22
+ setTableSection('body');
23
+ </script>
24
+
25
+ <tbody data-slot="table-body" {...rest} {...attrs([styles.body, sx], className)}>
26
+ {@render children?.()}
27
+ </tbody>
@@ -0,0 +1,10 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ export type TableBodyProps = Omit<HTMLAttributes<HTMLTableSectionElement>, 'children'> & {
5
+ sx?: Sx | undefined;
6
+ children?: Snippet | undefined;
7
+ };
8
+ declare const TableBody: import("svelte").Component<TableBodyProps, {}, "">;
9
+ type TableBody = ReturnType<typeof TableBody>;
10
+ export default TableBody;
@@ -0,0 +1,54 @@
1
+ <!-- A cell of a Table. A number sits at the end of its column, its digits lined up. -->
2
+ <script lang="ts" module>
3
+ import type { Snippet } from 'svelte';
4
+ import type { HTMLTdAttributes } from 'svelte/elements';
5
+ import { attrs, type Sx } from '../../internal/sx.js';
6
+ import { tableStyles } from '../../internal/table.js';
7
+ import { getTableContext } from './context.js';
8
+ import { alignOf, cellStyles, type TableAlign } from './styles.js';
9
+
10
+ export type TableCellProps = Omit<HTMLTdAttributes, 'children'> & {
11
+ /** Where its content sits. A numeric cell's sits at the end. */
12
+ align?: TableAlign | undefined;
13
+ /** A number: at the end, on one line. */
14
+ numeric?: boolean | undefined;
15
+ /** One line, cut short with an ellipsis. Defaults to the table's. */
16
+ truncate?: boolean | undefined;
17
+ sx?: Sx | undefined;
18
+ children?: Snippet | undefined;
19
+ };
20
+ </script>
21
+
22
+ <script lang="ts">
23
+ let {
24
+ align,
25
+ numeric = false,
26
+ truncate,
27
+ sx,
28
+ class: className,
29
+ children,
30
+ ...rest
31
+ }: TableCellProps = $props();
32
+
33
+ const table = getTableContext();
34
+ const cut = $derived(truncate ?? table?.truncate ?? false);
35
+ </script>
36
+
37
+ <td
38
+ data-slot="table-cell"
39
+ dir="auto"
40
+ {...rest}
41
+ {...attrs(
42
+ [
43
+ tableStyles.cell,
44
+ cellStyles.cell,
45
+ numeric && cellStyles.numeric,
46
+ alignOf(align, numeric),
47
+ cut && cellStyles.truncate,
48
+ sx
49
+ ],
50
+ className
51
+ )}
52
+ >
53
+ {@render children?.()}
54
+ </td>
@@ -0,0 +1,17 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLTdAttributes } from 'svelte/elements';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ import { type TableAlign } from './styles.js';
5
+ export type TableCellProps = Omit<HTMLTdAttributes, 'children'> & {
6
+ /** Where its content sits. A numeric cell's sits at the end. */
7
+ align?: TableAlign | undefined;
8
+ /** A number: at the end, on one line. */
9
+ numeric?: boolean | undefined;
10
+ /** One line, cut short with an ellipsis. Defaults to the table's. */
11
+ truncate?: boolean | undefined;
12
+ sx?: Sx | undefined;
13
+ children?: Snippet | undefined;
14
+ };
15
+ declare const TableCell: import("svelte").Component<TableCellProps, {}, "">;
16
+ type TableCell = ReturnType<typeof TableCell>;
17
+ export default TableCell;
@@ -0,0 +1,39 @@
1
+ <!--
2
+ The foot of a Table: a row of totals, kept at the bottom as the rows scroll over it. What is
3
+ said about the table as a whole, such as how many rows it has, goes under it, not here.
4
+ -->
5
+ <script lang="ts" module>
6
+ import * as stylex from '@stylexjs/stylex';
7
+ import type { Snippet } from 'svelte';
8
+ import type { HTMLAttributes } from 'svelte/elements';
9
+ import { attrs, type Sx } from '../../internal/sx.js';
10
+ import { colors, font } from '../../tokens.stylex.js';
11
+ import { setTableSection } from './context.js';
12
+
13
+ export type TableFootProps = Omit<HTMLAttributes<HTMLTableSectionElement>, 'children'> & {
14
+ sx?: Sx | undefined;
15
+ children?: Snippet | undefined;
16
+ };
17
+
18
+ const styles = stylex.create({
19
+ // Opaque in the frame's colour; the hairline over its row is all that sets it apart
20
+ foot: {
21
+ position: 'sticky',
22
+ insetBlockEnd: 0,
23
+ zIndex: 1,
24
+ backgroundColor: 'inherit',
25
+ color: colors.text,
26
+ fontWeight: font.weightMedium
27
+ }
28
+ });
29
+ </script>
30
+
31
+ <script lang="ts">
32
+ let { sx, class: className, children, ...rest }: TableFootProps = $props();
33
+
34
+ setTableSection('foot');
35
+ </script>
36
+
37
+ <tfoot data-slot="table-foot" {...rest} {...attrs([styles.foot, sx], className)}>
38
+ {@render children?.()}
39
+ </tfoot>
@@ -0,0 +1,10 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ export type TableFootProps = Omit<HTMLAttributes<HTMLTableSectionElement>, 'children'> & {
5
+ sx?: Sx | undefined;
6
+ children?: Snippet | undefined;
7
+ };
8
+ declare const TableFoot: import("svelte").Component<TableFootProps, {}, "">;
9
+ type TableFoot = ReturnType<typeof TableFoot>;
10
+ export default TableFoot;
@@ -0,0 +1,33 @@
1
+ <!-- The head of a Table: its rows of column names, kept at the top as the rows scroll under it. -->
2
+ <script lang="ts" module>
3
+ import * as stylex from '@stylexjs/stylex';
4
+ import type { Snippet } from 'svelte';
5
+ import type { HTMLAttributes } from 'svelte/elements';
6
+ import { attrs, type Sx } from '../../internal/sx.js';
7
+ import { setTableSection } from './context.js';
8
+
9
+ export type TableHeadProps = Omit<HTMLAttributes<HTMLTableSectionElement>, 'children'> & {
10
+ sx?: Sx | undefined;
11
+ children?: Snippet | undefined;
12
+ };
13
+
14
+ const styles = stylex.create({
15
+ // Opaque in the frame's colour, under the head's own fill
16
+ head: {
17
+ position: 'sticky',
18
+ insetBlockStart: 0,
19
+ zIndex: 1,
20
+ backgroundColor: 'inherit'
21
+ }
22
+ });
23
+ </script>
24
+
25
+ <script lang="ts">
26
+ let { sx, class: className, children, ...rest }: TableHeadProps = $props();
27
+
28
+ setTableSection('head');
29
+ </script>
30
+
31
+ <thead data-slot="table-head" {...rest} {...attrs([styles.head, sx], className)}>
32
+ {@render children?.()}
33
+ </thead>
@@ -0,0 +1,10 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ export type TableHeadProps = Omit<HTMLAttributes<HTMLTableSectionElement>, 'children'> & {
5
+ sx?: Sx | undefined;
6
+ children?: Snippet | undefined;
7
+ };
8
+ declare const TableHead: import("svelte").Component<TableHeadProps, {}, "">;
9
+ type TableHead = ReturnType<typeof TableHead>;
10
+ export default TableHead;
@@ -0,0 +1,61 @@
1
+ <!--
2
+ A header cell of a Table: a column's name in the head, or what names a row at its start in
3
+ the body. It says which with `scope`, which it sets from where it is.
4
+ -->
5
+ <script lang="ts" module>
6
+ import type { Snippet } from 'svelte';
7
+ import type { HTMLThAttributes } from 'svelte/elements';
8
+ import { attrs, type Sx } from '../../internal/sx.js';
9
+ import { tableStyles } from '../../internal/table.js';
10
+ import { getTableContext, getTableSection } from './context.js';
11
+ import { alignOf, cellStyles, type TableAlign } from './styles.js';
12
+
13
+ export type TableHeaderCellProps = Omit<HTMLThAttributes, 'children'> & {
14
+ /** Where its words sit. A numeric column's sit at the end. */
15
+ align?: TableAlign | undefined;
16
+ /** Names a column of numbers: it sits at the end, over them. */
17
+ numeric?: boolean | undefined;
18
+ /** One line, cut short with an ellipsis. Defaults to the table's. */
19
+ truncate?: boolean | undefined;
20
+ sx?: Sx | undefined;
21
+ children?: Snippet | undefined;
22
+ };
23
+ </script>
24
+
25
+ <script lang="ts">
26
+ let {
27
+ align,
28
+ numeric = false,
29
+ truncate,
30
+ scope,
31
+ sx,
32
+ class: className,
33
+ children,
34
+ ...rest
35
+ }: TableHeaderCellProps = $props();
36
+
37
+ const table = getTableContext();
38
+ const section = getTableSection();
39
+ const cut = $derived(truncate ?? table?.truncate ?? false);
40
+ </script>
41
+
42
+ <th
43
+ data-slot="table-header-cell"
44
+ scope={scope ?? (section === 'head' ? 'col' : 'row')}
45
+ dir="auto"
46
+ {...rest}
47
+ {...attrs(
48
+ [
49
+ tableStyles.cell,
50
+ cellStyles.cell,
51
+ section === 'head' ? tableStyles.headCell : cellStyles.header,
52
+ numeric && cellStyles.numeric,
53
+ alignOf(align, numeric),
54
+ cut && cellStyles.truncate,
55
+ sx
56
+ ],
57
+ className
58
+ )}
59
+ >
60
+ {@render children?.()}
61
+ </th>
@@ -0,0 +1,17 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLThAttributes } from 'svelte/elements';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ import { type TableAlign } from './styles.js';
5
+ export type TableHeaderCellProps = Omit<HTMLThAttributes, 'children'> & {
6
+ /** Where its words sit. A numeric column's sit at the end. */
7
+ align?: TableAlign | undefined;
8
+ /** Names a column of numbers: it sits at the end, over them. */
9
+ numeric?: boolean | undefined;
10
+ /** One line, cut short with an ellipsis. Defaults to the table's. */
11
+ truncate?: boolean | undefined;
12
+ sx?: Sx | undefined;
13
+ children?: Snippet | undefined;
14
+ };
15
+ declare const TableHeaderCell: import("svelte").Component<TableHeaderCellProps, {}, "">;
16
+ type TableHeaderCell = ReturnType<typeof TableHeaderCell>;
17
+ export default TableHeaderCell;
@@ -0,0 +1,144 @@
1
+ <!--
2
+ A table of data in a frame of its own, which scrolls both ways inside it: sideways when the
3
+ columns are wider than the frame, and down when the frame is given a height, with the head
4
+ and the foot kept in view. While it scrolls, the frame takes keyboard focus and is named, so
5
+ a keyboard can scroll it too.
6
+ -->
7
+ <script lang="ts" module>
8
+ import * as stylex from '@stylexjs/stylex';
9
+ import type { Snippet } from 'svelte';
10
+ import type { HTMLAttributes } from 'svelte/elements';
11
+ import { shared } from '../../internal/shared.js';
12
+ import { attrs, type Sx } from '../../internal/sx.js';
13
+ import { tableStyles } from '../../internal/table.js';
14
+ import { colors, radius } from '../../tokens.stylex.js';
15
+ import { typography } from '../../typography.js';
16
+ import { setTableContext } from './context.js';
17
+
18
+ export type TableRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
19
+ /** What the table holds, said by a screen reader: "Usage by provider". */
20
+ label: string;
21
+ /** Starts each row with its number, in a column of its own. */
22
+ rowNumbers?: boolean | undefined;
23
+ /** What the column of numbers is called, for a screen reader. */
24
+ rowNumberLabel?: string | undefined;
25
+ /** Keeps every cell to one line, cut short with an ellipsis. A cell's own `truncate` wins. */
26
+ truncate?: boolean | undefined;
27
+ /** On a raised surface, such as a card: the head and foot are opaque in its colour. */
28
+ raised?: boolean | undefined;
29
+ /** Styles for the `<table>` itself. */
30
+ tableSx?: Sx | undefined;
31
+ sx?: Sx | undefined;
32
+ children?: Snippet | undefined;
33
+ };
34
+
35
+ const styles = stylex.create({
36
+ // The edge is drawn over what scrolls, so a head kept in view never covers it
37
+ root: {
38
+ position: 'relative',
39
+ isolation: 'isolate',
40
+ display: 'flex',
41
+ flexDirection: 'column',
42
+ minWidth: 0,
43
+ borderRadius: radius.control,
44
+ '::after': {
45
+ content: '""',
46
+ position: 'absolute',
47
+ inset: 0,
48
+ zIndex: 2,
49
+ borderRadius: 'inherit',
50
+ boxShadow: `inset 0 0 0 1px ${colors.border}`,
51
+ pointerEvents: 'none',
52
+ // The shadow is removed in forced-colours mode; the outline is the edge there
53
+ outlineStyle: 'solid',
54
+ outlineWidth: '1px',
55
+ outlineColor: 'transparent',
56
+ outlineOffset: '-1px'
57
+ }
58
+ },
59
+ // It scrolls both ways, so the head can stay at its top. Its colour is the page's, under
60
+ // the head and the foot, so rows do not show through them as they pass
61
+ scroller: {
62
+ flexGrow: 1,
63
+ minHeight: 0,
64
+ overflow: 'auto',
65
+ borderRadius: 'inherit',
66
+ backgroundColor: colors.bg
67
+ },
68
+ raised: { backgroundColor: colors.bgRaised },
69
+ table: {
70
+ borderCollapse: 'separate',
71
+ borderSpacing: 0,
72
+ backgroundColor: 'inherit'
73
+ }
74
+ });
75
+ </script>
76
+
77
+ <script lang="ts">
78
+ let {
79
+ label,
80
+ rowNumbers = false,
81
+ rowNumberLabel = 'Row',
82
+ truncate = false,
83
+ raised = false,
84
+ tableSx,
85
+ sx,
86
+ class: className,
87
+ children,
88
+ ...rest
89
+ }: TableRootProps = $props();
90
+
91
+ setTableContext({
92
+ get rowNumbers() {
93
+ return rowNumbers;
94
+ },
95
+ get rowNumberLabel() {
96
+ return rowNumberLabel;
97
+ },
98
+ get truncate() {
99
+ return truncate;
100
+ }
101
+ });
102
+
103
+ let scroller = $state<HTMLDivElement>();
104
+ let table = $state<HTMLTableElement>();
105
+ /** Whether there is more than the frame shows, either way. */
106
+ let scrolls = $state(false);
107
+
108
+ $effect(() => {
109
+ const frame = scroller;
110
+ const content = table;
111
+ if (!frame || !content || typeof ResizeObserver === 'undefined') return;
112
+ // The frame changes size with the page, and the table with its rows: either can make
113
+ // it scroll. Read after layout, so asking costs no layout of its own
114
+ const observer = new ResizeObserver(() => {
115
+ scrolls =
116
+ frame.scrollWidth > frame.clientWidth + 1 || frame.scrollHeight > frame.clientHeight + 1;
117
+ });
118
+ observer.observe(frame);
119
+ observer.observe(content);
120
+ return () => observer.disconnect();
121
+ });
122
+ </script>
123
+
124
+ <div data-slot="table" {...rest} {...attrs([styles.root, sx], className)}>
125
+ <!-- A region with a name, and a tab stop, only while there is something to scroll to: a
126
+ keyboard scrolls it with the arrow keys once it has focus -->
127
+ <!-- svelte-ignore a11y_no_noninteractive_tabindex -->
128
+ <div
129
+ bind:this={scroller}
130
+ data-slot="table-scroller"
131
+ role={scrolls ? 'region' : undefined}
132
+ aria-label={scrolls ? label : undefined}
133
+ tabindex={scrolls ? 0 : undefined}
134
+ {...attrs([styles.scroller, raised && styles.raised, shared.focusable])}
135
+ >
136
+ <table
137
+ bind:this={table}
138
+ aria-label={label}
139
+ {...attrs([tableStyles.table, typography.body, styles.table, tableSx])}
140
+ >
141
+ {@render children?.()}
142
+ </table>
143
+ </div>
144
+ </div>
@@ -0,0 +1,22 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ export type TableRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
5
+ /** What the table holds, said by a screen reader: "Usage by provider". */
6
+ label: string;
7
+ /** Starts each row with its number, in a column of its own. */
8
+ rowNumbers?: boolean | undefined;
9
+ /** What the column of numbers is called, for a screen reader. */
10
+ rowNumberLabel?: string | undefined;
11
+ /** Keeps every cell to one line, cut short with an ellipsis. A cell's own `truncate` wins. */
12
+ truncate?: boolean | undefined;
13
+ /** On a raised surface, such as a card: the head and foot are opaque in its colour. */
14
+ raised?: boolean | undefined;
15
+ /** Styles for the `<table>` itself. */
16
+ tableSx?: Sx | undefined;
17
+ sx?: Sx | undefined;
18
+ children?: Snippet | undefined;
19
+ };
20
+ declare const TableRoot: import("svelte").Component<TableRootProps, {}, "">;
21
+ type TableRoot = ReturnType<typeof TableRoot>;
22
+ export default TableRoot;
@@ -0,0 +1,59 @@
1
+ <!--
2
+ A row of a Table. With the table's `rowNumbers`, it starts with its number: counted from one
3
+ down the body, or `number` when the rows shown are not the first.
4
+ -->
5
+ <script lang="ts" module>
6
+ import type { Snippet } from 'svelte';
7
+ import type { HTMLAttributes } from 'svelte/elements';
8
+ import { attrs, type Sx } from '../../internal/sx.js';
9
+ import { tableStyles } from '../../internal/table.js';
10
+ import { visuallyHidden } from '../../visually-hidden.js';
11
+ import { getTableContext, getTableSection } from './context.js';
12
+ import { cellStyles } from './styles.js';
13
+
14
+ export type TableRowProps = Omit<HTMLAttributes<HTMLTableRowElement>, 'children'> & {
15
+ /** The row's number, with the table's `rowNumbers`, in place of its place in the body. */
16
+ number?: number | undefined;
17
+ sx?: Sx | undefined;
18
+ children?: Snippet | undefined;
19
+ };
20
+ </script>
21
+
22
+ <script lang="ts">
23
+ let { number, sx, class: className, children, ...rest }: TableRowProps = $props();
24
+
25
+ const table = getTableContext();
26
+ const section = getTableSection();
27
+ const numbered = $derived(table?.rowNumbers === true);
28
+ </script>
29
+
30
+ <tr
31
+ data-slot="table-row"
32
+ {...rest}
33
+ {...attrs([section === 'body' && numbered && cellStyles.counter, sx], className)}
34
+ >
35
+ {#if numbered}
36
+ {#if section === 'head'}
37
+ <th
38
+ scope="col"
39
+ {...attrs([tableStyles.cell, cellStyles.cell, tableStyles.headCell, cellStyles.rowNumber])}
40
+ >
41
+ <span {...attrs([visuallyHidden])}>{table?.rowNumberLabel}</span>
42
+ </th>
43
+ {:else if section === 'body'}
44
+ <td
45
+ {...attrs([
46
+ tableStyles.cell,
47
+ cellStyles.cell,
48
+ cellStyles.rowNumber,
49
+ number === undefined && cellStyles.counted
50
+ ])}
51
+ >
52
+ {number?.toLocaleString()}
53
+ </td>
54
+ {:else}
55
+ <td {...attrs([tableStyles.cell, cellStyles.cell, cellStyles.rowNumber])}></td>
56
+ {/if}
57
+ {/if}
58
+ {@render children?.()}
59
+ </tr>
@@ -0,0 +1,12 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ export type TableRowProps = Omit<HTMLAttributes<HTMLTableRowElement>, 'children'> & {
5
+ /** The row's number, with the table's `rowNumbers`, in place of its place in the body. */
6
+ number?: number | undefined;
7
+ sx?: Sx | undefined;
8
+ children?: Snippet | undefined;
9
+ };
10
+ declare const TableRow: import("svelte").Component<TableRowProps, {}, "">;
11
+ type TableRow = ReturnType<typeof TableRow>;
12
+ export default TableRow;
@@ -0,0 +1,14 @@
1
+ export type TableContext = {
2
+ /** Whether each row starts with its number. */
3
+ readonly rowNumbers: boolean;
4
+ /** What the column of numbers is called, for a screen reader. */
5
+ readonly rowNumberLabel: string;
6
+ /** Whether a cell keeps to one line, cut short with an ellipsis. */
7
+ readonly truncate: boolean;
8
+ };
9
+ /** The part of the table a row is in. */
10
+ export type TableSection = 'head' | 'body' | 'foot';
11
+ export declare function setTableContext(context: TableContext): void;
12
+ export declare function getTableContext(): TableContext | undefined;
13
+ export declare function setTableSection(section: TableSection): void;
14
+ export declare function getTableSection(): TableSection;
@@ -0,0 +1,15 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ const ROOT = Symbol('narvi.table');
3
+ const SECTION = Symbol('narvi.table.section');
4
+ export function setTableContext(context) {
5
+ setContext(ROOT, context);
6
+ }
7
+ export function getTableContext() {
8
+ return getContext(ROOT);
9
+ }
10
+ export function setTableSection(section) {
11
+ setContext(SECTION, section);
12
+ }
13
+ export function getTableSection() {
14
+ return getContext(SECTION) ?? 'body';
15
+ }
@@ -0,0 +1,16 @@
1
+ import Body from './TableBody.svelte';
2
+ import Cell from './TableCell.svelte';
3
+ import Foot from './TableFoot.svelte';
4
+ import Head from './TableHead.svelte';
5
+ import HeaderCell from './TableHeaderCell.svelte';
6
+ import Root from './TableRoot.svelte';
7
+ import Row from './TableRow.svelte';
8
+ export { Root, Head, Body, Foot, Row, HeaderCell, Cell };
9
+ export type { TableBodyProps } from './TableBody.svelte';
10
+ export type { TableCellProps } from './TableCell.svelte';
11
+ export type { TableFootProps } from './TableFoot.svelte';
12
+ export type { TableHeadProps } from './TableHead.svelte';
13
+ export type { TableHeaderCellProps } from './TableHeaderCell.svelte';
14
+ export type { TableRootProps } from './TableRoot.svelte';
15
+ export type { TableRowProps } from './TableRow.svelte';
16
+ export type { TableAlign } from './styles.js';
@@ -0,0 +1,8 @@
1
+ import Body from './TableBody.svelte';
2
+ import Cell from './TableCell.svelte';
3
+ import Foot from './TableFoot.svelte';
4
+ import Head from './TableHead.svelte';
5
+ import HeaderCell from './TableHeaderCell.svelte';
6
+ import Root from './TableRoot.svelte';
7
+ import Row from './TableRow.svelte';
8
+ export { Root, Head, Body, Foot, Row, HeaderCell, Cell };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The cells of a Table, over the look it shares with Markdown's (`internal/table.ts`): their
3
+ * room, from the spacing scale, how they line up, and the column of row numbers.
4
+ */
5
+ import * as stylex from '@stylexjs/stylex';
6
+ export type TableAlign = 'start' | 'center' | 'end';
7
+ export declare const cellStyles: Readonly<{
8
+ readonly cell: Readonly<{
9
+ readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", string>;
10
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
11
+ }>;
12
+ readonly header: Readonly<{
13
+ readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", string>;
14
+ }>;
15
+ readonly start: Readonly<{
16
+ readonly textAlign: stylex.StyleXClassNameFor<"textAlign", "start">;
17
+ }>;
18
+ readonly center: Readonly<{
19
+ readonly textAlign: stylex.StyleXClassNameFor<"textAlign", "center">;
20
+ }>;
21
+ readonly end: Readonly<{
22
+ readonly textAlign: stylex.StyleXClassNameFor<"textAlign", "end">;
23
+ }>;
24
+ readonly numeric: Readonly<{
25
+ readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
26
+ }>;
27
+ readonly truncate: Readonly<{
28
+ readonly overflow: stylex.StyleXClassNameFor<"overflow", "hidden">;
29
+ readonly textOverflow: stylex.StyleXClassNameFor<"textOverflow", "ellipsis">;
30
+ readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
31
+ }>;
32
+ readonly rowNumber: Readonly<{
33
+ readonly width: stylex.StyleXClassNameFor<"width", "1%">;
34
+ readonly paddingInlineEnd: stylex.StyleXClassNameFor<"paddingInlineEnd", string>;
35
+ readonly color: stylex.StyleXClassNameFor<"color", string>;
36
+ readonly textAlign: stylex.StyleXClassNameFor<"textAlign", "end">;
37
+ readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
38
+ readonly userSelect: stylex.StyleXClassNameFor<"userSelect", "none">;
39
+ }>;
40
+ readonly counted: Readonly<{
41
+ readonly '::before': stylex.StyleXClassNameFor<"::before", {
42
+ readonly content: "counter(narvi-table-row)";
43
+ }>;
44
+ }>;
45
+ readonly counter: Readonly<{
46
+ readonly counterIncrement: stylex.StyleXClassNameFor<"counterIncrement", "narvi-table-row">;
47
+ }>;
48
+ }>;
49
+ /** The style for a cell's alignment: `align` if given, otherwise the end for a number. */
50
+ export declare function alignOf(align: TableAlign | undefined, numeric: boolean): Readonly<{
51
+ readonly textAlign: stylex.StyleXClassNameFor<"textAlign", "start">;
52
+ }> | Readonly<{
53
+ readonly textAlign: stylex.StyleXClassNameFor<"textAlign", "center">;
54
+ }> | Readonly<{
55
+ readonly textAlign: stylex.StyleXClassNameFor<"textAlign", "end">;
56
+ }> | null;