bref-ui 0.3.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/cli/commands/add/approve-overwrites.ts +17 -0
- package/cli/commands/add/display-changes.ts +11 -0
- package/cli/commands/add/index.ts +30 -0
- package/cli/commands/add/review-changes.ts +18 -0
- package/cli/commands/add/utils.ts +11 -0
- package/cli/commands/execute.ts +39 -0
- package/cli/commands/index.ts +19 -0
- package/cli/commands/init.ts +17 -0
- package/cli/commands/parse.ts +24 -0
- package/cli/commands/types.ts +2 -0
- package/cli/config/read/index.ts +15 -0
- package/cli/config/read/normalize-config.ts +21 -0
- package/cli/config/read/read-config-file.ts +13 -0
- package/cli/config/resolve/index.ts +20 -0
- package/cli/config/resolve/resolve-alias-target.ts +17 -0
- package/cli/config/resolve/resolve-alias.ts +17 -0
- package/cli/config/types.ts +5 -0
- package/cli/index.ts +4 -0
- package/cli/installation/copy/index.ts +25 -0
- package/cli/installation/copy/validate-overwrite-approvals.ts +18 -0
- package/cli/installation/copy/write-prepared-files.ts +26 -0
- package/cli/installation/exports/collect-exports.ts +19 -0
- package/cli/installation/exports/create-additions.ts +26 -0
- package/cli/installation/exports/index.ts +27 -0
- package/cli/installation/exports/merge-content.ts +12 -0
- package/cli/installation/exports/read-declared-export-names.ts +24 -0
- package/cli/installation/exports/read-exported-names.ts +21 -0
- package/cli/installation/exports/read-index.ts +14 -0
- package/cli/installation/exports/read-reexported-names.ts +24 -0
- package/cli/installation/exports/types.ts +10 -0
- package/cli/installation/exports/utils.ts +54 -0
- package/cli/installation/index.ts +35 -0
- package/cli/installation/parser/index.ts +29 -0
- package/cli/installation/parser/types.ts +12 -0
- package/cli/installation/parser/utils.ts +45 -0
- package/cli/installation/prepare/collect-source-files.ts +15 -0
- package/cli/installation/prepare/index.ts +15 -0
- package/cli/installation/prepare/read-source-files.ts +21 -0
- package/cli/installation/prepare/rewrite-imports.ts +50 -0
- package/cli/installation/prepare/rewrite-source.ts +36 -0
- package/cli/installation/prepare/types.ts +7 -0
- package/cli/installation/preview/compare-prepared-files.ts +18 -0
- package/cli/installation/preview/index.ts +18 -0
- package/cli/installation/preview/read-destination-files.ts +25 -0
- package/cli/installation/preview/types.ts +9 -0
- package/cli/installation/types.ts +15 -0
- package/cli/pack.ts +6 -0
- package/cli/registry/load/create-registry.ts +25 -0
- package/cli/registry/load/discover-manifests.ts +9 -0
- package/cli/registry/load/index.ts +21 -0
- package/cli/registry/load/load-entry.ts +22 -0
- package/cli/registry/load/utils.ts +70 -0
- package/cli/registry/load/validate-dependencies.ts +33 -0
- package/cli/registry/plan/collect-entries.ts +28 -0
- package/cli/registry/plan/index.ts +14 -0
- package/cli/registry/types.ts +17 -0
- package/dist/button/button.svelte +126 -0
- package/dist/button/button.svelte.d.ts +4 -0
- package/dist/button/registry.json +6 -0
- package/dist/button/types.d.ts +32 -0
- package/dist/checkbox/checkbox.svelte +143 -0
- package/dist/checkbox/checkbox.svelte.d.ts +4 -0
- package/dist/checkbox/registry.json +6 -0
- package/dist/checkbox/types.d.ts +6 -0
- package/dist/combobox/combobox.svelte +156 -0
- package/dist/combobox/combobox.svelte.d.ts +4 -0
- package/dist/combobox/form.svelte +61 -0
- package/dist/combobox/form.svelte.d.ts +4 -0
- package/dist/combobox/input.svelte +132 -0
- package/dist/combobox/input.svelte.d.ts +4 -0
- package/dist/combobox/list.svelte +78 -0
- package/dist/combobox/list.svelte.d.ts +4 -0
- package/dist/combobox/option.svelte +77 -0
- package/dist/combobox/option.svelte.d.ts +4 -0
- package/dist/combobox/registry.json +6 -0
- package/dist/combobox/types.d.ts +61 -0
- package/dist/dialog/dialog.svelte +182 -0
- package/dist/dialog/dialog.svelte.d.ts +4 -0
- package/dist/dialog/footer.svelte +26 -0
- package/dist/dialog/footer.svelte.d.ts +7 -0
- package/dist/dialog/header.svelte +56 -0
- package/dist/dialog/header.svelte.d.ts +4 -0
- package/dist/dialog/registry.json +6 -0
- package/dist/dialog/types.d.ts +31 -0
- package/dist/icon/icon.svelte +108 -0
- package/dist/icon/icon.svelte.d.ts +4 -0
- package/dist/icon/names.d.ts +7 -0
- package/dist/icon/registry.json +6 -0
- package/dist/icon/types.d.ts +16 -0
- package/dist/index.d.ts +20 -2
- package/dist/index.js +20 -2
- package/dist/pill/content.svelte +23 -0
- package/dist/pill/content.svelte.d.ts +4 -0
- package/dist/pill/on-delete.svelte +26 -0
- package/dist/pill/on-delete.svelte.d.ts +4 -0
- package/dist/pill/pill.svelte +200 -0
- package/dist/{base/pill → pill}/pill.svelte.d.ts +1 -1
- package/dist/pill/registry.json +6 -0
- package/dist/pill/types.d.ts +19 -0
- package/dist/pill-choice-group/pill-choice-group.svelte +131 -0
- package/dist/pill-choice-group/pill-choice-group.svelte.d.ts +4 -0
- package/dist/pill-choice-group/registry.json +6 -0
- package/dist/pill-choice-group/types.d.ts +13 -0
- package/dist/pill-group/container.svelte +40 -0
- package/dist/pill-group/container.svelte.d.ts +4 -0
- package/dist/pill-group/pill-group.svelte +27 -0
- package/dist/pill-group/pill-group.svelte.d.ts +4 -0
- package/dist/pill-group/registry.json +6 -0
- package/dist/pill-group/types.d.ts +13 -0
- package/dist/popover/popover.svelte +86 -0
- package/dist/popover/popover.svelte.d.ts +4 -0
- package/dist/popover/registry.json +6 -0
- package/dist/popover/types.d.ts +8 -0
- package/dist/progress/progress.svelte +256 -0
- package/dist/progress/progress.svelte.d.ts +4 -0
- package/dist/progress/registry.json +6 -0
- package/dist/progress/types.d.ts +11 -0
- package/dist/select/empty.svelte +25 -0
- package/dist/select/empty.svelte.d.ts +4 -0
- package/dist/select/list.svelte +27 -0
- package/dist/select/list.svelte.d.ts +4 -0
- package/dist/select/option.svelte +64 -0
- package/dist/select/option.svelte.d.ts +4 -0
- package/dist/select/registry.json +6 -0
- package/dist/select/select.svelte +70 -0
- package/dist/{base/select → select}/select.svelte.d.ts +2 -2
- package/dist/select/trigger.svelte +86 -0
- package/dist/select/trigger.svelte.d.ts +4 -0
- package/dist/select/types.d.ts +31 -0
- package/dist/spinner/registry.json +6 -0
- package/dist/spinner/spinner.svelte +114 -0
- package/dist/spinner/spinner.svelte.d.ts +4 -0
- package/dist/spinner/types.d.ts +6 -0
- package/dist/spinner/types.js +1 -0
- package/dist/surface/registry.json +6 -0
- package/dist/surface/surface.svelte +96 -0
- package/dist/surface/surface.svelte.d.ts +4 -0
- package/dist/surface/types.d.ts +25 -0
- package/dist/surface/types.js +1 -0
- package/dist/switch/registry.json +6 -0
- package/dist/switch/switch.svelte +162 -0
- package/dist/switch/switch.svelte.d.ts +4 -0
- package/dist/switch/types.d.ts +8 -0
- package/dist/switch/types.js +1 -0
- package/dist/text-area/registry.json +8 -0
- package/dist/text-area/text-area.svelte +186 -0
- package/dist/text-area/text-area.svelte.d.ts +4 -0
- package/dist/text-area/types.d.ts +12 -0
- package/dist/text-area/types.js +1 -0
- package/dist/text-input/registry.json +8 -0
- package/dist/text-input/text-input.svelte +189 -0
- package/dist/text-input/text-input.svelte.d.ts +4 -0
- package/dist/text-input/types.d.ts +11 -0
- package/dist/text-input/types.js +1 -0
- package/dist/theme/cli-theme.svelte +16 -0
- package/dist/theme/cli-theme.svelte.d.ts +7 -0
- package/dist/theme/colors.svelte +102 -0
- package/dist/theme/colors.svelte.d.ts +4 -0
- package/dist/theme/fonts.svelte +10 -0
- package/dist/theme/fonts.svelte.d.ts +26 -0
- package/dist/theme/registry.json +13 -0
- package/dist/theme/styles.svelte +50 -0
- package/dist/theme/styles.svelte.d.ts +26 -0
- package/dist/theme/surface.d.ts +3 -0
- package/dist/theme/surface.js +10 -0
- package/dist/theme/surfaces.svelte +208 -0
- package/dist/theme/surfaces.svelte.d.ts +18 -0
- package/dist/theme/theme-mode-toggle.svelte +9 -0
- package/dist/theme/theme-mode-toggle.svelte.d.ts +4 -0
- package/dist/theme/theme.svelte +16 -0
- package/dist/theme/theme.svelte.d.ts +4 -0
- package/dist/theme/types.d.ts +17 -0
- package/dist/theme/types.js +1 -0
- package/dist/tree-view/registry.json +15 -0
- package/dist/tree-view/tree-node/chevron-button.svelte +56 -0
- package/dist/tree-view/tree-node/chevron-button.svelte.d.ts +4 -0
- package/dist/tree-view/tree-node/content.svelte +62 -0
- package/dist/tree-view/tree-node/content.svelte.d.ts +4 -0
- package/dist/tree-view/tree-node/delete-button.svelte +52 -0
- package/dist/tree-view/tree-node/delete-button.svelte.d.ts +4 -0
- package/dist/tree-view/tree-node/tree-node.svelte +111 -0
- package/dist/{base/tree-view → tree-view/tree-node}/tree-node.svelte.d.ts +2 -3
- package/dist/tree-view/tree-view-section.svelte +42 -0
- package/dist/tree-view/tree-view-section.svelte.d.ts +4 -0
- package/dist/tree-view/tree-view.svelte +65 -0
- package/dist/{base/tree-view → tree-view}/tree-view.svelte.d.ts +2 -2
- package/dist/tree-view/types.d.ts +31 -0
- package/dist/tree-view/types.js +1 -0
- package/dist/types.d.ts +25 -0
- package/dist/types.js +1 -0
- package/package.json +55 -34
- package/readme.md +157 -0
- package/src/lib/button/button.svelte +126 -0
- package/src/lib/button/registry.json +6 -0
- package/src/lib/button/types.ts +42 -0
- package/src/lib/checkbox/checkbox.svelte +143 -0
- package/src/lib/checkbox/registry.json +6 -0
- package/src/lib/checkbox/types.ts +7 -0
- package/src/lib/combobox/combobox.svelte +156 -0
- package/src/lib/combobox/form.svelte +61 -0
- package/src/lib/combobox/input.svelte +132 -0
- package/src/lib/combobox/list.svelte +78 -0
- package/src/lib/combobox/option.svelte +77 -0
- package/src/lib/combobox/registry.json +6 -0
- package/src/lib/combobox/types.ts +89 -0
- package/src/lib/dialog/dialog.svelte +182 -0
- package/src/lib/dialog/footer.svelte +26 -0
- package/src/lib/dialog/header.svelte +56 -0
- package/src/lib/dialog/registry.json +6 -0
- package/src/lib/dialog/types.ts +35 -0
- package/src/lib/icon/icon.svelte +108 -0
- package/src/lib/icon/names.ts +3794 -0
- package/src/lib/icon/registry.json +6 -0
- package/src/lib/icon/types.ts +18 -0
- package/src/lib/index.ts +20 -0
- package/src/lib/pill/content.svelte +23 -0
- package/src/lib/pill/on-delete.svelte +26 -0
- package/src/lib/pill/pill.svelte +200 -0
- package/src/lib/pill/registry.json +6 -0
- package/src/lib/pill/types.ts +22 -0
- package/src/lib/pill-choice-group/pill-choice-group.svelte +131 -0
- package/src/lib/pill-choice-group/registry.json +6 -0
- package/src/lib/pill-choice-group/types.ts +14 -0
- package/src/lib/pill-group/container.svelte +40 -0
- package/src/lib/pill-group/pill-group.svelte +27 -0
- package/src/lib/pill-group/registry.json +6 -0
- package/src/lib/pill-group/types.ts +15 -0
- package/src/lib/popover/popover.svelte +86 -0
- package/src/lib/popover/registry.json +6 -0
- package/src/lib/popover/types.ts +9 -0
- package/src/lib/progress/progress.svelte +256 -0
- package/src/lib/progress/registry.json +6 -0
- package/src/lib/progress/types.ts +15 -0
- package/src/lib/select/empty.svelte +25 -0
- package/src/lib/select/list.svelte +27 -0
- package/src/lib/select/option.svelte +64 -0
- package/src/lib/select/registry.json +6 -0
- package/src/lib/select/select.svelte +70 -0
- package/src/lib/select/trigger.svelte +86 -0
- package/src/lib/select/types.ts +41 -0
- package/src/lib/spinner/registry.json +6 -0
- package/src/lib/spinner/spinner.svelte +114 -0
- package/src/lib/spinner/types.ts +7 -0
- package/src/lib/surface/registry.json +6 -0
- package/src/lib/surface/surface.svelte +96 -0
- package/src/lib/surface/types.ts +28 -0
- package/src/lib/switch/registry.json +6 -0
- package/src/lib/switch/switch.svelte +162 -0
- package/src/lib/switch/types.ts +12 -0
- package/src/lib/text-area/registry.json +8 -0
- package/src/lib/text-area/text-area.svelte +186 -0
- package/src/lib/text-area/types.ts +13 -0
- package/src/lib/text-input/registry.json +8 -0
- package/src/lib/text-input/text-input.svelte +189 -0
- package/src/lib/text-input/types.ts +12 -0
- package/src/lib/theme/cli-theme.svelte +16 -0
- package/src/lib/theme/colors.svelte +102 -0
- package/src/lib/theme/fonts.svelte +10 -0
- package/src/lib/theme/registry.json +13 -0
- package/src/lib/theme/styles.svelte +50 -0
- package/src/lib/theme/surface.ts +18 -0
- package/src/lib/theme/surfaces.svelte +208 -0
- package/src/lib/theme/theme-mode-toggle.svelte +9 -0
- package/src/lib/theme/theme.svelte +16 -0
- package/src/lib/theme/types.ts +18 -0
- package/src/lib/tree-view/registry.json +15 -0
- package/src/lib/tree-view/tree-node/chevron-button.svelte +56 -0
- package/src/lib/tree-view/tree-node/content.svelte +62 -0
- package/src/lib/tree-view/tree-node/delete-button.svelte +52 -0
- package/src/lib/tree-view/tree-node/tree-node.svelte +111 -0
- package/src/lib/tree-view/tree-view-section.svelte +42 -0
- package/src/lib/tree-view/tree-view.svelte +65 -0
- package/src/lib/tree-view/types.ts +39 -0
- package/src/lib/types.ts +45 -0
- package/README.md +0 -110
- package/dist/base/button/button.svelte +0 -260
- package/dist/base/button/button.svelte.d.ts +0 -6
- package/dist/base/button/icon-button.svelte +0 -226
- package/dist/base/button/icon-button.svelte.d.ts +0 -6
- package/dist/base/button/index.d.ts +0 -2
- package/dist/base/button/index.js +0 -2
- package/dist/base/button/types.d.ts +0 -17
- package/dist/base/icon/icon.svelte +0 -118
- package/dist/base/icon/icon.svelte.d.ts +0 -7
- package/dist/base/icon/index.d.ts +0 -2
- package/dist/base/icon/index.js +0 -2
- package/dist/base/icon/types.d.ts +0 -10
- package/dist/base/index.d.ts +0 -13
- package/dist/base/index.js +0 -13
- package/dist/base/loading/circular-loading.svelte +0 -95
- package/dist/base/loading/circular-loading.svelte.d.ts +0 -4
- package/dist/base/loading/index.d.ts +0 -4
- package/dist/base/loading/index.js +0 -4
- package/dist/base/loading/morphing-shapes-loading.svelte +0 -241
- package/dist/base/loading/morphing-shapes-loading.svelte.d.ts +0 -4
- package/dist/base/loading/pulsing-dots-loading.svelte +0 -115
- package/dist/base/loading/pulsing-dots-loading.svelte.d.ts +0 -4
- package/dist/base/loading/textual-loading.svelte +0 -179
- package/dist/base/loading/textual-loading.svelte.d.ts +0 -4
- package/dist/base/loading/types.d.ts +0 -16
- package/dist/base/pill/index.d.ts +0 -1
- package/dist/base/pill/index.js +0 -1
- package/dist/base/pill/pill.svelte +0 -171
- package/dist/base/pill/types.d.ts +0 -11
- package/dist/base/pill-selection/index.d.ts +0 -2
- package/dist/base/pill-selection/index.js +0 -2
- package/dist/base/pill-selection/pill-selection.svelte +0 -48
- package/dist/base/pill-selection/pill-selection.svelte.d.ts +0 -4
- package/dist/base/pill-selection/types.d.ts +0 -16
- package/dist/base/progress-bar/index.d.ts +0 -1
- package/dist/base/progress-bar/index.js +0 -1
- package/dist/base/progress-bar/progress-bar.svelte +0 -174
- package/dist/base/progress-bar/progress-bar.svelte.d.ts +0 -4
- package/dist/base/progress-bar/types.d.ts +0 -9
- package/dist/base/select/index.d.ts +0 -2
- package/dist/base/select/index.js +0 -2
- package/dist/base/select/select.svelte +0 -145
- package/dist/base/select/types.d.ts +0 -16
- package/dist/base/slider/index.d.ts +0 -1
- package/dist/base/slider/index.js +0 -1
- package/dist/base/slider/slider.svelte +0 -192
- package/dist/base/slider/slider.svelte.d.ts +0 -6
- package/dist/base/slider/types.d.ts +0 -12
- package/dist/base/text-input/area-text-input.svelte +0 -105
- package/dist/base/text-input/area-text-input.svelte.d.ts +0 -6
- package/dist/base/text-input/index.d.ts +0 -2
- package/dist/base/text-input/index.js +0 -2
- package/dist/base/text-input/text-input.svelte +0 -213
- package/dist/base/text-input/text-input.svelte.d.ts +0 -6
- package/dist/base/text-input/types.d.ts +0 -27
- package/dist/base/theme/color-tokens.d.ts +0 -36
- package/dist/base/theme/color-tokens.js +0 -105
- package/dist/base/theme/index.d.ts +0 -3
- package/dist/base/theme/index.js +0 -3
- package/dist/base/theme/mode.d.ts +0 -3
- package/dist/base/theme/mode.js +0 -14
- package/dist/base/theme/theme.svelte +0 -87
- package/dist/base/theme/theme.svelte.d.ts +0 -3
- package/dist/base/theme/types.d.ts +0 -27
- package/dist/base/theme/types.js +0 -20
- package/dist/base/toggle/index.d.ts +0 -1
- package/dist/base/toggle/index.js +0 -1
- package/dist/base/toggle/toggle.svelte +0 -109
- package/dist/base/toggle/toggle.svelte.d.ts +0 -4
- package/dist/base/toggle/types.d.ts +0 -7
- package/dist/base/tree-view/index.d.ts +0 -3
- package/dist/base/tree-view/index.js +0 -3
- package/dist/base/tree-view/tree-node.svelte +0 -132
- package/dist/base/tree-view/tree-view.svelte +0 -56
- package/dist/base/tree-view/types.d.ts +0 -23
- package/dist/base/types.d.ts +0 -4
- /package/dist/{base/button → button}/types.js +0 -0
- /package/dist/{base/icon → checkbox}/types.js +0 -0
- /package/dist/{base/loading → combobox}/types.js +0 -0
- /package/dist/{base/pill-selection → dialog}/types.js +0 -0
- /package/dist/{base/pill/types.js → icon/names.js} +0 -0
- /package/dist/{base/progress-bar → icon}/types.js +0 -0
- /package/dist/{base/text-input → pill}/types.js +0 -0
- /package/dist/{base/select → pill-choice-group}/types.js +0 -0
- /package/dist/{base/slider → pill-group}/types.js +0 -0
- /package/dist/{base/toggle → popover}/types.js +0 -0
- /package/dist/{base/tree-view → progress}/types.js +0 -0
- /package/dist/{base → select}/types.js +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import TreeNode from './tree-node/tree-node.svelte';
|
|
3
|
+
import TreeViewSection from './tree-view-section.svelte';
|
|
4
|
+
import type { TreeViewProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
items,
|
|
8
|
+
sections = [],
|
|
9
|
+
label = 'Tree view',
|
|
10
|
+
size = 'medium',
|
|
11
|
+
selection = $bindable(),
|
|
12
|
+
defaultExpanded = false,
|
|
13
|
+
onDelete,
|
|
14
|
+
node
|
|
15
|
+
}: TreeViewProps = $props();
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
{#snippet nodes(items: TreeViewProps['items'])}
|
|
19
|
+
<div data-nodes>
|
|
20
|
+
{#each items as item (item.id)}
|
|
21
|
+
{#if node}
|
|
22
|
+
{@render node(item)}
|
|
23
|
+
{:else}
|
|
24
|
+
<TreeNode {item} bind:selection {defaultExpanded} {onDelete} />
|
|
25
|
+
{/if}
|
|
26
|
+
{/each}
|
|
27
|
+
</div>
|
|
28
|
+
{/snippet}
|
|
29
|
+
|
|
30
|
+
<div role="group" aria-label={label} data-size={size}>
|
|
31
|
+
{@render nodes(items)}
|
|
32
|
+
{#each sections as section (section.id)}
|
|
33
|
+
<section aria-label={section.label}>
|
|
34
|
+
<TreeViewSection {...section} />
|
|
35
|
+
{@render nodes(section.items)}
|
|
36
|
+
</section>
|
|
37
|
+
{/each}
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<style>
|
|
41
|
+
div {
|
|
42
|
+
--tree-height: 2.75rem;
|
|
43
|
+
--tree-action-size: 2.25rem;
|
|
44
|
+
display: grid;
|
|
45
|
+
gap: 0.375rem;
|
|
46
|
+
min-width: 0;
|
|
47
|
+
color: var(--color-foreground);
|
|
48
|
+
font: inherit;
|
|
49
|
+
}
|
|
50
|
+
div[data-size='small'] {
|
|
51
|
+
--tree-height: 2.5rem;
|
|
52
|
+
--tree-action-size: 2rem;
|
|
53
|
+
font-size: 0.875rem;
|
|
54
|
+
}
|
|
55
|
+
div[data-size='large'] {
|
|
56
|
+
--tree-height: 3.25rem;
|
|
57
|
+
--tree-action-size: 2.5rem;
|
|
58
|
+
font-size: 1.125rem;
|
|
59
|
+
}
|
|
60
|
+
div[data-nodes] {
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
gap: 0.25rem;
|
|
64
|
+
}
|
|
65
|
+
</style>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TreeViewProps } from './types.
|
|
2
|
-
declare const TreeView: import("svelte").Component<TreeViewProps, {}, "">;
|
|
1
|
+
import type { TreeViewProps } from './types.js';
|
|
2
|
+
declare const TreeView: import("svelte").Component<TreeViewProps, {}, "selection">;
|
|
3
3
|
type TreeView = ReturnType<typeof TreeView>;
|
|
4
4
|
export default TreeView;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
|
+
import type { BaseSize, IconProps } from '../types.js';
|
|
4
|
+
export interface TreeItemProps {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
icon?: Omit<IconProps, 'label' | 'size' | 'color'>;
|
|
8
|
+
children?: TreeItemProps[];
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface TreeSectionProps extends Pick<TreeItemProps, 'id' | 'label' | 'icon'> {
|
|
12
|
+
description?: string;
|
|
13
|
+
items: TreeItemProps[];
|
|
14
|
+
}
|
|
15
|
+
export interface TreeViewProps {
|
|
16
|
+
items: TreeItemProps[];
|
|
17
|
+
sections?: TreeSectionProps[];
|
|
18
|
+
label?: string;
|
|
19
|
+
size?: BaseSize;
|
|
20
|
+
selection?: string | string[];
|
|
21
|
+
defaultExpanded?: boolean;
|
|
22
|
+
onDelete?: (id: string) => void;
|
|
23
|
+
node?: Snippet<[TreeItemProps]>;
|
|
24
|
+
}
|
|
25
|
+
export interface TreeNodeProps extends Pick<TreeViewProps, 'selection' | 'defaultExpanded' | 'onDelete'> {
|
|
26
|
+
item: TreeItemProps;
|
|
27
|
+
indent?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface TreeNodeContentProps extends HTMLButtonAttributes {
|
|
30
|
+
item: TreeItemProps;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type BaseSize = 'small' | 'medium' | 'large';
|
|
2
|
+
export type Size = 'x-small' | BaseSize | 'x-large';
|
|
3
|
+
export type Variant = 'neutral' | 'soft' | 'filled';
|
|
4
|
+
export type StatusColor = 'info' | 'success' | 'warning' | 'error';
|
|
5
|
+
export type Color = 'primary' | 'secondary' | 'foreground' | 'background' | 'muted' | StatusColor;
|
|
6
|
+
export type Orientation = 'horizontal' | 'vertical';
|
|
7
|
+
export type Dimension = 'fit' | 'fill';
|
|
8
|
+
export type { ButtonProps } from './button/types.js';
|
|
9
|
+
export type { ComboboxProps, ComboboxNativeProps, ComboboxInputProps, ComboboxListProps, ComboboxOptionProps, ComboboxFormProps } from './combobox/types.js';
|
|
10
|
+
export type * from './icon/types.js';
|
|
11
|
+
export type { SurfaceBaseProps, SurfaceProps, SurfaceRadius } from './surface/types.js';
|
|
12
|
+
export type * from './theme/types.ts';
|
|
13
|
+
export type { CheckboxProps } from './checkbox/types.js';
|
|
14
|
+
export type { SwitchProps } from './switch/types.js';
|
|
15
|
+
export type { ProgressProps } from './progress/types.js';
|
|
16
|
+
export type { SpinnerProps } from './spinner/types.js';
|
|
17
|
+
export type { PopoverProps } from './popover/types.js';
|
|
18
|
+
export type { DialogActionProps, DialogHeaderDataProps, DialogHeaderProps, DialogProps } from './dialog/types.js';
|
|
19
|
+
export type { TextInputProps } from './text-input/types.js';
|
|
20
|
+
export type { TextAreaProps } from './text-area/types.js';
|
|
21
|
+
export type * from './tree-view/types.js';
|
|
22
|
+
export type { PillDataProps, PillProps } from './pill/types.js';
|
|
23
|
+
export type { PillGroupProps } from './pill-group/types.js';
|
|
24
|
+
export type { PillChoiceGroupProps } from './pill-choice-group/types.js';
|
|
25
|
+
export type { OptionProps, SelectEmptyProps, SelectOptionDataProps, SelectListProps, SelectProps, SelectTriggerProps } from './select/types.js';
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bref-ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A Svelte UI
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "A Svelte-first, human-first, agent-first UI library for building beautiful sites and apps with components you can make your own.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"author": "feuerstein",
|
|
7
6
|
"repository": {
|
|
8
7
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/feuersteiner/bref.git"
|
|
8
|
+
"url": "git+https://github.com/feuersteiner/bref-ui.git"
|
|
10
9
|
},
|
|
11
|
-
"homepage": "https://
|
|
10
|
+
"homepage": "https://github.com/feuersteiner/bref-ui#readme",
|
|
12
11
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/feuersteiner/bref/issues"
|
|
12
|
+
"url": "https://github.com/feuersteiner/bref-ui/issues"
|
|
14
13
|
},
|
|
15
14
|
"scripts": {
|
|
16
15
|
"dev": "vite dev",
|
|
@@ -18,16 +17,18 @@
|
|
|
18
17
|
"demo-site-build": "vite build",
|
|
19
18
|
"preview": "vite preview",
|
|
20
19
|
"prepare": "svelte-kit sync || echo ''",
|
|
21
|
-
"prepack": "svelte-kit sync && svelte-package && publint",
|
|
20
|
+
"prepack": "bun cli/pack.ts && bun run svelte-kit sync && bun run svelte-package && bun run publint",
|
|
22
21
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
23
22
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
23
|
+
"lint": "prettier --check . && eslint .",
|
|
24
|
+
"format": "prettier --write ."
|
|
26
25
|
},
|
|
27
26
|
"files": [
|
|
28
27
|
"dist",
|
|
29
28
|
"!dist/**/*.test.*",
|
|
30
|
-
"!dist/**/*.spec.*"
|
|
29
|
+
"!dist/**/*.spec.*",
|
|
30
|
+
"cli/**/*.ts",
|
|
31
|
+
"src/lib"
|
|
31
32
|
],
|
|
32
33
|
"sideEffects": [
|
|
33
34
|
"**/*.css"
|
|
@@ -39,46 +40,66 @@
|
|
|
39
40
|
".": {
|
|
40
41
|
"types": "./dist/index.d.ts",
|
|
41
42
|
"svelte": "./dist/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./types": {
|
|
45
|
+
"types": "./dist/types.d.ts"
|
|
42
46
|
}
|
|
43
47
|
},
|
|
44
48
|
"peerDependencies": {
|
|
45
|
-
"svelte": "^5.
|
|
49
|
+
"svelte": "^5.56.1"
|
|
46
50
|
},
|
|
47
51
|
"devDependencies": {
|
|
48
|
-
"@eslint/
|
|
49
|
-
"@
|
|
50
|
-
"@fontsource/
|
|
51
|
-
"@fontsource/
|
|
52
|
-
"@
|
|
52
|
+
"@eslint/js": "^10.0.1",
|
|
53
|
+
"@fontsource-variable/bricolage-grotesque": "^5.3.0",
|
|
54
|
+
"@fontsource-variable/inter": "^5.3.0",
|
|
55
|
+
"@fontsource-variable/syne": "^5.3.0",
|
|
56
|
+
"@fontsource/meow-script": "5.2.8",
|
|
57
|
+
"@fontsource/spectral": "5.2.8",
|
|
53
58
|
"@sveltejs/adapter-static": "^3.0.10",
|
|
54
|
-
"@sveltejs/kit": "^2.
|
|
55
|
-
"@sveltejs/package": "^2.5.
|
|
56
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
59
|
+
"@sveltejs/kit": "^2.63.0",
|
|
60
|
+
"@sveltejs/package": "^2.5.8",
|
|
61
|
+
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
|
62
|
+
"@types/bun": "^1.4.2",
|
|
57
63
|
"@types/node": "^22",
|
|
58
|
-
"eslint": "^
|
|
64
|
+
"eslint": "^10.4.1",
|
|
59
65
|
"eslint-config-prettier": "^10.1.8",
|
|
60
|
-
"eslint-plugin-
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"prettier
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
66
|
+
"eslint-plugin-check-file": "^3.3.2",
|
|
67
|
+
"eslint-plugin-svelte": "^3.19.0",
|
|
68
|
+
"globals": "^17.6.0",
|
|
69
|
+
"prettier": "^3.8.3",
|
|
70
|
+
"prettier-plugin-svelte": "^4.1.0",
|
|
71
|
+
"publint": "^0.3.21",
|
|
72
|
+
"shiki": "^4.4.3",
|
|
73
|
+
"svelte": "^5.56.1",
|
|
74
|
+
"svelte-check": "^4.6.0",
|
|
75
|
+
"typescript": "^6.0.3",
|
|
76
|
+
"typescript-eslint": "^8.60.1",
|
|
77
|
+
"vite": "^8.0.16"
|
|
70
78
|
},
|
|
71
79
|
"keywords": [
|
|
72
80
|
"svelte",
|
|
73
81
|
"svelte5",
|
|
82
|
+
"sveltekit",
|
|
83
|
+
"svelte-components",
|
|
74
84
|
"ui",
|
|
75
|
-
"
|
|
85
|
+
"ui-library",
|
|
76
86
|
"component-library",
|
|
87
|
+
"components",
|
|
77
88
|
"design-system",
|
|
78
|
-
"
|
|
89
|
+
"copy-paste",
|
|
90
|
+
"cli",
|
|
91
|
+
"native-css",
|
|
92
|
+
"theming",
|
|
93
|
+
"dark-mode",
|
|
94
|
+
"accessible",
|
|
95
|
+
"a11y",
|
|
96
|
+
"ai-friendly",
|
|
97
|
+
"agent-friendly"
|
|
79
98
|
],
|
|
80
99
|
"dependencies": {
|
|
81
|
-
"@fontsource-variable/material-symbols-
|
|
82
|
-
|
|
100
|
+
"@fontsource-variable/material-symbols-outlined": "^5.3.5"
|
|
101
|
+
},
|
|
102
|
+
"bin": {
|
|
103
|
+
"bref-ui": "cli/index.ts"
|
|
83
104
|
}
|
|
84
105
|
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Bref-ui
|
|
2
|
+
|
|
3
|
+
A Svelte-first, human-first, agent-first UI library for building beautiful sites
|
|
4
|
+
and apps with components you can make your own.
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/bref-ui)
|
|
7
|
+
[](https://discord.gg/JpgQRTUsVS)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
> <small>V2 is in development and has not been published to npm. The npm badge tracks the
|
|
11
|
+
> published release; the examples below use the v2 development checkout. Button,
|
|
12
|
+
> Icon, Surface, Theme and ThemeModeToggle exist today. Agent skills, site generation
|
|
13
|
+
> and live generative UI are planned.</small>
|
|
14
|
+
|
|
15
|
+
## Get started
|
|
16
|
+
|
|
17
|
+
### Explore the gallery
|
|
18
|
+
|
|
19
|
+
Use Bun and Node 22.12+ within Node 22, or Node 24:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
git clone https://github.com/feuersteiner/bref-ui.git
|
|
23
|
+
cd bref-ui
|
|
24
|
+
bun install
|
|
25
|
+
bun run dev
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Open the URL printed in the terminal. The gallery includes component examples,
|
|
29
|
+
props and theme customization on `/button`, `/icon` and `/theme`.
|
|
30
|
+
|
|
31
|
+
### Use the local package
|
|
32
|
+
|
|
33
|
+
The CLI/registry changes are currently local and uncommitted, so they are absent
|
|
34
|
+
from the clone above. This section and the copy workflow below require the
|
|
35
|
+
development checkout containing those changes.
|
|
36
|
+
|
|
37
|
+
In that checkout, build a local package:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
bun run build
|
|
41
|
+
npm pack --ignore-scripts
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This produces `bref-ui-2.0.0.tgz`. In an existing Svelte 5.56.1+ project with its
|
|
45
|
+
dependencies installed, install that tarball, replacing the example path:
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
npm install /path/to/bref-ui-2.0.0.tgz
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Then use the components in a `.svelte` file:
|
|
52
|
+
|
|
53
|
+
```svelte
|
|
54
|
+
<script lang="ts">
|
|
55
|
+
import { Button, Theme } from 'bref-ui';
|
|
56
|
+
|
|
57
|
+
let count = $state(0);
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<Theme />
|
|
61
|
+
<Button label={`Count: ${count}`} onClick={() => count++} />
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The button increments the count when clicked. The current Button uses `label` and
|
|
65
|
+
`onClick`; the gallery documents each component's current API.
|
|
66
|
+
|
|
67
|
+
Render `Theme` once in the application root to opt into its palette, reset and
|
|
68
|
+
Material Symbols font setup. The current package declares a Material Symbols font
|
|
69
|
+
dependency, so zero runtime dependencies beyond Svelte remains a goal.
|
|
70
|
+
|
|
71
|
+
### Shared surface styles
|
|
72
|
+
|
|
73
|
+
Theme composes internal colors, surfaces, fonts and styles components. Surface and
|
|
74
|
+
Button use the same paint recipe; apply it to native HTML with the typed helper:
|
|
75
|
+
|
|
76
|
+
```svelte
|
|
77
|
+
<script>
|
|
78
|
+
import { Theme, surface } from 'bref-ui';
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<Theme />
|
|
82
|
+
<button class={surface({ variant: 'filled', color: 'primary', shadow: 'small', hover: 'medium' })}>
|
|
83
|
+
Save
|
|
84
|
+
</button>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
All options are optional: variant defaults to neutral and color to foreground;
|
|
88
|
+
shadow and hover accept small, medium or large. Shadow also accepts true for medium
|
|
89
|
+
and false for none. SurfaceProps extends SurfaceBaseProps with component props.
|
|
90
|
+
Supply padding, radius and layout
|
|
91
|
+
in element styles. The helper adds classes only; Theme loads their CSS. SurfaceBaseProps
|
|
92
|
+
is available from `bref-ui/types`. Copied components include the helper in
|
|
93
|
+
`theme/surface.ts`; the local UI barrel keeps component exports only.
|
|
94
|
+
|
|
95
|
+
## Why Bref-ui?
|
|
96
|
+
|
|
97
|
+
1. **Svelte-first.** The goal is modern components with zero runtime dependencies
|
|
98
|
+
beyond Svelte, built from scoped CSS, familiar HTML, native events, bindings and
|
|
99
|
+
snippets. Readable styles, with no class-name vocabulary to memorize. The
|
|
100
|
+
collection will grow from small UI components to marketing sections and
|
|
101
|
+
complete app interfaces.
|
|
102
|
+
2. **Human-first.** Composable components with full control over appearance and
|
|
103
|
+
behavior. Inspired by shadcn's source ownership model, tooling brings component
|
|
104
|
+
source into the project for unrestricted customization. Planned agent skills
|
|
105
|
+
and validation tools help developers adapt components while preserving native
|
|
106
|
+
behavior and accessibility.
|
|
107
|
+
3. **Agent-first.** A component collection paired with tools that help agents
|
|
108
|
+
discover, compose, customize and verify interfaces. Planned capabilities include
|
|
109
|
+
complete site generation, generative UI and interactive interfaces for agent
|
|
110
|
+
workflows.
|
|
111
|
+
|
|
112
|
+
## Copy components into a project (WIP)
|
|
113
|
+
|
|
114
|
+
The local package includes the `bref` executable. After installing the tarball,
|
|
115
|
+
preview and accept the setup and Button copies:
|
|
116
|
+
|
|
117
|
+
Run `bun run bref-ui add theme` to copy the default-only Theme source into the configured UI directory. The copied `Theme` has no `palette` prop; edit its CSS tokens directly. The package `Theme` retains the `palette` prop. Button copies include Icon and required types. SvelteKit can use
|
|
118
|
+
`--alias '$lib/bref'` during init after its existing sync command.
|
|
119
|
+
|
|
120
|
+
## Documentation and demos
|
|
121
|
+
|
|
122
|
+
Run `bun run dev` in the repository for the gallery and current API documentation.
|
|
123
|
+
Explore the [component exports](src/lib/index.ts) and [component source](src/lib)
|
|
124
|
+
to inspect and customize the implementation.
|
|
125
|
+
|
|
126
|
+
## Roadmap
|
|
127
|
+
|
|
128
|
+
- **Component foundation:** inputs/textarea, pills, tree views, loading/progress,
|
|
129
|
+
static theme tooling and complete npm/copy distribution. Planned theme tooling
|
|
130
|
+
emits the existing light/dark palette with literal primary and per-mode overrides;
|
|
131
|
+
contrast failures are reported without silently replacing inputs.
|
|
132
|
+
- **Marketing sites:** reusable sections and design recipes, then validated YAML/JSON
|
|
133
|
+
generation of complete SvelteKit sites with content, assets, routes and metadata.
|
|
134
|
+
Prove a small multipage site in two distinct recipes.
|
|
135
|
+
- **Agent tooling:** a machine-readable catalog, skills and shared CLI/SDK operations
|
|
136
|
+
for discovery, validation, planning, preview and repair. Regeneration previews
|
|
137
|
+
changes and detects human-edit conflicts; exported source can become human-owned.
|
|
138
|
+
- **Generative UI:** evaluate a Bref catalog on json-render with one interactive
|
|
139
|
+
task, preserving input and focus while invoking registered host actions. Measure
|
|
140
|
+
runtime cost before choosing a renderer and adding one optional host integration.
|
|
141
|
+
|
|
142
|
+
Generation tooling and agent integrations will be optional. A visual editor,
|
|
143
|
+
arbitrary application logic generation and hosted model services are deferred.
|
|
144
|
+
Accessibility depends on the final composition, theme and interactions; component
|
|
145
|
+
checks and generated CSS do not guarantee that every customization is accessible.
|
|
146
|
+
|
|
147
|
+
## Community and contributing
|
|
148
|
+
|
|
149
|
+
For questions and examples, join [Discord](https://discord.gg/JpgQRTUsVS) and use the
|
|
150
|
+
`bref-ui` channel. Report bugs and suggest features through
|
|
151
|
+
[GitHub Issues](https://github.com/feuersteiner/bref-ui/issues).
|
|
152
|
+
|
|
153
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines.
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
[MIT](LICENSE).
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/* eslint-disable svelte/consistent-selector-style -- Keep the shared button/link geometry scoped to .button. */
|
|
3
|
+
import Icon from '../icon/icon.svelte';
|
|
4
|
+
import { surface } from '../theme/surface.js';
|
|
5
|
+
import type { ButtonProps } from './types.js';
|
|
6
|
+
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
color = 'foreground',
|
|
10
|
+
size = 'medium',
|
|
11
|
+
variant = 'neutral',
|
|
12
|
+
label,
|
|
13
|
+
icon,
|
|
14
|
+
trailingIcon,
|
|
15
|
+
wide = false,
|
|
16
|
+
rounded = false,
|
|
17
|
+
disabled = false,
|
|
18
|
+
href,
|
|
19
|
+
onClick,
|
|
20
|
+
class: className,
|
|
21
|
+
...attributes
|
|
22
|
+
}: ButtonProps = $props();
|
|
23
|
+
|
|
24
|
+
const isIcon = $derived(label === undefined);
|
|
25
|
+
const isLink = $derived(href !== undefined);
|
|
26
|
+
const common = $derived({
|
|
27
|
+
class: ['button', surface({ variant, color, shadow: 'small', hover: 'medium' }), className],
|
|
28
|
+
'aria-label': attributes['aria-label'] ?? (isIcon ? (icon?.label ?? icon?.name) : undefined),
|
|
29
|
+
'data-color': color,
|
|
30
|
+
'data-size': size,
|
|
31
|
+
'data-variant': variant,
|
|
32
|
+
'data-kind': isIcon ? 'icon' : 'normal',
|
|
33
|
+
'data-wide': wide && !isIcon ? '' : undefined,
|
|
34
|
+
'data-rounded': rounded && isIcon ? '' : undefined
|
|
35
|
+
});
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
{#snippet content()}
|
|
39
|
+
{#if icon}
|
|
40
|
+
<span><Icon {...icon} color={undefined} label={undefined} /></span>
|
|
41
|
+
{/if}
|
|
42
|
+
{#if !isIcon}
|
|
43
|
+
{label}
|
|
44
|
+
{#if trailingIcon}
|
|
45
|
+
<span><Icon {...trailingIcon} color={undefined} label={undefined} /></span>
|
|
46
|
+
{/if}
|
|
47
|
+
{/if}
|
|
48
|
+
{/snippet}
|
|
49
|
+
|
|
50
|
+
{#if isLink}
|
|
51
|
+
<!-- eslint-disable svelte/no-navigation-without-resolve -- Native library links also support consumers outside SvelteKit. -->
|
|
52
|
+
<a
|
|
53
|
+
{...attributes as HTMLAnchorAttributes}
|
|
54
|
+
{...common}
|
|
55
|
+
href={disabled ? undefined : href}
|
|
56
|
+
aria-disabled={disabled ? true : attributes['aria-disabled']}
|
|
57
|
+
tabindex={disabled ? -1 : attributes.tabindex}
|
|
58
|
+
onclick={disabled ? (event) => event.preventDefault() : onClick}
|
|
59
|
+
>
|
|
60
|
+
{@render content()}
|
|
61
|
+
</a>
|
|
62
|
+
<!-- eslint-enable svelte/no-navigation-without-resolve -->
|
|
63
|
+
{:else}
|
|
64
|
+
<button
|
|
65
|
+
{...attributes as HTMLButtonAttributes}
|
|
66
|
+
{...common}
|
|
67
|
+
type={(attributes as HTMLButtonAttributes).type ?? 'button'}
|
|
68
|
+
{disabled}
|
|
69
|
+
onclick={onClick}
|
|
70
|
+
>
|
|
71
|
+
{@render content()}
|
|
72
|
+
</button>
|
|
73
|
+
{/if}
|
|
74
|
+
|
|
75
|
+
<style>
|
|
76
|
+
.button {
|
|
77
|
+
--internal-height: max(48px, 3rem);
|
|
78
|
+
--internal-padding: 1.125rem;
|
|
79
|
+
--internal-icon-size: calc(var(--internal-height) / 2 + 0.25rem);
|
|
80
|
+
box-sizing: border-box;
|
|
81
|
+
display: inline-flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
justify-content: center;
|
|
84
|
+
text-transform: capitalize;
|
|
85
|
+
gap: 0.5rem;
|
|
86
|
+
min-height: var(--internal-height);
|
|
87
|
+
min-width: 24px;
|
|
88
|
+
padding: 0.25rem var(--internal-padding);
|
|
89
|
+
border-radius: 0.45rem;
|
|
90
|
+
font: inherit;
|
|
91
|
+
font-size: 1rem;
|
|
92
|
+
text-decoration: none;
|
|
93
|
+
}
|
|
94
|
+
.button[data-size='x-small'] {
|
|
95
|
+
--internal-height: max(28px, 1.75rem);
|
|
96
|
+
--internal-padding: 0.5rem;
|
|
97
|
+
}
|
|
98
|
+
.button[data-size='small'] {
|
|
99
|
+
--internal-height: max(40px, 2.5rem);
|
|
100
|
+
--internal-padding: 0.875rem;
|
|
101
|
+
}
|
|
102
|
+
.button[data-size='large'] {
|
|
103
|
+
--internal-height: max(64px, 4rem);
|
|
104
|
+
--internal-padding: 1.5rem;
|
|
105
|
+
}
|
|
106
|
+
.button[data-size='x-large'] {
|
|
107
|
+
--internal-height: max(80px, 5rem);
|
|
108
|
+
--internal-padding: 2rem;
|
|
109
|
+
}
|
|
110
|
+
.button[data-kind='icon'] {
|
|
111
|
+
width: var(--internal-height);
|
|
112
|
+
height: var(--internal-height);
|
|
113
|
+
padding: 0;
|
|
114
|
+
font-size: var(--internal-icon-size);
|
|
115
|
+
}
|
|
116
|
+
span {
|
|
117
|
+
display: inline-flex;
|
|
118
|
+
font-size: var(--internal-icon-size);
|
|
119
|
+
}
|
|
120
|
+
.button[data-wide] {
|
|
121
|
+
width: 100%;
|
|
122
|
+
}
|
|
123
|
+
.button[data-rounded] {
|
|
124
|
+
border-radius: 50%;
|
|
125
|
+
}
|
|
126
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { DOMAttributes, HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
2
|
+
import type { Color, Size, Variant } from '../types.js';
|
|
3
|
+
import type { IconProps } from '../icon/types.js';
|
|
4
|
+
|
|
5
|
+
type ButtonIconProps = Omit<IconProps, 'size' | 'color'>;
|
|
6
|
+
|
|
7
|
+
interface TextButtonProps {
|
|
8
|
+
rounded?: never;
|
|
9
|
+
label: string;
|
|
10
|
+
wide?: boolean;
|
|
11
|
+
icon?: ButtonIconProps;
|
|
12
|
+
trailingIcon?: ButtonIconProps;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface IconButtonProps {
|
|
16
|
+
rounded?: boolean;
|
|
17
|
+
label?: never;
|
|
18
|
+
wide?: never;
|
|
19
|
+
icon: ButtonIconProps;
|
|
20
|
+
trailingIcon?: never;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type HrefButtonProps = Omit<
|
|
24
|
+
HTMLAnchorAttributes,
|
|
25
|
+
keyof DOMAttributes<HTMLElement> | 'color' | 'href'
|
|
26
|
+
> & {
|
|
27
|
+
href: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
type ClickButtonProps = Omit<HTMLButtonAttributes, keyof DOMAttributes<HTMLElement> | 'color'> & {
|
|
31
|
+
href?: never;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type ButtonProps = {
|
|
35
|
+
color?: Exclude<Color, 'background'>;
|
|
36
|
+
size?: Size;
|
|
37
|
+
variant?: Variant;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
onClick?: DOMAttributes<HTMLButtonElement | HTMLAnchorElement>['onclick'];
|
|
40
|
+
} & Omit<DOMAttributes<HTMLButtonElement | HTMLAnchorElement>, 'children' | 'onclick'> &
|
|
41
|
+
(TextButtonProps | IconButtonProps) &
|
|
42
|
+
(HrefButtonProps | ClickButtonProps);
|