@diegopluna/narvi 0.3.6 → 0.3.7

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 (29) hide show
  1. package/dist/components/app-shell/AppShellPanel.svelte +37 -11
  2. package/dist/components/app-shell/AppShellPanel.svelte.d.ts +13 -0
  3. package/dist/components/command/CommandDialog.svelte +9 -2
  4. package/dist/components/command/CommandDialog.svelte.d.ts +4 -0
  5. package/dist/components/command/CommandEmpty.svelte +38 -4
  6. package/dist/components/command/CommandEmpty.svelte.d.ts +18 -2
  7. package/dist/components/command/CommandFooter.svelte +5 -7
  8. package/dist/components/command/CommandFooter.svelte.d.ts +4 -1
  9. package/dist/components/command/CommandInput.svelte +13 -1
  10. package/dist/components/command/CommandInput.svelte.d.ts +11 -0
  11. package/dist/components/command/CommandItem.svelte +32 -6
  12. package/dist/components/command/CommandItem.svelte.d.ts +20 -0
  13. package/dist/components/command/CommandRoot.svelte +68 -9
  14. package/dist/components/command/CommandRoot.svelte.d.ts +13 -3
  15. package/dist/components/command/styles.d.ts +50 -8
  16. package/dist/components/command/styles.js +50 -8
  17. package/dist/components/menu/MenuContent.svelte +7 -1
  18. package/dist/components/menu/MenuContent.svelte.d.ts +10 -0
  19. package/dist/components/split-button/SplitButton.svelte +54 -15
  20. package/dist/components/split-button/SplitButton.svelte.d.ts +21 -4
  21. package/dist/internal/layer.d.ts +6 -3
  22. package/dist/internal/layer.js +13 -6
  23. package/package.json +1 -1
  24. package/skills/building-ui/SKILL.md +14 -14
  25. package/skills/building-ui/references/components.md +52 -13
  26. package/skills/markdown/SKILL.md +1 -1
  27. package/skills/setup/SKILL.md +1 -1
  28. package/skills/styling/SKILL.md +1 -1
  29. package/skills/theming/SKILL.md +1 -1
@@ -65,11 +65,61 @@ export declare const command: Readonly<{
65
65
  readonly textOverflow: stylex.StyleXClassNameFor<"textOverflow", "ellipsis">;
66
66
  readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
67
67
  }>;
68
+ readonly end: Readonly<{
69
+ readonly display: stylex.StyleXClassNameFor<"display", "flex">;
70
+ readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
71
+ readonly gap: stylex.StyleXClassNameFor<"gap", "0.125rem">;
72
+ readonly flexShrink: stylex.StyleXClassNameFor<"flexShrink", 0>;
73
+ readonly marginInlineEnd: stylex.StyleXClassNameFor<"marginInlineEnd", "-0.5rem">;
74
+ }>;
75
+ readonly badge: Readonly<{
76
+ readonly '--narvi-icon-size': stylex.StyleXClassNameFor<"--narvi-icon-size", "0.875rem">;
77
+ readonly display: stylex.StyleXClassNameFor<"display", "inline-flex">;
78
+ readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
79
+ readonly marginInlineStart: stylex.StyleXClassNameFor<"marginInlineStart", string>;
80
+ readonly verticalAlign: stylex.StyleXClassNameFor<"verticalAlign", "middle">;
81
+ readonly color: stylex.StyleXClassNameFor<"color", string>;
82
+ }>;
83
+ readonly wrapRow: Readonly<{
84
+ readonly flexGrow: stylex.StyleXClassNameFor<"flexGrow", 1>;
85
+ readonly display: stylex.StyleXClassNameFor<"display", "flex">;
86
+ readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
87
+ readonly gap: stylex.StyleXClassNameFor<"gap", string>;
88
+ readonly minWidth: stylex.StyleXClassNameFor<"minWidth", 0>;
89
+ readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", "0.375rem">;
90
+ }>;
91
+ readonly wrapLabel: Readonly<{
92
+ readonly minWidth: stylex.StyleXClassNameFor<"minWidth", 0>;
93
+ readonly overflow: stylex.StyleXClassNameFor<"overflow", "hidden">;
94
+ readonly textOverflow: stylex.StyleXClassNameFor<"textOverflow", "ellipsis">;
95
+ readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
96
+ }>;
97
+ readonly wrapped: Readonly<{
98
+ readonly display: stylex.StyleXClassNameFor<"display", "-webkit-box">;
99
+ readonly flexShrink: stylex.StyleXClassNameFor<"flexShrink", 1000>;
100
+ readonly minWidth: stylex.StyleXClassNameFor<"minWidth", 0>;
101
+ readonly overflow: stylex.StyleXClassNameFor<"overflow", "hidden">;
102
+ readonly overflowWrap: stylex.StyleXClassNameFor<"overflowWrap", "anywhere">;
103
+ readonly color: stylex.StyleXClassNameFor<"color", string>;
104
+ readonly fontSize: stylex.StyleXClassNameFor<"fontSize", string>;
105
+ readonly WebkitBoxOrient: stylex.StyleXClassNameFor<"WebkitBoxOrient", "vertical">;
106
+ readonly WebkitLineClamp: stylex.StyleXClassNameFor<"WebkitLineClamp", 2>;
107
+ }>;
68
108
  readonly empty: Readonly<{
69
109
  readonly paddingBlock: stylex.StyleXClassNameFor<"paddingBlock", string>;
110
+ readonly paddingInline: stylex.StyleXClassNameFor<"paddingInline", string>;
70
111
  readonly color: stylex.StyleXClassNameFor<"color", string>;
71
112
  readonly textAlign: stylex.StyleXClassNameFor<"textAlign", "center">;
72
113
  }>;
114
+ readonly emptyLoading: Readonly<{
115
+ readonly display: stylex.StyleXClassNameFor<"display", "flex">;
116
+ readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
117
+ readonly justifyContent: stylex.StyleXClassNameFor<"justifyContent", "center">;
118
+ readonly gap: stylex.StyleXClassNameFor<"gap", string>;
119
+ }>;
120
+ readonly emptyError: Readonly<{
121
+ readonly color: stylex.StyleXClassNameFor<"color", string>;
122
+ }>;
73
123
  readonly footer: Readonly<{
74
124
  readonly display: stylex.StyleXClassNameFor<"display", "flex">;
75
125
  readonly alignItems: stylex.StyleXClassNameFor<"alignItems", "center">;
@@ -107,12 +157,4 @@ export declare const command: Readonly<{
107
157
  readonly zIndex: stylex.StyleXClassNameFor<"zIndex", 50>;
108
158
  readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", `color-mix(in oklab, ${stylex.StyleXVar<string>} 70%, transparent)`>;
109
159
  }>;
110
- readonly hidden: Readonly<{
111
- readonly position: stylex.StyleXClassNameFor<"position", "absolute">;
112
- readonly width: stylex.StyleXClassNameFor<"width", "1px">;
113
- readonly height: stylex.StyleXClassNameFor<"height", "1px">;
114
- readonly overflow: stylex.StyleXClassNameFor<"overflow", "hidden">;
115
- readonly clipPath: stylex.StyleXClassNameFor<"clipPath", "inset(50%)">;
116
- readonly whiteSpace: stylex.StyleXClassNameFor<"whiteSpace", "nowrap">;
117
- }>;
118
160
  }>;
@@ -69,11 +69,61 @@ export const command = stylex.create({
69
69
  textOverflow: 'ellipsis',
70
70
  whiteSpace: 'nowrap'
71
71
  },
72
+ // Controls after the field, a little nearer the edge than the words start
73
+ end: {
74
+ display: 'flex',
75
+ alignItems: 'center',
76
+ gap: '0.125rem',
77
+ flexShrink: 0,
78
+ marginInlineEnd: '-0.5rem'
79
+ },
80
+ badge: {
81
+ '--narvi-icon-size': '0.875rem',
82
+ display: 'inline-flex',
83
+ alignItems: 'center',
84
+ marginInlineStart: space.x2,
85
+ verticalAlign: 'middle',
86
+ color: colors.textMuted
87
+ },
88
+ // A detail that wraps: beside the label, up to two lines, and the first to give way
89
+ wrapRow: {
90
+ flexGrow: 1,
91
+ display: 'flex',
92
+ alignItems: 'center',
93
+ gap: space.x2,
94
+ minWidth: 0,
95
+ paddingBlock: '0.375rem'
96
+ },
97
+ wrapLabel: {
98
+ minWidth: 0,
99
+ overflow: 'hidden',
100
+ textOverflow: 'ellipsis',
101
+ whiteSpace: 'nowrap'
102
+ },
103
+ wrapped: {
104
+ display: '-webkit-box',
105
+ flexShrink: 1000,
106
+ minWidth: 0,
107
+ overflow: 'hidden',
108
+ overflowWrap: 'anywhere',
109
+ color: colors.textSubtle,
110
+ fontSize: font.sizeMeta,
111
+ WebkitBoxOrient: 'vertical',
112
+ WebkitLineClamp: 2
113
+ },
72
114
  empty: {
73
115
  paddingBlock: space.x8,
116
+ paddingInline: space.x4,
74
117
  color: colors.textMuted,
75
118
  textAlign: 'center'
76
119
  },
120
+ emptyLoading: {
121
+ display: 'flex',
122
+ alignItems: 'center',
123
+ justifyContent: 'center',
124
+ gap: space.x2
125
+ },
126
+ emptyError: { color: colors.dangerText },
77
127
  footer: {
78
128
  display: 'flex',
79
129
  alignItems: 'center',
@@ -112,13 +162,5 @@ export const command = stylex.create({
112
162
  zIndex: 50,
113
163
  // Lighter than a dialog's: the page behind is what is being searched
114
164
  backgroundColor: `color-mix(in oklab, ${colors.scrim} 70%, transparent)`
115
- },
116
- hidden: {
117
- position: 'absolute',
118
- width: '1px',
119
- height: '1px',
120
- overflow: 'hidden',
121
- clipPath: 'inset(50%)',
122
- whiteSpace: 'nowrap'
123
165
  }
124
166
  });
@@ -12,6 +12,11 @@
12
12
  * the trigger's width, up to 22rem). It is still no wider than the window has room for.
13
13
  */
14
14
  width?: string | undefined;
15
+ /**
16
+ * How wide it is at least, such as `16rem`, in place of 12rem: it still fits its items,
17
+ * up to 22rem, and is at least as wide as its trigger.
18
+ */
19
+ minWidth?: string | undefined;
15
20
  sx?: Sx | undefined;
16
21
  children?: Snippet | undefined;
17
22
  }
@@ -23,6 +28,7 @@
23
28
  sideOffset = 6,
24
29
  collisionPadding = 8,
25
30
  width,
31
+ minWidth,
26
32
  style,
27
33
  align = 'start',
28
34
  sx,
@@ -39,7 +45,7 @@
39
45
  {align}
40
46
  data-slot="menu-content"
41
47
  {...rest}
42
- style={widthStyle(width, style)}
48
+ style={widthStyle(width, style, minWidth)}
43
49
  {...attrs([layer.surface, !!width && layer.sized, sx], className)}
44
50
  >
45
51
  {@render children?.()}
@@ -8,6 +8,11 @@ export type MenuContentProps = Loose<Omit<DropdownMenu.ContentProps, 'children'
8
8
  * the trigger's width, up to 22rem). It is still no wider than the window has room for.
9
9
  */
10
10
  width?: string | undefined;
11
+ /**
12
+ * How wide it is at least, such as `16rem`, in place of 12rem: it still fits its items,
13
+ * up to 22rem, and is at least as wide as its trigger.
14
+ */
15
+ minWidth?: string | undefined;
11
16
  sx?: Sx | undefined;
12
17
  children?: Snippet | undefined;
13
18
  }>;
@@ -17,6 +22,11 @@ declare const MenuContent: import("svelte").Component<Loose<Omit<DropdownMenu.Co
17
22
  * the trigger's width, up to 22rem). It is still no wider than the window has room for.
18
23
  */
19
24
  width?: string | undefined;
25
+ /**
26
+ * How wide it is at least, such as `16rem`, in place of 12rem: it still fits its items,
27
+ * up to 22rem, and is at least as wide as its trigger.
28
+ */
29
+ minWidth?: string | undefined;
20
30
  sx?: Sx | undefined;
21
31
  children?: Snippet | undefined;
22
32
  }>, {}, "">;
@@ -1,23 +1,37 @@
1
1
  <!--
2
2
  A button and, joined to its end, a second that opens a menu of how to do it, or
3
3
  of what else there is to do: Merge, and the ways to merge. The two are one
4
- group, disabled together. Without a menu the button stands alone, rounded at
5
- both ends, so a menu that is offered only sometimes does not change the markup.
4
+ group, disabled together, or with `mainDisabled` only the main one, so the
5
+ menu's other ways stay in reach. Without a menu the button stands alone,
6
+ rounded at both ends, so a menu that is offered only sometimes does not change
7
+ the markup.
6
8
  -->
7
9
  <script lang="ts" module>
8
10
  import * as stylex from '@stylexjs/stylex';
9
11
  import type { Snippet } from 'svelte';
10
12
  import Glyph from '../../internal/Glyph.svelte';
11
13
  import { attrs, type Sx } from '../../internal/sx.js';
12
- import Button, { type ButtonProps } from '../button/Button.svelte';
14
+ import Button, { type ButtonProps, type ButtonShape } from '../button/Button.svelte';
15
+ import { colors, space } from '../../tokens.stylex.js';
13
16
  import * as Menu from '../menu/index.js';
14
17
 
15
18
  export type SplitButtonProps = Omit<
16
19
  ButtonProps,
17
- 'variant' | 'iconOnly' | 'href' | 'shape' | 'pressed' | 'sx'
20
+ 'variant' | 'iconOnly' | 'href' | 'pressed' | 'sx' | 'justify'
18
21
  > & {
19
- /** `secondary`, an edge round both halves; `primary`, the one solid, with a line between them. */
20
- variant?: 'primary' | 'secondary' | undefined;
22
+ /**
23
+ * `secondary`, an edge round both halves; `primary`, the one solid, with a line between
24
+ * them; `ghost`, quiet, for a bar of them: no edge, a fill only under the pointer, and a
25
+ * short line between the halves. Give a ghost pair a fill of its own with `sx`.
26
+ */
27
+ variant?: 'primary' | 'secondary' | 'ghost' | undefined;
28
+ /** `pill` rounds the pair's two outer ends fully. */
29
+ shape?: ButtonShape | undefined;
30
+ /**
31
+ * Disables the main button alone. The menu stays open to the person: its other ways may
32
+ * still apply, or it may say why the main one cannot.
33
+ */
34
+ mainDisabled?: boolean | undefined;
21
35
  /** Names the pair as a group, where the button's own words do not say it all: "Merge". */
22
36
  label?: string | undefined;
23
37
  /** Names the button that opens the menu: "Choose how to merge", "More for GitHub". */
@@ -31,6 +45,8 @@
31
45
  align?: 'start' | 'center' | 'end' | undefined;
32
46
  /** A width of its own for the menu, such as `16rem`. */
33
47
  menuWidth?: string | undefined;
48
+ /** How wide the menu is at least, such as `16rem`; it still fits its items. */
49
+ menuMinWidth?: string | undefined;
34
50
  /** Whether the menu is open. Bindable. */
35
51
  open?: boolean | undefined;
36
52
  /** Called as the menu opens or closes: to fetch what it lists as it opens, say. */
@@ -42,6 +58,10 @@
42
58
  menuTooltip?: string | Snippet | undefined;
43
59
  /** On the group, which holds both halves. */
44
60
  sx?: Sx | undefined;
61
+ /** On the main button, after the pair's own styles. */
62
+ mainSx?: Sx | undefined;
63
+ /** On the button that opens the menu, after the pair's own styles. */
64
+ menuSx?: Sx | undefined;
45
65
  /** The main button's label, and its icon if it has one. */
46
66
  children?: Snippet | undefined;
47
67
  };
@@ -71,6 +91,18 @@
71
91
  pointerEvents: 'none'
72
92
  }
73
93
  },
94
+ // Quiet halves are divided by a short hairline, inset from the pair's ends
95
+ moreGhost: {
96
+ '::before': {
97
+ content: '""',
98
+ position: 'absolute',
99
+ insetInlineStart: 0,
100
+ insetBlock: space.x1_5,
101
+ width: '1px',
102
+ backgroundColor: colors.border,
103
+ pointerEvents: 'none'
104
+ }
105
+ },
74
106
  // The chevron's button is a little narrower than a square: it is the lesser half
75
107
  moreWidth: { paddingInline: '0.375rem' }
76
108
  });
@@ -85,6 +117,9 @@
85
117
  menu,
86
118
  align = 'end',
87
119
  menuWidth,
120
+ menuMinWidth,
121
+ shape = 'default',
122
+ mainDisabled = false,
88
123
  open = $bindable(false),
89
124
  onopenchange,
90
125
  menuTooltip,
@@ -92,6 +127,8 @@
92
127
  disabled = false,
93
128
  loading = false,
94
129
  sx,
130
+ mainSx,
131
+ menuSx,
95
132
  class: className,
96
133
  ref = $bindable(null),
97
134
  children,
@@ -99,6 +136,11 @@
99
136
  }: SplitButtonProps = $props();
100
137
 
101
138
  const glyph = { micro: 10, xs: 12, sm: 12, md: 14, lg: 16 } as const;
139
+ const divider = {
140
+ primary: styles.morePrimary,
141
+ secondary: styles.moreSecondary,
142
+ ghost: styles.moreGhost
143
+ } as const;
102
144
  </script>
103
145
 
104
146
  <div
@@ -112,10 +154,11 @@
112
154
  {...rest}
113
155
  {variant}
114
156
  {size}
115
- {disabled}
157
+ {shape}
158
+ disabled={disabled || mainDisabled}
116
159
  {loading}
117
160
  {tooltipSide}
118
- sx={[styles.half, menu && styles.main]}
161
+ sx={[styles.half, menu && styles.main, mainSx]}
119
162
  >
120
163
  {@render children?.()}
121
164
  </Button>
@@ -127,22 +170,18 @@
127
170
  {...props}
128
171
  {variant}
129
172
  {size}
173
+ {shape}
130
174
  disabled={disabled || loading}
131
175
  aria-label={menuLabel}
132
176
  tooltip={menuTooltip}
133
177
  {tooltipSide}
134
- sx={[
135
- styles.half,
136
- styles.more,
137
- styles.moreWidth,
138
- variant === 'primary' ? styles.morePrimary : styles.moreSecondary
139
- ]}
178
+ sx={[styles.half, styles.more, styles.moreWidth, divider[variant], menuSx]}
140
179
  >
141
180
  <Glyph name="chevron" size={glyph[size]} />
142
181
  </Button>
143
182
  {/snippet}
144
183
  </Menu.Trigger>
145
- <Menu.Content {align} width={menuWidth}>
184
+ <Menu.Content {align} width={menuWidth} minWidth={menuMinWidth}>
146
185
  {@render menu()}
147
186
  </Menu.Content>
148
187
  </Menu.Root>
@@ -1,9 +1,20 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import { type Sx } from '../../internal/sx.js';
3
- import { type ButtonProps } from '../button/Button.svelte';
4
- export type SplitButtonProps = Omit<ButtonProps, 'variant' | 'iconOnly' | 'href' | 'shape' | 'pressed' | 'sx'> & {
5
- /** `secondary`, an edge round both halves; `primary`, the one solid, with a line between them. */
6
- variant?: 'primary' | 'secondary' | undefined;
3
+ import { type ButtonProps, type ButtonShape } from '../button/Button.svelte';
4
+ export type SplitButtonProps = Omit<ButtonProps, 'variant' | 'iconOnly' | 'href' | 'pressed' | 'sx' | 'justify'> & {
5
+ /**
6
+ * `secondary`, an edge round both halves; `primary`, the one solid, with a line between
7
+ * them; `ghost`, quiet, for a bar of them: no edge, a fill only under the pointer, and a
8
+ * short line between the halves. Give a ghost pair a fill of its own with `sx`.
9
+ */
10
+ variant?: 'primary' | 'secondary' | 'ghost' | undefined;
11
+ /** `pill` rounds the pair's two outer ends fully. */
12
+ shape?: ButtonShape | undefined;
13
+ /**
14
+ * Disables the main button alone. The menu stays open to the person: its other ways may
15
+ * still apply, or it may say why the main one cannot.
16
+ */
17
+ mainDisabled?: boolean | undefined;
7
18
  /** Names the pair as a group, where the button's own words do not say it all: "Merge". */
8
19
  label?: string | undefined;
9
20
  /** Names the button that opens the menu: "Choose how to merge", "More for GitHub". */
@@ -17,6 +28,8 @@ export type SplitButtonProps = Omit<ButtonProps, 'variant' | 'iconOnly' | 'href'
17
28
  align?: 'start' | 'center' | 'end' | undefined;
18
29
  /** A width of its own for the menu, such as `16rem`. */
19
30
  menuWidth?: string | undefined;
31
+ /** How wide the menu is at least, such as `16rem`; it still fits its items. */
32
+ menuMinWidth?: string | undefined;
20
33
  /** Whether the menu is open. Bindable. */
21
34
  open?: boolean | undefined;
22
35
  /** Called as the menu opens or closes: to fetch what it lists as it opens, say. */
@@ -28,6 +41,10 @@ export type SplitButtonProps = Omit<ButtonProps, 'variant' | 'iconOnly' | 'href'
28
41
  menuTooltip?: string | Snippet | undefined;
29
42
  /** On the group, which holds both halves. */
30
43
  sx?: Sx | undefined;
44
+ /** On the main button, after the pair's own styles. */
45
+ mainSx?: Sx | undefined;
46
+ /** On the button that opens the menu, after the pair's own styles. */
47
+ menuSx?: Sx | undefined;
31
48
  /** The main button's label, and its icon if it has one. */
32
49
  children?: Snippet | undefined;
33
50
  };
@@ -7,13 +7,16 @@
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
+ /**
11
+ * The `style` that gives a floating surface a `width`, or a least width, of its own, with any
12
+ * `style` given too.
13
+ */
14
+ export declare function widthStyle(width: string | undefined, style: unknown, minWidth?: string | undefined): string | undefined;
12
15
  export declare const layer: Readonly<{
13
16
  readonly surface: Readonly<{
14
17
  readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">;
15
18
  readonly zIndex: stylex.StyleXClassNameFor<"zIndex", 55>;
16
- readonly minWidth: stylex.StyleXClassNameFor<"minWidth", "max(12rem, var(--bits-floating-anchor-width, 0px))">;
19
+ readonly minWidth: stylex.StyleXClassNameFor<"minWidth", "max(var(--narvi-layer-min-width, 12rem), var(--bits-floating-anchor-width, 0px))">;
17
20
  readonly maxWidth: stylex.StyleXClassNameFor<"maxWidth", "min(22rem, var(--bits-floating-available-width, 100vw))">;
18
21
  readonly maxHeight: stylex.StyleXClassNameFor<"maxHeight", "var(--bits-floating-available-height, 80vh)">;
19
22
  readonly overflowY: stylex.StyleXClassNameFor<"overflowY", "auto">;
@@ -12,12 +12,18 @@ 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) {
15
+ /**
16
+ * The `style` that gives a floating surface a `width`, or a least width, of its own, with any
17
+ * `style` given too.
18
+ */
19
+ export function widthStyle(width, style, minWidth) {
17
20
  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
+ const parts = [
22
+ width && `--narvi-layer-width: ${width}`,
23
+ minWidth && `--narvi-layer-min-width: ${minWidth}`,
24
+ own
25
+ ].filter(Boolean);
26
+ return parts.length ? parts.join('; ') : undefined;
21
27
  }
22
28
  export const layer = stylex.create({
23
29
  surface: {
@@ -25,7 +31,8 @@ export const layer = stylex.create({
25
31
  // Over a dialog (50 and 51) and a sheet, which are where a popup opens while one is up:
26
32
  // a modal makes the page behind it inert. Under a tooltip (60) and the toasts (the top layer).
27
33
  zIndex: 55,
28
- minWidth: 'max(12rem, var(--bits-floating-anchor-width, 0px))',
34
+ // From 12rem, or a least width of its own, or the trigger's width if that is wider
35
+ minWidth: 'max(var(--narvi-layer-min-width, 12rem), var(--bits-floating-anchor-width, 0px))',
29
36
  maxWidth: 'min(22rem, var(--bits-floating-available-width, 100vw))',
30
37
  // Never taller than the room left in the window; it scrolls inside instead
31
38
  maxHeight: 'var(--bits-floating-available-height, 80vh)',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diegopluna/narvi",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
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.6'
15
+ library_version: '0.3.7'
16
16
  requires:
17
17
  - setup
18
18
  sources:
@@ -39,6 +39,8 @@ sources:
39
39
  - src/lib/components/questionnaire/Questionnaire.svelte
40
40
  - src/lib/components/button/Button.svelte
41
41
  - src/lib/components/tooltip/TooltipProvider.svelte
42
+ - src/lib/components/command/*.svelte
43
+ - src/lib/components/menu/MenuContent.svelte
42
44
  ---
43
45
 
44
46
  # Build interfaces with Narvi
@@ -328,16 +330,16 @@ line, `lines={2}` for several). Use `Code` and `Kbd` inline, and
328
330
  sends the last to the end. `variant="link"` sits in a sentence. An open ghost, bare, secondary
329
331
  or floating trigger holds an open look by bits-ui's `aria-expanded`, and `pressed` makes a
330
332
  toggle button (`aria-pressed`) in that look: style neither.
331
- - A main action with a menu of how to do it (Merge, Sign in) is a `SplitButton`: `menu` snippet,
332
- `menuLabel` for the chevron, `label` for the group, both halves disabled together. Without
333
- `menu` it stands alone. Don't join two Buttons by hand.
333
+ - A main action with a menu of how to do it (Merge, Sign in) is a `SplitButton`; don't join two
334
+ Buttons by hand, or retheme its tokens to restyle a half. Its props are in the
335
+ [catalogue](references/components.md#split-buttons).
334
336
  - `Toggle` and `ToggleGroup.Root` take `tone="neutral"`: pressed, a toolbar's icon takes the fill
335
337
  of what is chosen, not the accent.
336
338
  - `Menu.Item`, `Menu.SubTrigger`, `Menu.CheckboxItem` and `Menu.RadioItem` take a
337
339
  `description` (a line under the label): a string, or a snippet whose icon is 12px and lies in
338
340
  the line; say in words what the icon stands for. All but the SubTrigger take `trailing`. A `Menu.CheckboxItem` with an
339
341
  `icon` puts its tick at the end, so its icon lines up with the others'. `Menu.Content` takes a
340
- `width` (`'18rem'`) in place of fitting its items, up to 22rem.
342
+ `width` (`'18rem'`) in place of fitting its items, up to 22rem, or a `minWidth`.
341
343
  - `Popover.Content` takes `padding="none"`, `layout="column"` and a `width`;
342
344
  `HoverCard.Content` takes `layout="column"` and `padding`; `Tooltip.Content` takes
343
345
  `layout="column"` for a title over a line that says more.
@@ -391,17 +393,15 @@ Parts of the shell that are easy to redraw by hand, and shouldn't be:
391
393
  what scrolls, in the same tab stop and arrow-key order. Don't add a second `Sidebar.Content`.
392
394
  - **A mark with a badge** in a row's `meta` may overhang it; the line clips only far past its end.
393
395
  - `AppShell.Main` is not focusable, so a press on text in the page leaves focus where it was.
394
- - **TabStrip** tabs narrow to an ellipsis before the strip scrolls. With a `leading` icon, a
395
- tab's close button takes the icon's place, so no room is kept at its end. A side panel's tabs
396
- are a TabStrip too: `menu` (a snippet of Menu parts, given the tab: right-click, the menu key,
397
- a long press), `onmove(id, index)` (drag, or Alt+Shift+arrow), `onrename(id, label)` with
398
- `bind:renaming` (double-click, F2, or a menu's Rename), `trailing` for a tab's own buttons,
399
- `beside` for the tab shown in a split, and per tab `tabId`, `panelId`, `title`, `renamable`.
400
- Arrows open the tab they reach (`activation="manual"` only moves focus); `onchange(id)`; a
401
- name cleared comes as `''`; `addMenu` (Menu parts) makes the add button open a menu.
396
+ - **TabStrip** tabs narrow to an ellipsis before the strip scrolls; with a `leading` icon, a
397
+ tab's close button takes the icon's place. A side panel's tabs are a TabStrip too, with menus,
398
+ dragging, renaming and an add menu: see the [catalogue](references/components.md#tab-strips).
402
399
  - **AppShell.Panel** goes narrow by its row, not the window; `maximized` lays it over the page,
403
400
  kept inert, so give it an `AppShell.Header` with `AppShell.Toggle when="closed"`. Beside a
404
- thread, put it in a flex row of yours (`position: relative`) inside `AppShell.Main`.
401
+ thread, put it in a flex row of yours (`position: relative`) inside `AppShell.Main`; for
402
+ `hideCovered`, `edgeLabel` and `edgeTitle` see the [catalogue](references/components.md#panels).
403
+ - **A palette** is `Command.Root`: don't work round its keys, highlight, footer or field by hand
404
+ (the [catalogue](references/components.md#palettes) says what each does).
405
405
  - **A Sheet** focuses itself as it opens (`focusOnOpen="sheet"`), so a Rail or a list in it
406
406
  shows no focus ring until the keys move in. Pass `focusOnOpen="first"` for a sheet that
407
407
  holds a form.
@@ -38,7 +38,7 @@ component: import the namespace (`Dialog`) and use `Dialog.Root`. Docs and live
38
38
  | `Switch` | A setting that takes effect at once | `switch` |
39
39
  | `SegmentedControl` | One of a few options, all visible (`options: { value, label, title? }[]`, `onchange`) | `segmented-control` |
40
40
  | `Slider` | A value or a range along a track | `slider` |
41
- | `SplitButton` | A main action joined to a menu of how to do it (`menu`, `menuLabel`, `label`, `variant`) | `split-button` |
41
+ | `SplitButton` | A main action joined to a menu of how to do it (`menu`, `menuLabel`, `label`, `variant` incl. `ghost`, `shape`, `mainDisabled`, `mainSx`/`menuSx`, `menuMinWidth`) | `split-button` |
42
42
  | `Toggle` | A button that stays pressed (`tone`: `accent`, or `neutral` for toolbar icons) | `toggle` |
43
43
  | `ToggleGroup.Root`, `.Item` | Toggles that belong together: one pressed, or any number | `toggle-group` |
44
44
  | `SettingsGroup` | A titled group of settings: a heading, an action, the rows on one card | `settings-group` |
@@ -47,20 +47,51 @@ component: import the namespace (`Dialog`) and use `Dialog.Root`. Docs and live
47
47
  | `SearchButton` | Looks like a search field and opens search (`label`, `shortcut`): for a window's bar | `search-button` |
48
48
  | `TabStrip` | Tabs for what is open in a pane: closable, addable, scrolling (`tabs`, `bind:value`, `onclose`, `onadd`); `menu`, `onmove`, `onrename`, `trailing`. The panels are yours | `tab-strip` |
49
49
 
50
+ ### Tab strips
51
+
52
+ A side panel's tabs are a `TabStrip`: `menu` (a snippet of Menu parts, given the tab:
53
+ right-click, the menu key, a long press), `onmove(id, index)` (drag, or Alt+Shift+arrow),
54
+ `onrename(id, label)` with `bind:renaming` (double-click, F2, or a menu's Rename), `trailing`
55
+ for a tab's own buttons, `beside` for the tab shown in a split, and per tab `tabId`, `panelId`,
56
+ `title`, `renamable`. Arrows open the tab they reach (`activation="manual"` only moves focus);
57
+ `onchange(id)`; a name cleared comes as `''`; `addMenu` (Menu parts) makes the add button open
58
+ a menu.
59
+
60
+ ### Split buttons
61
+
62
+ `SplitButton` takes a `menu` snippet, `menuLabel` for the chevron and `label` for the group.
63
+ Both halves are disabled together; `mainDisabled` disables the main one alone, so the menu stays
64
+ in reach. Without `menu` it stands alone. `variant="ghost"` is the quiet one for a bar, with a
65
+ short line between the halves (give it a fill of its own with `sx`); `shape="pill"` rounds its
66
+ outer ends; `mainSx` and `menuSx` style each half after its own styles; `menuWidth` and
67
+ `menuMinWidth` size the menu, as `Menu.Content`'s `width` and `minWidth` do.
68
+
50
69
  ## Overlays (bits-ui; use `child` snippets on triggers)
51
70
 
52
- | Component | Use it for | Docs slug |
53
- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
54
- | `Dialog.Root`, `.Trigger`, `.Content` (`size`, `side`, `as`), `.Header`, `.Title`, `.Description`, `.Body`, `.Footer`, `.Close` | A focused task over the page | `dialog` |
55
- | `ConfirmDialog` | A confirmation for an action that matters | `dialog` |
56
- | `Sheet.Root`, `.Trigger`, `.Content` (`side`, `size`, `focusOnOpen`), `.Header`, `.Title`, `.Description`, `.Body`, `.Footer`, `.Close` | A panel that slides in from an edge | `sheet` |
57
- | `Popover.Root`, `.Trigger`, `.Content` (`padding`, `layout`, `width`), `.Close` | Content anchored to the control that opened it | `popover` |
58
- | `HoverCard.Root`, `.Trigger`, `.Content` (`layout`, `padding`) | A preview while the pointer rests on a link or chip | `hover-card` |
59
- | `Menu.Root`, `.Trigger`, `.Content`, `.Item`, `.CheckboxItem`, `.RadioGroup`, `.RadioItem`, `.Group`, `.Label`, `.Separator`, `.Sub` | Actions and choices from a button; items take `description` (text or a snippet) and `trailing` | `menu` |
60
- | `ContextMenu.Root`, `.Trigger`, `.Content`, filled with `Menu` items | The same, from a right-click | `menu` |
61
- | `Command.Dialog`, `.Root`, `.Input`, `.List`, `.Group`, `.Item`, `.Empty`, `.Separator`, `.Footer` | A search field over everything the app can do (⌘K); drive it from outside with `Input` `bind:value`, `Root` `shouldFilter={false}` and `bind:value` (the highlighted item), and `Dialog` `onescape`, `restoreFocus`; items take a snippet `detail` and a `hint` | `command` |
62
- | `Tooltip.Provider`, `.Root`, `.Trigger`, `.Content` (`shortcut`, `layout`) | A control's name and its keys. Needs the Provider | `tooltip` |
63
- | `Collapsible.Root`, `.Trigger`, `.Content` | A region the person can fold away | `collapsible` |
71
+ | Component | Use it for | Docs slug |
72
+ | --------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
73
+ | `Dialog.Root`, `.Trigger`, `.Content` (`size`, `side`, `as`), `.Header`, `.Title`, `.Description`, `.Body`, `.Footer`, `.Close` | A focused task over the page | `dialog` |
74
+ | `ConfirmDialog` | A confirmation for an action that matters | `dialog` |
75
+ | `Sheet.Root`, `.Trigger`, `.Content` (`side`, `size`, `focusOnOpen`), `.Header`, `.Title`, `.Description`, `.Body`, `.Footer`, `.Close` | A panel that slides in from an edge | `sheet` |
76
+ | `Popover.Root`, `.Trigger`, `.Content` (`padding`, `layout`, `width`), `.Close` | Content anchored to the control that opened it | `popover` |
77
+ | `HoverCard.Root`, `.Trigger`, `.Content` (`layout`, `padding`) | A preview while the pointer rests on a link or chip | `hover-card` |
78
+ | `Menu.Root`, `.Trigger`, `.Content`, `.Item`, `.CheckboxItem`, `.RadioGroup`, `.RadioItem`, `.Group`, `.Label`, `.Separator`, `.Sub` | Actions and choices from a button; items take `description` (text or a snippet) and `trailing` | `menu` |
79
+ | `ContextMenu.Root`, `.Trigger`, `.Content`, filled with `Menu` items | The same, from a right-click | `menu` |
80
+ | `Command.Dialog`, `.Root`, `.Input`, `.List`, `.Group`, `.Item`, `.Empty`, `.Separator`, `.Footer` | A search field over everything the app can do (⌘K); drive it from outside with `Input` `bind:value`, `Root` `shouldFilter={false}` and `bind:value` (the highlighted item), and `Dialog` `onescape`, `restoreFocus`, `sx`; `Input` an `end` snippet; items a snippet `detail`, `wrapDetail`, `badge` and a `hint`; `Empty` a `status` (`loading`, `error`) | `command` |
81
+ | `Tooltip.Provider`, `.Root`, `.Trigger`, `.Content` (`shortcut`, `layout`) | A control's name and its keys. Needs the Provider | `tooltip` |
82
+ | `Collapsible.Root`, `.Trigger`, `.Content` | A region the person can fold away | `collapsible` |
83
+
84
+ ### Palettes
85
+
86
+ `Command.Root` passes keys to its list only from the root and its `Command.Input`: a button, a
87
+ field or a form of yours inside it keeps its keys, Enter among them, and the field keeps Home and
88
+ End for its caret. Ctrl+J/K/N/P are left to the app unless `vimBindings` is set. When the
89
+ highlighted item is removed, the highlight goes back to the first. `Command.Input` takes an `end`
90
+ snippet after the field; `Command.Item` a `badge` after the label and `wrapDetail` for a path
91
+ whose end matters; `Command.Empty` a `status` of `loading` (a spinner) or `error` (the danger
92
+ colour); `Command.Dialog` an `sx` for its place and width. `Command.Footer` is read out: pass
93
+ `aria-hidden="true"` only for hints alone. Command.Empty is not announced; say loading and
94
+ errors with an `Announcer` too.
64
95
 
65
96
  ## Feedback and status
66
97
 
@@ -150,6 +181,14 @@ first. Don't use a rail without a bar in a window that has traffic lights: they
150
181
  </AppShell.Root>
151
182
  ```
152
183
 
184
+ ### Panels
185
+
186
+ `AppShell.Panel` is raised wherever it stands, so don't give it `bgRaised` of your own. In a
187
+ flex row of yours inside `AppShell.Main`, lying over the row it makes the row's other children
188
+ inert, and with `hideCovered` hides them too (still laid out, so their scroll is kept); they
189
+ come back as they were. `edgeLabel` names its resize edge for assistive technology ("Resize
190
+ panel"), and `edgeTitle` gives the edge a tooltip ("Drag to resize, double-click to reset").
191
+
153
192
  ## AI chat
154
193
 
155
194
  | Component | Use it for | Docs slug |