@torpor/ui 0.2.0 → 0.2.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 (213) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/Accordion/Accordion.torp +23 -11
  3. package/dist/Accordion/AccordionContent.torp +13 -6
  4. package/dist/Accordion/AccordionHeader.torp +14 -5
  5. package/dist/Accordion/AccordionItem.torp +22 -8
  6. package/dist/Accordion/AccordionTrigger.torp +14 -6
  7. package/dist/Accordion/AccordionTypes.ts +2 -0
  8. package/dist/Accordion/index.d.ts +100 -35
  9. package/dist/Breadcrumb/Breadcrumb.torp +12 -3
  10. package/dist/Breadcrumb/BreadcrumbItem.torp +12 -3
  11. package/dist/Breadcrumb/BreadcrumbSeparator.torp +10 -1
  12. package/dist/Breadcrumb/index.d.ts +49 -21
  13. package/dist/Calendar/Calendar.torp +9 -1
  14. package/dist/Calendar/CalendarDay.torp +9 -1
  15. package/dist/Calendar/index.d.ts +16 -18
  16. package/dist/Dialog/Dialog.torp +13 -3
  17. package/dist/Dialog/DialogBody.torp +11 -3
  18. package/dist/Dialog/DialogButton.torp +16 -4
  19. package/dist/Dialog/DialogFooter.torp +11 -1
  20. package/dist/Dialog/DialogHeader.torp +11 -2
  21. package/dist/Dialog/index.d.ts +78 -35
  22. package/dist/Disclosure/Disclosure.torp +17 -7
  23. package/dist/Disclosure/DisclosureContent.torp +13 -6
  24. package/dist/Disclosure/DisclosureHeader.torp +14 -5
  25. package/dist/Disclosure/DisclosureTrigger.torp +10 -2
  26. package/dist/Disclosure/index.d.ts +67 -28
  27. package/dist/Drawer/Drawer.torp +11 -1
  28. package/dist/Drawer/index.d.ts +10 -9
  29. package/dist/Form/Field.torp +93 -0
  30. package/dist/Form/Form.torp +131 -0
  31. package/dist/Form/FormTypes.ts +30 -0
  32. package/dist/Form/Input.torp +94 -0
  33. package/dist/Form/Label.torp +31 -0
  34. package/dist/Form/Message.torp +35 -0
  35. package/dist/Form/StandardSchemaV1.ts +70 -0
  36. package/dist/Form/index.d.ts +117 -0
  37. package/dist/Form/index.js +22 -0
  38. package/dist/Form/index.js.map +1 -0
  39. package/dist/Menu/Menu.torp +12 -3
  40. package/dist/Menu/MenuButton.torp +14 -3
  41. package/dist/Menu/MenuCheck.torp +14 -3
  42. package/dist/Menu/MenuGroup.torp +13 -3
  43. package/dist/Menu/MenuIndicator.torp +12 -3
  44. package/dist/Menu/MenuPopout.torp +17 -6
  45. package/dist/Menu/MenuPopoutContent.torp +13 -4
  46. package/dist/Menu/MenuPopoutTrigger.torp +13 -4
  47. package/dist/Menu/MenuRadio.torp +16 -5
  48. package/dist/Menu/MenuRadioGroup.torp +16 -5
  49. package/dist/Menu/MenuSeparator.torp +11 -1
  50. package/dist/Menu/index.d.ts +170 -77
  51. package/dist/MenuBar/MenuBar.torp +13 -4
  52. package/dist/MenuBar/MenuBarItem.torp +17 -6
  53. package/dist/MenuBar/MenuBarItemContent.torp +13 -4
  54. package/dist/MenuBar/MenuBarItemTrigger.torp +11 -2
  55. package/dist/MenuBar/index.d.ts +79 -28
  56. package/dist/NavMenu/NavMenu.torp +13 -4
  57. package/dist/NavMenu/NavMenuButton.torp +12 -5
  58. package/dist/NavMenu/NavMenuElement.torp +14 -6
  59. package/dist/NavMenu/NavMenuGroup.torp +12 -3
  60. package/dist/NavMenu/NavMenuGroupHeader.torp +12 -4
  61. package/dist/NavMenu/NavMenuLink.torp +16 -8
  62. package/dist/NavMenu/NavMenuPopout.torp +11 -3
  63. package/dist/NavMenu/NavMenuPopoutButton.torp +14 -8
  64. package/dist/NavMenu/NavMenuPopoutContent.torp +13 -3
  65. package/dist/NavMenu/NavMenuSeparator.torp +10 -1
  66. package/dist/NavMenu/index.d.ts +147 -70
  67. package/dist/Notification/Notification.torp +15 -5
  68. package/dist/Notification/NotificationClose.torp +10 -1
  69. package/dist/Notification/NotificationContainer.torp +11 -1
  70. package/dist/Notification/NotificationContent.torp +11 -1
  71. package/dist/Notification/index.d.ts +46 -28
  72. package/dist/Popover/Popover.torp +20 -6
  73. package/dist/Popover/PopoverContent.torp +10 -1
  74. package/dist/Popover/PopoverContentAnchored.torp +13 -6
  75. package/dist/Popover/PopoverContentContextual.torp +10 -1
  76. package/dist/Popover/PopoverOverlay.torp +10 -1
  77. package/dist/Popover/PopoverTrigger.torp +10 -1
  78. package/dist/Popover/PopoverTriggerContextual.torp +10 -1
  79. package/dist/Popover/PopoverTriggerHover.torp +11 -2
  80. package/dist/Popover/index.d.ts +101 -56
  81. package/dist/TabGroup/TabContent.torp +11 -5
  82. package/dist/TabGroup/TabGroup.torp +21 -9
  83. package/dist/TabGroup/TabHeader.torp +14 -5
  84. package/dist/TabGroup/TabList.torp +13 -4
  85. package/dist/TabGroup/TabTrigger.torp +12 -4
  86. package/dist/TabGroup/index.d.ts +93 -35
  87. package/dist/icons/ArrowDown.torp +3 -3
  88. package/dist/icons/ArrowLeft.torp +3 -3
  89. package/dist/icons/ArrowRight.torp +3 -3
  90. package/dist/icons/ArrowUp.torp +3 -3
  91. package/dist/icons/Bars.torp +3 -3
  92. package/dist/icons/Check.torp +3 -3
  93. package/dist/icons/ChevronDown.torp +3 -3
  94. package/dist/icons/ChevronLeft.torp +3 -3
  95. package/dist/icons/ChevronRight.torp +3 -3
  96. package/dist/icons/ChevronUp.torp +3 -3
  97. package/dist/icons/Cross.torp +3 -3
  98. package/dist/icons/Loading.torp +3 -3
  99. package/dist/icons/Minus.torp +3 -3
  100. package/dist/icons/Plus.torp +3 -3
  101. package/dist/icons/index.d.ts +14 -126
  102. package/dist/metafile-esm.json +1 -1
  103. package/package.json +13 -4
  104. package/src/Accordion/Accordion.torp +23 -11
  105. package/src/Accordion/AccordionContent.torp +13 -6
  106. package/src/Accordion/AccordionHeader.torp +14 -5
  107. package/src/Accordion/AccordionItem.torp +22 -8
  108. package/src/Accordion/AccordionTrigger.torp +14 -6
  109. package/src/Accordion/AccordionTypes.ts +2 -0
  110. package/src/Breadcrumb/Breadcrumb.torp +12 -3
  111. package/src/Breadcrumb/BreadcrumbItem.torp +12 -3
  112. package/src/Breadcrumb/BreadcrumbSeparator.torp +10 -1
  113. package/src/Calendar/Calendar.torp +9 -1
  114. package/src/Calendar/CalendarDay.torp +9 -1
  115. package/src/Dialog/Dialog.torp +13 -3
  116. package/src/Dialog/DialogBody.torp +11 -3
  117. package/src/Dialog/DialogButton.torp +16 -4
  118. package/src/Dialog/DialogFooter.torp +11 -1
  119. package/src/Dialog/DialogHeader.torp +11 -2
  120. package/src/Disclosure/Disclosure.torp +17 -7
  121. package/src/Disclosure/DisclosureContent.torp +13 -6
  122. package/src/Disclosure/DisclosureHeader.torp +14 -5
  123. package/src/Disclosure/DisclosureTrigger.torp +10 -2
  124. package/src/Drawer/Drawer.torp +11 -1
  125. package/src/Form/Field.torp +93 -0
  126. package/src/Form/Form.torp +131 -0
  127. package/src/Form/FormTypes.ts +30 -0
  128. package/src/Form/Input.torp +94 -0
  129. package/src/Form/Label.torp +31 -0
  130. package/src/Form/Message.torp +35 -0
  131. package/src/Form/StandardSchemaV1.ts +70 -0
  132. package/src/Form/index.ts +7 -0
  133. package/src/Menu/Menu.torp +12 -3
  134. package/src/Menu/MenuButton.torp +14 -3
  135. package/src/Menu/MenuCheck.torp +14 -3
  136. package/src/Menu/MenuGroup.torp +13 -3
  137. package/src/Menu/MenuIndicator.torp +12 -3
  138. package/src/Menu/MenuPopout.torp +17 -6
  139. package/src/Menu/MenuPopoutContent.torp +13 -4
  140. package/src/Menu/MenuPopoutTrigger.torp +13 -4
  141. package/src/Menu/MenuRadio.torp +16 -5
  142. package/src/Menu/MenuRadioGroup.torp +16 -5
  143. package/src/Menu/MenuSeparator.torp +11 -1
  144. package/src/MenuBar/MenuBar.torp +13 -4
  145. package/src/MenuBar/MenuBarItem.torp +17 -6
  146. package/src/MenuBar/MenuBarItemContent.torp +13 -4
  147. package/src/MenuBar/MenuBarItemTrigger.torp +11 -2
  148. package/src/NavMenu/NavMenu.torp +13 -4
  149. package/src/NavMenu/NavMenuButton.torp +12 -5
  150. package/src/NavMenu/NavMenuElement.torp +14 -6
  151. package/src/NavMenu/NavMenuGroup.torp +12 -3
  152. package/src/NavMenu/NavMenuGroupHeader.torp +12 -4
  153. package/src/NavMenu/NavMenuLink.torp +16 -8
  154. package/src/NavMenu/NavMenuPopout.torp +11 -3
  155. package/src/NavMenu/NavMenuPopoutButton.torp +14 -8
  156. package/src/NavMenu/NavMenuPopoutContent.torp +13 -3
  157. package/src/NavMenu/NavMenuSeparator.torp +10 -1
  158. package/src/Notification/Notification.torp +15 -5
  159. package/src/Notification/NotificationClose.torp +10 -1
  160. package/src/Notification/NotificationContainer.torp +11 -1
  161. package/src/Notification/NotificationContent.torp +11 -1
  162. package/src/Popover/Popover.torp +20 -6
  163. package/src/Popover/PopoverContent.torp +10 -1
  164. package/src/Popover/PopoverContentAnchored.torp +13 -6
  165. package/src/Popover/PopoverContentContextual.torp +10 -1
  166. package/src/Popover/PopoverOverlay.torp +10 -1
  167. package/src/Popover/PopoverTrigger.torp +10 -1
  168. package/src/Popover/PopoverTriggerContextual.torp +10 -1
  169. package/src/Popover/PopoverTriggerHover.torp +11 -2
  170. package/src/TabGroup/TabContent.torp +11 -5
  171. package/src/TabGroup/TabGroup.torp +21 -9
  172. package/src/TabGroup/TabHeader.torp +14 -5
  173. package/src/TabGroup/TabList.torp +13 -4
  174. package/src/TabGroup/TabTrigger.torp +12 -4
  175. package/src/icons/ArrowDown.torp +3 -3
  176. package/src/icons/ArrowLeft.torp +3 -3
  177. package/src/icons/ArrowRight.torp +3 -3
  178. package/src/icons/ArrowUp.torp +3 -3
  179. package/src/icons/Bars.torp +3 -3
  180. package/src/icons/Check.torp +3 -3
  181. package/src/icons/ChevronDown.torp +3 -3
  182. package/src/icons/ChevronLeft.torp +3 -3
  183. package/src/icons/ChevronRight.torp +3 -3
  184. package/src/icons/ChevronUp.torp +3 -3
  185. package/src/icons/Cross.torp +3 -3
  186. package/src/icons/Loading.torp +3 -3
  187. package/src/icons/Minus.torp +3 -3
  188. package/src/icons/Plus.torp +3 -3
  189. package/test/Accordion/components/AccordionAccessibility.torp +2 -0
  190. package/test/Accordion/components/AccordionKeyboard.torp +2 -0
  191. package/test/Accordion/components/AccordionList.torp +2 -0
  192. package/test/Accordion/components/AccordionMultiple.torp +2 -0
  193. package/test/Accordion/components/AccordionSingle.torp +2 -0
  194. package/test/Disclosure/accessibility.test.ts +3 -2
  195. package/test/Disclosure/components/DisclosureTest.torp +2 -0
  196. package/test/Disclosure/toggle.test.ts +3 -2
  197. package/test/Form/components/FieldTest.torp +25 -0
  198. package/test/Form/components/FormTest.torp +31 -0
  199. package/test/Form/components/InputTest.torp +9 -0
  200. package/test/Form/field.test.ts +34 -0
  201. package/test/Form/form.test.ts +34 -0
  202. package/test/Form/input.test.ts +19 -0
  203. package/test/Menu/accessibility.test.ts +3 -2
  204. package/test/Menu/basic.test.ts +11 -10
  205. package/test/MenuBar/accessibility.test.ts +3 -2
  206. package/test/MenuBar/basic.test.ts +3 -2
  207. package/test/NavMenu/basic.test.ts +1 -1
  208. package/test/NavMenu/components/{NavMenu.torp → NavMenuBasic.torp} +1 -1
  209. package/test/TabGroup/components/TabGroupAccessibility.torp +2 -0
  210. package/test/TabGroup/components/TabGroupKeyboard.torp +2 -0
  211. package/test/TabGroup/components/TabGroupList.torp +2 -0
  212. package/test/TabGroup/components/TabGroupTrigger.torp +2 -0
  213. package/tsup.config.ts +1 -1
@@ -1,10 +1,19 @@
1
1
  import { disableScroll } from "../mount/disableScroll";
2
2
  import { PopoverContextName, type PopoverContext } from "./PopoverTypes";
3
3
 
4
+ interface PopoverOverlayProps {
5
+ /** An ID for the root element */
6
+ id?: string;
7
+ /** Class name(s) for the root element */
8
+ class?: string,
9
+ }
10
+
4
11
  /**
5
12
  * The background overlay for a Popover. Adding an overlay automatically sets the Popover to modal.
6
13
  */
7
- export default function PopoverOverlay($props: any) {
14
+ export default function PopoverOverlay($props: PopoverOverlayProps) {
15
+ $props ??= $watch({});
16
+
8
17
  // Get stuff out of the PopoverContext
9
18
  const context = $context[PopoverContextName] as PopoverContext;
10
19
  if (!context) {
@@ -1,9 +1,18 @@
1
1
  import { PopoverContextName, type PopoverContext } from "./PopoverTypes";
2
2
 
3
+ interface PopoverTriggerProps {
4
+ /** An ID for the root element */
5
+ id?: string;
6
+ /** Class name(s) for the root element */
7
+ class?: string,
8
+ }
9
+
3
10
  /**
4
11
  * The button that causes a Popover to appear or disappear.
5
12
  */
6
- export default function PopoverTrigger($props: any) {
13
+ export default function PopoverTrigger($props: PopoverTriggerProps) {
14
+ $props ??= $watch({});
15
+
7
16
  // Get stuff out of the PopoverContext
8
17
  const context = $context[PopoverContextName] as PopoverContext;
9
18
  if (!context) {
@@ -1,9 +1,18 @@
1
1
  import { PopoverContextName, type PopoverContext } from "./PopoverTypes";
2
2
 
3
+ interface PopoverTriggerContextualProps {
4
+ /** An ID for the root element */
5
+ id?: string;
6
+ /** Class name(s) for the root element */
7
+ class?: string,
8
+ }
9
+
3
10
  /**
4
11
  * The element that causes a Popover to appear or disappear when right-clicked.
5
12
  */
6
- export default function PopoverTriggerContextual($props: any) {
13
+ export default function PopoverTriggerContextual($props: PopoverTriggerContextualProps) {
14
+ $props ??= $watch({});
15
+
7
16
  // Get stuff out of the PopoverContext
8
17
  const context = $context[PopoverContextName] as PopoverContext;
9
18
  if (!context) {
@@ -2,10 +2,19 @@
2
2
  import { PopoverContextName, type PopoverContext } from "./PopoverTypes";
3
3
  import hoverTrigger from "../mount/hoverTrigger";
4
4
 
5
+ interface PopoverTriggerHoverProps {
6
+ /** An ID for the root element */
7
+ id?: string;
8
+ /** Class name(s) for the root element */
9
+ class?: string,
10
+ }
11
+
5
12
  /**
6
13
  * The div that causes a Popover to appear or disappear when hovered.
7
14
  */
8
- export default function PopoverTriggerHover($props: any) {
15
+ export default function PopoverTriggerHover($props: PopoverTriggerHoverProps) {
16
+ $props ??= $watch({});
17
+
9
18
  // Get stuff out of the PopoverContext
10
19
  const context = $context[PopoverContextName] as PopoverContext;
11
20
  if (!context) {
@@ -13,7 +22,7 @@ export default function PopoverTriggerHover($props: any) {
13
22
  }
14
23
  let $state = context.state;
15
24
 
16
- function handleHover(node, e) {
25
+ function handleHover(node: HTMLElement, e: TouchEvent | MouseEvent) {
17
26
  if ($state.position) {
18
27
  // Get the position relative to the element, so we can reposition on scroll
19
28
  const rect = node.getBoundingClientRect();
@@ -1,144 +1,189 @@
1
1
  import { type SlotRender } from "@torpor/view";
2
2
 
3
3
 
4
+ interface PopoverProps {
5
+ /** An ID for the root element */
6
+ id?: string;
7
+ /** Class name(s) for the root element */
8
+ class?: string,
9
+ /** Whether the popover is modal. If true, an overlay should be supplied to obscure outside content, and only the popover content will be visible to screen readers */
10
+ modal?: boolean,
11
+ /** Whether the popover is visible */
12
+ visible?: boolean,
13
+ /** The element to anchor this popover to, as an alternative to supplying a PopoverTrigger */
14
+ anchor?: HTMLElement,
15
+ /** The position to display this popover at if it's contextual, as an alternative to supplying a PopoverTriggerContextual */
16
+ position?: Point,
17
+ /** A function to be called when the user selects a response */
18
+ callback?: ((value: any) => void),
19
+ }
20
+
4
21
  /**
5
- * Mounts or hydrates the component into the supplied parent node.
6
- * @param $parent -- The parent node.
7
- * @param $anchor -- The node to mount the component before.
8
- * @param $props -- The values that have been passed into the component as properties.
9
- * @param $context -- Values that have been passed into the component from its ancestors.
10
- * @param $slots -- Functions for rendering children into slot nodes within the component.
22
+ * A popover that can be used to show rich content or obtain information from a user.
23
+ *
24
+ * See [the WAI ARIA guidelines for Dialogs](https://www.w3.org/WAI/ARIA/apg/patterns/dialogmodal/).
25
+ *
26
+ * The structure of a Popover is:
27
+ *
28
+ * ```
29
+ * <Popover>
30
+ * <PopoverOverlay /> (optional, if modal)
31
+ * <PopoverTrigger/PopoverTriggerContextual/PopoverTriggerHover /> (optional)
32
+ * <PopoverContent/PopoverContentAnchored/PopoverContentContextual />
33
+ * </Popover>
34
+ * ```
11
35
  */
12
36
  declare function Popover(
13
37
  $parent: ParentNode,
14
38
  $anchor: Node | null,
15
- $props: any,
39
+ $props: PopoverProps,
16
40
  $context?: Record<PropertyKey, any>,
17
41
  $slots?: Record<string, SlotRender>,
18
42
  ): void;
19
43
 
20
44
 
21
45
 
46
+ interface PopoverContentProps {
47
+ /** An ID for the root element */
48
+ id?: string;
49
+ /** Class name(s) for the root element */
50
+ class?: string,
51
+ }
52
+
22
53
  /**
23
- * Mounts or hydrates the component into the supplied parent node.
24
- * @param $parent -- The parent node.
25
- * @param $anchor -- The node to mount the component before.
26
- * @param $props -- The values that have been passed into the component as properties.
27
- * @param $context -- Values that have been passed into the component from its ancestors.
28
- * @param $slots -- Functions for rendering children into slot nodes within the component.
54
+ * The content that is displayed for a Popover when it is open, such as a Dialog
55
+ * in the middle of the screen or a div that slides in from the side.
29
56
  */
30
57
  declare function PopoverContent(
31
58
  $parent: ParentNode,
32
59
  $anchor: Node | null,
33
- $props: any,
60
+ $props: PopoverContentProps,
34
61
  $context?: Record<PropertyKey, any>,
35
62
  $slots?: Record<string, SlotRender>,
36
63
  ): void;
37
64
 
38
65
 
39
66
 
67
+ interface PopoverContentAnchoredProps {
68
+ /** An ID for the root element */
69
+ id?: string;
70
+ /** Class name(s) for the root element */
71
+ class?: string,
72
+ /** Where the popover will be shown, relative to the popover button */
73
+ side?: "top" | "right" | "bottom" | "left",
74
+ /** How the popover will be aligned, relative to the popover button */
75
+ alignment?: "start" | "center" | "end",
76
+ }
77
+
40
78
  /**
41
- * Mounts or hydrates the component into the supplied parent node.
42
- * @param $parent -- The parent node.
43
- * @param $anchor -- The node to mount the component before.
44
- * @param $props -- The values that have been passed into the component as properties.
45
- * @param $context -- Values that have been passed into the component from its ancestors.
46
- * @param $slots -- Functions for rendering children into slot nodes within the component.
79
+ * The content that is displayed for a Popover when it is open, displayed
80
+ * alongside an element.
47
81
  */
48
82
  declare function PopoverContentAnchored(
49
83
  $parent: ParentNode,
50
84
  $anchor: Node | null,
51
- $props: any,
85
+ $props: PopoverContentAnchoredProps,
52
86
  $context?: Record<PropertyKey, any>,
53
87
  $slots?: Record<string, SlotRender>,
54
88
  ): void;
55
89
 
56
90
 
57
91
 
92
+ interface PopoverContentContextualProps {
93
+ /** An ID for the root element */
94
+ id?: string;
95
+ /** Class name(s) for the root element */
96
+ class?: string,
97
+ }
98
+
58
99
  /**
59
- * Mounts or hydrates the component into the supplied parent node.
60
- * @param $parent -- The parent node.
61
- * @param $anchor -- The node to mount the component before.
62
- * @param $props -- The values that have been passed into the component as properties.
63
- * @param $context -- Values that have been passed into the component from its ancestors.
64
- * @param $slots -- Functions for rendering children into slot nodes within the component.
100
+ * The content that is displayed for a Popover when it is open, displayed at the
101
+ * position that the user right-clicked.
65
102
  */
66
103
  declare function PopoverContentContextual(
67
104
  $parent: ParentNode,
68
105
  $anchor: Node | null,
69
- $props: any,
106
+ $props: PopoverContentContextualProps,
70
107
  $context?: Record<PropertyKey, any>,
71
108
  $slots?: Record<string, SlotRender>,
72
109
  ): void;
73
110
 
74
111
 
75
112
 
113
+ interface PopoverOverlayProps {
114
+ /** An ID for the root element */
115
+ id?: string;
116
+ /** Class name(s) for the root element */
117
+ class?: string,
118
+ }
119
+
76
120
  /**
77
- * Mounts or hydrates the component into the supplied parent node.
78
- * @param $parent -- The parent node.
79
- * @param $anchor -- The node to mount the component before.
80
- * @param $props -- The values that have been passed into the component as properties.
81
- * @param $context -- Values that have been passed into the component from its ancestors.
82
- * @param $slots -- Functions for rendering children into slot nodes within the component.
121
+ * The background overlay for a Popover. Adding an overlay automatically sets the Popover to modal.
83
122
  */
84
123
  declare function PopoverOverlay(
85
124
  $parent: ParentNode,
86
125
  $anchor: Node | null,
87
- $props: any,
126
+ $props: PopoverOverlayProps,
88
127
  $context?: Record<PropertyKey, any>,
89
128
  $slots?: Record<string, SlotRender>,
90
129
  ): void;
91
130
 
92
131
 
93
132
 
133
+ interface PopoverTriggerProps {
134
+ /** An ID for the root element */
135
+ id?: string;
136
+ /** Class name(s) for the root element */
137
+ class?: string,
138
+ }
139
+
94
140
  /**
95
- * Mounts or hydrates the component into the supplied parent node.
96
- * @param $parent -- The parent node.
97
- * @param $anchor -- The node to mount the component before.
98
- * @param $props -- The values that have been passed into the component as properties.
99
- * @param $context -- Values that have been passed into the component from its ancestors.
100
- * @param $slots -- Functions for rendering children into slot nodes within the component.
141
+ * The button that causes a Popover to appear or disappear.
101
142
  */
102
143
  declare function PopoverTrigger(
103
144
  $parent: ParentNode,
104
145
  $anchor: Node | null,
105
- $props: any,
146
+ $props: PopoverTriggerProps,
106
147
  $context?: Record<PropertyKey, any>,
107
148
  $slots?: Record<string, SlotRender>,
108
149
  ): void;
109
150
 
110
151
 
111
152
 
153
+ interface PopoverTriggerContextualProps {
154
+ /** An ID for the root element */
155
+ id?: string;
156
+ /** Class name(s) for the root element */
157
+ class?: string,
158
+ }
159
+
112
160
  /**
113
- * Mounts or hydrates the component into the supplied parent node.
114
- * @param $parent -- The parent node.
115
- * @param $anchor -- The node to mount the component before.
116
- * @param $props -- The values that have been passed into the component as properties.
117
- * @param $context -- Values that have been passed into the component from its ancestors.
118
- * @param $slots -- Functions for rendering children into slot nodes within the component.
161
+ * The element that causes a Popover to appear or disappear when right-clicked.
119
162
  */
120
163
  declare function PopoverTriggerContextual(
121
164
  $parent: ParentNode,
122
165
  $anchor: Node | null,
123
- $props: any,
166
+ $props: PopoverTriggerContextualProps,
124
167
  $context?: Record<PropertyKey, any>,
125
168
  $slots?: Record<string, SlotRender>,
126
169
  ): void;
127
170
 
128
171
 
129
172
 
173
+ interface PopoverTriggerHoverProps {
174
+ /** An ID for the root element */
175
+ id?: string;
176
+ /** Class name(s) for the root element */
177
+ class?: string,
178
+ }
179
+
130
180
  /**
131
- * Mounts or hydrates the component into the supplied parent node.
132
- * @param $parent -- The parent node.
133
- * @param $anchor -- The node to mount the component before.
134
- * @param $props -- The values that have been passed into the component as properties.
135
- * @param $context -- Values that have been passed into the component from its ancestors.
136
- * @param $slots -- Functions for rendering children into slot nodes within the component.
181
+ * The div that causes a Popover to appear or disappear when hovered.
137
182
  */
138
183
  declare function PopoverTriggerHover(
139
184
  $parent: ParentNode,
140
185
  $anchor: Node | null,
141
- $props: any,
186
+ $props: PopoverTriggerHoverProps,
142
187
  $context?: Record<PropertyKey, any>,
143
188
  $slots?: Record<string, SlotRender>,
144
189
  ): void;
@@ -1,19 +1,25 @@
1
1
  import getId from "../utils/getId";
2
2
  import { TabGroupContextName, type TabGroupContext } from "./TabGroupTypes";
3
3
 
4
+ interface TabContentProps {
5
+ /** An ID for the root element */
6
+ id?: string;
7
+ /** Class name(s) for the root element */
8
+ class?: string,
9
+ }
10
+
4
11
  /**
5
12
  * Content for a TabGroup, which can be revealed or hidden by an associated TabTrigger.
6
- *
7
- * @prop {string} [id] -- An ID for the TabContent's div container
8
13
  */
9
- export default function TabContent($props: any) {
14
+ export default function TabContent($props: TabContentProps) {
15
+ $props ??= $watch({});
10
16
  $props.id ||= getId();
11
17
 
12
18
  const context = $context[TabGroupContextName] as TabGroupContext;
13
19
  if (!context) {
14
20
  throw new Error("TabContent must be contained within a TabGroup");
15
21
  }
16
- let $state = $context[TabGroupContextName].registerItem($props.index, $props.value);
22
+ let $state = context.registerItem($props.index, $props.value);
17
23
 
18
24
  // Set the content ID so that it can be used with aria-controls in TabTrigger
19
25
  $state.contentId = $props.id;
@@ -26,7 +32,7 @@ export default function TabContent($props: any) {
26
32
  aria-labelledby={$state.headerId}
27
33
  data-orientation={$props.orientation}
28
34
  data-state={$state.dataState}
29
- data-disabled={$state.dataDisabled}
35
+ data-disabled={$state.disabled ? "true" : undefined}
30
36
  >
31
37
  @if ($state.active) {
32
38
  <slot />
@@ -1,5 +1,22 @@
1
1
  import { TabGroupContextName, type TabGroupContext, type ItemState } from "./TabGroupTypes";
2
2
 
3
+ interface TabGroupProps {
4
+ /** An ID for the root element */
5
+ id?: string;
6
+ /** Class name(s) for the root element */
7
+ class?: string,
8
+ /** The orientation of the tab buttons, which affects keyboard navigation */
9
+ orientation?: "horizontal" | "vertical",
10
+ /** How tabs are activated; if automatic they are shown on focus, if manual they must be clicked */
11
+ activation?: "automatic" | "manual",
12
+ /** The value of the active TabContent */
13
+ value?: string | string[],
14
+ /** If set to true, the user cannot interact with any items in the TabGroup */
15
+ disabled?: boolean,
16
+ /** Raised when the active item has changed */
17
+ onchange?: (value: string | string[]) => void
18
+ }
19
+
3
20
  /**
4
21
  * A list of interactive headings coupled with layered sections of content that
5
22
  * enable users to reveal a single section of content at a time.
@@ -18,14 +35,9 @@ import { TabGroupContextName, type TabGroupContext, type ItemState } from "./Tab
18
35
  * <TabContent />
19
36
  * </TabGroup>
20
37
  * ```
21
- *
22
- * @prop {"horizontal" | "vertical"} orientation -- The orientation of the tab buttons, which affects keyboard navigation
23
- * @prop {"automatic" | "manual"} activation -- How tabs are activated; if automatic they are shown on focus, if manual they must be clicked
24
- * @prop {string | string[]} value -- The value of the active TabContent
25
- * @prop {boolean} disabled -- If set to true, the user cannot interact with any items in the TabGroup
26
- * @prop {(value: string | string[]) => void} [onchange] -- Raised when the active item has changed
27
38
  */
28
- export default function TabGroup($props: any) {
39
+ export default function TabGroup($props: TabGroupProps) {
40
+ $props ??= $watch({});
29
41
  $props.orientation ||= "horizontal";
30
42
  $props.activation ||= "automatic";
31
43
  $props.value ||= "";
@@ -63,7 +75,7 @@ export default function TabGroup($props: any) {
63
75
  });
64
76
 
65
77
  $run(() => {
66
- itemStates.forEach((s) => s.parentDisabled = $props.disabled);
78
+ itemStates.forEach((s) => s.parentDisabled = $props.disabled === true);
67
79
  });
68
80
 
69
81
  // Dispatch the change event when the value changes
@@ -74,7 +86,7 @@ export default function TabGroup($props: any) {
74
86
  if (firstChange) {
75
87
  firstChange = false;
76
88
  } else if (ev) {
77
- ev(value);
89
+ ev(value!);
78
90
  }
79
91
  });
80
92
 
@@ -1,5 +1,14 @@
1
1
  import { TabGroupContextName, TabItemContextName, type TabGroupContext, type TabItemContext } from "./TabGroupTypes";
2
2
 
3
+ interface TabHeaderProps {
4
+ /** An ID for the root element */
5
+ id?: string;
6
+ /** Class name(s) for the root element */
7
+ class?: string,
8
+ /** The type of HTML header to use */
9
+ as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6"
10
+ }
11
+
3
12
  /**
4
13
  * The header for a tab item, which contains the TabTrigger.
5
14
  *
@@ -10,15 +19,15 @@ import { TabGroupContextName, TabItemContextName, type TabGroupContext, type Tab
10
19
  * <TabTrigger />
11
20
  * </TabHeader>
12
21
  * ```
13
- *
14
- * @prop {"h1" | "h2" | "h3" | "h4" | "h5" | "h6"} as -- The type of HTML header to use
15
22
  */
16
- export default function TabHeader($props: any) {
23
+ export default function TabHeader($props: TabHeaderProps) {
24
+ $props ??= $watch({});
25
+
17
26
  const context = $context[TabGroupContextName] as TabGroupContext;
18
27
  if (!context) {
19
28
  throw new Error("TabHeader must be contained within a TabGroup");
20
29
  }
21
- let $state = $context[TabGroupContextName].registerHeader($props.index, $props.value);
30
+ let $state = context.registerHeader($props.index, $props.value);
22
31
 
23
32
  const itemContext: TabItemContext = {
24
33
  triggerItem: context.triggerItem,
@@ -44,7 +53,7 @@ export default function TabHeader($props: any) {
44
53
  $state.orientation
45
54
  ]}
46
55
  data-state={$state.dataState}
47
- data-disabled={$state.dataDisabled}
56
+ data-disabled={$state.disabled ? "true" : undefined}
48
57
  >
49
58
  <slot />
50
59
  </h4>
@@ -1,4 +1,13 @@
1
- import { TabGroupContextName, TabItemContextName, type TabGroupContext, type TabItemContext } from "./TabGroupTypes";
1
+ import { TabGroupContextName, type TabGroupContext } from "./TabGroupTypes";
2
+
3
+ interface TabListProps {
4
+ /** An ID for the root element */
5
+ id?: string;
6
+ /** Class name(s) for the root element */
7
+ class?: string,
8
+ /** An ARIA label for describing the tab list to screen readers */
9
+ ariaLabel?: string,
10
+ }
2
11
 
3
12
  /**
4
13
  * A component that holds the TabHeaders of a TabGroup.
@@ -12,10 +21,10 @@ import { TabGroupContextName, TabItemContextName, type TabGroupContext, type Tab
12
21
  * </TabHeader>
13
22
  * </TabList>
14
23
  * ```
15
- *
16
- * @prop {string} ariaLabel -- An ARIA label for describing the tab list to screen readers
17
24
  */
18
- export default function TabList($props: any) {
25
+ export default function TabList($props: TabListProps) {
26
+ $props ??= $watch({});
27
+
19
28
  // Get stuff out of the TabGroupContext
20
29
  const context = $context[TabGroupContextName] as TabGroupContext;
21
30
  if (!context) {
@@ -1,20 +1,28 @@
1
1
  import getId from "../utils/getId";
2
2
  import { TabItemContextName, type TabItemContext } from "./TabGroupTypes";
3
3
 
4
+ interface TabTriggerProps {
5
+ /** An ID for the root element */
6
+ id?: string;
7
+ /** Class name(s) for the root element */
8
+ class?: string,
9
+ }
10
+
4
11
  /**
5
12
  * A header button for a tab item, which can be used to reveal an associated TabContent.
6
13
  */
7
- export default function TabTrigger() {
8
- let button: HTMLButtonElement;
9
-
14
+ export default function TabTrigger($props: TabTriggerProps) {
15
+ $props ??= $watch({});
10
16
  $props.id ||= getId();
11
17
 
18
+ let button: HTMLButtonElement;
19
+
12
20
  // Get stuff out of the TabItemContext
13
21
  const context = $context[TabItemContextName] as TabItemContext;
14
22
  if (!context) {
15
23
  throw new Error("TabTrigger must be contained within a TabHeader");
16
24
  }
17
- let $state = $context[TabItemContextName].state;
25
+ let $state = context.state;
18
26
 
19
27
  // Set the header ID so that it can be used with aria-labelledby in TabContent
20
28
  $state.headerId = $props.id;