@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.
Files changed (66) 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/ComposerModelPicker.svelte +15 -1
  11. package/dist/components/composer/ComposerTray.svelte +150 -10
  12. package/dist/components/composer/ComposerTray.svelte.d.ts +15 -3
  13. package/dist/components/heading/Heading.svelte +2 -1
  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 +185 -49
  21. package/dist/components/queued-message/QueuedMessage.svelte.d.ts +26 -4
  22. package/dist/components/rail/RailItem.svelte +20 -6
  23. package/dist/components/sidebar/SidebarItem.svelte +8 -3
  24. package/dist/components/tab-strip/TabStrip.svelte +140 -17
  25. package/dist/components/tab-strip/TabStrip.svelte.d.ts +23 -1
  26. package/dist/components/table/TableBody.svelte +27 -0
  27. package/dist/components/table/TableBody.svelte.d.ts +10 -0
  28. package/dist/components/table/TableCell.svelte +54 -0
  29. package/dist/components/table/TableCell.svelte.d.ts +17 -0
  30. package/dist/components/table/TableFoot.svelte +39 -0
  31. package/dist/components/table/TableFoot.svelte.d.ts +10 -0
  32. package/dist/components/table/TableHead.svelte +33 -0
  33. package/dist/components/table/TableHead.svelte.d.ts +10 -0
  34. package/dist/components/table/TableHeaderCell.svelte +61 -0
  35. package/dist/components/table/TableHeaderCell.svelte.d.ts +17 -0
  36. package/dist/components/table/TableRoot.svelte +144 -0
  37. package/dist/components/table/TableRoot.svelte.d.ts +22 -0
  38. package/dist/components/table/TableRow.svelte +59 -0
  39. package/dist/components/table/TableRow.svelte.d.ts +12 -0
  40. package/dist/components/table/context.d.ts +14 -0
  41. package/dist/components/table/context.js +15 -0
  42. package/dist/components/table/index.d.ts +16 -0
  43. package/dist/components/table/index.js +8 -0
  44. package/dist/components/table/styles.d.ts +56 -0
  45. package/dist/components/table/styles.js +44 -0
  46. package/dist/components/text/Text.svelte +19 -4
  47. package/dist/components/text/Text.svelte.d.ts +4 -2
  48. package/dist/components/work-fold/WorkFold.svelte +26 -1
  49. package/dist/components/work-fold/WorkFold.svelte.d.ts +5 -0
  50. package/dist/index.d.ts +4 -1
  51. package/dist/index.js +7 -1
  52. package/dist/internal/markers.stylex.d.ts +4 -0
  53. package/dist/internal/markers.stylex.js +2 -0
  54. package/dist/internal/table.d.ts +29 -0
  55. package/dist/internal/table.js +34 -0
  56. package/dist/tokens.stylex.d.ts +2 -0
  57. package/dist/tokens.stylex.js +9 -3
  58. package/dist/typography.d.ts +45 -1
  59. package/dist/typography.js +47 -2
  60. package/package.json +1 -1
  61. package/skills/building-ui/SKILL.md +23 -23
  62. package/skills/building-ui/references/components.md +204 -42
  63. package/skills/markdown/SKILL.md +1 -1
  64. package/skills/setup/SKILL.md +1 -1
  65. package/skills/styling/SKILL.md +23 -5
  66. package/skills/theming/SKILL.md +1 -1
@@ -5,6 +5,11 @@
5
5
  sideways, and keeps the open one in view. A tab with a leading icon shows its
6
6
  close button in the icon's place, so no room is kept at its end.
7
7
 
8
+ A tab can be temporary, as a preview is: in italics, until a double-click or
9
+ the app keeps it. A middle click closes a tab, as it does in a browser. With
10
+ `variant="notch"` the open tab takes the colour of the surface under the
11
+ strip and runs into it, for a strip at the foot of a header.
12
+
8
13
  A tab can carry a menu (a right-click, the menu key or a long press), be
9
14
  dragged into another place, be renamed where it stands, and hold buttons of
10
15
  its own. Each is offered only when its callback or snippet is given.
@@ -14,7 +19,6 @@
14
19
  own `panelId`. For a fixed set of sections that own their panel, use Tabs.
15
20
  -->
16
21
  <script lang="ts" module>
17
- import { visuallyHidden } from '../../visually-hidden.js';
18
22
  import * as stylex from '@stylexjs/stylex';
19
23
  import { tick, type Snippet } from 'svelte';
20
24
  import type { HTMLAttributes } from 'svelte/elements';
@@ -41,6 +45,13 @@
41
45
  panelId?: string | undefined;
42
46
  /** With `onrename`, whether this tab can be renamed. Defaults to true. */
43
47
  renamable?: boolean | undefined;
48
+ /**
49
+ * A preview, which the next one opened takes the place of: in italics, and said as
50
+ * "preview" after its name. The italics are on the label inside the tab
51
+ * (`[data-slot="tab-strip-label"]`), not on the tab itself. A double-click calls `onkeep`,
52
+ * ahead of renaming.
53
+ */
54
+ temporary?: boolean | undefined;
44
55
  };
45
56
 
46
57
  export type TabStripProps = Omit<
@@ -73,7 +84,10 @@
73
84
  addLabel?: string | undefined;
74
85
  /** The name of a tab's close button. */
75
86
  closeLabel?: ((tab: TabStripTab) => string) | undefined;
76
- /** Before a tab's label: an icon, or a StatusIndicator. */
87
+ /**
88
+ * Before a tab's label: an icon, or a StatusIndicator. It is not part of the tab's name,
89
+ * which is its label and what `temporary` and `mark` add: say a tab's state there.
90
+ */
77
91
  leading?: Snippet<[TabStripTab]> | undefined;
78
92
  /**
79
93
  * Buttons of a tab's own, after its label and before its close button: one that mutes a
@@ -103,6 +117,18 @@
103
117
  renameLabel?: ((tab: TabStripTab) => string) | undefined;
104
118
  /** The id of a tab shown beside the open one, as in a split view: it is lit, as under the pointer. */
105
119
  beside?: string | undefined;
120
+ /**
121
+ * Called on a double-click of a temporary tab, to keep it: it is no longer a preview. A
122
+ * tab that is not temporary renames on a double-click, as before.
123
+ */
124
+ onkeep?: ((id: string) => void) | undefined;
125
+ /**
126
+ * `fill` marks the open tab with a fill, as the open row of a list has. `notch` gives it
127
+ * the colour of the surface under the strip, `--narvi-tab-surface` (`colors.bgRaised` by
128
+ * default), and runs it down into that surface with a curve each side: for a strip at the
129
+ * foot of a header, in AppShell.Strip, over a band of another colour.
130
+ */
131
+ variant?: 'fill' | 'notch' | undefined;
106
132
  sx?: Sx | undefined;
107
133
  };
108
134
 
@@ -112,6 +138,16 @@
112
138
  /** A length at the window's density (`density` in the tokens). */
113
139
  const d = (rem: string) => `calc(${rem} * ${density.factor})`;
114
140
 
141
+ // The notch: the open tab's colour, that of the surface it runs into, which a consumer can set
142
+ const SURFACE = `var(--narvi-tab-surface, ${colors.bgRaised})`;
143
+ // The radius of the curves where the open tab meets the surface
144
+ const NOTCH = '0.5rem';
145
+ // How far over the surface the other tabs stand
146
+ const REACH = '0.375rem';
147
+ // The curve each side: the surface's colour, cut by a circle. A mask, so nothing is graded
148
+ const corner = (at: string) =>
149
+ `radial-gradient(circle at ${at}, transparent ${NOTCH}, #000 calc(${NOTCH} + 0.5px))`;
150
+
115
151
  const styles = stylex.create({
116
152
  root: {
117
153
  display: 'flex',
@@ -134,6 +170,54 @@
134
170
  padding: '2px',
135
171
  margin: '-2px'
136
172
  },
173
+ // The notch: the strip runs the height of what holds it, its tabs standing at its foot
174
+ notchRoot: { alignSelf: 'stretch', alignItems: 'flex-end' },
175
+ notchList: {
176
+ alignSelf: 'stretch',
177
+ alignItems: 'flex-end',
178
+ // Room for the first and last tabs' curves, which the scroller would otherwise clip
179
+ paddingBlock: '2px 0',
180
+ paddingInline: NOTCH,
181
+ marginBlock: 0,
182
+ marginInline: `calc(-1 * ${NOTCH})`
183
+ },
184
+ // The tabs, and the button to add one, a little over the surface, on one line
185
+ notchStanding: { marginBlockEnd: REACH },
186
+ // The open tab is the surface's own colour and runs down into it: no fill of its own, no
187
+ // line and no shadow. It takes the room the others stand over, so its label stays on
188
+ // their line.
189
+ notchOpen: {
190
+ paddingBlockEnd: REACH,
191
+ borderEndStartRadius: 0,
192
+ borderEndEndRadius: 0,
193
+ backgroundColor: { default: SURFACE, [HOVER]: SURFACE },
194
+ color: colors.text,
195
+ '::before': {
196
+ content: '""',
197
+ position: 'absolute',
198
+ bottom: 0,
199
+ right: '100%',
200
+ width: NOTCH,
201
+ height: NOTCH,
202
+ backgroundColor: SURFACE,
203
+ maskImage: corner('0 0'),
204
+ pointerEvents: 'none'
205
+ },
206
+ '::after': {
207
+ content: '""',
208
+ position: 'absolute',
209
+ bottom: 0,
210
+ left: '100%',
211
+ width: NOTCH,
212
+ height: NOTCH,
213
+ backgroundColor: SURFACE,
214
+ maskImage: corner('100% 0'),
215
+ pointerEvents: 'none'
216
+ }
217
+ },
218
+ // The close button and a mark stay centred on the label, above the room it runs down by
219
+ notchOpenAside: { top: `calc((100% - ${REACH}) / 2)` },
220
+ temporary: { fontStyle: 'italic' },
137
221
  // Tabs narrow before the strip scrolls, so a title ends in an ellipsis, not mid-word
138
222
  tab: {
139
223
  position: 'relative',
@@ -397,6 +481,8 @@
397
481
  renaming = $bindable(),
398
482
  renameLabel = (tab) => `Name of ${tab.label}`,
399
483
  beside,
484
+ onkeep,
485
+ variant = 'fill',
400
486
  sx,
401
487
  class: className,
402
488
  ...rest
@@ -455,6 +541,17 @@
455
541
  return others;
456
542
  }
457
543
 
544
+ // Named in full, not by words hidden inside it: a hidden word is a box of its own, and a box
545
+ // is read with a space each side, as "Fix the parser , preview"
546
+ const tabName = (tab: TabStripTab) =>
547
+ [
548
+ tab.label,
549
+ tab.temporary && 'preview',
550
+ tab.mark && (tab.mark === 'live' ? 'working' : 'unsaved')
551
+ ]
552
+ .filter(Boolean)
553
+ .join(', ');
554
+
458
555
  const renamable = (tab: TabStripTab) => !!onrename && tab.renamable !== false;
459
556
 
460
557
  function startRename(tab: TabStripTab) {
@@ -477,6 +574,12 @@
477
574
  input.select();
478
575
  };
479
576
 
577
+ // A temporary tab is kept on a double-click; any other is renamed
578
+ function doubleClick(tab: TabStripTab) {
579
+ if (tab.temporary && onkeep) onkeep(tab.id);
580
+ else startRename(tab);
581
+ }
582
+
480
583
  function open(tab: TabStripTab) {
481
584
  if (value === tab.id) return;
482
585
  value = tab.id;
@@ -515,6 +618,7 @@
515
618
  {@const selected = tab.id === value}
516
619
  {@const lifted = !!drag && drag.from === index && !drag.settling}
517
620
  {@const editing = renaming === tab.id && renamable(tab)}
621
+ {@const notch = variant === 'notch'}
518
622
  {@const { onpointerdown: menuPointerDown, ...triggerRest } = withoutTabStop(trigger)}
519
623
  <div
520
624
  {...triggerRest}
@@ -522,16 +626,28 @@
522
626
  data-tab-id={tab.id}
523
627
  data-renaming={editing || undefined}
524
628
  data-lifted={lifted || undefined}
629
+ data-temporary={tab.temporary || undefined}
525
630
  style:--narvi-tab-offset={drag ? `${tabOffset(drag, index)}px` : undefined}
526
631
  onpointerdown={(event) => {
527
632
  // The menu's own, which opens it on a long press on a touch screen
528
633
  if (typeof menuPointerDown === 'function') menuPointerDown(event);
529
634
  if (onmove && !editing) dragging.press(index, event);
530
635
  }}
636
+ onmousedown={(event) => {
637
+ // The middle button closes: it neither scrolls the page nor pastes
638
+ if (event.button === 1 && onclose && !editing) event.preventDefault();
639
+ }}
640
+ onauxclick={(event) => {
641
+ // As it does in a browser, wherever on the tab it is pressed
642
+ if (event.button !== 1 || !onclose || editing) return;
643
+ event.preventDefault();
644
+ close(tab);
645
+ }}
531
646
  {...stylex.attrs(
532
647
  styles.tab,
533
648
  tab.id === beside && !selected && styles.beside,
534
649
  selected && styles.selected,
650
+ notch && (selected ? styles.notchOpen : styles.notchStanding),
535
651
  drag && !lifted && styles.sliding,
536
652
  lifted && styles.lifted,
537
653
  tabStripTabMarker
@@ -560,6 +676,7 @@
560
676
  aria-selected={selected}
561
677
  aria-controls={tab.panelId ?? controls}
562
678
  aria-current={selected ? 'true' : undefined}
679
+ aria-label={tabName(tab)}
563
680
  title={tab.title ?? tab.label}
564
681
  {...stylex.attrs(
565
682
  styles.button,
@@ -570,11 +687,7 @@
570
687
  onfocus={() => {
571
688
  if (arrowed && activation === 'automatic') open(tab);
572
689
  }}
573
- ondblclick={() => startRename(tab)}
574
- onauxclick={(event) => {
575
- // The middle button closes, as it does in a browser
576
- if (event.button === 1) close(tab);
577
- }}
690
+ ondblclick={() => doubleClick(tab)}
578
691
  onkeydown={(event) => {
579
692
  if (moveByKey(tab, event)) return;
580
693
  if (event.key === 'F2' && renamable(tab)) {
@@ -612,10 +725,10 @@
612
725
  {/if}
613
726
  </span>
614
727
  {/if}
615
- <span {...stylex.attrs(styles.text)}>{tab.label}</span>
616
- {#if tab.mark}<span {...stylex.attrs(visuallyHidden)}
617
- >, {tab.mark === 'live' ? 'working' : 'unsaved'}</span
618
- >{/if}
728
+ <span
729
+ data-slot="tab-strip-label"
730
+ {...stylex.attrs(styles.text, tab.temporary && styles.temporary)}>{tab.label}</span
731
+ >
619
732
  </button>
620
733
  {/if}
621
734
  {#if trailing}
@@ -627,7 +740,7 @@
627
740
  >
628
741
  {/if}
629
742
  {#if leading && onclose}
630
- <span {...stylex.attrs(styles.start)}>
743
+ <span {...stylex.attrs(styles.start, notch && selected && styles.notchOpenAside)}>
631
744
  <button
632
745
  type="button"
633
746
  tabindex="-1"
@@ -639,7 +752,7 @@
639
752
  </button>
640
753
  </span>
641
754
  {:else if onclose || tab.mark}
642
- <span {...stylex.attrs(styles.end)}>
755
+ <span {...stylex.attrs(styles.end, notch && selected && styles.notchOpenAside)}>
643
756
  {#if tab.mark}
644
757
  <span
645
758
  aria-hidden="true"
@@ -668,14 +781,14 @@
668
781
  data-slot="tab-strip"
669
782
  data-dragging={drag ? '' : undefined}
670
783
  {...rest}
671
- {...attrs([styles.root, sx], className)}
784
+ {...attrs([styles.root, variant === 'notch' && styles.notchRoot, sx], className)}
672
785
  >
673
786
  <div
674
787
  bind:this={list}
675
788
  role="tablist"
676
789
  aria-label={label}
677
790
  aria-orientation="horizontal"
678
- {...stylex.attrs(styles.list)}
791
+ {...stylex.attrs(styles.list, variant === 'notch' && styles.notchList)}
679
792
  {@attach roving({ selector: '[role="tab"]', orientation: 'horizontal', wrap: true })}
680
793
  onkeydowncapture={onListKeydownCapture}
681
794
  >
@@ -720,7 +833,12 @@
720
833
  <Menu.Root>
721
834
  <Menu.Trigger>
722
835
  {#snippet child({ props })}
723
- <button type="button" aria-label={addLabel} {...props} {...stylex.attrs(styles.add)}>
836
+ <button
837
+ type="button"
838
+ aria-label={addLabel}
839
+ {...props}
840
+ {...stylex.attrs(styles.add, variant === 'notch' && styles.notchStanding)}
841
+ >
724
842
  {@render plus()}
725
843
  </button>
726
844
  {/snippet}
@@ -728,7 +846,12 @@
728
846
  <Menu.Content align="end">{@render addMenu()}</Menu.Content>
729
847
  </Menu.Root>
730
848
  {:else if onadd}
731
- <button type="button" aria-label={addLabel} {...stylex.attrs(styles.add)} onclick={onadd}>
849
+ <button
850
+ type="button"
851
+ aria-label={addLabel}
852
+ {...stylex.attrs(styles.add, variant === 'notch' && styles.notchStanding)}
853
+ onclick={onadd}
854
+ >
732
855
  {@render plus()}
733
856
  </button>
734
857
  {/if}
@@ -14,6 +14,13 @@ export type TabStripTab = {
14
14
  panelId?: string | undefined;
15
15
  /** With `onrename`, whether this tab can be renamed. Defaults to true. */
16
16
  renamable?: boolean | undefined;
17
+ /**
18
+ * A preview, which the next one opened takes the place of: in italics, and said as
19
+ * "preview" after its name. The italics are on the label inside the tab
20
+ * (`[data-slot="tab-strip-label"]`), not on the tab itself. A double-click calls `onkeep`,
21
+ * ahead of renaming.
22
+ */
23
+ temporary?: boolean | undefined;
17
24
  };
18
25
  export type TabStripProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onclose' | 'onchange'> & {
19
26
  tabs: TabStripTab[];
@@ -42,7 +49,10 @@ export type TabStripProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'o
42
49
  addLabel?: string | undefined;
43
50
  /** The name of a tab's close button. */
44
51
  closeLabel?: ((tab: TabStripTab) => string) | undefined;
45
- /** Before a tab's label: an icon, or a StatusIndicator. */
52
+ /**
53
+ * Before a tab's label: an icon, or a StatusIndicator. It is not part of the tab's name,
54
+ * which is its label and what `temporary` and `mark` add: say a tab's state there.
55
+ */
46
56
  leading?: Snippet<[TabStripTab]> | undefined;
47
57
  /**
48
58
  * Buttons of a tab's own, after its label and before its close button: one that mutes a
@@ -72,6 +82,18 @@ export type TabStripProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'o
72
82
  renameLabel?: ((tab: TabStripTab) => string) | undefined;
73
83
  /** The id of a tab shown beside the open one, as in a split view: it is lit, as under the pointer. */
74
84
  beside?: string | undefined;
85
+ /**
86
+ * Called on a double-click of a temporary tab, to keep it: it is no longer a preview. A
87
+ * tab that is not temporary renames on a double-click, as before.
88
+ */
89
+ onkeep?: ((id: string) => void) | undefined;
90
+ /**
91
+ * `fill` marks the open tab with a fill, as the open row of a list has. `notch` gives it
92
+ * the colour of the surface under the strip, `--narvi-tab-surface` (`colors.bgRaised` by
93
+ * default), and runs it down into that surface with a curve each side: for a strip at the
94
+ * foot of a header, in AppShell.Strip, over a band of another colour.
95
+ */
96
+ variant?: 'fill' | 'notch' | undefined;
75
97
  sx?: Sx | undefined;
76
98
  };
77
99
  declare const TabStrip: import("svelte").Component<TabStripProps, {}, "value" | "renaming">;
@@ -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;