@webamoki/web-svelte 1.2.2 → 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.
Files changed (117) hide show
  1. package/README.md +3 -1
  2. package/dist/components/showcase/CodeBlock.svelte +1 -1
  3. package/dist/{components → shared/components}/form/Button.svelte +2 -2
  4. package/dist/{components → shared/components}/form/Button.svelte.d.ts +2 -2
  5. package/dist/{components → shared/components}/form/Errors.svelte +1 -1
  6. package/dist/{components → shared/components}/form/FieldWrapper.svelte +1 -1
  7. package/dist/{components → shared/components}/form/fields/ChoiceMultiField.svelte +3 -1
  8. package/dist/{components → shared/components}/form/fields/DateField.svelte +2 -2
  9. package/dist/{components → shared/components}/form/fields/MessageField.svelte +2 -2
  10. package/dist/{components → shared/components}/form/fields/NumberField.svelte +2 -2
  11. package/dist/{components → shared/components}/form/fields/PasswordField.svelte +2 -2
  12. package/dist/{components → shared/components}/form/fields/SelectField.svelte +3 -3
  13. package/dist/{components → shared/components}/form/fields/SelectMultiField.svelte +3 -3
  14. package/dist/{components → shared/components}/form/fields/TextField.svelte +2 -2
  15. package/dist/{components → shared/components}/form/fields/TextFieldNullable.svelte +2 -2
  16. package/dist/{components → shared/components}/form/fields/TimeField.svelte +2 -2
  17. package/dist/{components → shared/components}/ui/choice/ChoiceInternal.svelte +1 -1
  18. package/dist/{components → shared/components}/ui/choice/WeekdayChoice.svelte +6 -3
  19. package/dist/{components → shared/components}/ui/choice/WeekdayChoice.svelte.d.ts +1 -1
  20. package/dist/{components → shared/components}/ui/choice/WeekdayChoiceMulti.svelte +6 -3
  21. package/dist/{components → shared/components}/ui/choice/WeekdayChoiceMulti.svelte.d.ts +1 -1
  22. package/dist/{components → shared/components}/ui/context-menu/ContextMenuContent.svelte +1 -1
  23. package/dist/{components → shared/components}/ui/context-menu/ContextMenuItem.svelte +1 -1
  24. package/dist/{components → shared/components}/ui/search/SearchBar.svelte +2 -2
  25. package/dist/{utils/types → shared/utils}/arktype.d.ts +4 -12
  26. package/dist/shared/utils/arktype.js +40 -0
  27. package/dist/shared/utils/datetime/datetime.spec.d.ts +1 -0
  28. package/dist/shared/utils/datetime/datetime.spec.js +768 -0
  29. package/dist/{utils → shared/utils}/datetime/index.d.ts +22 -14
  30. package/dist/{utils → shared/utils}/datetime/index.js +44 -32
  31. package/dist/{utils → shared/utils}/email/README.md +5 -5
  32. package/dist/{utils → shared/utils}/email/ses.js +17 -9
  33. package/dist/shared/utils/email/ses.test.d.ts +1 -0
  34. package/dist/shared/utils/email/ses.test.js +335 -0
  35. package/dist/shared/utils/functional/index.d.ts +2 -0
  36. package/dist/shared/utils/functional/index.js +2 -0
  37. package/dist/shared/utils/functional/result.d.ts +72 -0
  38. package/dist/shared/utils/functional/result.js +86 -0
  39. package/dist/shared/utils/functional/result.spec.d.ts +1 -0
  40. package/dist/shared/utils/functional/result.spec.js +96 -0
  41. package/dist/shared/utils/remote.d.ts +28 -0
  42. package/dist/shared/utils/remote.js +74 -0
  43. package/dist/{utils/search.d.ts → shared/utils/string.d.ts} +1 -0
  44. package/dist/{utils/search.js → shared/utils/string.js} +13 -4
  45. package/package.json +28 -33
  46. package/dist/utils/email/aws-signer.d.ts +0 -17
  47. package/dist/utils/email/aws-signer.js +0 -83
  48. package/dist/utils/string.d.ts +0 -1
  49. package/dist/utils/string.js +0 -4
  50. package/dist/utils/types/arktype.js +0 -92
  51. package/dist/utils/types/consts.d.ts +0 -5
  52. package/dist/utils/types/consts.js +0 -5
  53. package/dist/utils/types/db.d.ts +0 -57
  54. package/dist/utils/types/db.js +0 -34
  55. /package/dist/{components → shared/components}/form/Errors.svelte.d.ts +0 -0
  56. /package/dist/{components → shared/components}/form/FieldWrapper.svelte.d.ts +0 -0
  57. /package/dist/{components → shared/components}/form/Form.svelte +0 -0
  58. /package/dist/{components → shared/components}/form/Form.svelte.d.ts +0 -0
  59. /package/dist/{components → shared/components}/form/IconInputWrapper.svelte +0 -0
  60. /package/dist/{components → shared/components}/form/IconInputWrapper.svelte.d.ts +0 -0
  61. /package/dist/{components → shared/components}/form/fields/ChoiceField.svelte +0 -0
  62. /package/dist/{components → shared/components}/form/fields/ChoiceField.svelte.d.ts +0 -0
  63. /package/dist/{components → shared/components}/form/fields/ChoiceMultiField.svelte.d.ts +0 -0
  64. /package/dist/{components → shared/components}/form/fields/DateField.svelte.d.ts +0 -0
  65. /package/dist/{components → shared/components}/form/fields/HexColorField.svelte +0 -0
  66. /package/dist/{components → shared/components}/form/fields/HexColorField.svelte.d.ts +0 -0
  67. /package/dist/{components → shared/components}/form/fields/MessageField.svelte.d.ts +0 -0
  68. /package/dist/{components → shared/components}/form/fields/NumberField.svelte.d.ts +0 -0
  69. /package/dist/{components → shared/components}/form/fields/PasswordField.svelte.d.ts +0 -0
  70. /package/dist/{components → shared/components}/form/fields/SelectField.svelte.d.ts +0 -0
  71. /package/dist/{components → shared/components}/form/fields/SelectMultiField.svelte.d.ts +0 -0
  72. /package/dist/{components → shared/components}/form/fields/TextField.svelte.d.ts +0 -0
  73. /package/dist/{components → shared/components}/form/fields/TextFieldNullable.svelte.d.ts +0 -0
  74. /package/dist/{components → shared/components}/form/fields/TimeField.svelte.d.ts +0 -0
  75. /package/dist/{components → shared/components}/form/fields/WeekdayChoiceField.svelte +0 -0
  76. /package/dist/{components → shared/components}/form/fields/WeekdayChoiceField.svelte.d.ts +0 -0
  77. /package/dist/{components → shared/components}/form/fields/WeekdayChoiceMultiField.svelte +0 -0
  78. /package/dist/{components → shared/components}/form/fields/WeekdayChoiceMultiField.svelte.d.ts +0 -0
  79. /package/dist/{components → shared/components}/form/index.d.ts +0 -0
  80. /package/dist/{components → shared/components}/form/index.js +0 -0
  81. /package/dist/{components → shared/components}/ui/choice/Choice.svelte +0 -0
  82. /package/dist/{components → shared/components}/ui/choice/Choice.svelte.d.ts +0 -0
  83. /package/dist/{components → shared/components}/ui/choice/ChoiceInternal.svelte.d.ts +0 -0
  84. /package/dist/{components → shared/components}/ui/choice/ChoiceMulti.svelte +0 -0
  85. /package/dist/{components → shared/components}/ui/choice/ChoiceMulti.svelte.d.ts +0 -0
  86. /package/dist/{components → shared/components}/ui/context-menu/ContextMenu.svelte +0 -0
  87. /package/dist/{components → shared/components}/ui/context-menu/ContextMenu.svelte.d.ts +0 -0
  88. /package/dist/{components → shared/components}/ui/context-menu/ContextMenuContent.svelte.d.ts +0 -0
  89. /package/dist/{components → shared/components}/ui/context-menu/ContextMenuItem.svelte.d.ts +0 -0
  90. /package/dist/{components → shared/components}/ui/context-menu/ContextMenuSeparator.svelte +0 -0
  91. /package/dist/{components → shared/components}/ui/context-menu/ContextMenuSeparator.svelte.d.ts +0 -0
  92. /package/dist/{components → shared/components}/ui/context-menu/ContextMenuTrigger.svelte +0 -0
  93. /package/dist/{components → shared/components}/ui/context-menu/ContextMenuTrigger.svelte.d.ts +0 -0
  94. /package/dist/{components → shared/components}/ui/context-menu/context-menu-state.svelte.d.ts +0 -0
  95. /package/dist/{components → shared/components}/ui/context-menu/context-menu-state.svelte.js +0 -0
  96. /package/dist/{components → shared/components}/ui/drag-drop/Draggable.svelte +0 -0
  97. /package/dist/{components → shared/components}/ui/drag-drop/Draggable.svelte.d.ts +0 -0
  98. /package/dist/{components → shared/components}/ui/drag-drop/Dropzone.svelte +0 -0
  99. /package/dist/{components → shared/components}/ui/drag-drop/Dropzone.svelte.d.ts +0 -0
  100. /package/dist/{components → shared/components}/ui/drag-drop/drag-manager.d.ts +0 -0
  101. /package/dist/{components → shared/components}/ui/drag-drop/drag-manager.js +0 -0
  102. /package/dist/{components → shared/components}/ui/index.d.ts +0 -0
  103. /package/dist/{components → shared/components}/ui/index.js +0 -0
  104. /package/dist/{components → shared/components}/ui/search/SearchBar.svelte.d.ts +0 -0
  105. /package/dist/{server → shared/server}/form-handler.d.ts +0 -0
  106. /package/dist/{server → shared/server}/form-handler.js +0 -0
  107. /package/dist/{server → shared/server}/form-processor.d.ts +0 -0
  108. /package/dist/{server → shared/server}/form-processor.js +0 -0
  109. /package/dist/{utils → shared/utils}/email/index.d.ts +0 -0
  110. /package/dist/{utils → shared/utils}/email/index.js +0 -0
  111. /package/dist/{utils → shared/utils}/email/ses.d.ts +0 -0
  112. /package/dist/{utils → shared/utils}/form/index.d.ts +0 -0
  113. /package/dist/{utils → shared/utils}/form/index.js +0 -0
  114. /package/dist/{utils → shared/utils}/form/virtual-form.d.ts +0 -0
  115. /package/dist/{utils → shared/utils}/form/virtual-form.js +0 -0
  116. /package/dist/{highlight.d.ts → utils/highlight.d.ts} +0 -0
  117. /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,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { highlight } from '../../highlight.js';
2
+ import { highlight } from '../../utils/highlight.js';
3
3
  import { onMount } from 'svelte';
4
4
 
5
5
  export let language: string = 'svelte';
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
- import type { ButtonProps } from '../../shadcn/components/ui/button/index.js';
2
+ import type { ButtonProps } from '../../../shadcn/components/ui/button/index.js';
3
3
 
4
- import { Button } from '../../shadcn/components/ui/button/index.js';
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 '../../shadcn/components/ui/button/index.js';
2
- import { Button } from '../../shadcn/components/ui/button/index.js';
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;
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { cn } from '../../shadcn/utils.js';
2
+ import { cn } from '../../../shadcn/utils.js';
3
3
  import { FieldErrors } from 'formsnap';
4
4
 
5
5
  interface Props {
@@ -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 '../../shadcn/utils.js';
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, { type ChoiceMultiProps } from '../../ui/choice/ChoiceMulti.svelte';
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 '../../../shadcn/components/ui/select/index.js';
17
- import { cn } from '../../../shadcn/utils.js';
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 '../../../shadcn/components/ui/select/index.js';
17
- import { cn } from '../../../shadcn/utils.js';
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 '../../../shadcn/components/ui/input/index.js';
6
- import { cn } from '../../../shadcn/utils.js';
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 '../../../shadcn/utils.js';
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 type { Day } from '../../../utils/types/arktype.js';
16
-
17
- import { Days, formatDayLetter, formatDayShort } from '../../../utils/datetime/index.js';
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 { Day } from '../../../utils/types/arktype.js';
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 type { Day } from '../../../utils/types/arktype.js';
19
-
20
- import { Days, formatDayLetter, formatDayShort } from '../../../utils/datetime/index.js';
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 { Day } from '../../../utils/types/arktype.js';
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,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { cn } from '../../../shadcn/utils.js';
2
+ import { cn } from '../../../../shadcn/utils.js';
3
3
  import { getContext, onMount, type Snippet } from 'svelte';
4
4
  import { scale } from 'svelte/transition';
5
5
 
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
 
4
- import { cn } from '../../../shadcn/utils.js';
4
+ import { cn } from '../../../../shadcn/utils.js';
5
5
 
6
6
  interface Props extends HTMLAttributes<HTMLDivElement> {
7
7
  disabled?: boolean;
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
- import Input from '../../../shadcn/components/ui/input/input.svelte';
3
- import { cn } from '../../../shadcn/utils.js';
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
- import { Days } from '../datetime/index.js';
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
- /** Type string which is trimmed before narrowing the type checking */
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
- export declare const HexColor: import("arktype/internal/variants/string.ts").StringType<string, {}>;
12
- export declare const Email: import("arktype/internal/variants/object.ts").ObjectType<(In: string) => import("arktype").Out<string>, {}>;
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
+ }
@@ -0,0 +1 @@
1
+ export {};