@webamoki/web-svelte 0.1.1 → 0.3.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.
Files changed (40) hide show
  1. package/README.md +4 -55
  2. package/dist/components/form/FieldWrapper.svelte +6 -0
  3. package/dist/components/form/FieldWrapper.svelte.d.ts +5 -0
  4. package/dist/components/form/fields/ChoiceField.svelte +44 -0
  5. package/dist/components/form/fields/ChoiceField.svelte.d.ts +27 -0
  6. package/dist/components/form/fields/ChoiceMultiField.svelte +46 -0
  7. package/dist/components/form/fields/ChoiceMultiField.svelte.d.ts +27 -0
  8. package/dist/components/form/fields/WeekdayChoiceField.svelte +41 -0
  9. package/dist/components/form/fields/WeekdayChoiceField.svelte.d.ts +27 -0
  10. package/dist/components/form/fields/WeekdayChoiceMultiField.svelte +41 -0
  11. package/dist/components/form/fields/WeekdayChoiceMultiField.svelte.d.ts +27 -0
  12. package/dist/components/index.d.ts +7 -1
  13. package/dist/components/index.js +7 -1
  14. package/dist/components/showcase/CodeBlock.svelte +52 -0
  15. package/dist/components/showcase/CodeBlock.svelte.d.ts +30 -0
  16. package/dist/components/showcase/Container.svelte +13 -0
  17. package/dist/components/showcase/Container.svelte.d.ts +24 -0
  18. package/dist/components/showcase/Preview.svelte +6 -0
  19. package/dist/components/showcase/Preview.svelte.d.ts +26 -0
  20. package/dist/components/showcase/Sidebar.svelte +6 -0
  21. package/dist/components/showcase/Sidebar.svelte.d.ts +26 -0
  22. package/dist/components/showcase/SidebarLink.svelte +7 -0
  23. package/dist/components/showcase/SidebarLink.svelte.d.ts +20 -0
  24. package/dist/components/ui/choice/Choice.svelte +27 -0
  25. package/dist/components/ui/choice/Choice.svelte.d.ts +29 -0
  26. package/dist/components/ui/choice/ChoiceInternal.svelte +57 -0
  27. package/dist/components/ui/choice/ChoiceInternal.svelte.d.ts +34 -0
  28. package/dist/components/ui/choice/ChoiceMulti.svelte +55 -0
  29. package/dist/components/ui/choice/ChoiceMulti.svelte.d.ts +30 -0
  30. package/dist/components/ui/choice/WeekdayChoice.svelte +28 -0
  31. package/dist/components/ui/choice/WeekdayChoice.svelte.d.ts +13 -0
  32. package/dist/components/ui/choice/WeekdayChoiceMulti.svelte +29 -0
  33. package/dist/components/ui/choice/WeekdayChoiceMulti.svelte.d.ts +14 -0
  34. package/dist/highlight.d.ts +1 -0
  35. package/dist/highlight.js +9 -0
  36. package/dist/utils/datetime/index.d.ts +168 -0
  37. package/dist/utils/datetime/index.js +322 -0
  38. package/dist/utils/index.d.ts +1 -1
  39. package/dist/utils/index.js +1 -2
  40. package/package.json +7 -3
package/README.md CHANGED
@@ -1,58 +1,7 @@
1
- # Svelte library
1
+ # Setup
2
2
 
3
- Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
3
+ in the main css file, e.g. `app.css`, add the following line:
4
4
 
5
- Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
6
-
7
- ## Creating a project
8
-
9
- If you're seeing this, you've probably already done this step. Congrats!
10
-
11
- ```sh
12
- # create a new project in the current directory
13
- npx sv create
14
-
15
- # create a new project in my-app
16
- npx sv create my-app
17
- ```
18
-
19
- ## Developing
20
-
21
- Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
22
-
23
- ```sh
24
- npm run dev
25
-
26
- # or start the server and open the app in a new browser tab
27
- npm run dev -- --open
28
- ```
29
-
30
- Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
31
-
32
- ## Building
33
-
34
- To build your library:
35
-
36
- ```sh
37
- npm pack
38
- ```
39
-
40
- To create a production version of your showcase app:
41
-
42
- ```sh
43
- npm run build
44
- ```
45
-
46
- You can preview the production build with `npm run preview`.
47
-
48
- > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
49
-
50
- ## Publishing
51
-
52
- Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
53
-
54
- To publish your library to [npm](https://www.npmjs.com):
55
-
56
- ```sh
57
- npm publish
5
+ ```css
6
+ @source "../...path/node_modules/@webamoki/web-svelte/dist/**/*.{js,svelte,ts}";
58
7
  ```
@@ -5,6 +5,11 @@
5
5
  label?: string;
6
6
  description?: string;
7
7
  }
8
+
9
+ export interface FormAttrs extends ControlAttrs {
10
+ disabled?: HTMLInputAttributes['disabled'];
11
+ readonly?: HTMLInputAttributes['readonly'];
12
+ }
8
13
  </script>
9
14
 
10
15
  <script lang="ts" generics="T extends Record<string, unknown>, U extends FormPath<T>, M">
@@ -19,6 +24,7 @@
19
24
  import type { Snippet } from 'svelte';
20
25
  import type { FormPath } from 'sveltekit-superforms';
21
26
  import Errors from './Errors.svelte';
27
+ import type { HTMLInputAttributes } from 'svelte/elements';
22
28
 
23
29
  interface Props extends FieldWrapperProps<T, U, M> {
24
30
  formElem: Snippet<[ControlAttrs]>;
@@ -4,9 +4,14 @@ export interface FieldWrapperProps<T extends Record<string, unknown>, U extends
4
4
  label?: string;
5
5
  description?: string;
6
6
  }
7
+ export interface FormAttrs extends ControlAttrs {
8
+ disabled?: HTMLInputAttributes['disabled'];
9
+ readonly?: HTMLInputAttributes['readonly'];
10
+ }
7
11
  import { type ControlAttrs, type FsSuperForm } from 'formsnap';
8
12
  import type { Snippet } from 'svelte';
9
13
  import type { FormPath } from 'sveltekit-superforms';
14
+ import type { HTMLInputAttributes } from 'svelte/elements';
10
15
  declare function $$render<T extends Record<string, unknown>, U extends FormPath<T>, M>(): {
11
16
  props: FieldWrapperProps<T, U, M> & {
12
17
  formElem: Snippet<[ControlAttrs]>;
@@ -0,0 +1,44 @@
1
+ <script
2
+ lang="ts"
3
+ generics="V, K extends string | number | symbol,T extends Record<string, unknown>, U extends FormPath<T>, M"
4
+ >
5
+ import type { FormPath } from 'sveltekit-superforms';
6
+ import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
7
+ import Choice, { type ChoiceProps } from '../../ui/choice/Choice.svelte';
8
+
9
+ type Props = FieldWrapperProps<T, U, M> & ChoiceProps<V, K>;
10
+
11
+ let {
12
+ items,
13
+ getKey,
14
+ getLabel,
15
+ onChange,
16
+ vertical,
17
+ value = $bindable(undefined),
18
+
19
+ form,
20
+ name,
21
+ label,
22
+ description,
23
+ disabled,
24
+ readonly
25
+ }: Props = $props();
26
+ </script>
27
+
28
+ <FieldWrapper {form} {name} {label} {description}>
29
+ {#snippet formElem(props)}
30
+ <div class="flex w-full items-center gap-2">
31
+ <Choice
32
+ {items}
33
+ {getKey}
34
+ {getLabel}
35
+ {onChange}
36
+ {vertical}
37
+ {disabled}
38
+ {readonly}
39
+ bind:value
40
+ {...props}
41
+ />
42
+ </div>
43
+ {/snippet}
44
+ </FieldWrapper>
@@ -0,0 +1,27 @@
1
+ import type { FormPath } from 'sveltekit-superforms';
2
+ import { type FieldWrapperProps } from '../FieldWrapper.svelte';
3
+ import { type ChoiceProps } from '../../ui/choice/Choice.svelte';
4
+ declare function $$render<V, K extends string | number | symbol, T extends Record<string, unknown>, U extends FormPath<T>, M>(): {
5
+ props: FieldWrapperProps<T, U, M> & ChoiceProps<V, K>;
6
+ exports: {};
7
+ bindings: "value";
8
+ slots: {};
9
+ events: {};
10
+ };
11
+ declare class __sveltets_Render<V, K extends string | number | symbol, T extends Record<string, unknown>, U extends FormPath<T>, M> {
12
+ props(): ReturnType<typeof $$render<V, K, T, U, M>>['props'];
13
+ events(): ReturnType<typeof $$render<V, K, T, U, M>>['events'];
14
+ slots(): ReturnType<typeof $$render<V, K, T, U, M>>['slots'];
15
+ bindings(): "value";
16
+ exports(): {};
17
+ }
18
+ interface $$IsomorphicComponent {
19
+ new <V, K extends string | number | symbol, T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<V, K, T, U, M>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<V, K, T, U, M>['props']>, ReturnType<__sveltets_Render<V, K, T, U, M>['events']>, ReturnType<__sveltets_Render<V, K, T, U, M>['slots']>> & {
20
+ $$bindings?: ReturnType<__sveltets_Render<V, K, T, U, M>['bindings']>;
21
+ } & ReturnType<__sveltets_Render<V, K, T, U, M>['exports']>;
22
+ <V, K extends string | number | symbol, T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<V, K, T, U, M>['props']> & {}): ReturnType<__sveltets_Render<V, K, T, U, M>['exports']>;
23
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any, any, any, any>['bindings']>;
24
+ }
25
+ declare const ChoiceField: $$IsomorphicComponent;
26
+ type ChoiceField<V, K extends string | number | symbol, T extends Record<string, unknown>, U extends FormPath<T>, M> = InstanceType<typeof ChoiceField<V, K, T, U, M>>;
27
+ export default ChoiceField;
@@ -0,0 +1,46 @@
1
+ <script
2
+ lang="ts"
3
+ generics="V, K extends string | number | symbol,T extends Record<string, unknown>, U extends FormPath<T>, M"
4
+ >
5
+ import type { FormPath } from 'sveltekit-superforms';
6
+ import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
7
+ import { type ChoiceMultiProps } from '../../ui/choice/ChoiceMulti.svelte';
8
+ import ChoiceMulti from '../../ui/choice/ChoiceMulti.svelte';
9
+
10
+ type Props = FieldWrapperProps<T, U, M> & ChoiceMultiProps<V, K>;
11
+ let {
12
+ items,
13
+ getKey,
14
+ getLabel,
15
+ onAdd,
16
+ onRemove,
17
+ vertical,
18
+ value = $bindable([]),
19
+
20
+ form,
21
+ name,
22
+ label,
23
+ description,
24
+ disabled,
25
+ readonly
26
+ }: Props = $props();
27
+ </script>
28
+
29
+ <FieldWrapper {form} {name} {label} {description}>
30
+ {#snippet formElem(props)}
31
+ <div class="flex w-full items-center gap-2">
32
+ <ChoiceMulti
33
+ {items}
34
+ {getKey}
35
+ {getLabel}
36
+ {onAdd}
37
+ {onRemove}
38
+ {disabled}
39
+ {readonly}
40
+ {vertical}
41
+ {...props}
42
+ bind:value
43
+ />
44
+ </div>
45
+ {/snippet}
46
+ </FieldWrapper>
@@ -0,0 +1,27 @@
1
+ import type { FormPath } from 'sveltekit-superforms';
2
+ import { type FieldWrapperProps } from '../FieldWrapper.svelte';
3
+ import { type ChoiceMultiProps } from '../../ui/choice/ChoiceMulti.svelte';
4
+ declare function $$render<V, K extends string | number | symbol, T extends Record<string, unknown>, U extends FormPath<T>, M>(): {
5
+ props: FieldWrapperProps<T, U, M> & ChoiceMultiProps<V, K>;
6
+ exports: {};
7
+ bindings: "value";
8
+ slots: {};
9
+ events: {};
10
+ };
11
+ declare class __sveltets_Render<V, K extends string | number | symbol, T extends Record<string, unknown>, U extends FormPath<T>, M> {
12
+ props(): ReturnType<typeof $$render<V, K, T, U, M>>['props'];
13
+ events(): ReturnType<typeof $$render<V, K, T, U, M>>['events'];
14
+ slots(): ReturnType<typeof $$render<V, K, T, U, M>>['slots'];
15
+ bindings(): "value";
16
+ exports(): {};
17
+ }
18
+ interface $$IsomorphicComponent {
19
+ new <V, K extends string | number | symbol, T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<V, K, T, U, M>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<V, K, T, U, M>['props']>, ReturnType<__sveltets_Render<V, K, T, U, M>['events']>, ReturnType<__sveltets_Render<V, K, T, U, M>['slots']>> & {
20
+ $$bindings?: ReturnType<__sveltets_Render<V, K, T, U, M>['bindings']>;
21
+ } & ReturnType<__sveltets_Render<V, K, T, U, M>['exports']>;
22
+ <V, K extends string | number | symbol, T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<V, K, T, U, M>['props']> & {}): ReturnType<__sveltets_Render<V, K, T, U, M>['exports']>;
23
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any, any, any, any>['bindings']>;
24
+ }
25
+ declare const ChoiceMultiField: $$IsomorphicComponent;
26
+ type ChoiceMultiField<V, K extends string | number | symbol, T extends Record<string, unknown>, U extends FormPath<T>, M> = InstanceType<typeof ChoiceMultiField<V, K, T, U, M>>;
27
+ export default ChoiceMultiField;
@@ -0,0 +1,41 @@
1
+ <script lang="ts" generics="T extends Record<string, unknown>, U extends FormPath<T>, M">
2
+ import type { FormPath } from 'sveltekit-superforms';
3
+ import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
4
+ import WeekdayChoice, {
5
+ type WeekdayChoiceProps
6
+ } from '../../ui/choice/WeekdayChoice.svelte';
7
+
8
+ type Props = FieldWrapperProps<T, U, M> & WeekdayChoiceProps;
9
+
10
+ let {
11
+ onChange,
12
+ vertical,
13
+ value = $bindable(undefined),
14
+ letterLabels,
15
+ longLabels,
16
+
17
+ form,
18
+ name,
19
+ label,
20
+ description,
21
+ disabled,
22
+ readonly
23
+ }: Props = $props();
24
+ </script>
25
+
26
+ <FieldWrapper {form} {name} {label} {description}>
27
+ {#snippet formElem(props)}
28
+ <div class="flex w-full items-center gap-2">
29
+ <WeekdayChoice
30
+ {onChange}
31
+ {vertical}
32
+ {disabled}
33
+ {readonly}
34
+ {letterLabels}
35
+ {longLabels}
36
+ bind:value
37
+ {...props}
38
+ />
39
+ </div>
40
+ {/snippet}
41
+ </FieldWrapper>
@@ -0,0 +1,27 @@
1
+ import type { FormPath } from 'sveltekit-superforms';
2
+ import { type FieldWrapperProps } from '../FieldWrapper.svelte';
3
+ import { type WeekdayChoiceProps } from '../../ui/choice/WeekdayChoice.svelte';
4
+ declare function $$render<T extends Record<string, unknown>, U extends FormPath<T>, M>(): {
5
+ props: FieldWrapperProps<T, U, M> & WeekdayChoiceProps;
6
+ exports: {};
7
+ bindings: "value";
8
+ slots: {};
9
+ events: {};
10
+ };
11
+ declare class __sveltets_Render<T extends Record<string, unknown>, U extends FormPath<T>, M> {
12
+ props(): ReturnType<typeof $$render<T, U, M>>['props'];
13
+ events(): ReturnType<typeof $$render<T, U, M>>['events'];
14
+ slots(): ReturnType<typeof $$render<T, U, M>>['slots'];
15
+ bindings(): "value";
16
+ exports(): {};
17
+ }
18
+ interface $$IsomorphicComponent {
19
+ new <T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, U, M>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, U, M>['props']>, ReturnType<__sveltets_Render<T, U, M>['events']>, ReturnType<__sveltets_Render<T, U, M>['slots']>> & {
20
+ $$bindings?: ReturnType<__sveltets_Render<T, U, M>['bindings']>;
21
+ } & ReturnType<__sveltets_Render<T, U, M>['exports']>;
22
+ <T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<T, U, M>['props']> & {}): ReturnType<__sveltets_Render<T, U, M>['exports']>;
23
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>['bindings']>;
24
+ }
25
+ declare const WeekdayChoiceField: $$IsomorphicComponent;
26
+ type WeekdayChoiceField<T extends Record<string, unknown>, U extends FormPath<T>, M> = InstanceType<typeof WeekdayChoiceField<T, U, M>>;
27
+ export default WeekdayChoiceField;
@@ -0,0 +1,41 @@
1
+ <script lang="ts" generics="T extends Record<string, unknown>, U extends FormPath<T>, M">
2
+ import type { FormPath } from 'sveltekit-superforms';
3
+ import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
4
+ import type { WeekdayChoiceMultiProps } from '../../ui/choice/WeekdayChoiceMulti.svelte';
5
+ import WeekdayChoiceMulti from '../../ui/choice/WeekdayChoiceMulti.svelte';
6
+
7
+ type Props = FieldWrapperProps<T, U, M> & WeekdayChoiceMultiProps;
8
+ let {
9
+ onAdd,
10
+ onRemove,
11
+ vertical,
12
+ value = $bindable([]),
13
+ letterLabels,
14
+ longLabels,
15
+
16
+ form,
17
+ name,
18
+ label,
19
+ description,
20
+ disabled,
21
+ readonly
22
+ }: Props = $props();
23
+ </script>
24
+
25
+ <FieldWrapper {form} {name} {label} {description}>
26
+ {#snippet formElem(props)}
27
+ <div class="flex w-full items-center gap-2">
28
+ <WeekdayChoiceMulti
29
+ {onAdd}
30
+ {onRemove}
31
+ {disabled}
32
+ {readonly}
33
+ {vertical}
34
+ {letterLabels}
35
+ {longLabels}
36
+ {...props}
37
+ bind:value
38
+ />
39
+ </div>
40
+ {/snippet}
41
+ </FieldWrapper>
@@ -0,0 +1,27 @@
1
+ import type { FormPath } from 'sveltekit-superforms';
2
+ import { type FieldWrapperProps } from '../FieldWrapper.svelte';
3
+ import type { WeekdayChoiceMultiProps } from '../../ui/choice/WeekdayChoiceMulti.svelte';
4
+ declare function $$render<T extends Record<string, unknown>, U extends FormPath<T>, M>(): {
5
+ props: FieldWrapperProps<T, U, M> & WeekdayChoiceMultiProps;
6
+ exports: {};
7
+ bindings: "value";
8
+ slots: {};
9
+ events: {};
10
+ };
11
+ declare class __sveltets_Render<T extends Record<string, unknown>, U extends FormPath<T>, M> {
12
+ props(): ReturnType<typeof $$render<T, U, M>>['props'];
13
+ events(): ReturnType<typeof $$render<T, U, M>>['events'];
14
+ slots(): ReturnType<typeof $$render<T, U, M>>['slots'];
15
+ bindings(): "value";
16
+ exports(): {};
17
+ }
18
+ interface $$IsomorphicComponent {
19
+ new <T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, U, M>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, U, M>['props']>, ReturnType<__sveltets_Render<T, U, M>['events']>, ReturnType<__sveltets_Render<T, U, M>['slots']>> & {
20
+ $$bindings?: ReturnType<__sveltets_Render<T, U, M>['bindings']>;
21
+ } & ReturnType<__sveltets_Render<T, U, M>['exports']>;
22
+ <T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<T, U, M>['props']> & {}): ReturnType<__sveltets_Render<T, U, M>['exports']>;
23
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>['bindings']>;
24
+ }
25
+ declare const WeekdayChoiceMultiField: $$IsomorphicComponent;
26
+ type WeekdayChoiceMultiField<T extends Record<string, unknown>, U extends FormPath<T>, M> = InstanceType<typeof WeekdayChoiceMultiField<T, U, M>>;
27
+ export default WeekdayChoiceMultiField;
@@ -1,3 +1,9 @@
1
1
  import TextField from './form/fields/TextField.svelte';
2
2
  import PasswordField from './form/fields/PasswordField.svelte';
3
- export { TextField, PasswordField };
3
+ import ChoiceField from './form/fields/ChoiceField.svelte';
4
+ import ChoiceMultiField from './form/fields/ChoiceMultiField.svelte';
5
+ import Choice from './ui/choice/Choice.svelte';
6
+ import ChoiceMulti from './ui/choice/ChoiceMulti.svelte';
7
+ import WeekdayChoice from './ui/choice/WeekdayChoice.svelte';
8
+ import WeekdayChoiceMulti from './ui/choice/WeekdayChoiceMulti.svelte';
9
+ export { TextField, PasswordField, ChoiceMultiField, ChoiceField, Choice, ChoiceMulti, WeekdayChoice, WeekdayChoiceMulti };
@@ -1,3 +1,9 @@
1
1
  import TextField from './form/fields/TextField.svelte';
2
2
  import PasswordField from './form/fields/PasswordField.svelte';
3
- export { TextField, PasswordField };
3
+ import ChoiceField from './form/fields/ChoiceField.svelte';
4
+ import ChoiceMultiField from './form/fields/ChoiceMultiField.svelte';
5
+ import Choice from './ui/choice/Choice.svelte';
6
+ import ChoiceMulti from './ui/choice/ChoiceMulti.svelte';
7
+ import WeekdayChoice from './ui/choice/WeekdayChoice.svelte';
8
+ import WeekdayChoiceMulti from './ui/choice/WeekdayChoiceMulti.svelte';
9
+ export { TextField, PasswordField, ChoiceMultiField, ChoiceField, Choice, ChoiceMulti, WeekdayChoice, WeekdayChoiceMulti };
@@ -0,0 +1,52 @@
1
+ <script lang="ts">
2
+ import { highlight } from '../../highlight.js';
3
+ import { onMount } from 'svelte';
4
+
5
+ export let language: string = 'svelte';
6
+ export let theme: string = 'nord';
7
+
8
+ let highlightedCode = '';
9
+ let codeBlock: HTMLDivElement;
10
+
11
+ onMount(async () => {
12
+ const code = codeBlock.textContent || '';
13
+ const lines = code.split('\n');
14
+ const firstLine = lines.find((line) => line.trim() !== '');
15
+
16
+ // Dedent the code first
17
+ let dedentedCode = '';
18
+ if (firstLine) {
19
+ const leadingSpaces = firstLine.match(/^\s*/)?.[0].length || 0;
20
+ dedentedCode = lines
21
+ .map((line) => line.slice(leadingSpaces))
22
+ .join('\n')
23
+ .trim();
24
+ } else {
25
+ dedentedCode = code.trim();
26
+ }
27
+
28
+ // Add tabs to each line and spacing above/below
29
+ const spacedCode =
30
+ '\n' +
31
+ dedentedCode
32
+ .split('\n')
33
+ .map((line) => `\t${line}`)
34
+ .join('\n') +
35
+ '\n\n';
36
+
37
+ highlightedCode = await highlight(spacedCode, language, theme);
38
+ });
39
+ </script>
40
+
41
+ <div class="overflow-hidden rounded-b-xl border bg-gray-900">
42
+ <div class="border-b border-gray-800 bg-gray-800 px-4 py-2 text-sm font-medium text-gray-200">
43
+ Code
44
+ </div>
45
+ <div bind:this={codeBlock} class="overflow-x-auto text-sm" style="display: none;">
46
+ <slot />
47
+ </div>
48
+ <div class="overflow-x-auto text-sm">
49
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
50
+ {@html highlightedCode}
51
+ </div>
52
+ </div>
@@ -0,0 +1,30 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
15
+ default: any;
16
+ } ? Props extends Record<string, never> ? any : {
17
+ children?: any;
18
+ } : {});
19
+ declare const CodeBlock: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
20
+ language?: string;
21
+ theme?: string;
22
+ }, {
23
+ default: {};
24
+ }>, {
25
+ [evt: string]: CustomEvent<any>;
26
+ }, {
27
+ default: {};
28
+ }, {}, string>;
29
+ type CodeBlock = InstanceType<typeof CodeBlock>;
30
+ export default CodeBlock;
@@ -0,0 +1,13 @@
1
+ <script lang="ts">
2
+ export let title: string;
3
+ export let description: string;
4
+ let id = title.toLowerCase().replace(/\s+/g, '-');
5
+ </script>
6
+
7
+ <section {id} class="mx-auto mb-12 w-full max-w-screen px-4">
8
+ <h2 class="mb-4 text-2xl font-semibold text-gray-800">{title}</h2>
9
+ <p class="mb-6 text-gray-600">{description}</p>
10
+
11
+ <slot name="preview" />
12
+ <slot name="code" />
13
+ </section>
@@ -0,0 +1,24 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const Container: $$__sveltets_2_IsomorphicComponent<{
15
+ title: string;
16
+ description: string;
17
+ }, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {
20
+ preview: {};
21
+ code: {};
22
+ }, {}, string>;
23
+ type Container = InstanceType<typeof Container>;
24
+ export default Container;
@@ -0,0 +1,6 @@
1
+ <div class="overflow-hidden rounded-t-xl border bg-white shadow-sm">
2
+ <div class="border-b bg-gray-50 px-4 py-2 text-sm font-medium text-gray-700">Preview</div>
3
+ <div class="p-6">
4
+ <slot />
5
+ </div>
6
+ </div>
@@ -0,0 +1,26 @@
1
+ export default Preview;
2
+ type Preview = SvelteComponent<any, {
3
+ [evt: string]: CustomEvent<any>;
4
+ }, {
5
+ default: {};
6
+ }> & {
7
+ $$bindings?: string | undefined;
8
+ };
9
+ declare const Preview: $$__sveltets_2_IsomorphicComponent<any, {
10
+ [evt: string]: CustomEvent<any>;
11
+ }, {
12
+ default: {};
13
+ }, {}, string>;
14
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
15
+ new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
16
+ $$bindings?: Bindings;
17
+ } & Exports;
18
+ (internal: unknown, props: {
19
+ $$events?: Events;
20
+ $$slots?: Slots;
21
+ }): Exports & {
22
+ $set?: any;
23
+ $on?: any;
24
+ };
25
+ z_$$bindings?: Bindings;
26
+ }
@@ -0,0 +1,6 @@
1
+ <aside class="sticky top-0 hidden h-screen w-64 overflow-y-auto border-r bg-white p-6 lg:block">
2
+ <h2 class="mb-4 text-xl font-bold text-gray-900">Components</h2>
3
+ <nav class="space-y-2">
4
+ <slot />
5
+ </nav>
6
+ </aside>
@@ -0,0 +1,26 @@
1
+ export default Sidebar;
2
+ type Sidebar = SvelteComponent<any, {
3
+ [evt: string]: CustomEvent<any>;
4
+ }, {
5
+ default: {};
6
+ }> & {
7
+ $$bindings?: string | undefined;
8
+ };
9
+ declare const Sidebar: $$__sveltets_2_IsomorphicComponent<any, {
10
+ [evt: string]: CustomEvent<any>;
11
+ }, {
12
+ default: {};
13
+ }, {}, string>;
14
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
15
+ new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
16
+ $$bindings?: Bindings;
17
+ } & Exports;
18
+ (internal: unknown, props: {
19
+ $$events?: Events;
20
+ $$slots?: Slots;
21
+ }): Exports & {
22
+ $set?: any;
23
+ $on?: any;
24
+ };
25
+ z_$$bindings?: Bindings;
26
+ }
@@ -0,0 +1,7 @@
1
+ <script lang="ts">
2
+ export let title: string;
3
+
4
+ let id = title.toLowerCase().replace(/\s+/g, '-');
5
+ </script>
6
+
7
+ <a href="#{id}" class="block text-gray-600 hover:text-gray-900">{title}</a>
@@ -0,0 +1,20 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const SidebarLink: $$__sveltets_2_IsomorphicComponent<{
15
+ title: string;
16
+ }, {
17
+ [evt: string]: CustomEvent<any>;
18
+ }, {}, {}, string>;
19
+ type SidebarLink = InstanceType<typeof SidebarLink>;
20
+ export default SidebarLink;