@r2digisolutions/ui 0.13.3 → 0.14.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/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +3 -1
- package/dist/components/ui/Field/Field.svelte +57 -0
- package/dist/components/ui/Field/Field.svelte.d.ts +4 -0
- package/dist/components/ui/Field/type.d.ts +12 -0
- package/dist/components/ui/Field/type.js +1 -0
- package/dist/components/ui/Label/Label.svelte +15 -0
- package/dist/components/ui/Label/Label.svelte.d.ts +4 -0
- package/dist/components/ui/Label/type.d.ts +7 -0
- package/dist/components/ui/Label/type.js +1 -0
- package/dist/types/direction.type.d.ts +1 -0
- package/dist/types/direction.type.js +1 -0
- package/package.json +1 -1
|
@@ -12,4 +12,6 @@ import Section from './ui/Section/Section.svelte';
|
|
|
12
12
|
import Loading from './ui/Loading/Loading.svelte';
|
|
13
13
|
import Button from './ui/Button/Button.svelte';
|
|
14
14
|
import Heading from './ui/Heading/Heading.svelte';
|
|
15
|
-
|
|
15
|
+
import Label from './ui/Label/Label.svelte';
|
|
16
|
+
import Field from './ui/Field/Field.svelte';
|
|
17
|
+
export { Alert, Avatar, Button, Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, Container, Field, Section, Loading, TableList, Heading, Label, };
|
package/dist/components/index.js
CHANGED
|
@@ -12,4 +12,6 @@ import Section from './ui/Section/Section.svelte';
|
|
|
12
12
|
import Loading from './ui/Loading/Loading.svelte';
|
|
13
13
|
import Button from './ui/Button/Button.svelte';
|
|
14
14
|
import Heading from './ui/Heading/Heading.svelte';
|
|
15
|
-
|
|
15
|
+
import Label from './ui/Label/Label.svelte';
|
|
16
|
+
import Field from './ui/Field/Field.svelte';
|
|
17
|
+
export { Alert, Avatar, Button, Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, Container, Field, Section, Loading, TableList, Heading, Label, };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Label from '../Label/Label.svelte';
|
|
3
|
+
import type { Props } from './type.js';
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
label,
|
|
7
|
+
children,
|
|
8
|
+
errors,
|
|
9
|
+
direction = 'col',
|
|
10
|
+
required = false,
|
|
11
|
+
...props
|
|
12
|
+
}: Props = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<Label
|
|
16
|
+
class={[
|
|
17
|
+
{
|
|
18
|
+
'flex-row items-center': direction === 'row',
|
|
19
|
+
'flex-row-reverse items-center justify-end': direction === 'row-reverse',
|
|
20
|
+
'flex-col': direction === 'col',
|
|
21
|
+
'flex-col-reverse items-center': direction === 'col-reverse'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
'field--errors': Boolean(errors?.length)
|
|
25
|
+
},
|
|
26
|
+
'flex w-full gap-2',
|
|
27
|
+
props.class
|
|
28
|
+
]}
|
|
29
|
+
>
|
|
30
|
+
{#if label}
|
|
31
|
+
<span class="block text-sm font-bold text-gray-600 dark:text-gray-200">
|
|
32
|
+
{label}
|
|
33
|
+
{#if required}
|
|
34
|
+
<span class="text-red-500">*</span>
|
|
35
|
+
{/if}
|
|
36
|
+
</span>
|
|
37
|
+
{/if}
|
|
38
|
+
{@render children()}
|
|
39
|
+
{#if errors?.length}
|
|
40
|
+
<div class="flex flex-col">
|
|
41
|
+
{#each errors as error}
|
|
42
|
+
<p class="text-xs text-red-500">{error}</p>
|
|
43
|
+
{/each}
|
|
44
|
+
</div>
|
|
45
|
+
{/if}
|
|
46
|
+
</Label>
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
:global(.field--errors) {
|
|
50
|
+
span {
|
|
51
|
+
color: var(--color-red-500);
|
|
52
|
+
}
|
|
53
|
+
:global(input, textarea, select, .select-multiple) {
|
|
54
|
+
border: 1px solid var(--color-red-500) !important;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IInputDirection } from '../../../types/direction.type.js';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ClassValue } from 'svelte/elements';
|
|
4
|
+
export interface Props {
|
|
5
|
+
direction?: IInputDirection;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
class?: ClassValue;
|
|
8
|
+
errors?: string[];
|
|
9
|
+
label?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
children: Snippet;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Props } from './type';
|
|
3
|
+
|
|
4
|
+
let { children, ...props }: Props = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<label
|
|
8
|
+
{...props}
|
|
9
|
+
class={[
|
|
10
|
+
'cursor-pointer text-sm font-bold text-gray-600 select-none dark:text-gray-200',
|
|
11
|
+
props.class
|
|
12
|
+
]}
|
|
13
|
+
>
|
|
14
|
+
{@render children()}
|
|
15
|
+
</label>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type IInputDirection = 'row' | 'row-reverse' | 'col' | 'col-reverse';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|