flowbite-svelte 0.27.4 → 0.27.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/CHANGELOG.md +29 -0
- package/accordions/Accordion.svelte +24 -0
- package/accordions/Accordion.svelte.d.ts +30 -0
- package/accordions/AccordionItem.svelte +36 -70
- package/accordions/AccordionItem.svelte.d.ts +5 -8
- package/breadcrumbs/BreadcrumbItem.svelte +37 -44
- package/breadcrumbs/BreadcrumbItem.svelte.d.ts +1 -0
- package/buttongroups/ButtonGroup.svelte +4 -4
- package/buttongroups/ButtonGroup.svelte.d.ts +2 -0
- package/buttons/Button.svelte +3 -8
- package/buttons/Button.svelte.d.ts +2 -2
- package/cards/Card.svelte +12 -12
- package/cards/Card.svelte.d.ts +3 -2
- package/carousels/CarouselTransition.svelte +1 -1
- package/carousels/Thumbnail.svelte +9 -1
- package/darkmode/DarkMode.svelte +27 -24
- package/drawer/Drawer.svelte +26 -13
- package/drawer/Drawer.svelte.d.ts +1 -0
- package/forms/Checkbox.svelte +17 -18
- package/forms/FloatingLabelInput.svelte.d.ts +1 -1
- package/forms/Helper.svelte.d.ts +1 -1
- package/forms/Input.svelte +70 -38
- package/forms/Input.svelte.d.ts +15 -5
- package/forms/InputAddon.svelte +29 -0
- package/forms/InputAddon.svelte.d.ts +19 -0
- package/forms/Label.svelte.d.ts +1 -1
- package/forms/NumberInput.svelte +7 -0
- package/forms/NumberInput.svelte.d.ts +16 -0
- package/forms/Radio.svelte +30 -43
- package/forms/Radio.svelte.d.ts +2 -2
- package/forms/Search.svelte +51 -43
- package/forms/Search.svelte.d.ts +5 -6
- package/forms/SimpleSearch.svelte +17 -62
- package/forms/SimpleSearch.svelte.d.ts +0 -18
- package/forms/Toggle.svelte +4 -13
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/list-group/ListgroupItem.svelte +38 -40
- package/modals/Modal.svelte.d.ts +2 -2
- package/package.json +7 -4
- package/ratings/Rating.svelte +21 -20
- package/ratings/Rating.svelte.d.ts +1 -0
- package/tables/Table.svelte.d.ts +1 -1
- package/tables/TableSearch.svelte.d.ts +1 -1
- package/toasts/Toast.svelte +0 -1
- package/tooltips/Tooltip.svelte.d.ts +1 -1
- package/types.d.ts +3 -32
- package/typography/P.svelte.d.ts +1 -1
- package/utils/Frame.svelte +1 -1
- package/utils/Frame.svelte.d.ts +1 -1
- package/utils/Popper.svelte +19 -16
- package/utils/focusTrap.js +15 -24
package/forms/Checkbox.svelte
CHANGED
|
@@ -7,7 +7,7 @@ export let custom = false;
|
|
|
7
7
|
export let inline = false;
|
|
8
8
|
export let group = [];
|
|
9
9
|
export let value = '';
|
|
10
|
-
export let checked =
|
|
10
|
+
export let checked = false;
|
|
11
11
|
// tinted if put in component having its own background
|
|
12
12
|
let background = getContext('background');
|
|
13
13
|
$: {
|
|
@@ -33,21 +33,20 @@ $: {
|
|
|
33
33
|
</script>
|
|
34
34
|
|
|
35
35
|
<Label class={labelClass(inline, $$props.class)} show={!!$$slots.default}>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/><slot />
|
|
36
|
+
<input
|
|
37
|
+
type="checkbox"
|
|
38
|
+
bind:checked
|
|
39
|
+
on:keyup
|
|
40
|
+
on:keydown
|
|
41
|
+
on:keypress
|
|
42
|
+
on:focus
|
|
43
|
+
on:blur
|
|
44
|
+
on:click
|
|
45
|
+
on:mouseover
|
|
46
|
+
on:mouseenter
|
|
47
|
+
on:mouseleave
|
|
48
|
+
on:paste
|
|
49
|
+
{value}
|
|
50
|
+
{...$$restProps}
|
|
51
|
+
class={inputClass(custom, color, true, background, $$slots.default || $$props.class)} /><slot />
|
|
53
52
|
</Label>
|
|
@@ -7,7 +7,7 @@ declare const __propDef: {
|
|
|
7
7
|
style?: "filled" | "outlined" | "standard" | undefined;
|
|
8
8
|
type?: InputType | undefined;
|
|
9
9
|
size?: "default" | "small" | undefined;
|
|
10
|
-
color?: "
|
|
10
|
+
color?: "red" | "green" | "base" | undefined;
|
|
11
11
|
value?: string | undefined;
|
|
12
12
|
label?: string | undefined;
|
|
13
13
|
};
|
package/forms/Helper.svelte.d.ts
CHANGED
package/forms/Input.svelte
CHANGED
|
@@ -1,50 +1,82 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script context="module">export function clampSize(s) {
|
|
2
|
+
return s && s === 'xs' ? 'sm' : s === 'xl' ? 'lg' : s;
|
|
3
|
+
}
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<script>import Wrapper from '../utils/Wrapper.svelte';
|
|
7
|
+
import classNames from 'classnames';
|
|
2
8
|
import { getContext } from 'svelte';
|
|
3
9
|
export let type = 'text';
|
|
4
10
|
export let value = '';
|
|
5
|
-
export let size =
|
|
6
|
-
export let
|
|
11
|
+
export let size = undefined;
|
|
12
|
+
export let defaultClass = 'block w-full disabled:cursor-not-allowed disabled:opacity-50';
|
|
7
13
|
export let color = 'base';
|
|
14
|
+
const borderClasses = {
|
|
15
|
+
base: 'border-gray-300 dark:border-gray-600',
|
|
16
|
+
tinted: 'border-gray-300 dark:border-gray-500',
|
|
17
|
+
green: 'border-green-500 dark:border-green-400',
|
|
18
|
+
red: 'border-red-500 dark:border-red-400'
|
|
19
|
+
};
|
|
20
|
+
const ringClasses = {
|
|
21
|
+
base: 'focus:border-blue-500 focus:ring-blue-500 dark:focus:border-blue-500 dark:focus:ring-blue-500',
|
|
22
|
+
green: 'focus:ring-green-500 focus:border-green-500 dark:focus:border-green-500 dark:focus:ring-green-500',
|
|
23
|
+
red: 'focus:ring-red-500 focus:border-red-500 dark:focus:ring-red-500 dark:focus:border-red-500'
|
|
24
|
+
};
|
|
8
25
|
const colorClasses = {
|
|
9
|
-
base: 'bg-gray-50
|
|
10
|
-
|
|
11
|
-
|
|
26
|
+
base: 'bg-gray-50 text-gray-900 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400',
|
|
27
|
+
tinted: 'bg-gray-50 text-gray-900 dark:bg-gray-600 dark:text-white dark:placeholder-gray-400',
|
|
28
|
+
green: 'bg-green-50 text-green-900 placeholder-green-700 dark:bg-gray-700',
|
|
29
|
+
red: 'bg-red-50 text-red-900 placeholder-red-700 dark:bg-gray-700'
|
|
12
30
|
};
|
|
13
31
|
// tinted if put in component having its own background
|
|
14
32
|
let background = getContext('background');
|
|
33
|
+
let group = getContext('group');
|
|
15
34
|
// you need to this to avoid 2-way binding
|
|
16
|
-
const setType = (node) => {
|
|
17
|
-
node.type =
|
|
35
|
+
const setType = (node, _type) => {
|
|
36
|
+
node.type = _type;
|
|
37
|
+
return {
|
|
38
|
+
update(_type) {
|
|
39
|
+
node.type = _type;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
18
42
|
};
|
|
43
|
+
const textSizes = { sm: 'sm:text-xs', md: 'text-sm', lg: 'sm:text-base' };
|
|
44
|
+
const leftPadding = { sm: 'pl-9', md: 'pl-10', lg: 'pl-11' };
|
|
45
|
+
const rightPadding = { sm: 'pr-9', md: 'pr-10', lg: 'pr-11' };
|
|
46
|
+
const inputPadding = { sm: 'p-2', md: 'p-2.5', lg: 'p-4' };
|
|
47
|
+
$: _size = size || clampSize(group?.size) || 'md';
|
|
48
|
+
let inputClass;
|
|
49
|
+
$: {
|
|
50
|
+
const _color = color === 'base' && background ? 'tinted' : color;
|
|
51
|
+
inputClass = classNames(defaultClass, $$slots.left && leftPadding[_size], $$slots.right && rightPadding[_size], ringClasses[color], colorClasses[_color], borderClasses[_color], inputPadding[_size], textSizes[_size], group || 'rounded-lg', group && 'first:rounded-l-lg last:rounded-r-lg', group && 'border-l-0 first:border-l last:border-r', $$props.class);
|
|
52
|
+
}
|
|
53
|
+
let floatClass = 'flex absolute inset-y-0 items-center pointer-events-none text-gray-500 dark:text-gray-400';
|
|
19
54
|
</script>
|
|
20
55
|
|
|
21
|
-
<
|
|
22
|
-
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
$$props.class
|
|
50
|
-
)} />
|
|
56
|
+
<Wrapper class="relative w-full" show={$$slots.left || $$slots.right}>
|
|
57
|
+
{#if $$slots.left}
|
|
58
|
+
<div class="{floatClass} left-0 pl-2.5"><slot name="left" /></div>
|
|
59
|
+
{/if}
|
|
60
|
+
<slot props={{ ...$$restProps, class: inputClass }}>
|
|
61
|
+
<input
|
|
62
|
+
{...$$restProps}
|
|
63
|
+
bind:value
|
|
64
|
+
on:blur
|
|
65
|
+
on:change
|
|
66
|
+
on:click
|
|
67
|
+
on:focus
|
|
68
|
+
on:keydown
|
|
69
|
+
on:keypress
|
|
70
|
+
on:keyup
|
|
71
|
+
on:mouseover
|
|
72
|
+
on:mouseenter
|
|
73
|
+
on:mouseleave
|
|
74
|
+
on:paste
|
|
75
|
+
on:input
|
|
76
|
+
use:setType={type}
|
|
77
|
+
class={inputClass} />
|
|
78
|
+
</slot>
|
|
79
|
+
{#if $$slots.right}
|
|
80
|
+
<div class="{floatClass} right-0 pr-2.5"><slot name="right" /></div>
|
|
81
|
+
{/if}
|
|
82
|
+
</Wrapper>
|
package/forms/Input.svelte.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { SizeType, FormSizeType } from '../types';
|
|
3
|
+
export declare function clampSize(s: SizeType): "sm" | "md" | "lg";
|
|
2
4
|
import type { InputType } from '../types';
|
|
3
5
|
declare const __propDef: {
|
|
4
6
|
props: {
|
|
5
7
|
[x: string]: any;
|
|
6
8
|
type?: InputType | undefined;
|
|
7
|
-
value?: string | undefined;
|
|
8
|
-
size?:
|
|
9
|
-
|
|
10
|
-
color?: "
|
|
9
|
+
value?: string | number | undefined;
|
|
10
|
+
size?: FormSizeType | undefined;
|
|
11
|
+
defaultClass?: string | undefined;
|
|
12
|
+
color?: "red" | "green" | "base" | undefined;
|
|
11
13
|
};
|
|
12
14
|
events: {
|
|
13
15
|
blur: FocusEvent;
|
|
@@ -25,7 +27,15 @@ declare const __propDef: {
|
|
|
25
27
|
} & {
|
|
26
28
|
[evt: string]: CustomEvent<any>;
|
|
27
29
|
};
|
|
28
|
-
slots: {
|
|
30
|
+
slots: {
|
|
31
|
+
left: {};
|
|
32
|
+
default: {
|
|
33
|
+
props: {
|
|
34
|
+
class: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
right: {};
|
|
38
|
+
};
|
|
29
39
|
};
|
|
30
40
|
export declare type InputProps = typeof __propDef.props;
|
|
31
41
|
export declare type InputEvents = typeof __propDef.events;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script>import classNames from 'classnames';
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
import { clampSize } from './Input.svelte';
|
|
4
|
+
export let size = undefined;
|
|
5
|
+
// tinted if put in component having its own background
|
|
6
|
+
let background = getContext('background');
|
|
7
|
+
let group = getContext('group');
|
|
8
|
+
const borderClasses = {
|
|
9
|
+
base: 'border-gray-300 dark:border-gray-600',
|
|
10
|
+
tinted: 'border-gray-300 dark:border-gray-500'
|
|
11
|
+
};
|
|
12
|
+
const darkBgClasses = {
|
|
13
|
+
base: 'dark:bg-gray-600 dark:text-gray-400',
|
|
14
|
+
tinted: 'dark:bg-gray-500 dark:text-gray-300'
|
|
15
|
+
};
|
|
16
|
+
const divider = {
|
|
17
|
+
base: 'dark:border-r-gray-700 dark:last:border-r-gray-600',
|
|
18
|
+
tinted: 'dark:border-r-gray-600 dark:last:border-r-gray-500'
|
|
19
|
+
};
|
|
20
|
+
const textSizes = { sm: 'sm:text-xs', md: 'text-sm', lg: 'sm:text-base' };
|
|
21
|
+
const prefixPadding = { sm: 'px-2', md: 'px-3', lg: 'px-4' };
|
|
22
|
+
// size: explicit, inherited, default
|
|
23
|
+
$: _size = size || clampSize(group?.size) || 'md';
|
|
24
|
+
$: divClass = classNames(textSizes[_size], prefixPadding[_size], background ? borderClasses['tinted'] : borderClasses['base'], 'text-gray-500 bg-gray-200', background ? darkBgClasses.tinted : darkBgClasses.base, background ? divider.tinted : divider.base, 'inline-flex items-center border-t border-b first:border-l border-r', 'first:rounded-l-lg last:rounded-r-lg', $$props.class);
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<div {...$$restProps} class={divClass}>
|
|
28
|
+
<slot />
|
|
29
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
size?: 'sm' | 'md' | 'lg' | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {
|
|
11
|
+
default: {};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare type InputAddonProps = typeof __propDef.props;
|
|
15
|
+
export declare type InputAddonEvents = typeof __propDef.events;
|
|
16
|
+
export declare type InputAddonSlots = typeof __propDef.slots;
|
|
17
|
+
export default class InputAddon extends SvelteComponentTyped<InputAddonProps, InputAddonEvents, InputAddonSlots> {
|
|
18
|
+
}
|
|
19
|
+
export {};
|
package/forms/Label.svelte.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
-
color?: "
|
|
5
|
+
color?: "gray" | "red" | "green" | "disabled" | undefined;
|
|
6
6
|
defaultClass?: string | undefined;
|
|
7
7
|
show?: boolean | undefined;
|
|
8
8
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
value?: number | undefined;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {};
|
|
10
|
+
};
|
|
11
|
+
export declare type NumberInputProps = typeof __propDef.props;
|
|
12
|
+
export declare type NumberInputEvents = typeof __propDef.events;
|
|
13
|
+
export declare type NumberInputSlots = typeof __propDef.slots;
|
|
14
|
+
export default class NumberInput extends SvelteComponentTyped<NumberInputProps, NumberInputEvents, NumberInputSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
package/forms/Radio.svelte
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
<script context="module"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export const labelClass = (inline, extraClass) =>
|
|
16
|
-
classNames(inline ? 'inline-flex' : 'flex', 'items-center', extraClass);
|
|
17
|
-
|
|
18
|
-
export const inputClass = (custom, color, rounded, tinted, extraClass) =>
|
|
19
|
-
classNames(
|
|
20
|
-
'w-4 h-4 bg-gray-100 border-gray-300 dark:ring-offset-gray-800 focus:ring-2 mr-2',
|
|
21
|
-
tinted ? 'dark:bg-gray-600 dark:border-gray-500' : 'dark:bg-gray-700 dark:border-gray-600',
|
|
22
|
-
custom && 'sr-only peer',
|
|
23
|
-
rounded && 'rounded',
|
|
24
|
-
colorClasses[color],
|
|
25
|
-
extraClass
|
|
26
|
-
);
|
|
1
|
+
<script context="module">// this part is shared between Radio and Checkbox
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
const colorClasses = {
|
|
4
|
+
red: 'text-red-600 focus:ring-red-500 dark:focus:ring-red-600',
|
|
5
|
+
green: 'text-green-600 focus:ring-green-500 dark:focus:ring-green-600',
|
|
6
|
+
purple: 'text-purple-600 focus:ring-purple-500 dark:focus:ring-purple-600',
|
|
7
|
+
teal: 'text-teal-600 focus:ring-teal-500 dark:focus:ring-teal-600',
|
|
8
|
+
yellow: 'text-yellow-400 focus:ring-yellow-500 dark:focus:ring-yellow-600',
|
|
9
|
+
orange: 'text-orange-500 focus:ring-orange-500 dark:focus:ring-orange-600',
|
|
10
|
+
blue: 'text-blue-600 focus:ring-blue-500 dark:focus:ring-blue-600'
|
|
11
|
+
};
|
|
12
|
+
export const labelClass = (inline, extraClass) => classNames(inline ? 'inline-flex' : 'flex', 'items-center', extraClass);
|
|
13
|
+
export const inputClass = (custom, color, rounded, tinted, extraClass) => classNames('w-4 h-4 bg-gray-100 border-gray-300 dark:ring-offset-gray-800 focus:ring-2', extraClass === true && 'mr-2', tinted ? 'dark:bg-gray-600 dark:border-gray-500' : 'dark:bg-gray-700 dark:border-gray-600', custom && 'sr-only peer', rounded && 'rounded', colorClasses[color], extraClass);
|
|
27
14
|
</script>
|
|
28
15
|
|
|
29
16
|
<script>import { getContext } from 'svelte';
|
|
@@ -38,21 +25,21 @@ let background = getContext('background');
|
|
|
38
25
|
</script>
|
|
39
26
|
|
|
40
27
|
<Label class={labelClass(inline, $$props.class)} show={$$slots.default}>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
28
|
+
<input
|
|
29
|
+
type="radio"
|
|
30
|
+
bind:group
|
|
31
|
+
on:blur
|
|
32
|
+
on:change
|
|
33
|
+
on:click
|
|
34
|
+
on:focus
|
|
35
|
+
on:keydown
|
|
36
|
+
on:keypress
|
|
37
|
+
on:keyup
|
|
38
|
+
on:mouseenter
|
|
39
|
+
on:mouseleave
|
|
40
|
+
on:mouseover
|
|
41
|
+
on:paste
|
|
42
|
+
{value}
|
|
43
|
+
{...$$restProps}
|
|
44
|
+
class={inputClass(custom, color, false, background, $$slots.default || $$props.class)} /><slot />
|
|
58
45
|
</Label>
|
package/forms/Radio.svelte.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
export declare const labelClass: (inline:
|
|
3
|
-
export declare const inputClass: (custom:
|
|
2
|
+
export declare const labelClass: (inline: boolean, extraClass: string) => string;
|
|
3
|
+
export declare const inputClass: (custom: boolean, color: FormColorType, rounded: boolean, tinted: boolean, extraClass: string | boolean) => string;
|
|
4
4
|
import type { FormColorType } from '../types';
|
|
5
5
|
declare const __propDef: {
|
|
6
6
|
props: {
|
package/forms/Search.svelte
CHANGED
|
@@ -1,46 +1,54 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
export let
|
|
4
|
-
export let btnClass = 'text-white absolute right-2.5 bottom-2.5 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800';
|
|
1
|
+
<script>import Wrapper from '../utils/Wrapper.svelte';
|
|
2
|
+
import Input from './Input.svelte';
|
|
3
|
+
export let size = 'lg';
|
|
5
4
|
export let placeholder = 'Search';
|
|
5
|
+
const sizes = {
|
|
6
|
+
sm: 'w-3.5 h-3.5',
|
|
7
|
+
md: 'w-5 h-5',
|
|
8
|
+
lg: 'w-6 h-6'
|
|
9
|
+
};
|
|
6
10
|
</script>
|
|
7
11
|
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
12
|
+
<Wrapper class="relative w-full" show={$$slots.default}>
|
|
13
|
+
<Input
|
|
14
|
+
on:blur
|
|
15
|
+
on:change
|
|
16
|
+
on:click
|
|
17
|
+
on:focus
|
|
18
|
+
on:keydown
|
|
19
|
+
on:keypress
|
|
20
|
+
on:keyup
|
|
21
|
+
on:mouseenter
|
|
22
|
+
on:mouseleave
|
|
23
|
+
on:mouseover
|
|
24
|
+
on:paste
|
|
25
|
+
type="search"
|
|
26
|
+
{placeholder}
|
|
27
|
+
{size}
|
|
28
|
+
{...$$restProps}
|
|
29
|
+
class={$$props.class}>
|
|
30
|
+
<svg
|
|
31
|
+
slot="left"
|
|
32
|
+
class={sizes[size]}
|
|
33
|
+
fill="currentColor"
|
|
34
|
+
viewBox="0 0 20 20"
|
|
35
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
36
|
+
<path
|
|
37
|
+
fill-rule="evenodd"
|
|
38
|
+
d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z"
|
|
39
|
+
clip-rule="evenodd" />
|
|
40
|
+
</svg>
|
|
41
|
+
<!-- We can use it here. See below. This will trigger right padding
|
|
42
|
+
<slot slot="right" />
|
|
43
|
+
-->
|
|
44
|
+
</Input>
|
|
45
|
+
<!-- This slot should be within Input as a slot='right'
|
|
46
|
+
Svelete has an issue with forwarded slots and even empty slot here will appear as existing slot in Input.
|
|
47
|
+
Due to that we need the below slot and Wrapper around
|
|
48
|
+
-->
|
|
49
|
+
{#if $$slots.default}
|
|
50
|
+
<div class="flex absolute inset-y-0 right-0 items-center pr-3 text-gray-500 dark:text-gray-400">
|
|
51
|
+
<slot />
|
|
52
|
+
</div>
|
|
53
|
+
{/if}
|
|
54
|
+
</Wrapper>
|
package/forms/Search.svelte.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { FormSizeType } from '../types';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
4
5
|
[x: string]: any;
|
|
5
|
-
|
|
6
|
-
labelClass?: string | undefined;
|
|
7
|
-
inputClass?: string | undefined;
|
|
8
|
-
btnClass?: string | undefined;
|
|
6
|
+
size?: FormSizeType | undefined;
|
|
9
7
|
placeholder?: string | undefined;
|
|
10
8
|
};
|
|
11
9
|
events: {
|
|
12
|
-
submit: SubmitEvent;
|
|
13
10
|
blur: FocusEvent;
|
|
14
11
|
change: Event;
|
|
15
12
|
click: MouseEvent;
|
|
@@ -24,7 +21,9 @@ declare const __propDef: {
|
|
|
24
21
|
} & {
|
|
25
22
|
[evt: string]: CustomEvent<any>;
|
|
26
23
|
};
|
|
27
|
-
slots: {
|
|
24
|
+
slots: {
|
|
25
|
+
default: {};
|
|
26
|
+
};
|
|
28
27
|
};
|
|
29
28
|
export declare type SearchProps = typeof __propDef.props;
|
|
30
29
|
export declare type SearchEvents = typeof __propDef.events;
|
|
@@ -1,65 +1,20 @@
|
|
|
1
|
-
<script>import
|
|
2
|
-
|
|
3
|
-
export let labelClass = 'sr-only';
|
|
4
|
-
export let iconClass = 'w-5 h-5 text-gray-500 dark:text-gray-400';
|
|
5
|
-
export let iconDivClass = 'flex absolute inset-y-0 left-0 items-center pl-3 pointer-events-none';
|
|
6
|
-
export let inputClass = 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500';
|
|
7
|
-
export let btnClass = 'p-2.5 ml-2 text-sm font-medium text-white bg-blue-700 rounded-lg border border-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800';
|
|
8
|
-
export let placeholder = 'Search';
|
|
9
|
-
// tainted if put in component having its own background
|
|
10
|
-
let background = getContext('background');
|
|
1
|
+
<script>import Search from './Search.svelte';
|
|
2
|
+
import Button from '../buttons/Button.svelte';
|
|
11
3
|
</script>
|
|
12
4
|
|
|
13
|
-
<form class="flex
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
</div>
|
|
29
|
-
<input
|
|
30
|
-
on:blur
|
|
31
|
-
on:change
|
|
32
|
-
on:click
|
|
33
|
-
on:focus
|
|
34
|
-
on:keydown
|
|
35
|
-
on:keypress
|
|
36
|
-
on:keyup
|
|
37
|
-
on:mouseenter
|
|
38
|
-
on:mouseleave
|
|
39
|
-
on:mouseover
|
|
40
|
-
on:paste
|
|
41
|
-
{...$$restProps}
|
|
42
|
-
type="text"
|
|
43
|
-
{id}
|
|
44
|
-
class="{background
|
|
45
|
-
? 'dark:bg-gray-600 dark:border-gray-500'
|
|
46
|
-
: ' dark:bg-gray-700 dark:border-gray-600'} {inputClass}"
|
|
47
|
-
{placeholder}
|
|
48
|
-
/>
|
|
49
|
-
</div>
|
|
50
|
-
<button type="submit" class={btnClass}
|
|
51
|
-
><svg
|
|
52
|
-
class="w-5 h-5"
|
|
53
|
-
fill="none"
|
|
54
|
-
stroke="currentColor"
|
|
55
|
-
viewBox="0 0 24 24"
|
|
56
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
57
|
-
><path
|
|
58
|
-
stroke-linecap="round"
|
|
59
|
-
stroke-linejoin="round"
|
|
60
|
-
stroke-width="2"
|
|
61
|
-
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
62
|
-
/></svg
|
|
63
|
-
></button
|
|
64
|
-
>
|
|
5
|
+
<form class="flex gap-2" on:submit>
|
|
6
|
+
<Search size="md" {...$$restProps} />
|
|
7
|
+
<Button class="!p-2.5">
|
|
8
|
+
<svg
|
|
9
|
+
class="w-5 h-5"
|
|
10
|
+
fill="none"
|
|
11
|
+
stroke="currentColor"
|
|
12
|
+
viewBox="0 0 24 24"
|
|
13
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
14
|
+
><path
|
|
15
|
+
stroke-linecap="round"
|
|
16
|
+
stroke-linejoin="round"
|
|
17
|
+
stroke-width="2"
|
|
18
|
+
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" /></svg>
|
|
19
|
+
</Button>
|
|
65
20
|
</form>
|
|
@@ -2,27 +2,9 @@ import { SvelteComponentTyped } from "svelte";
|
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
4
|
[x: string]: any;
|
|
5
|
-
id?: string | undefined;
|
|
6
|
-
labelClass?: string | undefined;
|
|
7
|
-
iconClass?: string | undefined;
|
|
8
|
-
iconDivClass?: string | undefined;
|
|
9
|
-
inputClass?: string | undefined;
|
|
10
|
-
btnClass?: string | undefined;
|
|
11
|
-
placeholder?: string | undefined;
|
|
12
5
|
};
|
|
13
6
|
events: {
|
|
14
7
|
submit: SubmitEvent;
|
|
15
|
-
blur: FocusEvent;
|
|
16
|
-
change: Event;
|
|
17
|
-
click: MouseEvent;
|
|
18
|
-
focus: FocusEvent;
|
|
19
|
-
keydown: KeyboardEvent;
|
|
20
|
-
keypress: KeyboardEvent;
|
|
21
|
-
keyup: KeyboardEvent;
|
|
22
|
-
mouseenter: MouseEvent;
|
|
23
|
-
mouseleave: MouseEvent;
|
|
24
|
-
mouseover: MouseEvent;
|
|
25
|
-
paste: ClipboardEvent;
|
|
26
8
|
} & {
|
|
27
9
|
[evt: string]: CustomEvent<any>;
|
|
28
10
|
};
|