@human-kit/ui 1.0.0-beta.0 → 1.0.0-beta.1

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 (157) hide show
  1. package/README.md +2 -0
  2. package/dist/FOCUS_STATE_CONTRACT.md +1 -0
  3. package/dist/accordion/root/accordion-root.svelte +15 -3
  4. package/dist/accordion/root/context.svelte.js +4 -4
  5. package/dist/accordion/types.d.ts +9 -2
  6. package/dist/autocomplete/list/autocomplete-list.svelte.d.ts +6 -0
  7. package/dist/calendar/root/context.svelte.js +8 -2
  8. package/dist/checkbox/root/checkbox-root.svelte +28 -11
  9. package/dist/checkbox/root/checkbox-root.svelte.d.ts +13 -0
  10. package/dist/clock/root/create-time-selection-state.svelte.d.ts +5 -0
  11. package/dist/clock/root/create-time-selection-state.svelte.js +113 -10
  12. package/dist/clock/root/wheel-options.d.ts +7 -3
  13. package/dist/clock/root/wheel-options.js +7 -15
  14. package/dist/clock/wheel-column/clock-wheel-column.svelte +10 -2
  15. package/dist/clock/wheel-column/clock-wheel-column.svelte.d.ts +2 -1
  16. package/dist/collapsible/root/collapsible-root.svelte +9 -4
  17. package/dist/collapsible/types.d.ts +9 -0
  18. package/dist/combobox/input/combobox-input.svelte +12 -1
  19. package/dist/combobox/list/combobox-listbox.svelte +93 -1
  20. package/dist/combobox/list/combobox-listbox.svelte.d.ts +20 -0
  21. package/dist/combobox/root/combobox.svelte +118 -45
  22. package/dist/combobox/root/combobox.svelte.d.ts +11 -0
  23. package/dist/combobox/root/context.d.ts +12 -0
  24. package/dist/combobox/status/README.md +2 -2
  25. package/dist/combobox/tag-remove/combobox-tag-remove.svelte +14 -2
  26. package/dist/combobox/tag-remove/combobox-tag-remove.svelte.d.ts +7 -0
  27. package/dist/combobox/tags/combobox-tags.svelte +5 -2
  28. package/dist/combobox/tags/combobox-tags.svelte.d.ts +2 -0
  29. package/dist/combobox/trigger/combobox-trigger.svelte +4 -1
  30. package/dist/datepicker/README.md +3 -2
  31. package/dist/datepicker/root/date-picker-root.svelte +38 -2
  32. package/dist/datepicker/root/date-picker-root.svelte.d.ts +2 -0
  33. package/dist/datepicker/root/draft-evaluation.d.ts +7 -0
  34. package/dist/datepicker/root/draft-evaluation.js +2 -2
  35. package/dist/daterangepicker/root/date-range-picker-root.svelte +19 -1
  36. package/dist/daterangepicker/root/date-range-picker-root.svelte.d.ts +2 -0
  37. package/dist/dialog/README.md +9 -1
  38. package/dist/dialog/close/dialog-close.svelte +57 -0
  39. package/dist/dialog/close/dialog-close.svelte.d.ts +19 -0
  40. package/dist/dialog/content/dialog-content.svelte +2 -0
  41. package/dist/dialog/description/dialog-description.svelte +46 -0
  42. package/dist/dialog/description/dialog-description.svelte.d.ts +20 -0
  43. package/dist/dialog/index.d.ts +9 -0
  44. package/dist/dialog/index.js +3 -0
  45. package/dist/dialog/index.parts.d.ts +3 -0
  46. package/dist/dialog/index.parts.js +3 -0
  47. package/dist/dialog/root/context.d.ts +8 -0
  48. package/dist/dialog/root/dialog-root.svelte +58 -16
  49. package/dist/dialog/root/dialog-root.svelte.d.ts +10 -3
  50. package/dist/dialog/root/dialog-stack.d.ts +6 -22
  51. package/dist/dialog/root/dialog-stack.js +4 -33
  52. package/dist/dialog/title/dialog-title.svelte +43 -0
  53. package/dist/dialog/title/dialog-title.svelte.d.ts +21 -0
  54. package/dist/drawer/README.md +111 -0
  55. package/dist/drawer/body/drawer-body.svelte +47 -0
  56. package/dist/drawer/body/drawer-body.svelte.d.ts +32 -0
  57. package/dist/drawer/close/drawer-close.svelte +52 -0
  58. package/dist/drawer/close/drawer-close.svelte.d.ts +20 -0
  59. package/dist/drawer/content/drawer-content.svelte +597 -0
  60. package/dist/drawer/content/drawer-content.svelte.d.ts +28 -0
  61. package/dist/drawer/description/drawer-description.svelte +40 -0
  62. package/dist/drawer/description/drawer-description.svelte.d.ts +20 -0
  63. package/dist/drawer/indent/drawer-indent-background.svelte +36 -0
  64. package/dist/drawer/indent/drawer-indent-background.svelte.d.ts +17 -0
  65. package/dist/drawer/indent/drawer-indent.svelte +59 -0
  66. package/dist/drawer/indent/drawer-indent.svelte.d.ts +32 -0
  67. package/dist/drawer/index.d.ts +49 -0
  68. package/dist/drawer/index.js +25 -0
  69. package/dist/drawer/index.parts.d.ts +14 -0
  70. package/dist/drawer/index.parts.js +15 -0
  71. package/dist/drawer/overlay/drawer-overlay.svelte +67 -0
  72. package/dist/drawer/overlay/drawer-overlay.svelte.d.ts +12 -0
  73. package/dist/drawer/portal/drawer-portal.svelte +57 -0
  74. package/dist/drawer/portal/drawer-portal.svelte.d.ts +13 -0
  75. package/dist/drawer/root/context.d.ts +81 -0
  76. package/dist/drawer/root/context.js +20 -0
  77. package/dist/drawer/root/drawer-root.svelte +333 -0
  78. package/dist/drawer/root/drawer-root.svelte.d.ts +77 -0
  79. package/dist/drawer/root/drawer-stack.svelte.d.ts +73 -0
  80. package/dist/drawer/root/drawer-stack.svelte.js +113 -0
  81. package/dist/drawer/root/handle.svelte.d.ts +39 -0
  82. package/dist/drawer/root/handle.svelte.js +64 -0
  83. package/dist/drawer/root/keyboard-context.d.ts +13 -0
  84. package/dist/drawer/root/keyboard-context.js +8 -0
  85. package/dist/drawer/root/presence-context.d.ts +22 -0
  86. package/dist/drawer/root/presence-context.js +8 -0
  87. package/dist/drawer/root/snap-points.d.ts +68 -0
  88. package/dist/drawer/root/snap-points.js +120 -0
  89. package/dist/drawer/root/starting-style.svelte.d.ts +18 -0
  90. package/dist/drawer/root/starting-style.svelte.js +38 -0
  91. package/dist/drawer/root/types.d.ts +36 -0
  92. package/dist/drawer/root/types.js +1 -0
  93. package/dist/drawer/root/viewport-context.d.ts +2 -0
  94. package/dist/drawer/root/viewport-context.js +16 -0
  95. package/dist/drawer/swipe-area/drawer-swipe-area.svelte +143 -0
  96. package/dist/drawer/swipe-area/drawer-swipe-area.svelte.d.ts +22 -0
  97. package/dist/drawer/title/drawer-title.svelte +37 -0
  98. package/dist/drawer/title/drawer-title.svelte.d.ts +21 -0
  99. package/dist/drawer/trigger/drawer-trigger.svelte +90 -0
  100. package/dist/drawer/trigger/drawer-trigger.svelte.d.ts +41 -0
  101. package/dist/drawer/viewport/drawer-viewport.svelte +69 -0
  102. package/dist/drawer/viewport/drawer-viewport.svelte.d.ts +15 -0
  103. package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte +88 -0
  104. package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte.d.ts +29 -0
  105. package/dist/hooks/use-virtual-focus.svelte.d.ts +9 -0
  106. package/dist/hooks/use-virtual-focus.svelte.js +7 -1
  107. package/dist/index.d.ts +2 -0
  108. package/dist/index.js +2 -0
  109. package/dist/listbox/item/listbox-item.svelte +8 -1
  110. package/dist/listbox/root/context.d.ts +30 -0
  111. package/dist/listbox/root/context.js +10 -0
  112. package/dist/listbox/root/listbox.svelte +291 -8
  113. package/dist/listbox/root/listbox.svelte.d.ts +35 -2
  114. package/dist/menu/content/menu-content.svelte +3 -1
  115. package/dist/menu/overlay/menu-overlay.svelte +1 -1
  116. package/dist/numberfield/root/number-field-root.svelte +2 -1
  117. package/dist/popover/content/popover-content.svelte +1 -1
  118. package/dist/popover/overlay/popover-overlay.svelte +1 -1
  119. package/dist/popover/root/popover-root.svelte +23 -11
  120. package/dist/popover/root/popover-root.svelte.d.ts +10 -2
  121. package/dist/primitives/floating.d.ts +7 -0
  122. package/dist/primitives/floating.js +6 -2
  123. package/dist/primitives/index.d.ts +1 -0
  124. package/dist/primitives/index.js +1 -0
  125. package/dist/primitives/keyboard-navigation.js +3 -1
  126. package/dist/primitives/layer-stack.d.ts +29 -0
  127. package/dist/primitives/layer-stack.js +35 -0
  128. package/dist/primitives/list-virtualizer.d.ts +75 -0
  129. package/dist/primitives/list-virtualizer.js +59 -0
  130. package/dist/primitives/scroll-lock.d.ts +23 -3
  131. package/dist/primitives/scroll-lock.js +122 -9
  132. package/dist/primitives/swipe-gesture.d.ts +126 -0
  133. package/dist/primitives/swipe-gesture.js +351 -0
  134. package/dist/primitives/text.d.ts +8 -0
  135. package/dist/primitives/text.js +13 -0
  136. package/dist/switch/root/switch-root.svelte +23 -9
  137. package/dist/switch/root/switch-root.svelte.d.ts +9 -2
  138. package/dist/table/body/table-body.svelte +84 -9
  139. package/dist/table/cell/table-cell.svelte +1 -3
  140. package/dist/table/column/table-column.svelte +5 -1
  141. package/dist/table/column-resizer/table-column-resizer.svelte +1 -5
  142. package/dist/table/interactive-cell/table-interactive-cell.svelte +1 -3
  143. package/dist/table/root/context.svelte.js +99 -49
  144. package/dist/table/row/table-row.svelte +7 -7
  145. package/dist/table/sort-trigger/table-sort-trigger.svelte +5 -1
  146. package/dist/table/types.d.ts +6 -0
  147. package/dist/tabs/root/tabs-root.svelte +20 -6
  148. package/dist/tabs/types.d.ts +9 -0
  149. package/dist/timepicker/root/time-picker-root.svelte +11 -0
  150. package/dist/timepicker/root/time-picker-root.svelte.d.ts +2 -0
  151. package/dist/toggle-group/root/context.svelte.js +11 -4
  152. package/dist/toggle-group/root/toggle-group-root.svelte +19 -4
  153. package/dist/toggle-group/types.d.ts +9 -0
  154. package/dist/tree/root/context.svelte.js +6 -0
  155. package/dist/tree/root/tree-root.svelte +22 -8
  156. package/dist/tree/types.d.ts +13 -0
  157. package/package.json +227 -224
@@ -0,0 +1,36 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { drawerStack } from '../root/drawer-stack.svelte';
4
+
5
+ /**
6
+ * Drawer.IndentBackground — the surface revealed behind an indented app.
7
+ *
8
+ * Pinned to the viewport and painted by the consumer (usually a dark colour that
9
+ * reads as "behind everything"). It exists as its own part because the indented
10
+ * wrapper cannot show what is behind it: scaling an element down reveals whatever
11
+ * its parent paints, and on a phone that is the page background, which is
12
+ * normally the same colour as the app.
13
+ */
14
+ type DrawerIndentBackgroundProps = {
15
+ /** CSS class for the layer. */
16
+ class?: string;
17
+ } & Omit<HTMLAttributes<HTMLDivElement>, 'class'>;
18
+
19
+ let {
20
+ class: className = '',
21
+ style: styleProp,
22
+ ...restProps
23
+ }: DrawerIndentBackgroundProps = $props();
24
+
25
+ const progress = $derived(drawerStack.indentProgress);
26
+ const anyOpen = $derived(drawerStack.count > 0);
27
+ </script>
28
+
29
+ <div
30
+ class={className}
31
+ data-drawer-indent-background
32
+ data-state={anyOpen ? 'open' : 'closed'}
33
+ aria-hidden="true"
34
+ style="position: fixed; inset: 0; --drawer-indent-progress: {progress}; {styleProp ?? ''}"
35
+ {...restProps}
36
+ ></div>
@@ -0,0 +1,17 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ /**
3
+ * Drawer.IndentBackground — the surface revealed behind an indented app.
4
+ *
5
+ * Pinned to the viewport and painted by the consumer (usually a dark colour that
6
+ * reads as "behind everything"). It exists as its own part because the indented
7
+ * wrapper cannot show what is behind it: scaling an element down reveals whatever
8
+ * its parent paints, and on a phone that is the page background, which is
9
+ * normally the same colour as the app.
10
+ */
11
+ type DrawerIndentBackgroundProps = {
12
+ /** CSS class for the layer. */
13
+ class?: string;
14
+ } & Omit<HTMLAttributes<HTMLDivElement>, 'class'>;
15
+ declare const DrawerIndentBackground: import("svelte").Component<DrawerIndentBackgroundProps, {}, "">;
16
+ type DrawerIndentBackground = ReturnType<typeof DrawerIndentBackground>;
17
+ export default DrawerIndentBackground;
@@ -0,0 +1,59 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ import { drawerStack } from '../root/drawer-stack.svelte';
5
+
6
+ /**
7
+ * Drawer.Indent — wraps the app UI so it can pull back while a drawer is open.
8
+ *
9
+ * It applies no transform of its own: what "indented" looks like (a scale, a
10
+ * corner radius, a translation) is a design decision, so this part only
11
+ * publishes the state and the consumer's CSS reads it. That keeps the effect
12
+ * consistent with every other part of the library, where the panel's appearance
13
+ * belongs to the page and only the behaviour lives here.
14
+ *
15
+ * ```css
16
+ * .Indent {
17
+ * transition: scale 400ms, border-radius 400ms;
18
+ * scale: calc(1 - 0.05 * var(--drawer-indent-progress));
19
+ * border-radius: calc(12px * var(--drawer-indent-progress));
20
+ * }
21
+ * .Indent[data-swiping] { transition: none; }
22
+ * ```
23
+ *
24
+ * Unlike Base UI this needs no provider around it: the drawer stack is already
25
+ * module-global, so there is nothing left for one to coordinate.
26
+ */
27
+ type DrawerIndentProps = {
28
+ /** The app UI that pulls back while a drawer is open. */
29
+ children?: Snippet;
30
+ /** CSS class for the wrapper. */
31
+ class?: string;
32
+ } & Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children'>;
33
+
34
+ let {
35
+ children,
36
+ class: className = '',
37
+ style: styleProp,
38
+ ...restProps
39
+ }: DrawerIndentProps = $props();
40
+
41
+ // Falls back toward 0 as the frontmost drawer is dragged away, so the app comes
42
+ // forward with the gesture rather than jumping when the drawer finally closes.
43
+ const progress = $derived(drawerStack.indentProgress);
44
+ const anyOpen = $derived(drawerStack.count > 0);
45
+ const swiping = $derived(drawerStack.isSwiping);
46
+ </script>
47
+
48
+ <div
49
+ class={className}
50
+ data-drawer-indent
51
+ data-state={anyOpen ? 'open' : 'closed'}
52
+ data-swiping={swiping || undefined}
53
+ style="--drawer-indent-progress: {progress}; {styleProp ?? ''}"
54
+ {...restProps}
55
+ >
56
+ {#if children}
57
+ {@render children()}
58
+ {/if}
59
+ </div>
@@ -0,0 +1,32 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ /**
4
+ * Drawer.Indent — wraps the app UI so it can pull back while a drawer is open.
5
+ *
6
+ * It applies no transform of its own: what "indented" looks like (a scale, a
7
+ * corner radius, a translation) is a design decision, so this part only
8
+ * publishes the state and the consumer's CSS reads it. That keeps the effect
9
+ * consistent with every other part of the library, where the panel's appearance
10
+ * belongs to the page and only the behaviour lives here.
11
+ *
12
+ * ```css
13
+ * .Indent {
14
+ * transition: scale 400ms, border-radius 400ms;
15
+ * scale: calc(1 - 0.05 * var(--drawer-indent-progress));
16
+ * border-radius: calc(12px * var(--drawer-indent-progress));
17
+ * }
18
+ * .Indent[data-swiping] { transition: none; }
19
+ * ```
20
+ *
21
+ * Unlike Base UI this needs no provider around it: the drawer stack is already
22
+ * module-global, so there is nothing left for one to coordinate.
23
+ */
24
+ type DrawerIndentProps = {
25
+ /** The app UI that pulls back while a drawer is open. */
26
+ children?: Snippet;
27
+ /** CSS class for the wrapper. */
28
+ class?: string;
29
+ } & Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children'>;
30
+ declare const DrawerIndent: import("svelte").Component<DrawerIndentProps, {}, "">;
31
+ type DrawerIndent = ReturnType<typeof DrawerIndent>;
32
+ export default DrawerIndent;
@@ -0,0 +1,49 @@
1
+ import type { ComponentProps } from 'svelte';
2
+ import type DrawerRootComponent from './root/drawer-root.svelte';
3
+ import type DrawerTriggerComponent from './trigger/drawer-trigger.svelte';
4
+ import type DrawerPortalComponent from './portal/drawer-portal.svelte';
5
+ import type DrawerOverlayComponent from './overlay/drawer-overlay.svelte';
6
+ import type DrawerViewportComponent from './viewport/drawer-viewport.svelte';
7
+ import type DrawerContentComponent from './content/drawer-content.svelte';
8
+ import type DrawerBodyComponent from './body/drawer-body.svelte';
9
+ import type DrawerTitleComponent from './title/drawer-title.svelte';
10
+ import type DrawerDescriptionComponent from './description/drawer-description.svelte';
11
+ import type DrawerCloseComponent from './close/drawer-close.svelte';
12
+ import type DrawerSwipeAreaComponent from './swipe-area/drawer-swipe-area.svelte';
13
+ import type DrawerIndentComponent from './indent/drawer-indent.svelte';
14
+ import type DrawerIndentBackgroundComponent from './indent/drawer-indent-background.svelte';
15
+ import type DrawerVirtualKeyboardProviderComponent from './virtual-keyboard/drawer-virtual-keyboard-provider.svelte';
16
+ import * as DrawerParts from './index.parts.js';
17
+ export declare const Drawer: typeof DrawerParts;
18
+ export default DrawerParts;
19
+ export { default as DrawerRoot } from './root/drawer-root.svelte';
20
+ export { default as DrawerTrigger } from './trigger/drawer-trigger.svelte';
21
+ export { default as DrawerPortal } from './portal/drawer-portal.svelte';
22
+ export { default as DrawerOverlay } from './overlay/drawer-overlay.svelte';
23
+ export { default as DrawerViewport } from './viewport/drawer-viewport.svelte';
24
+ export { default as DrawerContent } from './content/drawer-content.svelte';
25
+ export { default as DrawerBody } from './body/drawer-body.svelte';
26
+ export { default as DrawerTitle } from './title/drawer-title.svelte';
27
+ export { default as DrawerDescription } from './description/drawer-description.svelte';
28
+ export { default as DrawerClose } from './close/drawer-close.svelte';
29
+ export { default as DrawerSwipeArea } from './swipe-area/drawer-swipe-area.svelte';
30
+ export { default as DrawerIndent } from './indent/drawer-indent.svelte';
31
+ export { default as DrawerIndentBackground } from './indent/drawer-indent-background.svelte';
32
+ export { default as DrawerVirtualKeyboardProvider } from './virtual-keyboard/drawer-virtual-keyboard-provider.svelte';
33
+ export type DrawerRootProps = ComponentProps<typeof DrawerRootComponent>;
34
+ export type DrawerTriggerProps = ComponentProps<typeof DrawerTriggerComponent>;
35
+ export type DrawerPortalProps = ComponentProps<typeof DrawerPortalComponent>;
36
+ export type DrawerOverlayProps = ComponentProps<typeof DrawerOverlayComponent>;
37
+ export type DrawerViewportProps = ComponentProps<typeof DrawerViewportComponent>;
38
+ export type DrawerContentProps = ComponentProps<typeof DrawerContentComponent>;
39
+ export type DrawerBodyProps = ComponentProps<typeof DrawerBodyComponent>;
40
+ export type DrawerTitleProps = ComponentProps<typeof DrawerTitleComponent>;
41
+ export type DrawerDescriptionProps = ComponentProps<typeof DrawerDescriptionComponent>;
42
+ export type DrawerCloseProps = ComponentProps<typeof DrawerCloseComponent>;
43
+ export type DrawerSwipeAreaProps = ComponentProps<typeof DrawerSwipeAreaComponent>;
44
+ export type DrawerIndentProps = ComponentProps<typeof DrawerIndentComponent>;
45
+ export type DrawerIndentBackgroundProps = ComponentProps<typeof DrawerIndentBackgroundComponent>;
46
+ export type DrawerVirtualKeyboardProviderProps = ComponentProps<typeof DrawerVirtualKeyboardProviderComponent>;
47
+ export { createDrawerHandle, type DrawerHandle } from './root/handle.svelte.js';
48
+ export { getDrawerContext, setDrawerContext, requireDrawerContext, type DrawerContext } from './root/context.js';
49
+ export type { DrawerSide, DrawerModal, DrawerCloseReason, DrawerSnapPoint, DrawerStateHelpers } from './root/types.js';
@@ -0,0 +1,25 @@
1
+ // Drawer component with namespace pattern
2
+ // Usage: <Drawer.Root>, <Drawer.Trigger>, <Drawer.Portal>, <Drawer.Overlay>, <Drawer.Content>
3
+ import * as DrawerParts from './index.parts.js';
4
+ // Named export for namespace usage: import { Drawer } from '...'
5
+ export const Drawer = DrawerParts;
6
+ export default DrawerParts;
7
+ // Re-export individual parts for direct imports
8
+ export { default as DrawerRoot } from './root/drawer-root.svelte';
9
+ export { default as DrawerTrigger } from './trigger/drawer-trigger.svelte';
10
+ export { default as DrawerPortal } from './portal/drawer-portal.svelte';
11
+ export { default as DrawerOverlay } from './overlay/drawer-overlay.svelte';
12
+ export { default as DrawerViewport } from './viewport/drawer-viewport.svelte';
13
+ export { default as DrawerContent } from './content/drawer-content.svelte';
14
+ export { default as DrawerBody } from './body/drawer-body.svelte';
15
+ export { default as DrawerTitle } from './title/drawer-title.svelte';
16
+ export { default as DrawerDescription } from './description/drawer-description.svelte';
17
+ export { default as DrawerClose } from './close/drawer-close.svelte';
18
+ export { default as DrawerSwipeArea } from './swipe-area/drawer-swipe-area.svelte';
19
+ export { default as DrawerIndent } from './indent/drawer-indent.svelte';
20
+ export { default as DrawerIndentBackground } from './indent/drawer-indent-background.svelte';
21
+ export { default as DrawerVirtualKeyboardProvider } from './virtual-keyboard/drawer-virtual-keyboard-provider.svelte';
22
+ // Detached triggers
23
+ export { createDrawerHandle } from './root/handle.svelte.js';
24
+ // Context utilities
25
+ export { getDrawerContext, setDrawerContext, requireDrawerContext } from './root/context.js';
@@ -0,0 +1,14 @@
1
+ export { default as Root } from './root/drawer-root.svelte';
2
+ export { default as Trigger } from './trigger/drawer-trigger.svelte';
3
+ export { default as Portal } from './portal/drawer-portal.svelte';
4
+ export { default as Overlay } from './overlay/drawer-overlay.svelte';
5
+ export { default as Viewport } from './viewport/drawer-viewport.svelte';
6
+ export { default as Content } from './content/drawer-content.svelte';
7
+ export { default as Body } from './body/drawer-body.svelte';
8
+ export { default as Title } from './title/drawer-title.svelte';
9
+ export { default as Description } from './description/drawer-description.svelte';
10
+ export { default as Close } from './close/drawer-close.svelte';
11
+ export { default as SwipeArea } from './swipe-area/drawer-swipe-area.svelte';
12
+ export { default as Indent } from './indent/drawer-indent.svelte';
13
+ export { default as IndentBackground } from './indent/drawer-indent-background.svelte';
14
+ export { default as VirtualKeyboardProvider } from './virtual-keyboard/drawer-virtual-keyboard-provider.svelte';
@@ -0,0 +1,15 @@
1
+ // Namespace parts for <Drawer.Root>, <Drawer.Content>, etc.
2
+ export { default as Root } from './root/drawer-root.svelte';
3
+ export { default as Trigger } from './trigger/drawer-trigger.svelte';
4
+ export { default as Portal } from './portal/drawer-portal.svelte';
5
+ export { default as Overlay } from './overlay/drawer-overlay.svelte';
6
+ export { default as Viewport } from './viewport/drawer-viewport.svelte';
7
+ export { default as Content } from './content/drawer-content.svelte';
8
+ export { default as Body } from './body/drawer-body.svelte';
9
+ export { default as Title } from './title/drawer-title.svelte';
10
+ export { default as Description } from './description/drawer-description.svelte';
11
+ export { default as Close } from './close/drawer-close.svelte';
12
+ export { default as SwipeArea } from './swipe-area/drawer-swipe-area.svelte';
13
+ export { default as Indent } from './indent/drawer-indent.svelte';
14
+ export { default as IndentBackground } from './indent/drawer-indent-background.svelte';
15
+ export { default as VirtualKeyboardProvider } from './virtual-keyboard/drawer-virtual-keyboard-provider.svelte';
@@ -0,0 +1,67 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import { requireDrawerContext } from '../root/context';
4
+ import { getDrawerPresenceContext } from '../root/presence-context';
5
+ import { createStartingStyle } from '../root/starting-style.svelte';
6
+ import { getOverlayZIndex } from '../../primitives/layer-stack';
7
+
8
+ /**
9
+ * Drawer.Overlay — the backdrop behind the panel.
10
+ * Belongs inside a Drawer.Portal.
11
+ */
12
+ type DrawerOverlayProps = {
13
+ /** CSS class for the overlay. */
14
+ class?: string;
15
+ } & Omit<HTMLAttributes<HTMLDivElement>, 'class'>;
16
+
17
+ let { class: className = '', style: styleProp, ...restProps }: DrawerOverlayProps = $props();
18
+
19
+ const ctx = requireDrawerContext('Drawer.Overlay');
20
+
21
+ // Present only inside Drawer.Portal. Mirrors the panel's enter/exit phase so the
22
+ // backdrop can fade in step with it.
23
+ const presence = getDrawerPresenceContext();
24
+ // Mounts as the drawer opens, so its first frame is the one to fade in from.
25
+ const startingStyle = createStartingStyle();
26
+
27
+ const zIndex = $derived(getOverlayZIndex(ctx.stackLevel));
28
+
29
+ /**
30
+ * A drawer opened on top of another does not paint its own backdrop.
31
+ *
32
+ * Every root brings its own overlay, so stacking two of them dimmed the page
33
+ * twice — the second drawer visibly darkened everything behind it, the drawer it
34
+ * opened from included. The backdrop belongs to the stack rather than to each
35
+ * layer, so only the drawer at the back paints one and the rest defer to it.
36
+ *
37
+ * Hidden rather than unmounted: if the drawer underneath closes first, this one
38
+ * becomes the back of the stack and has to take the backdrop over.
39
+ */
40
+ const isStackedAbove = $derived(ctx.stackIndex > 0);
41
+
42
+ // The backdrop tracks the drag: a sheet pulled halfway down should reveal half
43
+ // the page behind it. The consumer decides how to use it (usually
44
+ // `opacity: calc(1 - var(--drawer-swipe-progress))`); publishing it here keeps
45
+ // the backdrop in sync with a gesture that Drawer.Content owns.
46
+ // A consumer `style` is appended rather than spread through `restProps`, which
47
+ // would land after this attribute and drop the positioning with it.
48
+ const style = $derived(
49
+ `position: fixed; inset: 0; z-index: ${zIndex}; --drawer-swipe-progress: ${ctx.swipeProgress};` +
50
+ (isStackedAbove ? ' display: none;' : '') +
51
+ ` ${styleProp ?? ''}`
52
+ );
53
+ </script>
54
+
55
+ <div
56
+ class={className}
57
+ data-drawer-overlay
58
+ data-state={presence ? presence.state : 'open'}
59
+ data-entering={presence?.isEntering || undefined}
60
+ data-exiting={presence?.isExiting || undefined}
61
+ data-starting-style={startingStyle.active || undefined}
62
+ data-swiping={ctx.isSwiping || undefined}
63
+ data-nested={isStackedAbove || undefined}
64
+ data-side={ctx.side}
65
+ {style}
66
+ {...restProps}
67
+ ></div>
@@ -0,0 +1,12 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ /**
3
+ * Drawer.Overlay — the backdrop behind the panel.
4
+ * Belongs inside a Drawer.Portal.
5
+ */
6
+ type DrawerOverlayProps = {
7
+ /** CSS class for the overlay. */
8
+ class?: string;
9
+ } & Omit<HTMLAttributes<HTMLDivElement>, 'class'>;
10
+ declare const DrawerOverlay: import("svelte").Component<DrawerOverlayProps, {}, "">;
11
+ type DrawerOverlay = ReturnType<typeof DrawerOverlay>;
12
+ export default DrawerOverlay;
@@ -0,0 +1,57 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import { Portal } from '../../portal';
4
+ import { createPresence } from '../../primitives/presence.svelte';
5
+ import { requireDrawerContext } from '../root/context';
6
+ import { setDrawerPresenceContext } from '../root/presence-context';
7
+
8
+ /**
9
+ * Drawer.Portal — renders the overlay and panel outside the app's DOM position
10
+ * while the drawer is open, keeping them mounted through the exit animation so
11
+ * it can play before they leave.
12
+ */
13
+ type DrawerPortalProps = {
14
+ /** The layers to portal (Overlay, Viewport/Content). */
15
+ children?: Snippet;
16
+ };
17
+
18
+ let { children }: DrawerPortalProps = $props();
19
+
20
+ const ctx = requireDrawerContext('Drawer.Portal');
21
+
22
+ // `isMounted` outlives `isOpen` by one exit animation. The duration is measured
23
+ // from the Content element (registered via setMotionTarget), so the timing follows
24
+ // the consumer's CSS and collapses to a single frame under prefers-reduced-motion.
25
+ // When no Content ever registers, the exit resolves immediately rather than leaving
26
+ // the portal mounted forever. Starts mounted when created while already open.
27
+ let motionTarget = $state<HTMLElement | null>(null);
28
+
29
+ const presence = createPresence(
30
+ () => ctx.isOpen,
31
+ () => motionTarget,
32
+ { initiallyMounted: ctx.isOpen }
33
+ );
34
+
35
+ setDrawerPresenceContext({
36
+ get state() {
37
+ return ctx.isOpen ? 'open' : 'closed';
38
+ },
39
+ get isEntering() {
40
+ return presence.isEntering;
41
+ },
42
+ get isExiting() {
43
+ return presence.isExiting;
44
+ },
45
+ setMotionTarget: (el) => {
46
+ motionTarget = el;
47
+ }
48
+ });
49
+ </script>
50
+
51
+ {#if presence.isMounted}
52
+ <Portal>
53
+ {#if children}
54
+ {@render children()}
55
+ {/if}
56
+ </Portal>
57
+ {/if}
@@ -0,0 +1,13 @@
1
+ import type { Snippet } from 'svelte';
2
+ /**
3
+ * Drawer.Portal — renders the overlay and panel outside the app's DOM position
4
+ * while the drawer is open, keeping them mounted through the exit animation so
5
+ * it can play before they leave.
6
+ */
7
+ type DrawerPortalProps = {
8
+ /** The layers to portal (Overlay, Viewport/Content). */
9
+ children?: Snippet;
10
+ };
11
+ declare const DrawerPortal: import("svelte").Component<DrawerPortalProps, {}, "">;
12
+ type DrawerPortal = ReturnType<typeof DrawerPortal>;
13
+ export default DrawerPortal;
@@ -0,0 +1,81 @@
1
+ import type { DrawerModal, DrawerSide, DrawerCloseReason, DrawerSnapPoint } from './types';
2
+ /**
3
+ * Context shared by every Drawer part.
4
+ *
5
+ * Everything a part needs to render itself lives here rather than being threaded
6
+ * through props, so `Drawer.Overlay` can fade in step with a swipe it does not
7
+ * own, and `Drawer.Title` can label a `Drawer.Content` it is nested inside.
8
+ */
9
+ export type DrawerContext = {
10
+ /** Whether the drawer is open. */
11
+ readonly isOpen: boolean;
12
+ /** Edge the panel is anchored to. */
13
+ readonly side: DrawerSide;
14
+ /** Focus/scroll behaviour: `true`, `'trap-focus'`, or `false`. */
15
+ readonly modal: DrawerModal;
16
+ /** Whether a swipe may dismiss the drawer. */
17
+ readonly dismissible: boolean;
18
+ readonly shouldCloseOnEscape: boolean;
19
+ readonly shouldCloseOnInteractOutside: boolean;
20
+ /** Reference to the trigger element. */
21
+ readonly triggerRef: HTMLElement | null;
22
+ /** Index among the open modal layers, for z-index math. */
23
+ readonly stackLevel: number;
24
+ /**
25
+ * Index among the open DRAWERS, in open order — `0` is the one at the back.
26
+ * Published by `Drawer.Content`; `Drawer.Overlay` uses it to stay out of the way
27
+ * of the backdrop already on screen.
28
+ */
29
+ readonly stackIndex: number;
30
+ setStackIndex: (index: number) => void;
31
+ /** ids of the `Drawer.Title` parts, for `aria-labelledby`. */
32
+ readonly labelledBy: string | undefined;
33
+ /** ids of the `Drawer.Description` parts, for `aria-describedby`. */
34
+ readonly describedBy: string | undefined;
35
+ /** Registers a label id; the returned function unregisters it. */
36
+ registerLabel: (id: string) => () => void;
37
+ /** Registers a description id; the returned function unregisters it. */
38
+ registerDescription: (id: string) => () => void;
39
+ /** Resting positions the panel may settle on, if any. */
40
+ readonly snapPoints: readonly DrawerSnapPoint[] | undefined;
41
+ /** The active snap point, or `null` when the drawer is fully open. */
42
+ readonly snapPoint: DrawerSnapPoint | null;
43
+ /** Whether a flick may skip past the neighbouring snap point. */
44
+ readonly snapToSequentialPoints: boolean;
45
+ /** Moves to a snap point. Called by `Drawer.Content` when a drag settles. */
46
+ setSnapPoint: (point: DrawerSnapPoint | null, event?: Event) => void;
47
+ /** How far the panel has been dragged toward dismissal, 0–1. */
48
+ readonly swipeProgress: number;
49
+ /** Whether a drag is currently in flight. */
50
+ readonly isSwiping: boolean;
51
+ /** Published by `Drawer.Content`, which owns the gesture. */
52
+ setSwipeState: (progress: number, isSwiping: boolean) => void;
53
+ /**
54
+ * Distance, in px, that an opening drag from `Drawer.SwipeArea` has travelled, or
55
+ * `null` when no such drag is in flight. The panel follows it instead of playing
56
+ * its enter animation, so the drawer arrives with the finger.
57
+ */
58
+ readonly swipeOpenDistance: number | null;
59
+ setSwipeOpenDistance: (distance: number | null) => void;
60
+ /** Panel extent along its axis, published by `Drawer.Content`. */
61
+ readonly panelExtent: number;
62
+ setPanelExtent: (extent: number) => void;
63
+ setTriggerRef: (el: HTMLElement | null) => void;
64
+ setStackLevel: (level: number) => void;
65
+ /** Open the drawer. */
66
+ open: () => void;
67
+ /** Close the drawer and return focus to the trigger. */
68
+ close: (reason?: DrawerCloseReason, event?: Event) => void;
69
+ /** Toggle the open state. */
70
+ toggle: () => void;
71
+ /** Called when the open state changes. */
72
+ onOpenChange: (open: boolean) => void;
73
+ };
74
+ export declare function setDrawerContext(ctx: DrawerContext): void;
75
+ export declare function getDrawerContext(): DrawerContext | undefined;
76
+ /**
77
+ * Reads the context or throws with the offending part's name. Every part needs
78
+ * the context to function, so a missing provider is a developer error worth
79
+ * failing loudly on rather than rendering something subtly broken.
80
+ */
81
+ export declare function requireDrawerContext(part: string): DrawerContext;
@@ -0,0 +1,20 @@
1
+ import { setContext, getContext } from 'svelte';
2
+ const DRAWER_CONTEXT_KEY = Symbol('drawer');
3
+ export function setDrawerContext(ctx) {
4
+ setContext(DRAWER_CONTEXT_KEY, ctx);
5
+ }
6
+ export function getDrawerContext() {
7
+ return getContext(DRAWER_CONTEXT_KEY);
8
+ }
9
+ /**
10
+ * Reads the context or throws with the offending part's name. Every part needs
11
+ * the context to function, so a missing provider is a developer error worth
12
+ * failing loudly on rather than rendering something subtly broken.
13
+ */
14
+ export function requireDrawerContext(part) {
15
+ const ctx = getDrawerContext();
16
+ if (!ctx) {
17
+ throw new Error(`${part} must be used inside a Drawer.Root`);
18
+ }
19
+ return ctx;
20
+ }