@rilaykit/core 0.1.1-alpha.1 → 0.1.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 AND YOU CREATE
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,182 @@
1
+ # @rilaykit/core
2
+
3
+ The foundation of [RilayKit](https://rilay.dev) — a schema-first, headless form library for React.
4
+
5
+ `@rilaykit/core` provides the component registry, type system, validation engine, condition system, and monitoring infrastructure that powers the entire RilayKit ecosystem.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ # pnpm (recommended)
11
+ pnpm add @rilaykit/core
12
+
13
+ # npm
14
+ npm install @rilaykit/core
15
+
16
+ # yarn
17
+ yarn add @rilaykit/core
18
+
19
+ # bun
20
+ bun add @rilaykit/core
21
+ ```
22
+
23
+ ### Requirements
24
+
25
+ - React >= 18
26
+ - TypeScript >= 5
27
+
28
+ ## Quick Start
29
+
30
+ ### 1. Define Your Components
31
+
32
+ ```tsx
33
+ import { ComponentRenderer } from '@rilaykit/core';
34
+
35
+ interface InputProps {
36
+ label: string;
37
+ type?: string;
38
+ placeholder?: string;
39
+ }
40
+
41
+ const Input: ComponentRenderer<InputProps> = ({
42
+ id, value, onChange, onBlur, error, props,
43
+ }) => (
44
+ <div>
45
+ <label htmlFor={id}>{props.label}</label>
46
+ <input
47
+ id={id}
48
+ type={props.type || 'text'}
49
+ value={value || ''}
50
+ onChange={(e) => onChange?.(e.target.value)}
51
+ onBlur={onBlur}
52
+ />
53
+ {error && <p>{error[0].message}</p>}
54
+ </div>
55
+ );
56
+ ```
57
+
58
+ ### 2. Create a Registry
59
+
60
+ ```tsx
61
+ import { ril } from '@rilaykit/core';
62
+
63
+ const rilay = ril.create()
64
+ .addComponent('input', { renderer: Input })
65
+ .addComponent('select', { renderer: Select });
66
+ ```
67
+
68
+ Each `.addComponent()` call returns a new typed instance — TypeScript tracks registered types and propagates component prop types through the entire builder chain.
69
+
70
+ ## Features
71
+
72
+ ### Component Registry
73
+
74
+ An immutable, type-safe registry that maps component type names to their renderers and default props. Configured once, used across your entire application.
75
+
76
+ ```tsx
77
+ const rilay = ril.create()
78
+ .addComponent('input', { renderer: Input })
79
+ .addComponent('textarea', { renderer: Textarea })
80
+ .addComponent('select', { renderer: Select });
81
+
82
+ // TypeScript knows exactly which types are valid
83
+ // and narrows props accordingly
84
+ ```
85
+
86
+ ### Validation Engine
87
+
88
+ Universal validation based on [Standard Schema](https://standardschema.dev). Use built-in validators, any Standard Schema compatible library (Zod, Valibot, ArkType, Yup...), or write custom validators — no adapters needed.
89
+
90
+ ```tsx
91
+ import { required, email, minLength, custom } from '@rilaykit/core';
92
+
93
+ // Built-in validators
94
+ validation: { validate: [required(), email()] }
95
+
96
+ // Zod (or any Standard Schema library) — no adapter
97
+ import { z } from 'zod';
98
+ validation: { validate: z.string().email() }
99
+
100
+ // Custom validators
101
+ const strongPassword = custom(
102
+ (value) => /(?=.*[A-Z])(?=.*\d)/.test(value),
103
+ 'Must contain uppercase and number'
104
+ );
105
+
106
+ // Mix them freely
107
+ validation: { validate: [required(), z.string().min(8), strongPassword] }
108
+ ```
109
+
110
+ **Built-in validators:** `required`, `email`, `url`, `pattern`, `min`, `max`, `minLength`, `maxLength`, `number`, `custom`, `async`, `combine`
111
+
112
+ ### Condition System
113
+
114
+ Declarative conditional logic with the `when()` builder. No `useEffect`, no imperative state management.
115
+
116
+ ```tsx
117
+ import { when } from '@rilaykit/core';
118
+
119
+ // Visibility
120
+ conditions: { visible: when('accountType').equals('business') }
121
+
122
+ // Combine with boolean logic
123
+ conditions: {
124
+ visible: when('country').in(['US', 'CA']).and().field('age').greaterThan(18),
125
+ required: when('accountType').equals('business'),
126
+ }
127
+ ```
128
+
129
+ **Operators:** `equals`, `notEquals`, `greaterThan`, `lessThan`, `greaterThanOrEqual`, `lessThanOrEqual`, `contains`, `notContains`, `in`, `notIn`, `matches`, `exists`, `notExists`
130
+
131
+ ### Monitoring
132
+
133
+ Pluggable monitoring system with event buffering, performance profiling, and automatic alerts.
134
+
135
+ ```tsx
136
+ import { initializeMonitoring } from '@rilaykit/core';
137
+
138
+ const monitor = initializeMonitoring({
139
+ adapters: [myAdapter],
140
+ bufferSize: 100,
141
+ flushInterval: 5000,
142
+ });
143
+ ```
144
+
145
+ ## API Overview
146
+
147
+ | Export | Description |
148
+ |--------|-------------|
149
+ | `ril` | Component registry builder with type accumulation |
150
+ | `when` | Condition builder for declarative field logic |
151
+ | `required`, `email`, `url`, `pattern`, `min`, `max`, `minLength`, `maxLength`, `number` | Built-in validators |
152
+ | `custom`, `async`, `combine` | Custom and composite validators |
153
+ | `initializeMonitoring`, `RilayMonitor` | Monitoring system |
154
+ | `evaluateCondition`, `ConditionDependencyGraph` | Condition evaluation utilities |
155
+
156
+ ## Architecture
157
+
158
+ `@rilaykit/core` is the foundation layer with no React rendering dependency. It can run in Node, in tests, and in build scripts. The other RilayKit packages build on top of it:
159
+
160
+ ```
161
+ @rilaykit/core ← you are here
162
+
163
+ @rilaykit/forms (form builder + React components)
164
+
165
+ @rilaykit/workflow (multi-step workflows)
166
+ ```
167
+
168
+ ## Documentation
169
+
170
+ Full documentation at [rilay.dev](https://rilay.dev):
171
+
172
+ - [Installation](https://rilay.dev/getting-started/installation)
173
+ - [Quick Start](https://rilay.dev/quickstart)
174
+ - [Component Registry](https://rilay.dev/core-concepts/ril-instance)
175
+ - [Validation](https://rilay.dev/core-concepts/validation)
176
+ - [Conditions](https://rilay.dev/core-concepts/conditions)
177
+ - [TypeScript Support](https://rilay.dev/core-concepts/typescript-support)
178
+ - [API Reference](https://rilay.dev/api)
179
+
180
+ ## License
181
+
182
+ MIT — see [LICENSE](./LICENSE) for details.