@sentropic/design-system-svelte 0.5.0 → 0.7.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 (37) hide show
  1. package/dist/AspectRatio.svelte +44 -0
  2. package/dist/AspectRatio.svelte.d.ts +11 -0
  3. package/dist/AspectRatio.svelte.d.ts.map +1 -0
  4. package/dist/CodeSnippet.svelte +91 -0
  5. package/dist/CodeSnippet.svelte.d.ts +13 -0
  6. package/dist/CodeSnippet.svelte.d.ts.map +1 -0
  7. package/dist/Form.svelte +117 -0
  8. package/dist/Form.svelte.d.ts +16 -0
  9. package/dist/Form.svelte.d.ts.map +1 -0
  10. package/dist/FormGroup.svelte +71 -0
  11. package/dist/FormGroup.svelte.d.ts +13 -0
  12. package/dist/FormGroup.svelte.d.ts.map +1 -0
  13. package/dist/Header.svelte +117 -0
  14. package/dist/Header.svelte.d.ts +16 -0
  15. package/dist/Header.svelte.d.ts.map +1 -0
  16. package/dist/OverflowMenu.svelte +222 -0
  17. package/dist/OverflowMenu.svelte.d.ts +21 -0
  18. package/dist/OverflowMenu.svelte.d.ts.map +1 -0
  19. package/dist/PaginationNav.svelte +219 -0
  20. package/dist/PaginationNav.svelte.d.ts +15 -0
  21. package/dist/PaginationNav.svelte.d.ts.map +1 -0
  22. package/dist/ProgressIndicator.svelte +283 -0
  23. package/dist/ProgressIndicator.svelte.d.ts +18 -0
  24. package/dist/ProgressIndicator.svelte.d.ts.map +1 -0
  25. package/dist/StructuredList.svelte +86 -0
  26. package/dist/StructuredList.svelte.d.ts +15 -0
  27. package/dist/StructuredList.svelte.d.ts.map +1 -0
  28. package/dist/TileGroup.svelte +179 -0
  29. package/dist/TileGroup.svelte.d.ts +21 -0
  30. package/dist/TileGroup.svelte.d.ts.map +1 -0
  31. package/dist/UnorderedList.svelte +108 -0
  32. package/dist/UnorderedList.svelte.d.ts +16 -0
  33. package/dist/UnorderedList.svelte.d.ts.map +1 -0
  34. package/dist/index.d.ts +16 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +11 -0
  37. package/package.json +2 -2
@@ -0,0 +1,222 @@
1
+ <script lang="ts" module>
2
+ export interface OverflowMenuItem {
3
+ value: string;
4
+ label: string;
5
+ disabled?: boolean;
6
+ danger?: boolean;
7
+ onclick?: () => void;
8
+ }
9
+ </script>
10
+
11
+ <script lang="ts">
12
+ import type { HTMLAttributes } from "svelte/elements";
13
+
14
+ type OverflowMenuProps = Omit<HTMLAttributes<HTMLDivElement>, "class" | "onselect"> & {
15
+ items: OverflowMenuItem[];
16
+ label?: string;
17
+ open?: boolean;
18
+ placement?: "bottom-start" | "bottom-end" | "top-start" | "top-end";
19
+ class?: string;
20
+ triggerLabel?: string;
21
+ onselect?: (value: string) => void;
22
+ };
23
+
24
+ let {
25
+ items,
26
+ label = "Menu",
27
+ open = $bindable(false),
28
+ placement = "bottom-end",
29
+ class: className,
30
+ triggerLabel = "More actions",
31
+ onselect,
32
+ ...rest
33
+ }: OverflowMenuProps = $props();
34
+
35
+ let host: HTMLDivElement | undefined = $state();
36
+
37
+ const classes = () =>
38
+ ["st-overflowMenu", `st-overflowMenu--${placement}`, className].filter(Boolean).join(" ");
39
+
40
+ function toggle() {
41
+ open = !open;
42
+ }
43
+
44
+ function close() {
45
+ open = false;
46
+ }
47
+
48
+ function selectItem(item: OverflowMenuItem) {
49
+ if (item.disabled) return;
50
+ item.onclick?.();
51
+ onselect?.(item.value);
52
+ close();
53
+ }
54
+
55
+ function onWindowKeydown(event: KeyboardEvent) {
56
+ if (event.key === "Escape" && open) {
57
+ event.preventDefault();
58
+ close();
59
+ }
60
+ }
61
+
62
+ function onWindowPointerDown(event: MouseEvent) {
63
+ if (!open) return;
64
+ const target = event.target as Node | null;
65
+ if (host && target && !host.contains(target)) close();
66
+ }
67
+ </script>
68
+
69
+ <svelte:window onkeydown={onWindowKeydown} onpointerdown={onWindowPointerDown} />
70
+
71
+ <div {...rest} bind:this={host} class={classes()}>
72
+ <button
73
+ type="button"
74
+ class="st-overflowMenu__trigger"
75
+ aria-haspopup="menu"
76
+ aria-expanded={open ? "true" : "false"}
77
+ aria-label={triggerLabel}
78
+ onclick={toggle}
79
+ >
80
+ <svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" focusable="false">
81
+ <circle cx="3" cy="8" r="1.4" fill="currentColor" />
82
+ <circle cx="8" cy="8" r="1.4" fill="currentColor" />
83
+ <circle cx="13" cy="8" r="1.4" fill="currentColor" />
84
+ </svg>
85
+ </button>
86
+ {#if open}
87
+ <ul class="st-overflowMenu__list" role="menu" aria-label={label}>
88
+ {#each items as item (item.value)}
89
+ <li role="none" class="st-overflowMenu__listItem">
90
+ <button
91
+ type="button"
92
+ class="st-overflowMenu__item"
93
+ class:st-overflowMenu__item--danger={item.danger}
94
+ role="menuitem"
95
+ aria-disabled={item.disabled ? "true" : undefined}
96
+ disabled={item.disabled}
97
+ onclick={() => selectItem(item)}
98
+ >
99
+ {item.label}
100
+ </button>
101
+ </li>
102
+ {/each}
103
+ </ul>
104
+ {/if}
105
+ </div>
106
+
107
+ <style>
108
+ .st-overflowMenu {
109
+ display: inline-block;
110
+ position: relative;
111
+ }
112
+
113
+ .st-overflowMenu__trigger {
114
+ align-items: center;
115
+ background: transparent;
116
+ border: 1px solid transparent;
117
+ border-radius: var(--st-component-overflowMenu-triggerRadius, var(--st-radius-small, 0.375rem));
118
+ color: var(--st-component-overflowMenu-triggerText, var(--st-semantic-text-primary));
119
+ cursor: pointer;
120
+ display: inline-flex;
121
+ height: 2rem;
122
+ justify-content: center;
123
+ padding: 0;
124
+ width: 2rem;
125
+ }
126
+
127
+ .st-overflowMenu__trigger:hover {
128
+ background: var(
129
+ --st-component-overflowMenu-triggerHoverBackground,
130
+ var(--st-semantic-surface-subtle)
131
+ );
132
+ }
133
+
134
+ .st-overflowMenu__trigger:focus-visible {
135
+ border-color: var(--st-component-control-focusRing, var(--st-semantic-border-interactive));
136
+ box-shadow: 0 0 0 2px var(--st-component-control-focusRing, var(--st-semantic-border-interactive));
137
+ outline: none;
138
+ }
139
+
140
+ .st-overflowMenu__trigger[aria-expanded="true"] {
141
+ background: var(
142
+ --st-component-overflowMenu-triggerHoverBackground,
143
+ var(--st-semantic-surface-subtle)
144
+ );
145
+ }
146
+
147
+ .st-overflowMenu__list {
148
+ background: var(--st-component-menu-background, var(--st-semantic-surface-raised));
149
+ border: 1px solid var(--st-component-menu-border, var(--st-semantic-border-subtle));
150
+ border-radius: var(--st-component-menu-radius, 0.375rem);
151
+ box-shadow: var(--st-component-menu-shadow, 0 8px 24px rgb(15 23 42 / 0.14));
152
+ display: grid;
153
+ list-style: none;
154
+ margin: 0;
155
+ min-width: 12rem;
156
+ padding: var(--st-spacing-1, 0.25rem);
157
+ position: absolute;
158
+ z-index: var(--st-component-popover-zIndex, 80);
159
+ }
160
+
161
+ .st-overflowMenu--bottom-end .st-overflowMenu__list {
162
+ right: 0;
163
+ top: calc(100% + var(--st-spacing-1, 0.25rem));
164
+ }
165
+
166
+ .st-overflowMenu--bottom-start .st-overflowMenu__list {
167
+ left: 0;
168
+ top: calc(100% + var(--st-spacing-1, 0.25rem));
169
+ }
170
+
171
+ .st-overflowMenu--top-end .st-overflowMenu__list {
172
+ bottom: calc(100% + var(--st-spacing-1, 0.25rem));
173
+ right: 0;
174
+ }
175
+
176
+ .st-overflowMenu--top-start .st-overflowMenu__list {
177
+ bottom: calc(100% + var(--st-spacing-1, 0.25rem));
178
+ left: 0;
179
+ }
180
+
181
+ .st-overflowMenu__listItem {
182
+ margin: 0;
183
+ padding: 0;
184
+ }
185
+
186
+ .st-overflowMenu__item {
187
+ background: transparent;
188
+ border: 0;
189
+ border-radius: var(--st-radius-small, 0.375rem);
190
+ color: var(--st-component-menu-text, var(--st-semantic-text-primary));
191
+ cursor: pointer;
192
+ display: block;
193
+ font: inherit;
194
+ padding: var(--st-spacing-2, 0.5rem) var(--st-spacing-3, 0.75rem);
195
+ text-align: left;
196
+ width: 100%;
197
+ }
198
+
199
+ .st-overflowMenu__item:hover:not(:disabled),
200
+ .st-overflowMenu__item:focus-visible {
201
+ background: var(--st-component-menu-itemHoverBackground, var(--st-semantic-surface-subtle));
202
+ outline: none;
203
+ }
204
+
205
+ .st-overflowMenu__item:disabled {
206
+ color: var(--st-component-menu-disabledText, var(--st-semantic-text-muted));
207
+ cursor: not-allowed;
208
+ }
209
+
210
+ .st-overflowMenu__item--danger {
211
+ color: var(--st-component-overflowMenu-dangerText, var(--st-semantic-feedback-error));
212
+ }
213
+
214
+ .st-overflowMenu__item--danger:hover:not(:disabled),
215
+ .st-overflowMenu__item--danger:focus-visible {
216
+ background: var(
217
+ --st-component-overflowMenu-dangerHoverBackground,
218
+ var(--st-semantic-feedback-error)
219
+ );
220
+ color: var(--st-component-overflowMenu-dangerHoverText, var(--st-semantic-action-primaryText));
221
+ }
222
+ </style>
@@ -0,0 +1,21 @@
1
+ export interface OverflowMenuItem {
2
+ value: string;
3
+ label: string;
4
+ disabled?: boolean;
5
+ danger?: boolean;
6
+ onclick?: () => void;
7
+ }
8
+ import type { HTMLAttributes } from "svelte/elements";
9
+ type OverflowMenuProps = Omit<HTMLAttributes<HTMLDivElement>, "class" | "onselect"> & {
10
+ items: OverflowMenuItem[];
11
+ label?: string;
12
+ open?: boolean;
13
+ placement?: "bottom-start" | "bottom-end" | "top-start" | "top-end";
14
+ class?: string;
15
+ triggerLabel?: string;
16
+ onselect?: (value: string) => void;
17
+ };
18
+ declare const OverflowMenu: import("svelte").Component<OverflowMenuProps, {}, "open">;
19
+ type OverflowMenu = ReturnType<typeof OverflowMenu>;
20
+ export default OverflowMenu;
21
+ //# sourceMappingURL=OverflowMenu.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OverflowMenu.svelte.d.ts","sourceRoot":"","sources":["../src/lib/OverflowMenu.svelte.ts"],"names":[],"mappings":"AAGE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,KAAK,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC,GAAG;IACpF,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,cAAc,GAAG,YAAY,GAAG,WAAW,GAAG,SAAS,CAAC;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC,CAAC;AA+EJ,QAAA,MAAM,YAAY,2DAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
@@ -0,0 +1,219 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from "svelte/elements";
3
+
4
+ type PaginationNavProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
5
+ page: number;
6
+ pageCount: number;
7
+ siblings?: number;
8
+ label?: string;
9
+ previousLabel?: string;
10
+ nextLabel?: string;
11
+ class?: string;
12
+ onPageChange?: (page: number) => void;
13
+ };
14
+
15
+ let {
16
+ page = $bindable(1),
17
+ pageCount,
18
+ siblings = 1,
19
+ label = "Pagination",
20
+ previousLabel = "Previous page",
21
+ nextLabel = "Next page",
22
+ class: className,
23
+ onPageChange,
24
+ ...rest
25
+ }: PaginationNavProps = $props();
26
+
27
+ type Slot = number | "ellipsis-start" | "ellipsis-end";
28
+
29
+ const classes = () => ["st-paginationNav", className].filter(Boolean).join(" ");
30
+
31
+ const slots = $derived.by<Slot[]>(() => {
32
+ const total = Math.max(0, Math.floor(pageCount));
33
+ if (total <= 0) return [];
34
+
35
+ const current = Math.min(Math.max(1, Math.floor(page)), total);
36
+ const sib = Math.max(0, Math.floor(siblings));
37
+
38
+ // Minimum: first, last, current, sib left, sib right, two ellipses
39
+ const minSlots = sib * 2 + 5;
40
+ if (total <= minSlots) {
41
+ return Array.from({ length: total }, (_, i) => i + 1) as Slot[];
42
+ }
43
+
44
+ const leftSibling = Math.max(current - sib, 1);
45
+ const rightSibling = Math.min(current + sib, total);
46
+ const showLeftEllipsis = leftSibling > 2;
47
+ const showRightEllipsis = rightSibling < total - 1;
48
+
49
+ const result: Slot[] = [];
50
+
51
+ if (!showLeftEllipsis && showRightEllipsis) {
52
+ const leftItemCount = 3 + sib * 2;
53
+ for (let i = 1; i <= leftItemCount; i += 1) result.push(i);
54
+ result.push("ellipsis-end");
55
+ result.push(total);
56
+ } else if (showLeftEllipsis && !showRightEllipsis) {
57
+ result.push(1);
58
+ result.push("ellipsis-start");
59
+ const rightItemCount = 3 + sib * 2;
60
+ for (let i = total - rightItemCount + 1; i <= total; i += 1) result.push(i);
61
+ } else if (showLeftEllipsis && showRightEllipsis) {
62
+ result.push(1);
63
+ result.push("ellipsis-start");
64
+ for (let i = leftSibling; i <= rightSibling; i += 1) result.push(i);
65
+ result.push("ellipsis-end");
66
+ result.push(total);
67
+ } else {
68
+ for (let i = 1; i <= total; i += 1) result.push(i);
69
+ }
70
+
71
+ return result;
72
+ });
73
+
74
+ function go(target: number) {
75
+ const total = Math.max(0, Math.floor(pageCount));
76
+ if (target < 1 || target > total || target === page) return;
77
+ page = target;
78
+ onPageChange?.(target);
79
+ }
80
+ </script>
81
+
82
+ <nav {...rest} class={classes()} aria-label={label}>
83
+ <ul class="st-paginationNav__list">
84
+ <li>
85
+ <button
86
+ type="button"
87
+ class="st-paginationNav__nav"
88
+ aria-label={previousLabel}
89
+ disabled={page <= 1 || pageCount <= 0}
90
+ onclick={() => go(page - 1)}
91
+ >
92
+ <svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" focusable="false">
93
+ <path
94
+ d="M10 3 5 8l5 5"
95
+ fill="none"
96
+ stroke="currentColor"
97
+ stroke-width="1.6"
98
+ stroke-linecap="round"
99
+ stroke-linejoin="round"
100
+ />
101
+ </svg>
102
+ </button>
103
+ </li>
104
+ {#each slots as slot, index (typeof slot === "number" ? `p-${slot}` : `${slot}-${index}`)}
105
+ <li>
106
+ {#if slot === "ellipsis-start" || slot === "ellipsis-end"}
107
+ <span class="st-paginationNav__ellipsis" aria-hidden="true">…</span>
108
+ {:else}
109
+ <button
110
+ type="button"
111
+ class="st-paginationNav__page"
112
+ class:st-paginationNav__page--active={slot === page}
113
+ aria-label={`Page ${slot}`}
114
+ aria-current={slot === page ? "page" : undefined}
115
+ onclick={() => go(slot)}
116
+ >
117
+ {slot}
118
+ </button>
119
+ {/if}
120
+ </li>
121
+ {/each}
122
+ <li>
123
+ <button
124
+ type="button"
125
+ class="st-paginationNav__nav"
126
+ aria-label={nextLabel}
127
+ disabled={page >= pageCount || pageCount <= 0}
128
+ onclick={() => go(page + 1)}
129
+ >
130
+ <svg viewBox="0 0 16 16" width="14" height="14" aria-hidden="true" focusable="false">
131
+ <path
132
+ d="M6 3l5 5-5 5"
133
+ fill="none"
134
+ stroke="currentColor"
135
+ stroke-width="1.6"
136
+ stroke-linecap="round"
137
+ stroke-linejoin="round"
138
+ />
139
+ </svg>
140
+ </button>
141
+ </li>
142
+ </ul>
143
+ </nav>
144
+
145
+ <style>
146
+ .st-paginationNav {
147
+ color: var(--st-component-paginationNav-text, var(--st-semantic-text-primary));
148
+ display: inline-block;
149
+ }
150
+
151
+ .st-paginationNav__list {
152
+ align-items: center;
153
+ display: flex;
154
+ flex-wrap: wrap;
155
+ gap: var(--st-spacing-1, 0.25rem);
156
+ list-style: none;
157
+ margin: 0;
158
+ padding: 0;
159
+ }
160
+
161
+ .st-paginationNav__page,
162
+ .st-paginationNav__nav {
163
+ align-items: center;
164
+ background: var(--st-component-paginationNav-background, var(--st-semantic-surface-default));
165
+ border: 1px solid var(--st-component-paginationNav-border, var(--st-semantic-border-subtle));
166
+ border-radius: var(--st-component-paginationNav-radius, 0.375rem);
167
+ color: var(--st-component-paginationNav-text, var(--st-semantic-text-primary));
168
+ cursor: pointer;
169
+ display: inline-flex;
170
+ font: inherit;
171
+ font-size: 0.875rem;
172
+ height: 2.25rem;
173
+ justify-content: center;
174
+ min-width: 2.25rem;
175
+ padding: 0 0.5rem;
176
+ }
177
+
178
+ .st-paginationNav__page:hover:not(:disabled),
179
+ .st-paginationNav__nav:hover:not(:disabled) {
180
+ background: var(
181
+ --st-component-paginationNav-hoverBackground,
182
+ var(--st-semantic-surface-subtle)
183
+ );
184
+ }
185
+
186
+ .st-paginationNav__page:focus-visible,
187
+ .st-paginationNav__nav:focus-visible {
188
+ border-color: var(--st-component-control-focusRing, var(--st-semantic-border-interactive));
189
+ box-shadow: 0 0 0 2px var(--st-component-control-focusRing, var(--st-semantic-border-interactive));
190
+ outline: none;
191
+ }
192
+
193
+ .st-paginationNav__page--active {
194
+ background: var(--st-component-paginationNav-activeBackground, var(--st-semantic-action-primary));
195
+ border-color: var(--st-component-paginationNav-activeBackground, var(--st-semantic-action-primary));
196
+ color: var(--st-component-paginationNav-activeText, var(--st-semantic-action-primaryText));
197
+ }
198
+
199
+ .st-paginationNav__page--active:hover {
200
+ background: var(--st-component-paginationNav-activeBackground, var(--st-semantic-action-primary));
201
+ }
202
+
203
+ .st-paginationNav__page:disabled,
204
+ .st-paginationNav__nav:disabled {
205
+ color: var(--st-component-paginationNav-disabledText, var(--st-semantic-text-muted));
206
+ cursor: not-allowed;
207
+ opacity: 0.6;
208
+ }
209
+
210
+ .st-paginationNav__ellipsis {
211
+ align-items: center;
212
+ color: var(--st-component-paginationNav-ellipsisText, var(--st-semantic-text-muted));
213
+ display: inline-flex;
214
+ height: 2.25rem;
215
+ justify-content: center;
216
+ min-width: 2.25rem;
217
+ padding: 0 0.25rem;
218
+ }
219
+ </style>
@@ -0,0 +1,15 @@
1
+ import type { HTMLAttributes } from "svelte/elements";
2
+ type PaginationNavProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
3
+ page: number;
4
+ pageCount: number;
5
+ siblings?: number;
6
+ label?: string;
7
+ previousLabel?: string;
8
+ nextLabel?: string;
9
+ class?: string;
10
+ onPageChange?: (page: number) => void;
11
+ };
12
+ declare const PaginationNav: import("svelte").Component<PaginationNavProps, {}, "page">;
13
+ type PaginationNav = ReturnType<typeof PaginationNav>;
14
+ export default PaginationNav;
15
+ //# sourceMappingURL=PaginationNav.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PaginationNav.svelte.d.ts","sourceRoot":"","sources":["../src/lib/PaginationNav.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,KAAK,kBAAkB,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,GAAG;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC;AA2GJ,QAAA,MAAM,aAAa,4DAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}