@canonical/svelte-ds-app-launchpad 0.25.0 → 0.27.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 (138) hide show
  1. package/dist/components/NumberInput/types.d.ts +2 -2
  2. package/dist/components/Popover/Popover.svelte +1 -1
  3. package/dist/components/SearchBox/SearchBox.svelte +79 -0
  4. package/dist/components/SearchBox/SearchBox.svelte.d.ts +36 -0
  5. package/dist/components/SearchBox/common/SearchButton/SearchButton.svelte +31 -0
  6. package/dist/components/SearchBox/common/SearchButton/SearchButton.svelte.d.ts +5 -0
  7. package/dist/components/SearchBox/common/SearchButton/index.d.ts +2 -0
  8. package/dist/components/SearchBox/common/SearchButton/index.js +1 -0
  9. package/dist/components/SearchBox/common/SearchButton/styles.css +11 -0
  10. package/dist/components/SearchBox/common/SearchButton/types.d.ts +2 -0
  11. package/dist/components/SearchBox/common/SearchButton/types.js +1 -0
  12. package/dist/components/SearchBox/common/index.d.ts +1 -0
  13. package/dist/components/SearchBox/common/index.js +1 -0
  14. package/dist/components/SearchBox/context.d.ts +2 -0
  15. package/dist/components/SearchBox/context.js +2 -0
  16. package/dist/components/SearchBox/index.d.ts +22 -0
  17. package/dist/components/SearchBox/index.js +6 -0
  18. package/dist/components/SearchBox/styles.css +35 -0
  19. package/dist/components/SearchBox/types.d.ts +26 -0
  20. package/dist/components/SearchBox/types.js +2 -0
  21. package/dist/components/Select/Select.svelte +51 -0
  22. package/dist/components/Select/Select.svelte.d.ts +17 -0
  23. package/dist/components/Select/index.d.ts +2 -0
  24. package/dist/components/Select/index.js +3 -0
  25. package/dist/components/Select/styles.css +161 -0
  26. package/dist/components/Select/types.d.ts +7 -0
  27. package/dist/components/Select/types.js +2 -0
  28. package/dist/components/SidePanel/SidePanel.svelte +34 -0
  29. package/dist/components/SidePanel/SidePanel.svelte.d.ts +13 -0
  30. package/dist/components/SidePanel/index.d.ts +72 -0
  31. package/dist/components/SidePanel/index.js +7 -0
  32. package/dist/components/SidePanel/styles.css +37 -0
  33. package/dist/components/SidePanel/types.d.ts +3 -0
  34. package/dist/components/SidePanel/types.js +2 -0
  35. package/dist/components/Table/Table.svelte +52 -0
  36. package/dist/components/Table/Table.svelte.d.ts +41 -0
  37. package/dist/components/Table/common/TH/TH.svelte +40 -0
  38. package/dist/components/Table/common/TH/TH.svelte.d.ts +5 -0
  39. package/dist/components/Table/common/TH/common/SortButton/SortButton.svelte +36 -0
  40. package/dist/components/Table/common/TH/common/SortButton/SortButton.svelte.d.ts +5 -0
  41. package/dist/components/Table/common/TH/common/SortButton/index.d.ts +2 -0
  42. package/dist/components/Table/common/TH/common/SortButton/index.js +3 -0
  43. package/dist/components/Table/common/TH/common/SortButton/styles.css +19 -0
  44. package/dist/components/Table/common/TH/common/SortButton/types.d.ts +10 -0
  45. package/dist/components/Table/common/TH/common/SortButton/types.js +2 -0
  46. package/dist/components/Table/common/TH/common/index.d.ts +1 -0
  47. package/dist/components/Table/common/TH/common/index.js +1 -0
  48. package/dist/components/Table/common/TH/context.d.ts +2 -0
  49. package/dist/components/Table/common/TH/context.js +2 -0
  50. package/dist/components/Table/common/TH/index.d.ts +10 -0
  51. package/dist/components/Table/common/TH/index.js +7 -0
  52. package/dist/components/Table/common/TH/styles.css +22 -0
  53. package/dist/components/Table/common/TH/types.d.ts +21 -0
  54. package/dist/components/Table/common/TH/types.js +2 -0
  55. package/dist/components/Table/common/index.d.ts +1 -0
  56. package/dist/components/Table/common/index.js +1 -0
  57. package/dist/components/Table/index.d.ts +21 -0
  58. package/dist/components/Table/index.js +6 -0
  59. package/dist/components/Table/styles.css +46 -0
  60. package/dist/components/Table/types.d.ts +2 -0
  61. package/dist/components/Table/types.js +2 -0
  62. package/dist/components/TextInput/types.d.ts +2 -2
  63. package/dist/components/Timeline/Timeline.svelte +51 -0
  64. package/dist/components/Timeline/Timeline.svelte.d.ts +40 -0
  65. package/dist/components/Timeline/common/Event/Event.svelte +54 -0
  66. package/dist/components/Timeline/common/Event/Event.svelte.d.ts +5 -0
  67. package/dist/components/Timeline/common/Event/common/TitleRow/TitleRow.svelte +32 -0
  68. package/dist/components/Timeline/common/Event/common/TitleRow/TitleRow.svelte.d.ts +5 -0
  69. package/dist/components/Timeline/common/Event/common/TitleRow/index.d.ts +2 -0
  70. package/dist/components/Timeline/common/Event/common/TitleRow/index.js +3 -0
  71. package/dist/components/Timeline/common/Event/common/TitleRow/styles.css +38 -0
  72. package/dist/components/Timeline/common/Event/common/TitleRow/types.d.ts +18 -0
  73. package/dist/components/Timeline/common/Event/common/TitleRow/types.js +2 -0
  74. package/dist/components/Timeline/common/Event/common/index.d.ts +1 -0
  75. package/dist/components/Timeline/common/Event/common/index.js +1 -0
  76. package/dist/components/Timeline/common/Event/index.d.ts +20 -0
  77. package/dist/components/Timeline/common/Event/index.js +7 -0
  78. package/dist/components/Timeline/common/Event/styles.css +115 -0
  79. package/dist/components/Timeline/common/Event/types.d.ts +25 -0
  80. package/dist/components/Timeline/common/Event/types.js +2 -0
  81. package/dist/components/Timeline/common/HiddenEvents/HiddenEvents.svelte +24 -0
  82. package/dist/components/Timeline/common/HiddenEvents/HiddenEvents.svelte.d.ts +5 -0
  83. package/dist/components/Timeline/common/HiddenEvents/common/Link/Link.svelte +15 -0
  84. package/dist/components/Timeline/common/HiddenEvents/common/Link/Link.svelte.d.ts +6 -0
  85. package/dist/components/Timeline/common/HiddenEvents/common/Link/index.d.ts +2 -0
  86. package/dist/components/Timeline/common/HiddenEvents/common/Link/index.js +3 -0
  87. package/dist/components/Timeline/common/HiddenEvents/common/Link/styles.css +9 -0
  88. package/dist/components/Timeline/common/HiddenEvents/common/Link/types.d.ts +2 -0
  89. package/dist/components/Timeline/common/HiddenEvents/common/Link/types.js +2 -0
  90. package/dist/components/Timeline/common/HiddenEvents/common/index.d.ts +1 -0
  91. package/dist/components/Timeline/common/HiddenEvents/common/index.js +1 -0
  92. package/dist/components/Timeline/common/HiddenEvents/index.d.ts +17 -0
  93. package/dist/components/Timeline/common/HiddenEvents/index.js +7 -0
  94. package/dist/components/Timeline/common/HiddenEvents/styles.css +42 -0
  95. package/dist/components/Timeline/common/HiddenEvents/types.d.ts +9 -0
  96. package/dist/components/Timeline/common/HiddenEvents/types.js +2 -0
  97. package/dist/components/Timeline/common/index.d.ts +2 -0
  98. package/dist/components/Timeline/common/index.js +2 -0
  99. package/dist/components/Timeline/index.d.ts +39 -0
  100. package/dist/components/Timeline/index.js +8 -0
  101. package/dist/components/Timeline/styles.css +12 -0
  102. package/dist/components/Timeline/types.d.ts +2 -0
  103. package/dist/components/Timeline/types.js +2 -0
  104. package/dist/components/Tooltip/Tooltip.svelte +165 -0
  105. package/dist/components/Tooltip/Tooltip.svelte.d.ts +23 -0
  106. package/dist/components/Tooltip/index.d.ts +2 -0
  107. package/dist/components/Tooltip/index.js +3 -0
  108. package/dist/components/Tooltip/styles.css +111 -0
  109. package/dist/components/Tooltip/types.d.ts +43 -0
  110. package/dist/components/Tooltip/types.js +2 -0
  111. package/dist/components/Tooltip/utils/ChainingManager.d.ts +18 -0
  112. package/dist/components/Tooltip/utils/ChainingManager.js +29 -0
  113. package/dist/components/Tooltip/utils/useDelayedOpen.svelte.d.ts +15 -0
  114. package/dist/components/Tooltip/utils/useDelayedOpen.svelte.js +42 -0
  115. package/dist/components/Tooltip/utils/useTooltipPosition.svelte.d.ts +24 -0
  116. package/dist/components/Tooltip/utils/useTooltipPosition.svelte.js +40 -0
  117. package/dist/components/UserAvatar/UserAvatar.svelte +63 -0
  118. package/dist/components/UserAvatar/UserAvatar.svelte.d.ts +17 -0
  119. package/dist/components/UserAvatar/index.d.ts +2 -0
  120. package/dist/components/UserAvatar/index.js +3 -0
  121. package/dist/components/UserAvatar/styles.css +66 -0
  122. package/dist/components/UserAvatar/types.d.ts +12 -0
  123. package/dist/components/UserAvatar/types.js +2 -0
  124. package/dist/components/UserAvatar/utils/getInitials.d.ts +1 -0
  125. package/dist/components/UserAvatar/utils/getInitials.js +8 -0
  126. package/dist/components/UserAvatar/utils/index.d.ts +1 -0
  127. package/dist/components/UserAvatar/utils/index.js +1 -0
  128. package/dist/components/icons/SortIcon.svelte +25 -0
  129. package/dist/components/icons/SortIcon.svelte.d.ts +4 -0
  130. package/dist/components/icons/index.d.ts +1 -0
  131. package/dist/components/icons/index.js +2 -0
  132. package/dist/components/index.d.ts +7 -0
  133. package/dist/components/index.js +7 -0
  134. package/dist/type-utils/DistributiveOmit.d.ts +4 -0
  135. package/dist/type-utils/DistributiveOmit.js +1 -0
  136. package/dist/type-utils/index.d.ts +1 -0
  137. package/dist/type-utils/index.js +1 -0
  138. package/package.json +8 -8
@@ -1,5 +1,5 @@
1
- import type { ModifierFamily } from "../../modifier-families/index.js";
1
+ import type { ModifierFamily, ModifierFamilyValues } from "../../modifier-families/index.js";
2
2
  import type { NumberInputPrimitiveProps } from "../common/index.js";
3
3
  export interface NumberInputProps extends Omit<NumberInputPrimitiveProps, "type">, ModifierFamily<"severity"> {
4
- density?: "dense" | "medium";
4
+ density?: Extract<ModifierFamilyValues["density"], "dense" | "medium">;
5
5
  }
@@ -55,7 +55,7 @@
55
55
  {@render trigger(
56
56
  {
57
57
  popovertarget: id,
58
- style: `anchor-name: ${anchorName}`,
58
+ style: `anchor-name: ${anchorName};`,
59
59
  [createAttachmentKey()]: triggerAttachment,
60
60
  },
61
61
  open,
@@ -0,0 +1,79 @@
1
+ <!-- @canonical/generator-ds 0.10.0-experimental.4 -->
2
+
3
+ <script lang="ts">
4
+ import type { SearchBoxProps } from "./types.js";
5
+ import "./styles.css";
6
+ import { InputPrimitive } from "../common/index.js";
7
+ import { SearchButton } from "./common/index.js";
8
+ import { setSearchBoxContext } from "./context.js";
9
+
10
+ const componentCssClassName = "ds search-box";
11
+
12
+ let {
13
+ class: className,
14
+ value = $bindable(),
15
+ children,
16
+ "aria-label": ariaLabel,
17
+ disabled,
18
+ shouldRenderInvalidStyles,
19
+ "data-testid": dataTestId,
20
+ ...rest
21
+ }: SearchBoxProps = $props();
22
+
23
+ setSearchBoxContext({
24
+ get disabled() {
25
+ return disabled;
26
+ },
27
+ get "aria-label"() {
28
+ return ariaLabel;
29
+ },
30
+ });
31
+ </script>
32
+
33
+ <div class={[componentCssClassName, className]} data-testid={dataTestId}>
34
+ <InputPrimitive
35
+ type="search"
36
+ bind:value
37
+ aria-label={ariaLabel}
38
+ {disabled}
39
+ class={{ "no-invalid-styles": !shouldRenderInvalidStyles }}
40
+ {...rest}
41
+ />
42
+ {#if children}
43
+ {@render children()}
44
+ {:else}
45
+ <SearchButton />
46
+ {/if}
47
+ </div>
48
+
49
+ <!-- @component
50
+ `SearchBox` is a text input field designed for search functionality.
51
+
52
+ By default, it renders an input and a submit button (`SearchBox.SearchButton`).
53
+ You can override the default button by passing `children`.
54
+
55
+ When `SearchBox.SearchButton` is used inside `SearchBox`, it inherits `aria-label` and `disabled` from `SearchBox` context by default. You can still override those values directly on `SearchBox.SearchButton` when needed.
56
+
57
+ ## Example Usage
58
+ ### Basic Example
59
+ ```svelte
60
+ <SearchBox aria-label="Search articles" placeholder="Ubuntu" />
61
+ ```
62
+
63
+ ### Customized SearchButton
64
+ ```svelte
65
+ <SearchBox aria-label="Search articles" placeholder="Ubuntu">
66
+ <SearchBox.SearchButton onclick={handleClick} aria-label="Run search" />
67
+ </SearchBox>
68
+ ```
69
+
70
+ ### As a search landmark
71
+ To make the `SearchBox` a search landmark wrap it in a [`<form role="search">`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/search_role) or [`<search>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/search)
72
+ ```svelte
73
+ <search>
74
+ <form>
75
+ <SearchBox aria-label="Articles" name="q" />
76
+ </form>
77
+ </search>
78
+ ```
79
+ -->
@@ -0,0 +1,36 @@
1
+ import type { SearchBoxProps } from "./types.js";
2
+ import "./styles.css";
3
+ /**
4
+ * `SearchBox` is a text input field designed for search functionality.
5
+ *
6
+ * By default, it renders an input and a submit button (`SearchBox.SearchButton`).
7
+ * You can override the default button by passing `children`.
8
+ *
9
+ * When `SearchBox.SearchButton` is used inside `SearchBox`, it inherits `aria-label` and `disabled` from `SearchBox` context by default. You can still override those values directly on `SearchBox.SearchButton` when needed.
10
+ *
11
+ * ## Example Usage
12
+ * ### Basic Example
13
+ * ```svelte
14
+ * <SearchBox aria-label="Search articles" placeholder="Ubuntu" />
15
+ * ```
16
+ *
17
+ * ### Customized SearchButton
18
+ * ```svelte
19
+ * <SearchBox aria-label="Search articles" placeholder="Ubuntu">
20
+ * <SearchBox.SearchButton onclick={handleClick} aria-label="Run search" />
21
+ * </SearchBox>
22
+ * ```
23
+ *
24
+ * ### As a search landmark
25
+ * To make the `SearchBox` a search landmark wrap it in a [`<form role="search">`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/search_role) or [`<search>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/search)
26
+ * ```svelte
27
+ * <search>
28
+ * <form>
29
+ * <SearchBox aria-label="Articles" name="q" />
30
+ * </form>
31
+ * </search>
32
+ * ```
33
+ */
34
+ declare const SearchBox: import("svelte").Component<SearchBoxProps, {}, "value">;
35
+ type SearchBox = ReturnType<typeof SearchBox>;
36
+ export default SearchBox;
@@ -0,0 +1,31 @@
1
+ <script lang="ts">
2
+ import { SearchIcon } from "@canonical/svelte-icons";
3
+ import { ButtonPrimitive } from "../../../common/index.js";
4
+ import type { SearchButtonProps } from "./types.js";
5
+ import "./styles.css";
6
+ import { getSearchBoxContext } from "../../context.js";
7
+
8
+ const componentCssClassName = "ds search-box-search-button";
9
+
10
+ let {
11
+ class: className,
12
+ type = "submit",
13
+ disabled,
14
+ "aria-label": ariaLabel,
15
+ ...rest
16
+ }: SearchButtonProps = $props();
17
+
18
+ const searchBoxContext = getSearchBoxContext();
19
+ </script>
20
+
21
+ <ButtonPrimitive
22
+ {type}
23
+ class={[componentCssClassName, className]}
24
+ disabled={disabled !== undefined ? disabled : searchBoxContext.disabled}
25
+ aria-label={ariaLabel !== undefined
26
+ ? ariaLabel
27
+ : searchBoxContext["aria-label"]}
28
+ {...rest}
29
+ >
30
+ <SearchIcon />
31
+ </ButtonPrimitive>
@@ -0,0 +1,5 @@
1
+ import type { SearchButtonProps } from "./types.js";
2
+ import "./styles.css";
3
+ declare const SearchButton: import("svelte").Component<SearchButtonProps, {}, "">;
4
+ type SearchButton = ReturnType<typeof SearchButton>;
5
+ export default SearchButton;
@@ -0,0 +1,2 @@
1
+ export { default as SearchButton } from "./SearchButton.svelte";
2
+ export type { SearchButtonProps } from "./types.js";
@@ -0,0 +1 @@
1
+ export { default as SearchButton } from "./SearchButton.svelte";
@@ -0,0 +1,11 @@
1
+ .ds.search-box-search-button.button-primitive {
2
+ justify-self: end;
3
+ display: grid;
4
+ place-items: center;
5
+ padding: 0;
6
+ --color-background-button-hover: transparent;
7
+ --color-background-button-active: transparent;
8
+
9
+ width: var(--dimension-width-search-box-button);
10
+ margin-inline-end: var(--dimension-gap-search-box);
11
+ }
@@ -0,0 +1,2 @@
1
+ import type { HTMLButtonAttributes } from "svelte/elements";
2
+ export type SearchButtonProps = Omit<HTMLButtonAttributes, "children">;
@@ -0,0 +1 @@
1
+ export * from "./SearchButton/index.js";
@@ -0,0 +1 @@
1
+ export * from "./SearchButton/index.js";
@@ -0,0 +1,2 @@
1
+ import type { SearchBoxContext } from "./types.js";
2
+ export declare const getSearchBoxContext: () => SearchBoxContext, setSearchBoxContext: (context: SearchBoxContext) => SearchBoxContext;
@@ -0,0 +1,2 @@
1
+ import { createContext } from "svelte";
2
+ export const [getSearchBoxContext, setSearchBoxContext] = createContext();
@@ -0,0 +1,22 @@
1
+ import { SearchButton } from "./common/index.js";
2
+ import { default as SearchBoxRoot } from "./SearchBox.svelte";
3
+ declare const SearchBox: typeof SearchBoxRoot & {
4
+ /**
5
+ * `SearchButton` is the button companion for `SearchBox`.
6
+ *
7
+ * It is available as `SearchBox.SearchButton` and is intended to be used inside `SearchBox` when you want to customize the default button behavior.
8
+ *
9
+ * `disabled` and `aria-label` props can be passed directly to `SearchButton`, but if they are not provided they will reflect their respective values from `SearchBox` context.
10
+ *
11
+ * @example
12
+ * ```svelte
13
+ * <SearchBox aria-label="Search articles">
14
+ * <SearchBox.SearchButton onclick={handleClick} disabled />
15
+ * </SearchBox>
16
+ * ```
17
+ */
18
+ SearchButton: typeof SearchButton;
19
+ };
20
+ export type { SearchButtonProps as SearchBoxSearchButtonProps } from "./common/index.js";
21
+ export type { SearchBoxProps } from "./types.js";
22
+ export { SearchBox };
@@ -0,0 +1,6 @@
1
+ /* @canonical/generator-ds 0.10.0-experimental.4 */
2
+ import { SearchButton } from "./common/index.js";
3
+ import { default as SearchBoxRoot } from "./SearchBox.svelte";
4
+ const SearchBox = SearchBoxRoot;
5
+ SearchBox.SearchButton = SearchButton;
6
+ export { SearchBox };
@@ -0,0 +1,35 @@
1
+ .ds.search-box {
2
+ --dimension-width-search-box-button: var(--lp-dimension-size-l);
3
+ --dimension-gap-search-box: var(--lp-dimension-spacing-inline-xs);
4
+
5
+ display: grid;
6
+ grid-template-areas: "main";
7
+
8
+ > * {
9
+ grid-area: main;
10
+ }
11
+
12
+ > input {
13
+ padding-inline-end: calc(
14
+ 2 *
15
+ var(--dimension-gap-search-box) +
16
+ var(--dimension-width-search-box-button)
17
+ );
18
+
19
+ &::-webkit-search-cancel-button {
20
+ display: none;
21
+ }
22
+
23
+ &.no-invalid-styles {
24
+ --color-background-input-invalid: var(--color-background-input);
25
+ --color-background-input-invalid-hover: var(
26
+ --color-background-input-hover
27
+ );
28
+ --color-background-input-invalid-active: var(
29
+ --color-background-input-active
30
+ );
31
+ --color-border-input-invalid: var(--color-border-input);
32
+ --color-outline-input-invalid: var(--color-outline-input);
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,26 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { HTMLInputAttributes } from "svelte/elements";
3
+ import type { TextInputPrimitiveProps } from "../common/index.js";
4
+ export interface SearchBoxProps extends Omit<TextInputPrimitiveProps, "type"> {
5
+ /**
6
+ * The accessible name for the input.
7
+ *
8
+ * A search input's purpose is usually clear for sighted users, but screen reader users may not have the same context. Providing an accessible name helps ensure that all users understand the purpose of the input (see: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/search#search_form_labels_and_accessibility).
9
+ */
10
+ "aria-label": string;
11
+ /**
12
+ * Whether to apply the invalid styles to the input when it fails native validation (`:user-invalid`) or `aria-invalid="true"` is set.
13
+ *
14
+ * @default false
15
+ * This is opt-in because search landmarks often have submission requirements, such as `required` and `minlength`, where you may want to block submission without showing a visual invalid state.
16
+ */
17
+ shouldRenderInvalidStyles?: boolean;
18
+ /**
19
+ * The content to render instead of the default `SearchBox.SearchButton`. This is useful when you want to customize the default button behavior, such as adding an `onclick` handler.
20
+ */
21
+ children?: Snippet<[]>;
22
+ }
23
+ export type SearchBoxContext = {
24
+ disabled: HTMLInputAttributes["disabled"];
25
+ "aria-label": string;
26
+ };
@@ -0,0 +1,2 @@
1
+ /* @canonical/generator-ds 0.10.0-experimental.4 */
2
+ export {};
@@ -0,0 +1,51 @@
1
+ <!-- @canonical/generator-ds 0.10.0-experimental.3 -->
2
+
3
+ <script lang="ts">
4
+ import { ChevronDownIcon } from "@canonical/svelte-icons";
5
+ import type { SelectProps } from "./types.js";
6
+ import "./styles.css";
7
+
8
+ const componentCssClassName = "ds select";
9
+
10
+ let {
11
+ class: className,
12
+ ref = $bindable(),
13
+ value = $bindable(),
14
+ children,
15
+ severity,
16
+ density,
17
+ "data-testid": dataTestId,
18
+ ...rest
19
+ }: SelectProps = $props();
20
+ </script>
21
+
22
+ <!--
23
+ The wrapper is needed to position the chevron icon correctly.
24
+ TODO: Remove the wrapper when:
25
+ - ideally [Customizable select elements](https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Customizable_select) are supported across browsers.
26
+ - alternatively, anchor positioning support is widespread enough to position the chevron icon without needing a wrapper element.
27
+ -->
28
+ <div
29
+ class={[componentCssClassName, className, severity, density]}
30
+ data-testid={dataTestId}
31
+ >
32
+ <select bind:value bind:this={ref} {...rest}>
33
+ {@render children?.()}
34
+ </select>
35
+ {#if !rest.multiple}
36
+ <ChevronDownIcon class="chevron" />
37
+ {/if}
38
+ </div>
39
+
40
+ <!-- @component
41
+ `Select` is a styled wrapper around the native HTML `<select>` element.
42
+
43
+ ## Example Usage
44
+ ```svelte
45
+ <Select bind:value={valueState}>
46
+ <option value="1">Option 1</option>
47
+ <option value="2">Option 2</option>
48
+ <option value="3">Option 3</option>
49
+ </Select>
50
+ ```
51
+ -->
@@ -0,0 +1,17 @@
1
+ import type { SelectProps } from "./types.js";
2
+ import "./styles.css";
3
+ /**
4
+ * `Select` is a styled wrapper around the native HTML `<select>` element.
5
+ *
6
+ * ## Example Usage
7
+ * ```svelte
8
+ * <Select bind:value={valueState}>
9
+ * <option value="1">Option 1</option>
10
+ * <option value="2">Option 2</option>
11
+ * <option value="3">Option 3</option>
12
+ * </Select>
13
+ * ```
14
+ */
15
+ declare const Select: import("svelte").Component<SelectProps, {}, "value" | "ref">;
16
+ type Select = ReturnType<typeof Select>;
17
+ export default Select;
@@ -0,0 +1,2 @@
1
+ export { default as Select } from "./Select.svelte";
2
+ export * from "./types.js";
@@ -0,0 +1,3 @@
1
+ /* @canonical/generator-ds 0.10.0-experimental.3 */
2
+ export { default as Select } from "./Select.svelte";
3
+ export * from "./types.js";
@@ -0,0 +1,161 @@
1
+ .ds.select {
2
+ --color-background-select-input-hover: var(
3
+ --lp-color-background-secondary-hover-context,
4
+ var(--lp-color-background-hover)
5
+ );
6
+ --color-background-select-input-active: var(
7
+ --lp-color-background-secondary-active-context,
8
+ var(--lp-color-background-active)
9
+ );
10
+ --color-background-select-input: var(
11
+ --lp-color-background-secondary-context,
12
+ var(--lp-color-background-input)
13
+ );
14
+ --dimension-padding-inline-select-input: var(
15
+ --lp-dimension-spacing-inline-xs
16
+ );
17
+ --dimension-padding-block-select-input: var(
18
+ --lp-dimension-padding-block-context,
19
+ var(--lp-dimension-spacing-block-xxs)
20
+ );
21
+ --color-border-select-input: var(
22
+ --lp-color-border-secondary-context,
23
+ var(--lp-color-border-high-contrast)
24
+ );
25
+ --color-outline-select-input: var(
26
+ --lp-color-border-secondary-context,
27
+ var(--lp-color-border-focus)
28
+ );
29
+
30
+ color: var(--lp-color-text-default);
31
+ font: var(--lp-typography-paragraph-default);
32
+
33
+ display: inline-grid;
34
+ align-items: center;
35
+ grid-template-areas: "select";
36
+
37
+ > * {
38
+ grid-area: select;
39
+ }
40
+
41
+ > .chevron {
42
+ justify-self: end;
43
+ margin-inline-end: var(--dimension-padding-inline-select-input);
44
+ pointer-events: none;
45
+ }
46
+
47
+ > select {
48
+ appearance: none;
49
+ border: none;
50
+ cursor: pointer;
51
+ color: inherit;
52
+ font: inherit;
53
+
54
+ padding-inline-start: var(--dimension-padding-inline-select-input);
55
+ /* Padding + gap + icon size */
56
+ padding-inline-end: calc(
57
+ var(--dimension-padding-inline-select-input) +
58
+ var(--lp-dimension-spacing-inline-xxxs) +
59
+ 1em
60
+ );
61
+ padding-block: var(--dimension-padding-block-select-input);
62
+ border-block-end: var(--lp-dimension-stroke-thickness-default) solid
63
+ var(--color-border-select-input);
64
+ background-color: var(--color-background-select-input);
65
+ outline-color: var(--color-outline-select-input);
66
+ border-radius: var(--lp-dimension-radius-none);
67
+
68
+ transition-duration: var(--lp-transition-duration-snap);
69
+ transition-property: background-color, border-color, outline-color;
70
+ transition-timing-function: var(--lp-transition-timing-ease-in);
71
+
72
+ :not(:disabled) {
73
+ &:hover {
74
+ background-color: var(--color-background-select-input-hover);
75
+ }
76
+
77
+ &:active,
78
+ &:focus {
79
+ background-color: var(--color-background-select-input-active);
80
+ }
81
+ }
82
+
83
+ &:disabled {
84
+ cursor: not-allowed;
85
+ opacity: var(--lp-opacity-muted);
86
+
87
+ + .chevron {
88
+ opacity: var(--lp-opacity-muted);
89
+ }
90
+ }
91
+
92
+ &:user-invalid,
93
+ &[aria-invalid="true"] {
94
+ --color-background-select-input: var(
95
+ --lp-color-background-negative-default
96
+ );
97
+ border-color: var(--lp-color-border-negative);
98
+ outline-color: var(--lp-color-border-negative);
99
+
100
+ &:hover {
101
+ background-color: var(--lp-color-background-negative-hover);
102
+ }
103
+
104
+ &:active,
105
+ &:focus {
106
+ background-color: var(--lp-color-background-negative-active);
107
+ }
108
+ }
109
+
110
+ &:not([multiple]) {
111
+ option {
112
+ /*
113
+ FIXME(steciuk): The colors currently used for the select background have some baked-in transparency.
114
+ This doesn't play well with how the select element is rendered in Chrome, making the options looked washed out and with very low contrast. This is a temporary workaround that aims to strip the transparency from the color while keeping similar visuals.
115
+
116
+ A better solution would be to update the design tokens to use solid colors, but the currently tokens and modifiers system are soon to be replaced anyway, so it might not be worth the effort.
117
+ */
118
+ background-color: var(--lp-color-background-default);
119
+ /* biome-ignore lint/suspicious/noDuplicateProperties: Fallback for older chrome versions */
120
+ background-color: color-mix(
121
+ in srgb,
122
+ rgb(from var(--color-background-select-input) r g b / 1) 20%,
123
+ var(--lp-color-background-default) 80%
124
+ );
125
+ }
126
+ }
127
+
128
+ &[multiple] {
129
+ padding: 0;
130
+
131
+ option {
132
+ padding-block: var(--dimension-padding-block-select-input);
133
+ padding-inline: var(--dimension-padding-inline-select-input);
134
+
135
+ &:checked {
136
+ background-color: var(--color-background-select-input-active);
137
+ }
138
+ }
139
+ }
140
+ }
141
+
142
+ &.base {
143
+ --lp-color-background-secondary-hover-context: initial;
144
+ --lp-color-background-secondary-active-context: initial;
145
+ --lp-color-background-secondary-context: transparent;
146
+ --lp-color-border-secondary-context: initial;
147
+
148
+ > select {
149
+ border: none;
150
+ }
151
+
152
+ &:not([multiple]) {
153
+ > select {
154
+ option {
155
+ /* FIXME(steciuk): Pt. 2 of the transparency workaround */
156
+ background-color: var(--lp-color-background-default);
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
@@ -0,0 +1,7 @@
1
+ import type { HTMLSelectAttributes } from "svelte/elements";
2
+ import type { ModifierFamilyValues } from "../../modifier-families/index.js";
3
+ export interface SelectProps extends HTMLSelectAttributes {
4
+ ref?: HTMLSelectElement;
5
+ density?: Extract<ModifierFamilyValues["density"], "dense" | "medium">;
6
+ severity?: ModifierFamilyValues["severity"] | "base";
7
+ }
@@ -0,0 +1,2 @@
1
+ /* @canonical/generator-ds 0.10.0-experimental.3 */
2
+ export {};
@@ -0,0 +1,34 @@
1
+ <!-- @canonical/generator-ds 0.10.0-experimental.2 -->
2
+
3
+ <script lang="ts">
4
+ import { Modal } from "../Modal/index.js";
5
+ import type { SidePanelMethods, SidePanelProps } from "./types.js";
6
+ import "./styles.css";
7
+
8
+ const componentCssClassName = "ds side-panel";
9
+
10
+ let { class: className, ...rest }: SidePanelProps = $props();
11
+
12
+ let modalMethods = $state<SidePanelMethods>();
13
+
14
+ export const showModal: SidePanelMethods["showModal"] = () => {
15
+ modalMethods?.showModal();
16
+ };
17
+
18
+ export const close: SidePanelMethods["close"] = () => {
19
+ modalMethods?.close();
20
+ };
21
+ </script>
22
+
23
+ <Modal
24
+ bind:this={modalMethods}
25
+ class={[componentCssClassName, className]}
26
+ {...rest}
27
+ />
28
+
29
+ <!-- @component
30
+ `SidePanel` displays a `Modal` with a side-docked layout, sliding in from the right edge of the viewport.
31
+
32
+ For API details and usage patterns, refer to `Modal`.
33
+
34
+ -->
@@ -0,0 +1,13 @@
1
+ import type { SidePanelMethods } from "./types.js";
2
+ import "./styles.css";
3
+ /**
4
+ * `SidePanel` displays a `Modal` with a side-docked layout, sliding in from the right edge of the viewport.
5
+ *
6
+ * For API details and usage patterns, refer to `Modal`.
7
+ */
8
+ declare const SidePanel: import("svelte").Component<import("../index.js").ModalProps, {
9
+ showModal: SidePanelMethods["showModal"];
10
+ close: SidePanelMethods["close"];
11
+ }, "">;
12
+ type SidePanel = ReturnType<typeof SidePanel>;
13
+ export default SidePanel;