@iroco/ui 1.0.0-9 → 1.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/README.md +7 -5
- package/dist/Alert.stories.svelte +19 -20
- package/dist/Alert.stories.svelte.d.ts +17 -35
- package/dist/Alert.svelte +12 -5
- package/dist/Alert.svelte.d.ts +7 -18
- package/dist/Button.stories.svelte +16 -12
- package/dist/Button.stories.svelte.d.ts +17 -43
- package/dist/Button.svelte +33 -12
- package/dist/Button.svelte.d.ts +13 -38
- package/dist/DataTable.stories.svelte +24 -19
- package/dist/DataTable.stories.svelte.d.ts +17 -27
- package/dist/DataTable.svelte +45 -25
- package/dist/DataTable.svelte.d.ts +16 -23
- package/dist/IconBurger.stories.svelte +8 -12
- package/dist/IconBurger.stories.svelte.d.ts +17 -46
- package/dist/IconBurger.svelte +7 -2
- package/dist/IconBurger.svelte.d.ts +6 -16
- package/dist/IconClose.stories.svelte +6 -12
- package/dist/IconClose.stories.svelte.d.ts +17 -46
- package/dist/IconClose.svelte +7 -2
- package/dist/IconClose.svelte.d.ts +6 -16
- package/dist/IconFloppyDisk.stories.svelte +4 -11
- package/dist/IconFloppyDisk.stories.svelte.d.ts +17 -53
- package/dist/IconFloppyDisk.svelte +8 -3
- package/dist/IconFloppyDisk.svelte.d.ts +7 -17
- package/dist/IconInfo.stories.svelte +8 -11
- package/dist/IconInfo.stories.svelte.d.ts +17 -48
- package/dist/IconInfo.svelte +7 -2
- package/dist/IconInfo.svelte.d.ts +6 -16
- package/dist/IconIrocoLogo.stories.svelte +8 -8
- package/dist/IconIrocoLogo.stories.svelte.d.ts +17 -55
- package/dist/IconIrocoLogo.svelte +18 -6
- package/dist/IconIrocoLogo.svelte.d.ts +9 -19
- package/dist/IconMoreSign.stories.svelte +7 -14
- package/dist/IconMoreSign.stories.svelte.d.ts +17 -48
- package/dist/IconMoreSign.svelte +7 -2
- package/dist/IconMoreSign.svelte.d.ts +6 -16
- package/dist/IconTrashCan.stories.svelte +6 -12
- package/dist/IconTrashCan.stories.svelte.d.ts +17 -48
- package/dist/IconTrashCan.svelte +8 -3
- package/dist/IconTrashCan.svelte.d.ts +7 -17
- package/dist/ImageArticle.stories.svelte +11 -8
- package/dist/ImageArticle.stories.svelte.d.ts +17 -64
- package/dist/ImageArticle.svelte +37 -165
- package/dist/ImageArticle.svelte.d.ts +11 -21
- package/dist/IrocoLogo.stories.svelte +12 -7
- package/dist/IrocoLogo.stories.svelte.d.ts +17 -48
- package/dist/IrocoLogo.svelte +15 -4
- package/dist/IrocoLogo.svelte.d.ts +8 -18
- package/dist/Loader.stories.svelte +11 -8
- package/dist/Loader.stories.svelte.d.ts +17 -27
- package/dist/Loader.svelte +19 -18
- package/dist/Loader.svelte.d.ts +16 -12
- package/dist/NavBar.stories.svelte +29 -20
- package/dist/NavBar.stories.svelte.d.ts +17 -35
- package/dist/NavBar.svelte +49 -183
- package/dist/NavBar.svelte.d.ts +33 -20
- package/dist/Navigation.stories.svelte +30 -28
- package/dist/Navigation.stories.svelte.d.ts +17 -57
- package/dist/Navigation.svelte +35 -14
- package/dist/Navigation.svelte.d.ts +18 -20
- package/dist/NumberInput.stories.svelte +12 -7
- package/dist/NumberInput.stories.svelte.d.ts +17 -75
- package/dist/NumberInput.svelte +26 -8
- package/dist/NumberInput.svelte.d.ts +13 -24
- package/dist/RadioButton.stories.svelte +17 -30
- package/dist/RadioButton.stories.svelte.d.ts +17 -54
- package/dist/RadioButton.svelte +26 -12
- package/dist/RadioButton.svelte.d.ts +10 -20
- package/dist/SlottedComponentWrapper.svelte +4 -4
- package/dist/SlottedComponentWrapper.svelte.d.ts +4 -22
- package/dist/TextInput.stories.svelte +24 -47
- package/dist/TextInput.stories.svelte.d.ts +17 -109
- package/dist/TextInput.svelte +45 -25
- package/dist/TextInput.svelte.d.ts +19 -30
- package/dist/definition.d.ts +0 -5
- package/dist/definition.js +0 -11
- package/dist/index.d.ts +14 -10
- package/dist/index.js +14 -10
- package/dist/scss/button.scss +7 -3
- package/dist/scss/colors.scss +21 -11
- package/dist/scss/fields/_input.scss +1 -1
- package/dist/scss/fields/_style.scss +2 -2
- package/package.json +49 -48
- package/dist/RadioButtonTest.svelte +0 -10
- package/dist/RadioButtonTest.svelte.d.ts +0 -19
package/README.md
CHANGED
|
@@ -10,8 +10,8 @@ See the [Documentation](https://iroco-co.github.io/iroco-ui/) (not in sync anymo
|
|
|
10
10
|
|
|
11
11
|
Prerequisites:
|
|
12
12
|
|
|
13
|
-
- @sveltejs/kit: ^2.
|
|
14
|
-
- svelte: ^
|
|
13
|
+
- @sveltejs/kit: ^2.x
|
|
14
|
+
- svelte: ^5.x
|
|
15
15
|
|
|
16
16
|
```sh
|
|
17
17
|
# latest
|
|
@@ -28,7 +28,7 @@ npm install @iroco/ui@next
|
|
|
28
28
|
@use 'node_modules/@iroco/ui/dist/scss/fonts';
|
|
29
29
|
@use 'node_modules/@iroco/ui/dist/scss/style';
|
|
30
30
|
@use 'node_modules/@iroco/ui/dist/scss/constants';
|
|
31
|
-
@
|
|
31
|
+
@use 'node_modules/@iroco/ui/dist/scss/containers';
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
Example of layout with navigation
|
|
@@ -49,13 +49,15 @@ Example of layout with navigation
|
|
|
49
49
|
<style lang="scss">
|
|
50
50
|
@use 'node_modules/@iroco/ui/dist/scss/colors.scss';
|
|
51
51
|
@use 'node_modules/@iroco/ui/dist/scss/constants.scss';
|
|
52
|
-
@
|
|
53
|
-
@
|
|
52
|
+
@use 'node_modules/@iroco/ui/dist/scss/containers.scss';
|
|
53
|
+
@use 'node_modules/@iroco/ui/dist/scss/button.scss';
|
|
54
54
|
</style>
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
# develop
|
|
58
58
|
|
|
59
|
+
[Useful Svelte 5 + Storybook examples](https://github.com/podman-desktop/podman-desktop/tree/main/storybook).
|
|
60
|
+
|
|
59
61
|
To install dependencies :
|
|
60
62
|
|
|
61
63
|
```shell
|
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import Alert from './
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { Alert } from './index';
|
|
3
|
+
import { defineMeta, setTemplate } from '@storybook/addon-svelte-csf';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
const { Story } = defineMeta({
|
|
5
6
|
title: 'Iroco-UI/Atoms/Alert',
|
|
6
|
-
component: Alert
|
|
7
|
-
|
|
8
|
-
type: {
|
|
9
|
-
control: { type: 'select' },
|
|
10
|
-
options: ['success', 'danger', 'flash']
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
};
|
|
7
|
+
component: Alert
|
|
8
|
+
});
|
|
14
9
|
</script>
|
|
15
10
|
|
|
16
|
-
<script>
|
|
17
|
-
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
setTemplate(template);
|
|
18
13
|
</script>
|
|
19
14
|
|
|
20
|
-
|
|
15
|
+
{#snippet template({ ...args })}
|
|
21
16
|
<Alert {...args}>
|
|
22
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc eros lacus, commodo eu tristique non, ultricies eu
|
|
18
|
+
tellus. Nulla facilisi. Integer a tincidunt purus. Proin vulputate tristique magna. Aliquam id eros id ante
|
|
19
|
+
malesuada interdum. Phasellus tristique ac leo at fringilla. Cras a viverra nibh, vitae rutrum ante. Sed pharetra
|
|
20
|
+
nibh ac velit dignissim ornare sed accumsan lacus. Vestibulum tincidunt purus sapien, ac dapibus sem semper a.
|
|
21
|
+
Nullam venenatis vestibulum risus id molestie. Aliquam facilisis nunc at nunc aliquam hendrerit. Etiam sodales
|
|
22
|
+
sodales lectus, ut suscipit lacus vehicula nec. Proin vel magna sed orci condimentum ornare in a odio. In varius eu
|
|
23
|
+
augue eget tincidunt. Ut quis porttitor nulla. Nulla leo nunc, efficitur non ipsum vel, tincidunt auctor lectus.
|
|
26
24
|
</Alert>
|
|
27
|
-
|
|
25
|
+
{/snippet}
|
|
28
26
|
|
|
29
27
|
<Story name="Default" />
|
|
30
28
|
<Story name="Danger" args={{ type: 'danger' }} />
|
|
31
|
-
<Story name="Success" args={{ type: 'success' }} />
|
|
32
29
|
<Story name="Flash" args={{ type: 'flash' }} />
|
|
30
|
+
<Story name="Success" args={{ type: 'success' }} />
|
|
31
|
+
|
|
@@ -1,37 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
1
|
+
import { Alert } from './index';
|
|
2
|
+
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> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
/** @typedef {typeof __propDef.events} AlertEvents */
|
|
16
|
-
/** @typedef {typeof __propDef.slots} AlertSlots */
|
|
17
|
-
export default class Alert extends SvelteComponent<{
|
|
18
|
-
[x: string]: never;
|
|
19
|
-
}, {
|
|
15
|
+
declare const Alert: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
20
16
|
[evt: string]: CustomEvent<any>;
|
|
21
|
-
}, {}
|
|
22
|
-
|
|
23
|
-
export
|
|
24
|
-
export type AlertEvents = typeof __propDef.events;
|
|
25
|
-
export type AlertSlots = typeof __propDef.slots;
|
|
26
|
-
import Alert from './Alert.svelte';
|
|
27
|
-
import { SvelteComponent } from "svelte";
|
|
28
|
-
declare const __propDef: {
|
|
29
|
-
props: {
|
|
30
|
-
[x: string]: never;
|
|
31
|
-
};
|
|
32
|
-
events: {
|
|
33
|
-
[evt: string]: CustomEvent<any>;
|
|
34
|
-
};
|
|
35
|
-
slots: {};
|
|
36
|
-
};
|
|
37
|
-
export {};
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type Alert = InstanceType<typeof Alert>;
|
|
19
|
+
export default Alert;
|
package/dist/Alert.svelte
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import IconClose from './IconClose.svelte';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
type?: 'success' | 'danger' | 'flash';
|
|
6
|
+
callback: (e: Event) => void;
|
|
7
|
+
children?: import('svelte').Snippet;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
let { type = 'success', callback, children }: Props = $props();
|
|
4
11
|
</script>
|
|
5
12
|
|
|
6
13
|
<div class={`alert alert--${type}`}>
|
|
7
|
-
<button
|
|
14
|
+
<button onclick={callback} class="alert__close">
|
|
8
15
|
<IconClose width="2em" height="2em" />
|
|
9
16
|
</button>
|
|
10
|
-
|
|
17
|
+
{@render children?.()}
|
|
11
18
|
</div>
|
|
12
19
|
|
|
13
20
|
<style>.alert {
|
package/dist/Alert.svelte.d.ts
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
callback: (e: Event) => void;
|
|
6
|
-
};
|
|
7
|
-
events: {
|
|
8
|
-
[evt: string]: CustomEvent<any>;
|
|
9
|
-
};
|
|
10
|
-
slots: {
|
|
11
|
-
default: {};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export type AlertProps = typeof __propDef.props;
|
|
15
|
-
export type AlertEvents = typeof __propDef.events;
|
|
16
|
-
export type AlertSlots = typeof __propDef.slots;
|
|
17
|
-
export default class Alert extends SvelteComponent<AlertProps, AlertEvents, AlertSlots> {
|
|
1
|
+
interface Props {
|
|
2
|
+
type?: 'success' | 'danger' | 'flash';
|
|
3
|
+
callback: (e: Event) => void;
|
|
4
|
+
children?: import('svelte').Snippet;
|
|
18
5
|
}
|
|
19
|
-
|
|
6
|
+
declare const Alert: import("svelte").Component<Props, {}, "">;
|
|
7
|
+
type Alert = ReturnType<typeof Alert>;
|
|
8
|
+
export default Alert;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import Button from './
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { Button } from './index';
|
|
3
|
+
|
|
4
|
+
import { defineMeta, setTemplate } from '@storybook/addon-svelte-csf';
|
|
5
|
+
|
|
6
|
+
const { Story } = defineMeta({
|
|
3
7
|
|
|
4
|
-
export const meta = {
|
|
5
8
|
title: 'Iroco-UI/Atoms/Button',
|
|
6
9
|
component: Button,
|
|
7
10
|
argTypes: {
|
|
@@ -14,25 +17,26 @@
|
|
|
14
17
|
options: ['small', 'regular']
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
|
-
};
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<script>
|
|
21
|
-
import { Story, Template } from '@storybook/addon-svelte-csf';
|
|
20
|
+
});
|
|
22
21
|
|
|
23
|
-
let count = 0;
|
|
22
|
+
let count = $state(0);
|
|
24
23
|
|
|
25
24
|
function handleClick() {
|
|
26
25
|
count += 1;
|
|
27
26
|
}
|
|
28
27
|
</script>
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
|
|
30
|
+
<script lang="ts">
|
|
31
|
+
setTemplate(template);
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
{#snippet template({ ...args })}
|
|
31
35
|
<!--👇 'on:click' allows to forward event to addon-actions -->
|
|
32
|
-
<Button {...args}
|
|
36
|
+
<Button {...args} onclick={handleClick}>
|
|
33
37
|
You clicked: {count}
|
|
34
38
|
</Button>
|
|
35
|
-
|
|
39
|
+
{/snippet}
|
|
36
40
|
|
|
37
41
|
<Story name="Default" />
|
|
38
42
|
<Story name="Success" args={{ kind: 'success' }} />
|
|
@@ -1,45 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export { type_1 as type };
|
|
15
|
-
}
|
|
16
|
-
export { control_1 as control };
|
|
17
|
-
let options_1: string[];
|
|
18
|
-
export { options_1 as options };
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
import { Button } from './index';
|
|
2
|
+
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> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
21
14
|
}
|
|
22
|
-
|
|
23
|
-
/** @typedef {typeof __propDef.events} ButtonEvents */
|
|
24
|
-
/** @typedef {typeof __propDef.slots} ButtonSlots */
|
|
25
|
-
export default class Button extends SvelteComponent<{
|
|
26
|
-
[x: string]: never;
|
|
27
|
-
}, {
|
|
15
|
+
declare const Button: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
28
16
|
[evt: string]: CustomEvent<any>;
|
|
29
|
-
}, {}
|
|
30
|
-
|
|
31
|
-
export
|
|
32
|
-
export type ButtonEvents = typeof __propDef.events;
|
|
33
|
-
export type ButtonSlots = typeof __propDef.slots;
|
|
34
|
-
import Button from './Button.svelte';
|
|
35
|
-
import { SvelteComponent } from "svelte";
|
|
36
|
-
declare const __propDef: {
|
|
37
|
-
props: {
|
|
38
|
-
[x: string]: never;
|
|
39
|
-
};
|
|
40
|
-
events: {
|
|
41
|
-
[evt: string]: CustomEvent<any>;
|
|
42
|
-
};
|
|
43
|
-
slots: {};
|
|
44
|
-
};
|
|
45
|
-
export {};
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type Button = InstanceType<typeof Button>;
|
|
19
|
+
export default Button;
|
package/dist/Button.svelte
CHANGED
|
@@ -1,21 +1,39 @@
|
|
|
1
|
-
<
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { MouseEventHandler } from 'svelte/elements';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
type?: 'button' | 'reset' | 'submit' | null | undefined;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
kind?: 'danger' | 'success' | 'dark' | 'basic';
|
|
8
|
+
size?: 'small' | 'regular';
|
|
9
|
+
fullWidth?: boolean;
|
|
10
|
+
id?: string | null;
|
|
11
|
+
children?: import('svelte').Snippet;
|
|
12
|
+
onclick?: MouseEventHandler<HTMLButtonElement>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
type = 'button',
|
|
17
|
+
disabled = false,
|
|
18
|
+
kind = 'basic',
|
|
19
|
+
size = 'regular',
|
|
20
|
+
fullWidth = false,
|
|
21
|
+
id = null,
|
|
22
|
+
children,
|
|
23
|
+
onclick
|
|
24
|
+
}: Props = $props();
|
|
2
25
|
|
|
3
|
-
<script>export let type = "button";
|
|
4
|
-
export let disabled = false;
|
|
5
|
-
export let kind = "basic";
|
|
6
|
-
export let size = "regular";
|
|
7
|
-
export let id;
|
|
8
26
|
</script>
|
|
9
27
|
|
|
10
28
|
<button
|
|
11
29
|
{id}
|
|
12
|
-
class={`iroco-ui-button iroco-ui-button--${size} iroco-ui-button--${kind}`}
|
|
30
|
+
class={`iroco-ui-button iroco-ui-button--${size} iroco-ui-button--${kind} ${fullWidth?'iroco-ui-button--full-width':''}`}
|
|
13
31
|
class:disabled
|
|
14
32
|
{type}
|
|
15
33
|
{disabled}
|
|
16
|
-
|
|
34
|
+
{onclick}
|
|
17
35
|
>
|
|
18
|
-
|
|
36
|
+
{@render children?.()}
|
|
19
37
|
</button>
|
|
20
38
|
|
|
21
39
|
<style>.container-wide {
|
|
@@ -190,9 +208,9 @@ export let id;
|
|
|
190
208
|
border-radius: 0.3em;
|
|
191
209
|
}
|
|
192
210
|
.iroco-ui-button--basic {
|
|
193
|
-
color: var(--btn-
|
|
194
|
-
background: var(--btn-
|
|
195
|
-
border: 1px solid var(--btn-
|
|
211
|
+
color: var(--btn-secondary-label);
|
|
212
|
+
background: var(--btn-secondary-bg);
|
|
213
|
+
border: 1px solid var(--btn-secondary-border);
|
|
196
214
|
}
|
|
197
215
|
.iroco-ui-button--dark {
|
|
198
216
|
background: var(--dark-btn-primary-bg);
|
|
@@ -229,6 +247,9 @@ export let id;
|
|
|
229
247
|
.iroco-ui-button.disabled:hover, .iroco-ui-button:disabled:hover {
|
|
230
248
|
box-shadow: none;
|
|
231
249
|
}
|
|
250
|
+
.iroco-ui-button--full-width {
|
|
251
|
+
width: 100%;
|
|
252
|
+
}
|
|
232
253
|
|
|
233
254
|
.iroco-ui-link {
|
|
234
255
|
background: none;
|
package/dist/Button.svelte.d.ts
CHANGED
|
@@ -1,39 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
click: MouseEvent;
|
|
12
|
-
} & {
|
|
13
|
-
[evt: string]: CustomEvent<any>;
|
|
14
|
-
};
|
|
15
|
-
slots: {
|
|
16
|
-
default: {};
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export type ButtonProps = typeof __propDef.props;
|
|
20
|
-
export type ButtonEvents = typeof __propDef.events;
|
|
21
|
-
export type ButtonSlots = typeof __propDef.slots;
|
|
22
|
-
export default class Button extends SvelteComponent<ButtonProps, ButtonEvents, ButtonSlots> {
|
|
23
|
-
get type(): string | undefined;
|
|
24
|
-
/**accessor*/
|
|
25
|
-
set type(_: string | undefined);
|
|
26
|
-
get disabled(): boolean | undefined;
|
|
27
|
-
/**accessor*/
|
|
28
|
-
set disabled(_: boolean | undefined);
|
|
29
|
-
get kind(): "success" | "danger" | "dark" | "basic" | undefined;
|
|
30
|
-
/**accessor*/
|
|
31
|
-
set kind(_: "success" | "danger" | "dark" | "basic" | undefined);
|
|
32
|
-
get size(): "small" | "regular" | undefined;
|
|
33
|
-
/**accessor*/
|
|
34
|
-
set size(_: "small" | "regular" | undefined);
|
|
35
|
-
get id(): string;
|
|
36
|
-
/**accessor*/
|
|
37
|
-
set id(_: string);
|
|
1
|
+
import type { MouseEventHandler } from 'svelte/elements';
|
|
2
|
+
interface Props {
|
|
3
|
+
type?: 'button' | 'reset' | 'submit' | null | undefined;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
kind?: 'danger' | 'success' | 'dark' | 'basic';
|
|
6
|
+
size?: 'small' | 'regular';
|
|
7
|
+
fullWidth?: boolean;
|
|
8
|
+
id?: string | null;
|
|
9
|
+
children?: import('svelte').Snippet;
|
|
10
|
+
onclick?: MouseEventHandler<HTMLButtonElement>;
|
|
38
11
|
}
|
|
39
|
-
|
|
12
|
+
declare const Button: import("svelte").Component<Props, {}, "">;
|
|
13
|
+
type Button = ReturnType<typeof Button>;
|
|
14
|
+
export default Button;
|
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script module lang="ts">
|
|
2
2
|
import { DataTable } from './index';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import { defineMeta, setTemplate } from '@storybook/addon-svelte-csf';
|
|
5
|
+
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
|
|
5
8
|
title: 'Iroco-UI/Components/DataTable',
|
|
6
9
|
component: DataTable,
|
|
7
|
-
argTypes: {}
|
|
8
|
-
|
|
10
|
+
argTypes: {},
|
|
11
|
+
args: {
|
|
12
|
+
columns: [
|
|
13
|
+
{ key: 'key1', title: 'Title 1' },
|
|
14
|
+
{ key: 'key2', title: 'Title 2' },
|
|
15
|
+
{ key: 'key3', title: 'Title 3' }
|
|
16
|
+
],
|
|
17
|
+
rows: [
|
|
18
|
+
{ key1: 'value 1', key2: 'value 2', key3: 'value 3' },
|
|
19
|
+
{ key1: 'value a', key2: 'value b', key3: 'value c' },
|
|
20
|
+
{ key1: 1.56, key2: 2.76, key3: 3.98 }
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
});
|
|
9
24
|
</script>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import { Story, Template } from '@storybook/addon-svelte-csf';
|
|
25
|
+
<script lang="ts">
|
|
26
|
+
setTemplate(template);
|
|
13
27
|
</script>
|
|
14
28
|
|
|
15
|
-
|
|
29
|
+
{#snippet template({ ...args })}
|
|
16
30
|
<DataTable
|
|
17
31
|
{...args}
|
|
18
|
-
|
|
19
|
-
{ key: 'key1', title: 'Title 1' },
|
|
20
|
-
{ key: 'key2', title: 'Title 2' },
|
|
21
|
-
{ key: 'key3', title: 'Title 3' }
|
|
22
|
-
]}
|
|
23
|
-
rows={[
|
|
24
|
-
{ key1: 'value 1', key2: 'value 2', key3: 'value 3' },
|
|
25
|
-
{ key1: 'value a', key2: 'value b', key3: 'value c' },
|
|
26
|
-
{ key1: 1.56, key2: 2.76, key3: 3.98 }
|
|
27
|
-
]}
|
|
32
|
+
|
|
28
33
|
/>
|
|
29
|
-
|
|
34
|
+
{/snippet}
|
|
30
35
|
|
|
31
36
|
<Story name="Default" />
|
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
export namespace meta {
|
|
2
|
-
export let title: string;
|
|
3
|
-
export { DataTable as component };
|
|
4
|
-
export let argTypes: {};
|
|
5
|
-
}
|
|
6
|
-
/** @typedef {typeof __propDef.props} DataTableProps */
|
|
7
|
-
/** @typedef {typeof __propDef.events} DataTableEvents */
|
|
8
|
-
/** @typedef {typeof __propDef.slots} DataTableSlots */
|
|
9
|
-
export default class DataTable extends SvelteComponent<{
|
|
10
|
-
[x: string]: never;
|
|
11
|
-
}, {
|
|
12
|
-
[evt: string]: CustomEvent<any>;
|
|
13
|
-
}, {}> {
|
|
14
|
-
}
|
|
15
|
-
export type DataTableProps = typeof __propDef.props;
|
|
16
|
-
export type DataTableEvents = typeof __propDef.events;
|
|
17
|
-
export type DataTableSlots = typeof __propDef.slots;
|
|
18
1
|
import { DataTable } from './index';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
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> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
23
12
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const DataTable: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type DataTable = InstanceType<typeof DataTable>;
|
|
19
|
+
export default DataTable;
|
package/dist/DataTable.svelte
CHANGED
|
@@ -1,35 +1,55 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
rows: Array<TableRow>,
|
|
6
|
+
columns: Array<TableColumn>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type TableColumn = {
|
|
10
|
+
key: string;
|
|
11
|
+
title: string;
|
|
12
|
+
renderComponent?: {
|
|
13
|
+
component: Component;
|
|
14
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
15
|
+
props?: any;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type TableRow = {
|
|
20
|
+
[key: string]: string | number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
let { rows, columns }: Props = $props();
|
|
3
24
|
</script>
|
|
4
25
|
|
|
5
26
|
<table class="data-table">
|
|
6
27
|
<thead class="data-table__header">
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
28
|
+
<tr>
|
|
29
|
+
{#each columns as column}
|
|
30
|
+
<th class="data-table__header__cell">
|
|
31
|
+
{column.title}
|
|
32
|
+
</th>
|
|
33
|
+
{/each}
|
|
34
|
+
</tr>
|
|
14
35
|
</thead>
|
|
15
36
|
|
|
16
37
|
<tbody class="data-table__body">
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
{/each}
|
|
38
|
+
{#each rows as row}
|
|
39
|
+
<tr class="data-table__body__row">
|
|
40
|
+
{#each columns as { key, renderComponent }}
|
|
41
|
+
<td class="data-table__body__cell">
|
|
42
|
+
{#if renderComponent}
|
|
43
|
+
<renderComponent.component
|
|
44
|
+
on:click={() => renderComponent.props.onclick(row)}
|
|
45
|
+
/>
|
|
46
|
+
{:else}
|
|
47
|
+
{row[key]}
|
|
48
|
+
{/if}
|
|
49
|
+
</td>
|
|
50
|
+
{/each}
|
|
51
|
+
</tr>
|
|
52
|
+
{/each}
|
|
33
53
|
</tbody>
|
|
34
54
|
</table>
|
|
35
55
|
|
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
key: string;
|
|
9
|
-
title: string;
|
|
10
|
-
renderComponent?: {
|
|
11
|
-
component: SvelteComponent;
|
|
12
|
-
props?: any;
|
|
13
|
-
} | undefined;
|
|
14
|
-
}[];
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
type TableColumn = {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
renderComponent?: {
|
|
6
|
+
component: Component;
|
|
7
|
+
props?: any;
|
|
15
8
|
};
|
|
16
|
-
events: {
|
|
17
|
-
[evt: string]: CustomEvent<any>;
|
|
18
|
-
};
|
|
19
|
-
slots: {};
|
|
20
9
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
type TableRow = {
|
|
11
|
+
[key: string]: string | number;
|
|
12
|
+
};
|
|
13
|
+
interface Props {
|
|
14
|
+
rows: Array<TableRow>;
|
|
15
|
+
columns: Array<TableColumn>;
|
|
25
16
|
}
|
|
26
|
-
|
|
17
|
+
declare const DataTable: Component<Props, {}, "">;
|
|
18
|
+
type DataTable = ReturnType<typeof DataTable>;
|
|
19
|
+
export default DataTable;
|