@diegopluna/narvi 0.3.13 → 0.4.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/dist/components/app-shell/AppShellHeader.svelte +15 -2
- package/dist/components/app-shell/AppShellStrip.svelte +41 -0
- package/dist/components/app-shell/AppShellStrip.svelte.d.ts +10 -0
- package/dist/components/app-shell/index.d.ts +3 -1
- package/dist/components/app-shell/index.js +2 -1
- package/dist/components/approval/Approval.svelte +147 -13
- package/dist/components/approval/Approval.svelte.d.ts +22 -0
- package/dist/components/avatar/AvatarFallback.svelte +2 -1
- package/dist/components/avatar/AvatarRoot.svelte +9 -6
- package/dist/components/composer/ComposerModelPicker.svelte +15 -1
- package/dist/components/composer/ComposerTray.svelte +150 -10
- package/dist/components/composer/ComposerTray.svelte.d.ts +15 -3
- package/dist/components/heading/Heading.svelte +2 -1
- package/dist/components/markdown/MarkdownHtml.svelte +7 -3
- package/dist/components/markdown/MarkdownTable.svelte +19 -5
- package/dist/components/markdown/styles.d.ts +0 -17
- package/dist/components/markdown/styles.js +4 -20
- package/dist/components/plan/Plan.svelte +146 -28
- package/dist/components/plan/Plan.svelte.d.ts +17 -2
- package/dist/components/queued-message/QueuedMessage.svelte +185 -49
- package/dist/components/queued-message/QueuedMessage.svelte.d.ts +26 -4
- package/dist/components/rail/RailItem.svelte +20 -6
- package/dist/components/sidebar/SidebarItem.svelte +8 -3
- package/dist/components/tab-strip/TabStrip.svelte +140 -17
- package/dist/components/tab-strip/TabStrip.svelte.d.ts +23 -1
- package/dist/components/table/TableBody.svelte +27 -0
- package/dist/components/table/TableBody.svelte.d.ts +10 -0
- package/dist/components/table/TableCell.svelte +54 -0
- package/dist/components/table/TableCell.svelte.d.ts +17 -0
- package/dist/components/table/TableFoot.svelte +39 -0
- package/dist/components/table/TableFoot.svelte.d.ts +10 -0
- package/dist/components/table/TableHead.svelte +33 -0
- package/dist/components/table/TableHead.svelte.d.ts +10 -0
- package/dist/components/table/TableHeaderCell.svelte +61 -0
- package/dist/components/table/TableHeaderCell.svelte.d.ts +17 -0
- package/dist/components/table/TableRoot.svelte +144 -0
- package/dist/components/table/TableRoot.svelte.d.ts +22 -0
- package/dist/components/table/TableRow.svelte +59 -0
- package/dist/components/table/TableRow.svelte.d.ts +12 -0
- package/dist/components/table/context.d.ts +14 -0
- package/dist/components/table/context.js +15 -0
- package/dist/components/table/index.d.ts +16 -0
- package/dist/components/table/index.js +8 -0
- package/dist/components/table/styles.d.ts +56 -0
- package/dist/components/table/styles.js +44 -0
- package/dist/components/text/Text.svelte +19 -4
- package/dist/components/text/Text.svelte.d.ts +4 -2
- package/dist/components/work-fold/WorkFold.svelte +26 -1
- package/dist/components/work-fold/WorkFold.svelte.d.ts +5 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +7 -1
- package/dist/internal/markers.stylex.d.ts +4 -0
- package/dist/internal/markers.stylex.js +2 -0
- package/dist/internal/table.d.ts +29 -0
- package/dist/internal/table.js +34 -0
- package/dist/tokens.stylex.d.ts +2 -0
- package/dist/tokens.stylex.js +9 -3
- package/dist/typography.d.ts +45 -1
- package/dist/typography.js +47 -2
- package/package.json +1 -1
- package/skills/building-ui/SKILL.md +23 -23
- package/skills/building-ui/references/components.md +204 -42
- package/skills/markdown/SKILL.md +1 -1
- package/skills/setup/SKILL.md +1 -1
- package/skills/styling/SKILL.md +23 -5
- package/skills/theming/SKILL.md +1 -1
|
@@ -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;
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
import { colors, font, space } from '../../tokens.stylex.js';
|
|
7
|
+
export const cellStyles = stylex.create({
|
|
8
|
+
cell: {
|
|
9
|
+
paddingBlock: space.x1_5,
|
|
10
|
+
paddingInline: space.x3
|
|
11
|
+
},
|
|
12
|
+
// A header cell in the body or the foot, which names its row: Narvi's weight, not the browser's bold
|
|
13
|
+
header: { fontWeight: font.weightMedium },
|
|
14
|
+
start: { textAlign: 'start' },
|
|
15
|
+
center: { textAlign: 'center' },
|
|
16
|
+
end: { textAlign: 'end' },
|
|
17
|
+
// A number is never broken across lines
|
|
18
|
+
numeric: { whiteSpace: 'nowrap' },
|
|
19
|
+
// One line, cut short. The whole of it goes in a `title` or a tooltip of the app's own
|
|
20
|
+
truncate: {
|
|
21
|
+
overflow: 'hidden',
|
|
22
|
+
textOverflow: 'ellipsis',
|
|
23
|
+
whiteSpace: 'nowrap'
|
|
24
|
+
},
|
|
25
|
+
// The row's number: as narrow as it can be, quieter than what is in the row, and left out
|
|
26
|
+
// when the rows are selected and copied
|
|
27
|
+
rowNumber: {
|
|
28
|
+
width: '1%',
|
|
29
|
+
paddingInlineEnd: space.x1,
|
|
30
|
+
color: colors.textSubtle,
|
|
31
|
+
textAlign: 'end',
|
|
32
|
+
whiteSpace: 'nowrap',
|
|
33
|
+
userSelect: 'none'
|
|
34
|
+
},
|
|
35
|
+
counted: {
|
|
36
|
+
'::before': { content: 'counter(narvi-table-row)' }
|
|
37
|
+
},
|
|
38
|
+
counter: { counterIncrement: 'narvi-table-row' }
|
|
39
|
+
});
|
|
40
|
+
/** The style for a cell's alignment: `align` if given, otherwise the end for a number. */
|
|
41
|
+
export function alignOf(align, numeric) {
|
|
42
|
+
const side = align ?? (numeric ? 'end' : undefined);
|
|
43
|
+
return side ? cellStyles[side] : null;
|
|
44
|
+
}
|
|
@@ -9,10 +9,22 @@
|
|
|
9
9
|
/**
|
|
10
10
|
* What the text is. Each role is one size, weight and line height: `title`, `reading`
|
|
11
11
|
* (a reply, the prompt), `label` (what names a thing), `body` (running copy), `meta`,
|
|
12
|
-
* `caption` and `micro`.
|
|
12
|
+
* `caption` and `micro`. The figures are a number that is the point of its place:
|
|
13
|
+
* `figureTile` (one among several), `figure` (a card's) and `figurePage` (a page's).
|
|
14
|
+
* `lead` is a lede: the line under a page's title.
|
|
13
15
|
*/
|
|
14
16
|
export type TextVariant =
|
|
15
|
-
|
|
17
|
+
| 'figurePage'
|
|
18
|
+
| 'figure'
|
|
19
|
+
| 'figureTile'
|
|
20
|
+
| 'title'
|
|
21
|
+
| 'reading'
|
|
22
|
+
| 'label'
|
|
23
|
+
| 'body'
|
|
24
|
+
| 'meta'
|
|
25
|
+
| 'caption'
|
|
26
|
+
| 'micro'
|
|
27
|
+
| 'lead';
|
|
16
28
|
export type TextTone = 'default' | 'muted' | 'subtle' | 'accent' | 'danger' | 'success';
|
|
17
29
|
export type TextWeight = 'regular' | 'medium' | 'semibold';
|
|
18
30
|
/** `body` is the page's own face; `display` is the serif that large headings are set in. */
|
|
@@ -76,7 +88,7 @@
|
|
|
76
88
|
}
|
|
77
89
|
});
|
|
78
90
|
|
|
79
|
-
// A lede has no role among the
|
|
91
|
+
// A lede has no role among the others: it is a page's, set fluid between two sizes
|
|
80
92
|
const lead = stylex.create({
|
|
81
93
|
body: {
|
|
82
94
|
fontSize: 'clamp(1.125rem, 1rem + 0.5vw, 1.25rem)',
|
|
@@ -136,6 +148,9 @@
|
|
|
136
148
|
}: TextProps = $props();
|
|
137
149
|
|
|
138
150
|
const display = $derived(face === 'display');
|
|
151
|
+
const figure = $derived(
|
|
152
|
+
variant === 'figure' || variant === 'figureTile' || variant === 'figurePage'
|
|
153
|
+
);
|
|
139
154
|
</script>
|
|
140
155
|
|
|
141
156
|
<svelte:element
|
|
@@ -147,7 +162,7 @@
|
|
|
147
162
|
styles.base,
|
|
148
163
|
variant === 'lead' ? lead.body : typography[variant],
|
|
149
164
|
// A figure keeps its own size in the serif too
|
|
150
|
-
display && [styles.display,
|
|
165
|
+
display && [styles.display, !figure && displaySizes[variant as keyof typeof displaySizes]],
|
|
151
166
|
tones[tone],
|
|
152
167
|
weight && weights[weight],
|
|
153
168
|
italic && styles.italic,
|
|
@@ -4,9 +4,11 @@ import { type Sx } from '../../internal/sx.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* What the text is. Each role is one size, weight and line height: `title`, `reading`
|
|
6
6
|
* (a reply, the prompt), `label` (what names a thing), `body` (running copy), `meta`,
|
|
7
|
-
* `caption` and `micro`.
|
|
7
|
+
* `caption` and `micro`. The figures are a number that is the point of its place:
|
|
8
|
+
* `figureTile` (one among several), `figure` (a card's) and `figurePage` (a page's).
|
|
9
|
+
* `lead` is a lede: the line under a page's title.
|
|
8
10
|
*/
|
|
9
|
-
export type TextVariant = 'figure' | 'title' | 'reading' | 'label' | 'body' | 'meta' | 'caption' | 'micro' | 'lead';
|
|
11
|
+
export type TextVariant = 'figurePage' | 'figure' | 'figureTile' | 'title' | 'reading' | 'label' | 'body' | 'meta' | 'caption' | 'micro' | 'lead';
|
|
10
12
|
export type TextTone = 'default' | 'muted' | 'subtle' | 'accent' | 'danger' | 'success';
|
|
11
13
|
export type TextWeight = 'regular' | 'medium' | 'semibold';
|
|
12
14
|
/** `body` is the page's own face; `display` is the serif that large headings are set in. */
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
label: string;
|
|
22
22
|
/** Whether the work shows. Bindable. */
|
|
23
23
|
open?: boolean | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* What sits on the line after the fold's button, outside it: the turn's totals, such
|
|
26
|
+
* as a ChangeStats. It is not part of the button's name or the region's.
|
|
27
|
+
*/
|
|
28
|
+
trailing?: Snippet | undefined;
|
|
24
29
|
sx?: Sx | undefined;
|
|
25
30
|
class?: string | undefined;
|
|
26
31
|
/** The turn's working: Reasoning, Activity rows, notes. */
|
|
@@ -55,6 +60,14 @@
|
|
|
55
60
|
transitionTimingFunction: 'ease'
|
|
56
61
|
},
|
|
57
62
|
label: { display: 'inline-flex', alignItems: 'center', gap: '0.25rem' },
|
|
63
|
+
// The button and what follows it, on one line
|
|
64
|
+
line: {
|
|
65
|
+
display: 'flex',
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
alignSelf: 'flex-start',
|
|
68
|
+
gap: '0.625rem',
|
|
69
|
+
minWidth: 0
|
|
70
|
+
},
|
|
58
71
|
chevron: { display: 'grid', color: colors.textSubtle },
|
|
59
72
|
// The work is set in under the icon, its rows in line with the label
|
|
60
73
|
work: {
|
|
@@ -73,6 +86,7 @@
|
|
|
73
86
|
let {
|
|
74
87
|
label,
|
|
75
88
|
open = $bindable(false),
|
|
89
|
+
trailing,
|
|
76
90
|
sx,
|
|
77
91
|
class: className,
|
|
78
92
|
children,
|
|
@@ -82,13 +96,24 @@
|
|
|
82
96
|
const uid = $props.id();
|
|
83
97
|
</script>
|
|
84
98
|
|
|
85
|
-
|
|
99
|
+
{#snippet trigger()}
|
|
86
100
|
<Collapsible.Trigger id="{uid}-trigger" {...stylex.attrs(styles.trigger)}>
|
|
87
101
|
<Tile glyph="layers" />
|
|
88
102
|
<span {...stylex.attrs(styles.label)}
|
|
89
103
|
>{label}<span {...stylex.attrs(styles.chevron)}><Chevron {open} size={12} /></span></span
|
|
90
104
|
>
|
|
91
105
|
</Collapsible.Trigger>
|
|
106
|
+
{/snippet}
|
|
107
|
+
|
|
108
|
+
<CollapsibleRoot bind:open data-slot="work-fold" {...rest} {sx} class={className}>
|
|
109
|
+
{#if trailing}
|
|
110
|
+
<div data-slot="work-fold-line" {...stylex.attrs(styles.line)}>
|
|
111
|
+
{@render trigger()}
|
|
112
|
+
{@render trailing()}
|
|
113
|
+
</div>
|
|
114
|
+
{:else}
|
|
115
|
+
{@render trigger()}
|
|
116
|
+
{/if}
|
|
92
117
|
<CollapsibleContent role="region" aria-labelledby="{uid}-trigger" sx={styles.work}>
|
|
93
118
|
{@render children?.()}
|
|
94
119
|
</CollapsibleContent>
|
|
@@ -6,6 +6,11 @@ export type WorkFoldProps = Omit<CollapsibleRootProps, 'children' | 'open' | 'sx
|
|
|
6
6
|
label: string;
|
|
7
7
|
/** Whether the work shows. Bindable. */
|
|
8
8
|
open?: boolean | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* What sits on the line after the fold's button, outside it: the turn's totals, such
|
|
11
|
+
* as a ChangeStats. It is not part of the button's name or the region's.
|
|
12
|
+
*/
|
|
13
|
+
trailing?: Snippet | undefined;
|
|
9
14
|
sx?: Sx | undefined;
|
|
10
15
|
class?: string | undefined;
|
|
11
16
|
/** The turn's working: Reasoning, Activity rows, notes. */
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { default as Approval } from './components/approval/Approval.svelte';
|
|
|
2
2
|
export type { ApprovalAnswer, ApprovalChoice, ApprovalProps, ApprovalShortcut } from './components/approval/Approval.svelte';
|
|
3
3
|
export * as AppShell from './components/app-shell/index.js';
|
|
4
4
|
export { getAppShellContext } from './components/app-shell/index.js';
|
|
5
|
-
export type { AppShellBarProps, AppShellContext, AppShellHeaderProps, AppShellMainProps, AppShellPanelProps, AppShellPanesProps, AppShellRailProps, AppShellRootProps, AppShellSheetProps, AppShellSidebarProps, AppShellToggleProps } from './components/app-shell/index.js';
|
|
5
|
+
export type { AppShellBarProps, AppShellContext, AppShellHeaderProps, AppShellMainProps, AppShellPanelProps, AppShellPanesProps, AppShellRailProps, AppShellRootProps, AppShellSheetProps, AppShellSidebarProps, AppShellStripProps, AppShellToggleProps } from './components/app-shell/index.js';
|
|
6
6
|
export * as Activity from './components/activity/index.js';
|
|
7
7
|
export type { ActivityContentProps, ActivityIconProps, ActivityIconTone, ActivityRootProps, ActivityStepKind, ActivityStepOutputLabels, ActivityStepProps, ActivityStepStatus, ActivityThoughtProps, ActivityTriggerProps } from './components/activity/index.js';
|
|
8
8
|
export { default as Announcer } from './components/announcer/Announcer.svelte';
|
|
@@ -136,6 +136,8 @@ export type { StatusDotProps, StatusDotShape, StatusDotTone } from './components
|
|
|
136
136
|
export type { Status, StatusIndicatorProps } from './components/status-indicator/StatusIndicator.svelte';
|
|
137
137
|
export { default as Switch } from './components/switch/Switch.svelte';
|
|
138
138
|
export type { SwitchProps } from './components/switch/Switch.svelte';
|
|
139
|
+
export * as Table from './components/table/index.js';
|
|
140
|
+
export type { TableAlign, TableBodyProps, TableCellProps, TableFootProps, TableHeadProps, TableHeaderCellProps, TableRootProps, TableRowProps } from './components/table/index.js';
|
|
139
141
|
export { default as TabStrip } from './components/tab-strip/TabStrip.svelte';
|
|
140
142
|
export type { TabStripProps, TabStripTab } from './components/tab-strip/TabStrip.svelte';
|
|
141
143
|
export { default as Tabs } from './components/tabs/Tabs.svelte';
|
|
@@ -144,6 +146,7 @@ export { default as Text } from './components/text/Text.svelte';
|
|
|
144
146
|
export type { TextFace, TextProps, TextTone, TextVariant, TextWeight } from './components/text/Text.svelte';
|
|
145
147
|
export { typography } from './typography.js';
|
|
146
148
|
export type { TypeRole } from './typography.js';
|
|
149
|
+
export { monogram } from './typography.js';
|
|
147
150
|
export { visuallyHidden } from './visually-hidden.js';
|
|
148
151
|
export { focusRing } from './focus-ring.js';
|
|
149
152
|
export type { IconComponent } from './internal/icon.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Components
|
|
2
2
|
export { default as Approval } from './components/approval/Approval.svelte';
|
|
3
3
|
// Compound: <AppShell.Root>, <AppShell.Bar>, <AppShell.Rail>, <AppShell.Panes>, <AppShell.Sheet>,
|
|
4
|
-
// <AppShell.Sidebar>, <AppShell.Main>, <AppShell.Header>, <AppShell.
|
|
4
|
+
// <AppShell.Sidebar>, <AppShell.Main>, <AppShell.Header>, <AppShell.Strip>, <AppShell.Panel>,
|
|
5
|
+
// <AppShell.Toggle>
|
|
5
6
|
export * as AppShell from './components/app-shell/index.js';
|
|
6
7
|
export { getAppShellContext } from './components/app-shell/index.js';
|
|
7
8
|
// Compound: <Activity.Root>, <Activity.Trigger>, <Activity.Content>, <Activity.Step>, <Activity.Thought>,
|
|
@@ -100,11 +101,16 @@ export * as Suggestions from './components/suggestions/index.js';
|
|
|
100
101
|
export { default as StatusIndicator } from './components/status-indicator/StatusIndicator.svelte';
|
|
101
102
|
export { default as StatusDot } from './components/status-indicator/StatusDot.svelte';
|
|
102
103
|
export { default as Switch } from './components/switch/Switch.svelte';
|
|
104
|
+
// Compound: <Table.Root>, <Table.Head>, <Table.Body>, <Table.Foot>, <Table.Row>,
|
|
105
|
+
// <Table.HeaderCell>, <Table.Cell>
|
|
106
|
+
export * as Table from './components/table/index.js';
|
|
103
107
|
export { default as TabStrip } from './components/tab-strip/TabStrip.svelte';
|
|
104
108
|
export { default as Tabs } from './components/tabs/Tabs.svelte';
|
|
105
109
|
export { default as Text } from './components/text/Text.svelte';
|
|
106
110
|
// The type roles as styles, for an element of your own: `stylex.attrs(typography.caption, …)`
|
|
107
111
|
export { typography } from './typography.js';
|
|
112
|
+
// A letter inside a small mark, sized from the mark: `monogram.mark` on it, `monogram.letter` inside
|
|
113
|
+
export { monogram } from './typography.js';
|
|
108
114
|
// Hidden from sight, kept for assistive technology: `stylex.attrs(visuallyHidden)`
|
|
109
115
|
export { visuallyHidden } from './visually-hidden.js';
|
|
110
116
|
// Focus as Narvi's parts show it: `focusRing.ring` for a control of your own, `focusRing.frame`
|
|
@@ -24,3 +24,7 @@ export declare const tabStripTabMarker: Readonly<{
|
|
|
24
24
|
export declare const segmentedInputMarker: Readonly<{
|
|
25
25
|
readonly marker: stylex.StyleXClassNameFor<"marker", symbol>;
|
|
26
26
|
}>;
|
|
27
|
+
/** Placed on AppShell.Strip, so the header that holds it takes a band's colour and no line. */
|
|
28
|
+
export declare const appShellStripMarker: Readonly<{
|
|
29
|
+
readonly marker: stylex.StyleXClassNameFor<"marker", symbol>;
|
|
30
|
+
}>;
|
|
@@ -14,3 +14,5 @@ export const sidebarItemMarker = stylex.defineMarker();
|
|
|
14
14
|
export const tabStripTabMarker = stylex.defineMarker();
|
|
15
15
|
/** A SegmentedControl's radio, so the label after it follows its state. */
|
|
16
16
|
export const segmentedInputMarker = stylex.defineMarker();
|
|
17
|
+
/** Placed on AppShell.Strip, so the header that holds it takes a band's colour and no line. */
|
|
18
|
+
export const appShellStripMarker = stylex.defineMarker();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a table of Narvi's looks like, whoever draws it: Markdown's, from a document, and
|
|
3
|
+
* `Table`'s, from data. Each adds only its own room and size: Markdown's in `em`, to take the
|
|
4
|
+
* size of the document, and Table's from the spacing scale.
|
|
5
|
+
*/
|
|
6
|
+
import * as stylex from '@stylexjs/stylex';
|
|
7
|
+
export declare const tableStyles: Readonly<{
|
|
8
|
+
readonly table: Readonly<{
|
|
9
|
+
readonly width: stylex.StyleXClassNameFor<"width", "max-content">;
|
|
10
|
+
readonly minWidth: stylex.StyleXClassNameFor<"minWidth", "100%">;
|
|
11
|
+
readonly fontVariantNumeric: stylex.StyleXClassNameFor<"fontVariantNumeric", "tabular-nums">;
|
|
12
|
+
}>;
|
|
13
|
+
readonly cell: Readonly<{
|
|
14
|
+
readonly textAlign: stylex.StyleXClassNameFor<"textAlign", "start">;
|
|
15
|
+
readonly verticalAlign: stylex.StyleXClassNameFor<"verticalAlign", "top">;
|
|
16
|
+
readonly maxWidth: stylex.StyleXClassNameFor<"maxWidth", "24rem">;
|
|
17
|
+
readonly overflowWrap: stylex.StyleXClassNameFor<"overflowWrap", "break-word">;
|
|
18
|
+
readonly borderBlockStartWidth: stylex.StyleXClassNameFor<"borderBlockStartWidth", "1px">;
|
|
19
|
+
readonly borderBlockStartStyle: stylex.StyleXClassNameFor<"borderBlockStartStyle", "solid">;
|
|
20
|
+
readonly borderBlockStartColor: stylex.StyleXClassNameFor<"borderBlockStartColor", string>;
|
|
21
|
+
}>;
|
|
22
|
+
readonly headCell: Readonly<{
|
|
23
|
+
readonly borderBlockStartWidth: stylex.StyleXClassNameFor<"borderBlockStartWidth", 0>;
|
|
24
|
+
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string>;
|
|
25
|
+
readonly color: stylex.StyleXClassNameFor<"color", string>;
|
|
26
|
+
readonly fontWeight: stylex.StyleXClassNameFor<"fontWeight", string>;
|
|
27
|
+
readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
|
|
28
|
+
}>;
|
|
29
|
+
}>;
|