@diegopluna/narvi 0.3.2 → 0.3.4

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 (133) hide show
  1. package/dist/components/activity/ActivityIcon.svelte +54 -0
  2. package/dist/components/activity/ActivityIcon.svelte.d.ts +24 -0
  3. package/dist/components/activity/ActivityStep.svelte +47 -13
  4. package/dist/components/activity/ActivityStep.svelte.d.ts +13 -4
  5. package/dist/components/activity/ActivityThought.svelte +24 -5
  6. package/dist/components/activity/ActivityThought.svelte.d.ts +12 -2
  7. package/dist/components/activity/index.d.ts +3 -1
  8. package/dist/components/activity/index.js +2 -1
  9. package/dist/components/app-shell/AppShellHeader.svelte +18 -4
  10. package/dist/components/app-shell/AppShellHeader.svelte.d.ts +5 -0
  11. package/dist/components/app-shell/AppShellMain.svelte +14 -2
  12. package/dist/components/app-shell/AppShellPanel.svelte +77 -12
  13. package/dist/components/app-shell/AppShellPanel.svelte.d.ts +11 -1
  14. package/dist/components/app-shell/AppShellSheet.svelte +11 -1
  15. package/dist/components/app-shell/context.d.ts +8 -0
  16. package/dist/components/app-shell/context.js +7 -0
  17. package/dist/components/approval/Approval.svelte +14 -1
  18. package/dist/components/approval/Approval.svelte.d.ts +5 -0
  19. package/dist/components/avatar/AvatarRoot.svelte +20 -7
  20. package/dist/components/avatar/AvatarRoot.svelte.d.ts +10 -3
  21. package/dist/components/badge/Badge.svelte +3 -1
  22. package/dist/components/badge/Badge.svelte.d.ts +1 -1
  23. package/dist/components/button/Button.svelte +28 -6
  24. package/dist/components/button/Button.svelte.d.ts +7 -0
  25. package/dist/components/composer/ComposerModelPicker.svelte +80 -13
  26. package/dist/components/composer/ComposerModelPicker.svelte.d.ts +23 -6
  27. package/dist/components/composer/ComposerRoot.svelte +51 -12
  28. package/dist/components/composer/ComposerRoot.svelte.d.ts +16 -0
  29. package/dist/components/composer/ComposerSubmit.svelte +19 -5
  30. package/dist/components/composer/ComposerSubmit.svelte.d.ts +3 -1
  31. package/dist/components/composer/ComposerToggle.svelte +18 -4
  32. package/dist/components/composer/ComposerToggle.svelte.d.ts +2 -0
  33. package/dist/components/composer/ComposerTray.svelte +17 -3
  34. package/dist/components/composer/ComposerTray.svelte.d.ts +5 -0
  35. package/dist/components/composer/context.d.ts +4 -1
  36. package/dist/components/dialog/DialogContent.svelte +22 -12
  37. package/dist/components/dialog/DialogContent.svelte.d.ts +10 -0
  38. package/dist/components/divider/Divider.svelte +56 -14
  39. package/dist/components/divider/Divider.svelte.d.ts +13 -3
  40. package/dist/components/empty-state/EmptyState.svelte +12 -2
  41. package/dist/components/empty-state/EmptyState.svelte.d.ts +6 -0
  42. package/dist/components/heading/Heading.svelte +15 -0
  43. package/dist/components/heading/Heading.svelte.d.ts +6 -0
  44. package/dist/components/hover-card/HoverCardContent.svelte +18 -2
  45. package/dist/components/hover-card/HoverCardContent.svelte.d.ts +8 -0
  46. package/dist/components/input/Input.svelte +13 -3
  47. package/dist/components/input/Input.svelte.d.ts +10 -2
  48. package/dist/components/markdown/Markdown.svelte +22 -2
  49. package/dist/components/markdown/MarkdownDiagram.svelte +33 -2
  50. package/dist/components/markdown/MarkdownFile.svelte +56 -10
  51. package/dist/components/markdown/MarkdownMath.svelte +6 -0
  52. package/dist/components/markdown/MarkdownTable.svelte +3 -4
  53. package/dist/components/markdown/context.d.ts +6 -0
  54. package/dist/components/markdown/labels.d.ts +7 -0
  55. package/dist/components/markdown/labels.js +2 -0
  56. package/dist/components/menu/MenuCheckboxItem.svelte +44 -7
  57. package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +12 -2
  58. package/dist/components/menu/MenuContent.svelte +10 -2
  59. package/dist/components/menu/MenuContent.svelte.d.ts +10 -0
  60. package/dist/components/menu/MenuItem.svelte +17 -2
  61. package/dist/components/menu/MenuItem.svelte.d.ts +8 -0
  62. package/dist/components/menu/MenuSubContent.svelte +10 -2
  63. package/dist/components/menu/MenuSubContent.svelte.d.ts +10 -0
  64. package/dist/components/menu/MenuSubTrigger.svelte +19 -2
  65. package/dist/components/menu/MenuSubTrigger.svelte.d.ts +6 -0
  66. package/dist/components/message/MessageBubble.svelte +40 -0
  67. package/dist/components/message/MessageBubble.svelte.d.ts +12 -0
  68. package/dist/components/message/MessageContent.svelte +23 -14
  69. package/dist/components/message/MessageContent.svelte.d.ts +6 -0
  70. package/dist/components/message/MessageCopy.svelte +27 -15
  71. package/dist/components/message/MessageCopy.svelte.d.ts +9 -2
  72. package/dist/components/message/MessageRoot.svelte +20 -3
  73. package/dist/components/message/MessageRoot.svelte.d.ts +6 -0
  74. package/dist/components/message/context.d.ts +2 -0
  75. package/dist/components/message/index.d.ts +4 -1
  76. package/dist/components/message/index.js +3 -2
  77. package/dist/components/message/styles.d.ts +30 -0
  78. package/dist/components/message/styles.js +24 -0
  79. package/dist/components/notice/Notice.svelte +3 -3
  80. package/dist/components/popover/PopoverContent.svelte +27 -3
  81. package/dist/components/popover/PopoverContent.svelte.d.ts +18 -0
  82. package/dist/components/questionnaire/Questionnaire.svelte +103 -19
  83. package/dist/components/questionnaire/Questionnaire.svelte.d.ts +13 -1
  84. package/dist/components/queued-message/QueuedMessage.svelte +44 -6
  85. package/dist/components/queued-message/QueuedMessage.svelte.d.ts +12 -1
  86. package/dist/components/segmented/SegmentedControl.svelte +12 -1
  87. package/dist/components/segmented/SegmentedControl.svelte.d.ts +3 -1
  88. package/dist/components/select/Select.svelte +43 -6
  89. package/dist/components/select/Select.svelte.d.ts +14 -0
  90. package/dist/components/settings-row/SettingsRow.svelte +87 -37
  91. package/dist/components/settings-row/SettingsRow.svelte.d.ts +13 -0
  92. package/dist/components/split-button/SplitButton.svelte +137 -0
  93. package/dist/components/split-button/SplitButton.svelte.d.ts +29 -0
  94. package/dist/components/tab-strip/TabStrip.svelte +337 -93
  95. package/dist/components/tab-strip/TabStrip.svelte.d.ts +36 -1
  96. package/dist/components/tab-strip/drag.svelte.d.ts +31 -0
  97. package/dist/components/tab-strip/drag.svelte.js +148 -0
  98. package/dist/components/toast/Toaster.svelte +1 -1
  99. package/dist/components/toggle/Toggle.svelte +12 -2
  100. package/dist/components/toggle/Toggle.svelte.d.ts +11 -1
  101. package/dist/components/toggle-group/ToggleGroupItem.svelte +10 -1
  102. package/dist/components/toggle-group/ToggleGroupRoot.svelte +7 -1
  103. package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +3 -1
  104. package/dist/components/toggle-group/context.d.ts +2 -1
  105. package/dist/components/tooltip/TooltipContent.svelte +13 -1
  106. package/dist/components/tooltip/TooltipContent.svelte.d.ts +10 -0
  107. package/dist/components/work-fold/WorkFold.svelte +13 -4
  108. package/dist/components/work-fold/WorkFold.svelte.d.ts +2 -1
  109. package/dist/focus-ring.d.ts +29 -0
  110. package/dist/focus-ring.js +42 -0
  111. package/dist/index.d.ts +8 -5
  112. package/dist/index.js +8 -2
  113. package/dist/internal/Collapse.svelte +15 -2
  114. package/dist/internal/Glyph.svelte +28 -0
  115. package/dist/internal/Glyph.svelte.d.ts +5 -0
  116. package/dist/internal/Tile.svelte +3 -2
  117. package/dist/internal/layer.d.ts +23 -0
  118. package/dist/internal/layer.js +19 -0
  119. package/dist/internal/toggle.d.ts +8 -1
  120. package/dist/internal/toggle.js +20 -2
  121. package/dist/markdown/file-paths.d.ts +7 -0
  122. package/dist/markdown/file-paths.js +29 -0
  123. package/dist/markdown/files.d.ts +22 -2
  124. package/dist/markdown/files.js +45 -14
  125. package/dist/tokens.stylex.d.ts +3 -0
  126. package/dist/tokens.stylex.js +5 -1
  127. package/package.json +1 -1
  128. package/skills/building-ui/SKILL.md +77 -5
  129. package/skills/building-ui/references/components.md +51 -50
  130. package/skills/markdown/SKILL.md +22 -6
  131. package/skills/setup/SKILL.md +1 -1
  132. package/skills/styling/SKILL.md +10 -3
  133. package/skills/theming/SKILL.md +11 -4
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Dragging a tab along a TabStrip into another place: it follows the pointer, the others slide
3
+ * aside to make room, and let go, it settles into its place before the move is made. From
4
+ * Eregion's side panel (`tabDrag.svelte.ts`).
5
+ */
6
+ /** How far the pointer moves before a press on a tab becomes a drag, in pixels. */
7
+ const THRESHOLD = 4;
8
+ /** How long a dropped tab takes to settle into its place: `motion.fast`. */
9
+ const SETTLE_MS = 120;
10
+ /**
11
+ * The place a tab dragged by `dx` would drop into. It passes another once its leading edge
12
+ * crosses that one's middle, so a wide tab passes a narrow one as readily as the other way.
13
+ */
14
+ function dropPlace(rects, from, dx) {
15
+ const moving = rects[from];
16
+ if (!moving)
17
+ return from;
18
+ const left = moving.left + dx;
19
+ const right = left + moving.width;
20
+ return rects.filter((rect, index) => {
21
+ const middle = rect.left + rect.width / 2;
22
+ return index !== from && (index < from ? left > middle : right > middle);
23
+ }).length;
24
+ }
25
+ /** How far the dragged tab moves to sit in the place it drops into. */
26
+ function settledOffset(rects, from, to) {
27
+ const moving = rects[from];
28
+ const target = rects[to];
29
+ if (!moving || !target || to === from)
30
+ return 0;
31
+ return to < from
32
+ ? target.left - moving.left
33
+ : target.left + target.width - moving.width - moving.left;
34
+ }
35
+ /** How far the tab at `index` moves while another is dragged: aside, to make room, or not at all. */
36
+ export function tabOffset(drag, index) {
37
+ if (!drag)
38
+ return 0;
39
+ if (index === drag.from)
40
+ return drag.dx;
41
+ const moving = drag.rects[drag.from];
42
+ const [first, second] = drag.rects;
43
+ const gap = first && second ? second.left - (first.left + first.width) : 0;
44
+ const room = (moving?.width ?? 0) + gap;
45
+ if (index > drag.from && index <= drag.to)
46
+ return -room;
47
+ if (index < drag.from && index >= drag.to)
48
+ return room;
49
+ return 0;
50
+ }
51
+ export class TabDragging {
52
+ drag = $state.raw(null);
53
+ #settling = 0;
54
+ /** The tabs, in order. */
55
+ #tabs;
56
+ /** The strip they are dragged along, and kept within. */
57
+ #strip;
58
+ #onmove;
59
+ constructor(tabs, strip, onmove) {
60
+ this.#tabs = tabs;
61
+ this.#strip = strip;
62
+ this.#onmove = onmove;
63
+ }
64
+ /** A press on the tab at `index`, which becomes a drag once the pointer moves far enough. */
65
+ press(index, event) {
66
+ const strip = this.#strip();
67
+ const tab = event.currentTarget;
68
+ const target = event.target instanceof Element ? event.target : null;
69
+ // Its close button and its own buttons keep their presses, and so does a name being typed
70
+ const control = target?.closest('button, input, a');
71
+ if (!strip ||
72
+ !(tab instanceof HTMLElement) ||
73
+ event.button !== 0 ||
74
+ (control && control.getAttribute('role') !== 'tab'))
75
+ return;
76
+ const pointer = event.pointerId;
77
+ const startX = event.clientX;
78
+ const bounds = strip.getBoundingClientRect();
79
+ const rects = this.#tabs().map((each) => {
80
+ const rect = each.getBoundingClientRect();
81
+ return { left: rect.left, width: rect.width };
82
+ });
83
+ const moving = rects[index];
84
+ if (!moving)
85
+ return;
86
+ const state = { started: false, to: index, dx: 0 };
87
+ const move = (next) => {
88
+ if (next.pointerId !== pointer)
89
+ return;
90
+ const dx = next.clientX - startX;
91
+ if (!state.started && Math.abs(dx) < THRESHOLD)
92
+ return;
93
+ if (!state.started) {
94
+ state.started = true;
95
+ tab.setPointerCapture?.(pointer);
96
+ }
97
+ // It stays within the strip
98
+ const low = bounds.left - moving.left;
99
+ const high = bounds.right - (moving.left + moving.width);
100
+ state.dx = Math.min(high, Math.max(low, dx));
101
+ state.to = dropPlace(rects, index, state.dx);
102
+ this.drag = { from: index, to: state.to, dx: state.dx, settling: false, rects };
103
+ };
104
+ const end = (last) => {
105
+ if (last.pointerId !== pointer)
106
+ return;
107
+ removeEventListener('pointermove', move);
108
+ removeEventListener('pointerup', end);
109
+ removeEventListener('pointercancel', end);
110
+ if (!state.started)
111
+ return;
112
+ // The press ends in a click, which would open the tab, and a drag is not one
113
+ const swallow = (click) => {
114
+ click.stopPropagation();
115
+ click.preventDefault();
116
+ };
117
+ addEventListener('click', swallow, { capture: true, once: true });
118
+ setTimeout(() => removeEventListener('click', swallow, { capture: true }));
119
+ const commit = () => {
120
+ this.drag = null;
121
+ if (state.to !== index)
122
+ this.#onmove(index, state.to);
123
+ };
124
+ if (last.type === 'pointercancel' || matchMedia('(prefers-reduced-motion: reduce)').matches) {
125
+ if (last.type === 'pointercancel')
126
+ state.to = index;
127
+ commit();
128
+ return;
129
+ }
130
+ this.drag = {
131
+ from: index,
132
+ to: state.to,
133
+ dx: settledOffset(rects, index, state.to),
134
+ settling: true,
135
+ rects
136
+ };
137
+ clearTimeout(this.#settling);
138
+ this.#settling = window.setTimeout(commit, SETTLE_MS);
139
+ };
140
+ addEventListener('pointermove', move);
141
+ addEventListener('pointerup', end);
142
+ addEventListener('pointercancel', end);
143
+ }
144
+ /** Stops a drop settling, as the strip goes. */
145
+ dispose() {
146
+ clearTimeout(this.#settling);
147
+ }
148
+ }
@@ -77,7 +77,7 @@
77
77
  borderRadius: '9999px',
78
78
  backgroundColor: colors.accent
79
79
  },
80
- info: { color: colors.accent },
80
+ info: { color: colors.info },
81
81
  success: { color: colors.success },
82
82
  warning: { color: colors.warning },
83
83
  error: { color: colors.danger },
@@ -3,11 +3,16 @@
3
3
  import { Toggle } from 'bits-ui';
4
4
  import type { Snippet } from 'svelte';
5
5
  import { attrs, type Sx } from '../../internal/sx.js';
6
- import { toggle, type ToggleSize } from '../../internal/toggle.js';
6
+ import { toggle, type ToggleSize, type ToggleTone } from '../../internal/toggle.js';
7
7
 
8
8
  export type ToggleProps = Loose<
9
9
  Omit<Toggle.RootProps, 'children' | 'child'> & {
10
10
  size?: ToggleSize | undefined;
11
+ /**
12
+ * How it shows it is pressed: lit in the `accent`, or `neutral`, in the fill of what is
13
+ * chosen, for a toolbar's icons that show or hide something.
14
+ */
15
+ tone?: ToggleTone | undefined;
11
16
  /** Square, for a single icon. Give it an `aria-label`. */
12
17
  iconOnly?: boolean | undefined;
13
18
  sx?: Sx | undefined;
@@ -22,6 +27,7 @@
22
27
  pressed = $bindable(false),
23
28
  ref = $bindable(null),
24
29
  size = 'md',
30
+ tone = 'accent',
25
31
  iconOnly = false,
26
32
  sx,
27
33
  class: className,
@@ -36,8 +42,12 @@
36
42
  bind:pressed
37
43
  bind:ref
38
44
  data-slot="toggle"
45
+ data-tone={tone}
39
46
  {...rest}
40
- {...attrs([toggle.base, toggle[size], iconOnly && square[size], sx], className)}
47
+ {...attrs(
48
+ [toggle.base, tone === 'neutral' && toggle.neutral, toggle[size], iconOnly && square[size], sx],
49
+ className
50
+ )}
41
51
  >
42
52
  {@render children?.()}
43
53
  </Toggle.Root>
@@ -2,9 +2,14 @@ import type { Loose } from '../../internal/loose.js';
2
2
  import { Toggle } from 'bits-ui';
3
3
  import type { Snippet } from 'svelte';
4
4
  import { type Sx } from '../../internal/sx.js';
5
- import { type ToggleSize } from '../../internal/toggle.js';
5
+ import { type ToggleSize, type ToggleTone } from '../../internal/toggle.js';
6
6
  export type ToggleProps = Loose<Omit<Toggle.RootProps, 'children' | 'child'> & {
7
7
  size?: ToggleSize | undefined;
8
+ /**
9
+ * How it shows it is pressed: lit in the `accent`, or `neutral`, in the fill of what is
10
+ * chosen, for a toolbar's icons that show or hide something.
11
+ */
12
+ tone?: ToggleTone | undefined;
8
13
  /** Square, for a single icon. Give it an `aria-label`. */
9
14
  iconOnly?: boolean | undefined;
10
15
  sx?: Sx | undefined;
@@ -13,6 +18,11 @@ export type ToggleProps = Loose<Omit<Toggle.RootProps, 'children' | 'child'> & {
13
18
  }>;
14
19
  declare const Toggle: import("svelte").Component<Loose<Omit<Toggle.RootProps, "children" | "child"> & {
15
20
  size?: ToggleSize | undefined;
21
+ /**
22
+ * How it shows it is pressed: lit in the `accent`, or `neutral`, in the fill of what is
23
+ * chosen, for a toolbar's icons that show or hide something.
24
+ */
25
+ tone?: ToggleTone | undefined;
16
26
  /** Square, for a single icon. Give it an `aria-label`. */
17
27
  iconOnly?: boolean | undefined;
18
28
  sx?: Sx | undefined;
@@ -34,7 +34,16 @@
34
34
  bind:ref
35
35
  data-slot="toggle-group-item"
36
36
  {...rest}
37
- {...attrs([toggle.base, toggle[group.size], iconOnly && square[group.size], sx], className)}
37
+ {...attrs(
38
+ [
39
+ toggle.base,
40
+ group.tone === 'neutral' && toggle.neutral,
41
+ toggle[group.size],
42
+ iconOnly && square[group.size],
43
+ sx
44
+ ],
45
+ className
46
+ )}
38
47
  >
39
48
  {@render children?.()}
40
49
  </ToggleGroup.Item>
@@ -4,7 +4,7 @@
4
4
  import type { Snippet } from 'svelte';
5
5
  import type { Loose } from '../../internal/loose.js';
6
6
  import { attrs, type Sx } from '../../internal/sx.js';
7
- import type { ToggleSize } from '../../internal/toggle.js';
7
+ import type { ToggleSize, ToggleTone } from '../../internal/toggle.js';
8
8
  import { setToggleGroupContext } from './context.js';
9
9
 
10
10
  type Base = {
@@ -14,6 +14,8 @@
14
14
  orientation?: 'horizontal' | 'vertical' | undefined;
15
15
  /** The size of every item. */
16
16
  size?: ToggleSize | undefined;
17
+ /** How a pressed item shows it: lit in the `accent`, or `neutral`, in the fill of what is chosen. */
18
+ tone?: ToggleTone | undefined;
17
19
  sx?: Sx | undefined;
18
20
  ref?: HTMLElement | null | undefined;
19
21
  /** ToggleGroup.Item buttons. */
@@ -62,6 +64,7 @@
62
64
  value = $bindable(),
63
65
  onValueChange,
64
66
  size = 'md',
67
+ tone = 'accent',
65
68
  orientation = 'horizontal',
66
69
  ref = $bindable(null),
67
70
  sx,
@@ -73,6 +76,9 @@
73
76
  setToggleGroupContext({
74
77
  get size() {
75
78
  return size;
79
+ },
80
+ get tone() {
81
+ return tone;
76
82
  }
77
83
  });
78
84
 
@@ -2,7 +2,7 @@ import { ToggleGroup } from 'bits-ui';
2
2
  import type { Snippet } from 'svelte';
3
3
  import type { Loose } from '../../internal/loose.js';
4
4
  import { type Sx } from '../../internal/sx.js';
5
- import type { ToggleSize } from '../../internal/toggle.js';
5
+ import type { ToggleSize, ToggleTone } from '../../internal/toggle.js';
6
6
  type Base = {
7
7
  disabled?: boolean | undefined;
8
8
  /** Whether the arrow keys wrap from the last item to the first. */
@@ -10,6 +10,8 @@ type Base = {
10
10
  orientation?: 'horizontal' | 'vertical' | undefined;
11
11
  /** The size of every item. */
12
12
  size?: ToggleSize | undefined;
13
+ /** How a pressed item shows it: lit in the `accent`, or `neutral`, in the fill of what is chosen. */
14
+ tone?: ToggleTone | undefined;
13
15
  sx?: Sx | undefined;
14
16
  ref?: HTMLElement | null | undefined;
15
17
  /** ToggleGroup.Item buttons. */
@@ -1,6 +1,7 @@
1
- import type { ToggleSize } from '../../internal/toggle.js';
1
+ import type { ToggleSize, ToggleTone } from '../../internal/toggle.js';
2
2
  export type ToggleGroupContext = {
3
3
  readonly size: ToggleSize;
4
+ readonly tone: ToggleTone;
4
5
  };
5
6
  export declare function setToggleGroupContext(context: ToggleGroupContext): void;
6
7
  export declare function getToggleGroupContext(part: string): ToggleGroupContext;
@@ -12,6 +12,11 @@
12
12
  Omit<Tooltip.ContentProps, 'children' | 'child'> & {
13
13
  /** The keys that do the same, shown after the label: `['⌘', 'K']`. */
14
14
  shortcut?: string[] | undefined;
15
+ /**
16
+ * `row` keeps the label and the shortcut on one line. `column` sets the content one
17
+ * part under another: a title, then a line or two that says more.
18
+ */
19
+ layout?: 'row' | 'column' | undefined;
15
20
  sx?: Sx | undefined;
16
21
  children?: Snippet | undefined;
17
22
  }
@@ -48,6 +53,12 @@
48
53
  // toolbar should feel quick, not like each button is thinking
49
54
  transitionDuration: { default: '120ms', [CLOSED]: '80ms', [INSTANT]: '0ms' }
50
55
  },
56
+ column: {
57
+ flexDirection: 'column',
58
+ alignItems: 'flex-start',
59
+ gap: '0.125rem',
60
+ paddingBlock: '0.4375rem'
61
+ },
51
62
  keys: { display: 'inline-flex', gap: '0.125rem' }
52
63
  });
53
64
  </script>
@@ -57,6 +68,7 @@
57
68
  sideOffset = 6,
58
69
  collisionPadding = 8,
59
70
  shortcut,
71
+ layout = 'row',
60
72
  sx,
61
73
  class: className,
62
74
  children,
@@ -70,7 +82,7 @@
70
82
  {collisionPadding}
71
83
  data-slot="tooltip"
72
84
  {...rest}
73
- {...attrs([styles.content, sx], className)}
85
+ {...attrs([styles.content, layout === 'column' && styles.column, sx], className)}
74
86
  >
75
87
  {@render children?.()}
76
88
  {#if shortcut?.length}
@@ -5,12 +5,22 @@ import { type Sx } from '../../internal/sx.js';
5
5
  export type TooltipContentProps = Loose<Omit<Tooltip.ContentProps, 'children' | 'child'> & {
6
6
  /** The keys that do the same, shown after the label: `['⌘', 'K']`. */
7
7
  shortcut?: string[] | undefined;
8
+ /**
9
+ * `row` keeps the label and the shortcut on one line. `column` sets the content one
10
+ * part under another: a title, then a line or two that says more.
11
+ */
12
+ layout?: 'row' | 'column' | undefined;
8
13
  sx?: Sx | undefined;
9
14
  children?: Snippet | undefined;
10
15
  }>;
11
16
  declare const TooltipContent: import("svelte").Component<Loose<Omit<Tooltip.ContentProps, "children" | "child"> & {
12
17
  /** The keys that do the same, shown after the label: `['⌘', 'K']`. */
13
18
  shortcut?: string[] | undefined;
19
+ /**
20
+ * `row` keeps the label and the shortcut on one line. `column` sets the content one
21
+ * part under another: a title, then a line or two that says more.
22
+ */
23
+ layout?: "row" | "column" | undefined;
14
24
  sx?: Sx | undefined;
15
25
  children?: Snippet | undefined;
16
26
  }>, {}, "">;
@@ -12,9 +12,11 @@
12
12
  import { colors, font, motion, radius } from '../../tokens.stylex.js';
13
13
  import { media } from '../../media.stylex.js';
14
14
  import CollapsibleContent from '../collapsible/CollapsibleContent.svelte';
15
- import CollapsibleRoot from '../collapsible/CollapsibleRoot.svelte';
15
+ import CollapsibleRoot, {
16
+ type CollapsibleRootProps
17
+ } from '../collapsible/CollapsibleRoot.svelte';
16
18
 
17
- export type WorkFoldProps = {
19
+ export type WorkFoldProps = Omit<CollapsibleRootProps, 'children' | 'open' | 'sx' | 'class'> & {
18
20
  /** What the fold holds, in words: "Worked for 2m 5s". */
19
21
  label: string;
20
22
  /** Whether the work shows. Bindable. */
@@ -65,12 +67,19 @@
65
67
  </script>
66
68
 
67
69
  <script lang="ts">
68
- let { label, open = $bindable(false), sx, class: className, children }: WorkFoldProps = $props();
70
+ let {
71
+ label,
72
+ open = $bindable(false),
73
+ sx,
74
+ class: className,
75
+ children,
76
+ ...rest
77
+ }: WorkFoldProps = $props();
69
78
 
70
79
  const uid = $props.id();
71
80
  </script>
72
81
 
73
- <CollapsibleRoot bind:open data-slot="work-fold" {sx} class={className}>
82
+ <CollapsibleRoot bind:open data-slot="work-fold" {...rest} {sx} class={className}>
74
83
  <Collapsible.Trigger id="{uid}-trigger" {...stylex.attrs(styles.trigger)}>
75
84
  <Tile glyph="layers" />
76
85
  <span {...stylex.attrs(styles.label)}
@@ -1,6 +1,7 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { Sx } from '../../internal/sx.js';
3
- export type WorkFoldProps = {
3
+ import { type CollapsibleRootProps } from '../collapsible/CollapsibleRoot.svelte';
4
+ export type WorkFoldProps = Omit<CollapsibleRootProps, 'children' | 'open' | 'sx' | 'class'> & {
4
5
  /** What the fold holds, in words: "Worked for 2m 5s". */
5
6
  label: string;
6
7
  /** Whether the work shows. Bindable. */
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Focus as Narvi's own parts show it, for an element of your own.
3
+ *
4
+ * - `ring`: for anything that takes focus, such as a button or a row. A 2px ring in the
5
+ * accent, 2px out, when the keyboard brings focus there, and none for a click. Normally it
6
+ * is a transparent hairline, which forced-colours mode turns into an edge.
7
+ * - `frame`: for a frame around a field, such as the box around an editor of your own. Its
8
+ * hairline turns to the ring, with a halo, while a field in it is typed into, as a text
9
+ * field's does. Buttons inside the frame show their own focus, not the frame's.
10
+ *
11
+ * <button {...stylex.attrs(focusRing.ring, styles.chip)}>
12
+ * <div {...stylex.attrs(focusRing.frame, styles.box)}>…your editor…</div>
13
+ */
14
+ import * as stylex from '@stylexjs/stylex';
15
+ export declare const focusRing: Readonly<{
16
+ readonly ring: Readonly<{
17
+ readonly outlineStyle: stylex.StyleXClassNameFor<"outlineStyle", "solid">;
18
+ readonly outlineWidth: stylex.StyleXClassNameFor<"outlineWidth", "1px" | "2px">;
19
+ readonly outlineColor: stylex.StyleXClassNameFor<"outlineColor", string>;
20
+ readonly outlineOffset: stylex.StyleXClassNameFor<"outlineOffset", "2px" | "-1px">;
21
+ }>;
22
+ readonly frame: Readonly<{
23
+ readonly boxShadow: stylex.StyleXClassNameFor<"boxShadow", `inset 0 0 0 1px ${stylex.StyleXVar<string>}` | `inset 0 0 0 1px ${stylex.StyleXVar<string>}, 0 0 0 3px ${stylex.StyleXVar<string>}`>;
24
+ readonly outlineStyle: stylex.StyleXClassNameFor<"outlineStyle", "solid">;
25
+ readonly outlineColor: stylex.StyleXClassNameFor<"outlineColor", "transparent">;
26
+ readonly outlineOffset: stylex.StyleXClassNameFor<"outlineOffset", "-1px">;
27
+ readonly outlineWidth: stylex.StyleXClassNameFor<"outlineWidth", "1px" | "2px">;
28
+ }>;
29
+ }>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Focus as Narvi's own parts show it, for an element of your own.
3
+ *
4
+ * - `ring`: for anything that takes focus, such as a button or a row. A 2px ring in the
5
+ * accent, 2px out, when the keyboard brings focus there, and none for a click. Normally it
6
+ * is a transparent hairline, which forced-colours mode turns into an edge.
7
+ * - `frame`: for a frame around a field, such as the box around an editor of your own. Its
8
+ * hairline turns to the ring, with a halo, while a field in it is typed into, as a text
9
+ * field's does. Buttons inside the frame show their own focus, not the frame's.
10
+ *
11
+ * <button {...stylex.attrs(focusRing.ring, styles.chip)}>
12
+ * <div {...stylex.attrs(focusRing.frame, styles.box)}>…your editor…</div>
13
+ */
14
+ import * as stylex from '@stylexjs/stylex';
15
+ import { colors } from './tokens.stylex.js';
16
+ import { media } from './media.stylex.js';
17
+ // A field inside the frame, as it takes the keyboard. A text field matches `:focus-visible`
18
+ // for a click too, as it is typed into either way.
19
+ const FIELD = `:has(:is(input, textarea, [contenteditable]:not([contenteditable="false"])):focus-visible)`;
20
+ const styles = stylex.create({
21
+ ring: {
22
+ outlineStyle: 'solid',
23
+ outlineWidth: { default: '1px', ':focus-visible': '2px' },
24
+ outlineColor: { default: 'transparent', ':focus-visible': colors.focusRing },
25
+ outlineOffset: { default: '-1px', ':focus-visible': '2px' }
26
+ },
27
+ frame: {
28
+ boxShadow: {
29
+ default: `inset 0 0 0 1px ${colors.border}`,
30
+ [FIELD]: `inset 0 0 0 1px ${colors.focusRing}, 0 0 0 3px ${colors.focusHalo}`
31
+ },
32
+ // In forced colours the shadow is gone; the outline is the edge, and thickens with focus
33
+ outlineStyle: 'solid',
34
+ outlineColor: 'transparent',
35
+ outlineOffset: '-1px',
36
+ outlineWidth: {
37
+ default: '1px',
38
+ [media.forcedColors]: { default: '1px', ':focus-within': '2px' }
39
+ }
40
+ }
41
+ });
42
+ export const focusRing = styles;
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export * as AppShell from './components/app-shell/index.js';
4
4
  export { getAppShellContext } from './components/app-shell/index.js';
5
5
  export type { AppShellBarProps, AppShellContext, AppShellHeaderProps, AppShellMainProps, AppShellPanelProps, AppShellPanesProps, AppShellRailProps, AppShellRootProps, AppShellSheetProps, AppShellSidebarProps, AppShellToggleProps } from './components/app-shell/index.js';
6
6
  export * as Activity from './components/activity/index.js';
7
- export type { ActivityContentProps, ActivityRootProps, ActivityStepKind, ActivityStepProps, ActivityStepStatus, ActivityThoughtProps, ActivityTriggerProps } from './components/activity/index.js';
7
+ export type { ActivityContentProps, ActivityIconProps, ActivityIconTone, ActivityRootProps, ActivityStepKind, ActivityStepProps, ActivityStepStatus, ActivityThoughtProps, ActivityTriggerProps } from './components/activity/index.js';
8
8
  export { default as Announcer } from './components/announcer/Announcer.svelte';
9
9
  export type { AnnouncerProps } from './components/announcer/Announcer.svelte';
10
10
  export * as Avatar from './components/avatar/index.js';
@@ -55,7 +55,7 @@ export type { FrameProps } from './components/frame/Frame.svelte';
55
55
  export { default as Grid } from './components/grid/Grid.svelte';
56
56
  export type { GridAlign, GridColumns, GridGap, GridProps } from './components/grid/Grid.svelte';
57
57
  export { default as Heading } from './components/heading/Heading.svelte';
58
- export type { HeadingLevel, HeadingProps, HeadingSize } from './components/heading/Heading.svelte';
58
+ export type { HeadingLevel, HeadingProps, HeadingSize, HeadingWeight } from './components/heading/Heading.svelte';
59
59
  export * as HoverCard from './components/hover-card/index.js';
60
60
  export type { HoverCardContentProps, HoverCardRootProps } from './components/hover-card/index.js';
61
61
  export { default as Input } from './components/input/Input.svelte';
@@ -67,7 +67,7 @@ export type { LinkProps } from './components/link/Link.svelte';
67
67
  export * as Menu from './components/menu/index.js';
68
68
  export type { MenuCheckboxItemProps, MenuContentProps, MenuGroupProps, MenuItemProps, MenuLabelProps, MenuRadioGroupProps, MenuRadioItemProps, MenuSeparatorProps, MenuSubContentProps, MenuSubTriggerProps } from './components/menu/index.js';
69
69
  export * as Message from './components/message/index.js';
70
- export type { MessageActionProps, MessageActionsProps, MessageContentProps, MessageCopyProps, MessageFrom, MessageHeaderProps, MessagePendingProps, MessageRootProps, MessageTimeProps } from './components/message/index.js';
70
+ export type { MessageActionProps, MessageActionsProps, MessageBubbleProps, MessageContentProps, MessageCopyProps, MessageFrom, MessageHeaderProps, MessagePendingProps, MessageRootProps, MessageTextSize, MessageTimeProps } from './components/message/index.js';
71
71
  export { default as Markdown } from './components/markdown/Markdown.svelte';
72
72
  export type { MarkdownProps } from './components/markdown/Markdown.svelte';
73
73
  export { copyAsWritten } from './components/markdown/copy.js';
@@ -86,7 +86,7 @@ export type { PopoverContentProps } from './components/popover/index.js';
86
86
  export { default as Questionnaire } from './components/questionnaire/Questionnaire.svelte';
87
87
  export type { Question, QuestionAnswer, QuestionnaireAnswers, QuestionnaireProps } from './components/questionnaire/Questionnaire.svelte';
88
88
  export { default as QueuedMessage } from './components/queued-message/QueuedMessage.svelte';
89
- export type { QueuedMessageProps, QueuedMessageStatus } from './components/queued-message/QueuedMessage.svelte';
89
+ export type { QueuedMessageAction, QueuedMessageProps, QueuedMessageStatus } from './components/queued-message/QueuedMessage.svelte';
90
90
  export * as Rail from './components/rail/index.js';
91
91
  export type { RailItemProps, RailRootProps } from './components/rail/index.js';
92
92
  export * as Reasoning from './components/reasoning/index.js';
@@ -122,6 +122,8 @@ export { default as Slider } from './components/slider/Slider.svelte';
122
122
  export type { SliderProps } from './components/slider/Slider.svelte';
123
123
  export { default as Spinner } from './components/spinner/Spinner.svelte';
124
124
  export type { SpinnerProps } from './components/spinner/Spinner.svelte';
125
+ export { default as SplitButton } from './components/split-button/SplitButton.svelte';
126
+ export type { SplitButtonProps } from './components/split-button/SplitButton.svelte';
125
127
  export { default as Stack } from './components/stack/Stack.svelte';
126
128
  export type { StackAlign, StackDirection, StackGap, StackJustify, StackProps } from './components/stack/Stack.svelte';
127
129
  export * as Suggestions from './components/suggestions/index.js';
@@ -141,12 +143,13 @@ export type { TextFace, TextProps, TextTone, TextVariant, TextWeight } from './c
141
143
  export { typography } from './typography.js';
142
144
  export type { TypeRole } from './typography.js';
143
145
  export { visuallyHidden } from './visually-hidden.js';
146
+ export { focusRing } from './focus-ring.js';
144
147
  export type { IconComponent } from './internal/icon.js';
145
148
  export { default as Textarea } from './components/textarea/Textarea.svelte';
146
149
  export type { TextareaProps } from './components/textarea/Textarea.svelte';
147
150
  export { default as Toggle } from './components/toggle/Toggle.svelte';
148
151
  export type { ToggleProps } from './components/toggle/Toggle.svelte';
149
- export type { ToggleSize } from './internal/toggle.js';
152
+ export type { ToggleSize, ToggleTone } from './internal/toggle.js';
150
153
  export * as ToggleGroup from './components/toggle-group/index.js';
151
154
  export type { ToggleGroupItemProps, ToggleGroupRootProps } from './components/toggle-group/index.js';
152
155
  export * as Tool from './components/tool/index.js';
package/dist/index.js CHANGED
@@ -4,7 +4,8 @@ export { default as Approval } from './components/approval/Approval.svelte';
4
4
  // <AppShell.Sidebar>, <AppShell.Main>, <AppShell.Header>, <AppShell.Panel>, <AppShell.Toggle>
5
5
  export * as AppShell from './components/app-shell/index.js';
6
6
  export { getAppShellContext } from './components/app-shell/index.js';
7
- // Compound: <Activity.Root>, <Activity.Trigger>, <Activity.Content>, <Activity.Step>, <Activity.Thought>
7
+ // Compound: <Activity.Root>, <Activity.Trigger>, <Activity.Content>, <Activity.Step>, <Activity.Thought>,
8
+ // <Activity.Icon>
8
9
  export * as Activity from './components/activity/index.js';
9
10
  export { default as Announcer } from './components/announcer/Announcer.svelte';
10
11
  // Compound: <Avatar.Root>, <Avatar.Image>, <Avatar.Fallback>
@@ -52,7 +53,8 @@ export { default as Link } from './components/link/Link.svelte';
52
53
  // Compound: <Menu.Root>, <Menu.Trigger>, <Menu.Content>, <Menu.Item>, <Menu.CheckboxItem>,
53
54
  // <Menu.RadioGroup>, <Menu.RadioItem>, <Menu.Group>, <Menu.Label>, <Menu.Separator>, <Menu.Sub>…
54
55
  export * as Menu from './components/menu/index.js';
55
- // Compound: <Message.Root>, <Message.Header>, <Message.Pending>, <Message.Content>, <Message.Actions>, <Message.Action>, <Message.Copy>
56
+ // Compound: <Message.Root>, <Message.Header>, <Message.Pending>, <Message.Content>, <Message.Bubble>,
57
+ // <Message.Actions>, <Message.Action>, <Message.Copy>, <Message.Time>
56
58
  export * as Message from './components/message/index.js';
57
59
  export { default as Markdown } from './components/markdown/Markdown.svelte';
58
60
  export { copyAsWritten } from './components/markdown/copy.js';
@@ -90,6 +92,7 @@ export * as Sidebar from './components/sidebar/index.js';
90
92
  export { default as Skeleton } from './components/skeleton/Skeleton.svelte';
91
93
  export { default as Slider } from './components/slider/Slider.svelte';
92
94
  export { default as Spinner } from './components/spinner/Spinner.svelte';
95
+ export { default as SplitButton } from './components/split-button/SplitButton.svelte';
93
96
  export { default as Stack } from './components/stack/Stack.svelte';
94
97
  // Compound: <Suggestions.Root>, <Suggestions.Item>
95
98
  export * as Suggestions from './components/suggestions/index.js';
@@ -103,6 +106,9 @@ export { default as Text } from './components/text/Text.svelte';
103
106
  export { typography } from './typography.js';
104
107
  // Hidden from sight, kept for assistive technology: `stylex.attrs(visuallyHidden)`
105
108
  export { visuallyHidden } from './visually-hidden.js';
109
+ // Focus as Narvi's parts show it: `focusRing.ring` for a control of your own, `focusRing.frame`
110
+ // for the box around a field of your own
111
+ export { focusRing } from './focus-ring.js';
106
112
  export { default as Textarea } from './components/textarea/Textarea.svelte';
107
113
  export { default as Toggle } from './components/toggle/Toggle.svelte';
108
114
  // Compound: <ToggleGroup.Root>, <ToggleGroup.Item>
@@ -2,6 +2,8 @@
2
2
  A region that folds open and shut. Its height eases between nothing and its
3
3
  content's height by moving a grid row between 0fr and 1fr, which needs no
4
4
  measuring. While shut it is inert: out of the tab order and the accessibility tree.
5
+ Once it has finished closing, its content is not rendered either, so the page's find,
6
+ `checkVisibility()` and a test's visibility checks all know it is not shown.
5
7
  -->
6
8
  <script lang="ts" module>
7
9
  import * as stylex from '@stylexjs/stylex';
@@ -24,9 +26,20 @@
24
26
  gridTemplateRows: '1fr',
25
27
  opacity: 1
26
28
  },
29
+ // Shut, the content stops being rendered at the end of the fold, and starts again as it
30
+ // opens: `visibility` turns at those ends by itself, `content-visibility` as a discrete step
27
31
  inner: {
28
32
  minHeight: 0,
29
- overflow: 'hidden'
33
+ overflow: 'hidden',
34
+ visibility: 'hidden',
35
+ contentVisibility: 'hidden',
36
+ transitionProperty: 'visibility, content-visibility',
37
+ transitionBehavior: 'allow-discrete',
38
+ transitionDuration: motion.slow
39
+ },
40
+ innerOpen: {
41
+ visibility: 'visible',
42
+ contentVisibility: 'visible'
30
43
  }
31
44
  });
32
45
  </script>
@@ -50,7 +63,7 @@
50
63
  </script>
51
64
 
52
65
  <div inert={!open} {...rest} {...attrs([styles.region, open && styles.open, sx], className)}>
53
- <div {...stylex.attrs(styles.inner)}>
66
+ <div {...stylex.attrs(styles.inner, open && styles.innerOpen)}>
54
67
  <div {...attrs([innerSx], innerClass)}>
55
68
  {@render children?.()}
56
69
  </div>