@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
@@ -6,6 +6,17 @@ import {
6
6
  type NavMenuPopoutContext
7
7
  } from "./NavMenuTypes";
8
8
 
9
+ interface NavMenuProps {
10
+ /** An ID for the root element */
11
+ id?: string;
12
+ /** Class name(s) for the root element */
13
+ class?: string,
14
+ /** An ARIA label for describing the menu to screen readers */
15
+ ariaLabel?: string | undefined,
16
+ /** The orientation of the menu, which affects keyboard navigation */
17
+ orientation?: "horizontal" | "vertical",
18
+ }
19
+
9
20
  /**
10
21
  * A list of links for navigating a website.
11
22
  *
@@ -21,11 +32,9 @@ import {
21
32
  * ...
22
33
  * </NavMenu>
23
34
  * ```
24
- *
25
- * @prop {string | undefined} ariaLabel -- An ARIA label for describing the menu to screen readers
26
- * @prop {"horizontal" | "vertical"} orientation -- The orientation of the menu, which affects keyboard navigation
27
35
  */
28
- export default function NavMenu($props: any) {
36
+ export default function NavMenu($props: NavMenuProps) {
37
+ $props ??= $watch({});
29
38
  $props.orientation ||= "horizontal";
30
39
 
31
40
  // A collection containing the state and some functions for each item
@@ -1,13 +1,20 @@
1
1
  import { NavMenuContextName, type NavMenuContext } from "./NavMenuTypes";
2
2
 
3
+ interface NavMenuButtonProps {
4
+ /** An ID for the root element */
5
+ id?: string;
6
+ /** Class name(s) for the root element */
7
+ class?: string,
8
+ /** Whether this button is disabled */
9
+ disabled?: boolean,
10
+ }
11
+
3
12
  /**
4
13
  * A button that is placed in a NavMenu to carry out a non-navigation action such as logging out.
5
14
  *
6
- * @prop {boolean} disabled -- Whether this button is disabled
7
15
  */
8
- export default function NavMenuButton($props: any) {
9
- /** Set when the item is disabled */
10
- let dataDisabled = $props.disabled || undefined;
16
+ export default function NavMenuButton($props: NavMenuButtonProps) {
17
+ $props ??= $watch({});
11
18
 
12
19
  let button: HTMLButtonElement;
13
20
 
@@ -33,7 +40,7 @@ export default function NavMenuButton($props: any) {
33
40
  {$props.disabled}
34
41
  role="menuitem"
35
42
  aria-disabled={$props.disabled ? "true" : undefined}
36
- data-disabled={dataDisabled}
43
+ data-disabled={$props.disabled ? "true" : undefined}
37
44
  onkeydown
38
45
  onkeydown={handleItemKey}
39
46
  onclick
@@ -1,14 +1,22 @@
1
1
  import { NavMenuContextName, type NavMenuContext } from "./NavMenuTypes";
2
2
 
3
+ interface NavMenuElementProps {
4
+ /** An ID for the root element */
5
+ id?: string;
6
+ /** Class name(s) for the root element */
7
+ class?: string,
8
+ /** Whether this button is disabled */
9
+ disabled?: boolean,
10
+ /** An element that can be focused via keyboard navigation */
11
+ element?: HTMLElement,
12
+ }
13
+
3
14
  /**
4
15
  * An element of any type that can be placed in a NavMenu.
5
16
  *
6
- * @prop {boolean} disabled -- Whether this button is disabled
7
- * @prop {HTMLElement} element -- An element that can be focused via keyboard navigation
8
17
  */
9
- export default function NavMenuElement($props: any) {
10
- /** Set when the item is disabled */
11
- let dataDisabled = $props.disabled || undefined;
18
+ export default function NavMenuElement($props: NavMenuElementProps) {
19
+ $props ??= $watch({});
12
20
 
13
21
  // Get stuff out of the NavMenuContext
14
22
  const menuContext = $context[NavMenuContextName] as NavMenuContext;
@@ -31,7 +39,7 @@ export default function NavMenuElement($props: any) {
31
39
  type="div"
32
40
  role="menuitem"
33
41
  aria-disabled={$props.disabled ? "true" : undefined}
34
- data-disabled={dataDisabled}
42
+ data-disabled={$props.disabled ? "true" : undefined}
35
43
  onkeydown
36
44
  onkeydown={handleItemKey}
37
45
  onclick
@@ -1,11 +1,20 @@
1
1
  import { NavMenuGroupContextName, type NavMenuGroupContext } from "./NavMenuTypes";
2
2
 
3
+ interface NavMenuGroupProps {
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 group to screen readers */
9
+ ariaLabel?: string,
10
+ }
11
+
3
12
  /**
4
13
  * A container for a logical group of navigation menu items.
5
- *
6
- * @prop {string | undefined} ariaLabel -- An ARIA label for describing the group to screen readers
7
14
  */
8
- export default function NavMenuGroup($props: any) {
15
+ export default function NavMenuGroup($props: NavMenuGroupProps) {
16
+ $props ??= $watch({});
17
+
9
18
  let $state = $watch({
10
19
  headerId: ""
11
20
  });
@@ -1,12 +1,20 @@
1
1
  import getId from "../utils/getId";
2
2
  import { NavMenuGroupContextName, type NavMenuGroupContext } from "./NavMenuTypes";
3
3
 
4
+ interface NavMenuGroupHeaderProps {
5
+ /** An ID for the root element */
6
+ id?: string;
7
+ /** Class name(s) for the root element */
8
+ class?: string,
9
+ /** The type of HTML header to use */
10
+ as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6",
11
+ }
12
+
4
13
  /**
5
14
  * The header for a NavMenuGroup.
6
- *
7
- * @prop {"h1" | "h2" | "h3" | "h4" | "h5" | "h6"} as -- The type of HTML header to use
8
15
  */
9
- export default function NavMenuGroupHeader($props: any) {
16
+ export default function NavMenuGroupHeader($props: NavMenuGroupHeaderProps) {
17
+ $props ??= $watch({});
10
18
  $props.id ??= getId();
11
19
 
12
20
  const context = $context[NavMenuGroupContextName] as NavMenuGroupContext;
@@ -19,8 +27,8 @@ export default function NavMenuGroupHeader($props: any) {
19
27
  $state.headerId = $props.id;
20
28
 
21
29
  @render {
30
+ @// TODO: self={$props.as}
22
31
  <h4
23
- @// TODO: self={$props.as}
24
32
  {$props.id}
25
33
  class={`torp-nav-menu-group-header ${$props.class ?? ""}`.trim()}
26
34
  >
@@ -1,19 +1,27 @@
1
1
 
2
2
  import { NavMenuContextName, type NavMenuContext } from "./NavMenuTypes";
3
3
 
4
+ interface NavMenuLinkProps {
5
+ /** An ID for the root element */
6
+ id?: string;
7
+ /** Class name(s) for the root element */
8
+ class?: string,
9
+ /** The URL for the menu link */
10
+ href: string,
11
+ /** Whether the menu link should open in a new tab/window */
12
+ newWindow?: boolean,
13
+ /** Whether this link is disabled */
14
+ disabled?: boolean,
15
+ }
16
+
4
17
  /**
5
18
  * A link that is placed in a NavMenu and signals a response by a user.
6
19
  *
7
- * @prop {string} href -- The URL for the menu link
8
- * @prop {newWindow} boolean -- Whether the menu link should open in a new tab/window
9
- * @prop {boolean} disabled -- Whether this link is disabled
10
20
  */
11
- export default function NavMenuLink($props: any) {
21
+ export default function NavMenuLink($props: NavMenuLinkProps) {
22
+ $props ??= $watch({ href: "#" });
12
23
  $props.newWindow ??= false;
13
24
 
14
- /** Set when the item is disabled */
15
- let dataDisabled = $props.disabled || undefined;
16
-
17
25
  let link: HTMLAnchorElement;
18
26
 
19
27
  // Get stuff out of the NavMenuContext
@@ -39,7 +47,7 @@ export default function NavMenuLink($props: any) {
39
47
  target={$props.newWindow ? "_blank" : undefined}
40
48
  role="menuitem"
41
49
  aria-disabled={$props.disabled ? "true" : undefined}
42
- data-disabled={dataDisabled}
50
+ data-disabled={$props.disabled ? "true" : undefined}
43
51
  onkeydown
44
52
  onkeydown={handleItemKey}
45
53
  onclick
@@ -1,5 +1,14 @@
1
1
  import { NavMenuPopoutContextName, type NavMenuPopoutContext } from "./NavMenuTypes";
2
2
 
3
+ interface NavMenuPopoutProps {
4
+ /** An ID for the root element */
5
+ id?: string;
6
+ /** Class name(s) for the root element */
7
+ class?: string,
8
+ /** Whether the popout is visible */
9
+ visible?: boolean,
10
+ }
11
+
3
12
  /**
4
13
  * A popout that is attached to a menu button and can be used to show a submenu.
5
14
  *
@@ -11,10 +20,9 @@ import { NavMenuPopoutContextName, type NavMenuPopoutContext } from "./NavMenuTy
11
20
  * <NavMenuPopoutContent />
12
21
  * </NavMenuPopout>
13
22
  * ```
14
- *
15
- * @prop {boolean} visible -- Whether the popout is visible
16
23
  */
17
- export default function NavMenuPopout($props: any) {
24
+ export default function NavMenuPopout($props: NavMenuPopoutProps) {
25
+ $props ??= $watch({});
18
26
  $props.visible ??= false;
19
27
 
20
28
  let $state = $watch({
@@ -1,4 +1,3 @@
1
-
2
1
  import {
3
2
  NavMenuContextName,
4
3
  NavMenuPopoutContextName,
@@ -6,18 +5,25 @@ import {
6
5
  type NavMenuPopoutContext,
7
6
  } from "./NavMenuTypes";
8
7
 
8
+ interface NavMenuPopoutButtonProps {
9
+ /** An ID for the root element */
10
+ id?: string;
11
+ /** Class name(s) for the root element */
12
+ class?: string,
13
+ /** The delay before showing the popout, in milliseconds */
14
+ hoverDelay?: number,
15
+ /** Whether this button is disabled */
16
+ disabled?: boolean,
17
+ }
18
+
9
19
  /**
10
20
  * A button that is placed in a NavMenu and signals a response by a user.
11
21
  *
12
- * @prop {number} hoverDelay -- The delay before showing the popout, in milliseconds
13
- * @prop {boolean} disabled -- Whether this button is disabled
14
22
  */
15
- export default function NavMenuPopoutButton($props: any) {
23
+ export default function NavMenuPopoutButton($props: NavMenuPopoutButtonProps) {
24
+ $props ??= $watch({});
16
25
  $props.hoverDelay ??= 500;
17
26
 
18
- /** Set when the item is disabled */
19
- let dataDisabled = $props.disabled || undefined;
20
-
21
27
  let button: HTMLButtonElement;
22
28
  let interval: NodeJS.Timeout | undefined;
23
29
 
@@ -104,7 +110,7 @@ export default function NavMenuPopoutButton($props: any) {
104
110
  aria-haspopup="true"
105
111
  aria-expanded={$state.visible.toString()}
106
112
  aria-disabled={$props.disabled ? "true" : undefined}
107
- data-disabled={dataDisabled}
113
+ data-disabled={$state.disabled ? "true" : undefined}
108
114
  onkeydown={handlePopoutKey}
109
115
  onclick={handleClick}
110
116
  onfocus={() => handleItemFocus(index)}
@@ -3,13 +3,23 @@ import getScrollParent from "../utils/getScrollParent";
3
3
  import setPopoverPosition from "../utils/setPopoverPosition";
4
4
  import { NavMenuPopoutContextName, type NavMenuPopoutContext } from "./NavMenuTypes";
5
5
 
6
+ interface NavMenuPopoutContentProps {
7
+ /** An ID for the root element */
8
+ id?: string;
9
+ /** Class name(s) for the root element */
10
+ class?: string,
11
+ /** Where the popout will be shown, relative to the popout button */
12
+ side?: "top" | "right" | "bottom" | "left",
13
+ /** How the popout will be aligned, relative to the popout button */
14
+ alignment?: "start" | "center" | "end",
15
+ }
16
+
6
17
  /**
7
18
  * The content that is displayed for a NavMenuPopout when it is open.
8
19
  *
9
- * @prop {"top" | "right" | "bottom" | "left"} side -- Where the popout will be shown, relative to the popout button
10
- * @prop {"start" | "center" | "end"} alignment -- How the popout will be aligned, relative to the popout button
11
20
  */
12
- export default function NavMenuPopoutContent($props: any) {
21
+ export default function NavMenuPopoutContent($props: NavMenuPopoutContentProps) {
22
+ $props ??= $watch({});
13
23
  $props.side ??= "bottom";
14
24
  $props.alignment ??= "start";
15
25
 
@@ -1,8 +1,17 @@
1
1
 
2
+ interface NavMenuSeparatorProps {
3
+ /** An ID for the root element */
4
+ id?: string;
5
+ /** Class name(s) for the root element */
6
+ class?: string,
7
+ }
8
+
2
9
  /**
3
10
  * An element in a menu that separates logical sets of menu items.
4
11
  */
5
- export default function NavMenuSeparator($props: any) {
12
+ export default function NavMenuSeparator($props: NavMenuSeparatorProps) {
13
+ $props ??= $watch({});
14
+
6
15
  @render {
7
16
  <div
8
17
  {$props.id}
@@ -1,16 +1,26 @@
1
1
  import { NotificationContextName, type NotificationContext } from "./NotificationTypes";
2
2
 
3
+ interface NotificationProps {
4
+ /** An ID for the root element */
5
+ id?: string;
6
+ /** Class name(s) for the root element */
7
+ class?: string,
8
+ /** Whether the notification is visible */
9
+ visible?: boolean,
10
+ /** The duration, in milliseconds, to keep the notification visible */
11
+ duration?: number,
12
+ /** Raised when the notification has closed, either after the duration has elapsed, or when the user has pressed the close button */
13
+ onclose?: () => void,
14
+ }
15
+
3
16
  /**
4
17
  * An element that displays a brief, important message in a way that attracts
5
18
  * the user's attention without interrupting the user's task.
6
19
  *
7
20
  * See [the WAI ARIA guidelines for Alerts](https://www.w3.org/WAI/ARIA/apg/patterns/alert/).
8
- *
9
- * @prop {boolean} visible -- Whether the notification is visible
10
- * @prop {number | undefined} duration -- The duration, in milliseconds, to keep the notification visible
11
- * @prop {() => void} onclose -- Raised when the notification has closed, either after the duration has elapsed, or when the user has pressed the close button
12
21
  */
13
- export default function Notification($props) {
22
+ export default function Notification($props: NotificationProps) {
23
+ $props ??= $watch({});
14
24
  $props.visible ??= true;
15
25
  $props.duration ??= 5000;
16
26
 
@@ -1,9 +1,18 @@
1
1
  import { NotificationContextName, type NotificationContext } from "./NotificationTypes";
2
2
 
3
+ interface NotificationCloseProps {
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 a user can press to close this Notification.
5
12
  */
6
- export default function NotificationClose() {
13
+ export default function NotificationClose($props: NotificationCloseProps) {
14
+ $props ??= $watch({});
15
+
7
16
  // Get stuff out of the NotificationContext
8
17
  const context = $context[NotificationContextName] as NotificationContext;
9
18
  if (!context) {
@@ -1,8 +1,18 @@
1
+
2
+ interface NotificationContainerProps {
3
+ /** An ID for the root element */
4
+ id?: string;
5
+ /** Class name(s) for the root element */
6
+ class?: string,
7
+ }
8
+
1
9
  /**
2
10
  * The container for one or more Notifications, which can be used to position
3
11
  * the notifications inside the viewport.
4
12
  */
5
- export default function NotificationContainer() {
13
+ export default function NotificationContainer($props: NotificationContainerProps) {
14
+ $props ??= $watch({});
15
+
6
16
  @render {
7
17
  <div
8
18
  {$props.id}
@@ -1,7 +1,17 @@
1
+
2
+ interface NotificationContentProps {
3
+ /** An ID for the root element */
4
+ id?: string;
5
+ /** Class name(s) for the root element */
6
+ class?: string,
7
+ }
8
+
1
9
  /**
2
10
  * The content to display within a Notification.
3
11
  */
4
- export default function NotificationContent() {
12
+ export default function NotificationContent($props: NotificationContentProps) {
13
+ $props ??= $watch({});
14
+
5
15
  @render {
6
16
  <div
7
17
  {$props.id}
@@ -1,5 +1,22 @@
1
1
  import { PopoverContextName, type Point, type PopoverContext, type PopoverState } from "./PopoverTypes";
2
2
 
3
+ interface PopoverProps {
4
+ /** An ID for the root element */
5
+ id?: string;
6
+ /** Class name(s) for the root element */
7
+ class?: string,
8
+ /** 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 */
9
+ modal?: boolean,
10
+ /** Whether the popover is visible */
11
+ visible?: boolean,
12
+ /** The element to anchor this popover to, as an alternative to supplying a PopoverTrigger */
13
+ anchor?: HTMLElement,
14
+ /** The position to display this popover at if it's contextual, as an alternative to supplying a PopoverTriggerContextual */
15
+ position?: Point,
16
+ /** A function to be called when the user selects a response */
17
+ callback?: ((value: any) => void),
18
+ }
19
+
3
20
  /**
4
21
  * A popover that can be used to show rich content or obtain information from a user.
5
22
  *
@@ -14,13 +31,10 @@ import { PopoverContextName, type Point, type PopoverContext, type PopoverState
14
31
  * <PopoverContent/PopoverContentAnchored/PopoverContentContextual />
15
32
  * </Popover>
16
33
  * ```
17
- * @prop {boolean} modal -- 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
18
- * @prop {boolean} visible -- Whether the popover is visible
19
- * @prop {HTMLElement | undefined} anchor -- The element to anchor this popover to, as an alternative to supplying a PopoverTrigger
20
- * @prop {Point | undefined} position -- The position to display this popover at if it's contextual, as an alternative to supplying a PopoverTriggerContextual
21
- * @prop {((value: any) => void) | undefined} [callback] -- A function to be called when the user selects a response
22
34
  */
23
- export default function Popover($props: any) {
35
+ export default function Popover($props: PopoverProps) {
36
+ $props ??= $watch({});
37
+
24
38
  let $state: PopoverState = $watch({
25
39
  visible: false,
26
40
  position: { x: 0, y: 0 }
@@ -1,11 +1,20 @@
1
1
  import { addDocumentEvent, removeDocumentEvent } from "../utils/documentEvents";
2
2
  import { PopoverContextName, type PopoverContext } from "./PopoverTypes";
3
3
 
4
+ interface PopoverContentProps {
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 content that is displayed for a Popover when it is open, such as a Dialog
6
13
  * in the middle of the screen or a div that slides in from the side.
7
14
  */
8
- export default function PopoverContent($props: any) {
15
+ export default function PopoverContent($props: PopoverContentProps) {
16
+ $props ??= $watch({});
17
+
9
18
  let div: HTMLDivElement;
10
19
  let shown = false;
11
20
  let closeOnClick = false;
@@ -3,16 +3,23 @@ import getScrollParent from "../utils/getScrollParent";
3
3
  import setPopoverPosition from "../utils/setPopoverPosition";
4
4
  import { PopoverContextName, type PopoverContext } from "./PopoverTypes";
5
5
 
6
+ interface PopoverContentAnchoredProps {
7
+ /** An ID for the root element */
8
+ id?: string;
9
+ /** Class name(s) for the root element */
10
+ class?: string,
11
+ /** Where the popover will be shown, relative to the popover button */
12
+ side?: "top" | "right" | "bottom" | "left",
13
+ /** How the popover will be aligned, relative to the popover button */
14
+ alignment?: "start" | "center" | "end",
15
+ }
16
+
6
17
  /**
7
18
  * The content that is displayed for a Popover when it is open, displayed
8
19
  * alongside an element.
9
- *
10
- * @prop {"top" | "right" | "bottom" | "left"} site -- Where the popover will be
11
- * shown, relative to the popover button
12
- * @prop {"start" | "center" | "end"} alignment -- How the popover will be
13
- * aligned, relative to the popover button
14
20
  */
15
- export default function PopoverContentAnchored($props: any) {
21
+ export default function PopoverContentAnchored($props: PopoverContentAnchoredProps) {
22
+ $props ??= $watch({});
16
23
  $props.side ??= "bottom";
17
24
  $props.alignment ??= "center";
18
25
 
@@ -4,11 +4,20 @@ import getScrollParent from "../utils/getScrollParent";
4
4
  import setContextPosition from "../utils/setContextPosition";
5
5
  import { PopoverContextName, type PopoverContext } from "./PopoverTypes";
6
6
 
7
+ interface PopoverContentContextualProps {
8
+ /** An ID for the root element */
9
+ id?: string;
10
+ /** Class name(s) for the root element */
11
+ class?: string,
12
+ }
13
+
7
14
  /**
8
15
  * The content that is displayed for a Popover when it is open, displayed at the
9
16
  * position that the user right-clicked.
10
17
  */
11
- export default function PopoverContentContextual($props: any) {
18
+ export default function PopoverContentContextual($props: PopoverContentContextualProps) {
19
+ $props ??= $watch({});
20
+
12
21
  let div: HTMLDivElement;
13
22
  let shown = false;
14
23
  let closeOnClick = false;
@@ -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,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 />