@webamoki/web-svelte 1.2.3 → 2.0.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/README.md +3 -1
- package/dist/components/showcase/CodeBlock.svelte +1 -1
- package/dist/{components → shared/components}/form/Button.svelte +2 -2
- package/dist/{components → shared/components}/form/Button.svelte.d.ts +2 -2
- package/dist/{components → shared/components}/form/Errors.svelte +1 -1
- package/dist/{components → shared/components}/form/FieldWrapper.svelte +1 -1
- package/dist/{components → shared/components}/form/fields/ChoiceMultiField.svelte +3 -1
- package/dist/{components → shared/components}/form/fields/DateField.svelte +2 -2
- package/dist/{components → shared/components}/form/fields/MessageField.svelte +2 -2
- package/dist/{components → shared/components}/form/fields/NumberField.svelte +2 -2
- package/dist/{components → shared/components}/form/fields/PasswordField.svelte +2 -2
- package/dist/{components → shared/components}/form/fields/SelectField.svelte +3 -3
- package/dist/{components → shared/components}/form/fields/SelectMultiField.svelte +3 -3
- package/dist/{components → shared/components}/form/fields/TextField.svelte +2 -2
- package/dist/{components → shared/components}/form/fields/TextFieldNullable.svelte +2 -2
- package/dist/{components → shared/components}/form/fields/TimeField.svelte +2 -2
- package/dist/{components → shared/components}/ui/choice/ChoiceInternal.svelte +1 -1
- package/dist/{components → shared/components}/ui/choice/WeekdayChoice.svelte +6 -3
- package/dist/{components → shared/components}/ui/choice/WeekdayChoice.svelte.d.ts +1 -1
- package/dist/{components → shared/components}/ui/choice/WeekdayChoiceMulti.svelte +6 -3
- package/dist/{components → shared/components}/ui/choice/WeekdayChoiceMulti.svelte.d.ts +1 -1
- package/dist/{components → shared/components}/ui/context-menu/ContextMenuContent.svelte +1 -1
- package/dist/{components → shared/components}/ui/context-menu/ContextMenuItem.svelte +1 -1
- package/dist/{components → shared/components}/ui/search/SearchBar.svelte +2 -2
- package/dist/{utils/types → shared/utils}/arktype.d.ts +4 -12
- package/dist/shared/utils/arktype.js +40 -0
- package/dist/{utils → shared/utils}/datetime/datetime.spec.js +31 -18
- package/dist/{utils → shared/utils}/datetime/index.d.ts +22 -14
- package/dist/{utils → shared/utils}/datetime/index.js +44 -32
- package/dist/{utils → shared/utils}/email/README.md +5 -5
- package/dist/{utils → shared/utils}/email/ses.js +17 -9
- package/dist/shared/utils/functional/index.d.ts +2 -0
- package/dist/shared/utils/functional/index.js +2 -0
- package/dist/shared/utils/functional/result.d.ts +72 -0
- package/dist/shared/utils/functional/result.js +86 -0
- package/dist/shared/utils/functional/result.spec.d.ts +1 -0
- package/dist/shared/utils/functional/result.spec.js +96 -0
- package/dist/shared/utils/remote.d.ts +28 -0
- package/dist/shared/utils/remote.js +74 -0
- package/dist/{utils/search.d.ts → shared/utils/string.d.ts} +1 -0
- package/dist/{utils/search.js → shared/utils/string.js} +13 -4
- package/package.json +27 -30
- package/dist/utils/email/aws-signer.d.ts +0 -17
- package/dist/utils/email/aws-signer.js +0 -83
- package/dist/utils/string.d.ts +0 -1
- package/dist/utils/string.js +0 -4
- package/dist/utils/types/arktype.js +0 -92
- package/dist/utils/types/consts.d.ts +0 -5
- package/dist/utils/types/consts.js +0 -5
- package/dist/utils/types/db.d.ts +0 -57
- package/dist/utils/types/db.js +0 -34
- /package/dist/{components → shared/components}/form/Errors.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/FieldWrapper.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/Form.svelte +0 -0
- /package/dist/{components → shared/components}/form/Form.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/IconInputWrapper.svelte +0 -0
- /package/dist/{components → shared/components}/form/IconInputWrapper.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/ChoiceField.svelte +0 -0
- /package/dist/{components → shared/components}/form/fields/ChoiceField.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/ChoiceMultiField.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/DateField.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/HexColorField.svelte +0 -0
- /package/dist/{components → shared/components}/form/fields/HexColorField.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/MessageField.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/NumberField.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/PasswordField.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/SelectField.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/SelectMultiField.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/TextField.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/TextFieldNullable.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/TimeField.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/WeekdayChoiceField.svelte +0 -0
- /package/dist/{components → shared/components}/form/fields/WeekdayChoiceField.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/fields/WeekdayChoiceMultiField.svelte +0 -0
- /package/dist/{components → shared/components}/form/fields/WeekdayChoiceMultiField.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/form/index.d.ts +0 -0
- /package/dist/{components → shared/components}/form/index.js +0 -0
- /package/dist/{components → shared/components}/ui/choice/Choice.svelte +0 -0
- /package/dist/{components → shared/components}/ui/choice/Choice.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/ui/choice/ChoiceInternal.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/ui/choice/ChoiceMulti.svelte +0 -0
- /package/dist/{components → shared/components}/ui/choice/ChoiceMulti.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/ui/context-menu/ContextMenu.svelte +0 -0
- /package/dist/{components → shared/components}/ui/context-menu/ContextMenu.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/ui/context-menu/ContextMenuContent.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/ui/context-menu/ContextMenuItem.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/ui/context-menu/ContextMenuSeparator.svelte +0 -0
- /package/dist/{components → shared/components}/ui/context-menu/ContextMenuSeparator.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/ui/context-menu/ContextMenuTrigger.svelte +0 -0
- /package/dist/{components → shared/components}/ui/context-menu/ContextMenuTrigger.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/ui/context-menu/context-menu-state.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/ui/context-menu/context-menu-state.svelte.js +0 -0
- /package/dist/{components → shared/components}/ui/drag-drop/Draggable.svelte +0 -0
- /package/dist/{components → shared/components}/ui/drag-drop/Draggable.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/ui/drag-drop/Dropzone.svelte +0 -0
- /package/dist/{components → shared/components}/ui/drag-drop/Dropzone.svelte.d.ts +0 -0
- /package/dist/{components → shared/components}/ui/drag-drop/drag-manager.d.ts +0 -0
- /package/dist/{components → shared/components}/ui/drag-drop/drag-manager.js +0 -0
- /package/dist/{components → shared/components}/ui/index.d.ts +0 -0
- /package/dist/{components → shared/components}/ui/index.js +0 -0
- /package/dist/{components → shared/components}/ui/search/SearchBar.svelte.d.ts +0 -0
- /package/dist/{server → shared/server}/form-handler.d.ts +0 -0
- /package/dist/{server → shared/server}/form-handler.js +0 -0
- /package/dist/{server → shared/server}/form-processor.d.ts +0 -0
- /package/dist/{server → shared/server}/form-processor.js +0 -0
- /package/dist/{utils → shared/utils}/datetime/datetime.spec.d.ts +0 -0
- /package/dist/{utils → shared/utils}/email/index.d.ts +0 -0
- /package/dist/{utils → shared/utils}/email/index.js +0 -0
- /package/dist/{utils → shared/utils}/email/ses.d.ts +0 -0
- /package/dist/{utils → shared/utils}/email/ses.test.d.ts +0 -0
- /package/dist/{utils → shared/utils}/email/ses.test.js +0 -0
- /package/dist/{utils → shared/utils}/form/index.d.ts +0 -0
- /package/dist/{utils → shared/utils}/form/index.js +0 -0
- /package/dist/{utils → shared/utils}/form/virtual-form.d.ts +0 -0
- /package/dist/{utils → shared/utils}/form/virtual-form.js +0 -0
- /package/dist/{highlight.d.ts → utils/highlight.d.ts} +0 -0
- /package/dist/{highlight.js → utils/highlight.js} +0 -0
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ pnpm dev
|
|
|
73
73
|
|
|
74
74
|
---
|
|
75
75
|
|
|
76
|
-
## Versioning & Releases
|
|
76
|
+
## 🔖 Versioning & Releases
|
|
77
77
|
|
|
78
78
|
We use **Semantic Versioning** managed automatically by `semantic-release`.
|
|
79
79
|
|
|
@@ -121,6 +121,8 @@ ci: blah // No versioning - not standard
|
|
|
121
121
|
|
|
122
122
|
### Breaking Changes
|
|
123
123
|
|
|
124
|
+
Commits with a breaking change automatically trigger a `major` version bump.
|
|
125
|
+
|
|
124
126
|
For breaking changes, you must append `!` before the colon in the commit header as such:
|
|
125
127
|
|
|
126
128
|
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { ButtonProps } from '
|
|
2
|
+
import type { ButtonProps } from '../../../shadcn/components/ui/button/index.js';
|
|
3
3
|
|
|
4
|
-
import { Button } from '
|
|
4
|
+
import { Button } from '../../../shadcn/components/ui/button/index.js';
|
|
5
5
|
import Loader2Icon from '@lucide/svelte/icons/loader-2';
|
|
6
6
|
|
|
7
7
|
type Props = ButtonProps & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ButtonProps } from '
|
|
2
|
-
import { Button } from '
|
|
1
|
+
import type { ButtonProps } from '../../../shadcn/components/ui/button/index.js';
|
|
2
|
+
import { Button } from '../../../shadcn/components/ui/button/index.js';
|
|
3
3
|
type Props = ButtonProps & {
|
|
4
4
|
class?: string;
|
|
5
5
|
loading?: boolean;
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
19
19
|
import type { FormPath } from 'sveltekit-superforms';
|
|
20
20
|
|
|
21
|
-
import { cn } from '
|
|
21
|
+
import { cn } from '../../../shadcn/utils.js';
|
|
22
22
|
import {
|
|
23
23
|
Control,
|
|
24
24
|
type ControlAttrs,
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
>
|
|
5
5
|
import type { FormPath } from 'sveltekit-superforms';
|
|
6
6
|
|
|
7
|
-
import ChoiceMulti, {
|
|
7
|
+
import ChoiceMulti, {
|
|
8
|
+
type ChoiceMultiProps
|
|
9
|
+
} from '../../ui/choice/ChoiceMulti.svelte';
|
|
8
10
|
|
|
9
11
|
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
10
12
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import type { Component } from 'svelte';
|
|
3
3
|
import type { FormPath } from 'sveltekit-superforms';
|
|
4
4
|
|
|
5
|
+
import { Input } from '../../../../shadcn/components/ui/input/index.js';
|
|
6
|
+
import { cn } from '../../../../shadcn/utils.js';
|
|
5
7
|
import IconInputWrapper from '../IconInputWrapper.svelte';
|
|
6
|
-
import { Input } from '../../../shadcn/components/ui/input/index.js';
|
|
7
|
-
import { cn } from '../../../shadcn/utils.js';
|
|
8
8
|
import { CalendarDate } from '@internationalized/date';
|
|
9
9
|
|
|
10
10
|
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import type { Component } from 'svelte';
|
|
3
3
|
import type { FormPath } from 'sveltekit-superforms';
|
|
4
4
|
|
|
5
|
+
import { Textarea } from '../../../../shadcn/components/ui/textarea/index.js';
|
|
6
|
+
import { cn } from '../../../../shadcn/utils.js';
|
|
5
7
|
import IconInputWrapper from '../IconInputWrapper.svelte';
|
|
6
|
-
import { Textarea } from '../../../shadcn/components/ui/textarea/index.js';
|
|
7
|
-
import { cn } from '../../../shadcn/utils.js';
|
|
8
8
|
|
|
9
9
|
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
10
10
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import type { Component } from 'svelte';
|
|
3
3
|
import type { FormPath } from 'sveltekit-superforms';
|
|
4
4
|
|
|
5
|
+
import { Input } from '../../../../shadcn/components/ui/input/index.js';
|
|
6
|
+
import { cn } from '../../../../shadcn/utils.js';
|
|
5
7
|
import IconInputWrapper from '../IconInputWrapper.svelte';
|
|
6
|
-
import { Input } from '../../../shadcn/components/ui/input/index.js';
|
|
7
|
-
import { cn } from '../../../shadcn/utils.js';
|
|
8
8
|
|
|
9
9
|
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
10
10
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import type { Component } from 'svelte';
|
|
3
3
|
import type { FormPath } from 'sveltekit-superforms';
|
|
4
4
|
|
|
5
|
+
import { Input } from '../../../../shadcn/components/ui/input/index.js';
|
|
6
|
+
import { cn } from '../../../../shadcn/utils.js';
|
|
5
7
|
import IconInputWrapper from '../IconInputWrapper.svelte';
|
|
6
|
-
import { Input } from '../../../shadcn/components/ui/input/index.js';
|
|
7
|
-
import { cn } from '../../../shadcn/utils.js';
|
|
8
8
|
import { Eye, EyeOff } from '@lucide/svelte';
|
|
9
9
|
|
|
10
10
|
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import type { Component } from 'svelte';
|
|
6
6
|
import type { FormPath } from 'sveltekit-superforms';
|
|
7
7
|
|
|
8
|
-
import IconInputWrapper from '../IconInputWrapper.svelte';
|
|
9
8
|
import {
|
|
10
9
|
Select,
|
|
11
10
|
SelectContent,
|
|
@@ -13,8 +12,9 @@
|
|
|
13
12
|
SelectItem,
|
|
14
13
|
SelectLabel,
|
|
15
14
|
SelectTrigger
|
|
16
|
-
} from '
|
|
17
|
-
import { cn } from '
|
|
15
|
+
} from '../../../../shadcn/components/ui/select/index.js';
|
|
16
|
+
import { cn } from '../../../../shadcn/utils.js';
|
|
17
|
+
import IconInputWrapper from '../IconInputWrapper.svelte';
|
|
18
18
|
|
|
19
19
|
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
20
20
|
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import type { Component } from 'svelte';
|
|
6
6
|
import type { FormPath } from 'sveltekit-superforms';
|
|
7
7
|
|
|
8
|
-
import IconInputWrapper from '../IconInputWrapper.svelte';
|
|
9
8
|
import {
|
|
10
9
|
Select,
|
|
11
10
|
SelectContent,
|
|
@@ -13,8 +12,9 @@
|
|
|
13
12
|
SelectItem,
|
|
14
13
|
SelectLabel,
|
|
15
14
|
SelectTrigger
|
|
16
|
-
} from '
|
|
17
|
-
import { cn } from '
|
|
15
|
+
} from '../../../../shadcn/components/ui/select/index.js';
|
|
16
|
+
import { cn } from '../../../../shadcn/utils.js';
|
|
17
|
+
import IconInputWrapper from '../IconInputWrapper.svelte';
|
|
18
18
|
|
|
19
19
|
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
20
20
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import type { Component } from 'svelte';
|
|
3
3
|
import type { FormPath } from 'sveltekit-superforms';
|
|
4
4
|
|
|
5
|
+
import { Input } from '../../../../shadcn/components/ui/input/index.js';
|
|
6
|
+
import { cn } from '../../../../shadcn/utils.js';
|
|
5
7
|
import IconInputWrapper from '../IconInputWrapper.svelte';
|
|
6
|
-
import { Input } from '../../../shadcn/components/ui/input/index.js';
|
|
7
|
-
import { cn } from '../../../shadcn/utils.js';
|
|
8
8
|
|
|
9
9
|
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
10
10
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import type { Component } from 'svelte';
|
|
3
3
|
import type { FormPath } from 'sveltekit-superforms';
|
|
4
4
|
|
|
5
|
-
import { Input } from '
|
|
6
|
-
import { cn } from '
|
|
5
|
+
import { Input } from '../../../../shadcn/components/ui/input/index.js';
|
|
6
|
+
import { cn } from '../../../../shadcn/utils.js';
|
|
7
7
|
|
|
8
8
|
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
9
9
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import type { Component } from 'svelte';
|
|
3
3
|
import type { FormPath } from 'sveltekit-superforms';
|
|
4
4
|
|
|
5
|
+
import { Input } from '../../../../shadcn/components/ui/input/index.js';
|
|
6
|
+
import { cn } from '../../../../shadcn/utils.js';
|
|
5
7
|
import IconInputWrapper from '../IconInputWrapper.svelte';
|
|
6
|
-
import { Input } from '../../../shadcn/components/ui/input/index.js';
|
|
7
|
-
import { cn } from '../../../shadcn/utils.js';
|
|
8
8
|
import { Time } from '@internationalized/date';
|
|
9
9
|
|
|
10
10
|
import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import type { FormAttrs } from '../../form/FieldWrapper.svelte';
|
|
19
19
|
import type { Snippet } from 'svelte';
|
|
20
20
|
|
|
21
|
-
import { cn } from '
|
|
21
|
+
import { cn } from '../../../../shadcn/utils.js';
|
|
22
22
|
|
|
23
23
|
interface Props extends ChoiceInternalProps<V, I, K> {
|
|
24
24
|
handleItemClick: (item: I) => void;
|
|
@@ -12,9 +12,12 @@
|
|
|
12
12
|
</script>
|
|
13
13
|
|
|
14
14
|
<script lang="ts">
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
import {
|
|
16
|
+
type Day,
|
|
17
|
+
Days,
|
|
18
|
+
formatDayLetter,
|
|
19
|
+
formatDayShort
|
|
20
|
+
} from '../../../utils/datetime/index.js';
|
|
18
21
|
import { identity } from 'ramda';
|
|
19
22
|
|
|
20
23
|
import Choice from './Choice.svelte';
|
|
@@ -8,7 +8,7 @@ export interface WeekdayChoiceProps {
|
|
|
8
8
|
value?: Day;
|
|
9
9
|
vertical?: boolean;
|
|
10
10
|
}
|
|
11
|
-
import type
|
|
11
|
+
import { type Day } from '../../../utils/datetime/index.js';
|
|
12
12
|
declare const WeekdayChoice: import("svelte").Component<WeekdayChoiceProps, {}, "value">;
|
|
13
13
|
type WeekdayChoice = ReturnType<typeof WeekdayChoice>;
|
|
14
14
|
export default WeekdayChoice;
|
|
@@ -15,9 +15,12 @@
|
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
17
|
<script lang="ts">
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
import {
|
|
19
|
+
type Day,
|
|
20
|
+
Days,
|
|
21
|
+
formatDayLetter,
|
|
22
|
+
formatDayShort
|
|
23
|
+
} from '../../../utils/datetime/index.js';
|
|
21
24
|
|
|
22
25
|
import ChoiceMulti from './ChoiceMulti.svelte';
|
|
23
26
|
|
|
@@ -9,7 +9,7 @@ export interface WeekdayChoiceMultiProps {
|
|
|
9
9
|
value: Day[];
|
|
10
10
|
vertical?: boolean;
|
|
11
11
|
}
|
|
12
|
-
import type
|
|
12
|
+
import { type Day } from '../../../utils/datetime/index.js';
|
|
13
13
|
declare const WeekdayChoiceMulti: import("svelte").Component<WeekdayChoiceMultiProps, {}, "value">;
|
|
14
14
|
type WeekdayChoiceMulti = ReturnType<typeof WeekdayChoiceMulti>;
|
|
15
15
|
export default WeekdayChoiceMulti;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import Input from '
|
|
3
|
-
import { cn } from '
|
|
2
|
+
import Input from '../../../../shadcn/components/ui/input/input.svelte';
|
|
3
|
+
import { cn } from '../../../../shadcn/utils.js';
|
|
4
4
|
import { Search } from '@lucide/svelte';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import type { Type } from 'arktype';
|
|
2
2
|
import { CalendarDate as calendarImport, Time as timeImport } from '@internationalized/date';
|
|
3
|
-
|
|
3
|
+
export declare const IntegerId: import("arktype/internal/variants/number.ts").NumberType<number, {}>;
|
|
4
4
|
export declare const Phone: import("arktype/internal/variants/string.ts").StringType<string, {}>;
|
|
5
|
-
|
|
6
|
-
export declare function trimTo(typeTo: Type<string>): import("arktype/internal/variants/object.ts").ObjectType<(In: string) => import("arktype/internal/attributes.ts").To<string>, {}>;
|
|
5
|
+
export declare const HexColor: import("arktype/internal/variants/string.ts").StringType<string, {}>;
|
|
7
6
|
export declare const Day: import("arktype/internal/variants/string.ts").StringType<"Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday", {}>;
|
|
8
|
-
export type Day = (typeof Days)[number];
|
|
9
7
|
export declare const Time: import("arktype/internal/variants/object.ts").ObjectType<timeImport, {}>;
|
|
10
8
|
export declare const CalendarDate: import("arktype/internal/variants/object.ts").ObjectType<calendarImport, {}>;
|
|
11
|
-
|
|
12
|
-
export declare
|
|
13
|
-
export declare const Name: import("arktype/internal/variants/object.ts").ObjectType<(In: string) => import("arktype").Out<string>, {}>;
|
|
14
|
-
export declare const FirstName: import("arktype/internal/variants/object.ts").ObjectType<(In: string) => import("arktype").Out<string>, {}>;
|
|
15
|
-
export declare const LastName: import("arktype/internal/variants/object.ts").ObjectType<(In: string) => import("arktype").Out<string>, {}>;
|
|
16
|
-
export declare const Id: import("arktype/internal/variants/number.ts").NumberType<number, {}>;
|
|
17
|
-
export declare const Password: import("arktype/internal/variants/string.ts").StringType<string, {}>;
|
|
18
|
-
export declare const Duration: import("arktype/internal/variants/number.ts").NumberType<number, {}>;
|
|
9
|
+
/** Type string which is trimmed before narrowing the type checking */
|
|
10
|
+
export declare function trimTo(typeTo: Type<string>): import("arktype/internal/variants/object.ts").ObjectType<(In: string) => import("arktype/internal/attributes.ts").To<string>, {}>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CalendarDate as calendarImport, Time as timeImport } from '@internationalized/date';
|
|
2
|
+
import { type } from 'arktype';
|
|
3
|
+
import { Days } from './datetime/index.js';
|
|
4
|
+
// Useful common types
|
|
5
|
+
export const IntegerId = type('number.integer >= 0');
|
|
6
|
+
// Phone arktype: allows "+", digits, and spaces only
|
|
7
|
+
export const Phone = type('string').narrow((value, ctx) => {
|
|
8
|
+
if (!/^[+0-9 ]+$/.test(value)) {
|
|
9
|
+
return ctx.reject({
|
|
10
|
+
problem: 'invalid phone number. Only +, digits, and spaces are allowed.'
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
});
|
|
15
|
+
export const HexColor = type('string').narrow((value, ctx) => {
|
|
16
|
+
// Regex explanation:
|
|
17
|
+
// ^ : start of string
|
|
18
|
+
// [0-9A-Fa-f]{3} : three hex digits (short form)
|
|
19
|
+
// ([0-9A-Fa-f]{3})? : optional three more digits (long form #RRGGBB)
|
|
20
|
+
// $ : end of string
|
|
21
|
+
if (!/^[0-9A-Fa-f]{3}([0-9A-Fa-f]{3})?$/.test(value)) {
|
|
22
|
+
return ctx.reject({
|
|
23
|
+
problem: 'invalid hex color value'
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
});
|
|
28
|
+
// Datetime types
|
|
29
|
+
export const Day = type.enumerated(...Days);
|
|
30
|
+
export const Time = type.instanceOf(timeImport).configure({
|
|
31
|
+
problem: () => 'invalid time'
|
|
32
|
+
});
|
|
33
|
+
export const CalendarDate = type.instanceOf(calendarImport).configure({
|
|
34
|
+
problem: () => 'invalid date'
|
|
35
|
+
});
|
|
36
|
+
// Arktype utilities
|
|
37
|
+
/** Type string which is trimmed before narrowing the type checking */
|
|
38
|
+
export function trimTo(typeTo) {
|
|
39
|
+
return type('string.trim').to(typeTo);
|
|
40
|
+
}
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { CalendarDate, CalendarDateTime, Time, ZonedDateTime } from '@internationalized/date';
|
|
2
2
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
-
import {
|
|
3
|
+
import { checkOverlap, dateDiffWeeks, datesWithin, formatAbsolute, formatDateFull, formatDateISO, formatDateNum, formatDateShort, formatDayLetter, formatDayShort, formatMonth, formatTimeEnd, formatTimeFull, formatTimeShort, getDayIndex, getDayOfDate, getLastDateOfDay, getLastDatesOfDay, getLastMonths, getNextDateOfDay, isDateDay, LocalDateF } from './index.js';
|
|
4
4
|
const SERVER_TIME_ZONE = 'Europe/London';
|
|
5
|
+
const dt = new LocalDateF(SERVER_TIME_ZONE);
|
|
6
|
+
describe('getDayIndex', () => {
|
|
7
|
+
it('returns the correct day index (0 = Monday)', () => {
|
|
8
|
+
// Test specific dates with known day indices
|
|
9
|
+
expect(getDayIndex(new CalendarDate(2023, 5, 1))).toBe(0); // May 1, 2023 was a Monday
|
|
10
|
+
expect(getDayIndex(new CalendarDate(2023, 5, 2))).toBe(1); // May 2, 2023 was a Tuesday
|
|
11
|
+
expect(getDayIndex(new CalendarDate(2023, 5, 3))).toBe(2); // May 3, 2023 was a Wednesday
|
|
12
|
+
expect(getDayIndex(new CalendarDate(2023, 5, 4))).toBe(3); // May 4, 2023 was a Thursday
|
|
13
|
+
expect(getDayIndex(new CalendarDate(2023, 5, 5))).toBe(4); // May 5, 2023 was a Friday
|
|
14
|
+
expect(getDayIndex(new CalendarDate(2023, 5, 6))).toBe(5); // May 6, 2023 was a Saturday
|
|
15
|
+
expect(getDayIndex(new CalendarDate(2023, 5, 7))).toBe(6); // May 7, 2023 was a Sunday
|
|
16
|
+
});
|
|
17
|
+
});
|
|
5
18
|
describe('getDayOfDate', () => {
|
|
6
19
|
it('returns the correct day of the week (0 = Monday)', () => {
|
|
7
20
|
// Test specific dates with known days of the week
|
|
@@ -64,30 +77,30 @@ describe('isDateToday', () => {
|
|
|
64
77
|
});
|
|
65
78
|
it('returns true when date is today', () => {
|
|
66
79
|
const today = new CalendarDate(2024, 5, 15);
|
|
67
|
-
expect(isDateToday(today
|
|
80
|
+
expect(dt.isDateToday(today)).toBe(true);
|
|
68
81
|
});
|
|
69
82
|
it('returns false when date is in the past', () => {
|
|
70
83
|
const yesterday = new CalendarDate(2024, 5, 14);
|
|
71
|
-
expect(isDateToday(yesterday
|
|
84
|
+
expect(dt.isDateToday(yesterday)).toBe(false);
|
|
72
85
|
const lastMonth = new CalendarDate(2024, 4, 15);
|
|
73
|
-
expect(isDateToday(lastMonth
|
|
86
|
+
expect(dt.isDateToday(lastMonth)).toBe(false);
|
|
74
87
|
const lastYear = new CalendarDate(2023, 5, 15);
|
|
75
|
-
expect(isDateToday(lastYear
|
|
88
|
+
expect(dt.isDateToday(lastYear)).toBe(false);
|
|
76
89
|
});
|
|
77
90
|
it('returns false when date is in the future', () => {
|
|
78
91
|
const tomorrow = new CalendarDate(2024, 5, 16);
|
|
79
|
-
expect(isDateToday(tomorrow
|
|
92
|
+
expect(dt.isDateToday(tomorrow)).toBe(false);
|
|
80
93
|
const nextMonth = new CalendarDate(2024, 6, 15);
|
|
81
|
-
expect(isDateToday(nextMonth
|
|
94
|
+
expect(dt.isDateToday(nextMonth)).toBe(false);
|
|
82
95
|
const nextYear = new CalendarDate(2025, 5, 15);
|
|
83
|
-
expect(isDateToday(nextYear
|
|
96
|
+
expect(dt.isDateToday(nextYear)).toBe(false);
|
|
84
97
|
});
|
|
85
98
|
it('handles date comparison at day boundaries', () => {
|
|
86
99
|
// Still the same day regardless of time of day
|
|
87
100
|
vi.setSystemTime(new CalendarDateTime(2024, 5, 15, 0, 0, 1).toDate(SERVER_TIME_ZONE));
|
|
88
|
-
expect(isDateToday(new CalendarDate(2024, 5, 15)
|
|
101
|
+
expect(dt.isDateToday(new CalendarDate(2024, 5, 15))).toBe(true);
|
|
89
102
|
vi.setSystemTime(new CalendarDateTime(2024, 5, 15, 23, 59, 59).toDate(SERVER_TIME_ZONE));
|
|
90
|
-
expect(isDateToday(new CalendarDate(2024, 5, 15)
|
|
103
|
+
expect(dt.isDateToday(new CalendarDate(2024, 5, 15))).toBe(true);
|
|
91
104
|
});
|
|
92
105
|
});
|
|
93
106
|
describe('ageFromDob', () => {
|
|
@@ -102,35 +115,35 @@ describe('ageFromDob', () => {
|
|
|
102
115
|
});
|
|
103
116
|
it('should calculate age correctly for a normal case', () => {
|
|
104
117
|
const dob = new CalendarDate(2000, 3, 30);
|
|
105
|
-
expect(ageFromDob(dob
|
|
118
|
+
expect(dt.ageFromDob(dob)).toBe(25);
|
|
106
119
|
});
|
|
107
120
|
it('should calculate age correctly when birthday is today', () => {
|
|
108
121
|
const dob = new CalendarDate(2000, 3, 30);
|
|
109
|
-
expect(ageFromDob(dob
|
|
122
|
+
expect(dt.ageFromDob(dob)).toBe(25);
|
|
110
123
|
});
|
|
111
124
|
it('should calculate age correctly for someone born yesterday', () => {
|
|
112
125
|
const dob = new CalendarDate(2000, 3, 29);
|
|
113
|
-
expect(ageFromDob(dob
|
|
126
|
+
expect(dt.ageFromDob(dob)).toBe(25);
|
|
114
127
|
});
|
|
115
128
|
it('should calculate age correctly for someone born tomorrow', () => {
|
|
116
129
|
const dob = new CalendarDate(2000, 3, 31);
|
|
117
|
-
expect(ageFromDob(dob
|
|
130
|
+
expect(dt.ageFromDob(dob)).toBe(24);
|
|
118
131
|
});
|
|
119
132
|
it('should handle leap year birthdays', () => {
|
|
120
133
|
const dob = new CalendarDate(2000, 2, 29);
|
|
121
|
-
expect(ageFromDob(dob
|
|
134
|
+
expect(dt.ageFromDob(dob)).toBe(25);
|
|
122
135
|
});
|
|
123
136
|
it('should return undefined for future dates', () => {
|
|
124
137
|
const futureDob = new CalendarDate(2026, 1, 1);
|
|
125
|
-
expect(() => ageFromDob(futureDob
|
|
138
|
+
expect(() => dt.ageFromDob(futureDob)).toThrow();
|
|
126
139
|
});
|
|
127
140
|
it('should handle month boundary cases', () => {
|
|
128
141
|
const dob = new CalendarDate(2000, 2, 28);
|
|
129
|
-
expect(ageFromDob(dob
|
|
142
|
+
expect(dt.ageFromDob(dob)).toBe(25);
|
|
130
143
|
});
|
|
131
144
|
it('should handle year boundary cases', () => {
|
|
132
145
|
const dob = new CalendarDate(2000, 12, 31);
|
|
133
|
-
expect(ageFromDob(dob
|
|
146
|
+
expect(dt.ageFromDob(dob)).toBe(24);
|
|
134
147
|
});
|
|
135
148
|
});
|
|
136
149
|
describe('getNextDateOfDay', () => {
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import type { Transport } from '@sveltejs/kit';
|
|
2
2
|
import { CalendarDate, type DateDuration, Time, ZonedDateTime } from '@internationalized/date';
|
|
3
|
-
import type { Day } from '../types/arktype.js';
|
|
4
3
|
export declare const Days: readonly ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
|
|
4
|
+
export type Day = (typeof Days)[number];
|
|
5
5
|
export declare const DayIndex: Record<Day, number>;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
export declare class LocalDateF {
|
|
7
|
+
private readonly timezone;
|
|
8
|
+
constructor(timezone: string);
|
|
9
|
+
/**
|
|
10
|
+
* Calculates the age from a date of birth.
|
|
11
|
+
* @param dob - The date of birth.
|
|
12
|
+
* @returns The age in years.
|
|
13
|
+
* @throws Error if the date of birth is in the future.
|
|
14
|
+
*/
|
|
15
|
+
ageFromDob(dob: CalendarDate): number;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if a given date is today.
|
|
18
|
+
* @param date - The date to check.
|
|
19
|
+
* @returns True if the date is today, false otherwise.
|
|
20
|
+
*/
|
|
21
|
+
isDateToday(date: CalendarDate): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* @returns The current date.
|
|
24
|
+
*/
|
|
25
|
+
today(): CalendarDate;
|
|
26
|
+
}
|
|
13
27
|
/**
|
|
14
28
|
* Checks if two time ranges overlap, boundaries are not considered overlapping.
|
|
15
29
|
* @param start1 - The start time of the first range.
|
|
@@ -73,12 +87,6 @@ export declare function getNextDateOfDay(dayOfWeek: Day, startDate: CalendarDate
|
|
|
73
87
|
* @returns True if the date is the specified day, false otherwise.
|
|
74
88
|
*/
|
|
75
89
|
export declare function isDateDay(date: CalendarDate, dayOfWeek: Day): boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Checks if a given date is today.
|
|
78
|
-
* @param date - The date to check.
|
|
79
|
-
* @returns True if the date is today, false otherwise.
|
|
80
|
-
*/
|
|
81
|
-
export declare function isDateToday(date: CalendarDate, timezone: string): boolean;
|
|
82
90
|
/**
|
|
83
91
|
* Calculates the difference in weeks between two dates.
|
|
84
92
|
* @param date1 - The first date in order.
|