@signal9/era-ui 22.0.0 → 23.0.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 (93) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/era-ui.css +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/ui/accordion/accordion-trigger.svelte +2 -2
  5. package/dist/ui/accordion/accordion-trigger.svelte.d.ts +2 -2
  6. package/dist/ui/alert-dialog/alert-dialog-content.svelte +6 -2
  7. package/dist/ui/alert-dialog/alert-dialog-content.svelte.d.ts +2 -2
  8. package/dist/ui/alert-dialog/alert-dialog-root.svelte +33 -0
  9. package/dist/ui/alert-dialog/alert-dialog-root.svelte.d.ts +8 -0
  10. package/dist/ui/alert-dialog/alert-dialog-trigger.svelte +8 -0
  11. package/dist/ui/alert-dialog/index.d.ts +1 -1
  12. package/dist/ui/alert-dialog/index.js +1 -1
  13. package/dist/ui/combobox/combobox-trigger.svelte +2 -2
  14. package/dist/ui/combobox/combobox-trigger.svelte.d.ts +2 -2
  15. package/dist/ui/context-menu/context-menu-content.svelte +6 -2
  16. package/dist/ui/context-menu/context-menu-content.svelte.d.ts +2 -2
  17. package/dist/ui/context-menu/context-menu-root.svelte +33 -0
  18. package/dist/ui/context-menu/context-menu-root.svelte.d.ts +8 -0
  19. package/dist/ui/context-menu/context-menu-sub-content.svelte +6 -2
  20. package/dist/ui/context-menu/context-menu-sub-content.svelte.d.ts +2 -2
  21. package/dist/ui/context-menu/context-menu-sub-trigger.svelte +2 -2
  22. package/dist/ui/context-menu/context-menu-sub-trigger.svelte.d.ts +2 -2
  23. package/dist/ui/context-menu/context-menu-trigger.svelte +8 -0
  24. package/dist/ui/context-menu/index.d.ts +1 -1
  25. package/dist/ui/context-menu/index.js +1 -1
  26. package/dist/ui/date-picker/date-picker-trigger.svelte +2 -2
  27. package/dist/ui/date-picker/date-picker-trigger.svelte.d.ts +2 -2
  28. package/dist/ui/date-range-picker/date-range-picker-trigger.svelte +2 -2
  29. package/dist/ui/date-range-picker/date-range-picker-trigger.svelte.d.ts +2 -2
  30. package/dist/ui/dialog/dialog-content.svelte +16 -2
  31. package/dist/ui/dialog/dialog-content.svelte.d.ts +2 -2
  32. package/dist/ui/dialog/dialog-root.svelte +43 -0
  33. package/dist/ui/dialog/dialog-root.svelte.d.ts +8 -0
  34. package/dist/ui/dialog/dialog-trigger.svelte +10 -0
  35. package/dist/ui/dialog/index.d.ts +1 -1
  36. package/dist/ui/dialog/index.js +1 -1
  37. package/dist/ui/dropdown-menu/dropdown-menu-content.svelte +6 -2
  38. package/dist/ui/dropdown-menu/dropdown-menu-content.svelte.d.ts +2 -2
  39. package/dist/ui/dropdown-menu/dropdown-menu-root.svelte +33 -0
  40. package/dist/ui/dropdown-menu/dropdown-menu-root.svelte.d.ts +8 -0
  41. package/dist/ui/dropdown-menu/dropdown-menu-sub-content.svelte +6 -2
  42. package/dist/ui/dropdown-menu/dropdown-menu-sub-content.svelte.d.ts +2 -2
  43. package/dist/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +2 -2
  44. package/dist/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte.d.ts +2 -2
  45. package/dist/ui/dropdown-menu/dropdown-menu-trigger.svelte +10 -2
  46. package/dist/ui/dropdown-menu/dropdown-menu-trigger.svelte.d.ts +2 -2
  47. package/dist/ui/dropdown-menu/index.d.ts +1 -1
  48. package/dist/ui/dropdown-menu/index.js +1 -1
  49. package/dist/ui/index.d.ts +1 -0
  50. package/dist/ui/index.js +1 -0
  51. package/dist/ui/link-preview/index.d.ts +1 -1
  52. package/dist/ui/link-preview/index.js +1 -1
  53. package/dist/ui/link-preview/link-preview-content.svelte +6 -2
  54. package/dist/ui/link-preview/link-preview-content.svelte.d.ts +2 -2
  55. package/dist/ui/link-preview/link-preview-root.svelte +33 -0
  56. package/dist/ui/link-preview/link-preview-root.svelte.d.ts +8 -0
  57. package/dist/ui/link-preview/link-preview-trigger.svelte +8 -0
  58. package/dist/ui/menubar/menubar-content.svelte +6 -2
  59. package/dist/ui/menubar/menubar-content.svelte.d.ts +2 -2
  60. package/dist/ui/menubar/menubar-root.svelte +26 -1
  61. package/dist/ui/menubar/menubar-root.svelte.d.ts +1 -1
  62. package/dist/ui/menubar/menubar-sub-content.svelte +6 -2
  63. package/dist/ui/menubar/menubar-sub-content.svelte.d.ts +2 -2
  64. package/dist/ui/menubar/menubar-sub-trigger.svelte +2 -2
  65. package/dist/ui/menubar/menubar-sub-trigger.svelte.d.ts +2 -2
  66. package/dist/ui/nav/index.d.ts +2 -0
  67. package/dist/ui/nav/index.js +2 -0
  68. package/dist/ui/nav/nav-bar.svelte +51 -0
  69. package/dist/ui/nav/nav-bar.svelte.d.ts +21 -0
  70. package/dist/ui/nav/nav-item.svelte +79 -0
  71. package/dist/ui/nav/nav-item.svelte.d.ts +29 -0
  72. package/dist/ui/provider/axes.d.ts +14 -1
  73. package/dist/ui/provider/axis-relay.svelte.d.ts +34 -0
  74. package/dist/ui/provider/axis-relay.svelte.js +109 -0
  75. package/dist/ui/select/select-content.svelte +2 -2
  76. package/dist/ui/select/select-content.svelte.d.ts +2 -2
  77. package/dist/ui/select/select-trigger.svelte +2 -2
  78. package/dist/ui/select/select-trigger.svelte.d.ts +2 -2
  79. package/dist/ui/sheet/sheet-content.svelte +8 -2
  80. package/dist/ui/sheet/sheet-content.svelte.d.ts +2 -2
  81. package/dist/ui/step/step-content.svelte +2 -2
  82. package/dist/ui/step/step-content.svelte.d.ts +2 -2
  83. package/dist/ui/step/step-summary.svelte +2 -2
  84. package/dist/ui/step/step-summary.svelte.d.ts +2 -2
  85. package/dist/ui/tooltip/index.d.ts +1 -1
  86. package/dist/ui/tooltip/index.js +1 -1
  87. package/dist/ui/tooltip/tooltip-content.svelte +6 -2
  88. package/dist/ui/tooltip/tooltip-content.svelte.d.ts +2 -2
  89. package/dist/ui/tooltip/tooltip-root.svelte +33 -0
  90. package/dist/ui/tooltip/tooltip-root.svelte.d.ts +8 -0
  91. package/dist/ui/tooltip/tooltip-trigger.svelte +8 -0
  92. package/dist/utils/index.d.ts +36 -3
  93. package/package.json +1 -1
@@ -1,14 +1,14 @@
1
1
  <script lang="ts">
2
2
  import { DropdownMenu } from 'bits-ui';
3
3
  import ChevronRight from '@lucide/svelte/icons/chevron-right';
4
- import { cn, type PartProps } from '../../utils/index.js';
4
+ import { cn, type OwnedPartProps } from '../../utils/index.js';
5
5
 
6
6
  let {
7
7
  ref = $bindable(null),
8
8
  children,
9
9
  class: className,
10
10
  ...restProps
11
- }: PartProps<DropdownMenu.SubTriggerProps> = $props();
11
+ }: OwnedPartProps<DropdownMenu.SubTriggerProps> = $props();
12
12
  </script>
13
13
 
14
14
  <DropdownMenu.SubTrigger
@@ -1,5 +1,5 @@
1
1
  import { DropdownMenu } from 'bits-ui';
2
- import { type PartProps } from '../../utils/index.js';
3
- declare const DropdownMenuSubTrigger: import("svelte").Component<PartProps<DropdownMenu.SubTriggerProps>, {}, "ref">;
2
+ import { type OwnedPartProps } from '../../utils/index.js';
3
+ declare const DropdownMenuSubTrigger: import("svelte").Component<OwnedPartProps<DropdownMenu.SubTriggerProps>, {}, "ref">;
4
4
  type DropdownMenuSubTrigger = ReturnType<typeof DropdownMenuSubTrigger>;
5
5
  export default DropdownMenuSubTrigger;
@@ -1,14 +1,22 @@
1
1
  <script lang="ts">
2
+ import { getAxisRelay } from '../provider/axis-relay.svelte.js';
2
3
  import { DropdownMenu } from 'bits-ui';
3
4
  import ChevronDown from '@lucide/svelte/icons/chevron-down';
4
- import { cn, type PartProps } from '../../utils/index.js';
5
+ import { cn, type OwnedPartProps } from '../../utils/index.js';
5
6
 
6
7
  let {
7
8
  ref = $bindable(null),
8
9
  children,
9
10
  class: className,
10
11
  ...restProps
11
- }: PartProps<DropdownMenu.TriggerProps> = $props();
12
+ }: OwnedPartProps<DropdownMenu.TriggerProps> = $props();
13
+
14
+ // The trigger is the last node still inside the subtree, so it is the
15
+ // anchor the axes are read FROM when the content opens.
16
+ const relay = getAxisRelay();
17
+ $effect(() => {
18
+ relay?.register(ref);
19
+ });
12
20
  </script>
13
21
 
14
22
  <DropdownMenu.Trigger
@@ -1,5 +1,5 @@
1
1
  import { DropdownMenu } from 'bits-ui';
2
- import { type PartProps } from '../../utils/index.js';
3
- declare const DropdownMenuTrigger: import("svelte").Component<PartProps<DropdownMenu.TriggerProps>, {}, "ref">;
2
+ import { type OwnedPartProps } from '../../utils/index.js';
3
+ declare const DropdownMenuTrigger: import("svelte").Component<OwnedPartProps<DropdownMenu.TriggerProps>, {}, "ref">;
4
4
  type DropdownMenuTrigger = ReturnType<typeof DropdownMenuTrigger>;
5
5
  export default DropdownMenuTrigger;
@@ -1,5 +1,5 @@
1
1
  import { DropdownMenu } from 'bits-ui';
2
- export declare const Root: typeof DropdownMenu.Root;
2
+ export { default as Root } from './dropdown-menu-root.svelte';
3
3
  export declare const Group: typeof DropdownMenu.Group;
4
4
  export declare const RadioGroup: typeof DropdownMenu.RadioGroup;
5
5
  export declare const Sub: typeof DropdownMenu.Sub;
@@ -1,5 +1,5 @@
1
1
  import { DropdownMenu } from 'bits-ui';
2
- export const Root = DropdownMenu.Root;
2
+ export { default as Root } from './dropdown-menu-root.svelte';
3
3
  export const Group = DropdownMenu.Group;
4
4
  export const RadioGroup = DropdownMenu.RadioGroup;
5
5
  export const Sub = DropdownMenu.Sub;
@@ -23,6 +23,7 @@ export * as Dialog from './dialog/index.js';
23
23
  export * as DropdownMenu from './dropdown-menu/index.js';
24
24
  export { FileUpload } from './file-upload/index.js';
25
25
  export * as Menubar from './menubar/index.js';
26
+ export * as Nav from './nav/index.js';
26
27
  export * as Menu from './menu/index.js';
27
28
  export { Meter } from './meter/index.js';
28
29
  export { Progress } from './progress/index.js';
package/dist/ui/index.js CHANGED
@@ -23,6 +23,7 @@ export * as Dialog from './dialog/index.js';
23
23
  export * as DropdownMenu from './dropdown-menu/index.js';
24
24
  export { FileUpload } from './file-upload/index.js';
25
25
  export * as Menubar from './menubar/index.js';
26
+ export * as Nav from './nav/index.js';
26
27
  export * as Menu from './menu/index.js';
27
28
  export { Meter } from './meter/index.js';
28
29
  export { Progress } from './progress/index.js';
@@ -1,5 +1,5 @@
1
1
  import { LinkPreview } from 'bits-ui';
2
- export declare const Root: typeof LinkPreview.Root;
2
+ export { default as Root } from './link-preview-root.svelte';
3
3
  export declare const Arrow: typeof LinkPreview.Arrow;
4
4
  export declare const ContentStatic: typeof LinkPreview.ContentStatic;
5
5
  export declare const Portal: typeof LinkPreview.Portal;
@@ -1,5 +1,5 @@
1
1
  import { LinkPreview } from 'bits-ui';
2
- export const Root = LinkPreview.Root;
2
+ export { default as Root } from './link-preview-root.svelte';
3
3
  export const Arrow = LinkPreview.Arrow;
4
4
  export const ContentStatic = LinkPreview.ContentStatic;
5
5
  export const Portal = LinkPreview.Portal;
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
+ import { getAxisRelay } from '../provider/axis-relay.svelte.js';
2
3
  import { LinkPreview } from 'bits-ui';
3
- import { cn, type PartProps } from '../../utils/index.js';
4
+ import { cn, type OwnedPartProps } from '../../utils/index.js';
4
5
 
5
6
  let {
6
7
  ref = $bindable(null),
@@ -8,12 +9,15 @@
8
9
  class: className,
9
10
  sideOffset = 8,
10
11
  ...restProps
11
- }: PartProps<LinkPreview.ContentProps> = $props();
12
+ }: OwnedPartProps<LinkPreview.ContentProps> = $props();
13
+
14
+ const relay = getAxisRelay();
12
15
  </script>
13
16
 
14
17
  <LinkPreview.Portal>
15
18
  <LinkPreview.Content
16
19
  bind:ref
20
+ {...relay?.attrs}
17
21
  class={cn(
18
22
  'z-overlay max-w-xs rounded-control bg-elevated p-inset-control text-body shadow-lg glass-blur',
19
23
  className
@@ -1,5 +1,5 @@
1
1
  import { LinkPreview } from 'bits-ui';
2
- import { type PartProps } from '../../utils/index.js';
3
- declare const LinkPreviewContent: import("svelte").Component<PartProps<LinkPreview.ContentProps>, {}, "ref">;
2
+ import { type OwnedPartProps } from '../../utils/index.js';
3
+ declare const LinkPreviewContent: import("svelte").Component<OwnedPartProps<LinkPreview.ContentProps>, {}, "ref">;
4
4
  type LinkPreviewContent = ReturnType<typeof LinkPreviewContent>;
5
5
  export default LinkPreviewContent;
@@ -0,0 +1,33 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import { LinkPreview } from 'bits-ui';
4
+ import { setAxisRelay } from '../provider/axis-relay.svelte.js';
5
+
6
+ /*
7
+ * era owns Root ONLY to open the axis channel — it renders no DOM, adds no
8
+ * behaviour and forwards everything. There has to BE a component here: a
9
+ * re-export (`export const Root = LinkPreview.Root`) has nowhere to put a context,
10
+ * which is exactly why the axes could not cross the portal before.
11
+ *
12
+ * `open` is re-declared bindable because a spread cannot carry a two-way
13
+ * binding, so wrapping a primitive breaks `bind:open` at every call site
14
+ * unless the wrapper states it.
15
+ */
16
+ let {
17
+ open = $bindable(false),
18
+ children,
19
+ ...restProps
20
+ }: LinkPreview.RootProps & { children?: Snippet } = $props();
21
+
22
+ const relay = setAxisRelay();
23
+
24
+ // Capture on OPEN, not on mount: bits-ui mounts content eagerly and toggles
25
+ // it, so a mount-time read runs once at page load and never again.
26
+ $effect(() => {
27
+ if (open) relay.refresh();
28
+ });
29
+ </script>
30
+
31
+ <LinkPreview.Root bind:open {...restProps}>
32
+ {@render children?.()}
33
+ </LinkPreview.Root>
@@ -0,0 +1,8 @@
1
+ import type { Snippet } from 'svelte';
2
+ import { LinkPreview } from 'bits-ui';
3
+ type $$ComponentProps = LinkPreview.RootProps & {
4
+ children?: Snippet;
5
+ };
6
+ declare const LinkPreviewRoot: import("svelte").Component<$$ComponentProps, {}, "open">;
7
+ type LinkPreviewRoot = ReturnType<typeof LinkPreviewRoot>;
8
+ export default LinkPreviewRoot;
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import { getAxisRelay } from '../provider/axis-relay.svelte.js';
2
3
  import { LinkPreview } from 'bits-ui';
3
4
  import { cn, type PartProps } from '../../utils/index.js';
4
5
 
@@ -8,6 +9,13 @@
8
9
  class: className,
9
10
  ...restProps
10
11
  }: PartProps<LinkPreview.TriggerProps> = $props();
12
+
13
+ // The trigger is the last node still inside the subtree, so it is the
14
+ // anchor the axes are read FROM when the content opens.
15
+ const relay = getAxisRelay();
16
+ $effect(() => {
17
+ relay?.register(ref);
18
+ });
11
19
  </script>
12
20
 
13
21
  <LinkPreview.Trigger
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
+ import { getAxisRelay } from '../provider/axis-relay.svelte.js';
2
3
  import { Menubar } from 'bits-ui';
3
- import { cn, type PartProps } from '../../utils/index.js';
4
+ import { cn, type OwnedPartProps } from '../../utils/index.js';
4
5
 
5
6
  let {
6
7
  ref = $bindable(null),
@@ -8,12 +9,15 @@
8
9
  class: className,
9
10
  sideOffset = 4,
10
11
  ...restProps
11
- }: PartProps<Menubar.ContentProps> = $props();
12
+ }: OwnedPartProps<Menubar.ContentProps> = $props();
13
+
14
+ const relay = getAxisRelay();
12
15
  </script>
13
16
 
14
17
  <Menubar.Portal>
15
18
  <Menubar.Content
16
19
  bind:ref
20
+ {...relay?.attrs}
17
21
  align="start"
18
22
  // p-menu, SURFACE-owned on purpose: 0 on flat — rows run the
19
23
  // panel's full width, flush, and the first row sits directly under the
@@ -1,5 +1,5 @@
1
1
  import { Menubar } from 'bits-ui';
2
- import { type PartProps } from '../../utils/index.js';
3
- declare const MenubarContent: import("svelte").Component<PartProps<Menubar.ContentProps>, {}, "ref">;
2
+ import { type OwnedPartProps } from '../../utils/index.js';
3
+ declare const MenubarContent: import("svelte").Component<OwnedPartProps<Menubar.ContentProps>, {}, "ref">;
4
4
  type MenubarContent = ReturnType<typeof MenubarContent>;
5
5
  export default MenubarContent;
@@ -1,12 +1,37 @@
1
1
  <script lang="ts">
2
2
  import { Menubar } from 'bits-ui';
3
3
  import { cn } from '../../utils/index.js';
4
+ import { setAxisRelay } from '../provider/axis-relay.svelte.js';
4
5
 
5
- let { ref = $bindable(null), class: className, ...restProps }: Menubar.RootProps = $props();
6
+ let {
7
+ ref = $bindable(null),
8
+ value = $bindable(''),
9
+ class: className,
10
+ ...restProps
11
+ }: Menubar.RootProps = $props();
12
+
13
+ const relay = setAxisRelay();
14
+
15
+ /*
16
+ * Menubar's "open" is `value` — WHICH menu is open, not whether one is — so
17
+ * the capture keys off a non-empty value. Same reason as everywhere else:
18
+ * bits-ui mounts content eagerly, so reading at mount reads page load.
19
+ *
20
+ * The root ELEMENT is the anchor here rather than a trigger. A menubar's
21
+ * triggers are inside it, so the bar sits at the same place in the tree for
22
+ * axis purposes, and it exists whether or not any menu has been opened.
23
+ */
24
+ $effect(() => {
25
+ relay.register(ref);
26
+ });
27
+ $effect(() => {
28
+ if (value) relay.refresh();
29
+ });
6
30
  </script>
7
31
 
8
32
  <Menubar.Root
9
33
  bind:ref
34
+ bind:value
10
35
  class={cn('flex h-bar items-center rounded-bar bg-well px-gutter shadow-sm', className)}
11
36
  {...restProps}
12
37
  />
@@ -1,4 +1,4 @@
1
1
  import { Menubar } from 'bits-ui';
2
- declare const MenubarRoot: import("svelte").Component<Menubar.RootProps, {}, "ref">;
2
+ declare const MenubarRoot: import("svelte").Component<Menubar.RootProps, {}, "value" | "ref">;
3
3
  type MenubarRoot = ReturnType<typeof MenubarRoot>;
4
4
  export default MenubarRoot;
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
+ import { getAxisRelay } from '../provider/axis-relay.svelte.js';
2
3
  import { Menubar } from 'bits-ui';
3
- import { cn, type PartProps } from '../../utils/index.js';
4
+ import { cn, type OwnedPartProps } from '../../utils/index.js';
4
5
 
5
6
  let {
6
7
  ref = $bindable(null),
@@ -8,12 +9,15 @@
8
9
  class: className,
9
10
  sideOffset = 4,
10
11
  ...restProps
11
- }: PartProps<Menubar.SubContentProps> = $props();
12
+ }: OwnedPartProps<Menubar.SubContentProps> = $props();
13
+
14
+ const relay = getAxisRelay();
12
15
  </script>
13
16
 
14
17
  <Menubar.Portal>
15
18
  <Menubar.SubContent
16
19
  bind:ref
20
+ {...relay?.attrs}
17
21
  class={cn(
18
22
  'z-overlay w-max overflow-hidden rounded-control bg-elevated p-menu shadow-lg glass-blur',
19
23
  className
@@ -1,5 +1,5 @@
1
1
  import { Menubar } from 'bits-ui';
2
- import { type PartProps } from '../../utils/index.js';
3
- declare const MenubarSubContent: import("svelte").Component<PartProps<Menubar.SubContentProps>, {}, "ref">;
2
+ import { type OwnedPartProps } from '../../utils/index.js';
3
+ declare const MenubarSubContent: import("svelte").Component<OwnedPartProps<Menubar.SubContentProps>, {}, "ref">;
4
4
  type MenubarSubContent = ReturnType<typeof MenubarSubContent>;
5
5
  export default MenubarSubContent;
@@ -1,14 +1,14 @@
1
1
  <script lang="ts">
2
2
  import { Menubar } from 'bits-ui';
3
3
  import ChevronRight from '@lucide/svelte/icons/chevron-right';
4
- import { cn, type PartProps } from '../../utils/index.js';
4
+ import { cn, type OwnedPartProps } from '../../utils/index.js';
5
5
 
6
6
  let {
7
7
  ref = $bindable(null),
8
8
  children,
9
9
  class: className,
10
10
  ...restProps
11
- }: PartProps<Menubar.SubTriggerProps> = $props();
11
+ }: OwnedPartProps<Menubar.SubTriggerProps> = $props();
12
12
  </script>
13
13
 
14
14
  <Menubar.SubTrigger
@@ -1,5 +1,5 @@
1
1
  import { Menubar } from 'bits-ui';
2
- import { type PartProps } from '../../utils/index.js';
3
- declare const MenubarSubTrigger: import("svelte").Component<PartProps<Menubar.SubTriggerProps>, {}, "ref">;
2
+ import { type OwnedPartProps } from '../../utils/index.js';
3
+ declare const MenubarSubTrigger: import("svelte").Component<OwnedPartProps<Menubar.SubTriggerProps>, {}, "ref">;
4
4
  type MenubarSubTrigger = ReturnType<typeof MenubarSubTrigger>;
5
5
  export default MenubarSubTrigger;
@@ -0,0 +1,2 @@
1
+ export { default as Bar } from './nav-bar.svelte';
2
+ export { default as Item } from './nav-item.svelte';
@@ -0,0 +1,2 @@
1
+ export { default as Bar } from './nav-bar.svelte';
2
+ export { default as Item } from './nav-item.svelte';
@@ -0,0 +1,51 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ import { cn } from '../../utils/index.js';
5
+ // Bar's geometry, imported rather than restated. A re-export here would be a
6
+ // second name for one thing; anyone who wants the variants imports them from
7
+ // Bar, which is where they are defined.
8
+ import { barVariants } from '../bar/bar.svelte';
9
+
10
+ let {
11
+ ref = $bindable(null),
12
+ size = 'bar',
13
+ content = 'tier',
14
+ label = 'Main',
15
+ children,
16
+ class: className,
17
+ ...restProps
18
+ }: HTMLAttributes<HTMLElement> & {
19
+ ref?: HTMLElement | null;
20
+ /** Height tier, exactly as Bar's — the geometry is Bar's, not a second copy. */
21
+ size?: 'chip' | 'control' | 'bar';
22
+ /** Tier of the items inside, so the wall stays concentric to them. */
23
+ content?: 'tier' | 'pill';
24
+ /**
25
+ * The accessible name for this landmark. A page may hold several
26
+ * navigations (primary, breadcrumb, pagination, footer) and a screen
27
+ * reader lists them all by name — unnamed, they read as "navigation",
28
+ * "navigation", "navigation". Defaults to "Main" rather than nothing so
29
+ * the common case is named without anyone having to know this.
30
+ */
31
+ label?: string;
32
+ children?: Snippet;
33
+ } = $props();
34
+ </script>
35
+
36
+ <!--
37
+ A <nav> LANDMARK, not a styled div, which is the entire reason this exists
38
+ next to Bar. Bar is a layout primitive: a flex row on a tier with concentric
39
+ walls, and deliberately semantics-free, so consumers were building tab bars
40
+ out of it and shipping a row of links no assistive technology could find or
41
+ skip. Nav.Bar is that same geometry — it literally reuses barVariants rather
42
+ than restating it — with the landmark and the name attached.
43
+ -->
44
+ <nav
45
+ bind:this={ref}
46
+ aria-label={label}
47
+ class={cn(barVariants({ size, content }), className)}
48
+ {...restProps}
49
+ >
50
+ {@render children?.()}
51
+ </nav>
@@ -0,0 +1,21 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ type $$ComponentProps = HTMLAttributes<HTMLElement> & {
4
+ ref?: HTMLElement | null;
5
+ /** Height tier, exactly as Bar's — the geometry is Bar's, not a second copy. */
6
+ size?: 'chip' | 'control' | 'bar';
7
+ /** Tier of the items inside, so the wall stays concentric to them. */
8
+ content?: 'tier' | 'pill';
9
+ /**
10
+ * The accessible name for this landmark. A page may hold several
11
+ * navigations (primary, breadcrumb, pagination, footer) and a screen
12
+ * reader lists them all by name — unnamed, they read as "navigation",
13
+ * "navigation", "navigation". Defaults to "Main" rather than nothing so
14
+ * the common case is named without anyone having to know this.
15
+ */
16
+ label?: string;
17
+ children?: Snippet;
18
+ };
19
+ declare const NavBar: import("svelte").Component<$$ComponentProps, {}, "ref">;
20
+ type NavBar = ReturnType<typeof NavBar>;
21
+ export default NavBar;
@@ -0,0 +1,79 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLAnchorAttributes } from 'svelte/elements';
4
+ import { cn } from '../../utils/index.js';
5
+ import { buttonVariants } from '../button/variants.js';
6
+
7
+ let {
8
+ ref = $bindable(null),
9
+ href,
10
+ current = false,
11
+ size = 'control',
12
+ lead,
13
+ trail,
14
+ children,
15
+ class: className,
16
+ ...restProps
17
+ }: HTMLAnchorAttributes & {
18
+ ref?: HTMLAnchorElement | null;
19
+ href: string;
20
+ /**
21
+ * Whether this item points at the page you are on.
22
+ *
23
+ * There is deliberately no `active` prop beside this one. `active` would
24
+ * be a second source of truth for one fact, and the two drift the moment
25
+ * a route changes and someone updates the styling flag but not the
26
+ * announcement — leaving a tab that LOOKS current to sighted users and
27
+ * announces nothing to a screen reader, or the reverse. This sets
28
+ * `aria-current="page"`, and the styling below keys off that attribute,
29
+ * so the look and the announcement cannot disagree: there is one fact
30
+ * and it is the accessible one.
31
+ */
32
+ current?: boolean;
33
+ /** Tier, matching Button's rungs so an item nests in a bar the same way. */
34
+ size?: 'control' | 'chip' | 'pill' | 'icon';
35
+ /** Icon before the label, outside it — same contract as Button's. */
36
+ lead?: Snippet;
37
+ /** Icon after the label, outside it. */
38
+ trail?: Snippet;
39
+ children?: Snippet;
40
+ } = $props();
41
+ </script>
42
+
43
+ <!--
44
+ GEOMETRY IS BUTTON'S, borrowed rather than restated: an item in a bar is a
45
+ control on a rung, and a nav that invented its own heights would fall off the
46
+ ladder the first time the density axis moved.
47
+
48
+ The latched face is Button's too — bg-fill, the pressed shadow, held on hover
49
+ so it does not spring back up on bevel — but it is driven by
50
+ [aria-current='page'] instead of a class the caller sets. That is the whole
51
+ design: the attribute a screen reader reads IS the selector that paints.
52
+ -->
53
+ <!-- Nav.Item takes app routes and external URLs alike; resolution is the caller's. -->
54
+ <!-- eslint-disable svelte/no-navigation-without-resolve -->
55
+ <a
56
+ bind:this={ref}
57
+ {href}
58
+ aria-current={current ? 'page' : undefined}
59
+ class={cn(
60
+ buttonVariants({ size }),
61
+ 'no-underline aria-[current=page]:bg-fill aria-[current=page]:text-bright aria-[current=page]:shadow-pressed aria-[current=page]:hover:shadow-pressed',
62
+ className
63
+ )}
64
+ {...restProps}
65
+ >
66
+ <span
67
+ data-button-content
68
+ class="inline-flex items-center justify-center [gap:inherit] not-has-[svg]:era-label-ink"
69
+ >
70
+ {#if lead || trail}
71
+ {@render lead?.()}
72
+ {#if children}<span class="era-text-trim">{@render children()}</span>{/if}
73
+ {@render trail?.()}
74
+ {:else}
75
+ {@render children?.()}
76
+ {/if}
77
+ </span>
78
+ </a>
79
+ <!-- eslint-enable svelte/no-navigation-without-resolve -->
@@ -0,0 +1,29 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAnchorAttributes } from 'svelte/elements';
3
+ type $$ComponentProps = HTMLAnchorAttributes & {
4
+ ref?: HTMLAnchorElement | null;
5
+ href: string;
6
+ /**
7
+ * Whether this item points at the page you are on.
8
+ *
9
+ * There is deliberately no `active` prop beside this one. `active` would
10
+ * be a second source of truth for one fact, and the two drift the moment
11
+ * a route changes and someone updates the styling flag but not the
12
+ * announcement — leaving a tab that LOOKS current to sighted users and
13
+ * announces nothing to a screen reader, or the reverse. This sets
14
+ * `aria-current="page"`, and the styling below keys off that attribute,
15
+ * so the look and the announcement cannot disagree: there is one fact
16
+ * and it is the accessible one.
17
+ */
18
+ current?: boolean;
19
+ /** Tier, matching Button's rungs so an item nests in a bar the same way. */
20
+ size?: 'control' | 'chip' | 'pill' | 'icon';
21
+ /** Icon before the label, outside it — same contract as Button's. */
22
+ lead?: Snippet;
23
+ /** Icon after the label, outside it. */
24
+ trail?: Snippet;
25
+ children?: Snippet;
26
+ };
27
+ declare const NavItem: import("svelte").Component<$$ComponentProps, {}, "ref">;
28
+ type NavItem = ReturnType<typeof NavItem>;
29
+ export default NavItem;
@@ -15,7 +15,20 @@ export interface AxisMeta {
15
15
  key: string;
16
16
  /** Default level value. */
17
17
  default: string;
18
- /** Must be set on <html> so portalled content inherits it. */
18
+ /**
19
+ * Set this axis on <html> for a whole-document default.
20
+ *
21
+ * This used to read "MUST be set on <html> so portalled content inherits
22
+ * it", which was not a description of the axis but a surrender: portalled
23
+ * content is reparented to <body>, so it stopped inheriting from its subtree,
24
+ * and hoisting to the root was the only way to make it look right. That cost
25
+ * subtree scoping for the eight portalling components, and it was not even
26
+ * always available — an app that scopes a surface to part of itself cannot
27
+ * hoist without restyling the rest.
28
+ *
29
+ * The axes now cross the portal on their own (provider/axis-relay.svelte.ts),
30
+ * so this is a convenience, not a requirement.
31
+ */
19
32
  onHtml: boolean;
20
33
  /** Selectable levels, in scale order. */
21
34
  levels: readonly AxisLevel[];
@@ -0,0 +1,34 @@
1
+ export declare class AxisRelay {
2
+ #private;
3
+ /** Attributes to stamp on portalled content. Empty until a capture runs. */
4
+ attrs: Record<string, string>;
5
+ /** `dark` / `light` when a scoped one is in force, else undefined. */
6
+ scheme: "dark" | "light" | undefined;
7
+ /** Called by the Trigger once it has an element. */
8
+ register(el: HTMLElement | null | undefined): void;
9
+ /**
10
+ * Read the axes in force at the anchor and remember them.
11
+ *
12
+ * CALLED WHEN THE CONTENT OPENS, not when the trigger mounts. Capturing at
13
+ * mount looks equivalent and is not: an axis can change while a trigger sits
14
+ * there — the docs' own pickers do it on every click, and a consumer toggling
15
+ * a theme or pinning a panel to dense does it too — and a value read once at
16
+ * mount is then wrong for every subsequent open. Content is created fresh on
17
+ * each open, so refreshing there is both correct and self-scheduling.
18
+ *
19
+ * Nearest-ancestor per axis, INDEPENDENTLY: a subtree can override density
20
+ * without touching surface, and closest() answers each question separately,
21
+ * which is what makes the axes orthogonal in the first place.
22
+ */
23
+ refresh(): void;
24
+ /** The class string portalled content should carry. */
25
+ get schemeClass(): string;
26
+ }
27
+ /** Called by era's Root for a portalling component. */
28
+ export declare function setAxisRelay(): AxisRelay;
29
+ /**
30
+ * Called by a Trigger or Content. Returns null outside an era Root — a consumer
31
+ * using bits-ui's own Root directly still gets working components, just without
32
+ * the relay, so this must never throw.
33
+ */
34
+ export declare function getAxisRelay(): AxisRelay | null;