@ims360/svelte-ivory 0.1.15 → 0.2.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 +0 -5
- package/dist/components/ai/AiMessage.svelte +2 -3
- package/dist/components/ai/AiMessage.svelte.d.ts.map +1 -1
- package/dist/components/ai/Chat.svelte +2 -3
- package/dist/components/ai/Chat.svelte.d.ts.map +1 -1
- package/dist/components/ai/Markdown.svelte +4 -7
- package/dist/components/ai/Markdown.svelte.d.ts.map +1 -1
- package/dist/components/ai/UserMessage.svelte +2 -3
- package/dist/components/ai/UserMessage.svelte.d.ts.map +1 -1
- package/dist/components/basic/checkbox/Checkbox.svelte +13 -11
- package/dist/components/basic/checkbox/Checkbox.svelte.d.ts.map +1 -1
- package/dist/components/basic/toggle/Toggle.svelte +5 -8
- package/dist/components/basic/toggle/Toggle.svelte.d.ts.map +1 -1
- package/dist/components/inputs/CheckboxInput.svelte +39 -0
- package/dist/components/inputs/CheckboxInput.svelte.d.ts +12 -0
- package/dist/components/inputs/CheckboxInput.svelte.d.ts.map +1 -0
- package/dist/components/inputs/ColorInput.svelte +25 -0
- package/dist/components/inputs/ColorInput.svelte.d.ts +5 -0
- package/dist/components/inputs/ColorInput.svelte.d.ts.map +1 -0
- package/dist/components/inputs/DateInput.svelte +11 -0
- package/dist/components/inputs/DateInput.svelte.d.ts +5 -0
- package/dist/components/inputs/DateInput.svelte.d.ts.map +1 -0
- package/dist/components/inputs/EmailInput.svelte +16 -0
- package/dist/components/inputs/EmailInput.svelte.d.ts +5 -0
- package/dist/components/inputs/EmailInput.svelte.d.ts.map +1 -0
- package/dist/components/inputs/FileInput.svelte +131 -0
- package/dist/components/inputs/FileInput.svelte.d.ts +11 -0
- package/dist/components/inputs/FileInput.svelte.d.ts.map +1 -0
- package/dist/components/inputs/Input.svelte +101 -0
- package/dist/components/inputs/Input.svelte.d.ts +48 -0
- package/dist/components/inputs/Input.svelte.d.ts.map +1 -0
- package/dist/components/inputs/NumberInput.svelte +17 -0
- package/dist/components/inputs/NumberInput.svelte.d.ts +10 -0
- package/dist/components/inputs/NumberInput.svelte.d.ts.map +1 -0
- package/dist/components/inputs/PasswordCreateInput.svelte +60 -0
- package/dist/components/inputs/PasswordCreateInput.svelte.d.ts +12 -0
- package/dist/components/inputs/PasswordCreateInput.svelte.d.ts.map +1 -0
- package/dist/components/inputs/PasswordInput.svelte +27 -0
- package/dist/components/inputs/PasswordInput.svelte.d.ts +10 -0
- package/dist/components/inputs/PasswordInput.svelte.d.ts.map +1 -0
- package/dist/components/inputs/TextInput.svelte +16 -0
- package/dist/components/inputs/TextInput.svelte.d.ts +7 -0
- package/dist/components/inputs/TextInput.svelte.d.ts.map +1 -0
- package/dist/components/inputs/ToggleInput.svelte +24 -0
- package/dist/components/inputs/ToggleInput.svelte.d.ts +5 -0
- package/dist/components/inputs/ToggleInput.svelte.d.ts.map +1 -0
- package/dist/components/inputs/index.d.ts +13 -0
- package/dist/components/inputs/index.d.ts.map +1 -1
- package/dist/components/inputs/index.js +13 -0
- package/dist/components/inputs/issues/FormIssues.svelte +35 -0
- package/dist/components/inputs/issues/FormIssues.svelte.d.ts +10 -0
- package/dist/components/inputs/issues/FormIssues.svelte.d.ts.map +1 -0
- package/dist/components/inputs/select/Select.svelte +69 -0
- package/dist/components/inputs/select/Select.svelte.d.ts +15 -0
- package/dist/components/inputs/select/Select.svelte.d.ts.map +1 -0
- package/dist/components/inputs/select/SelectOption.svelte +34 -0
- package/dist/components/inputs/select/SelectOption.svelte.d.ts +11 -0
- package/dist/components/inputs/select/SelectOption.svelte.d.ts.map +1 -0
- package/dist/components/layout/Heading.svelte +5 -4
- package/dist/components/layout/Heading.svelte.d.ts.map +1 -1
- package/dist/components/layout/dialog/Dialog.svelte +5 -8
- package/dist/components/layout/dialog/Dialog.svelte.d.ts.map +1 -1
- package/dist/components/layout/drawer/Drawer.svelte +7 -10
- package/dist/components/layout/drawer/Drawer.svelte.d.ts.map +1 -1
- package/dist/components/layout/index.d.ts +1 -2
- package/dist/components/layout/index.d.ts.map +1 -1
- package/dist/components/layout/index.js +0 -1
- package/dist/components/layout/modal/Modal.svelte +10 -15
- package/dist/components/layout/modal/Modal.svelte.d.ts.map +1 -1
- package/dist/components/layout/popover/Popover.svelte +10 -13
- package/dist/components/layout/popover/Popover.svelte.d.ts.map +1 -1
- package/dist/components/layout/tabs/Tab.svelte +5 -8
- package/dist/components/layout/tabs/Tab.svelte.d.ts.map +1 -1
- package/dist/components/layout/tooltip/Tooltip.svelte +4 -7
- package/dist/components/layout/tooltip/Tooltip.svelte.d.ts.map +1 -1
- package/dist/components/table/Column.svelte +7 -10
- package/dist/components/table/Column.svelte.d.ts.map +1 -1
- package/dist/components/table/ColumnHead.svelte +2 -2
- package/dist/components/table/Table.svelte +5 -8
- package/dist/components/table/Table.svelte.d.ts.map +1 -1
- package/dist/components/table/VirtualList.svelte +3 -8
- package/dist/components/table/VirtualList.svelte.d.ts.map +1 -1
- package/dist/theme.svelte.d.ts +18 -0
- package/dist/theme.svelte.d.ts.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/{actions → attachments}/clickOutside.d.ts +2 -4
- package/dist/utils/attachments/clickOutside.d.ts.map +1 -0
- package/dist/utils/{actions → attachments}/clickOutside.js +4 -7
- package/dist/utils/attachments/focusTrap.d.ts +3 -0
- package/dist/utils/attachments/focusTrap.d.ts.map +1 -0
- package/dist/utils/{actions → attachments}/focusTrap.js +5 -14
- package/dist/utils/{actions → attachments}/index.d.ts +0 -1
- package/dist/utils/attachments/index.d.ts.map +1 -0
- package/dist/utils/{actions → attachments}/index.js +0 -1
- package/dist/utils/attachments/resize.d.ts +6 -0
- package/dist/utils/attachments/resize.d.ts.map +1 -0
- package/dist/utils/{actions → attachments}/resize.js +3 -5
- package/dist/utils/attachments/shortcut.svelte.d.ts.map +1 -0
- package/dist/utils/attachments/visible.d.ts +6 -0
- package/dist/utils/attachments/visible.d.ts.map +1 -0
- package/dist/utils/attachments/visible.js +12 -0
- package/dist/utils/merge.d.ts +4 -0
- package/dist/utils/merge.d.ts.map +1 -0
- package/dist/utils/merge.js +6 -0
- package/package.json +7 -5
- package/src/lib/components/ai/AiMessage.svelte +2 -3
- package/src/lib/components/ai/Chat.svelte +2 -3
- package/src/lib/components/ai/Markdown.svelte +4 -7
- package/src/lib/components/ai/UserMessage.svelte +2 -3
- package/src/lib/components/basic/checkbox/Checkbox.svelte +13 -11
- package/src/lib/components/basic/toggle/Toggle.svelte +5 -8
- package/src/lib/components/inputs/CheckboxInput.svelte +39 -0
- package/src/lib/components/inputs/ColorInput.svelte +25 -0
- package/src/lib/components/inputs/DateInput.svelte +11 -0
- package/src/lib/components/inputs/EmailInput.svelte +16 -0
- package/src/lib/components/inputs/FileInput.svelte +131 -0
- package/src/lib/components/inputs/Input.svelte +101 -0
- package/src/lib/components/inputs/NumberInput.svelte +17 -0
- package/src/lib/components/inputs/PasswordCreateInput.svelte +60 -0
- package/src/lib/components/inputs/PasswordInput.svelte +27 -0
- package/src/lib/components/inputs/TextInput.svelte +16 -0
- package/src/lib/components/inputs/ToggleInput.svelte +24 -0
- package/src/lib/components/inputs/index.ts +17 -0
- package/src/lib/components/inputs/issues/FormIssues.svelte +35 -0
- package/src/lib/components/inputs/select/Select.svelte +69 -0
- package/src/lib/components/inputs/select/SelectOption.svelte +34 -0
- package/src/lib/components/layout/Heading.svelte +5 -4
- package/src/lib/components/layout/dialog/Dialog.svelte +5 -8
- package/src/lib/components/layout/drawer/Drawer.svelte +7 -10
- package/src/lib/components/layout/index.ts +1 -5
- package/src/lib/components/layout/modal/Modal.svelte +10 -15
- package/src/lib/components/layout/popover/Popover.svelte +10 -13
- package/src/lib/components/layout/tabs/Tab.svelte +5 -8
- package/src/lib/components/layout/tooltip/Tooltip.svelte +4 -7
- package/src/lib/components/table/Column.svelte +7 -10
- package/src/lib/components/table/ColumnHead.svelte +2 -2
- package/src/lib/components/table/Table.svelte +5 -8
- package/src/lib/components/table/VirtualList.svelte +3 -8
- package/src/lib/theme.svelte.ts +18 -0
- package/src/lib/types.ts +3 -2
- package/src/lib/utils/attachments/clickOutside.ts +36 -0
- package/src/lib/utils/attachments/focusTrap.ts +67 -0
- package/src/lib/utils/{actions → attachments}/index.ts +0 -1
- package/src/lib/utils/attachments/resize.ts +38 -0
- package/src/lib/utils/attachments/visible.ts +22 -0
- package/src/lib/utils/merge.ts +7 -0
- package/dist/components/layout/portal/Portal.svelte +0 -39
- package/dist/components/layout/portal/Portal.svelte.d.ts +0 -21
- package/dist/components/layout/portal/Portal.svelte.d.ts.map +0 -1
- package/dist/components/layout/portal/index.d.ts +0 -6
- package/dist/components/layout/portal/index.d.ts.map +0 -1
- package/dist/components/layout/portal/index.js +0 -5
- package/dist/utils/actions/clickOutside.d.ts.map +0 -1
- package/dist/utils/actions/focusTrap.d.ts +0 -5
- package/dist/utils/actions/focusTrap.d.ts.map +0 -1
- package/dist/utils/actions/index.d.ts.map +0 -1
- package/dist/utils/actions/portal.d.ts +0 -10
- package/dist/utils/actions/portal.d.ts.map +0 -1
- package/dist/utils/actions/portal.js +0 -39
- package/dist/utils/actions/resize.d.ts +0 -6
- package/dist/utils/actions/resize.d.ts.map +0 -1
- package/dist/utils/actions/shortcut.svelte.d.ts.map +0 -1
- package/dist/utils/actions/visible.d.ts +0 -6
- package/dist/utils/actions/visible.d.ts.map +0 -1
- package/dist/utils/actions/visible.js +0 -14
- package/src/lib/components/layout/portal/Portal.svelte +0 -39
- package/src/lib/components/layout/portal/index.ts +0 -7
- package/src/lib/utils/actions/clickOutside.ts +0 -38
- package/src/lib/utils/actions/focusTrap.ts +0 -65
- package/src/lib/utils/actions/portal.ts +0 -43
- package/src/lib/utils/actions/resize.ts +0 -35
- package/src/lib/utils/actions/visible.ts +0 -28
- /package/dist/utils/{actions → attachments}/shortcut.svelte.d.ts +0 -0
- /package/dist/utils/{actions → attachments}/shortcut.svelte.js +0 -0
- /package/src/lib/utils/{actions → attachments}/shortcut.svelte.ts +0 -0
package/README.md
CHANGED
|
@@ -20,8 +20,3 @@ _You may need to adjust the path if your `app.css` is not located in `/src`_
|
|
|
20
20
|
- [x] Basic layout components (modal, tabs, popover, etc.)
|
|
21
21
|
- [x] Table
|
|
22
22
|
- [ ] Input components
|
|
23
|
-
|
|
24
|
-
## TODOs
|
|
25
|
-
|
|
26
|
-
- [ ] Bindings to exported functions
|
|
27
|
-
- [ ] Replace `<Portal>` with `<dialog>` element in Modal, Popover and Drawer
|
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
-->
|
|
6
6
|
|
|
7
7
|
<script lang="ts">
|
|
8
|
+
import { merge } from '../../utils/merge';
|
|
8
9
|
import { ThumbsDown, ThumbsUp } from '@lucide/svelte';
|
|
9
|
-
import clsx from 'clsx';
|
|
10
10
|
import type { Snippet } from 'svelte';
|
|
11
11
|
import type { ClassValue } from 'svelte/elements';
|
|
12
|
-
import { twMerge } from 'tailwind-merge';
|
|
13
12
|
import CopyToClipboardButton from '../buttons/CopyToClipboardButton.svelte';
|
|
14
13
|
import type { AiChatMessage } from './Chat.svelte';
|
|
15
14
|
import Markdown from './Markdown.svelte';
|
|
@@ -48,7 +47,7 @@
|
|
|
48
47
|
</script>
|
|
49
48
|
|
|
50
49
|
<div
|
|
51
|
-
class={
|
|
50
|
+
class={merge('group flex w-full flex-col items-start', clazz)}
|
|
52
51
|
style={minHeight ? `min-height: ${minHeight}px;` : undefined}
|
|
53
52
|
>
|
|
54
53
|
{@render messageText({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiMessage.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/AiMessage.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"AiMessage.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/AiMessage.svelte.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI/C,UAAU,KAAK;IACX,SAAS,EAAE,aAAa,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC,CAAC;IACpD,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAsFL;;;GAGG;AACH,QAAA,MAAM,SAAS,oDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
|
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
-->
|
|
7
7
|
|
|
8
8
|
<script lang="ts" module>
|
|
9
|
-
import
|
|
9
|
+
import { merge } from '../../utils/merge';
|
|
10
10
|
import { tick, type Snippet } from 'svelte';
|
|
11
11
|
import type { ClassValue } from 'svelte/elements';
|
|
12
|
-
import { twMerge } from 'tailwind-merge';
|
|
13
12
|
import AiMessage from './AiMessage.svelte';
|
|
14
13
|
import UserMessage from './UserMessage.svelte';
|
|
15
14
|
|
|
@@ -101,7 +100,7 @@
|
|
|
101
100
|
}
|
|
102
101
|
</script>
|
|
103
102
|
|
|
104
|
-
<div class={
|
|
103
|
+
<div class={merge('flex grow flex-col gap-2 overflow-hidden', clazz)}>
|
|
105
104
|
<div
|
|
106
105
|
class="flex grow flex-col gap-4 overflow-auto pr-2 [scrollbar-gutter:stable]"
|
|
107
106
|
bind:this={chatContainer}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/Chat.svelte.ts"],"names":[],"mappings":"AAII,OAAO,EAAQ,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Chat.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/Chat.svelte.ts"],"names":[],"mappings":"AAII,OAAO,EAAQ,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIlD,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,MAAM;IACnB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,KAAK;IACX,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAC/D,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IACrF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC,CAAC;QAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC,CAAC,CAAC;IAC7E,MAAM,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAqHL;;;;GAIG;AACH,QAAA,MAAM,IAAI;;YAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
|
|
@@ -5,11 +5,10 @@
|
|
|
5
5
|
-->
|
|
6
6
|
|
|
7
7
|
<script lang="ts">
|
|
8
|
-
import
|
|
8
|
+
import { merge } from '../../utils/merge';
|
|
9
9
|
import DomPurify from 'dompurify';
|
|
10
10
|
import { marked } from 'marked';
|
|
11
11
|
import type { ClassValue } from 'svelte/elements';
|
|
12
|
-
import { twMerge } from 'tailwind-merge';
|
|
13
12
|
|
|
14
13
|
interface Props {
|
|
15
14
|
source: string;
|
|
@@ -44,11 +43,9 @@
|
|
|
44
43
|
</script>
|
|
45
44
|
|
|
46
45
|
<div
|
|
47
|
-
class={
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
clazz
|
|
51
|
-
)
|
|
46
|
+
class={merge(
|
|
47
|
+
'text-surface-950-50 prose prose-strong:text-surface-950-50 prose-p:my-1 flex flex-col items-start gap-1',
|
|
48
|
+
clazz
|
|
52
49
|
)}
|
|
53
50
|
>
|
|
54
51
|
{#await html then html}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/Markdown.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Markdown.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/Markdown.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG9C,UAAU,KAAK;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,eAAe,EAAE,MAAM,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;KAC3F,CAAC;CACL;AA8CL;;;GAGG;AACH,QAAA,MAAM,QAAQ,2CAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import { merge } from '../../utils/merge';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import type { ClassValue } from 'svelte/elements';
|
|
5
|
-
import { twMerge } from 'tailwind-merge';
|
|
6
5
|
import AttachedFile from './AttachedFile.svelte';
|
|
7
6
|
import type { AiChatMessage } from './Chat.svelte';
|
|
8
7
|
import Markdown from './Markdown.svelte';
|
|
@@ -24,7 +23,7 @@
|
|
|
24
23
|
}: Props = $props();
|
|
25
24
|
</script>
|
|
26
25
|
|
|
27
|
-
<div class={
|
|
26
|
+
<div class={merge('flex w-full flex-col items-end gap-1', clazz)}>
|
|
28
27
|
{@render messageText({ message })}
|
|
29
28
|
{#if message.files}
|
|
30
29
|
<div class="flex flex-row items-center gap-2">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserMessage.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/UserMessage.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"UserMessage.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ai/UserMessage.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI/C,UAAU,KAAK;IACX,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;IACvB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACrC,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;QAAE,OAAO,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC,CAAC;CACvD;AAgDL,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
+
import { theme } from '../../../theme.svelte';
|
|
2
3
|
import type { IvoryComponent } from '../../../types';
|
|
4
|
+
import { merge } from '../../../utils/merge';
|
|
3
5
|
import { Check, type Icon as LucideIcon, Minus } from '@lucide/svelte';
|
|
4
6
|
import clsx from 'clsx';
|
|
5
7
|
import type { ClassValue } from 'svelte/elements';
|
|
6
8
|
import { scale } from 'svelte/transition';
|
|
7
|
-
import { twMerge } from 'tailwind-merge';
|
|
8
9
|
|
|
9
10
|
export interface CheckboxProps extends IvoryComponent<HTMLElement> {
|
|
10
11
|
class?: ClassValue;
|
|
@@ -40,16 +41,19 @@
|
|
|
40
41
|
innerClass,
|
|
41
42
|
style
|
|
42
43
|
}: { icon?: typeof LucideIcon; innerClass?: string; style?: string } = $derived.by(() => {
|
|
43
|
-
|
|
44
|
+
const overwrittenClass =
|
|
45
|
+
theme.current.checkbox?.class &&
|
|
46
|
+
clsx(theme.current.checkbox?.class?.(!!checked, !!partial));
|
|
47
|
+
if (!checked && !partial) return { innerClass: overwrittenClass ?? 'border-surface-500' };
|
|
44
48
|
if (checked)
|
|
45
49
|
return {
|
|
46
50
|
icon: Check,
|
|
47
|
-
innerClass: 'bg-primary-500 border-primary-500 text-surface-50'
|
|
51
|
+
innerClass: overwrittenClass ?? 'bg-primary-500 border-primary-500 text-surface-50'
|
|
48
52
|
};
|
|
49
53
|
if (partial)
|
|
50
54
|
return {
|
|
51
55
|
icon: Minus,
|
|
52
|
-
innerClass: 'border-primary-700 text-primary-500'
|
|
56
|
+
innerClass: overwrittenClass ?? 'border-primary-700 text-primary-500'
|
|
53
57
|
};
|
|
54
58
|
return {};
|
|
55
59
|
});
|
|
@@ -62,13 +66,11 @@
|
|
|
62
66
|
{disabled}
|
|
63
67
|
{style}
|
|
64
68
|
{onclick}
|
|
65
|
-
class={
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
clazz
|
|
71
|
-
)
|
|
69
|
+
class={merge(
|
|
70
|
+
'box-border flex h-5 w-5 items-center justify-center overflow-hidden rounded border-2 transition-colors',
|
|
71
|
+
disabled && 'cursor-not-allowed opacity-70',
|
|
72
|
+
innerClass,
|
|
73
|
+
clazz
|
|
72
74
|
)}
|
|
73
75
|
{...rest}
|
|
74
76
|
>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/basic/checkbox/Checkbox.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Checkbox.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/basic/checkbox/Checkbox.svelte.ts"],"names":[],"mappings":"AAII,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC9D,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAuDL,sBAAsB;AACtB,QAAA,MAAM,QAAQ,mDAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import type { IvoryComponent } from '../../../types';
|
|
3
|
-
import
|
|
3
|
+
import { merge } from '../../../utils/merge';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
import type { ClassValue } from 'svelte/elements';
|
|
6
|
-
import { twMerge } from 'tailwind-merge';
|
|
7
6
|
|
|
8
7
|
export interface ToggleProps extends IvoryComponent<HTMLElement> {
|
|
9
8
|
value?: boolean;
|
|
@@ -18,12 +17,10 @@
|
|
|
18
17
|
|
|
19
18
|
<svelte:element
|
|
20
19
|
this={rest.onclick ? 'button' : 'div'}
|
|
21
|
-
class={
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
clazz
|
|
26
|
-
)
|
|
20
|
+
class={merge(
|
|
21
|
+
'group relative flex h-5 w-9 flex-row items-center rounded-full p-0.5 transition-colors duration-100',
|
|
22
|
+
value ? 'bg-primary-500' : 'bg-surface-300-700',
|
|
23
|
+
clazz
|
|
27
24
|
)}
|
|
28
25
|
type={rest.onclick ? 'button' : undefined}
|
|
29
26
|
role={rest.onclick ? 'button' : undefined}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toggle.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/basic/toggle/Toggle.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Toggle.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/basic/toggle/Toggle.svelte.ts"],"names":[],"mappings":"AAGI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC5D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AA8BL,QAAA,MAAM,MAAM,iDAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ClassValue } from 'svelte/elements';
|
|
3
|
+
import { Checkbox } from '../basic';
|
|
4
|
+
import type { InputProps } from './Input.svelte';
|
|
5
|
+
import FormIssues from './issues/FormIssues.svelte';
|
|
6
|
+
|
|
7
|
+
interface Props extends InputProps<boolean> {
|
|
8
|
+
class?: ClassValue;
|
|
9
|
+
label: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
onclick?: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let { class: clazz = '', label, description, onclick, disabled, form }: Props = $props();
|
|
15
|
+
|
|
16
|
+
const { set, issues, value } = $derived(form);
|
|
17
|
+
|
|
18
|
+
const checked = $derived(value());
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<div class={['flex flex-col', clazz]}>
|
|
22
|
+
<button
|
|
23
|
+
type="button"
|
|
24
|
+
{disabled}
|
|
25
|
+
onclick={onclick ||
|
|
26
|
+
(() => {
|
|
27
|
+
set(!checked);
|
|
28
|
+
})}
|
|
29
|
+
class={['flex flex-row items-center gap-2', disabled && 'opacity-80']}
|
|
30
|
+
>
|
|
31
|
+
<Checkbox {checked} />
|
|
32
|
+
{label}
|
|
33
|
+
</button>
|
|
34
|
+
<input class="hidden" {...form.as('checkbox')} {checked} />
|
|
35
|
+
{#if description}
|
|
36
|
+
<p class="text-surface-700-300">{description}</p>
|
|
37
|
+
{/if}
|
|
38
|
+
<FormIssues issues={issues?.()} />
|
|
39
|
+
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ClassValue } from 'svelte/elements';
|
|
2
|
+
import type { InputProps } from './Input.svelte';
|
|
3
|
+
interface Props extends InputProps<boolean> {
|
|
4
|
+
class?: ClassValue;
|
|
5
|
+
label: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
onclick?: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare const CheckboxInput: import("svelte").Component<Props, {}, "">;
|
|
10
|
+
type CheckboxInput = ReturnType<typeof CheckboxInput>;
|
|
11
|
+
export default CheckboxInput;
|
|
12
|
+
//# sourceMappingURL=CheckboxInput.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxInput.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/inputs/CheckboxInput.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI7C,UAAU,KAAM,SAAQ,UAAU,CAAC,OAAO,CAAC;IACvC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAgCL,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { merge } from '../../utils/merge';
|
|
3
|
+
import Input, { INPUT_UNSET_OUTLINE, type InputProps } from './Input.svelte';
|
|
4
|
+
|
|
5
|
+
let props: InputProps<string> = $props();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<Input {...props}>
|
|
9
|
+
{#snippet children({ id, class: inputClass })}
|
|
10
|
+
<div
|
|
11
|
+
class={merge([inputClass, 'flex grow flex-row items-center justify-between gap-4 p-0'])}
|
|
12
|
+
>
|
|
13
|
+
<input
|
|
14
|
+
type="text"
|
|
15
|
+
bind:value={props.form.value, props.form.set}
|
|
16
|
+
class={['flex h-full grow items-center bg-transparent pl-2', INPUT_UNSET_OUTLINE]}
|
|
17
|
+
/>
|
|
18
|
+
<input
|
|
19
|
+
class={['h-full rounded', INPUT_UNSET_OUTLINE]}
|
|
20
|
+
{id}
|
|
21
|
+
{...props.form.as('color')}
|
|
22
|
+
/>
|
|
23
|
+
</div>
|
|
24
|
+
{/snippet}
|
|
25
|
+
</Input>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorInput.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/inputs/ColorInput.svelte.ts"],"names":[],"mappings":"AAIA,OAAc,EAAuB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAoB7E,QAAA,MAAM,UAAU,wDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Input, { type InputProps } from './Input.svelte';
|
|
3
|
+
|
|
4
|
+
let props: InputProps<string> = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<Input {...props}>
|
|
8
|
+
{#snippet children(inputProps)}
|
|
9
|
+
<input {...inputProps} {...props.form.as?.('date')} />
|
|
10
|
+
{/snippet}
|
|
11
|
+
</Input>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateInput.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/inputs/DateInput.svelte.ts"],"names":[],"mappings":"AAGA,OAAc,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAgBxD,QAAA,MAAM,SAAS,wDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Input, { type InputProps } from './Input.svelte';
|
|
3
|
+
|
|
4
|
+
let props: InputProps<string> = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<Input {...props}>
|
|
8
|
+
{#snippet children(inputProps)}
|
|
9
|
+
<input
|
|
10
|
+
{...inputProps}
|
|
11
|
+
{...props.form.as?.('email')}
|
|
12
|
+
autocomplete="email"
|
|
13
|
+
autocapitalize="off"
|
|
14
|
+
/>
|
|
15
|
+
{/snippet}
|
|
16
|
+
</Input>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailInput.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/inputs/EmailInput.svelte.ts"],"names":[],"mappings":"AAGA,OAAc,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAgBxD,QAAA,MAAM,UAAU,wDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { FileUp, X } from '@lucide/svelte';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import type { InputProps } from './Input.svelte';
|
|
5
|
+
import Input from './Input.svelte';
|
|
6
|
+
|
|
7
|
+
export interface FileInputProps extends InputProps<File[] | File> {
|
|
8
|
+
accept?: string[];
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
multiple?: boolean;
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
let { accept, children: passedChildren, multiple = false, ...rest }: FileInputProps = $props();
|
|
16
|
+
|
|
17
|
+
let hovering = $state(false);
|
|
18
|
+
|
|
19
|
+
function onDrop(
|
|
20
|
+
event: DragEvent & {
|
|
21
|
+
currentTarget: EventTarget & HTMLElement;
|
|
22
|
+
}
|
|
23
|
+
) {
|
|
24
|
+
add(event.dataTransfer?.files ? Array.from(event.dataTransfer.files) : []);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function add(files: File[]) {
|
|
28
|
+
const value = rest.form.value();
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
rest.form.set([...value.filter((f) => !files.includes(f)), ...Array.from(files || [])]);
|
|
31
|
+
} else {
|
|
32
|
+
rest.form.set((files[0] ?? undefined) as File);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function remove(file: File) {
|
|
37
|
+
const value = rest.form.value();
|
|
38
|
+
if (Array.isArray(value)) {
|
|
39
|
+
rest.form.set(value.filter((e) => e !== file));
|
|
40
|
+
} else {
|
|
41
|
+
rest.form.set(undefined as unknown as File);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const files = $derived.by(() => {
|
|
46
|
+
const value = rest.form.value();
|
|
47
|
+
if (Array.isArray(value)) {
|
|
48
|
+
return value;
|
|
49
|
+
} else {
|
|
50
|
+
return value ? [value] : [];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const formAttributes = $derived(rest.form.as(multiple ? 'file multiple' : 'file'));
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<Input {...rest} fixTitle>
|
|
58
|
+
{#snippet children({ id })}
|
|
59
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
60
|
+
<div
|
|
61
|
+
class={[
|
|
62
|
+
'group relative h-full min-h-16 w-full rounded transition-all',
|
|
63
|
+
hovering ? 'bg-primary-50-950' : ''
|
|
64
|
+
]}
|
|
65
|
+
ondragover={() => {
|
|
66
|
+
hovering = true;
|
|
67
|
+
}}
|
|
68
|
+
ondragleave={() => {
|
|
69
|
+
hovering = false;
|
|
70
|
+
}}
|
|
71
|
+
ondrop={(e) => {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
e.stopPropagation();
|
|
74
|
+
hovering = false;
|
|
75
|
+
onDrop(e);
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
{#if passedChildren}
|
|
79
|
+
{@render passedChildren()}
|
|
80
|
+
{:else}
|
|
81
|
+
<div class="flex h-full w-full flex-col items-center justify-center gap-2 p-4">
|
|
82
|
+
{#if files && files.length > 0}
|
|
83
|
+
<div class="flex flex-row items-center gap-4">
|
|
84
|
+
{#each files as file (file)}
|
|
85
|
+
{@render fileRender(file)}
|
|
86
|
+
{/each}
|
|
87
|
+
</div>
|
|
88
|
+
{:else}
|
|
89
|
+
<div
|
|
90
|
+
class="text-primary-200-800 group-hover:text-primary-300-700 group-hover:bg-primary-100-900 flex h-14 w-14 shrink-0 items-center justify-center rounded-full text-xl transition-colors"
|
|
91
|
+
>
|
|
92
|
+
<FileUp />
|
|
93
|
+
</div>
|
|
94
|
+
{/if}
|
|
95
|
+
</div>
|
|
96
|
+
{/if}
|
|
97
|
+
<input
|
|
98
|
+
type={formAttributes.type}
|
|
99
|
+
aria-invalid={formAttributes['aria-invalid']}
|
|
100
|
+
name={formAttributes.name}
|
|
101
|
+
oninput={(e) => {
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
e.stopPropagation();
|
|
104
|
+
add(e.currentTarget.files ? Array.from(e.currentTarget.files) : []);
|
|
105
|
+
}}
|
|
106
|
+
{multiple}
|
|
107
|
+
title=""
|
|
108
|
+
accept={accept?.join(', ')}
|
|
109
|
+
class="absolute top-0 left-0 h-full w-full grow cursor-pointer opacity-0"
|
|
110
|
+
{id}
|
|
111
|
+
/>
|
|
112
|
+
</div>
|
|
113
|
+
{/snippet}
|
|
114
|
+
</Input>
|
|
115
|
+
|
|
116
|
+
{#snippet fileRender(file: File)}
|
|
117
|
+
<div class="bg-primary-200-800 flex w-fit items-center rounded-full py-2 pr-2 pl-4">
|
|
118
|
+
<p>{file.name}</p>
|
|
119
|
+
<button
|
|
120
|
+
type="button"
|
|
121
|
+
class="btn-icon hover:text-primary-500"
|
|
122
|
+
onclick={(e) => {
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
e.stopPropagation();
|
|
125
|
+
remove(file);
|
|
126
|
+
}}
|
|
127
|
+
>
|
|
128
|
+
<X />
|
|
129
|
+
</button>
|
|
130
|
+
</div>
|
|
131
|
+
{/snippet}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { InputProps } from './Input.svelte';
|
|
3
|
+
export interface FileInputProps extends InputProps<File[] | File> {
|
|
4
|
+
accept?: string[];
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
multiple?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const FileInput: import("svelte").Component<FileInputProps, {}, "">;
|
|
9
|
+
type FileInput = ReturnType<typeof FileInput>;
|
|
10
|
+
export default FileInput;
|
|
11
|
+
//# sourceMappingURL=FileInput.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileInput.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/inputs/FileInput.svelte.ts"],"names":[],"mappings":"AAII,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,MAAM,WAAW,cAAe,SAAQ,UAAU,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC;IAC7D,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAwGL,QAAA,MAAM,SAAS,oDAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { theme } from '../../theme.svelte';
|
|
3
|
+
import { pseudoRandomId } from '../../utils/functions';
|
|
4
|
+
import { merge } from '../../utils/merge';
|
|
5
|
+
import type { RemoteFormField, RemoteFormFieldValue } from '@sveltejs/kit';
|
|
6
|
+
import type { Snippet } from 'svelte';
|
|
7
|
+
import type { ClassValue } from 'svelte/elements';
|
|
8
|
+
import { slide } from 'svelte/transition';
|
|
9
|
+
import FormIssues from './issues/FormIssues.svelte';
|
|
10
|
+
|
|
11
|
+
interface CommonProps {
|
|
12
|
+
id?: string;
|
|
13
|
+
class?: ClassValue;
|
|
14
|
+
style?: string;
|
|
15
|
+
label?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface InputProps<T extends RemoteFormFieldValue> extends CommonProps {
|
|
20
|
+
form: RemoteFormField<T>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const INPUT_UNSET_OUTLINE =
|
|
24
|
+
'border-none outline-none ring-transparent focus:outline-none';
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script lang="ts" generics="T extends RemoteFormFieldValue">
|
|
28
|
+
interface Props<K extends RemoteFormFieldValue> extends CommonProps {
|
|
29
|
+
children: Snippet<[{ class: string; id: string; disabled?: boolean }]>;
|
|
30
|
+
fixTitle?: boolean;
|
|
31
|
+
form: Pick<RemoteFormField<K>, 'value' | 'issues'>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let {
|
|
35
|
+
class: clazz,
|
|
36
|
+
style,
|
|
37
|
+
label,
|
|
38
|
+
id = pseudoRandomId(),
|
|
39
|
+
children,
|
|
40
|
+
form,
|
|
41
|
+
fixTitle,
|
|
42
|
+
...inputProps
|
|
43
|
+
}: Props<T> = $props();
|
|
44
|
+
|
|
45
|
+
const inputClass = `bg-transparent grow h-14 transition-all peer m-[1px] px-4 py-3 text-lg ${INPUT_UNSET_OUTLINE}`;
|
|
46
|
+
|
|
47
|
+
const hasIssues = $derived.by(() => {
|
|
48
|
+
const i = form.issues?.();
|
|
49
|
+
return i && i.length > 0;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const hasValue = $derived(!!fixTitle || !!form.value?.());
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<div
|
|
56
|
+
class={[
|
|
57
|
+
'accent-primary-500 relative flex h-fit flex-col pt-5',
|
|
58
|
+
inputProps.disabled && 'pointer-events-none opacity-70',
|
|
59
|
+
theme.current.input?.outerClass,
|
|
60
|
+
clazz
|
|
61
|
+
]}
|
|
62
|
+
{style}
|
|
63
|
+
>
|
|
64
|
+
<div
|
|
65
|
+
class={merge(
|
|
66
|
+
'group flex h-full grow flex-col overflow-hidden rounded border-2',
|
|
67
|
+
hasIssues
|
|
68
|
+
? 'bg-error-500/20 border-error-500'
|
|
69
|
+
: 'focus-within:border-primary-500 focus-within:hover:border-primary-500 border-surface-300-700/25 hover:border-surface-300-700/50 transition-[border-color] duration-300',
|
|
70
|
+
theme.current.input?.class?.(hasValue, hasIssues)
|
|
71
|
+
)}
|
|
72
|
+
>
|
|
73
|
+
{@render children({ class: inputClass, id, ...inputProps })}
|
|
74
|
+
{#if label}
|
|
75
|
+
<label
|
|
76
|
+
class={merge([
|
|
77
|
+
'pointer-events-none absolute cursor-text px-1 transition-all select-none group-focus-within:top-0 group-focus-within:left-0 group-focus-within:text-sm focus:cursor-default',
|
|
78
|
+
hasValue ? 'top-0 left-0 cursor-default text-sm' : 'top-10 left-3',
|
|
79
|
+
hasIssues ? 'text-error-500' : 'text-surface-700-300',
|
|
80
|
+
theme.current.input?.label?.class?.(hasValue, hasIssues)
|
|
81
|
+
])}
|
|
82
|
+
for={id}
|
|
83
|
+
>
|
|
84
|
+
{label}
|
|
85
|
+
</label>
|
|
86
|
+
{/if}
|
|
87
|
+
</div>
|
|
88
|
+
{#if form.issues?.()}
|
|
89
|
+
<div class="h-fit w-full">
|
|
90
|
+
<div
|
|
91
|
+
class={merge(
|
|
92
|
+
'flex w-full flex-col overflow-hidden',
|
|
93
|
+
theme.current.input?.issues?.class
|
|
94
|
+
)}
|
|
95
|
+
transition:slide
|
|
96
|
+
>
|
|
97
|
+
<FormIssues issues={form.issues?.()} class="my-0.5 pr-2 first:mt-1 last:mb-1" />
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
{/if}
|
|
101
|
+
</div>
|