@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
@@ -38,6 +38,34 @@
38
38
  steer: ['M3.5 3v5.5a2 2 0 0 0 2 2h7', 'M10 8l2.5 2.5L10 13'],
39
39
  search: ['M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Z', 'm10.5 10.5 3 3'],
40
40
  file: ['M4.25 2.25h4.5l3 3v8.5h-7.5Z', 'M8.75 2.25v3h3'],
41
+ // Files by kind: the page, with what it holds on it
42
+ fileCode: [
43
+ 'M4.25 2.25h4.5l3 3v8.5h-7.5Z',
44
+ 'M8.75 2.25v3h3',
45
+ 'M7 8.5 5.75 9.75 7 11',
46
+ 'M9 8.5l1.25 1.25L9 11'
47
+ ],
48
+ fileText: [
49
+ 'M4.25 2.25h4.5l3 3v8.5h-7.5Z',
50
+ 'M8.75 2.25v3h3',
51
+ 'M6.25 8.5h3.5',
52
+ 'M6.25 10.75h3.5'
53
+ ],
54
+ fileData: [
55
+ 'M4.25 2.25h4.5l3 3v8.5h-7.5Z',
56
+ 'M8.75 2.25v3h3',
57
+ 'M7 8c-.5 0-.75.3-.75.75v.4c0 .4-.25.6-.6.6.35 0 .6.2.6.6v.4c0 .45.25.75.75.75',
58
+ 'M9 8c.5 0 .75.3.75.75v.4c0 .4.25.6.6.6-.35 0-.6.2-.6.6v.4c0 .45-.25.75-.75.75'
59
+ ],
60
+ fileImage: [
61
+ 'M4.25 2.25h4.5l3 3v8.5h-7.5Z',
62
+ 'M8.75 2.25v3h3',
63
+ 'm4.25 12.5 2.25-2.25 1.75 1.75 1.25-1.25 2.25 2.25',
64
+ 'M6.75 7.75h.01'
65
+ ],
66
+ folder: [
67
+ 'M2.25 4.5c0-.69.56-1.25 1.25-1.25h2.6c.4 0 .77.19 1 .51l.75 1.04c.24.32.61.5 1 .5h3.65c.69 0 1.25.56 1.25 1.25v5.7c0 .69-.56 1.25-1.25 1.25h-9c-.69 0-1.25-.56-1.25-1.25Z'
68
+ ],
41
69
  selector: ['M5.25 6 8 3.25 10.75 6', 'M5.25 10 8 12.75 10.75 10'],
42
70
  // A thought: a bulb with its filament
43
71
  bulb: [
@@ -21,6 +21,11 @@ declare const paths: {
21
21
  readonly steer: readonly ["M3.5 3v5.5a2 2 0 0 0 2 2h7", "M10 8l2.5 2.5L10 13"];
22
22
  readonly search: readonly ["M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Z", "m10.5 10.5 3 3"];
23
23
  readonly file: readonly ["M4.25 2.25h4.5l3 3v8.5h-7.5Z", "M8.75 2.25v3h3"];
24
+ readonly fileCode: readonly ["M4.25 2.25h4.5l3 3v8.5h-7.5Z", "M8.75 2.25v3h3", "M7 8.5 5.75 9.75 7 11", "M9 8.5l1.25 1.25L9 11"];
25
+ readonly fileText: readonly ["M4.25 2.25h4.5l3 3v8.5h-7.5Z", "M8.75 2.25v3h3", "M6.25 8.5h3.5", "M6.25 10.75h3.5"];
26
+ readonly fileData: readonly ["M4.25 2.25h4.5l3 3v8.5h-7.5Z", "M8.75 2.25v3h3", "M7 8c-.5 0-.75.3-.75.75v.4c0 .4-.25.6-.6.6.35 0 .6.2.6.6v.4c0 .45.25.75.75.75", "M9 8c.5 0 .75.3.75.75v.4c0 .4.25.6.6.6-.35 0-.6.2-.6.6v.4c0 .45-.25.75-.75.75"];
27
+ readonly fileImage: readonly ["M4.25 2.25h4.5l3 3v8.5h-7.5Z", "M8.75 2.25v3h3", "m4.25 12.5 2.25-2.25 1.75 1.75 1.25-1.25 2.25 2.25", "M6.75 7.75h.01"];
28
+ readonly folder: readonly ["M2.25 4.5c0-.69.56-1.25 1.25-1.25h2.6c.4 0 .77.19 1 .51l.75 1.04c.24.32.61.5 1 .5h3.65c.69 0 1.25.56 1.25 1.25v5.7c0 .69-.56 1.25-1.25 1.25h-9c-.69 0-1.25-.56-1.25-1.25Z"];
24
29
  readonly selector: readonly ["M5.25 6 8 3.25 10.75 6", "M5.25 10 8 12.75 10.75 10"];
25
30
  readonly bulb: readonly ["M6.25 13.75h3.5", "M8 2.25a4 4 0 0 0-2.4 7.2c.42.32.65.7.65 1.15v.65h3.5v-.65c0-.45.23-.83.65-1.15A4 4 0 0 0 8 2.25Z"];
26
31
  readonly layers: readonly ["M8 2.75 13.25 5.5 8 8.25 2.75 5.5Z", "M2.75 8.25 8 11l5.25-2.75", "M2.75 11 8 13.75 13.25 11"];
@@ -25,8 +25,8 @@
25
25
  transitionDuration: motion.slow,
26
26
  transitionTimingFunction: 'ease'
27
27
  },
28
- md: { width: '1rem', height: '1.5rem' },
29
- sm: { width: '1rem', height: '1.25rem' },
28
+ md: { '--narvi-icon-size': '1rem', width: '1rem', height: '1.5rem' },
29
+ sm: { '--narvi-icon-size': '0.875rem', width: '1rem', height: '1.25rem' },
30
30
  neutral: {},
31
31
  live: { color: colors.accent },
32
32
  success: { color: colors.success },
@@ -54,6 +54,7 @@
54
54
 
55
55
  <span
56
56
  aria-hidden="true"
57
+ data-icons
57
58
  data-slot="tile"
58
59
  data-tone={tone}
59
60
  {...stylex.attrs(styles.tile, styles[size], styles[tone], sx)}
@@ -7,6 +7,8 @@
7
7
  */
8
8
  import * as stylex from '@stylexjs/stylex';
9
9
  import './icons.css';
10
+ /** The `style` that gives a floating surface a `width` of its own, with any `style` given too. */
11
+ export declare function widthStyle(width: string | undefined, style: unknown): string | undefined;
10
12
  export declare const layer: Readonly<{
11
13
  readonly surface: Readonly<{
12
14
  readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
@@ -35,6 +37,16 @@ export declare const layer: Readonly<{
35
37
  readonly transitionDuration: stylex.StyleXClassNameFor<"transitionDuration", string>;
36
38
  readonly transitionTimingFunction: stylex.StyleXClassNameFor<"transitionTimingFunction", string>;
37
39
  }>;
40
+ readonly sized: Readonly<{
41
+ readonly width: stylex.StyleXClassNameFor<"width", "min(var(--narvi-layer-width), var(--bits-floating-available-width, 100vw))">;
42
+ readonly minWidth: stylex.StyleXClassNameFor<"minWidth", 0>;
43
+ readonly maxWidth: stylex.StyleXClassNameFor<"maxWidth", "none">;
44
+ }>;
45
+ readonly column: Readonly<{
46
+ readonly display: stylex.StyleXClassNameFor<"display", "flex">;
47
+ readonly flexDirection: stylex.StyleXClassNameFor<"flexDirection", "column">;
48
+ readonly gap: stylex.StyleXClassNameFor<"gap", "0.625rem">;
49
+ }>;
38
50
  readonly item: Readonly<{
39
51
  readonly position: stylex.StyleXClassNameFor<"position", "relative">;
40
52
  readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
@@ -72,6 +84,17 @@ export declare const layer: Readonly<{
72
84
  readonly textOverflow: stylex.StyleXClassNameFor<"textOverflow", "ellipsis">;
73
85
  readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
74
86
  }>;
87
+ readonly text: Readonly<{
88
+ readonly display: stylex.StyleXClassNameFor<"display", "flex">;
89
+ readonly flexDirection: stylex.StyleXClassNameFor<"flexDirection", "column">;
90
+ readonly gap: stylex.StyleXClassNameFor<"gap", "0.125rem">;
91
+ readonly minWidth: stylex.StyleXClassNameFor<"minWidth", 0>;
92
+ readonly flexGrow: stylex.StyleXClassNameFor<"flexGrow", 1>;
93
+ }>;
94
+ readonly description: Readonly<{
95
+ readonly color: stylex.StyleXClassNameFor<"color", string>;
96
+ readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
97
+ }>;
75
98
  readonly trailing: Readonly<{
76
99
  readonly display: stylex.StyleXClassNameFor<"display", "inline-flex">;
77
100
  readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
@@ -12,6 +12,13 @@ import './icons.css';
12
12
  const CLOSED = ':is([data-state="closed"])';
13
13
  const HIGHLIGHTED = ':is([data-highlighted])';
14
14
  const DISABLED = ':is([data-disabled])';
15
+ /** The `style` that gives a floating surface a `width` of its own, with any `style` given too. */
16
+ export function widthStyle(width, style) {
17
+ const own = typeof style === 'string' && style ? style : undefined;
18
+ if (!width)
19
+ return own;
20
+ return [`--narvi-layer-width: ${width}`, own].filter(Boolean).join('; ');
21
+ }
15
22
  export const layer = stylex.create({
16
23
  surface: {
17
24
  boxSizing: 'border-box',
@@ -47,6 +54,15 @@ export const layer = stylex.create({
47
54
  transitionDuration: { default: motion.fast, [CLOSED]: '80ms' },
48
55
  transitionTimingFunction: motion.easeOut
49
56
  },
57
+ // A width of its own (`--narvi-layer-width`), in place of fitting its items: still no wider
58
+ // than the room bits-ui measures for it
59
+ sized: {
60
+ width: 'min(var(--narvi-layer-width), var(--bits-floating-available-width, 100vw))',
61
+ minWidth: 0,
62
+ maxWidth: 'none'
63
+ },
64
+ // Content of its own, one part under another, with room between them
65
+ column: { display: 'flex', flexDirection: 'column', gap: '0.625rem' },
50
66
  // A row in a menu, a select or the palette
51
67
  item: {
52
68
  position: 'relative',
@@ -95,6 +111,9 @@ export const layer = stylex.create({
95
111
  textOverflow: 'ellipsis',
96
112
  whiteSpace: 'nowrap'
97
113
  },
114
+ // A label with a line under it, such as what a choice means
115
+ text: { display: 'flex', flexDirection: 'column', gap: '0.125rem', minWidth: 0, flexGrow: 1 },
116
+ description: { color: colors.textMuted, fontSize: font.sizeCaption },
98
117
  // A shortcut or a count, at the far end
99
118
  trailing: {
100
119
  display: 'inline-flex',
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * The look of a button that stays pressed: Toggle, and the items of a
3
3
  * ToggleGroup. Off, it is as quiet as a ghost button; on, it is lit with
4
- * the accent, the one colour that marks state, as Composer's toggles are.
4
+ * the accent, the one colour that marks state, as Composer's toggles are, or, `neutral`, with
5
+ * the fill of what is chosen.
5
6
  */
6
7
  import * as stylex from '@stylexjs/stylex';
7
8
  export declare const toggle: Readonly<{
@@ -69,5 +70,11 @@ export declare const toggle: Readonly<{
69
70
  readonly width: stylex.StyleXClassNameFor<"width", "2rem">;
70
71
  readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", 0>;
71
72
  }>;
73
+ readonly neutral: Readonly<{
74
+ readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", string | null>;
75
+ readonly color: stylex.StyleXClassNameFor<"color", string | null>;
76
+ }>;
72
77
  }>;
73
78
  export type ToggleSize = 'sm' | 'md';
79
+ /** How a pressed toggle shows it: lit in the `accent`, or `neutral`, in the fill of what is chosen. */
80
+ export type ToggleTone = 'accent' | 'neutral';
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * The look of a button that stays pressed: Toggle, and the items of a
3
3
  * ToggleGroup. Off, it is as quiet as a ghost button; on, it is lit with
4
- * the accent, the one colour that marks state, as Composer's toggles are.
4
+ * the accent, the one colour that marks state, as Composer's toggles are, or, `neutral`, with
5
+ * the fill of what is chosen.
5
6
  */
6
7
  import * as stylex from '@stylexjs/stylex';
7
8
  import { colors, font, motion, radius } from '../tokens.stylex.js';
@@ -79,5 +80,22 @@ export const toggle = stylex.create({
79
80
  '::after': { content: '""', position: 'absolute', insetInline: 0, insetBlock: '-4px' }
80
81
  },
81
82
  iconSm: { width: '1.75rem', paddingInline: 0 },
82
- iconMd: { width: '2rem', paddingInline: 0 }
83
+ iconMd: { width: '2rem', paddingInline: 0 },
84
+ // On, without the accent: the fill of what is chosen, in the text's colour. For a toolbar's
85
+ // icons, such as a panel shown or hidden, where a lit one would read as something live.
86
+ neutral: {
87
+ backgroundColor: {
88
+ default: 'transparent',
89
+ ':hover': { default: null, [media.hover]: colors.fillHover },
90
+ [ON]: {
91
+ default: colors.fillSelected,
92
+ ':hover': { default: null, [media.hover]: colors.fillSelected }
93
+ }
94
+ },
95
+ color: {
96
+ default: colors.textMuted,
97
+ ':hover': { default: null, [media.hover]: colors.text },
98
+ [ON]: { default: colors.text, [media.forcedColors]: 'Highlight' }
99
+ }
100
+ }
83
101
  });
@@ -16,6 +16,13 @@ export declare const reExtension: RegExp;
16
16
  * "1/2", "v1.2.3" and "github.com/owner/repo" are not paths.
17
17
  */
18
18
  export declare function looksLikePath(path: string, hasPosition?: boolean): boolean;
19
+ /**
20
+ * What kind of thing a path names, by its name: a `folder` (it ends in a slash), `code`, an
21
+ * `image`, `text` to read, `data` (configuration and records), or any other `file`.
22
+ */
23
+ export type FileKind = 'folder' | 'code' | 'image' | 'text' | 'data' | 'file';
24
+ /** What kind of thing a path names: see `FileKind`. */
25
+ export declare function fileKind(path: string): FileKind;
19
26
  export declare function basename(path: string): string;
20
27
  /**
21
28
  * What a chip shows for a path: the file's name, or the whole path when it leaves the
@@ -50,6 +50,35 @@ export function looksLikePath(path, hasPosition = false) {
50
50
  // `./.env` and `/etc/hosts` name files without an extension; `src/lib` alone could be anything
51
51
  return hasExtension || rooted || segments.length > 2;
52
52
  }
53
+ const KINDS = {
54
+ code: new Set(('ts tsx mts cts js jsx mjs cjs svelte vue astro py pyi rb go rs java kt kts swift c h cc ' +
55
+ 'cpp cxx hpp hh m mm cs fs php sh bash zsh fish ps1 lua dart scala ex exs erl hrl clj ' +
56
+ 'cljs elm hs ml mli zig nim jl r pl sql html htm css scss sass less styl wasm wat gleam').split(' ')),
57
+ image: new Set('png jpg jpeg gif webp avif svg ico bmp tif tiff heic heif'.split(' ')),
58
+ text: new Set('md mdx markdown txt rst adoc asciidoc org tex rtf log pdf'.split(' ')),
59
+ data: new Set(('json jsonc json5 jsonl ndjson yaml yml toml xml csv tsv ini cfg conf env lock plist ' +
60
+ 'properties graphql gql proto prisma').split(' '))
61
+ };
62
+ // Files whose name is their kind: `Makefile`, `Dockerfile`, `.gitignore`
63
+ const CODE_NAMES = /^(?:[A-Z][a-z]*file|Dockerfile\..+|Containerfile)$/;
64
+ const DATA_NAMES = /^\.(?:[a-z]+rc|env(?:\..+)?|git(?:ignore|attributes|modules)|editorconfig|npmrc|nvmrc|prettierrc|eslintrc)$/;
65
+ /** What kind of thing a path names: see `FileKind`. */
66
+ export function fileKind(path) {
67
+ if (/[\\/]$/.test(path))
68
+ return 'folder';
69
+ const name = basename(path);
70
+ if (CODE_NAMES.test(name))
71
+ return 'code';
72
+ if (DATA_NAMES.test(name))
73
+ return 'data';
74
+ const extension = /\.([A-Za-z0-9]+)$/.exec(name)?.[1]?.toLowerCase();
75
+ if (!extension || extension === name.slice(1).toLowerCase())
76
+ return 'file';
77
+ for (const [kind, extensions] of Object.entries(KINDS))
78
+ if (extensions.has(extension))
79
+ return kind;
80
+ return 'file';
81
+ }
53
82
  export function basename(path) {
54
83
  const trimmed = path.replace(/[\\/]+$/, '');
55
84
  const base = trimmed.slice(Math.max(trimmed.lastIndexOf('/'), trimmed.lastIndexOf('\\')) + 1);
@@ -1,6 +1,19 @@
1
- import { formatPosition, looksLikePath, splitPosition, type FileReference } from './file-paths.js';
1
+ import { fileKind, formatPosition, looksLikePath, splitPosition, type FileKind, type FileReference } from './file-paths.js';
2
2
  import { type MarkdownPlugin } from './plugin.js';
3
- export { formatPosition, looksLikePath, splitPosition, type FileReference };
3
+ export { fileKind, formatPosition, looksLikePath, splitPosition, type FileKind, type FileReference };
4
+ /** A file named in a reply, as `icon` is asked about it: where it is, and what kind of thing. */
5
+ export type FileChipTarget = FileReference & {
6
+ kind: FileKind;
7
+ };
8
+ /**
9
+ * A chip's icon of the app's own: an SVG image, by its address (a `data:` URL, or one the
10
+ * page can load), drawn as a mask in `color`, so it takes the chip's colours unless given its
11
+ * own. `color` is any CSS colour, `light-dark()` too.
12
+ */
13
+ export type FileIcon = {
14
+ url: string;
15
+ color?: string | undefined;
16
+ };
4
17
  export type FilesOptions = {
5
18
  /**
6
19
  * Says whether a path names a file the app knows, and returns it as the app wants it (made
@@ -11,6 +24,13 @@ export type FilesOptions = {
11
24
  resolve?: ((path: string) => string | null | undefined) | undefined;
12
25
  /** Opens a file when its chip is activated. Without it, chips only show. */
13
26
  open?: ((file: FileReference, event: MouseEvent) => void) | undefined;
27
+ /**
28
+ * The icon a chip shows, from the app's own set: given the file and its kind (`folder`,
29
+ * `code`, `image`, `text`, `data` or `file`). Return null for Narvi's own icon for the kind.
30
+ * It is asked once per chip, as the reply is read, so finished replies are still written
31
+ * as markup (`static`).
32
+ */
33
+ icon?: ((file: FileChipTarget) => FileIcon | null | undefined) | undefined;
14
34
  };
15
35
  /** The first-party file plugin. */
16
36
  export declare function files(options?: FilesOptions): MarkdownPlugin;
@@ -9,10 +9,15 @@
9
9
  * are all read, as is `[the config](src/config.ts#L10)`.
10
10
  */
11
11
  import MarkdownFile, { chipFile, fileHtml } from '../components/markdown/MarkdownFile.svelte';
12
- import { displayName, formatPosition, looksLikePath, namesPath, reExtension, splitPosition } from './file-paths.js';
12
+ import { displayName, fileKind, formatPosition, looksLikePath, namesPath, reExtension, splitPosition } from './file-paths.js';
13
13
  import { mapInlines, withProps } from './plugin.js';
14
14
  import { inlineText } from './table.js';
15
- export { formatPosition, looksLikePath, splitPosition };
15
+ export { fileKind, formatPosition, looksLikePath, splitPosition };
16
+ // What may go in a style attribute: no quote, backslash or line ending to break out of it
17
+ const reIconUrl = /^[^"\\\r\n]{1,20000}$/;
18
+ const reIconColor = /^[\w\s#%(),./-]{1,200}$/;
19
+ /** The words of a single-word link that name a file anyway: `README`, `Makefile`. */
20
+ const reNamedFile = /^(?:README|LICEN[CS]E|CHANGELOG|CHANGES|CONTRIBUTING|AUTHORS|NOTICE|COPYING|CODEOWNERS|TODO|VERSION|SECURITY|[A-Z][a-z]*file)$/;
16
21
  function decode(url) {
17
22
  try {
18
23
  return decodeURIComponent(url);
@@ -23,7 +28,22 @@ function decode(url) {
23
28
  }
24
29
  /** The first-party file plugin. */
25
30
  export function files(options = {}) {
26
- const { resolve, open } = options;
31
+ const { resolve, open, icon } = options;
32
+ /** The app's icon for a chip, if it gives one that can be written safely. */
33
+ const iconOf = (target) => {
34
+ let given;
35
+ try {
36
+ given = icon?.(target);
37
+ }
38
+ catch {
39
+ // An icon that throws leaves the chip with Narvi's own
40
+ return undefined;
41
+ }
42
+ if (!given || !reIconUrl.test(given.url))
43
+ return undefined;
44
+ const color = given.color && reIconColor.test(given.color) ? given.color : undefined;
45
+ return color ? { url: given.url, color } : { url: given.url };
46
+ };
27
47
  /**
28
48
  * The file some text names, or null. `certain` is for a `file:` address, which names a
29
49
  * file whatever it looks like, spaces and all.
@@ -69,21 +89,32 @@ export function files(options = {}) {
69
89
  .replace(/[\p{Cc}\p{Cf}]/gu, '')
70
90
  .trim();
71
91
  const tokens = words.split(/\s+/).map((token) => token.replace(/[.,;:!?)\]]+$/, ''));
72
- const readsAsFile = (token) => /[\\/]/.test(token) || reExtension.test(splitPosition(token).path);
73
- const honest = tokens.length === 1
74
- ? namesPath(splitPosition(tokens[0]).path, file.path)
75
- : tokens.every((token) => !readsAsFile(token) || namesPath(splitPosition(token).path, file.path));
92
+ // What could be a file's name: a path, a name with an extension, a dotfile, one with an
93
+ // underscore (`id_rsa`), or a name files go by without an extension (`README`). A plain
94
+ // word, such as "here" or "this", is none of these, alone or among others.
95
+ const readsAsFile = (token) => /[\\/_]/.test(token) ||
96
+ token.startsWith('.') ||
97
+ reExtension.test(splitPosition(token).path) ||
98
+ reNamedFile.test(token);
99
+ const honest = tokens.length > 0 &&
100
+ tokens[0] !== '' &&
101
+ tokens.every((token) => !readsAsFile(token) || namesPath(splitPosition(token).path, file.path));
76
102
  if (honest)
77
103
  return children;
78
104
  return [{ type: 'text', value: displayName(file.path) + formatPosition(file) }];
79
105
  };
80
- const chip = (file, source, children, link = false) => ({
81
- type: 'custom',
82
- name: 'file',
83
- // `link` marks a chip whose label is the words of a link, not a path
84
- data: link ? { ...file, source, link } : { ...file, source },
85
- children
86
- });
106
+ const chip = (file, source, children, link = false) => {
107
+ // A folder is named with a slash at its end, as written or as the app resolves it
108
+ const kind = fileKind(/[\\/]$/.test(source.replace(/#.*$/, '')) ? `${file.path}/` : file.path);
109
+ const own = iconOf({ ...file, kind });
110
+ return {
111
+ type: 'custom',
112
+ name: 'file',
113
+ // `link` marks a chip whose label is the words of a link, not a path
114
+ data: { ...file, source, kind, ...(link ? { link } : {}), ...(own ? { icon: own } : {}) },
115
+ children
116
+ };
117
+ };
87
118
  return {
88
119
  name: 'files',
89
120
  transform: (block) => mapInlines(block, (node, { inLink }) => {
@@ -43,12 +43,15 @@ export declare const colors: stylex.VarGroup<Readonly<{
43
43
  success: string;
44
44
  warning: string;
45
45
  danger: string;
46
+ info: string;
46
47
  successSoft: string;
47
48
  warningSoft: string;
48
49
  dangerSoft: string;
50
+ infoSoft: string;
49
51
  successText: string;
50
52
  warningText: string;
51
53
  dangerText: string;
54
+ infoText: string;
52
55
  codeKey: string;
53
56
  codeString: string;
54
57
  codeNumber: string;
@@ -64,19 +64,23 @@ export const colors = stylex.defineVars({
64
64
  primary: 'light-dark(#1c1e21, #eceff4)',
65
65
  onPrimary: 'light-dark(#fafafa, #0b0d11)',
66
66
  // Status: definite colours, each holding 4.5:1 as small text on a hovered row of the
67
- // page, on every stone a preset offers
67
+ // page, on every stone a preset offers. `info` is for what is only to be known, such as a
68
+ // note or a comment: a blue of its own, which stays blue whatever accent a preset picks.
68
69
  success: 'light-dark(#007835, #37d16c)',
69
70
  warning: 'light-dark(#8b6001, #f5af20)',
70
71
  danger: 'light-dark(#c92228, #ff7a70)',
72
+ info: 'light-dark(#0164cf, #72acfe)',
71
73
  // Behind a status: a wash of its colour, stronger at night so it still reads
72
74
  successSoft: 'light-dark(rgb(0 120 53 / 0.12), rgb(55 209 108 / 0.16))',
73
75
  warningSoft: 'light-dark(rgb(139 96 1 / 0.12), rgb(245 175 32 / 0.16))',
74
76
  dangerSoft: 'light-dark(rgb(201 34 40 / 0.12), rgb(255 122 112 / 0.16))',
77
+ infoSoft: 'light-dark(rgb(1 100 207 / 0.12), rgb(114 172 254 / 0.16))',
75
78
  // Small text in a status colour: mixed toward the text colour, so a 12px label
76
79
  // on its soft wash still holds 4.5:1
77
80
  successText: 'light-dark(#195c2e, #a0dcac)',
78
81
  warningText: 'light-dark(#674600, #f2ca8d)',
79
82
  dangerText: 'light-dark(#7a342f, #ffb9b1)',
83
+ infoText: 'light-dark(#1a4f8c, #a9c8f8)',
80
84
  // Code: keys in slate blue, strings in green, numbers in copper, literals in magenta, and
81
85
  // punctuation in a grey that stands back. Each holds 4.5:1 on `fillSunken` in both
82
86
  // schemes, punctuation too: a brace is text.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diegopluna/narvi",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "packageManager": "pnpm@12.18.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -12,7 +12,7 @@ metadata:
12
12
  Grid, and Narvi's conventions for colour, labels and copy.
13
13
  type: core
14
14
  library: '@diegopluna/narvi'
15
- library_version: '0.3.2'
15
+ library_version: '0.3.4'
16
16
  requires:
17
17
  - setup
18
18
  sources:
@@ -32,6 +32,9 @@ sources:
32
32
  - src/lib/components/list/ListRoot.svelte
33
33
  - src/lib/components/choice-cards/ChoiceCards.svelte
34
34
  - src/lib/components/dialog/DialogContent.svelte
35
+ - src/lib/components/tab-strip/TabStrip.svelte
36
+ - src/lib/components/split-button/SplitButton.svelte
37
+ - src/lib/components/app-shell/AppShellPanel.svelte
35
38
  ---
36
39
 
37
40
  # Build interfaces with Narvi
@@ -117,6 +120,8 @@ The same `child` pattern applies to `Menu.Trigger`, `Popover.Trigger`, `Tooltip.
117
120
  `HoverCard.Trigger`, `Sheet.Trigger` and `Collapsible.Trigger`.
118
121
 
119
122
  `Dialog.Content` takes `size`: `sm` 24rem, `md` 32 (the default), `lg` 36, `xl` 44 and `2xl` 56.
123
+ `as="form"` makes the dialog the form itself: give it `onsubmit`, and a footer button with
124
+ `type="submit"`; Enter in a field submits it.
120
125
  A `Sheet.Content` along an edge takes the same names, from 20rem; from `lg` up, a dialog and a
121
126
  sheet of one size are as wide. `Dialog.Body` takes a bindable `ref`, the element that scrolls.
122
127
  A Select, Menu or Popover opened inside a dialog or a sheet opens over it.
@@ -157,7 +162,8 @@ wiring for them.
157
162
  (radios, a start and an end). The help and the error describe the group; its controls take
158
163
  no id from it.
159
164
  - `Input` takes an `icon` snippet at its start, sized to the field:
160
- `<Input>{#snippet icon()}<Search />{/snippet}</Input>`. Don't position an icon by hand.
165
+ `<Input>{#snippet icon()}<Search />{/snippet}</Input>`. Don't position an icon by hand. With
166
+ an icon, `sx` styles the element around the field; `inputSx` and `inputClass` style the field.
161
167
  - For one choice among a few that each need a line of detail, use `ChoiceCards`
162
168
  (`options: { value, label, detail?, icon?, disabled? }[]`, `bind:value`, `aria-label`).
163
169
 
@@ -165,7 +171,8 @@ The other controls don't read Field, so label them directly:
165
171
 
166
172
  - `Checkbox` and `Switch` take their label as children: `<Switch bind:checked>Night shift</Switch>`.
167
173
  To act on a change, `onCheckedChange={(checked) => save(checked)}` gets the new value; the
168
- native `onchange` gets the event. `Select`'s `onchange` gets the new value.
174
+ native `onchange` gets the event. `Select`'s and `SegmentedControl`'s `onchange` get the new
175
+ value, as the person picks it: narrow it to your type there rather than in a `bind:value` setter.
169
176
  - `SegmentedControl`, `ToggleGroup.Root` and `Slider` need an `aria-label` (or
170
177
  `aria-labelledby`), for example `<SegmentedControl aria-label="Theme" … />`.
171
178
  A `SegmentedControl` option with a short label can carry a `title` that names it in full
@@ -229,6 +236,9 @@ of the heading), which lays them on one card with a line between each, and each
229
236
  - Attributes such as `id`, `tabindex` and `data-*` go on the row's element (and on the group's
230
237
  `<section>`), so search can scroll to one and focus it. Set `highlighted` for a moment as it
231
238
  lands to light it.
239
+ - `leading` is a snippet before the label (a provider's mark, an icon), `dimmed` mutes the
240
+ label (an agent switched off), and `mono` sets it in monospace (an environment variable, a
241
+ tool). Don't draw a row of your own for these.
232
242
  - A `SettingsGroup` draws its lines between any children, so rows of the app's own go in it too;
233
243
  give them their own padding (`SettingsRow` is inset 16px on the card).
234
244
 
@@ -310,7 +320,26 @@ line, `lines={2}` for several). Use `Code` and `Kbd` inline, and
310
320
  - A `Button` that is loading hides its label under the spinner, which is as large as an icon in
311
321
  a button of that size, icon-only ones too; `loadingLabel="Connecting…"`
312
322
  says what it is doing beside the spinner instead. `variant="link"` sits in a sentence, at its
313
- size, with no padding.
323
+ size, with no padding. A ghost, bare, secondary or floating Button that opens a menu or a
324
+ popover holds an open look while it shows, by the `aria-expanded` bits-ui sets: don't style
325
+ the open trigger yourself. `pressed` makes it a toggle button (`aria-pressed`) held in the same
326
+ look while true: don't style `aria-pressed` by hand.
327
+ - A main action with a menu of how to do it (Merge, Sign in) is a `SplitButton`: `menu` snippet,
328
+ `menuLabel` for the chevron, `label` for the group, both halves disabled together. Without
329
+ `menu` it stands alone. Don't join two Buttons by hand.
330
+ - `Toggle` and `ToggleGroup.Root` take `tone="neutral"` for a toolbar's icons that show or hide
331
+ something: pressed, they take the fill of what is chosen instead of lighting in the accent.
332
+ - `Menu.Item`, `Menu.SubTrigger` and `Menu.CheckboxItem` take a `description` (a line under the
333
+ label), and `Menu.Item` a `trailing` snippet after its shortcut. A `Menu.CheckboxItem` with an
334
+ `icon` puts its tick at the end, so its icon lines up with the others'. `Menu.Content` takes a
335
+ `width` (`'18rem'`) in place of fitting its items, up to 22rem.
336
+ - `Popover.Content` takes `padding="none"`, `layout="column"` and a `width`;
337
+ `HoverCard.Content` takes `layout="column"` and `padding`; `Tooltip.Content` takes
338
+ `layout="column"` for a title over a line that says more.
339
+ - `Select` takes an `optionIcon` snippet, given each option, for an icon with props of its own.
340
+ An option's `detail` (a hash, a size, a count; `detailMono` for code) is muted at the end of
341
+ its row in the list, and kept off the trigger.
342
+ - `EmptyState`'s title is a heading (`level`, 2 by default). `Heading` takes a `weight`.
314
343
 
315
344
  ### App and chat screens
316
345
 
@@ -358,10 +387,53 @@ Parts of the shell that are easy to redraw by hand, and shouldn't be:
358
387
  - **A mark with a badge** in a row's `meta` may overhang it; the line clips only far past its end.
359
388
  - `AppShell.Main` is not focusable, so a press on text in the page leaves focus where it was.
360
389
  - **TabStrip** tabs narrow to an ellipsis before the strip scrolls. With a `leading` icon, a
361
- tab's close button takes the icon's place, so no room is kept at its end.
390
+ tab's close button takes the icon's place, so no room is kept at its end. A side panel's tabs
391
+ are a TabStrip too: `menu` (a snippet of Menu parts, given the tab: right-click, the menu key,
392
+ a long press), `onmove(id, index)` (drag, or Alt+Shift+arrow), `onrename(id, label)` with
393
+ `bind:renaming` (double-click, F2, or a menu's Rename), `trailing` for a tab's own buttons,
394
+ `beside` for the tab shown in a split, and per tab `tabId`, `panelId`, `title`, `renamable`.
395
+ - **AppShell.Panel** goes narrow by its row (the sheet less the sidebar), not the window.
396
+ `maximized` lays it over the whole page, header too; the page underneath is kept, inert. Give
397
+ the panel its own `AppShell.Header` with `AppShell.Toggle when="closed"`.
362
398
  - **A Sheet** focuses itself as it opens (`focusOnOpen="sheet"`), so a Rail or a list in it
363
399
  shows no focus ring until the keys move in. Pass `focusOnOpen="first"` for a sheet that
364
400
  holds a form.
401
+ - `AppShell.Header` draws a line under itself; `divider={false}` leaves it out where the page
402
+ runs on under the header, as a conversation does.
403
+
404
+ Parts of a thread that are easy to redraw by hand, and shouldn't be:
405
+
406
+ - **An editor of your own in the composer** (a rich prompt field): put it where
407
+ `Composer.Textarea` goes and mark it `data-composer-field` (an editable element is found on
408
+ its own). The frame shows its focus edge and sends clicks to it. Set `hasContent` from the
409
+ editor, so `Composer.Submit` knows there is something to send, and `sending` while a message
410
+ is on its way and can't be stopped: Submit spins, says "Sending" (`sendingLabel`), and nothing
411
+ more is sent. `onfiles` receives picked, dropped and pasted files; return `false` to keep them
412
+ on a list of your own instead of the composer's.
413
+ - **Composer.ModelPicker** takes `bind:open`, and `multiple` with `value: string[]` to pick
414
+ several. `Composer.Toggle` works outside a `Composer.Root` too.
415
+ - **Composer.Tray** shows its shelf for a child that holds something and isn't `hidden`; pass
416
+ `waiting` when what is inside hides itself some other way.
417
+ - **A user's message with attachments:** `<Message.Content bubble={false}>` is a column at the
418
+ end of the line; put the attachments in it, then the words in a `Message.Bubble`, then any
419
+ cards. Its actions then sit under it. `textSize="body"` on `Message.Root` (and on
420
+ `QueuedMessage`) sets the words at the interface's 14px instead of 16.
421
+ - **QueuedMessage** takes `attachments` (a snippet over the bubble), draws no bubble without
422
+ words, and `disabled` holds its actions back (`true`, or the ones to hold by name).
423
+ - **A timeline row of your own** starts with `Activity.Icon` (`kind`, `tone`, `spinning`, or
424
+ your own icon as children), as the others' do. `Activity.Thought` takes a snippet, such as
425
+ Markdown, in place of `text`. `Activity.Step` takes `wrap` for a label that runs on, and
426
+ `status="neutral"` for a step that settled without going through or failing ("Skipped",
427
+ `statusLabels.neutral`); it and `WorkFold` pass `data-*` attributes on.
428
+ - **A divider with more than words:** `Divider` takes children (a link, a time) and
429
+ `role="status"` for words read out as they change. A long label wraps between the rules.
430
+ - **Answers on their way:** `Approval` and `Questionnaire` take `busy`, which spins the button
431
+ pressed and holds the rest. A `Question` takes a `description`, and `secret` for an answer
432
+ typed into a hidden field and never shown back. ⌘Enter sends only once every question is
433
+ answered or skipped.
434
+ - **Closed folds** (`WorkFold`, `Collapsible`, `Activity`, `Reasoning`, `Tool`) stop rendering
435
+ their content once shut, so `checkVisibility()`, find-in-page and Playwright see it as hidden.
436
+ Don't add `display: none` of your own.
365
437
 
366
438
  ## Conventions
367
439