@oxcide-ui/schema 0.0.3

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.
@@ -0,0 +1,69 @@
1
+ import type { IconName } from '@oxcide-ui/icons'
2
+ import { z } from 'zod'
3
+
4
+ export const toastSeveritySchema = z.enum([
5
+ 'success',
6
+ 'info',
7
+ 'warning',
8
+ 'danger',
9
+ 'secondary',
10
+ 'help',
11
+ 'contrast',
12
+ 'primary'
13
+ ])
14
+
15
+ export const toastMessageSchema = z.object({
16
+ id: z.string().optional(),
17
+ severity: toastSeveritySchema.default('info'),
18
+ summary: z.string().optional(),
19
+ detail: z.string().optional(),
20
+ life: z.number().optional().default(3000),
21
+ sticky: z.boolean().optional().default(false),
22
+ closable: z.boolean().optional().default(true),
23
+ icon: z.string().optional() as z.ZodType<IconName | undefined>,
24
+ group: z.string().optional()
25
+ })
26
+
27
+ export const toastPropsSchema = z.object({
28
+ position: z
29
+ .enum(['top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right', 'center'])
30
+ .default('top-right'),
31
+ group: z.string().optional(),
32
+ baseZIndex: z.number().optional().default(0),
33
+ autoZIndex: z.boolean().optional().default(true),
34
+ /** Teleport target selector or element */
35
+ appendTo: z.any().default('#teleports')
36
+ })
37
+
38
+ export type ToastSeverity = z.infer<typeof toastSeveritySchema>
39
+ export type ToastMessage = z.infer<typeof toastMessageSchema>
40
+ /* @oxcide-sync:source
41
+ export type ToastProps = z.input<typeof toastPropsSchema>
42
+ export type ToastResolvedProps = z.infer<typeof toastPropsSchema>
43
+ @oxcide-sync:end */
44
+ export interface ToastProps {
45
+ position?:
46
+ | 'top-left'
47
+ | 'top-center'
48
+ | 'top-right'
49
+ | 'bottom-left'
50
+ | 'bottom-center'
51
+ | 'bottom-right'
52
+ | 'center'
53
+ | undefined
54
+ group?: string | undefined
55
+ baseZIndex?: number | undefined
56
+ autoZIndex?: boolean | undefined
57
+ appendTo?: any
58
+ }
59
+ export type ToastResolvedProps = {
60
+ position: 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'center'
61
+ baseZIndex: number
62
+ autoZIndex: boolean
63
+ group?: string | undefined
64
+ appendTo?: any
65
+ }
66
+
67
+ export function getToastDefaults(props: ToastProps = {}): ToastResolvedProps {
68
+ return toastPropsSchema.parse(props) as ToastResolvedProps
69
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './components'
2
+ export * from './registry'
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod'
2
+
3
+ /**
4
+ * Schema for a single file in a registry item.
5
+ */
6
+ export const registryItemFileSchema = z.object({
7
+ /** Relative file path */
8
+ path: z.string(),
9
+ /** File content as string */
10
+ content: z.string(),
11
+ /** File type hint */
12
+ type: z.enum(['component', 'style', 'schema', 'composable', 'util']).optional()
13
+ })
14
+
15
+ /**
16
+ * Schema for a registry item (component metadata + source).
17
+ * Used to validate the JSON output of the registry build process.
18
+ */
19
+ export const registryItemSchema = z.object({
20
+ /** Component name (kebab-case) */
21
+ name: z.string(),
22
+ /** Component type */
23
+ type: z.enum(['component', 'primitive', 'composable', 'util']).default('component'),
24
+ /** Human-readable description */
25
+ description: z.string().optional(),
26
+ /** Source files */
27
+ files: z.array(registryItemFileSchema),
28
+ /** npm dependencies required by this component */
29
+ dependencies: z.array(z.string()).default([]),
30
+ /** Other registry components this one depends on */
31
+ registryDependencies: z.array(z.string()).default([]),
32
+ /** CSS file paths (if separately bundled) */
33
+ cssFiles: z.array(z.string()).default([])
34
+ })
35
+
36
+ export type RegistryItem = z.infer<typeof registryItemSchema>
37
+ export type RegistryItemFile = z.infer<typeof registryItemFileSchema>
38
+
39
+ /**
40
+ * Schema for the full registry index.
41
+ */
42
+ export const registryIndexSchema = z.array(
43
+ z.object({
44
+ name: z.string(),
45
+ type: z.string(),
46
+ description: z.string().optional(),
47
+ dependencies: z.array(z.string()).default([]),
48
+ registryDependencies: z.array(z.string()).default([])
49
+ })
50
+ )
51
+
52
+ export type RegistryIndex = z.infer<typeof registryIndexSchema>
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "baseUrl": "."
5
+ },
6
+ "include": ["src/**/*.ts"]
7
+ }