@placeholderco/placeholder-ui 1.0.11 → 2.0.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.
- package/LICENSE +1 -1
- package/README.md +134 -130
- package/dist/app.css +178 -0
- package/dist/bootstrap.min.css +3600 -0
- package/dist/cards/GitCard.svelte +115 -0
- package/dist/cards/GitCard.svelte.d.ts +22 -0
- package/dist/display/Avatar.svelte +29 -17
- package/dist/display/Avatar.svelte.d.ts +12 -2
- package/dist/display/LinkCollection.svelte +40 -18
- package/dist/display/LinkCollection.svelte.d.ts +9 -2
- package/dist/display/Paper.svelte +31 -19
- package/dist/display/Paper.svelte.d.ts +12 -3
- package/dist/display/alert/Alert.svelte +129 -0
- package/dist/display/alert/Alert.svelte.d.ts +15 -0
- package/dist/display/alert/AlertVariant.d.ts +1 -0
- package/dist/display/alert/AlertVariant.js +1 -0
- package/dist/display/filetree/FileTree.svelte +259 -0
- package/dist/display/filetree/FileTree.svelte.d.ts +76 -0
- package/dist/display/filetree/FileTreeItem.svelte +396 -0
- package/dist/display/filetree/FileTreeItem.svelte.d.ts +40 -0
- package/dist/display/filetree/FileTreeNode.d.ts +46 -0
- package/dist/display/filetree/FileTreeNode.js +115 -0
- package/dist/display/filetree/index.d.ts +5 -0
- package/dist/display/filetree/index.js +3 -0
- package/dist/editors/CodeMirror.svelte +306 -0
- package/dist/editors/CodeMirror.svelte.d.ts +31 -0
- package/dist/editors/tiptap/LinkActionMenu.svelte +307 -0
- package/dist/editors/tiptap/LinkActionMenu.svelte.d.ts +8 -0
- package/dist/editors/tiptap/TipTap.svelte +856 -0
- package/dist/editors/tiptap/TipTap.svelte.d.ts +54 -0
- package/dist/editors/tiptap/TipTapBubble.svelte +790 -0
- package/dist/editors/tiptap/TipTapBubble.svelte.d.ts +44 -0
- package/dist/editors/tiptap/collaboration.d.ts +55 -0
- package/dist/editors/tiptap/collaboration.js +1 -0
- package/dist/editors/tiptap/extensions/Alert.d.ts +18 -0
- package/dist/editors/tiptap/extensions/Alert.js +72 -0
- package/dist/editors/tiptap/extensions/CodeBlockEditor.d.ts +21 -0
- package/dist/editors/tiptap/extensions/CodeBlockEditor.js +326 -0
- package/dist/editors/tiptap/extensions/Div.d.ts +19 -0
- package/dist/editors/tiptap/extensions/Div.js +89 -0
- package/dist/editors/tiptap/extensions/Span.d.ts +5 -0
- package/dist/editors/tiptap/extensions/Span.js +56 -0
- package/dist/editors/tiptap/extensions/codeBlockEditor.css +236 -0
- package/dist/editors/tiptap/extensions/codeBlockLanguages.d.ts +17 -0
- package/dist/editors/tiptap/extensions/codeBlockLanguages.js +124 -0
- package/dist/editors/tiptap/extensions/index.d.ts +7 -0
- package/dist/editors/tiptap/extensions/index.js +5 -0
- package/dist/editors/tiptap/toolbar/AlertButton.svelte +261 -0
- package/dist/editors/tiptap/toolbar/AlertButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/AlignCenterButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/AlignCenterButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/AlignJustifyButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/AlignJustifyButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/AlignLeftButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/AlignLeftButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/AlignRightButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/AlignRightButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/BoldButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/BoldButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/BulletListButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/BulletListButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/CodeBlockButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/CodeBlockButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/CodeButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/CodeButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/ColorButton.svelte +299 -0
- package/dist/editors/tiptap/toolbar/ColorButton.svelte.d.ts +20 -0
- package/dist/editors/tiptap/toolbar/DocumentButton.svelte +58 -0
- package/dist/editors/tiptap/toolbar/DocumentButton.svelte.d.ts +9 -0
- package/dist/editors/tiptap/toolbar/HeadingButton.svelte +30 -0
- package/dist/editors/tiptap/toolbar/HeadingButton.svelte.d.ts +8 -0
- package/dist/editors/tiptap/toolbar/HtmlButton.svelte +68 -0
- package/dist/editors/tiptap/toolbar/HtmlButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/ImageButton.svelte +54 -0
- package/dist/editors/tiptap/toolbar/ImageButton.svelte.d.ts +8 -0
- package/dist/editors/tiptap/toolbar/ItalicButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/ItalicButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/LinkButton.svelte +257 -0
- package/dist/editors/tiptap/toolbar/LinkButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/OrderedListButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/OrderedListButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/RedoButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/RedoButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/StrikethroughButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/StrikethroughButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/SubscriptButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/SubscriptButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/SuperscriptButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/SuperscriptButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/TableButton.svelte +258 -0
- package/dist/editors/tiptap/toolbar/TableButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/ToolbarButton.svelte +84 -0
- package/dist/editors/tiptap/toolbar/ToolbarButton.svelte.d.ts +10 -0
- package/dist/editors/tiptap/toolbar/UnderlineButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/UnderlineButton.svelte.d.ts +7 -0
- package/dist/editors/tiptap/toolbar/UndoButton.svelte +18 -0
- package/dist/editors/tiptap/toolbar/UndoButton.svelte.d.ts +7 -0
- package/dist/form/Autocomplete.svelte +270 -137
- package/dist/form/Autocomplete.svelte.d.ts +58 -10
- package/dist/form/AutocompleteMulti.svelte +385 -227
- package/dist/form/AutocompleteMulti.svelte.d.ts +59 -10
- package/dist/form/Checkbox.svelte +124 -43
- package/dist/form/Checkbox.svelte.d.ts +26 -2
- package/dist/form/Chips.svelte +47 -17
- package/dist/form/Chips.svelte.d.ts +24 -3
- package/dist/form/ComboBox.svelte +30 -20
- package/dist/form/ComboBox.svelte.d.ts +1 -1
- package/dist/form/ComboBoxItemBuilder.svelte +161 -188
- package/dist/form/ComboBoxItemBuilder.svelte.d.ts +19 -2
- package/dist/form/ComboBoxMulti.svelte +38 -24
- package/dist/form/ComboBoxMulti.svelte.d.ts +1 -1
- package/dist/form/CronBuilder.svelte +84 -67
- package/dist/form/CronBuilder.svelte.d.ts +16 -3
- package/dist/form/DatePicker.svelte +177 -191
- package/dist/form/DatePicker.svelte.d.ts +17 -2
- package/dist/form/DateRangePicker.svelte +775 -0
- package/dist/form/DateRangePicker.svelte.d.ts +23 -0
- package/dist/form/DateTimePicker.svelte +168 -209
- package/dist/form/DateTimePicker.svelte.d.ts +10 -2
- package/dist/form/FormGroup.svelte +33 -10
- package/dist/form/FormGroup.svelte.d.ts +12 -2
- package/dist/form/Number.svelte +71 -29
- package/dist/form/Number.svelte.d.ts +39 -6
- package/dist/form/Radio.svelte +174 -0
- package/dist/form/Radio.svelte.d.ts +21 -0
- package/dist/form/RadioGroup.svelte +52 -138
- package/dist/form/RadioGroup.svelte.d.ts +19 -2
- package/dist/form/SegmentedControl.svelte +103 -57
- package/dist/form/SegmentedControl.svelte.d.ts +12 -2
- package/dist/form/Select.svelte +160 -229
- package/dist/form/Select.svelte.d.ts +35 -6
- package/dist/form/SelectMulti.svelte +166 -277
- package/dist/form/SelectMulti.svelte.d.ts +37 -6
- package/dist/form/Slider.svelte +185 -268
- package/dist/form/Slider.svelte.d.ts +33 -16
- package/dist/form/StringArrayBuilder.svelte +249 -0
- package/dist/form/StringArrayBuilder.svelte.d.ts +15 -0
- package/dist/form/Switch.svelte +164 -106
- package/dist/form/Switch.svelte.d.ts +22 -3
- package/dist/form/TextArea.svelte +80 -45
- package/dist/form/TextArea.svelte.d.ts +35 -10
- package/dist/form/Textbox.svelte +80 -47
- package/dist/form/Textbox.svelte.d.ts +41 -8
- package/dist/form/TimePicker.svelte +42 -47
- package/dist/form/TimePicker.svelte.d.ts +12 -2
- package/dist/form/comboBoxCore.svelte.d.ts +99 -0
- package/dist/form/comboBoxCore.svelte.js +243 -0
- package/dist/icon/Icon.svelte +8 -3
- package/dist/icon/Icon.svelte.d.ts +8 -3
- package/dist/icon/cube-send.svg +1 -0
- package/dist/icon/file-type-bmp.svg +1 -0
- package/dist/icon/file-type-csv.svg +1 -0
- package/dist/icon/file-type-doc.svg +1 -0
- package/dist/icon/file-type-docx.svg +1 -0
- package/dist/icon/file-type-jpg.svg +1 -0
- package/dist/icon/file-type-pdf.svg +1 -0
- package/dist/icon/file-type-png.svg +1 -0
- package/dist/icon/file-type-ppt.svg +1 -0
- package/dist/icon/file-type-svg.svg +1 -0
- package/dist/icon/file-type-txt.svg +1 -0
- package/dist/icon/file-type-xls.svg +1 -0
- package/dist/icon/file-type-zip.svg +1 -0
- package/dist/icon/index.d.ts +166 -145
- package/dist/icon/index.js +166 -146
- package/dist/icon/layout-sidebar-left-collapse.svg +1 -0
- package/dist/icon/layout-sidebar-left-expand.svg +1 -0
- package/dist/icon/logo-placeholder.svg +6 -0
- package/dist/icon/paperclip.svg +1 -0
- package/dist/icon/source-code.svg +1 -0
- package/dist/icon/sun-moon.svg +1 -0
- package/dist/icon/table.svg +6 -0
- package/dist/icon/thumb-down.svg +1 -0
- package/dist/icon/thumb-up.svg +1 -0
- package/dist/index.d.ts +93 -22
- package/dist/index.js +28 -27
- package/dist/layout/AppShell.svelte +12 -162
- package/dist/layout/AppShell.svelte.d.ts +6 -27
- package/dist/layout/CustomNavbar.svelte +9 -7
- package/dist/layout/CustomNavbar.svelte.d.ts +4 -2
- package/dist/layout/Navbar.svelte +158 -110
- package/dist/layout/Navbar.svelte.d.ts +26 -12
- package/dist/layout/NavbarItemDisplay.svelte +2 -2
- package/dist/layout/NavbarItemView.svelte +182 -0
- package/dist/layout/NavbarItemView.svelte.d.ts +10 -0
- package/dist/layout/Sidenav.svelte +280 -341
- package/dist/layout/Sidenav.svelte.d.ts +36 -4
- package/dist/models/ComboBoxItem.d.ts +2 -0
- package/dist/models/Employee.d.ts +53 -0
- package/dist/models/Employee.js +23 -0
- package/dist/models/Hyperlink.d.ts +3 -1
- package/dist/models/LinkCollectionItem.d.ts +3 -1
- package/dist/models/NavbarItem.d.ts +6 -2
- package/dist/theme.svelte.d.ts +0 -1
- package/dist/theme.svelte.js +46 -58
- package/dist/ui/Accordion.svelte +81 -242
- package/dist/ui/Accordion.svelte.d.ts +37 -14
- package/dist/ui/AccordionItem.svelte +303 -0
- package/dist/ui/AccordionItem.svelte.d.ts +21 -0
- package/dist/ui/ActionIcon.svelte +25 -21
- package/dist/ui/ActionIcon.svelte.d.ts +15 -2
- package/dist/ui/Badge.svelte +170 -161
- package/dist/ui/Badge.svelte.d.ts +16 -4
- package/dist/ui/Button.svelte +178 -205
- package/dist/ui/Button.svelte.d.ts +19 -2
- package/dist/ui/ButtonVariant.d.ts +15 -1
- package/dist/ui/ContextMenu.svelte +146 -0
- package/dist/ui/ContextMenu.svelte.d.ts +37 -0
- package/dist/ui/ContextMenuList.svelte +188 -0
- package/dist/ui/ContextMenuList.svelte.d.ts +12 -0
- package/dist/ui/Dialog.svelte +183 -104
- package/dist/ui/Dialog.svelte.d.ts +21 -2
- package/dist/ui/Drawer.svelte +237 -184
- package/dist/ui/Drawer.svelte.d.ts +20 -2
- package/dist/ui/Dropdown.svelte +24 -14
- package/dist/ui/Dropdown.svelte.d.ts +11 -2
- package/dist/ui/Dropzone.svelte +159 -57
- package/dist/ui/Dropzone.svelte.d.ts +29 -2
- package/dist/ui/Link.svelte +12 -4
- package/dist/ui/Link.svelte.d.ts +8 -2
- package/dist/ui/Loader.svelte +23 -18
- package/dist/ui/Loader.svelte.d.ts +5 -2
- package/dist/ui/Logo.svelte +37 -0
- package/dist/ui/Logo.svelte.d.ts +16 -0
- package/dist/ui/MultiSortable.svelte +287 -0
- package/dist/ui/MultiSortable.svelte.d.ts +50 -0
- package/dist/ui/Pagination.svelte +12 -6
- package/dist/ui/Pagination.svelte.d.ts +6 -2
- package/dist/ui/Popover.svelte +43 -65
- package/dist/ui/Popover.svelte.d.ts +14 -5
- package/dist/ui/ProgressBar.svelte +169 -0
- package/dist/ui/ProgressBar.svelte.d.ts +30 -0
- package/dist/ui/ProgressBarVariant.d.ts +7 -0
- package/dist/ui/ProgressBarVariant.js +1 -0
- package/dist/ui/SegmentedControl.svelte +0 -0
- package/dist/ui/SegmentedControl.svelte.d.ts +26 -0
- package/dist/ui/Sortable.svelte +163 -0
- package/dist/ui/Sortable.svelte.d.ts +47 -0
- package/dist/ui/Table.svelte +497 -56
- package/dist/ui/Table.svelte.d.ts +64 -2
- package/dist/ui/Tabs.svelte +22 -18
- package/dist/ui/Tabs.svelte.d.ts +6 -2
- package/dist/ui/ThemeSwitcher.svelte +26 -7
- package/dist/ui/ThemeSwitcher.svelte.d.ts +4 -2
- package/dist/ui/Tooltip.svelte +312 -180
- package/dist/ui/Tooltip.svelte.d.ts +4 -3
- package/dist/uiTheme.svelte.d.ts +86 -0
- package/dist/uiTheme.svelte.js +214 -0
- package/dist/util/DateFunctions.js +1 -1
- package/dist/util/DragDrop.d.ts +50 -0
- package/dist/util/DragDrop.js +154 -0
- package/dist/util/NavigateTo.js +2 -2
- package/dist/util/dayjs.d.ts +4 -0
- package/dist/util/dayjs.js +15 -0
- package/dist/util/interceptLinkClick.d.ts +13 -0
- package/dist/util/interceptLinkClick.js +33 -0
- package/package.json +66 -26
- package/dist/display/Alert.svelte +0 -179
- package/dist/display/Alert.svelte.d.ts +0 -13
- package/dist/form/FileInput.svelte +0 -235
- package/dist/form/FileInput.svelte.d.ts +0 -23
- package/dist/form/PasswordInput.svelte +0 -252
- package/dist/form/PasswordInput.svelte.d.ts +0 -33
- package/dist/form/Rating.svelte +0 -235
- package/dist/form/Rating.svelte.d.ts +0 -21
- package/dist/styles/components.css +0 -199
- package/dist/styles/dark.css +0 -146
- package/dist/styles/index.css +0 -116
- package/dist/styles/reset.css +0 -110
- package/dist/styles/semantic.css +0 -86
- package/dist/styles/tokens.css +0 -203
- package/dist/styles/utilities.css +0 -523
- package/dist/ui/Breadcrumbs.svelte +0 -131
- package/dist/ui/Breadcrumbs.svelte.d.ts +0 -16
- package/dist/ui/LoadingOverlay.svelte +0 -53
- package/dist/ui/LoadingOverlay.svelte.d.ts +0 -11
- package/dist/ui/Progress.svelte +0 -191
- package/dist/ui/Progress.svelte.d.ts +0 -15
- package/dist/ui/RingProgress.svelte +0 -141
- package/dist/ui/RingProgress.svelte.d.ts +0 -18
- package/dist/ui/Skeleton.svelte +0 -85
- package/dist/ui/Skeleton.svelte.d.ts +0 -12
- package/dist/ui/Stepper.svelte +0 -355
- package/dist/ui/Stepper.svelte.d.ts +0 -24
- package/dist/ui/Timeline.svelte +0 -225
- package/dist/ui/Timeline.svelte.d.ts +0 -23
- /package/dist/{actions → util}/ClickOutside.d.ts +0 -0
- /package/dist/{actions → util}/ClickOutside.js +0 -0
- /package/dist/{transitions → util}/Transitions.d.ts +0 -0
- /package/dist/{transitions → util}/Transitions.js +0 -0
package/dist/ui/Accordion.svelte
CHANGED
|
@@ -1,271 +1,110 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ButtonVariant } from './ButtonVariant.js';
|
|
4
|
+
|
|
5
|
+
export type AccordionSize = 'sm' | 'md';
|
|
6
|
+
|
|
7
|
+
export interface AccordionTitleContext {
|
|
8
|
+
/** Value of the item being rendered */
|
|
9
|
+
value: string;
|
|
10
|
+
/** The item's `title` prop */
|
|
4
11
|
title: string;
|
|
5
|
-
|
|
12
|
+
/** Whether the item is currently expanded */
|
|
13
|
+
open: boolean;
|
|
14
|
+
/** Whether the item is disabled */
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface AccordionContext {
|
|
19
|
+
/** Whether the given item value is currently expanded (reactive) */
|
|
20
|
+
isOpen: (value: string) => boolean;
|
|
21
|
+
/** Toggle the expanded state for the given item value */
|
|
22
|
+
toggle: (value: string) => void;
|
|
23
|
+
/** Accordion-level snippet used to render item titles */
|
|
24
|
+
readonly itemTitle?: Snippet<[AccordionTitleContext]>;
|
|
25
|
+
/** Size variant applied to all items */
|
|
26
|
+
readonly size: AccordionSize;
|
|
27
|
+
/** Colour variant applied to expanded item headers. Items can override individually */
|
|
28
|
+
readonly variant: ButtonVariant;
|
|
6
29
|
}
|
|
7
30
|
</script>
|
|
8
31
|
|
|
9
32
|
<script lang="ts">
|
|
10
|
-
import
|
|
11
|
-
import Icon from '../icon/Icon.svelte';
|
|
12
|
-
import { iconChevronDown } from '../icon/index.js';
|
|
33
|
+
import { setContext } from 'svelte';
|
|
13
34
|
|
|
14
|
-
interface
|
|
15
|
-
|
|
35
|
+
export interface AccordionProps {
|
|
36
|
+
/** Allow more than one item to be expanded at the same time */
|
|
16
37
|
multiple?: boolean;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
38
|
+
/** Value(s) of the expanded item(s) (bindable). String when `multiple` is false, array otherwise */
|
|
39
|
+
value?: string | string[];
|
|
40
|
+
/** Callback when the expanded value(s) change */
|
|
41
|
+
onchange?: (value: string | string[]) => void;
|
|
42
|
+
/** Size variant applied to all items */
|
|
43
|
+
size?: AccordionSize;
|
|
44
|
+
/** Colour scheme for expanded item headers, using the Button variants. Items can override individually */
|
|
45
|
+
variant?: ButtonVariant;
|
|
46
|
+
/** Custom snippet rendered as the title of every item. Item-level `header` snippets take precedence */
|
|
47
|
+
itemTitle?: Snippet<[AccordionTitleContext]>;
|
|
48
|
+
/** AccordionItem children */
|
|
24
49
|
children?: Snippet;
|
|
25
50
|
}
|
|
26
51
|
|
|
27
52
|
let {
|
|
28
|
-
items = [],
|
|
29
53
|
multiple = false,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class: classes = '',
|
|
36
|
-
itemContent,
|
|
54
|
+
value = $bindable(multiple ? [] : ''),
|
|
55
|
+
onchange,
|
|
56
|
+
size = 'md',
|
|
57
|
+
variant = 'primary',
|
|
58
|
+
itemTitle,
|
|
37
59
|
children
|
|
38
|
-
}:
|
|
60
|
+
}: AccordionProps = $props();
|
|
39
61
|
|
|
40
|
-
|
|
62
|
+
const openValues = $derived(
|
|
63
|
+
Array.isArray(value) ? value : value ? [value] : []
|
|
64
|
+
);
|
|
41
65
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
openItems = new Set(defaultOpen);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
66
|
+
function isOpen(itemValue: string): boolean {
|
|
67
|
+
return openValues.includes(itemValue);
|
|
68
|
+
}
|
|
48
69
|
|
|
49
|
-
function
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
function toggle(itemValue: string): void {
|
|
71
|
+
if (multiple) {
|
|
72
|
+
const current = Array.isArray(value) ? value : value ? [value] : [];
|
|
73
|
+
value = current.includes(itemValue)
|
|
74
|
+
? current.filter((v) => v !== itemValue)
|
|
75
|
+
: [...current, itemValue];
|
|
53
76
|
} else {
|
|
54
|
-
|
|
55
|
-
openItems.add(id);
|
|
56
|
-
openItems = new Set(openItems);
|
|
57
|
-
} else {
|
|
58
|
-
openItems = new Set([id]);
|
|
59
|
-
}
|
|
77
|
+
value = value === itemValue ? '' : itemValue;
|
|
60
78
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
79
|
+
onchange?.(value);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
setContext<AccordionContext>('accordion', {
|
|
83
|
+
isOpen,
|
|
84
|
+
toggle,
|
|
85
|
+
get itemTitle() {
|
|
86
|
+
return itemTitle;
|
|
87
|
+
},
|
|
88
|
+
get size() {
|
|
89
|
+
return size;
|
|
90
|
+
},
|
|
91
|
+
get variant() {
|
|
92
|
+
return variant;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
66
95
|
</script>
|
|
67
96
|
|
|
68
|
-
<div class="accordion
|
|
69
|
-
{
|
|
70
|
-
{@render children()}
|
|
71
|
-
{:else}
|
|
72
|
-
{#each items as item (item.id)}
|
|
73
|
-
{@const open = isOpen(item.id)}
|
|
74
|
-
<div class="accordion-item" class:open>
|
|
75
|
-
<button
|
|
76
|
-
class="accordion-control chevron-{chevronPosition}"
|
|
77
|
-
aria-expanded={open}
|
|
78
|
-
onclick={() => toggleItem(item.id)}
|
|
79
|
-
>
|
|
80
|
-
{#if chevronPosition === 'left'}
|
|
81
|
-
<span class="accordion-chevron" class:rotated={open && !disableChevronRotation}>
|
|
82
|
-
<Icon svg={iconChevronDown} size="18px" />
|
|
83
|
-
</span>
|
|
84
|
-
{/if}
|
|
85
|
-
<span class="accordion-title">{item.title}</span>
|
|
86
|
-
{#if chevronPosition === 'right'}
|
|
87
|
-
<span class="accordion-chevron" class:rotated={open && !disableChevronRotation}>
|
|
88
|
-
<Icon svg={iconChevronDown} size="18px" />
|
|
89
|
-
</span>
|
|
90
|
-
{/if}
|
|
91
|
-
</button>
|
|
92
|
-
<div class="accordion-panel" class:open aria-hidden={!open}>
|
|
93
|
-
<div class="accordion-content">
|
|
94
|
-
<div class="accordion-content-inner">
|
|
95
|
-
{#if itemContent}
|
|
96
|
-
{@render itemContent(item)}
|
|
97
|
-
{:else if item.content}
|
|
98
|
-
{item.content}
|
|
99
|
-
{/if}
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
{/each}
|
|
105
|
-
{/if}
|
|
97
|
+
<div class="accordion">
|
|
98
|
+
{@render children?.()}
|
|
106
99
|
</div>
|
|
107
100
|
|
|
108
101
|
<style>
|
|
109
102
|
.accordion {
|
|
110
|
-
width: 100%;
|
|
111
|
-
--_accordion-radius: var(--pui-radius-md);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/* Radius */
|
|
115
|
-
.radius-none { --_accordion-radius: 0; }
|
|
116
|
-
.radius-sm { --_accordion-radius: var(--pui-radius-sm); }
|
|
117
|
-
.radius-md { --_accordion-radius: var(--pui-radius-md); }
|
|
118
|
-
.radius-lg { --_accordion-radius: var(--pui-radius-lg); }
|
|
119
|
-
|
|
120
|
-
.accordion {
|
|
121
|
-
border-radius: var(--_accordion-radius);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/* Variants */
|
|
125
|
-
.variant-default .accordion-item {
|
|
126
|
-
border-bottom: 1px solid var(--pui-border-default);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
:global(.dark) .variant-default .accordion-item {
|
|
130
|
-
border-bottom-color: var(--pui-color-dark-border);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.variant-contained {
|
|
134
|
-
border: 1px solid var(--pui-border-default);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
:global(.dark) .variant-contained {
|
|
138
|
-
border-color: var(--pui-color-dark-border);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.variant-contained .accordion-item:not(:last-child) {
|
|
142
|
-
border-bottom: 1px solid var(--pui-border-default);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
:global(.dark) .variant-contained .accordion-item:not(:last-child) {
|
|
146
|
-
border-bottom-color: var(--pui-color-dark-border);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
.variant-filled .accordion-item {
|
|
150
|
-
background-color: var(--pui-bg-surface-raised);
|
|
151
|
-
margin-bottom: var(--pui-spacing-2);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
:global(.dark) .variant-filled .accordion-item {
|
|
155
|
-
background-color: var(--pui-color-dark-200);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.variant-separated .accordion-item {
|
|
159
|
-
border: 1px solid var(--pui-border-default);
|
|
160
|
-
margin-bottom: var(--pui-spacing-2);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
:global(.dark) .variant-separated .accordion-item {
|
|
164
|
-
border-color: var(--pui-color-dark-border);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/* Item radius — contained/default: first/last corners; filled/separated: all corners */
|
|
168
|
-
.variant-default .accordion-item:first-child,
|
|
169
|
-
.variant-contained .accordion-item:first-child {
|
|
170
|
-
border-top-left-radius: var(--_accordion-radius);
|
|
171
|
-
border-top-right-radius: var(--_accordion-radius);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.variant-default .accordion-item:last-child,
|
|
175
|
-
.variant-contained .accordion-item:last-child {
|
|
176
|
-
border-bottom-left-radius: var(--_accordion-radius);
|
|
177
|
-
border-bottom-right-radius: var(--_accordion-radius);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
.variant-filled .accordion-item,
|
|
181
|
-
.variant-separated .accordion-item {
|
|
182
|
-
border-radius: var(--_accordion-radius);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.accordion-item {
|
|
186
|
-
overflow: hidden;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.accordion-control {
|
|
190
|
-
width: 100%;
|
|
191
|
-
display: flex;
|
|
192
|
-
align-items: center;
|
|
193
|
-
gap: var(--pui-spacing-2);
|
|
194
|
-
padding: var(--pui-spacing-3) var(--pui-spacing-4);
|
|
195
|
-
background: none;
|
|
196
|
-
border: none;
|
|
197
|
-
cursor: pointer;
|
|
198
|
-
font-family: inherit;
|
|
199
|
-
font-size: var(--pui-font-size-base);
|
|
200
|
-
font-weight: var(--pui-font-weight-medium);
|
|
201
|
-
color: var(--pui-text-primary);
|
|
202
|
-
text-align: left;
|
|
203
|
-
transition: background-color var(--pui-transition-fast) var(--pui-ease-in-out);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
:global(.dark) .accordion-control {
|
|
207
|
-
color: var(--pui-color-gray-100);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
.accordion-item.open > .accordion-control {
|
|
211
|
-
background-color: var(--pui-bg-surface-raised);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
:global(.dark) .accordion-item.open > .accordion-control {
|
|
215
|
-
background-color: rgba(255, 255, 255, 0.06);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
.accordion-control:hover {
|
|
219
|
-
background-color: var(--pui-bg-hover);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
:global(.dark) .accordion-control:hover {
|
|
223
|
-
background-color: rgba(255, 255, 255, 0.08);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.accordion-control:focus-visible {
|
|
227
|
-
outline: var(--pui-focus-ring-width) solid var(--pui-focus-ring-color);
|
|
228
|
-
outline-offset: calc(-1 * var(--pui-focus-ring-width));
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
.accordion-title {
|
|
232
|
-
flex: 1;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
.accordion-chevron {
|
|
236
103
|
display: flex;
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
color: var(--pui-text-muted);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
.accordion-chevron.rotated {
|
|
244
|
-
transform: rotate(180deg);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
.accordion-panel {
|
|
248
|
-
display: grid;
|
|
249
|
-
grid-template-rows: 0fr;
|
|
250
|
-
transition: grid-template-rows var(--pui-transition-base) var(--pui-ease-in-out);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.accordion-panel.open {
|
|
254
|
-
grid-template-rows: 1fr;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
.accordion-content {
|
|
104
|
+
flex-direction: column;
|
|
105
|
+
border: 1px solid var(--border-color);
|
|
106
|
+
border-radius: 0.375rem;
|
|
258
107
|
overflow: hidden;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
.accordion-content-inner {
|
|
262
|
-
padding: var(--pui-spacing-2) var(--pui-spacing-4) var(--pui-spacing-4);
|
|
263
|
-
color: var(--pui-text-secondary);
|
|
264
|
-
font-size: var(--pui-font-size-sm);
|
|
265
|
-
line-height: var(--pui-line-height-relaxed);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
:global(.dark) .accordion-content-inner {
|
|
269
|
-
color: var(--pui-color-gray-300);
|
|
108
|
+
background: var(--paper-body-bg);
|
|
270
109
|
}
|
|
271
110
|
</style>
|
|
@@ -1,21 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ButtonVariant } from './ButtonVariant.js';
|
|
3
|
+
export type AccordionSize = 'sm' | 'md';
|
|
4
|
+
export interface AccordionTitleContext {
|
|
5
|
+
/** Value of the item being rendered */
|
|
6
|
+
value: string;
|
|
7
|
+
/** The item's `title` prop */
|
|
3
8
|
title: string;
|
|
4
|
-
|
|
9
|
+
/** Whether the item is currently expanded */
|
|
10
|
+
open: boolean;
|
|
11
|
+
/** Whether the item is disabled */
|
|
12
|
+
disabled: boolean;
|
|
5
13
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
export interface AccordionContext {
|
|
15
|
+
/** Whether the given item value is currently expanded (reactive) */
|
|
16
|
+
isOpen: (value: string) => boolean;
|
|
17
|
+
/** Toggle the expanded state for the given item value */
|
|
18
|
+
toggle: (value: string) => void;
|
|
19
|
+
/** Accordion-level snippet used to render item titles */
|
|
20
|
+
readonly itemTitle?: Snippet<[AccordionTitleContext]>;
|
|
21
|
+
/** Size variant applied to all items */
|
|
22
|
+
readonly size: AccordionSize;
|
|
23
|
+
/** Colour variant applied to expanded item headers. Items can override individually */
|
|
24
|
+
readonly variant: ButtonVariant;
|
|
25
|
+
}
|
|
26
|
+
export interface AccordionProps {
|
|
27
|
+
/** Allow more than one item to be expanded at the same time */
|
|
9
28
|
multiple?: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
/** Value(s) of the expanded item(s) (bindable). String when `multiple` is false, array otherwise */
|
|
30
|
+
value?: string | string[];
|
|
31
|
+
/** Callback when the expanded value(s) change */
|
|
32
|
+
onchange?: (value: string | string[]) => void;
|
|
33
|
+
/** Size variant applied to all items */
|
|
34
|
+
size?: AccordionSize;
|
|
35
|
+
/** Colour scheme for expanded item headers, using the Button variants. Items can override individually */
|
|
36
|
+
variant?: ButtonVariant;
|
|
37
|
+
/** Custom snippet rendered as the title of every item. Item-level `header` snippets take precedence */
|
|
38
|
+
itemTitle?: Snippet<[AccordionTitleContext]>;
|
|
39
|
+
/** AccordionItem children */
|
|
17
40
|
children?: Snippet;
|
|
18
41
|
}
|
|
19
|
-
declare const Accordion: import("svelte").Component<
|
|
42
|
+
declare const Accordion: import("svelte").Component<AccordionProps, {}, "value">;
|
|
20
43
|
type Accordion = ReturnType<typeof Accordion>;
|
|
21
44
|
export default Accordion;
|