components-svelte 0.1.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 +21 -0
- package/README.md +103 -0
- package/dist/components/Search.svelte +320 -0
- package/dist/components/Search.svelte.d.ts +31 -0
- package/dist/components/SearchButton.svelte +82 -0
- package/dist/components/SearchButton.svelte.d.ts +13 -0
- package/dist/components/SearchProvider.svelte +87 -0
- package/dist/components/SearchProvider.svelte.d.ts +17 -0
- package/dist/components/accordion/Accordion.svelte +150 -0
- package/dist/components/accordion/Accordion.svelte.d.ts +25 -0
- package/dist/components/accordion/AccordionCover.svelte +68 -0
- package/dist/components/accordion/AccordionCover.svelte.d.ts +13 -0
- package/dist/components/accordion/AccordionGroup.svelte +23 -0
- package/dist/components/accordion/AccordionGroup.svelte.d.ts +8 -0
- package/dist/components/accordion/accordion-url-utils.d.ts +4 -0
- package/dist/components/accordion/accordion-url-utils.js +48 -0
- package/dist/components/accordion/index.d.ts +29 -0
- package/dist/components/accordion/index.js +6 -0
- package/dist/components/badge/Badge.svelte +152 -0
- package/dist/components/badge/Badge.svelte.d.ts +23 -0
- package/dist/components/badge/index.d.ts +1 -0
- package/dist/components/badge/index.js +2 -0
- package/dist/components/callout/Callout.svelte +317 -0
- package/dist/components/callout/Callout.svelte.d.ts +17 -0
- package/dist/components/callout/Check.svelte +9 -0
- package/dist/components/callout/Check.svelte.d.ts +4 -0
- package/dist/components/callout/Danger.svelte +9 -0
- package/dist/components/callout/Danger.svelte.d.ts +4 -0
- package/dist/components/callout/Info.svelte +9 -0
- package/dist/components/callout/Info.svelte.d.ts +4 -0
- package/dist/components/callout/Note.svelte +9 -0
- package/dist/components/callout/Note.svelte.d.ts +4 -0
- package/dist/components/callout/Tip.svelte +9 -0
- package/dist/components/callout/Tip.svelte.d.ts +4 -0
- package/dist/components/callout/Warning.svelte +9 -0
- package/dist/components/callout/Warning.svelte.d.ts +4 -0
- package/dist/components/callout/index.d.ts +8 -0
- package/dist/components/callout/index.js +8 -0
- package/dist/components/card/Card.svelte +172 -0
- package/dist/components/card/Card.svelte.d.ts +21 -0
- package/dist/components/card/index.d.ts +3 -0
- package/dist/components/card/index.js +2 -0
- package/dist/components/code-block/BaseCodeBlock.svelte +249 -0
- package/dist/components/code-block/BaseCodeBlock.svelte.d.ts +10 -0
- package/dist/components/code-block/CodeBlock.svelte +185 -0
- package/dist/components/code-block/CodeBlock.svelte.d.ts +5 -0
- package/dist/components/code-block/CodeFooter.svelte +34 -0
- package/dist/components/code-block/CodeFooter.svelte.d.ts +8 -0
- package/dist/components/code-block/CodeHeader.svelte +52 -0
- package/dist/components/code-block/CodeHeader.svelte.d.ts +11 -0
- package/dist/components/code-block/CopyToClipboardButton.svelte +124 -0
- package/dist/components/code-block/CopyToClipboardButton.svelte.d.ts +4 -0
- package/dist/components/code-block/index.d.ts +10 -0
- package/dist/components/code-block/index.js +5 -0
- package/dist/components/code-block/types.d.ts +85 -0
- package/dist/components/code-block/types.js +1 -0
- package/dist/components/code-group/CodeGroup.svelte +327 -0
- package/dist/components/code-group/CodeGroup.svelte.d.ts +24 -0
- package/dist/components/code-group/CodeGroupSelect.svelte +170 -0
- package/dist/components/code-group/CodeGroupSelect.svelte.d.ts +25 -0
- package/dist/components/code-group/CodeSelectDropdown.svelte +74 -0
- package/dist/components/code-group/CodeSelectDropdown.svelte.d.ts +9 -0
- package/dist/components/code-group/LanguageDropdown.svelte +134 -0
- package/dist/components/code-group/LanguageDropdown.svelte.d.ts +11 -0
- package/dist/components/code-group/LanguageIcon.svelte +24 -0
- package/dist/components/code-group/LanguageIcon.svelte.d.ts +8 -0
- package/dist/components/code-group/context.d.ts +14 -0
- package/dist/components/code-group/context.js +2 -0
- package/dist/components/code-group/index.d.ts +8 -0
- package/dist/components/code-group/index.js +4 -0
- package/dist/components/color/Color.svelte +34 -0
- package/dist/components/color/Color.svelte.d.ts +10 -0
- package/dist/components/color/ColorItem.svelte +140 -0
- package/dist/components/color/ColorItem.svelte.d.ts +10 -0
- package/dist/components/color/ColorRow.svelte +27 -0
- package/dist/components/color/ColorRow.svelte.d.ts +8 -0
- package/dist/components/color/index.d.ts +1 -0
- package/dist/components/color/index.js +8 -0
- package/dist/components/columns/Box.svelte +15 -0
- package/dist/components/columns/Box.svelte.d.ts +7 -0
- package/dist/components/columns/Columns.svelte +31 -0
- package/dist/components/columns/Columns.svelte.d.ts +10 -0
- package/dist/components/columns/constants.d.ts +5 -0
- package/dist/components/columns/constants.js +3 -0
- package/dist/components/columns/index.d.ts +5 -0
- package/dist/components/columns/index.js +3 -0
- package/dist/components/expandable/Expandable.svelte +182 -0
- package/dist/components/expandable/Expandable.svelte.d.ts +22 -0
- package/dist/components/expandable/index.d.ts +3 -0
- package/dist/components/expandable/index.js +2 -0
- package/dist/components/frame/Frame.svelte +118 -0
- package/dist/components/frame/Frame.svelte.d.ts +15 -0
- package/dist/components/frame/index.d.ts +3 -0
- package/dist/components/frame/index.js +2 -0
- package/dist/components/icon/Icon.svelte +129 -0
- package/dist/components/icon/Icon.svelte.d.ts +18 -0
- package/dist/components/icon/index.d.ts +2 -0
- package/dist/components/icon/index.js +1 -0
- package/dist/components/index.d.ts +22 -0
- package/dist/components/index.js +22 -0
- package/dist/components/mermaid/Mermaid.svelte +181 -0
- package/dist/components/mermaid/Mermaid.svelte.d.ts +11 -0
- package/dist/components/mermaid/ZoomControls.svelte +74 -0
- package/dist/components/mermaid/ZoomControls.svelte.d.ts +12 -0
- package/dist/components/mermaid/index.d.ts +7 -0
- package/dist/components/mermaid/index.js +4 -0
- package/dist/components/mermaid/use-pan-zoom.svelte.d.ts +11 -0
- package/dist/components/mermaid/use-pan-zoom.svelte.js +41 -0
- package/dist/components/panel/Panel.svelte +27 -0
- package/dist/components/panel/Panel.svelte.d.ts +9 -0
- package/dist/components/panel/index.d.ts +3 -0
- package/dist/components/panel/index.js +2 -0
- package/dist/components/property/DeprecatedPill.svelte +16 -0
- package/dist/components/property/DeprecatedPill.svelte.d.ts +6 -0
- package/dist/components/property/InfoPill.svelte +32 -0
- package/dist/components/property/InfoPill.svelte.d.ts +10 -0
- package/dist/components/property/ParamHead.svelte +188 -0
- package/dist/components/property/ParamHead.svelte.d.ts +22 -0
- package/dist/components/property/Property.svelte +123 -0
- package/dist/components/property/Property.svelte.d.ts +24 -0
- package/dist/components/property/RequiredPill.svelte +16 -0
- package/dist/components/property/RequiredPill.svelte.d.ts +6 -0
- package/dist/components/property/index.d.ts +11 -0
- package/dist/components/property/index.js +6 -0
- package/dist/components/search/index.d.ts +7 -0
- package/dist/components/search/index.js +4 -0
- package/dist/components/search/use-search.d.ts +9 -0
- package/dist/components/search/use-search.js +6 -0
- package/dist/components/steps/Step.svelte +314 -0
- package/dist/components/steps/Step.svelte.d.ts +26 -0
- package/dist/components/steps/Steps.svelte +51 -0
- package/dist/components/steps/Steps.svelte.d.ts +11 -0
- package/dist/components/steps/constants.d.ts +4 -0
- package/dist/components/steps/constants.js +2 -0
- package/dist/components/steps/context.d.ts +10 -0
- package/dist/components/steps/context.js +2 -0
- package/dist/components/steps/index.d.ts +32 -0
- package/dist/components/steps/index.js +6 -0
- package/dist/components/tabs/Tabs.svelte +254 -0
- package/dist/components/tabs/Tabs.svelte.d.ts +16 -0
- package/dist/components/tabs/TabsItem.svelte +56 -0
- package/dist/components/tabs/TabsItem.svelte.d.ts +15 -0
- package/dist/components/tabs/context.d.ts +20 -0
- package/dist/components/tabs/context.js +2 -0
- package/dist/components/tabs/index.d.ts +27 -0
- package/dist/components/tabs/index.js +5 -0
- package/dist/components/tile/Tile.svelte +124 -0
- package/dist/components/tile/Tile.svelte.d.ts +12 -0
- package/dist/components/tile/index.d.ts +2 -0
- package/dist/components/tile/index.js +1 -0
- package/dist/components/tooltip/Tooltip.svelte +170 -0
- package/dist/components/tooltip/Tooltip.svelte.d.ts +23 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/tree/Tree.svelte +226 -0
- package/dist/components/tree/Tree.svelte.d.ts +9 -0
- package/dist/components/tree/TreeFile.svelte +44 -0
- package/dist/components/tree/TreeFile.svelte.d.ts +6 -0
- package/dist/components/tree/TreeFolder.svelte +107 -0
- package/dist/components/tree/TreeFolder.svelte.d.ts +10 -0
- package/dist/components/tree/context.d.ts +3 -0
- package/dist/components/tree/context.js +7 -0
- package/dist/components/tree/index.d.ts +10 -0
- package/dist/components/tree/index.js +9 -0
- package/dist/components/tree/tree-level-context.d.ts +8 -0
- package/dist/components/tree/tree-level-context.js +7 -0
- package/dist/components/tree/use-tree-level.d.ts +3 -0
- package/dist/components/tree/use-tree-level.js +5 -0
- package/dist/components/tree/utils.d.ts +9 -0
- package/dist/components/tree/utils.js +86 -0
- package/dist/components/update/Update.svelte +210 -0
- package/dist/components/update/Update.svelte.d.ts +34 -0
- package/dist/components/update/index.d.ts +4 -0
- package/dist/components/update/index.js +3 -0
- package/dist/components/view/View.svelte +52 -0
- package/dist/components/view/View.svelte.d.ts +14 -0
- package/dist/components/view/index.d.ts +3 -0
- package/dist/components/view/index.js +2 -0
- package/dist/constants/brands.d.ts +2 -0
- package/dist/constants/brands.js +4 -0
- package/dist/constants/index.d.ts +6 -0
- package/dist/constants/index.js +6 -0
- package/dist/constants/selectors.d.ts +125 -0
- package/dist/constants/selectors.js +125 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/use-expandable-memory.svelte.d.ts +6 -0
- package/dist/hooks/use-expandable-memory.svelte.js +89 -0
- package/dist/hooks/use-expandable.svelte.d.ts +15 -0
- package/dist/hooks/use-expandable.svelte.js +53 -0
- package/dist/hooks/use-get-shiki-highlighted-html.svelte.d.ts +8 -0
- package/dist/hooks/use-get-shiki-highlighted-html.svelte.js +36 -0
- package/dist/hooks/use-has-hover.d.ts +2 -0
- package/dist/hooks/use-has-hover.js +10 -0
- package/dist/hooks/use-is-dark-theme.svelte.d.ts +3 -0
- package/dist/hooks/use-is-dark-theme.svelte.js +25 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts +3 -0
- package/dist/hooks/use-isomorphic-layout-effect.js +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/styles.css +2 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.js +7 -0
- package/dist/utils/copy-to-clipboard.d.ts +4 -0
- package/dist/utils/copy-to-clipboard.js +50 -0
- package/dist/utils/dedent.d.ts +1 -0
- package/dist/utils/dedent.js +125 -0
- package/dist/utils/enhance-video-props.d.ts +4 -0
- package/dist/utils/enhance-video-props.js +25 -0
- package/dist/utils/get-node-text.d.ts +2 -0
- package/dist/utils/get-node-text.js +26 -0
- package/dist/utils/icon-utils.d.ts +18 -0
- package/dist/utils/icon-utils.js +30 -0
- package/dist/utils/is-absolute-url.d.ts +4 -0
- package/dist/utils/is-absolute-url.js +11 -0
- package/dist/utils/is-remote-url.d.ts +2 -0
- package/dist/utils/is-remote-url.js +12 -0
- package/dist/utils/make-marker-ids-unique.d.ts +2 -0
- package/dist/utils/make-marker-ids-unique.js +36 -0
- package/dist/utils/shiki/code-styling.d.ts +13 -0
- package/dist/utils/shiki/code-styling.js +1 -0
- package/dist/utils/shiki/constants.d.ts +21 -0
- package/dist/utils/shiki/constants.js +116 -0
- package/dist/utils/shiki/get-code-styling.d.ts +9 -0
- package/dist/utils/shiki/get-code-styling.js +38 -0
- package/dist/utils/shiki/get-shiki-background-colors.d.ts +20 -0
- package/dist/utils/shiki/get-shiki-background-colors.js +56 -0
- package/dist/utils/shiki/index.d.ts +30 -0
- package/dist/utils/shiki/index.js +209 -0
- package/dist/utils/shiki/lib.d.ts +4 -0
- package/dist/utils/shiki/lib.js +49 -0
- package/dist/utils/shiki/shiki-themes.d.ts +2 -0
- package/dist/utils/shiki/shiki-themes.js +64 -0
- package/dist/utils/shiki/snippet-presets.d.ts +27 -0
- package/dist/utils/shiki/snippet-presets.js +44 -0
- package/dist/utils/shiki/worker-client.d.ts +9 -0
- package/dist/utils/shiki/worker-client.js +22 -0
- package/dist/utils/shiki/worker.d.ts +1 -0
- package/dist/utils/shiki/worker.js +134 -0
- package/dist/utils/slugify.d.ts +2 -0
- package/dist/utils/slugify.js +9 -0
- package/package.json +100 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import { MAX_DEFAULT_VALUE_LENGTH } from "../../constants";
|
|
4
|
+
import { Classes } from "../../constants/selectors";
|
|
5
|
+
import { cn } from "../../utils/cn";
|
|
6
|
+
import ParamHead from "./ParamHead.svelte";
|
|
7
|
+
|
|
8
|
+
type PropertyProps = {
|
|
9
|
+
name: string;
|
|
10
|
+
type: string;
|
|
11
|
+
location?: string;
|
|
12
|
+
hidden?: boolean;
|
|
13
|
+
default?: unknown;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
deprecated?: boolean;
|
|
16
|
+
children?: Snippet | string;
|
|
17
|
+
id?: string;
|
|
18
|
+
pre?: string[];
|
|
19
|
+
post?: string[];
|
|
20
|
+
class?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
onMount?: () => void;
|
|
23
|
+
navigateToHeaderAriaLabel?: string;
|
|
24
|
+
defaultLabel?: string;
|
|
25
|
+
requiredLabel?: string;
|
|
26
|
+
deprecatedLabel?: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const DEFAULT_NAVIGATE_TO_HEADER_ARIA_LABEL = "Navigate to header";
|
|
30
|
+
const DEFAULT_DEFAULT_LABEL = "default";
|
|
31
|
+
const DEFAULT_REQUIRED_LABEL = "required";
|
|
32
|
+
const DEFAULT_DEPRECATED_LABEL = "deprecated";
|
|
33
|
+
|
|
34
|
+
let {
|
|
35
|
+
name,
|
|
36
|
+
type,
|
|
37
|
+
location,
|
|
38
|
+
hidden,
|
|
39
|
+
default: defaultValue,
|
|
40
|
+
required,
|
|
41
|
+
deprecated,
|
|
42
|
+
children,
|
|
43
|
+
id,
|
|
44
|
+
pre,
|
|
45
|
+
post,
|
|
46
|
+
class: classAttribute,
|
|
47
|
+
className,
|
|
48
|
+
onMount,
|
|
49
|
+
navigateToHeaderAriaLabel = DEFAULT_NAVIGATE_TO_HEADER_ARIA_LABEL,
|
|
50
|
+
defaultLabel = DEFAULT_DEFAULT_LABEL,
|
|
51
|
+
requiredLabel = DEFAULT_REQUIRED_LABEL,
|
|
52
|
+
deprecatedLabel = DEFAULT_DEPRECATED_LABEL,
|
|
53
|
+
}: PropertyProps = $props();
|
|
54
|
+
|
|
55
|
+
let propertyClass = $derived(
|
|
56
|
+
cn(
|
|
57
|
+
Classes.Field,
|
|
58
|
+
"my-2.5 border-stone-50 border-b pt-2.5 pb-5 dark:border-stone-800/50",
|
|
59
|
+
classAttribute ?? className
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
let stringifiedDefaultValue = $derived.by(() => {
|
|
64
|
+
if (defaultValue !== null && typeof defaultValue === "object") {
|
|
65
|
+
// don't display values with nested objects; looks bad on one line
|
|
66
|
+
const containsNestedObject = Object.values(
|
|
67
|
+
defaultValue as Record<string, unknown>
|
|
68
|
+
).some((value) => value !== null && typeof value === "object");
|
|
69
|
+
|
|
70
|
+
if (containsNestedObject) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
const stringifiedValue = JSON.stringify(defaultValue);
|
|
77
|
+
if (
|
|
78
|
+
stringifiedValue &&
|
|
79
|
+
stringifiedValue.length > 0 &&
|
|
80
|
+
stringifiedValue.length < MAX_DEFAULT_VALUE_LENGTH
|
|
81
|
+
) {
|
|
82
|
+
return stringifiedValue;
|
|
83
|
+
}
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return null;
|
|
89
|
+
});
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
{#if !hidden}
|
|
93
|
+
<div class={propertyClass}>
|
|
94
|
+
<ParamHead
|
|
95
|
+
default={stringifiedDefaultValue}
|
|
96
|
+
defaultLabel={defaultLabel}
|
|
97
|
+
deprecated={deprecated}
|
|
98
|
+
deprecatedLabel={deprecatedLabel}
|
|
99
|
+
id={id}
|
|
100
|
+
location={location}
|
|
101
|
+
name={name}
|
|
102
|
+
navigateToHeaderAriaLabel={navigateToHeaderAriaLabel}
|
|
103
|
+
onMount={onMount}
|
|
104
|
+
post={post}
|
|
105
|
+
pre={pre}
|
|
106
|
+
required={required}
|
|
107
|
+
requiredLabel={requiredLabel}
|
|
108
|
+
type={type}
|
|
109
|
+
/>
|
|
110
|
+
{#if children}
|
|
111
|
+
<div
|
|
112
|
+
class="prose-sm prose-stone dark:prose-invert mt-4 [&_.prose>p:first-child]:mt-0 [&_.prose>p:last-child]:mb-0"
|
|
113
|
+
data-component-part="field-content"
|
|
114
|
+
>
|
|
115
|
+
{#if typeof children === "string"}
|
|
116
|
+
{children}
|
|
117
|
+
{:else}
|
|
118
|
+
{@render children()}
|
|
119
|
+
{/if}
|
|
120
|
+
</div>
|
|
121
|
+
{/if}
|
|
122
|
+
</div>
|
|
123
|
+
{/if}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
type PropertyProps = {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
location?: string;
|
|
6
|
+
hidden?: boolean;
|
|
7
|
+
default?: unknown;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
deprecated?: boolean;
|
|
10
|
+
children?: Snippet | string;
|
|
11
|
+
id?: string;
|
|
12
|
+
pre?: string[];
|
|
13
|
+
post?: string[];
|
|
14
|
+
class?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
onMount?: () => void;
|
|
17
|
+
navigateToHeaderAriaLabel?: string;
|
|
18
|
+
defaultLabel?: string;
|
|
19
|
+
requiredLabel?: string;
|
|
20
|
+
deprecatedLabel?: string;
|
|
21
|
+
};
|
|
22
|
+
declare const Property: import("svelte").Component<PropertyProps, {}, "">;
|
|
23
|
+
type Property = ReturnType<typeof Property>;
|
|
24
|
+
export default Property;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
type RequiredPillProps = {
|
|
3
|
+
label?: string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
let { label }: RequiredPillProps = $props();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
{#if label}
|
|
10
|
+
<div
|
|
11
|
+
class="whitespace-nowrap rounded-md bg-red-100/50 px-2 py-0.5 font-medium text-red-600 dark:bg-red-400/10 dark:text-red-300"
|
|
12
|
+
data-component-part="field-required-pill"
|
|
13
|
+
>
|
|
14
|
+
{label}
|
|
15
|
+
</div>
|
|
16
|
+
{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import DeprecatedPill from "./DeprecatedPill.svelte";
|
|
2
|
+
import InfoPill from "./InfoPill.svelte";
|
|
3
|
+
import ParamHead from "./ParamHead.svelte";
|
|
4
|
+
import Property from "./Property.svelte";
|
|
5
|
+
import RequiredPill from "./RequiredPill.svelte";
|
|
6
|
+
export type { default as ParamHeadProps } from "./ParamHead.svelte";
|
|
7
|
+
export type { default as DeprecatedPillProps } from "./DeprecatedPill.svelte";
|
|
8
|
+
export type { default as InfoPillProps } from "./InfoPill.svelte";
|
|
9
|
+
export type { default as PropertyProps } from "./Property.svelte";
|
|
10
|
+
export type { default as RequiredPillProps } from "./RequiredPill.svelte";
|
|
11
|
+
export { DeprecatedPill, InfoPill, ParamHead, Property, RequiredPill };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import DeprecatedPill from "./DeprecatedPill.svelte";
|
|
2
|
+
import InfoPill from "./InfoPill.svelte";
|
|
3
|
+
import ParamHead from "./ParamHead.svelte";
|
|
4
|
+
import Property from "./Property.svelte";
|
|
5
|
+
import RequiredPill from "./RequiredPill.svelte";
|
|
6
|
+
export { DeprecatedPill, InfoPill, ParamHead, Property, RequiredPill };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { SearchButtonProps } from "../SearchButton.svelte";
|
|
2
|
+
export { default as SearchButton } from "../SearchButton.svelte";
|
|
3
|
+
export type { SearchContextValue, SearchProviderProps } from "../SearchProvider.svelte";
|
|
4
|
+
export { default as SearchProvider } from "../SearchProvider.svelte";
|
|
5
|
+
export { useSearch } from "./use-search";
|
|
6
|
+
export type { SearchProps, SearchResult } from "../Search.svelte";
|
|
7
|
+
export { default as Search } from "../Search.svelte";
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, onMount, untrack } from "svelte";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import Icon from "../icon/Icon.svelte";
|
|
5
|
+
import { Classes } from "../../constants/selectors";
|
|
6
|
+
import { copyToClipboard } from "../../utils/copy-to-clipboard";
|
|
7
|
+
import { cn } from "../../utils/cn";
|
|
8
|
+
import type { IconLibrary, IconType } from "../../utils/icon-utils";
|
|
9
|
+
import { STEPS_CONTEXT, type StepsContext } from "./context";
|
|
10
|
+
import { STEP_TITLE_SIZES, type StepTitleSize } from "./constants";
|
|
11
|
+
|
|
12
|
+
type Numberish = number | `${number}`;
|
|
13
|
+
|
|
14
|
+
type StepProps = {
|
|
15
|
+
icon?: string | Snippet;
|
|
16
|
+
stepNumber?: Numberish;
|
|
17
|
+
iconType?: IconType;
|
|
18
|
+
iconLibrary?: IconLibrary;
|
|
19
|
+
title: string | Snippet;
|
|
20
|
+
children?: string | Snippet;
|
|
21
|
+
titleSize?: StepTitleSize;
|
|
22
|
+
class?: string;
|
|
23
|
+
className?: string;
|
|
24
|
+
isLast?: boolean;
|
|
25
|
+
id?: string;
|
|
26
|
+
noAnchor?: boolean;
|
|
27
|
+
scrollElementIntoView?: (id: string) => void;
|
|
28
|
+
onCopyAnchorLink?: (id: string | undefined) => void;
|
|
29
|
+
onRegisterHeading?: (id: string, rect: DOMRect) => void;
|
|
30
|
+
onUnregisterHeading?: (id: string) => void;
|
|
31
|
+
_hasContext?: boolean;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
let {
|
|
35
|
+
stepNumber,
|
|
36
|
+
icon,
|
|
37
|
+
iconType,
|
|
38
|
+
iconLibrary,
|
|
39
|
+
title,
|
|
40
|
+
children,
|
|
41
|
+
titleSize,
|
|
42
|
+
class: classAttribute,
|
|
43
|
+
className,
|
|
44
|
+
isLast = false,
|
|
45
|
+
id,
|
|
46
|
+
noAnchor = false,
|
|
47
|
+
scrollElementIntoView,
|
|
48
|
+
onRegisterHeading,
|
|
49
|
+
onUnregisterHeading,
|
|
50
|
+
_hasContext,
|
|
51
|
+
onCopyAnchorLink,
|
|
52
|
+
}: StepProps = $props();
|
|
53
|
+
|
|
54
|
+
const stepsContext = getContext<StepsContext | undefined>(STEPS_CONTEXT);
|
|
55
|
+
const stepId = Symbol("steps-item");
|
|
56
|
+
|
|
57
|
+
let stepElement: HTMLDivElement | null = $state(null);
|
|
58
|
+
let rect: DOMRect | null = $state(null);
|
|
59
|
+
let isTitleHovered = $state(false);
|
|
60
|
+
|
|
61
|
+
$effect(() => {
|
|
62
|
+
if (!stepsContext) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
untrack(() => stepsContext.register(stepId));
|
|
67
|
+
return () => untrack(() => stepsContext.unregister(stepId));
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
function observeStep(node: HTMLDivElement) {
|
|
71
|
+
stepElement = node;
|
|
72
|
+
|
|
73
|
+
const measure = () => {
|
|
74
|
+
rect = node.getBoundingClientRect();
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
measure();
|
|
78
|
+
|
|
79
|
+
if (typeof ResizeObserver === "undefined") {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const resizeObserver = new ResizeObserver(measure);
|
|
84
|
+
resizeObserver.observe(node);
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
destroy() {
|
|
88
|
+
resizeObserver.unobserve(node);
|
|
89
|
+
if (stepElement === node) {
|
|
90
|
+
stepElement = null;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let stepIndex = $derived(stepsContext?.items.indexOf(stepId) ?? 0);
|
|
97
|
+
let stepCount = $derived(stepsContext?.items.length ?? 1);
|
|
98
|
+
let resolvedStepNumber = $derived(stepNumber ?? stepIndex + 1);
|
|
99
|
+
let resolvedTitleSize = $derived(titleSize ?? stepsContext?.titleSize ?? "p");
|
|
100
|
+
let titleTag = $derived(
|
|
101
|
+
STEP_TITLE_SIZES.includes(resolvedTitleSize) ? resolvedTitleSize : "p"
|
|
102
|
+
);
|
|
103
|
+
let isAnchorEnabled = $derived(titleTag === "h2" || titleTag === "h3");
|
|
104
|
+
let resolvedIsLast = $derived(
|
|
105
|
+
stepsContext ? stepIndex === stepCount - 1 : isLast
|
|
106
|
+
);
|
|
107
|
+
let itemClass = $derived(
|
|
108
|
+
cn(
|
|
109
|
+
Classes.Step,
|
|
110
|
+
"group/step relative flex items-start pb-5",
|
|
111
|
+
classAttribute ?? className
|
|
112
|
+
)
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Match React's heading registration effect for integrations that provide
|
|
116
|
+
// the optional heading context callbacks.
|
|
117
|
+
$effect(() => {
|
|
118
|
+
if (!(_hasContext && id && rect)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
onRegisterHeading?.(id, rect);
|
|
123
|
+
|
|
124
|
+
return () => {
|
|
125
|
+
onUnregisterHeading?.(id);
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Scrolling happens only once, on initial load, after the element mounts.
|
|
130
|
+
onMount(() => {
|
|
131
|
+
if (!id || noAnchor) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
const hash = decodeURIComponent(window.location.hash.substring(1));
|
|
137
|
+
if (hash === id) {
|
|
138
|
+
scrollElementIntoView?.(id);
|
|
139
|
+
}
|
|
140
|
+
} catch {
|
|
141
|
+
// silently fail if the hash is invalid
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
async function copyAnchorLink() {
|
|
146
|
+
if (!isAnchorEnabled || noAnchor || !id || typeof window === "undefined") {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const encodedId = encodeURIComponent(id);
|
|
151
|
+
const result = await copyToClipboard(
|
|
152
|
+
`${window.location.href.split("#")[0]}#${encodedId}`
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
if (result === "success") {
|
|
156
|
+
window.location.hash = encodedId;
|
|
157
|
+
onCopyAnchorLink?.(id);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function toggleAnchor(shown: boolean) {
|
|
162
|
+
if (!isAnchorEnabled || noAnchor || !id) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
isTitleHovered = shown;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const titleClasses = "mt-2 text-stone-900 dark:text-stone-200";
|
|
170
|
+
</script>
|
|
171
|
+
|
|
172
|
+
<!-- Svelte preserves the original list-item wrapper and its semantic role. -->
|
|
173
|
+
<div
|
|
174
|
+
bind:this={stepElement}
|
|
175
|
+
use:observeStep
|
|
176
|
+
class={itemClass}
|
|
177
|
+
data-component-part="step-item"
|
|
178
|
+
id={id}
|
|
179
|
+
role="listitem"
|
|
180
|
+
>
|
|
181
|
+
<div
|
|
182
|
+
class={cn(
|
|
183
|
+
"absolute top-11 h-[calc(100%-2.75rem)] w-px",
|
|
184
|
+
resolvedIsLast
|
|
185
|
+
? "bg-linear-to-b from-stone-200 via-80% via-stone-200 to-transparent dark:from-white/10 dark:via-white/10 [[data-component-part=step-item]:has([data-component-part=step-content]:empty)_&]:hidden"
|
|
186
|
+
: "bg-stone-200/70 dark:bg-white/10"
|
|
187
|
+
)}
|
|
188
|
+
contenteditable="false"
|
|
189
|
+
data-component-part="step-line"
|
|
190
|
+
></div>
|
|
191
|
+
<div
|
|
192
|
+
class="absolute ml-[-13px] py-2"
|
|
193
|
+
contenteditable="false"
|
|
194
|
+
data-component-part="step-number"
|
|
195
|
+
>
|
|
196
|
+
<!-- Svelte keeps the original hover target intact; the nested anchor remains the accessible control. -->
|
|
197
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
198
|
+
<div
|
|
199
|
+
class="relative flex size-7 shrink-0 items-center justify-center rounded-full bg-stone-50 font-semibold text-stone-900 text-xs dark:bg-white/10 dark:text-stone-50"
|
|
200
|
+
onmouseenter={() => toggleAnchor(true)}
|
|
201
|
+
onmouseleave={() => toggleAnchor(false)}
|
|
202
|
+
>
|
|
203
|
+
<div class={cn(isTitleHovered && "opacity-0")}>
|
|
204
|
+
<!-- Svelte conditional branches replace the original nested icon ternary. -->
|
|
205
|
+
{#if typeof icon === "string"}
|
|
206
|
+
<Icon
|
|
207
|
+
class="size-3 bg-stone-900 dark:bg-stone-50"
|
|
208
|
+
icon={icon}
|
|
209
|
+
iconLibrary={iconLibrary}
|
|
210
|
+
iconType={iconType}
|
|
211
|
+
overrideColor={true}
|
|
212
|
+
overrideSize={true}
|
|
213
|
+
/>
|
|
214
|
+
{:else if icon == null}
|
|
215
|
+
{Number(resolvedStepNumber)}
|
|
216
|
+
{:else}
|
|
217
|
+
{@render icon()}
|
|
218
|
+
{/if}
|
|
219
|
+
</div>
|
|
220
|
+
{#if isAnchorEnabled && !noAnchor && id}
|
|
221
|
+
<div class="absolute" data-component-part="step-number-anchor-link">
|
|
222
|
+
<a
|
|
223
|
+
aria-label="Navigate to header"
|
|
224
|
+
class={cn("flex items-center border-0 opacity-0", isTitleHovered && "opacity-100")}
|
|
225
|
+
href={`#${encodeURIComponent(id)}`}
|
|
226
|
+
onclick={(event) => {
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
void copyAnchorLink();
|
|
229
|
+
}}
|
|
230
|
+
>
|
|
231
|
+
<div class="flex size-6 items-center justify-center">
|
|
232
|
+
<span aria-hidden="true" class="contents">
|
|
233
|
+
<Icon
|
|
234
|
+
class="size-3 bg-stone-900 dark:bg-stone-50"
|
|
235
|
+
icon="link"
|
|
236
|
+
overrideColor={true}
|
|
237
|
+
overrideSize={true}
|
|
238
|
+
/>
|
|
239
|
+
</span>
|
|
240
|
+
</div>
|
|
241
|
+
</a>
|
|
242
|
+
</div>
|
|
243
|
+
{/if}
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
<div class="w-full overflow-hidden pr-px pl-8">
|
|
247
|
+
{#if title}
|
|
248
|
+
{#if titleTag === "h2"}
|
|
249
|
+
<!-- The title click handler preserves the original anchor-copy behavior without changing the heading element. -->
|
|
250
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
251
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
252
|
+
<h2
|
|
253
|
+
class={titleClasses}
|
|
254
|
+
contenteditable="false"
|
|
255
|
+
data-component-part="step-title"
|
|
256
|
+
onclick={() => void copyAnchorLink()}
|
|
257
|
+
onmouseenter={() => toggleAnchor(true)}
|
|
258
|
+
onmouseleave={() => toggleAnchor(false)}
|
|
259
|
+
>
|
|
260
|
+
{#if typeof title === "string"}{title}{:else}{@render title()}{/if}
|
|
261
|
+
</h2>
|
|
262
|
+
{:else if titleTag === "h3"}
|
|
263
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
264
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
265
|
+
<h3
|
|
266
|
+
class={titleClasses}
|
|
267
|
+
contenteditable="false"
|
|
268
|
+
data-component-part="step-title"
|
|
269
|
+
onclick={() => void copyAnchorLink()}
|
|
270
|
+
onmouseenter={() => toggleAnchor(true)}
|
|
271
|
+
onmouseleave={() => toggleAnchor(false)}
|
|
272
|
+
>
|
|
273
|
+
{#if typeof title === "string"}{title}{:else}{@render title()}{/if}
|
|
274
|
+
</h3>
|
|
275
|
+
{:else if titleTag === "h4"}
|
|
276
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
277
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
278
|
+
<h4
|
|
279
|
+
class={titleClasses}
|
|
280
|
+
contenteditable="false"
|
|
281
|
+
data-component-part="step-title"
|
|
282
|
+
onclick={() => void copyAnchorLink()}
|
|
283
|
+
onmouseenter={() => toggleAnchor(true)}
|
|
284
|
+
onmouseleave={() => toggleAnchor(false)}
|
|
285
|
+
>
|
|
286
|
+
{#if typeof title === "string"}{title}{:else}{@render title()}{/if}
|
|
287
|
+
</h4>
|
|
288
|
+
{:else}
|
|
289
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
290
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
291
|
+
<p
|
|
292
|
+
class={cn(titleClasses, "prose dark:prose-invert font-semibold")}
|
|
293
|
+
contenteditable="false"
|
|
294
|
+
data-component-part="step-title"
|
|
295
|
+
onclick={() => void copyAnchorLink()}
|
|
296
|
+
onmouseenter={() => toggleAnchor(true)}
|
|
297
|
+
onmouseleave={() => toggleAnchor(false)}
|
|
298
|
+
>
|
|
299
|
+
{#if typeof title === "string"}{title}{:else}{@render title()}{/if}
|
|
300
|
+
</p>
|
|
301
|
+
{/if}
|
|
302
|
+
{/if}
|
|
303
|
+
<div
|
|
304
|
+
class={cn("prose dark:prose-invert", !title && "mt-2")}
|
|
305
|
+
data-component-part="step-content"
|
|
306
|
+
>
|
|
307
|
+
{#if typeof children === "string"}
|
|
308
|
+
{children}
|
|
309
|
+
{:else if children}
|
|
310
|
+
{@render children()}
|
|
311
|
+
{/if}
|
|
312
|
+
</div>
|
|
313
|
+
</div>
|
|
314
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { IconLibrary, IconType } from "../../utils/icon-utils";
|
|
3
|
+
import { type StepTitleSize } from "./constants";
|
|
4
|
+
type Numberish = number | `${number}`;
|
|
5
|
+
type StepProps = {
|
|
6
|
+
icon?: string | Snippet;
|
|
7
|
+
stepNumber?: Numberish;
|
|
8
|
+
iconType?: IconType;
|
|
9
|
+
iconLibrary?: IconLibrary;
|
|
10
|
+
title: string | Snippet;
|
|
11
|
+
children?: string | Snippet;
|
|
12
|
+
titleSize?: StepTitleSize;
|
|
13
|
+
class?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
isLast?: boolean;
|
|
16
|
+
id?: string;
|
|
17
|
+
noAnchor?: boolean;
|
|
18
|
+
scrollElementIntoView?: (id: string) => void;
|
|
19
|
+
onCopyAnchorLink?: (id: string | undefined) => void;
|
|
20
|
+
onRegisterHeading?: (id: string, rect: DOMRect) => void;
|
|
21
|
+
onUnregisterHeading?: (id: string) => void;
|
|
22
|
+
_hasContext?: boolean;
|
|
23
|
+
};
|
|
24
|
+
declare const Step: import("svelte").Component<StepProps, {}, "">;
|
|
25
|
+
type Step = ReturnType<typeof Step>;
|
|
26
|
+
export default Step;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { setContext } from "svelte";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import { Classes } from "../../constants/selectors";
|
|
5
|
+
import { cn } from "../../utils/cn";
|
|
6
|
+
import { STEPS_CONTEXT, type StepsContext } from "./context";
|
|
7
|
+
import type { StepTitleSize } from "./constants";
|
|
8
|
+
|
|
9
|
+
type StepsProps = {
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
titleSize?: StepTitleSize;
|
|
12
|
+
class?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
children,
|
|
18
|
+
titleSize,
|
|
19
|
+
class: classAttribute,
|
|
20
|
+
className,
|
|
21
|
+
}: StepsProps = $props();
|
|
22
|
+
|
|
23
|
+
const stepsContext: StepsContext = $state({
|
|
24
|
+
items: [],
|
|
25
|
+
register(id) {
|
|
26
|
+
if (!stepsContext.items.includes(id)) {
|
|
27
|
+
stepsContext.items = [...stepsContext.items, id];
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
unregister(id) {
|
|
31
|
+
stepsContext.items = stepsContext.items.filter((itemId) => itemId !== id);
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
$effect(() => {
|
|
36
|
+
stepsContext.titleSize = titleSize;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
setContext(STEPS_CONTEXT, stepsContext);
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<!-- Svelte preserves the original list wrapper and its component-part contract. -->
|
|
43
|
+
<div
|
|
44
|
+
class={cn(Classes.Steps, "mt-10 mb-6 ml-3.5", classAttribute ?? className)}
|
|
45
|
+
data-component-part="steps"
|
|
46
|
+
role="list"
|
|
47
|
+
>
|
|
48
|
+
{#if children}
|
|
49
|
+
{@render children()}
|
|
50
|
+
{/if}
|
|
51
|
+
</div>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { StepTitleSize } from "./constants";
|
|
3
|
+
type StepsProps = {
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
titleSize?: StepTitleSize;
|
|
6
|
+
class?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const Steps: import("svelte").Component<StepsProps, {}, "">;
|
|
10
|
+
type Steps = ReturnType<typeof Steps>;
|
|
11
|
+
export default Steps;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { StepTitleSize } from "./constants";
|
|
2
|
+
type StepsContext = {
|
|
3
|
+
items: symbol[];
|
|
4
|
+
titleSize?: StepTitleSize;
|
|
5
|
+
register: (id: symbol) => void;
|
|
6
|
+
unregister: (id: symbol) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const STEPS_CONTEXT: unique symbol;
|
|
9
|
+
export type { StepsContext };
|
|
10
|
+
export { STEPS_CONTEXT };
|