@rkosafo/cai.components 0.0.5 → 0.0.6
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 +8 -8
- package/dist/baseEditor/index.svelte +32 -32
- package/dist/builders/filters/FilterBuilder.svelte +638 -638
- package/dist/forms/FormCheckbox/FormCheckbox.svelte +53 -53
- package/dist/forms/FormDatepicker/FormDatepicker.svelte +159 -159
- package/dist/forms/FormInput/FormInput.svelte +87 -87
- package/dist/forms/FormRadio/FormRadio.svelte +53 -53
- package/dist/forms/FormSelect/FormSelect.svelte +86 -86
- package/dist/forms/FormTextarea/FormTextarea.svelte +77 -77
- package/dist/forms/checkbox/Checkbox.svelte +82 -82
- package/dist/forms/checkbox/CheckboxButton.svelte +92 -92
- package/dist/forms/datepicker/Datepicker.svelte +706 -706
- package/dist/forms/form/Form.svelte +69 -69
- package/dist/forms/input/Input.svelte +363 -363
- package/dist/forms/label/Label.svelte +38 -38
- package/dist/forms/radio/Radio.svelte +48 -48
- package/dist/forms/radio/RadioButton.svelte +22 -22
- package/dist/forms/select/Select.svelte +50 -50
- package/dist/forms/textarea/Textarea.svelte +165 -165
- package/dist/layout/TF/Content/Content.svelte +28 -28
- package/dist/layout/TF/Header/Header.svelte +159 -159
- package/dist/layout/TF/Sidebar/Sidebar.svelte +74 -74
- package/dist/layout/TF/Wrapper/Wrapper.svelte +17 -17
- package/dist/themes/ThemeProvider.svelte +20 -20
- package/dist/typography/heading/Heading.svelte +35 -35
- package/dist/ui/accordion/Accordion.svelte +49 -49
- package/dist/ui/accordion/AccordionItem.svelte +173 -173
- package/dist/ui/alert/Alert.svelte +83 -83
- package/dist/ui/alertDialog/AlertDialog.svelte +40 -40
- package/dist/ui/avatar/Avatar.svelte +77 -77
- package/dist/ui/buttons/Button.svelte +102 -102
- package/dist/ui/buttons/GradientButton.svelte +59 -59
- package/dist/ui/datatable/Datatable.svelte +516 -516
- package/dist/ui/drawer/Drawer.svelte +280 -280
- package/dist/ui/dropdown/Dropdown.svelte +36 -36
- package/dist/ui/dropdown/DropdownDivider.svelte +11 -11
- package/dist/ui/dropdown/DropdownGroup.svelte +14 -14
- package/dist/ui/dropdown/DropdownHeader.svelte +14 -14
- package/dist/ui/dropdown/DropdownItem.svelte +52 -52
- package/dist/ui/footer/Footer.svelte +15 -15
- package/dist/ui/footer/FooterBrand.svelte +37 -37
- package/dist/ui/footer/FooterCopyright.svelte +45 -45
- package/dist/ui/footer/FooterIcon.svelte +22 -22
- package/dist/ui/footer/FooterLink.svelte +33 -33
- package/dist/ui/footer/FooterLinkGroup.svelte +13 -13
- package/dist/ui/indicator/Indicator.svelte +42 -42
- package/dist/ui/modal/Modal.svelte +265 -265
- package/dist/ui/notificationList/NotificationList.svelte +123 -123
- package/dist/ui/pageLoader/PageLoader.svelte +10 -10
- package/dist/ui/paginate/Paginate.svelte +96 -96
- package/dist/ui/tab/Tab.svelte +65 -65
- package/dist/ui/table/Table.svelte +385 -385
- package/dist/ui/tableLoader/TableLoader.svelte +24 -24
- package/dist/ui/toolbar/Toolbar.svelte +59 -59
- package/dist/ui/toolbar/ToolbarButton.svelte +56 -56
- package/dist/ui/toolbar/ToolbarGroup.svelte +43 -43
- package/dist/utils/Popper.svelte +257 -257
- package/dist/utils/closeButton/CloseButton.svelte +88 -88
- package/dist/utils/singleSelection.svelte.js +48 -48
- package/dist/youtube/index.svelte +12 -12
- package/package.json +1 -1
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Checkbox, key, Label } from '../../index.js';
|
|
3
|
-
import type { FormCheckboxProps, FormRadioProps, FormSelectProps } from '../../types/index.js';
|
|
4
|
-
import { getContext } from 'svelte';
|
|
5
|
-
import Radio from '../radio/Radio.svelte';
|
|
6
|
-
|
|
7
|
-
let {
|
|
8
|
-
label = '',
|
|
9
|
-
required,
|
|
10
|
-
name,
|
|
11
|
-
disabled,
|
|
12
|
-
contextKey = null,
|
|
13
|
-
placeholder,
|
|
14
|
-
multiple = false,
|
|
15
|
-
onchange,
|
|
16
|
-
...otherProps
|
|
17
|
-
}: FormRadioProps<any> = $props();
|
|
18
|
-
const { touched, errors, data, setData }: any = getContext(contextKey || key);
|
|
19
|
-
|
|
20
|
-
const hasError = $derived($touched[name] && $errors[name]?.length);
|
|
21
|
-
const error = $derived($errors[name]?.join(', '));
|
|
22
|
-
const value = $derived($data[name]);
|
|
23
|
-
|
|
24
|
-
function handleChange(e: Event) {
|
|
25
|
-
const value = (e.target as HTMLInputElement).value;
|
|
26
|
-
setData({ ...$data, [name]: value });
|
|
27
|
-
if (onchange) onchange(e as any);
|
|
28
|
-
}
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<div class="relative space-y-1">
|
|
32
|
-
<Radio {disabled} onchange={handleChange} {...otherProps} group={value}
|
|
33
|
-
>{label}
|
|
34
|
-
{#if required}
|
|
35
|
-
<span class="pt-1 pl-1 text-red-500">*</span>
|
|
36
|
-
{/if}
|
|
37
|
-
{#if hasError}
|
|
38
|
-
<Label
|
|
39
|
-
class="v-error-container absolute top-0 right-2 flex items-center gap-1 text-sm {hasError &&
|
|
40
|
-
'text-red-600'}"
|
|
41
|
-
>
|
|
42
|
-
<span class="v-error-message hidden backdrop-blur-sm">
|
|
43
|
-
{error}
|
|
44
|
-
</span>
|
|
45
|
-
<iconify-icon
|
|
46
|
-
icon="solar:danger-circle-bold-duotone"
|
|
47
|
-
class="v-error-svg ml-auto cursor-pointer text-red-500 select-none hover:text-red-600"
|
|
48
|
-
style="font-size: 18px;"
|
|
49
|
-
></iconify-icon>
|
|
50
|
-
</Label>
|
|
51
|
-
{/if}
|
|
52
|
-
</Radio>
|
|
53
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Checkbox, key, Label } from '../../index.js';
|
|
3
|
+
import type { FormCheckboxProps, FormRadioProps, FormSelectProps } from '../../types/index.js';
|
|
4
|
+
import { getContext } from 'svelte';
|
|
5
|
+
import Radio from '../radio/Radio.svelte';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
label = '',
|
|
9
|
+
required,
|
|
10
|
+
name,
|
|
11
|
+
disabled,
|
|
12
|
+
contextKey = null,
|
|
13
|
+
placeholder,
|
|
14
|
+
multiple = false,
|
|
15
|
+
onchange,
|
|
16
|
+
...otherProps
|
|
17
|
+
}: FormRadioProps<any> = $props();
|
|
18
|
+
const { touched, errors, data, setData }: any = getContext(contextKey || key);
|
|
19
|
+
|
|
20
|
+
const hasError = $derived($touched[name] && $errors[name]?.length);
|
|
21
|
+
const error = $derived($errors[name]?.join(', '));
|
|
22
|
+
const value = $derived($data[name]);
|
|
23
|
+
|
|
24
|
+
function handleChange(e: Event) {
|
|
25
|
+
const value = (e.target as HTMLInputElement).value;
|
|
26
|
+
setData({ ...$data, [name]: value });
|
|
27
|
+
if (onchange) onchange(e as any);
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<div class="relative space-y-1">
|
|
32
|
+
<Radio {disabled} onchange={handleChange} {...otherProps} group={value}
|
|
33
|
+
>{label}
|
|
34
|
+
{#if required}
|
|
35
|
+
<span class="pt-1 pl-1 text-red-500">*</span>
|
|
36
|
+
{/if}
|
|
37
|
+
{#if hasError}
|
|
38
|
+
<Label
|
|
39
|
+
class="v-error-container absolute top-0 right-2 flex items-center gap-1 text-sm {hasError &&
|
|
40
|
+
'text-red-600'}"
|
|
41
|
+
>
|
|
42
|
+
<span class="v-error-message hidden backdrop-blur-sm">
|
|
43
|
+
{error}
|
|
44
|
+
</span>
|
|
45
|
+
<iconify-icon
|
|
46
|
+
icon="solar:danger-circle-bold-duotone"
|
|
47
|
+
class="v-error-svg ml-auto cursor-pointer text-red-500 select-none hover:text-red-600"
|
|
48
|
+
style="font-size: 18px;"
|
|
49
|
+
></iconify-icon>
|
|
50
|
+
</Label>
|
|
51
|
+
{/if}
|
|
52
|
+
</Radio>
|
|
53
|
+
</div>
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { key, Label } from '../../index.js';
|
|
3
|
-
import type { FormSelectProps } from '../../types/index.js';
|
|
4
|
-
import { getContext } from 'svelte';
|
|
5
|
-
import Select from '../select/Select.svelte';
|
|
6
|
-
|
|
7
|
-
let {
|
|
8
|
-
label = '',
|
|
9
|
-
required,
|
|
10
|
-
name = '',
|
|
11
|
-
disabled,
|
|
12
|
-
contextKey = null,
|
|
13
|
-
placeholder,
|
|
14
|
-
multiple = false,
|
|
15
|
-
onChange,
|
|
16
|
-
...otherProps
|
|
17
|
-
// onchange,
|
|
18
|
-
}: FormSelectProps = $props();
|
|
19
|
-
const { touched, errors, data, setData }: any = getContext(contextKey || key);
|
|
20
|
-
|
|
21
|
-
const hasError = $derived($touched[name] && $errors[name]?.length);
|
|
22
|
-
const error = $derived($errors[name]?.join(', '));
|
|
23
|
-
const value = $derived($data[name]);
|
|
24
|
-
const isSuccess = $derived(!disabled && !hasError && $touched[name]);
|
|
25
|
-
|
|
26
|
-
let renderId = $state(0);
|
|
27
|
-
|
|
28
|
-
function handleChange(e: any) {
|
|
29
|
-
if (!e) return;
|
|
30
|
-
if (!multiple) {
|
|
31
|
-
setData({ ...$data, [name]: e.value });
|
|
32
|
-
} else {
|
|
33
|
-
const d = e.map((a: any) => a.value);
|
|
34
|
-
setData({ ...$data, [name]: d });
|
|
35
|
-
}
|
|
36
|
-
if (onChange) onChange(e);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// $effect(() => {
|
|
40
|
-
// if (hasError) renderId++;
|
|
41
|
-
// if (isSuccess) {
|
|
42
|
-
// alert(isSuccess);
|
|
43
|
-
// renderId++;
|
|
44
|
-
// alert('herr');
|
|
45
|
-
// }
|
|
46
|
-
// });
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
<div class="relative space-y-1">
|
|
50
|
-
<Label
|
|
51
|
-
>{label}
|
|
52
|
-
{#if required}
|
|
53
|
-
<span class="pl-1 text-red-500">*</span>
|
|
54
|
-
{/if}
|
|
55
|
-
</Label>
|
|
56
|
-
|
|
57
|
-
<!-- {#key renderId} -->
|
|
58
|
-
<Select
|
|
59
|
-
{name}
|
|
60
|
-
{multiple}
|
|
61
|
-
{value}
|
|
62
|
-
{disabled}
|
|
63
|
-
onChange={handleChange}
|
|
64
|
-
{hasError}
|
|
65
|
-
minHeight={40}
|
|
66
|
-
hasSuccess={isSuccess}
|
|
67
|
-
{...otherProps}
|
|
68
|
-
/>
|
|
69
|
-
<!-- {/key} -->
|
|
70
|
-
|
|
71
|
-
{#if hasError}
|
|
72
|
-
<Label
|
|
73
|
-
class="v-error-container absolute top-8 right-2 flex items-center gap-1 text-sm {hasError &&
|
|
74
|
-
'text-red-600'}"
|
|
75
|
-
>
|
|
76
|
-
<span class="v-error-message hidden backdrop-blur-sm">
|
|
77
|
-
{error}
|
|
78
|
-
</span>
|
|
79
|
-
<iconify-icon
|
|
80
|
-
icon="solar:danger-circle-bold-duotone"
|
|
81
|
-
class="v-error-svg ml-auto cursor-pointer text-red-500 select-none hover:text-red-600"
|
|
82
|
-
style="font-size: 18px;"
|
|
83
|
-
></iconify-icon>
|
|
84
|
-
</Label>
|
|
85
|
-
{/if}
|
|
86
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { key, Label } from '../../index.js';
|
|
3
|
+
import type { FormSelectProps } from '../../types/index.js';
|
|
4
|
+
import { getContext } from 'svelte';
|
|
5
|
+
import Select from '../select/Select.svelte';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
label = '',
|
|
9
|
+
required,
|
|
10
|
+
name = '',
|
|
11
|
+
disabled,
|
|
12
|
+
contextKey = null,
|
|
13
|
+
placeholder,
|
|
14
|
+
multiple = false,
|
|
15
|
+
onChange,
|
|
16
|
+
...otherProps
|
|
17
|
+
// onchange,
|
|
18
|
+
}: FormSelectProps = $props();
|
|
19
|
+
const { touched, errors, data, setData }: any = getContext(contextKey || key);
|
|
20
|
+
|
|
21
|
+
const hasError = $derived($touched[name] && $errors[name]?.length);
|
|
22
|
+
const error = $derived($errors[name]?.join(', '));
|
|
23
|
+
const value = $derived($data[name]);
|
|
24
|
+
const isSuccess = $derived(!disabled && !hasError && $touched[name]);
|
|
25
|
+
|
|
26
|
+
let renderId = $state(0);
|
|
27
|
+
|
|
28
|
+
function handleChange(e: any) {
|
|
29
|
+
if (!e) return;
|
|
30
|
+
if (!multiple) {
|
|
31
|
+
setData({ ...$data, [name]: e.value });
|
|
32
|
+
} else {
|
|
33
|
+
const d = e.map((a: any) => a.value);
|
|
34
|
+
setData({ ...$data, [name]: d });
|
|
35
|
+
}
|
|
36
|
+
if (onChange) onChange(e);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// $effect(() => {
|
|
40
|
+
// if (hasError) renderId++;
|
|
41
|
+
// if (isSuccess) {
|
|
42
|
+
// alert(isSuccess);
|
|
43
|
+
// renderId++;
|
|
44
|
+
// alert('herr');
|
|
45
|
+
// }
|
|
46
|
+
// });
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<div class="relative space-y-1">
|
|
50
|
+
<Label
|
|
51
|
+
>{label}
|
|
52
|
+
{#if required}
|
|
53
|
+
<span class="pl-1 text-red-500">*</span>
|
|
54
|
+
{/if}
|
|
55
|
+
</Label>
|
|
56
|
+
|
|
57
|
+
<!-- {#key renderId} -->
|
|
58
|
+
<Select
|
|
59
|
+
{name}
|
|
60
|
+
{multiple}
|
|
61
|
+
{value}
|
|
62
|
+
{disabled}
|
|
63
|
+
onChange={handleChange}
|
|
64
|
+
{hasError}
|
|
65
|
+
minHeight={40}
|
|
66
|
+
hasSuccess={isSuccess}
|
|
67
|
+
{...otherProps}
|
|
68
|
+
/>
|
|
69
|
+
<!-- {/key} -->
|
|
70
|
+
|
|
71
|
+
{#if hasError}
|
|
72
|
+
<Label
|
|
73
|
+
class="v-error-container absolute top-8 right-2 flex items-center gap-1 text-sm {hasError &&
|
|
74
|
+
'text-red-600'}"
|
|
75
|
+
>
|
|
76
|
+
<span class="v-error-message hidden backdrop-blur-sm">
|
|
77
|
+
{error}
|
|
78
|
+
</span>
|
|
79
|
+
<iconify-icon
|
|
80
|
+
icon="solar:danger-circle-bold-duotone"
|
|
81
|
+
class="v-error-svg ml-auto cursor-pointer text-red-500 select-none hover:text-red-600"
|
|
82
|
+
style="font-size: 18px;"
|
|
83
|
+
></iconify-icon>
|
|
84
|
+
</Label>
|
|
85
|
+
{/if}
|
|
86
|
+
</div>
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { key, type FormTextareaProps } from '../../index.js';
|
|
3
|
-
import { getContext } from 'svelte';
|
|
4
|
-
import Label from '../label/Label.svelte';
|
|
5
|
-
import Textarea from '../textarea/Textarea.svelte';
|
|
6
|
-
|
|
7
|
-
let {
|
|
8
|
-
label = '',
|
|
9
|
-
required,
|
|
10
|
-
name,
|
|
11
|
-
readonly,
|
|
12
|
-
contextKey = null,
|
|
13
|
-
placeholder,
|
|
14
|
-
onchange,
|
|
15
|
-
...otherProps
|
|
16
|
-
// onchange,
|
|
17
|
-
}: FormTextareaProps = $props();
|
|
18
|
-
const { touched, errors, data, setData }: any = getContext(contextKey || key);
|
|
19
|
-
|
|
20
|
-
const hasError = $derived($touched[name] && $errors[name]?.length);
|
|
21
|
-
const error = $derived($errors[name]?.join(', '));
|
|
22
|
-
const isSuccess = $derived(!readonly && !hasError && $touched[name]);
|
|
23
|
-
const isTouched = $derived(!readonly && $touched[name]);
|
|
24
|
-
|
|
25
|
-
function handeleChange(e: Event) {
|
|
26
|
-
const value = (e.target as HTMLTextAreaElement).value;
|
|
27
|
-
// console.log({ value });
|
|
28
|
-
setData({ ...$data, [name]: value });
|
|
29
|
-
if (onchange) onchange(e as any);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getNestedValue<T extends Record<string, any>>(obj: T, path: string): any {
|
|
33
|
-
return path
|
|
34
|
-
.split('.')
|
|
35
|
-
.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : null), obj);
|
|
36
|
-
}
|
|
37
|
-
</script>
|
|
38
|
-
|
|
39
|
-
<div class="relative space-y-1">
|
|
40
|
-
<Label
|
|
41
|
-
>{label}
|
|
42
|
-
{#if required}
|
|
43
|
-
<span class="pl-1 text-red-500">*</span>
|
|
44
|
-
{/if}
|
|
45
|
-
</Label>
|
|
46
|
-
|
|
47
|
-
<Textarea
|
|
48
|
-
color={readonly ? 'gray' : hasError ? 'red' : isSuccess ? 'green' : 'default'}
|
|
49
|
-
{readonly}
|
|
50
|
-
value={getNestedValue($data, name) || ''}
|
|
51
|
-
onchange={handeleChange}
|
|
52
|
-
class="flex w-full"
|
|
53
|
-
{...otherProps}
|
|
54
|
-
/>
|
|
55
|
-
|
|
56
|
-
{#if hasError}
|
|
57
|
-
<Label
|
|
58
|
-
class="v-error-container absolute top-8 right-2 flex items-center gap-1 text-sm {hasError &&
|
|
59
|
-
'text-red-600'}"
|
|
60
|
-
>
|
|
61
|
-
<span class="v-error-message hidden backdrop-blur-sm">
|
|
62
|
-
{error}
|
|
63
|
-
</span>
|
|
64
|
-
<iconify-icon
|
|
65
|
-
icon="solar:danger-circle-bold-duotone"
|
|
66
|
-
class="v-error-svg ml-auto cursor-pointer text-red-500 select-none hover:text-red-600"
|
|
67
|
-
style="font-size: 18px;"
|
|
68
|
-
></iconify-icon>
|
|
69
|
-
</Label>
|
|
70
|
-
{/if}
|
|
71
|
-
</div>
|
|
72
|
-
|
|
73
|
-
<!-- <style>
|
|
74
|
-
.v-error-container:hover .v-error-message {
|
|
75
|
-
display: block !important;
|
|
76
|
-
}
|
|
77
|
-
</style> -->
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { key, type FormTextareaProps } from '../../index.js';
|
|
3
|
+
import { getContext } from 'svelte';
|
|
4
|
+
import Label from '../label/Label.svelte';
|
|
5
|
+
import Textarea from '../textarea/Textarea.svelte';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
label = '',
|
|
9
|
+
required,
|
|
10
|
+
name,
|
|
11
|
+
readonly,
|
|
12
|
+
contextKey = null,
|
|
13
|
+
placeholder,
|
|
14
|
+
onchange,
|
|
15
|
+
...otherProps
|
|
16
|
+
// onchange,
|
|
17
|
+
}: FormTextareaProps = $props();
|
|
18
|
+
const { touched, errors, data, setData }: any = getContext(contextKey || key);
|
|
19
|
+
|
|
20
|
+
const hasError = $derived($touched[name] && $errors[name]?.length);
|
|
21
|
+
const error = $derived($errors[name]?.join(', '));
|
|
22
|
+
const isSuccess = $derived(!readonly && !hasError && $touched[name]);
|
|
23
|
+
const isTouched = $derived(!readonly && $touched[name]);
|
|
24
|
+
|
|
25
|
+
function handeleChange(e: Event) {
|
|
26
|
+
const value = (e.target as HTMLTextAreaElement).value;
|
|
27
|
+
// console.log({ value });
|
|
28
|
+
setData({ ...$data, [name]: value });
|
|
29
|
+
if (onchange) onchange(e as any);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getNestedValue<T extends Record<string, any>>(obj: T, path: string): any {
|
|
33
|
+
return path
|
|
34
|
+
.split('.')
|
|
35
|
+
.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : null), obj);
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<div class="relative space-y-1">
|
|
40
|
+
<Label
|
|
41
|
+
>{label}
|
|
42
|
+
{#if required}
|
|
43
|
+
<span class="pl-1 text-red-500">*</span>
|
|
44
|
+
{/if}
|
|
45
|
+
</Label>
|
|
46
|
+
|
|
47
|
+
<Textarea
|
|
48
|
+
color={readonly ? 'gray' : hasError ? 'red' : isSuccess ? 'green' : 'default'}
|
|
49
|
+
{readonly}
|
|
50
|
+
value={getNestedValue($data, name) || ''}
|
|
51
|
+
onchange={handeleChange}
|
|
52
|
+
class="flex w-full"
|
|
53
|
+
{...otherProps}
|
|
54
|
+
/>
|
|
55
|
+
|
|
56
|
+
{#if hasError}
|
|
57
|
+
<Label
|
|
58
|
+
class="v-error-container absolute top-8 right-2 flex items-center gap-1 text-sm {hasError &&
|
|
59
|
+
'text-red-600'}"
|
|
60
|
+
>
|
|
61
|
+
<span class="v-error-message hidden backdrop-blur-sm">
|
|
62
|
+
{error}
|
|
63
|
+
</span>
|
|
64
|
+
<iconify-icon
|
|
65
|
+
icon="solar:danger-circle-bold-duotone"
|
|
66
|
+
class="v-error-svg ml-auto cursor-pointer text-red-500 select-none hover:text-red-600"
|
|
67
|
+
style="font-size: 18px;"
|
|
68
|
+
></iconify-icon>
|
|
69
|
+
</Label>
|
|
70
|
+
{/if}
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
<!-- <style>
|
|
74
|
+
.v-error-container:hover .v-error-message {
|
|
75
|
+
display: block !important;
|
|
76
|
+
}
|
|
77
|
+
</style> -->
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { getTheme, warnThemeDeprecation } from '../../themes/themeUtils.js';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { checkbox } from './index.js';
|
|
5
|
-
import { Label, type CheckboxItem, type CheckboxProps } from '../../index.js';
|
|
6
|
-
|
|
7
|
-
let {
|
|
8
|
-
children,
|
|
9
|
-
color = 'primary',
|
|
10
|
-
custom,
|
|
11
|
-
inline,
|
|
12
|
-
tinted,
|
|
13
|
-
rounded,
|
|
14
|
-
group = $bindable([]),
|
|
15
|
-
choices = [],
|
|
16
|
-
checked = $bindable(false),
|
|
17
|
-
indeterminate,
|
|
18
|
-
classes,
|
|
19
|
-
class: className,
|
|
20
|
-
divClass,
|
|
21
|
-
disabled = false,
|
|
22
|
-
value,
|
|
23
|
-
labelProps = {},
|
|
24
|
-
...restProps
|
|
25
|
-
}: CheckboxProps = $props();
|
|
26
|
-
|
|
27
|
-
warnThemeDeprecation('Checkbox', { divClass }, { divClass: 'div' });
|
|
28
|
-
const styling = $derived(classes ?? { div: divClass });
|
|
29
|
-
|
|
30
|
-
const theme = getTheme('checkbox');
|
|
31
|
-
|
|
32
|
-
const disabledValue = $derived(disabled === null ? undefined : disabled);
|
|
33
|
-
const { base, div: divStyle } = $derived(
|
|
34
|
-
checkbox({ color, tinted, custom, rounded, inline, disabled: disabledValue })
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
// Separate label rendering logic
|
|
38
|
-
function renderLabel(choice?: CheckboxItem) {
|
|
39
|
-
if (!choice) return '';
|
|
40
|
-
|
|
41
|
-
if (children) {
|
|
42
|
-
return children(choice);
|
|
43
|
-
}
|
|
44
|
-
return choice.label || '';
|
|
45
|
-
}
|
|
46
|
-
</script>
|
|
47
|
-
|
|
48
|
-
{#if choices.length > 0}
|
|
49
|
-
{#each choices as choice, i}
|
|
50
|
-
<div class={divStyle({ class: clsx(theme?.div, styling.div) })}>
|
|
51
|
-
<Label show={true} {...labelProps}>
|
|
52
|
-
<input
|
|
53
|
-
type="checkbox"
|
|
54
|
-
value={choice.value}
|
|
55
|
-
checked={choice.checked ?? false}
|
|
56
|
-
{disabled}
|
|
57
|
-
bind:group
|
|
58
|
-
{...restProps}
|
|
59
|
-
class={base({ class: clsx(theme?.base, className) })}
|
|
60
|
-
/>
|
|
61
|
-
{renderLabel(choice)}
|
|
62
|
-
</Label>
|
|
63
|
-
</div>
|
|
64
|
-
{/each}
|
|
65
|
-
{:else}
|
|
66
|
-
<div class={divStyle({ class: clsx(theme?.div, styling.div) })}>
|
|
67
|
-
<Label show={true} {...labelProps}>
|
|
68
|
-
<input
|
|
69
|
-
type="checkbox"
|
|
70
|
-
{value}
|
|
71
|
-
bind:checked
|
|
72
|
-
{indeterminate}
|
|
73
|
-
{disabled}
|
|
74
|
-
{...restProps}
|
|
75
|
-
class={base({ class: clsx(theme?.base, className) })}
|
|
76
|
-
/>
|
|
77
|
-
{#if children}
|
|
78
|
-
{@render children({ value, checked, disabled })}
|
|
79
|
-
{/if}
|
|
80
|
-
</Label>
|
|
81
|
-
</div>
|
|
82
|
-
{/if}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getTheme, warnThemeDeprecation } from '../../themes/themeUtils.js';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { checkbox } from './index.js';
|
|
5
|
+
import { Label, type CheckboxItem, type CheckboxProps } from '../../index.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
children,
|
|
9
|
+
color = 'primary',
|
|
10
|
+
custom,
|
|
11
|
+
inline,
|
|
12
|
+
tinted,
|
|
13
|
+
rounded,
|
|
14
|
+
group = $bindable([]),
|
|
15
|
+
choices = [],
|
|
16
|
+
checked = $bindable(false),
|
|
17
|
+
indeterminate,
|
|
18
|
+
classes,
|
|
19
|
+
class: className,
|
|
20
|
+
divClass,
|
|
21
|
+
disabled = false,
|
|
22
|
+
value,
|
|
23
|
+
labelProps = {},
|
|
24
|
+
...restProps
|
|
25
|
+
}: CheckboxProps = $props();
|
|
26
|
+
|
|
27
|
+
warnThemeDeprecation('Checkbox', { divClass }, { divClass: 'div' });
|
|
28
|
+
const styling = $derived(classes ?? { div: divClass });
|
|
29
|
+
|
|
30
|
+
const theme = getTheme('checkbox');
|
|
31
|
+
|
|
32
|
+
const disabledValue = $derived(disabled === null ? undefined : disabled);
|
|
33
|
+
const { base, div: divStyle } = $derived(
|
|
34
|
+
checkbox({ color, tinted, custom, rounded, inline, disabled: disabledValue })
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Separate label rendering logic
|
|
38
|
+
function renderLabel(choice?: CheckboxItem) {
|
|
39
|
+
if (!choice) return '';
|
|
40
|
+
|
|
41
|
+
if (children) {
|
|
42
|
+
return children(choice);
|
|
43
|
+
}
|
|
44
|
+
return choice.label || '';
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
{#if choices.length > 0}
|
|
49
|
+
{#each choices as choice, i}
|
|
50
|
+
<div class={divStyle({ class: clsx(theme?.div, styling.div) })}>
|
|
51
|
+
<Label show={true} {...labelProps}>
|
|
52
|
+
<input
|
|
53
|
+
type="checkbox"
|
|
54
|
+
value={choice.value}
|
|
55
|
+
checked={choice.checked ?? false}
|
|
56
|
+
{disabled}
|
|
57
|
+
bind:group
|
|
58
|
+
{...restProps}
|
|
59
|
+
class={base({ class: clsx(theme?.base, className) })}
|
|
60
|
+
/>
|
|
61
|
+
{renderLabel(choice)}
|
|
62
|
+
</Label>
|
|
63
|
+
</div>
|
|
64
|
+
{/each}
|
|
65
|
+
{:else}
|
|
66
|
+
<div class={divStyle({ class: clsx(theme?.div, styling.div) })}>
|
|
67
|
+
<Label show={true} {...labelProps}>
|
|
68
|
+
<input
|
|
69
|
+
type="checkbox"
|
|
70
|
+
{value}
|
|
71
|
+
bind:checked
|
|
72
|
+
{indeterminate}
|
|
73
|
+
{disabled}
|
|
74
|
+
{...restProps}
|
|
75
|
+
class={base({ class: clsx(theme?.base, className) })}
|
|
76
|
+
/>
|
|
77
|
+
{#if children}
|
|
78
|
+
{@render children({ value, checked, disabled })}
|
|
79
|
+
{/if}
|
|
80
|
+
</Label>
|
|
81
|
+
</div>
|
|
82
|
+
{/if}
|