@canonical/svelte-ds-app-launchpad 0.23.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/dist/components/Badge/Badge.svelte +1 -1
  2. package/dist/components/Badge/Badge.svelte.d.ts +1 -1
  3. package/dist/components/Badge/index.d.ts +1 -1
  4. package/dist/components/Breadcrumbs/Breadcrumbs.svelte +1 -1
  5. package/dist/components/Breadcrumbs/Breadcrumbs.svelte.d.ts +1 -1
  6. package/dist/components/Breadcrumbs/index.d.ts +1 -1
  7. package/dist/components/Button/Button.svelte +20 -20
  8. package/dist/components/Button/Button.svelte.d.ts +1 -1
  9. package/dist/components/Button/common/Content/Content.svelte +14 -14
  10. package/dist/components/Button/common/Content/Content.svelte.d.ts +1 -1
  11. package/dist/components/Button/common/Content/index.d.ts +1 -1
  12. package/dist/components/Button/index.d.ts +1 -1
  13. package/dist/components/Button/styles.css +1 -1
  14. package/dist/components/Button/types.d.ts +1 -1
  15. package/dist/components/Chip/Chip.svelte +1 -1
  16. package/dist/components/Chip/Chip.svelte.d.ts +1 -1
  17. package/dist/components/Chip/index.d.ts +1 -1
  18. package/dist/components/Link/Link.svelte +1 -1
  19. package/dist/components/Link/Link.svelte.d.ts +1 -1
  20. package/dist/components/Link/index.d.ts +1 -1
  21. package/dist/components/Modal/Modal.svelte +134 -0
  22. package/dist/components/Modal/Modal.svelte.d.ts +58 -0
  23. package/dist/components/Modal/index.d.ts +72 -0
  24. package/dist/components/Modal/index.js +7 -0
  25. package/dist/components/Modal/styles.css +39 -0
  26. package/dist/components/Modal/types.d.ts +41 -0
  27. package/dist/components/Modal/types.js +2 -0
  28. package/dist/components/Popover/index.d.ts +1 -1
  29. package/dist/components/Spinner/Spinner.svelte +5 -5
  30. package/dist/components/Spinner/Spinner.svelte.d.ts +1 -1
  31. package/dist/components/Spinner/index.d.ts +1 -1
  32. package/dist/components/common/ButtonPrimitive/ButtonPrimitive.svelte +1 -1
  33. package/dist/components/common/ButtonPrimitive/ButtonPrimitive.svelte.d.ts +1 -1
  34. package/dist/components/common/ButtonPrimitive/index.d.ts +1 -1
  35. package/dist/components/common/DialogContent/DialogContent.svelte +35 -0
  36. package/dist/components/common/DialogContent/DialogContent.svelte.d.ts +24 -0
  37. package/dist/components/common/DialogContent/common/Body/Body.svelte +14 -0
  38. package/dist/components/common/DialogContent/common/Body/Body.svelte.d.ts +4 -0
  39. package/dist/components/common/DialogContent/common/Body/index.d.ts +2 -0
  40. package/dist/components/common/DialogContent/common/Body/index.js +2 -0
  41. package/dist/components/common/DialogContent/common/Body/styles.css +5 -0
  42. package/dist/components/common/DialogContent/common/Body/types.d.ts +2 -0
  43. package/dist/components/common/DialogContent/common/Body/types.js +2 -0
  44. package/dist/components/common/DialogContent/common/Footer/Footer.svelte +14 -0
  45. package/dist/components/common/DialogContent/common/Footer/Footer.svelte.d.ts +4 -0
  46. package/dist/components/common/DialogContent/common/Footer/index.d.ts +2 -0
  47. package/dist/components/common/DialogContent/common/Footer/index.js +2 -0
  48. package/dist/components/common/DialogContent/common/Footer/styles.css +8 -0
  49. package/dist/components/common/DialogContent/common/Footer/types.d.ts +2 -0
  50. package/dist/components/common/DialogContent/common/Footer/types.js +2 -0
  51. package/dist/components/common/DialogContent/common/Header/Header.svelte +14 -0
  52. package/dist/components/common/DialogContent/common/Header/Header.svelte.d.ts +4 -0
  53. package/dist/components/common/DialogContent/common/Header/common/CloseButton/CloseButton.svelte +28 -0
  54. package/dist/components/common/DialogContent/common/Header/common/CloseButton/CloseButton.svelte.d.ts +4 -0
  55. package/dist/components/common/DialogContent/common/Header/common/CloseButton/index.d.ts +2 -0
  56. package/dist/components/common/DialogContent/common/Header/common/CloseButton/index.js +2 -0
  57. package/dist/components/common/DialogContent/common/Header/common/CloseButton/types.d.ts +4 -0
  58. package/dist/components/common/DialogContent/common/Header/common/CloseButton/types.js +2 -0
  59. package/dist/components/common/DialogContent/common/Header/common/index.d.ts +1 -0
  60. package/dist/components/common/DialogContent/common/Header/common/index.js +1 -0
  61. package/dist/components/common/DialogContent/common/Header/index.d.ts +16 -0
  62. package/dist/components/common/DialogContent/common/Header/index.js +6 -0
  63. package/dist/components/common/DialogContent/common/Header/styles.css +12 -0
  64. package/dist/components/common/DialogContent/common/Header/types.d.ts +2 -0
  65. package/dist/components/common/DialogContent/common/Header/types.js +2 -0
  66. package/dist/components/common/DialogContent/common/index.d.ts +3 -0
  67. package/dist/components/common/DialogContent/common/index.js +3 -0
  68. package/dist/components/common/DialogContent/index.d.ts +42 -0
  69. package/dist/components/common/DialogContent/index.js +8 -0
  70. package/dist/components/common/DialogContent/styles.css +11 -0
  71. package/dist/components/common/DialogContent/types.d.ts +2 -0
  72. package/dist/components/common/DialogContent/types.js +2 -0
  73. package/dist/components/common/index.d.ts +1 -0
  74. package/dist/components/common/index.js +1 -0
  75. package/dist/components/index.d.ts +1 -0
  76. package/dist/components/index.js +1 -0
  77. package/dist/utils/index.d.ts +1 -0
  78. package/dist/utils/index.js +1 -0
  79. package/dist/utils/isEventTargetInElement.d.ts +8 -0
  80. package/dist/utils/isEventTargetInElement.js +13 -0
  81. package/package.json +13 -10
  82. package/dist/components/Badge/Badge.ssr.test.d.ts +0 -1
  83. package/dist/components/Badge/Badge.ssr.test.js +0 -113
  84. package/dist/components/Badge/Badge.stories.svelte +0 -60
  85. package/dist/components/Badge/Badge.stories.svelte.d.ts +0 -19
  86. package/dist/components/Badge/Badge.svelte.test.d.ts +0 -1
  87. package/dist/components/Badge/Badge.svelte.test.js +0 -120
  88. package/dist/components/Breadcrumbs/Breadcrumbs.ssr.test.d.ts +0 -1
  89. package/dist/components/Breadcrumbs/Breadcrumbs.ssr.test.js +0 -101
  90. package/dist/components/Breadcrumbs/Breadcrumbs.stories.svelte +0 -139
  91. package/dist/components/Breadcrumbs/Breadcrumbs.stories.svelte.d.ts +0 -19
  92. package/dist/components/Breadcrumbs/Breadcrumbs.svelte.test.d.ts +0 -1
  93. package/dist/components/Breadcrumbs/Breadcrumbs.svelte.test.js +0 -298
  94. package/dist/components/Button/Button.ssr.test.d.ts +0 -1
  95. package/dist/components/Button/Button.ssr.test.js +0 -88
  96. package/dist/components/Button/Button.stories.svelte +0 -143
  97. package/dist/components/Button/Button.stories.svelte.d.ts +0 -19
  98. package/dist/components/Button/Button.svelte.test.d.ts +0 -1
  99. package/dist/components/Button/Button.svelte.test.js +0 -136
  100. package/dist/components/Checkbox/Checkbox.ssr.test.d.ts +0 -1
  101. package/dist/components/Checkbox/Checkbox.ssr.test.js +0 -74
  102. package/dist/components/Checkbox/Checkbox.stories.svelte +0 -105
  103. package/dist/components/Checkbox/Checkbox.stories.svelte.d.ts +0 -19
  104. package/dist/components/Checkbox/Checkbox.svelte.test.d.ts +0 -1
  105. package/dist/components/Checkbox/Checkbox.svelte.test.js +0 -115
  106. package/dist/components/Chip/Chip.ssr.test.d.ts +0 -1
  107. package/dist/components/Chip/Chip.ssr.test.js +0 -65
  108. package/dist/components/Chip/Chip.stories.svelte +0 -124
  109. package/dist/components/Chip/Chip.stories.svelte.d.ts +0 -19
  110. package/dist/components/Chip/Chip.svelte.test.d.ts +0 -1
  111. package/dist/components/Chip/Chip.svelte.test.js +0 -132
  112. package/dist/components/DateTime/DateTime.ssr.test.d.ts +0 -1
  113. package/dist/components/DateTime/DateTime.ssr.test.js +0 -94
  114. package/dist/components/DateTime/DateTime.stories.svelte +0 -34
  115. package/dist/components/DateTime/DateTime.stories.svelte.d.ts +0 -19
  116. package/dist/components/DateTime/DateTime.svelte.test.d.ts +0 -1
  117. package/dist/components/DateTime/DateTime.svelte.test.js +0 -81
  118. package/dist/components/DescriptionList/DescriptionList.ssr.test.d.ts +0 -1
  119. package/dist/components/DescriptionList/DescriptionList.ssr.test.js +0 -50
  120. package/dist/components/DescriptionList/DescriptionList.stories.svelte +0 -40
  121. package/dist/components/DescriptionList/DescriptionList.stories.svelte.d.ts +0 -19
  122. package/dist/components/DescriptionList/DescriptionList.svelte.test.d.ts +0 -1
  123. package/dist/components/DescriptionList/DescriptionList.svelte.test.js +0 -45
  124. package/dist/components/DescriptionList/common/Item/Item.ssr.test.d.ts +0 -1
  125. package/dist/components/DescriptionList/common/Item/Item.ssr.test.js +0 -66
  126. package/dist/components/DescriptionList/common/Item/Item.stories.svelte +0 -34
  127. package/dist/components/DescriptionList/common/Item/Item.stories.svelte.d.ts +0 -19
  128. package/dist/components/DescriptionList/common/Item/Item.svelte.test.d.ts +0 -1
  129. package/dist/components/DescriptionList/common/Item/Item.svelte.test.js +0 -62
  130. package/dist/components/Link/Link.ssr.test.d.ts +0 -1
  131. package/dist/components/Link/Link.ssr.test.js +0 -59
  132. package/dist/components/Link/Link.stories.svelte +0 -18
  133. package/dist/components/Link/Link.stories.svelte.d.ts +0 -19
  134. package/dist/components/Link/Link.svelte.test.d.ts +0 -1
  135. package/dist/components/Link/Link.svelte.test.js +0 -56
  136. package/dist/components/NumberInput/NumberInput.ssr.test.d.ts +0 -1
  137. package/dist/components/NumberInput/NumberInput.ssr.test.js +0 -84
  138. package/dist/components/NumberInput/NumberInput.stories.svelte +0 -67
  139. package/dist/components/NumberInput/NumberInput.stories.svelte.d.ts +0 -4
  140. package/dist/components/NumberInput/NumberInput.svelte.test.d.ts +0 -1
  141. package/dist/components/NumberInput/NumberInput.svelte.test.js +0 -96
  142. package/dist/components/Popover/Popover.ssr.test.d.ts +0 -1
  143. package/dist/components/Popover/Popover.ssr.test.js +0 -70
  144. package/dist/components/Popover/Popover.stories.svelte +0 -170
  145. package/dist/components/Popover/Popover.stories.svelte.d.ts +0 -4
  146. package/dist/components/Popover/Popover.svelte.test.d.ts +0 -1
  147. package/dist/components/Popover/Popover.svelte.test.js +0 -137
  148. package/dist/components/Popover/test.fixtures.svelte +0 -24
  149. package/dist/components/Popover/test.fixtures.svelte.d.ts +0 -25
  150. package/dist/components/Radio/Radio.ssr.test.d.ts +0 -1
  151. package/dist/components/Radio/Radio.ssr.test.js +0 -75
  152. package/dist/components/Radio/Radio.stories.svelte +0 -93
  153. package/dist/components/Radio/Radio.stories.svelte.d.ts +0 -19
  154. package/dist/components/Radio/Radio.svelte.test.d.ts +0 -1
  155. package/dist/components/Radio/Radio.svelte.test.js +0 -100
  156. package/dist/components/RelativeDateTime/RelativeDateTime.ssr.test.d.ts +0 -1
  157. package/dist/components/RelativeDateTime/RelativeDateTime.ssr.test.js +0 -130
  158. package/dist/components/RelativeDateTime/RelativeDateTime.stories.svelte +0 -41
  159. package/dist/components/RelativeDateTime/RelativeDateTime.stories.svelte.d.ts +0 -19
  160. package/dist/components/RelativeDateTime/RelativeDateTime.svelte.test.d.ts +0 -1
  161. package/dist/components/RelativeDateTime/RelativeDateTime.svelte.test.js +0 -152
  162. package/dist/components/RelativeDateTime/utils/getOptimalRelativeTimeFormatValue.test.d.ts +0 -1
  163. package/dist/components/RelativeDateTime/utils/getOptimalRelativeTimeFormatValue.test.js +0 -65
  164. package/dist/components/Spinner/Spinner.ssr.test.d.ts +0 -1
  165. package/dist/components/Spinner/Spinner.ssr.test.js +0 -29
  166. package/dist/components/Spinner/Spinner.stories.svelte +0 -16
  167. package/dist/components/Spinner/Spinner.stories.svelte.d.ts +0 -19
  168. package/dist/components/Spinner/Spinner.svelte.test.d.ts +0 -1
  169. package/dist/components/Spinner/Spinner.svelte.test.js +0 -25
  170. package/dist/components/Switch/Switch.ssr.test.d.ts +0 -1
  171. package/dist/components/Switch/Switch.ssr.test.js +0 -98
  172. package/dist/components/Switch/Switch.stories.svelte +0 -93
  173. package/dist/components/Switch/Switch.stories.svelte.d.ts +0 -19
  174. package/dist/components/Switch/Switch.svelte.test.d.ts +0 -1
  175. package/dist/components/Switch/Switch.svelte.test.js +0 -143
  176. package/dist/components/TextInput/TextInput.ssr.test.d.ts +0 -1
  177. package/dist/components/TextInput/TextInput.ssr.test.js +0 -90
  178. package/dist/components/TextInput/TextInput.stories.svelte +0 -96
  179. package/dist/components/TextInput/TextInput.stories.svelte.d.ts +0 -4
  180. package/dist/components/TextInput/TextInput.svelte.test.d.ts +0 -1
  181. package/dist/components/TextInput/TextInput.svelte.test.js +0 -118
  182. package/dist/components/Textarea/Textarea.ssr.test.d.ts +0 -1
  183. package/dist/components/Textarea/Textarea.ssr.test.js +0 -49
  184. package/dist/components/Textarea/Textarea.stories.svelte +0 -58
  185. package/dist/components/Textarea/Textarea.stories.svelte.d.ts +0 -19
  186. package/dist/components/Textarea/Textarea.svelte.test.d.ts +0 -1
  187. package/dist/components/Textarea/Textarea.svelte.test.js +0 -90
  188. package/dist/components/Textarea/utils/calculateDynamicRows.svelte.test.d.ts +0 -1
  189. package/dist/components/Textarea/utils/calculateDynamicRows.svelte.test.js +0 -148
  190. package/dist/components/common/ButtonPrimitive/ButtonPrimitive.ssr.test.d.ts +0 -1
  191. package/dist/components/common/ButtonPrimitive/ButtonPrimitive.ssr.test.js +0 -71
  192. package/dist/components/common/ButtonPrimitive/ButtonPrimitive.svelte.test.d.ts +0 -1
  193. package/dist/components/common/ButtonPrimitive/ButtonPrimitive.svelte.test.js +0 -75
  194. package/dist/components/common/InputPrimitive/InputPrimitive.ssr.test.d.ts +0 -1
  195. package/dist/components/common/InputPrimitive/InputPrimitive.ssr.test.js +0 -100
  196. package/dist/components/common/InputPrimitive/InputPrimitive.svelte.test.d.ts +0 -1
  197. package/dist/components/common/InputPrimitive/InputPrimitive.svelte.test.js +0 -91
  198. package/dist/test-utils.d.ts +0 -6
  199. package/dist/test-utils.js +0 -18
@@ -10,7 +10,7 @@
10
10
  </script>
11
11
 
12
12
  <script lang="ts">
13
- import type { BadgeProps } from "./types";
13
+ import type { BadgeProps } from "./types.js";
14
14
  import "./styles.css";
15
15
 
16
16
  const componentCssClassName = "ds badge";
@@ -1,4 +1,4 @@
1
- import type { BadgeProps } from "./types";
1
+ import type { BadgeProps } from "./types.js";
2
2
  import "./styles.css";
3
3
  /**
4
4
  * `Badge` is a visual indicator for numeric values. It is static and not interactive.
@@ -1,2 +1,2 @@
1
1
  export { default as Badge } from "./Badge.svelte";
2
- export type { BadgeProps } from "./types";
2
+ export type { BadgeProps } from "./types.js";
@@ -2,7 +2,7 @@
2
2
 
3
3
  <script lang="ts">
4
4
  import { CollapsedItems, ExpandedItems } from "./common/index.js";
5
- import type { BreadcrumbsProps, PossiblyCollapsedSegment } from "./types";
5
+ import type { BreadcrumbsProps, PossiblyCollapsedSegment } from "./types.js";
6
6
  import "./styles.css";
7
7
 
8
8
  const componentCssClassName = "ds breadcrumbs";
@@ -1,4 +1,4 @@
1
- import type { BreadcrumbsProps } from "./types";
1
+ import type { BreadcrumbsProps } from "./types.js";
2
2
  import "./styles.css";
3
3
  /**
4
4
  * `Breadcrumbs` is a navigation component used to display the current page's location within a navigational hierarchy. It allows users to easily navigate back to previous pages or sections.
@@ -1,2 +1,2 @@
1
1
  export { default as Breadcrumbs } from "./Breadcrumbs.svelte";
2
- export type { BreadcrumbsProps, Segment } from "./types";
2
+ export type { BreadcrumbsProps, Segment } from "./types.js";
@@ -1,8 +1,8 @@
1
1
  <script lang="ts">
2
2
  import { ButtonPrimitive } from "../common/ButtonPrimitive/index.js";
3
3
  import { Spinner } from "../Spinner/index.js";
4
- import { Content } from "./common/Content";
5
- import type { ButtonProps } from "./types";
4
+ import { Content } from "./common/Content/index.js";
5
+ import type { ButtonProps } from "./types.js";
6
6
  import "./styles.css";
7
7
 
8
8
  const componentCssClassName = "ds button";
@@ -24,25 +24,25 @@
24
24
  </script>
25
25
 
26
26
  <ButtonPrimitive
27
- bind:ref
28
- class={[
29
- componentCssClassName,
30
- className,
31
- severity,
32
- density,
33
- { loading, "explicit-disabled": disabled },
34
- ]}
35
- disabled={isDisabled}
36
- {...rest}
27
+ bind:ref
28
+ class={[
29
+ componentCssClassName,
30
+ className,
31
+ severity,
32
+ density,
33
+ { loading, "explicit-disabled": disabled },
34
+ ]}
35
+ disabled={isDisabled}
36
+ {...rest}
37
37
  >
38
- <Content {iconLeft} {iconRight}>
39
- {@render children?.()}
40
- </Content>
41
- {#if loading}
42
- <span class="loader">
43
- <Spinner />
44
- </span>
45
- {/if}
38
+ <Content {iconLeft} {iconRight}>
39
+ {@render children?.()}
40
+ </Content>
41
+ {#if loading}
42
+ <span class="loader">
43
+ <Spinner />
44
+ </span>
45
+ {/if}
46
46
  </ButtonPrimitive>
47
47
 
48
48
  <!-- @component
@@ -1,4 +1,4 @@
1
- import type { ButtonProps } from "./types";
1
+ import type { ButtonProps } from "./types.js";
2
2
  import "./styles.css";
3
3
  /**
4
4
  * `Button` is a styled button element.
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import type { ContentProps } from "./types";
2
+ import type { ContentProps } from "./types.js";
3
3
  import "./styles.css";
4
4
 
5
5
  const componentCssClassName = "ds button-content";
@@ -14,17 +14,17 @@
14
14
  </script>
15
15
 
16
16
  <div class={[componentCssClassName, className]} {...rest}>
17
- {#if iconLeft}
18
- <span class="icon left">
19
- {@render iconLeft()}
20
- </span>
21
- {/if}
22
- <span class="text">
23
- {@render children?.()}
24
- </span>
25
- {#if iconRight}
26
- <span class="icon right">
27
- {@render iconRight()}
28
- </span>
29
- {/if}
17
+ {#if iconLeft}
18
+ <span class="icon left">
19
+ {@render iconLeft()}
20
+ </span>
21
+ {/if}
22
+ <span class="text">
23
+ {@render children?.()}
24
+ </span>
25
+ {#if iconRight}
26
+ <span class="icon right">
27
+ {@render iconRight()}
28
+ </span>
29
+ {/if}
30
30
  </div>
@@ -1,4 +1,4 @@
1
- import type { ContentProps } from "./types";
1
+ import type { ContentProps } from "./types.js";
2
2
  import "./styles.css";
3
3
  declare const Content: import("svelte").Component<ContentProps, {}, "">;
4
4
  type Content = ReturnType<typeof Content>;
@@ -1,2 +1,2 @@
1
1
  export { default as Content } from "./Content.svelte";
2
- export type { ContentProps } from "./types";
2
+ export type { ContentProps } from "./types.js";
@@ -1,2 +1,2 @@
1
1
  export { default as Button } from "./Button.svelte";
2
- export type { ButtonProps } from "./types";
2
+ export type { ButtonProps } from "./types.js";
@@ -1,4 +1,4 @@
1
- .ds.button {
1
+ .ds.button.button-primitive {
2
2
  --color-background-button-active: var(
3
3
  --lp-color-background-active-context,
4
4
  var(--lp-color-background-neutral-active)
@@ -1,6 +1,6 @@
1
1
  import type { Snippet } from "svelte";
2
2
  import type { ModifierFamilyValues } from "../../modifier-families/index.js";
3
- import type { ButtonPrimitiveProps } from "../common/ButtonPrimitive";
3
+ import type { ButtonPrimitiveProps } from "../common/ButtonPrimitive/index.js";
4
4
  export type ButtonProps = ButtonPrimitiveProps & {
5
5
  iconLeft?: Snippet;
6
6
  iconRight?: Snippet;
@@ -2,7 +2,7 @@
2
2
 
3
3
  <script lang="ts">
4
4
  import { CloseIcon } from "@canonical/svelte-icons";
5
- import type { ChipProps } from "./types";
5
+ import type { ChipProps } from "./types.js";
6
6
  import "./styles.css";
7
7
 
8
8
  const componentCssClassName = "ds chip";
@@ -1,4 +1,4 @@
1
- import type { ChipProps } from "./types";
1
+ import type { ChipProps } from "./types.js";
2
2
  import "./styles.css";
3
3
  /**
4
4
  * `Chip` displays a small actionable pieces of information.
@@ -1,2 +1,2 @@
1
1
  export { default as Chip } from "./Chip.svelte";
2
- export type { ChipProps } from "./types";
2
+ export type { ChipProps } from "./types.js";
@@ -1,7 +1,7 @@
1
1
  <!-- Generated by @canonical/summon:component-svelte v0.1.0 -->
2
2
 
3
3
  <script lang="ts">
4
- import type { LinkProps } from "./types";
4
+ import type { LinkProps } from "./types.js";
5
5
  import "./styles.css";
6
6
 
7
7
  const componentCssClassName = "ds link";
@@ -1,4 +1,4 @@
1
- import type { LinkProps } from "./types";
1
+ import type { LinkProps } from "./types.js";
2
2
  import "./styles.css";
3
3
  /**
4
4
  * `Link` is a styled anchor element.
@@ -1,2 +1,2 @@
1
1
  export { default as Link } from "./Link.svelte";
2
- export type { LinkProps } from "./types";
2
+ export type { LinkProps } from "./types.js";
@@ -0,0 +1,134 @@
1
+ <!-- @canonical/generator-ds 0.10.0-experimental.2 -->
2
+
3
+ <script lang="ts">
4
+ import { useIsMounted } from "../../useFunctions/index.js";
5
+ import { isEventTargetInElement } from "../../utils/index.js";
6
+ import type { ModalMethods, ModalProps } from "./types.js";
7
+ import "./styles.css";
8
+
9
+ const componentCssClassName = "ds modal";
10
+
11
+ let {
12
+ id: idProp,
13
+ class: className,
14
+ trigger,
15
+ children,
16
+ closeOnOutsideClick = true,
17
+ onclick,
18
+ ...rest
19
+ }: ModalProps = $props();
20
+
21
+ let dialogRef = $state<HTMLDialogElement>();
22
+
23
+ const fallbackId = $props.id();
24
+ const id = $derived(idProp || fallbackId);
25
+
26
+ const isMounted = useIsMounted();
27
+
28
+ export const showModal: ModalMethods["showModal"] = () => {
29
+ dialogRef?.showModal();
30
+ };
31
+
32
+ export const close: ModalMethods["close"] = () => {
33
+ dialogRef?.close();
34
+ };
35
+
36
+ // Webkit doesn't support `closedby` attribute on dialog elements (https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/closedBy).
37
+ // TODO(closedby): Remove this fallback when Webkit supports it.
38
+ let contentWrapperRef = $state<HTMLElement>();
39
+
40
+ const isClosedByFallbackNeeded = $derived(
41
+ isMounted.value && !("closedBy" in HTMLDialogElement.prototype),
42
+ );
43
+
44
+ // TODO(Invoker Commands API): Remove this when Invoker Commands API is widely supported (https://caniuse.com/wf-invoker-commands)
45
+ const isInvokerCommandsFallbackNeeded = $derived(
46
+ isMounted.value &&
47
+ (!("commandForElement" in HTMLButtonElement.prototype) ||
48
+ !("command" in HTMLButtonElement.prototype)),
49
+ );
50
+
51
+ const fallbackOnclick: typeof onclick = (e) => {
52
+ onclick?.(e);
53
+ if (
54
+ closeOnOutsideClick &&
55
+ contentWrapperRef &&
56
+ !isEventTargetInElement(e.target, contentWrapperRef)
57
+ ) {
58
+ close();
59
+ }
60
+ };
61
+ </script>
62
+
63
+ {@render trigger?.({
64
+ onclick: isInvokerCommandsFallbackNeeded ? showModal : undefined,
65
+ commandfor: id,
66
+ command: "show-modal",
67
+ "aria-haspopup": "dialog",
68
+ })}
69
+
70
+ <dialog
71
+ bind:this={dialogRef}
72
+ {id}
73
+ class={[componentCssClassName, className]}
74
+ closedby={closeOnOutsideClick ? "any" : "closerequest"}
75
+ onclick={isClosedByFallbackNeeded ? fallbackOnclick : onclick}
76
+ {...rest}
77
+ >
78
+ <!-- TODO(closedby): Remove this wrapper when Webkit supports closedby -->
79
+ <div style="display: contents;" bind:this={contentWrapperRef}>
80
+ {@render children?.(id, close)}
81
+ </div>
82
+ </dialog>
83
+
84
+ <!-- @component
85
+ `Modal` provides a mechanism for displaying content overlaying the main application.
86
+
87
+ Modal can be imperatively controlled by the following methods available on the component instance:
88
+ - `showModal`: Shows the modal.
89
+ - `close`: Closes the modal.
90
+
91
+ Modal is declaratively controlled by default through the [Invoker Commands API](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API) using `commandfor` and `command` attributes supplied via the `trigger` snippet. Imperative methods remain available for cases where opening or closing must be orchestrated in code. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog) for more information.
92
+
93
+ ## Example Usage
94
+ ```svelte
95
+ <script lang="ts">
96
+ let modal = $state<ModalMethods>();
97
+ // Imperative controls on the component instance
98
+ $effect(() => modal?.showModal())
99
+ </script>
100
+
101
+ <Modal bind:this={modal}>
102
+ {#snippet trigger(triggerProps)}
103
+ <button {...triggerProps}>
104
+ Open Modal
105
+ </button>
106
+ {/snippet}
107
+ {#snippet children(commandfor, close)}
108
+ <Modal.Content>
109
+ <Modal.Content.Header>
110
+ Modal's Header
111
+ <Modal.Content.Header.CloseButton
112
+ {commandfor}
113
+ command="close"
114
+ />
115
+ </Modal.Content.Header>
116
+ <Modal.Content.Body>
117
+ Main Content
118
+ </Modal.Content.Body>
119
+ <Modal.Content.Footer>
120
+ <Button
121
+ onclick={() => {
122
+ // doSomething();
123
+ close();
124
+ }}
125
+ >
126
+ Confirm
127
+ </Button>
128
+ </Modal.Content.Footer>
129
+ </Modal.Content>
130
+ {/snippet}
131
+ </Modal>
132
+ ```
133
+
134
+ -->
@@ -0,0 +1,58 @@
1
+ import type { ModalMethods, ModalProps } from "./types.js";
2
+ import "./styles.css";
3
+ /**
4
+ * `Modal` provides a mechanism for displaying content overlaying the main application.
5
+ *
6
+ * Modal can be imperatively controlled by the following methods available on the component instance:
7
+ * - `showModal`: Shows the modal.
8
+ * - `close`: Closes the modal.
9
+ *
10
+ * Modal is declaratively controlled by default through the [Invoker Commands API](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API) using `commandfor` and `command` attributes supplied via the `trigger` snippet. Imperative methods remain available for cases where opening or closing must be orchestrated in code. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog) for more information.
11
+ *
12
+ * ## Example Usage
13
+ * ```svelte
14
+ * <script lang="ts">
15
+ * let modal = $state<ModalMethods>();
16
+ * // Imperative controls on the component instance
17
+ * $effect(() => modal?.showModal())
18
+ * </script>
19
+ *
20
+ * <Modal bind:this={modal}>
21
+ * {#snippet trigger(triggerProps)}
22
+ * <button {...triggerProps}>
23
+ * Open Modal
24
+ * </button>
25
+ * {/snippet}
26
+ * {#snippet children(commandfor, close)}
27
+ * <Modal.Content>
28
+ * <Modal.Content.Header>
29
+ * Modal's Header
30
+ * <Modal.Content.Header.CloseButton
31
+ * {commandfor}
32
+ * command="close"
33
+ * />
34
+ * </Modal.Content.Header>
35
+ * <Modal.Content.Body>
36
+ * Main Content
37
+ * </Modal.Content.Body>
38
+ * <Modal.Content.Footer>
39
+ * <Button
40
+ * onclick={() => {
41
+ * // doSomething();
42
+ * close();
43
+ * }}
44
+ * >
45
+ * Confirm
46
+ * </Button>
47
+ * </Modal.Content.Footer>
48
+ * </Modal.Content>
49
+ * {/snippet}
50
+ * </Modal>
51
+ * ```
52
+ */
53
+ declare const Modal: import("svelte").Component<ModalProps, {
54
+ showModal: ModalMethods["showModal"];
55
+ close: ModalMethods["close"];
56
+ }, "">;
57
+ type Modal = ReturnType<typeof Modal>;
58
+ export default Modal;
@@ -0,0 +1,72 @@
1
+ import { DialogContent } from "../common/index.js";
2
+ import { default as ModalRoot } from "./Modal.svelte";
3
+ declare const Modal: typeof ModalRoot & {
4
+ /**
5
+ * `Modal.Content` is a layout component that provides a structured container for the modal's content.
6
+ *
7
+ * @example
8
+ * ```svelte
9
+ * <Modal.Content>
10
+ * <Modal.Content.Header>
11
+ * Modal Header
12
+ * <Modal.Content.Header.CloseButton {commandfor} command="close" />
13
+ * </Modal.Content.Header>
14
+ * <Modal.Content.Body>
15
+ * Main Content
16
+ * </Modal.Content.Body>
17
+ * <Modal.Content.Footer>
18
+ * <Button>Footer Button</Button>
19
+ * </Modal.Content.Footer>
20
+ * </Modal.Content>
21
+ * ```
22
+ */
23
+ Content: typeof DialogContent & {
24
+ /**
25
+ * `Modal.Content.Header` represents the header section of the modal.
26
+ *
27
+ * @example
28
+ * ```svelte
29
+ * <Modal.Content.Header>
30
+ * Header Content
31
+ * <Modal.Content.Header.CloseButton {commandfor} command="close" />
32
+ * </Modal.Content.Header>
33
+ * ```
34
+ */
35
+ Header: typeof DialogContent.Header & {
36
+ /**
37
+ * `Modal.Content.Header.CloseButton` is a wrapper over `Button` meant to be used as a close button in modal headers.
38
+ *
39
+ * @example
40
+ * ```svelte
41
+ * <Modal.Content.Header.CloseButton {commandfor} command="close" />
42
+ * ```
43
+ */
44
+ CloseButton: typeof DialogContent.Header.CloseButton;
45
+ };
46
+ /**
47
+ * `Modal.Content.Body` represents the main content area of the modal.
48
+ *
49
+ * @example
50
+ * ```svelte
51
+ * <Modal.Content.Body>
52
+ * Main Content
53
+ * </Modal.Content.Body>
54
+ * ```
55
+ */
56
+ Body: typeof DialogContent.Body;
57
+ /**
58
+ * `Modal.Content.Footer` represents the footer section of the modal. Usually contains action buttons.
59
+ *
60
+ * @example
61
+ * ```svelte
62
+ * <Modal.Content.Footer>
63
+ * <Button>Cancel</Button>
64
+ * <Button>Confirm</Button>
65
+ * </Modal.Content.Footer>
66
+ * ```
67
+ */
68
+ Footer: typeof DialogContent.Footer;
69
+ };
70
+ };
71
+ export * from "./types.js";
72
+ export { Modal };
@@ -0,0 +1,7 @@
1
+ /* @canonical/generator-ds 0.10.0-experimental.2 */
2
+ import { DialogContent } from "../common/index.js";
3
+ import { default as ModalRoot } from "./Modal.svelte";
4
+ const Modal = ModalRoot;
5
+ Modal.Content = DialogContent;
6
+ export * from "./types.js";
7
+ export { Modal };
@@ -0,0 +1,39 @@
1
+ .ds.modal {
2
+ /* TODO: Replace with a token */
3
+ --dimension-width-modal: 38rem;
4
+
5
+ position: fixed;
6
+ margin: auto;
7
+ width: min(100vw, var(--dimension-width-modal));
8
+
9
+ border: var(--lp-dimension-stroke-thickness-default) solid
10
+ var(--lp-color-border-high-contrast);
11
+
12
+ &,
13
+ &::backdrop {
14
+ opacity: 0;
15
+ transition-behavior: allow-discrete;
16
+ transition-property: display, opacity, overlay;
17
+ transition-duration: var(--lp-transition-duration-fast);
18
+ }
19
+
20
+ &::backdrop {
21
+ background-color: var(--lp-color-background-overlay);
22
+ }
23
+
24
+ /*
25
+ [open] is a fallback for Safari that doesn't support the `:open`.
26
+
27
+ TODO(:open): Remove when Safari supports it (https://developer.mozilla.org/en-US/docs/Web/CSS/:open)
28
+ */
29
+ &:is(:open, [open]) {
30
+ &,
31
+ &::backdrop {
32
+ opacity: 1;
33
+
34
+ @starting-style {
35
+ opacity: 0;
36
+ }
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,41 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { HTMLDialogAttributes } from "svelte/elements";
3
+ type BaseProps = Omit<HTMLDialogAttributes, "open" | "children">;
4
+ export type ModalTriggerProps = {
5
+ onclick?: () => void;
6
+ commandfor: string;
7
+ command: "show-modal";
8
+ "aria-haspopup": "dialog";
9
+ };
10
+ export interface ModalProps extends BaseProps {
11
+ /**
12
+ * A snippet containing a button element that triggers the modal.
13
+ *
14
+ * Snippet arguments:
15
+ * - `triggerProps`: Props to spread on the button element. It contains:
16
+ * - `commandfor`: The id of the dialog element. Setting it as `commandfor` associates the button with the dialog to open.
17
+ * - `command`: Always set to `"show-modal"` to indicate that the button opens a modal.
18
+ * - `onclick`: An onclick handler that calls `dialog.showModal()`. Present only as a fallback for browsers that don't support [Invoker Commands API](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API).
19
+ * - `aria-haspopup`: Always set to `"dialog"` to indicate that the button opens a dialog.
20
+ */
21
+ trigger?: Snippet<[triggerProps: ModalTriggerProps]>;
22
+ /**
23
+ * Whether to close the modal when clicking outside of it.
24
+ *
25
+ * @default true
26
+ */
27
+ closeOnOutsideClick?: boolean;
28
+ /**
29
+ * Content of the modal.
30
+ *
31
+ * Snippet arguments:
32
+ * - `commandfor`: The id of the dialog element. Can be used to associate a close button with the dialog by setting it as `commandfor` and `command` to `"close"`.
33
+ * - `close`: A function to close the modal.
34
+ */
35
+ children?: Snippet<[commandfor: string, close: () => void]>;
36
+ }
37
+ export interface ModalMethods {
38
+ showModal: () => void;
39
+ close: () => void;
40
+ }
41
+ export {};
@@ -0,0 +1,2 @@
1
+ /* @canonical/generator-ds 0.10.0-experimental.2 */
2
+ export {};
@@ -1,2 +1,2 @@
1
1
  export { default as Popover } from "./Popover.svelte";
2
- export type { PopoverMethods, PopoverProps } from "./types";
2
+ export type { PopoverMethods, PopoverProps } from "./types.js";
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { SpinnerIcon } from "@canonical/svelte-icons";
3
- import type { SpinnerProps } from "./types";
3
+ import type { SpinnerProps } from "./types.js";
4
4
  import "./styles.css";
5
5
 
6
6
  const componentCssClassName = "ds spinner";
@@ -9,10 +9,10 @@
9
9
  </script>
10
10
 
11
11
  <SpinnerIcon
12
- name="spinner"
13
- class={[componentCssClassName, className]}
14
- aria-label="Loading"
15
- {...rest}
12
+ name="spinner"
13
+ class={[componentCssClassName, className]}
14
+ aria-label="Loading"
15
+ {...rest}
16
16
  />
17
17
 
18
18
  <!-- @component
@@ -1,4 +1,4 @@
1
- import type { SpinnerProps } from "./types";
1
+ import type { SpinnerProps } from "./types.js";
2
2
  import "./styles.css";
3
3
  /**
4
4
  * `Spinner` A loading icon indicator.
@@ -1,2 +1,2 @@
1
1
  export { default as Spinner } from "./Spinner.svelte";
2
- export type { SpinnerProps } from "./types";
2
+ export type { SpinnerProps } from "./types.js";
@@ -3,7 +3,7 @@
3
3
  HTMLAnchorAttributes,
4
4
  HTMLButtonAttributes,
5
5
  } from "svelte/elements";
6
- import type { ButtonPrimitiveProps } from "./types";
6
+ import type { ButtonPrimitiveProps } from "./types.js";
7
7
  import "./styles.css";
8
8
 
9
9
  const componentCssClassName = "ds button-primitive";
@@ -1,4 +1,4 @@
1
- import type { ButtonPrimitiveProps } from "./types";
1
+ import type { ButtonPrimitiveProps } from "./types.js";
2
2
  import "./styles.css";
3
3
  declare const ButtonPrimitive: import("svelte").Component<ButtonPrimitiveProps, {}, "ref">;
4
4
  type ButtonPrimitive = ReturnType<typeof ButtonPrimitive>;
@@ -1,2 +1,2 @@
1
1
  export { default as ButtonPrimitive } from "./ButtonPrimitive.svelte";
2
- export type { ButtonPrimitiveProps } from "./types";
2
+ export type { ButtonPrimitiveProps } from "./types.js";