@diegopluna/narvi 0.0.1 → 0.1.0

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 (112) hide show
  1. package/README.md +27 -8
  2. package/dist/base.css +96 -0
  3. package/dist/color.d.ts +38 -0
  4. package/dist/color.js +88 -0
  5. package/dist/components/activity/ActivityTrigger.svelte +2 -3
  6. package/dist/components/app-shell/AppShellHeader.svelte +2 -3
  7. package/dist/components/app-shell/AppShellSidebar.svelte +6 -6
  8. package/dist/components/approval/Approval.svelte +8 -4
  9. package/dist/components/button/Button.svelte +15 -18
  10. package/dist/components/card/Card.svelte +98 -12
  11. package/dist/components/card/Card.svelte.d.ts +8 -3
  12. package/dist/components/checkbox/Checkbox.svelte +16 -13
  13. package/dist/components/collapsible/CollapsibleContent.svelte +38 -0
  14. package/dist/components/collapsible/CollapsibleContent.svelte.d.ts +11 -0
  15. package/dist/components/collapsible/CollapsibleRoot.svelte +44 -0
  16. package/dist/components/collapsible/CollapsibleRoot.svelte.d.ts +11 -0
  17. package/dist/components/collapsible/CollapsibleTrigger.svelte +83 -0
  18. package/dist/components/collapsible/CollapsibleTrigger.svelte.d.ts +13 -0
  19. package/dist/components/collapsible/context.d.ts +5 -0
  20. package/dist/components/collapsible/context.js +11 -0
  21. package/dist/components/collapsible/index.d.ts +7 -0
  22. package/dist/components/collapsible/index.js +4 -0
  23. package/dist/components/command/styles.js +3 -3
  24. package/dist/components/composer/ComposerAttachment.svelte +4 -6
  25. package/dist/components/composer/ComposerModelPicker.svelte +8 -10
  26. package/dist/components/composer/ComposerRoot.svelte +7 -6
  27. package/dist/components/composer/ComposerSubmit.svelte +4 -5
  28. package/dist/components/composer/ComposerToggle.svelte +11 -11
  29. package/dist/components/conversation/ConversationScrollButton.svelte +6 -8
  30. package/dist/components/dialog/DialogContent.svelte +5 -1
  31. package/dist/components/dialog/styles.d.ts +0 -23
  32. package/dist/components/dialog/styles.js +7 -43
  33. package/dist/components/grid/Grid.svelte +111 -0
  34. package/dist/components/grid/Grid.svelte.d.ts +27 -0
  35. package/dist/components/hover-card/HoverCardContent.svelte +50 -0
  36. package/dist/components/hover-card/HoverCardContent.svelte.d.ts +10 -0
  37. package/dist/components/hover-card/HoverCardRoot.svelte +22 -0
  38. package/dist/components/hover-card/HoverCardRoot.svelte.d.ts +5 -0
  39. package/dist/components/hover-card/index.d.ts +7 -0
  40. package/dist/components/hover-card/index.js +7 -0
  41. package/dist/components/link/Link.svelte +2 -4
  42. package/dist/components/message/MessageAction.svelte +2 -3
  43. package/dist/components/message/MessageActions.svelte +2 -3
  44. package/dist/components/message/MessageCopy.svelte +4 -5
  45. package/dist/components/message/MessageRoot.svelte +3 -4
  46. package/dist/components/message/MessageTime.svelte +2 -3
  47. package/dist/components/plan/Plan.svelte +3 -4
  48. package/dist/components/progress/Progress.svelte +4 -6
  49. package/dist/components/rail/RailItem.svelte +9 -9
  50. package/dist/components/reasoning/ReasoningTrigger.svelte +2 -3
  51. package/dist/components/resize-handle/ResizeHandle.svelte +3 -5
  52. package/dist/components/reveal/Reveal.svelte +89 -0
  53. package/dist/components/reveal/Reveal.svelte.d.ts +17 -0
  54. package/dist/components/reveal/revealed.d.ts +38 -0
  55. package/dist/components/reveal/revealed.js +79 -0
  56. package/dist/components/segmented/SegmentedControl.svelte +5 -9
  57. package/dist/components/sheet/SheetContent.svelte +63 -0
  58. package/dist/components/sheet/SheetContent.svelte.d.ts +18 -0
  59. package/dist/components/sheet/index.d.ts +12 -0
  60. package/dist/components/sheet/index.js +12 -0
  61. package/dist/components/sheet/styles.d.ts +51 -0
  62. package/dist/components/sheet/styles.js +65 -0
  63. package/dist/components/shimmer/Shimmer.svelte +8 -6
  64. package/dist/components/sidebar/SidebarGroup.svelte +5 -3
  65. package/dist/components/sidebar/SidebarItem.svelte +10 -8
  66. package/dist/components/slider/Slider.svelte +199 -0
  67. package/dist/components/slider/Slider.svelte.d.ts +55 -0
  68. package/dist/components/stack/Stack.svelte +37 -44
  69. package/dist/components/stack/Stack.svelte.d.ts +12 -6
  70. package/dist/components/suggestions/SuggestionsItem.svelte +7 -9
  71. package/dist/components/switch/Switch.svelte +8 -12
  72. package/dist/components/tabs/Tabs.svelte +3 -6
  73. package/dist/components/text/Text.svelte +47 -5
  74. package/dist/components/text/Text.svelte.d.ts +8 -2
  75. package/dist/components/toast/Toaster.svelte +7 -5
  76. package/dist/components/toggle/Toggle.svelte +40 -0
  77. package/dist/components/toggle/Toggle.svelte.d.ts +15 -0
  78. package/dist/components/toggle-group/ToggleGroupItem.svelte +37 -0
  79. package/dist/components/toggle-group/ToggleGroupItem.svelte.d.ts +12 -0
  80. package/dist/components/toggle-group/ToggleGroupRoot.svelte +95 -0
  81. package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +33 -0
  82. package/dist/components/toggle-group/context.d.ts +6 -0
  83. package/dist/components/toggle-group/context.js +11 -0
  84. package/dist/components/toggle-group/index.d.ts +5 -0
  85. package/dist/components/toggle-group/index.js +3 -0
  86. package/dist/components/tool/ToolTrigger.svelte +4 -6
  87. package/dist/components/tooltip/TooltipContent.svelte +6 -3
  88. package/dist/components/work-fold/WorkFold.svelte +12 -25
  89. package/dist/components/work-fold/WorkFold.svelte.d.ts +1 -1
  90. package/dist/index.d.ts +25 -3
  91. package/dist/index.js +24 -2
  92. package/dist/internal/Chevron.svelte +2 -3
  93. package/dist/internal/Collapse.svelte +6 -5
  94. package/dist/internal/Collapse.svelte.d.ts +2 -1
  95. package/dist/internal/control.js +4 -4
  96. package/dist/internal/layer.js +6 -8
  97. package/dist/internal/layout.d.ts +13 -0
  98. package/dist/internal/layout.js +453 -0
  99. package/dist/internal/responsive.d.ts +45 -0
  100. package/dist/internal/responsive.js +42 -0
  101. package/dist/internal/sx.d.ts +39 -4
  102. package/dist/internal/sx.js +17 -0
  103. package/dist/internal/toggle.d.ts +74 -0
  104. package/dist/internal/toggle.js +87 -0
  105. package/dist/media.stylex.d.ts +52 -0
  106. package/dist/media.stylex.js +53 -0
  107. package/dist/preset.js +9 -3
  108. package/dist/tokens.stylex.d.ts +15 -0
  109. package/dist/tokens.stylex.js +24 -2
  110. package/dist/vite.d.ts +27 -3
  111. package/dist/vite.js +25 -3
  112. package/package.json +14 -5
@@ -4,6 +4,7 @@
4
4
  import type { HTMLInputAttributes } from 'svelte/elements';
5
5
  import { attrs, type Sx } from '../../internal/sx.js';
6
6
  import { colors, font, motion, radius } from '../../tokens.stylex.js';
7
+ import { media } from '../../media.stylex.js';
7
8
 
8
9
  export type SwitchProps = Omit<HTMLInputAttributes, 'type' | 'role' | 'children'> & {
9
10
  checked?: boolean;
@@ -17,11 +18,6 @@
17
18
  children?: Snippet;
18
19
  };
19
20
 
20
- // StyleX needs these in the same file to evaluate them at build time
21
- const HOVER = '@media (hover: hover) and (pointer: fine)';
22
- const MOTION = '@media (prefers-reduced-motion: no-preference)';
23
- const FORCED = '@media (forced-colors: active)';
24
-
25
21
  const styles = stylex.create({
26
22
  root: {
27
23
  display: 'inline-flex',
@@ -56,13 +52,13 @@
56
52
  borderRadius: radius.full,
57
53
  backgroundColor: {
58
54
  default: colors.edge,
59
- ':hover': { default: null, [HOVER]: colors.edgeHover },
60
- [FORCED]: { default: 'Canvas', ':checked': 'Highlight' }
55
+ ':hover': { default: null, [media.hover]: colors.edgeHover },
56
+ [media.forcedColors]: { default: 'Canvas', ':checked': 'Highlight' }
61
57
  },
62
58
  backgroundImage: {
63
59
  default: 'none',
64
60
  ':checked': `linear-gradient(180deg, ${colors.ithil}, ${colors.ithilStrong})`,
65
- [FORCED]: 'none'
61
+ [media.forcedColors]: 'none'
66
62
  },
67
63
  boxShadow: {
68
64
  default: `inset 0 1px 2px ${colors.shade}`,
@@ -77,7 +73,7 @@
77
73
  outlineColor: {
78
74
  default: 'transparent',
79
75
  ':focus-visible': colors.focusRing,
80
- [FORCED]: { default: 'ButtonText', ':focus-visible': 'Highlight' }
76
+ [media.forcedColors]: { default: 'ButtonText', ':focus-visible': 'Highlight' }
81
77
  },
82
78
  outlineOffset: { default: '-1px', ':focus-visible': '2px' },
83
79
  transitionProperty: 'background-color',
@@ -97,7 +93,7 @@
97
93
  ':checked': { default: '14px 0', ':dir(rtl)': '-14px 0' }
98
94
  },
99
95
  // While pressed, the thumb stretches towards where it is about to go
100
- scale: { default: null, ':active': { default: null, [MOTION]: '1.2 1' } },
96
+ scale: { default: null, ':active': { default: null, [media.motion]: '1.2 1' } },
101
97
  transformOrigin: {
102
98
  default: 'left center',
103
99
  ':dir(rtl)': 'right center',
@@ -107,12 +103,12 @@
107
103
  backgroundColor: {
108
104
  default: '#fff',
109
105
  ':checked': colors.onIthil,
110
- [FORCED]: { default: 'ButtonText', ':checked': 'HighlightText' }
106
+ [media.forcedColors]: { default: 'ButtonText', ':checked': 'HighlightText' }
111
107
  },
112
108
  boxShadow: '0 1px 2px rgb(0 0 0 / 0.4)',
113
109
  transitionProperty: {
114
110
  default: 'background-color',
115
- [MOTION]: 'translate, scale, transform-origin, background-color'
111
+ [media.motion]: 'translate, scale, transform-origin, background-color'
116
112
  },
117
113
  transitionDuration: '200ms',
118
114
  transitionTimingFunction: motion.easeOut
@@ -4,6 +4,7 @@
4
4
  import type { HTMLAttributes } from 'svelte/elements';
5
5
  import { attrs, type Sx } from '../../internal/sx.js';
6
6
  import { colors, font, motion, radius } from '../../tokens.stylex.js';
7
+ import { media } from '../../media.stylex.js';
7
8
 
8
9
  export type TabItem = { value: string; label: string; count?: number; disabled?: boolean };
9
10
 
@@ -18,10 +19,6 @@
18
19
  children?: Snippet<[string]>;
19
20
  };
20
21
 
21
- // StyleX needs these in the same file to evaluate them at build time
22
- const HOVER = '@media (hover: hover) and (pointer: fine)';
23
- const FORCED = '@media (forced-colors: active)';
24
-
25
22
  const styles = stylex.create({
26
23
  root: {
27
24
  minWidth: 0,
@@ -46,7 +43,7 @@
46
43
  backgroundColor: 'transparent',
47
44
  color: {
48
45
  default: colors.textMuted,
49
- ':hover': { default: null, [HOVER]: colors.text }
46
+ ':hover': { default: null, [media.hover]: colors.text }
50
47
  },
51
48
  fontFamily: 'inherit',
52
49
  fontSize: font.sizeMd,
@@ -74,7 +71,7 @@
74
71
  bottom: '-1px',
75
72
  height: '2px',
76
73
  borderRadius: '2px',
77
- backgroundColor: { default: colors.ithil, [FORCED]: 'Highlight' },
74
+ backgroundColor: { default: colors.ithil, [media.forcedColors]: 'Highlight' },
78
75
  boxShadow: `0 0 8px ${colors.glow}`,
79
76
  forcedColorAdjust: 'none'
80
77
  }
@@ -5,16 +5,22 @@
5
5
  import { attrs, type Sx } from '../../internal/sx.js';
6
6
  import { colors, font } from '../../tokens.stylex.js';
7
7
 
8
- export type TextSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
8
+ /** `lead` is a lede: the line under a page's title, or the opening of a section. */
9
+ export type TextSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'lead';
9
10
  export type TextTone = 'default' | 'muted' | 'subtle' | 'accent' | 'danger' | 'success';
10
11
  export type TextWeight = 'regular' | 'medium' | 'semibold';
12
+ /** `body` is the page's own face; `display` is the serif that large headings are set in. */
13
+ export type TextFace = 'body' | 'display';
11
14
 
12
15
  export type TextProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
13
16
  /** Element to render. */
14
- as?: 'p' | 'span' | 'div' | 'label' | 'strong' | 'em' | 'small';
17
+ as?: 'p' | 'span' | 'div' | 'label' | 'strong' | 'em' | 'small' | 'figcaption' | 'blockquote';
15
18
  size?: TextSize;
16
19
  tone?: TextTone;
20
+ /** Defaults to `regular` in the body face, and to the heading weight in the display face. */
17
21
  weight?: TextWeight;
22
+ face?: TextFace;
23
+ italic?: boolean;
18
24
  /** Cuts the text off with an ellipsis on one line. */
19
25
  truncate?: boolean;
20
26
  sx?: Sx;
@@ -29,6 +35,13 @@
29
35
  lineHeight: font.leadingNormal,
30
36
  textWrap: 'pretty'
31
37
  },
38
+ display: {
39
+ fontFamily: font.display,
40
+ fontWeight: font.weightDisplay,
41
+ // The serif's capitals are tall and its lowercase small: it sets tighter than the body
42
+ lineHeight: font.leadingSnug
43
+ },
44
+ italic: { fontStyle: 'italic' },
32
45
  truncate: {
33
46
  display: 'block',
34
47
  minWidth: 0,
@@ -43,7 +56,23 @@
43
56
  sm: { fontSize: font.sizeSm },
44
57
  md: { fontSize: font.sizeMd },
45
58
  lg: { fontSize: font.sizeLg },
46
- xl: { fontSize: font.sizeXl }
59
+ xl: { fontSize: font.sizeXl },
60
+ lead: { fontSize: 'clamp(1.125rem, 1rem + 0.5vw, 1.25rem)', textWrap: 'balance' }
61
+ });
62
+
63
+ // The display serif has a small lowercase, so at the same size it reads a step smaller than
64
+ // the body face. Each size is set larger in it, to read as the same size beside body text.
65
+ const displaySizes = stylex.create({
66
+ xs: { fontSize: '0.875rem' },
67
+ sm: { fontSize: '1rem' },
68
+ md: { fontSize: '1.125rem' },
69
+ lg: { fontSize: '1.25rem' },
70
+ xl: { fontSize: '1.375rem' },
71
+ lead: {
72
+ fontSize: 'clamp(1.5rem, 1.2rem + 1.2vw, 1.875rem)',
73
+ lineHeight: font.leadingTight,
74
+ textWrap: 'balance'
75
+ }
47
76
  });
48
77
 
49
78
  const tones = stylex.create({
@@ -67,20 +96,33 @@
67
96
  as = 'p',
68
97
  size = 'md',
69
98
  tone = 'default',
70
- weight = 'regular',
99
+ weight,
100
+ face = 'body',
101
+ italic = false,
71
102
  truncate = false,
72
103
  sx,
73
104
  class: className,
74
105
  children,
75
106
  ...rest
76
107
  }: TextProps = $props();
108
+
109
+ const display = $derived(face === 'display');
77
110
  </script>
78
111
 
79
112
  <svelte:element
80
113
  this={as}
81
114
  {...rest}
82
115
  {...attrs(
83
- [styles.base, sizes[size], tones[tone], weights[weight], truncate && styles.truncate, sx],
116
+ [
117
+ styles.base,
118
+ display && styles.display,
119
+ display ? displaySizes[size] : sizes[size],
120
+ tones[tone],
121
+ weight ? weights[weight] : !display && weights.regular,
122
+ italic && styles.italic,
123
+ truncate && styles.truncate,
124
+ sx
125
+ ],
84
126
  className
85
127
  )}
86
128
  >
@@ -1,15 +1,21 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
  import { type Sx } from '../../internal/sx.js';
4
- export type TextSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
4
+ /** `lead` is a lede: the line under a page's title, or the opening of a section. */
5
+ export type TextSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'lead';
5
6
  export type TextTone = 'default' | 'muted' | 'subtle' | 'accent' | 'danger' | 'success';
6
7
  export type TextWeight = 'regular' | 'medium' | 'semibold';
8
+ /** `body` is the page's own face; `display` is the serif that large headings are set in. */
9
+ export type TextFace = 'body' | 'display';
7
10
  export type TextProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
8
11
  /** Element to render. */
9
- as?: 'p' | 'span' | 'div' | 'label' | 'strong' | 'em' | 'small';
12
+ as?: 'p' | 'span' | 'div' | 'label' | 'strong' | 'em' | 'small' | 'figcaption' | 'blockquote';
10
13
  size?: TextSize;
11
14
  tone?: TextTone;
15
+ /** Defaults to `regular` in the body face, and to the heading weight in the display face. */
12
16
  weight?: TextWeight;
17
+ face?: TextFace;
18
+ italic?: boolean;
13
19
  /** Cuts the text off with an ellipsis on one line. */
14
20
  truncate?: boolean;
15
21
  sx?: Sx;
@@ -8,6 +8,7 @@
8
8
  <script lang="ts" module>
9
9
  import * as stylex from '@stylexjs/stylex';
10
10
  import { colors, font, motion, radius, space } from '../../tokens.stylex.js';
11
+ import { media } from '../../media.stylex.js';
11
12
  import Glyph from '../../internal/Glyph.svelte';
12
13
  import Button from '../button/Button.svelte';
13
14
  import Spinner from '../spinner/Spinner.svelte';
@@ -20,8 +21,6 @@
20
21
  label?: string;
21
22
  };
22
23
 
23
- const MOTION = '@media (prefers-reduced-motion: no-preference)';
24
-
25
24
  const styles = stylex.create({
26
25
  // The top layer brings the browser's popover styles; these undo them
27
26
  region: {
@@ -58,14 +57,17 @@
58
57
  lineHeight: font.leadingSnug,
59
58
  pointerEvents: 'auto',
60
59
  opacity: { default: 1, '@starting-style': 0 },
61
- translate: { default: null, [MOTION]: { default: '0 0', '@starting-style': '0 -0.5rem' } },
62
- transitionProperty: { default: 'opacity', [MOTION]: 'opacity, translate' },
60
+ translate: {
61
+ default: null,
62
+ [media.motion]: { default: '0 0', '@starting-style': '0 -0.5rem' }
63
+ },
64
+ transitionProperty: { default: 'opacity', [media.motion]: 'opacity, translate' },
63
65
  transitionDuration: motion.slow,
64
66
  transitionTimingFunction: motion.easeOut
65
67
  },
66
68
  leaving: {
67
69
  opacity: 0,
68
- translate: { default: null, [MOTION]: '0.5rem 0' },
70
+ translate: { default: null, [media.motion]: '0.5rem 0' },
69
71
  transitionDuration: motion.fast
70
72
  },
71
73
  icon: { display: 'grid', placeItems: 'center', width: '1rem', height: '1.25rem' },
@@ -0,0 +1,40 @@
1
+ <script lang="ts" module>
2
+ import { Toggle } from 'bits-ui';
3
+ import type { Snippet } from 'svelte';
4
+ import { attrs, type Sx } from '../../internal/sx.js';
5
+ import { toggle, type ToggleSize } from '../../internal/toggle.js';
6
+
7
+ export type ToggleProps = Omit<Toggle.RootProps, 'children' | 'child'> & {
8
+ size?: ToggleSize;
9
+ /** Square, for a single icon. Give it an `aria-label`. */
10
+ iconOnly?: boolean;
11
+ sx?: Sx;
12
+ /** An icon, a short label, or both. */
13
+ children?: Snippet;
14
+ };
15
+ </script>
16
+
17
+ <script lang="ts">
18
+ let {
19
+ pressed = $bindable(false),
20
+ ref = $bindable(null),
21
+ size = 'md',
22
+ iconOnly = false,
23
+ sx,
24
+ class: className,
25
+ children,
26
+ ...rest
27
+ }: ToggleProps = $props();
28
+
29
+ const square = { sm: toggle.iconSm, md: toggle.iconMd };
30
+ </script>
31
+
32
+ <Toggle.Root
33
+ bind:pressed
34
+ bind:ref
35
+ data-slot="toggle"
36
+ {...rest}
37
+ {...attrs([toggle.base, toggle[size], iconOnly && square[size], sx], className)}
38
+ >
39
+ {@render children?.()}
40
+ </Toggle.Root>
@@ -0,0 +1,15 @@
1
+ import { Toggle } from 'bits-ui';
2
+ import type { Snippet } from 'svelte';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ import { type ToggleSize } from '../../internal/toggle.js';
5
+ export type ToggleProps = Omit<Toggle.RootProps, 'children' | 'child'> & {
6
+ size?: ToggleSize;
7
+ /** Square, for a single icon. Give it an `aria-label`. */
8
+ iconOnly?: boolean;
9
+ sx?: Sx;
10
+ /** An icon, a short label, or both. */
11
+ children?: Snippet;
12
+ };
13
+ declare const Toggle: import("svelte").Component<ToggleProps, {}, "ref" | "pressed">;
14
+ type Toggle = ReturnType<typeof Toggle>;
15
+ export default Toggle;
@@ -0,0 +1,37 @@
1
+ <script lang="ts" module>
2
+ import { ToggleGroup } from 'bits-ui';
3
+ import type { Snippet } from 'svelte';
4
+ import { attrs, type Sx } from '../../internal/sx.js';
5
+ import { toggle } from '../../internal/toggle.js';
6
+ import { getToggleGroupContext } from './context.js';
7
+
8
+ export type ToggleGroupItemProps = Omit<ToggleGroup.ItemProps, 'children' | 'child'> & {
9
+ /** Square, for a single icon. Give it an `aria-label`. */
10
+ iconOnly?: boolean;
11
+ sx?: Sx;
12
+ children?: Snippet;
13
+ };
14
+ </script>
15
+
16
+ <script lang="ts">
17
+ let {
18
+ iconOnly = false,
19
+ ref = $bindable(null),
20
+ sx,
21
+ class: className,
22
+ children,
23
+ ...rest
24
+ }: ToggleGroupItemProps = $props();
25
+
26
+ const group = getToggleGroupContext('Item');
27
+ const square = { sm: toggle.iconSm, md: toggle.iconMd };
28
+ </script>
29
+
30
+ <ToggleGroup.Item
31
+ bind:ref
32
+ data-slot="toggle-group-item"
33
+ {...rest}
34
+ {...attrs([toggle.base, toggle[group.size], iconOnly && square[group.size], sx], className)}
35
+ >
36
+ {@render children?.()}
37
+ </ToggleGroup.Item>
@@ -0,0 +1,12 @@
1
+ import { ToggleGroup } from 'bits-ui';
2
+ import type { Snippet } from 'svelte';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ export type ToggleGroupItemProps = Omit<ToggleGroup.ItemProps, 'children' | 'child'> & {
5
+ /** Square, for a single icon. Give it an `aria-label`. */
6
+ iconOnly?: boolean;
7
+ sx?: Sx;
8
+ children?: Snippet;
9
+ };
10
+ declare const ToggleGroupItem: import("svelte").Component<ToggleGroupItemProps, {}, "ref">;
11
+ type ToggleGroupItem = ReturnType<typeof ToggleGroupItem>;
12
+ export default ToggleGroupItem;
@@ -0,0 +1,95 @@
1
+ <script lang="ts" module>
2
+ import { ToggleGroup } from 'bits-ui';
3
+ import * as stylex from '@stylexjs/stylex';
4
+ import type { Snippet } from 'svelte';
5
+ import { attrs, type Sx } from '../../internal/sx.js';
6
+ import type { ToggleSize } from '../../internal/toggle.js';
7
+ import { setToggleGroupContext } from './context.js';
8
+
9
+ type Base = {
10
+ disabled?: boolean;
11
+ /** Whether the arrow keys wrap from the last item to the first. */
12
+ loop?: boolean;
13
+ orientation?: 'horizontal' | 'vertical';
14
+ /** The size of every item. */
15
+ size?: ToggleSize;
16
+ sx?: Sx;
17
+ ref?: HTMLElement | null;
18
+ /** ToggleGroup.Item buttons. */
19
+ children?: Snippet;
20
+ };
21
+
22
+ type Html = Omit<
23
+ ToggleGroup.RootProps,
24
+ 'type' | 'value' | 'onValueChange' | 'children' | 'child' | keyof Base
25
+ >;
26
+
27
+ export type ToggleGroupRootProps = Html &
28
+ Base &
29
+ (
30
+ | {
31
+ /** One item at most is pressed; pressing it again lets it go. */
32
+ type: 'single';
33
+ /** The pressed item's value, or `''` when none is. Bindable. */
34
+ value?: string;
35
+ onValueChange?: (value: string) => void;
36
+ }
37
+ | {
38
+ /** Any number of items may be pressed. */
39
+ type: 'multiple';
40
+ /** The pressed items' values. Bindable. */
41
+ value?: string[];
42
+ onValueChange?: (value: string[]) => void;
43
+ }
44
+ );
45
+
46
+ const styles = stylex.create({
47
+ root: {
48
+ display: 'inline-flex',
49
+ alignItems: 'center',
50
+ gap: '0.25rem'
51
+ },
52
+ vertical: { flexDirection: 'column', alignItems: 'stretch' }
53
+ });
54
+ </script>
55
+
56
+ <script lang="ts">
57
+ let {
58
+ type,
59
+ value = $bindable(),
60
+ onValueChange,
61
+ size = 'md',
62
+ orientation = 'horizontal',
63
+ ref = $bindable(null),
64
+ sx,
65
+ class: className,
66
+ children,
67
+ ...rest
68
+ }: ToggleGroupRootProps = $props();
69
+
70
+ setToggleGroupContext({
71
+ get size() {
72
+ return size;
73
+ }
74
+ });
75
+
76
+ const group = $derived({
77
+ type,
78
+ value: value ?? (type === 'multiple' ? [] : ''),
79
+ onValueChange: (next: string | string[]) => {
80
+ value = next;
81
+ (onValueChange as ((value: string | string[]) => void) | undefined)?.(next);
82
+ }
83
+ } as ToggleGroup.RootProps);
84
+ </script>
85
+
86
+ <ToggleGroup.Root
87
+ bind:ref
88
+ {orientation}
89
+ data-slot="toggle-group"
90
+ {...group}
91
+ {...rest}
92
+ {...attrs([styles.root, orientation === 'vertical' && styles.vertical, sx], className)}
93
+ >
94
+ {@render children?.()}
95
+ </ToggleGroup.Root>
@@ -0,0 +1,33 @@
1
+ import { ToggleGroup } from 'bits-ui';
2
+ import type { Snippet } from 'svelte';
3
+ import { type Sx } from '../../internal/sx.js';
4
+ import type { ToggleSize } from '../../internal/toggle.js';
5
+ type Base = {
6
+ disabled?: boolean;
7
+ /** Whether the arrow keys wrap from the last item to the first. */
8
+ loop?: boolean;
9
+ orientation?: 'horizontal' | 'vertical';
10
+ /** The size of every item. */
11
+ size?: ToggleSize;
12
+ sx?: Sx;
13
+ ref?: HTMLElement | null;
14
+ /** ToggleGroup.Item buttons. */
15
+ children?: Snippet;
16
+ };
17
+ type Html = Omit<ToggleGroup.RootProps, 'type' | 'value' | 'onValueChange' | 'children' | 'child' | keyof Base>;
18
+ export type ToggleGroupRootProps = Html & Base & ({
19
+ /** One item at most is pressed; pressing it again lets it go. */
20
+ type: 'single';
21
+ /** The pressed item's value, or `''` when none is. Bindable. */
22
+ value?: string;
23
+ onValueChange?: (value: string) => void;
24
+ } | {
25
+ /** Any number of items may be pressed. */
26
+ type: 'multiple';
27
+ /** The pressed items' values. Bindable. */
28
+ value?: string[];
29
+ onValueChange?: (value: string[]) => void;
30
+ });
31
+ declare const ToggleGroupRoot: import("svelte").Component<ToggleGroupRootProps, {}, "value" | "ref">;
32
+ type ToggleGroupRoot = ReturnType<typeof ToggleGroupRoot>;
33
+ export default ToggleGroupRoot;
@@ -0,0 +1,6 @@
1
+ import type { ToggleSize } from '../../internal/toggle.js';
2
+ export type ToggleGroupContext = {
3
+ readonly size: ToggleSize;
4
+ };
5
+ export declare function setToggleGroupContext(context: ToggleGroupContext): void;
6
+ export declare function getToggleGroupContext(part: string): ToggleGroupContext;
@@ -0,0 +1,11 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ const KEY = Symbol('narvi.toggle-group');
3
+ export function setToggleGroupContext(context) {
4
+ setContext(KEY, context);
5
+ }
6
+ export function getToggleGroupContext(part) {
7
+ const context = getContext(KEY);
8
+ if (!context)
9
+ throw new Error(`<ToggleGroup.${part}> must be placed inside <ToggleGroup.Root>.`);
10
+ return context;
11
+ }
@@ -0,0 +1,5 @@
1
+ import Item from './ToggleGroupItem.svelte';
2
+ import Root from './ToggleGroupRoot.svelte';
3
+ export { Root, Item };
4
+ export type { ToggleGroupItemProps } from './ToggleGroupItem.svelte';
5
+ export type { ToggleGroupRootProps } from './ToggleGroupRoot.svelte';
@@ -0,0 +1,3 @@
1
+ import Item from './ToggleGroupItem.svelte';
2
+ import Root from './ToggleGroupRoot.svelte';
3
+ export { Root, Item };
@@ -8,6 +8,7 @@
8
8
  import { attrs, type Sx } from '../../internal/sx.js';
9
9
  import Tile, { type TileTone } from '../../internal/Tile.svelte';
10
10
  import { colors, font, motion, radius } from '../../tokens.stylex.js';
11
+ import { media } from '../../media.stylex.js';
11
12
  import Shimmer from '../shimmer/Shimmer.svelte';
12
13
  import { getToolContext, type ToolState } from './context.js';
13
14
 
@@ -20,9 +21,6 @@
20
21
  children?: Snippet;
21
22
  };
22
23
 
23
- const HOVER = '@media (hover: hover) and (pointer: fine)';
24
- const MOTION = '@media (prefers-reduced-motion: no-preference)';
25
-
26
24
  const TONES: Record<ToolState, TileTone> = {
27
25
  pending: 'live',
28
26
  running: 'live',
@@ -44,7 +42,7 @@
44
42
  borderWidth: 0,
45
43
  borderRadius: radius.xs,
46
44
  backgroundColor: 'transparent',
47
- color: { default: colors.textMuted, ':hover': { default: null, [HOVER]: colors.text } },
45
+ color: { default: colors.textMuted, ':hover': { default: null, [media.hover]: colors.text } },
48
46
  fontFamily: 'inherit',
49
47
  fontSize: font.sizeMd,
50
48
  lineHeight: font.leadingSnug,
@@ -95,8 +93,8 @@
95
93
  fontSize: font.sizeXs,
96
94
  fontWeight: font.weightMedium,
97
95
  opacity: { default: 1, '@starting-style': 0 },
98
- scale: { default: null, [MOTION]: { default: 1, '@starting-style': 0.6 } },
99
- transitionProperty: { default: 'opacity', [MOTION]: 'opacity, scale' },
96
+ scale: { default: null, [media.motion]: { default: 1, '@starting-style': 0.6 } },
97
+ transitionProperty: { default: 'opacity', [media.motion]: 'opacity, scale' },
100
98
  transitionDuration: motion.slow,
101
99
  transitionTimingFunction: motion.easeOut
102
100
  },
@@ -4,6 +4,7 @@
4
4
  import type { Snippet } from 'svelte';
5
5
  import { attrs, type Sx } from '../../internal/sx.js';
6
6
  import { colors, font, motion, radius } from '../../tokens.stylex.js';
7
+ import { media } from '../../media.stylex.js';
7
8
  import Kbd from '../kbd/Kbd.svelte';
8
9
 
9
10
  export type TooltipContentProps = Omit<Tooltip.ContentProps, 'children' | 'child'> & {
@@ -13,7 +14,6 @@
13
14
  children?: Snippet;
14
15
  };
15
16
 
16
- const MOTION = '@media (prefers-reduced-motion: no-preference)';
17
17
  const CLOSED = ':is([data-state="closed"])';
18
18
  const INSTANT = ':is([data-state="instant-open"])';
19
19
 
@@ -35,8 +35,11 @@
35
35
  lineHeight: font.leadingSnug,
36
36
  transformOrigin: 'var(--bits-floating-transform-origin)',
37
37
  opacity: { default: 1, '@starting-style': 0, [CLOSED]: 0 },
38
- scale: { default: null, [MOTION]: { default: 1, '@starting-style': 0.97, [CLOSED]: 0.97 } },
39
- transitionProperty: { default: 'opacity', [MOTION]: 'opacity, scale' },
38
+ scale: {
39
+ default: null,
40
+ [media.motion]: { default: 1, '@starting-style': 0.97, [CLOSED]: 0.97 }
41
+ },
42
+ transitionProperty: { default: 'opacity', [media.motion]: 'opacity, scale' },
40
43
  transitionTimingFunction: motion.easeOut,
41
44
  // Once one tooltip is open, the next opens at once: moving along a
42
45
  // toolbar should feel quick, not like each button is thinking