@coffer-org/sdk 1.1.0 → 1.2.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.
Files changed (69) hide show
  1. package/dist/color-names.d.ts +0 -1
  2. package/dist/color-names.js +0 -1
  3. package/dist/condition.d.ts +3 -19
  4. package/dist/condition.js +50 -69
  5. package/dist/countries.d.ts +0 -2
  6. package/dist/countries.js +0 -1
  7. package/dist/currencies.d.ts +0 -10
  8. package/dist/currencies.js +0 -10
  9. package/dist/extend.d.ts +3 -22
  10. package/dist/extend.js +2 -6
  11. package/dist/field-helpers.d.ts +0 -7
  12. package/dist/field-helpers.js +0 -16
  13. package/dist/field-presets.d.ts +55 -87
  14. package/dist/field-presets.js +116 -108
  15. package/dist/fields/constants.d.ts +36 -0
  16. package/dist/fields/constants.js +18 -0
  17. package/dist/fields/normalize.d.ts +84 -0
  18. package/dist/fields/normalize.js +47 -0
  19. package/dist/fields/url.d.ts +13 -0
  20. package/dist/fields/url.js +49 -0
  21. package/dist/fields/validation.d.ts +30 -0
  22. package/dist/fields/validation.js +57 -0
  23. package/dist/fields.d.ts +222 -332
  24. package/dist/fields.js +435 -351
  25. package/dist/index.d.ts +14 -16
  26. package/dist/index.js +14 -16
  27. package/dist/module.d.ts +13 -103
  28. package/dist/module.js +51 -83
  29. package/dist/package.d.ts +3 -20
  30. package/dist/package.js +14 -19
  31. package/dist/plugin.d.ts +5 -45
  32. package/dist/plugin.js +5 -19
  33. package/dist/settings.d.ts +1 -2
  34. package/dist/settings.js +0 -1
  35. package/dist/units.d.ts +0 -1
  36. package/dist/units.js +0 -5
  37. package/dist/vault.d.ts +3 -8
  38. package/dist/vault.js +4 -1
  39. package/package.json +5 -1
  40. package/dist/color-names.d.ts.map +0 -1
  41. package/dist/color-names.js.map +0 -1
  42. package/dist/condition.d.ts.map +0 -1
  43. package/dist/condition.js.map +0 -1
  44. package/dist/countries.d.ts.map +0 -1
  45. package/dist/countries.js.map +0 -1
  46. package/dist/currencies.d.ts.map +0 -1
  47. package/dist/currencies.js.map +0 -1
  48. package/dist/extend.d.ts.map +0 -1
  49. package/dist/extend.js.map +0 -1
  50. package/dist/field-helpers.d.ts.map +0 -1
  51. package/dist/field-helpers.js.map +0 -1
  52. package/dist/field-presets.d.ts.map +0 -1
  53. package/dist/field-presets.js.map +0 -1
  54. package/dist/fields.d.ts.map +0 -1
  55. package/dist/fields.js.map +0 -1
  56. package/dist/index.d.ts.map +0 -1
  57. package/dist/index.js.map +0 -1
  58. package/dist/module.d.ts.map +0 -1
  59. package/dist/module.js.map +0 -1
  60. package/dist/package.d.ts.map +0 -1
  61. package/dist/package.js.map +0 -1
  62. package/dist/plugin.d.ts.map +0 -1
  63. package/dist/plugin.js.map +0 -1
  64. package/dist/settings.d.ts.map +0 -1
  65. package/dist/settings.js.map +0 -1
  66. package/dist/units.d.ts.map +0 -1
  67. package/dist/units.js.map +0 -1
  68. package/dist/vault.d.ts.map +0 -1
  69. package/dist/vault.js.map +0 -1
package/dist/fields.d.ts CHANGED
@@ -1,28 +1,13 @@
1
- /**
2
- * Система типів полів — серце платформи. Чистий, ізоморфний модуль.
3
- * Один опис поля → три споживачі:
4
- * 1. `zod` — валідація (однакова на сервері й клієнті)
5
- * 2. `column` — тип колонки в БД
6
- * 3. `prim`/`kind` — ключі для резолву рендера (див. web/render/registry)
7
- */
8
1
  import { z } from 'zod';
9
- /**
10
- * Базові примітиви-рендери (storage-родина). Кожна фабрика ставить один `prim` —
11
- * гарантований fallback-рендер. Семантичні обгортки задають свій `kind` (рядок),
12
- * який має пріоритет; якщо для `kind` рендера немає — тихий відкат на `prim`.
13
- *
14
- * `(string & {})` лишає автодоповнення CorePrim-літералів, але дозволяє плагінам
15
- * оголошувати власні prim (напр. 'service-links') типи полів виносяться у плагіни.
16
- */
17
- export type CorePrim = 'text' | 'number' | 'date' | 'time' | 'datetime' | 'checkbox' | 'select' | 'json' | 'checklist' | 'measured' | 'relation' | 'file' | 'per-weekday' | 'key-value' | 'lookup';
2
+ export { vmsg, reqErr, typeErr, reqTypeErr, jsonRefined, optionalize, jsonValue, decodeVmsg, validateField } from './fields/validation.ts';
3
+ import type { Condition } from './condition.ts';
4
+ export type { Rules, View, FieldConfig } from './fields/normalize.ts';
5
+ export { normalizeOpts } from './fields/normalize.ts';
6
+ import { type Rules, type View } from './fields/normalize.ts';
7
+ import { presets } from './field-presets.ts';
8
+ export type CorePrim = 'text' | 'number' | 'date' | 'time' | 'datetime' | 'checkbox' | 'select' | 'json' | 'check' | 'measured' | 'relation' | 'file' | 'per-weekday' | 'lookup';
18
9
  export type Prim = CorePrim | (string & {});
19
10
  export type ColumnType = 'text' | 'integer' | 'real' | 'boolean' | 'date' | 'time' | 'datetime';
20
- /**
21
- * Іконка опції — візуальний лідер у списку. Дискримінований за kind:
22
- * swatch — кольоровий кружок ('#rrggbb')
23
- * icon — <Icon> ('flag:ua' | lucide-ім'я | emoji)
24
- * image — аватар-картинка (url)
25
- */
26
11
  export type OptionIcon = {
27
12
  kind: 'swatch';
28
13
  value: string;
@@ -33,37 +18,33 @@ export type OptionIcon = {
33
18
  kind: 'image';
34
19
  value: string;
35
20
  };
36
- /**
37
- * Опція вибору. `value` — storage-ключ (обов'язковий). Трійка відображення:
38
- * icon — візуальний лідер (опц.)
39
- * title — основна мітка (i18n-ключ або текст)
40
- * subtitle — технічне значення праворуч (опц.; ISO-код, hex, …)
41
- */
42
21
  export interface OptionItem {
43
22
  value: string;
44
23
  title: string;
45
24
  icon?: OptionIcon;
46
25
  subtitle?: string;
47
26
  }
48
- /**
49
- * Phantom-бренд: лише фабрики `field.*({ key })` повертають FieldItem.
50
- * Не існує в runtime — суто типовий маркер, щоб TS відхиляв ручні `{ key, type }`
51
- * літерали у `fields`. Будуй елементи через `field.*({ key, … })`.
52
- */
53
27
  declare const __fieldItemBrand: unique symbol;
54
- /** Поле: key = ім'я колонки БД, type = FieldMeta. Будується через field.*({key:'x',...}). */
55
28
  export interface FieldItem {
56
29
  key: string;
57
30
  type: FieldMeta;
58
31
  readonly [__fieldItemBrand]: typeof __fieldItemBrand;
59
32
  }
60
- /** Статичне поле: тільки display-режим. value — вже розпарсений об'єкт. */
61
33
  export interface StaticEl {
62
34
  el: 'static';
63
35
  type: FieldMeta;
64
36
  value: unknown;
65
37
  }
66
- /** Псевдо-елементи: не зберігаються, не валідуються. */
38
+ export interface ComputeCtx {
39
+ record: Record<string, unknown>;
40
+ settings: Record<string, unknown>;
41
+ global: Record<string, unknown>;
42
+ meta: {
43
+ vault: string;
44
+ module: string;
45
+ };
46
+ }
47
+ export type ComputeFn = (ctx: ComputeCtx) => unknown;
67
48
  export interface DividerEl {
68
49
  el: 'divider';
69
50
  }
@@ -76,23 +57,26 @@ export interface ButtonEl {
76
57
  label: string;
77
58
  value: string;
78
59
  icon?: string;
79
- variant?: 'default' | 'outline' | 'destructive';
60
+ variant?: 'default' | 'outline' | 'destructive' | 'secondary' | 'ghost' | 'link';
80
61
  }
62
+ export interface BreakEl {
63
+ el: 'break';
64
+ }
65
+ export type GroupDisplay = 'wrap' | 'scroll' | 'table' | 'sheet';
81
66
  export interface GroupEl {
82
67
  el: 'group';
83
- /** Storage-режим: ім'я колонки (embedded) / child-таблиці (collection). Без key → layout. */
84
68
  key?: string;
85
- /** collection (масив рядків → child-таблиця). Лише зі storage key. */
86
69
  multiple?: boolean;
87
- /** Storage: чи обов'язковий (collection → ≥1 рядок; embedded → непорожній). */
88
70
  required?: boolean;
89
- /** collection: sub-ключі з UNIQUE(parent_id, …) на child-таблиці. */
90
71
  unique?: string[];
91
72
  label?: string;
92
73
  icon?: string;
93
- fields: (FieldItem | StaticEl | PseudoEl)[];
74
+ display?: GroupDisplay;
75
+ kind?: string;
76
+ fixed?: boolean;
77
+ fields: LayoutEl[];
94
78
  }
95
- export type PseudoEl = DividerEl | InfoEl | ButtonEl;
79
+ export type PseudoEl = DividerEl | InfoEl | ButtonEl | BreakEl;
96
80
  export type LayoutEl = FieldItem | StaticEl | GroupEl | PseudoEl;
97
81
  export declare const isField: (x: LayoutEl) => x is FieldItem;
98
82
  export declare const isStatic: (x: LayoutEl) => x is StaticEl;
@@ -100,13 +84,11 @@ export declare const isGroup: (x: LayoutEl) => x is GroupEl;
100
84
  export declare const isDivider: (x: LayoutEl) => x is DividerEl;
101
85
  export declare const isInfo: (x: LayoutEl) => x is InfoEl;
102
86
  export declare const isButton: (x: LayoutEl) => x is ButtonEl;
103
- /** Серіалізовна частина поля (безпечно віддавати клієнту). */
87
+ export declare const isBreak: (x: LayoutEl) => x is BreakEl;
104
88
  export interface FieldClient {
105
- /** Семантичний рендер-ключ (пріоритет). За замовчуванням === prim. */
106
89
  kind: string;
107
90
  label: string;
108
- required: boolean;
109
- /** Базовий примітив-рендер (storage-родина) — гарантований fallback. */
91
+ required: boolean | Condition;
110
92
  prim: Prim;
111
93
  hints: Record<string, unknown>;
112
94
  options?: OptionItem[];
@@ -114,126 +96,113 @@ export interface FieldClient {
114
96
  vault: string;
115
97
  type: string;
116
98
  };
117
- /** Якщо true — поле не зберігається в БД і не включається у zod-схему. */
118
99
  virtual?: boolean;
119
- /** Опційна підказка ширини в 12-кол гріді (1–12). Рендер — фінальна інстанція, може ігнорувати. */
120
- span?: number;
121
- }
122
- /**
123
- * Візуальна або storage-група полів (один рівень вкладеності — груп усередині груп нема).
124
- * Без `key` → layout-група (не зберігається). З `key` → storage:
125
- * - embedded (key, без multiple): зберігається як колонка або вкладений об'єкт.
126
- * - collection (key + multiple): child-таблиця (масив рядків).
127
- * Storage-група вимагає `label` і лише `FieldItem`-нащадків (зі storage key).
128
- */
100
+ default?: string | number | boolean | null;
101
+ json?: true;
102
+ columns?: Record<string, ColumnType>;
103
+ hidden?: boolean | Condition;
104
+ }
129
105
  export declare function group(o: {
130
106
  key?: string;
107
+ label?: string;
108
+ fields: LayoutEl[];
131
109
  multiple?: boolean;
132
110
  required?: boolean;
133
- unique?: string[];
111
+ rules?: {
112
+ unique?: string[];
113
+ fixed?: boolean;
114
+ };
115
+ view?: {
116
+ display?: GroupDisplay;
117
+ kind?: string;
118
+ icon?: string;
119
+ };
120
+ }): GroupEl;
121
+ export declare function row(o: {
134
122
  label?: string;
135
- icon?: string;
136
- fields: (FieldItem | StaticEl | PseudoEl)[];
123
+ fields: LayoutEl[];
124
+ view?: {
125
+ icon?: string;
126
+ };
127
+ }): GroupEl;
128
+ export declare function table(o: {
129
+ key: string;
130
+ label: string;
131
+ fields: LayoutEl[];
132
+ rules?: {
133
+ unique?: string[];
134
+ };
135
+ required?: boolean;
136
+ view?: {
137
+ icon?: string;
138
+ };
139
+ }): GroupEl;
140
+ export declare function sheet(o: {
141
+ label?: string;
142
+ fields: LayoutEl[][];
143
+ view?: {
144
+ icon?: string;
145
+ };
146
+ }): GroupEl;
147
+ export declare function url(o: {
148
+ key: string;
149
+ label?: string;
150
+ required?: boolean;
151
+ }): GroupEl;
152
+ type ContainerFactory = typeof row | typeof group | typeof table;
153
+ export declare function keyed(o: {
154
+ key: string;
155
+ label: string;
156
+ container?: ContainerFactory;
157
+ by: FieldItem;
158
+ fields: LayoutEl[];
159
+ fixed?: boolean;
160
+ unique?: string[];
161
+ required?: boolean;
162
+ view?: {
163
+ icon?: string;
164
+ };
137
165
  }): GroupEl;
138
166
  export declare const isStorageGroup: (g: GroupEl) => boolean;
139
167
  export declare const isCollectionGroup: (g: GroupEl) => boolean;
140
168
  export declare const isEmbeddedGroup: (g: GroupEl) => boolean;
141
- /** Горизонтальний розділювач. */
142
169
  export declare function divider(): DividerEl;
143
- /** Довідковий markdown-блок за i18n-ключем. */
170
+ export declare function brk(): BreakEl;
144
171
  export declare function info(textKey: string): InfoEl;
145
- /** Кнопка-дія: викликає обробник, зареєстрований у actionRegistry під ключем `value`. */
146
172
  export declare function button(o: {
147
173
  label: string;
148
174
  value: string;
149
175
  icon?: string;
150
176
  variant?: ButtonEl['variant'];
151
177
  }): ButtonEl;
152
- /** Валідація/поведінка поля (не перемикає віджет). */
153
- export interface FieldConfig {
154
- min?: number;
155
- max?: number;
156
- step?: number;
157
- pattern?: string;
158
- messageKey?: string;
159
- granularity?: 'minute' | 'hour' | 'day' | 'month' | 'year' | 'second';
160
- language?: string;
161
- }
162
- /** Джерело варіантів/одиниць: іменоване (string) або inline (array). */
163
178
  export type FieldOptions = string | unknown[];
164
- /** Спільні opts для всіх фабрик. key → FieldItem, value → StaticEl, обидва відсутні → FieldMeta. */
165
179
  export interface FieldCoreOpts {
166
- /** Ім'я колонки БД. Якщо вказано — фабрика повертає FieldItem. */
167
180
  key?: string;
168
- /** Статичне значення (вже розпарсений об'єкт). Якщо вказано — повертає StaticEl. */
169
181
  value?: unknown;
170
- /** Валідація/поведінка поля (не перемикає віджет). */
171
- config?: FieldConfig;
172
- /** Підказка ширини поля в 12-кол гріді (1–12). Рендер може відкинути. */
173
- span?: number;
174
- /** Прибрати per-field кнопки edit/save/cancel; редагування — лише через editAll/group. */
175
- noEditControl?: boolean;
182
+ label?: string;
183
+ rules?: Rules;
184
+ view?: View;
185
+ default?: string | number | boolean | null;
186
+ required?: boolean | Condition;
187
+ multiple?: boolean;
176
188
  }
177
- /** Обгортає FieldMeta у FieldItem/StaticEl залежно від opts.key/opts.value. */
178
189
  export declare function wrapKey(opts: {
179
190
  key?: string;
180
191
  value?: unknown;
181
- span?: number;
182
192
  noEditControl?: boolean;
193
+ default?: string | number | boolean | null;
194
+ hidden?: boolean | Condition;
183
195
  }, meta: FieldMeta): FieldItem | StaticEl | FieldMeta;
184
196
  export interface FieldMeta extends FieldClient {
185
197
  column: ColumnType;
186
198
  zod: z.ZodTypeAny;
187
199
  }
188
- /** Усі мови ISO 639-1 (native-назви як label). Джерело — пакет `iso-639-1`. */
189
- export declare const LANGUAGES: {
190
- code: string;
191
- name: string;
192
- }[];
193
- /** Стать — спільний optionList 'sex' (реєструє plugin-core). i18n: core.sex.*. */
194
- export declare const SEX_OPTIONS: [{
195
- readonly value: "M";
196
- readonly title: "core.sex.M";
197
- }, {
198
- readonly value: "F";
199
- readonly title: "core.sex.F";
200
- }, {
201
- readonly value: "other";
202
- readonly title: "core.sex.other";
203
- }];
204
- /** Структуроване повідомлення для zod: JSON {code, params}. Декодує mutate.ts. */
205
- export declare function vmsg(code: string, params?: Record<string, unknown>): string;
206
- /** Контекст zod v4 error-map (звужений до потрібних полів). */
207
- type ZErrCtx = {
208
- input?: unknown;
209
- code?: string;
210
- };
211
- /** v4 error-map: повідомлення для відсутнього значення (колишній required_error). */
212
- export declare function reqErr(code?: string): {
213
- error: (iss: ZErrCtx) => string | undefined;
214
- };
215
- /** v4 error-map: повідомлення для невалідного типу (колишній invalid_type_error). */
216
- export declare function typeErr(code?: string): {
217
- error: (iss: ZErrCtx) => string | undefined;
218
- };
219
- /** v4 error-map: required + invalid_type разом (колишні required_error + invalid_type_error). */
220
- export declare function reqTypeErr(): {
221
- error: (iss: ZErrCtx) => string | undefined;
222
- };
223
- /**
224
- * Спільна фабрика для полів, що зберігають JSON-рядок і валідуються вкладеною
225
- * zod-схемою: parse → inner.safeParse → при невдачі issue з кодом `code`,
226
- * при невалідному JSON — код 'json'. Уникає дублювання try/parse/superRefine.
227
- */
228
- export declare function jsonRefined(inner: z.ZodTypeAny, code: string): z.ZodTypeAny;
229
- export declare function optionalize(schema: z.ZodTypeAny, required: boolean): z.ZodTypeAny;
200
+ export declare function isJsonStored(field: FieldMeta | FieldClient): boolean;
201
+ export { LANGUAGES, SEX_OPTIONS, WEEKDAY_OPTIONS } from './fields/constants.ts';
202
+ export { parseUrl, buildUrl, hrefOf, type UrlValue } from './fields/url.ts';
230
203
  export declare function applyMultiple(base: FieldMeta, multiple: boolean): FieldMeta;
231
204
  export interface StringOpts extends FieldCoreOpts {
232
- label?: string;
233
- required?: boolean;
234
- multiple?: boolean;
235
205
  }
236
- /** Однорядковий текст. Довільний pattern/messageKey — через `config`. Багаторядковий — `text()`. */
237
206
  export declare function string(o: StringOpts & {
238
207
  key: string;
239
208
  }): FieldItem;
@@ -245,14 +214,33 @@ export declare function string(o: StringOpts & {
245
214
  key?: undefined;
246
215
  value?: undefined;
247
216
  }): FieldMeta;
248
- /** Багаторядковий текст (kind 'textarea'). Однорядковий — `string()`. Без `multiple`. */
217
+ export interface LocalPathOpts extends FieldCoreOpts {
218
+ }
219
+ export interface LocalFileOpts extends LocalPathOpts {
220
+ }
221
+ export declare function localDir(o: LocalPathOpts & {
222
+ key: string;
223
+ }): FieldItem;
224
+ export declare function localDir(o: LocalPathOpts & {
225
+ value: unknown;
226
+ key?: undefined;
227
+ }): StaticEl;
228
+ export declare function localDir(o: LocalPathOpts & {
229
+ key?: undefined;
230
+ value?: undefined;
231
+ }): FieldMeta;
232
+ export declare function localFile(o: LocalFileOpts & {
233
+ key: string;
234
+ }): FieldItem;
235
+ export declare function localFile(o: LocalFileOpts & {
236
+ value: unknown;
237
+ key?: undefined;
238
+ }): StaticEl;
239
+ export declare function localFile(o: LocalFileOpts & {
240
+ key?: undefined;
241
+ value?: undefined;
242
+ }): FieldMeta;
249
243
  export interface TextOpts extends FieldCoreOpts {
250
- label?: string;
251
- required?: boolean;
252
- /** @deprecated use config.min */
253
- min?: number;
254
- /** @deprecated use config.max */
255
- max?: number;
256
244
  }
257
245
  export declare function text(o: TextOpts & {
258
246
  key: string;
@@ -265,12 +253,30 @@ export declare function text(o: TextOpts & {
265
253
  key?: undefined;
266
254
  value?: undefined;
267
255
  }): FieldMeta;
256
+ export declare function i18n(o: TextOpts & {
257
+ key: string;
258
+ }): FieldItem;
259
+ export declare function i18n(o: TextOpts & {
260
+ value: unknown;
261
+ key?: undefined;
262
+ }): StaticEl;
263
+ export declare function i18n(o: TextOpts & {
264
+ key?: undefined;
265
+ value?: undefined;
266
+ }): FieldMeta;
267
+ export declare function smallText(o: TextOpts & {
268
+ key: string;
269
+ }): FieldItem;
270
+ export declare function smallText(o: TextOpts & {
271
+ value: unknown;
272
+ key?: undefined;
273
+ }): StaticEl;
274
+ export declare function smallText(o: TextOpts & {
275
+ key?: undefined;
276
+ value?: undefined;
277
+ }): FieldMeta;
268
278
  export interface RealOpts extends FieldCoreOpts {
269
- label?: string;
270
- required?: boolean;
271
- multiple?: boolean;
272
279
  }
273
- /** Дійсне число (column 'real'). min/max/step — через `config`. */
274
280
  export declare function real(o: RealOpts & {
275
281
  key: string;
276
282
  }): FieldItem;
@@ -283,11 +289,7 @@ export declare function real(o: RealOpts & {
283
289
  value?: undefined;
284
290
  }): FieldMeta;
285
291
  export interface IntOpts extends FieldCoreOpts {
286
- label?: string;
287
- required?: boolean;
288
- multiple?: boolean;
289
292
  }
290
- /** Ціле число (column 'integer'). min/max/step — через `config`. */
291
293
  export declare function int(o: IntOpts & {
292
294
  key: string;
293
295
  }): FieldItem;
@@ -300,11 +302,6 @@ export declare function int(o: IntOpts & {
300
302
  value?: undefined;
301
303
  }): FieldMeta;
302
304
  export interface DateOpts extends FieldCoreOpts {
303
- label?: string;
304
- required?: boolean;
305
- min?: string;
306
- max?: string;
307
- multiple?: boolean;
308
305
  }
309
306
  export declare function date(o: DateOpts & {
310
307
  key: string;
@@ -318,9 +315,6 @@ export declare function date(o: DateOpts & {
318
315
  value?: undefined;
319
316
  }): FieldMeta;
320
317
  export interface TimeOpts extends FieldCoreOpts {
321
- label?: string;
322
- required?: boolean;
323
- multiple?: boolean;
324
318
  }
325
319
  export declare function time(o: TimeOpts & {
326
320
  key: string;
@@ -334,9 +328,6 @@ export declare function time(o: TimeOpts & {
334
328
  value?: undefined;
335
329
  }): FieldMeta;
336
330
  export interface DateTimeOpts extends FieldCoreOpts {
337
- label?: string;
338
- required?: boolean;
339
- multiple?: boolean;
340
331
  }
341
332
  export declare function datetime(o: DateTimeOpts & {
342
333
  key: string;
@@ -350,7 +341,6 @@ export declare function datetime(o: DateTimeOpts & {
350
341
  value?: undefined;
351
342
  }): FieldMeta;
352
343
  export interface BooleanOpts extends FieldCoreOpts {
353
- label?: string;
354
344
  }
355
345
  export declare function boolean(o: BooleanOpts & {
356
346
  key: string;
@@ -364,8 +354,6 @@ export declare function boolean(o: BooleanOpts & {
364
354
  value?: undefined;
365
355
  }): FieldMeta;
366
356
  export interface TriStateOpts extends FieldCoreOpts {
367
- label?: string;
368
- required?: boolean;
369
357
  }
370
358
  export declare function triState(o: TriStateOpts & {
371
359
  key: string;
@@ -379,16 +367,7 @@ export declare function triState(o: TriStateOpts & {
379
367
  value?: undefined;
380
368
  }): FieldMeta;
381
369
  export interface SelectOpts extends FieldCoreOpts {
382
- label?: string;
383
- required?: boolean;
384
- /**
385
- * Джерело варіантів: рядок (іменований список з PluginManifest.optionLists)
386
- * або inline-масив OptionItem (для невеликих статичних списків).
387
- * Рядок → hints.source (UI отримує з реєстру); масив → inline enum.
388
- * Для прив'язки до записів модуля використовуй `relation({ vault, module })`.
389
- */
390
370
  options?: FieldOptions;
391
- multiple?: boolean;
392
371
  }
393
372
  export declare function select(o: SelectOpts & {
394
373
  key: string;
@@ -402,22 +381,11 @@ export declare function select(o: SelectOpts & {
402
381
  value?: undefined;
403
382
  }): FieldMeta;
404
383
  export interface RelationOpts extends FieldCoreOpts {
405
- label?: string;
406
- required?: boolean;
407
- /** Цільовий модуль записів. */
408
- vault: string;
409
- module: string;
410
- /** `true` → кілька id (JSON-масив); інакше один uuid. */
411
- multiple?: boolean;
412
- /** Поле-мітка цілі (fallback, коли немає views.inline). За замовч. `name`. */
413
- displayKey?: string;
414
- }
415
- /**
416
- * Прив'язка до записів іншого модуля (`{vault, module}`). Зберігає uuid (single)
417
- * або JSON-масив uuid (multiple). Рендериться як RecordInline + пікер записів.
418
- * Раніше це була record-гілка `select()`; винесено в окремий примітив, щоб select
419
- * лишився суто enum/source-списком.
420
- */
384
+ options: {
385
+ vault: string;
386
+ module: string;
387
+ };
388
+ }
421
389
  export declare function relation(o: RelationOpts & {
422
390
  key: string;
423
391
  }): FieldItem;
@@ -429,17 +397,8 @@ export declare function relation(o: RelationOpts & {
429
397
  key?: undefined;
430
398
  value?: undefined;
431
399
  }): FieldMeta;
432
- /**
433
- * Compose-time: підв'язати enum-валідацію source-селекту до значень списку.
434
- * Factory не знає вмісту optionList (списки збираються лише в composeRegistry),
435
- * тому zod source-полів спочатку z.string(); реєстр викликає це для кожного
436
- * такого поля, щоб сервер відхиляв значення поза списком.
437
- * Відтворює повний ланцюг модифікаторів: enum → multiple.
438
- */
439
400
  export declare function bindSelectSourceZod(field: FieldMeta, values: string[]): void;
440
401
  export interface JsonOpts extends FieldCoreOpts {
441
- label?: string;
442
- required?: boolean;
443
402
  }
444
403
  export declare function json(o: JsonOpts & {
445
404
  key: string;
@@ -452,36 +411,22 @@ export declare function json(o: JsonOpts & {
452
411
  key?: undefined;
453
412
  value?: undefined;
454
413
  }): FieldMeta;
455
- /**
456
- * Чекліст — масив пунктів `[{ done: boolean, text: string }]`.
457
- * Для списків справ/покупок/зборів: галочка + текст у кожному рядку.
458
- * multiple: кілька чеклістів в одному полі (масив JSON-рядків, як applyMultiple).
459
- */
460
- export interface ChecklistOpts extends FieldCoreOpts {
461
- label?: string;
462
- required?: boolean;
463
- multiple?: boolean;
414
+ export interface CheckOpts extends FieldCoreOpts {
415
+ slots?: string[];
464
416
  }
465
- export declare function checklist(o: ChecklistOpts & {
417
+ export declare function check(o: CheckOpts & {
466
418
  key: string;
467
- }): FieldItem;
468
- export declare function checklist(o: ChecklistOpts & {
419
+ }): FieldItem | GroupEl;
420
+ export declare function check(o: CheckOpts & {
469
421
  value: unknown;
470
422
  key?: undefined;
471
423
  }): StaticEl;
472
- export declare function checklist(o: ChecklistOpts & {
424
+ export declare function check(o: CheckOpts & {
473
425
  key?: undefined;
474
426
  value?: undefined;
475
427
  }): FieldMeta;
476
428
  export interface MeasuredOpts extends FieldCoreOpts {
477
- label?: string;
478
- required?: boolean;
479
- /**
480
- * Набір одиниць: рядок (іменований пресет з UnitsPreset, напр. 'currency') або
481
- * inline-масив UnitOption. min/max/step/int — через `config`.
482
- */
483
429
  options: FieldOptions;
484
- multiple?: boolean;
485
430
  }
486
431
  export declare function measured(o: MeasuredOpts & {
487
432
  key: string;
@@ -495,14 +440,6 @@ export declare function measured(o: MeasuredOpts & {
495
440
  value?: undefined;
496
441
  }): FieldMeta;
497
442
  export interface MoneyOpts extends FieldCoreOpts {
498
- label?: string;
499
- required?: boolean;
500
- multiple?: boolean;
501
- config?: FieldConfig & {
502
- defaultCurrency?: string;
503
- min?: number;
504
- max?: number;
505
- };
506
443
  }
507
444
  export declare function money(o: MoneyOpts & {
508
445
  key: string;
@@ -516,11 +453,6 @@ export declare function money(o: MoneyOpts & {
516
453
  value?: undefined;
517
454
  }): FieldMeta;
518
455
  export interface CodeFieldOpts extends FieldCoreOpts {
519
- label?: string;
520
- required?: boolean;
521
- config?: FieldConfig & {
522
- defaultLang?: string;
523
- };
524
456
  }
525
457
  export declare function code(o: CodeFieldOpts & {
526
458
  key: string;
@@ -534,8 +466,6 @@ export declare function code(o: CodeFieldOpts & {
534
466
  value?: undefined;
535
467
  }): FieldMeta;
536
468
  export interface GeoOpts extends FieldCoreOpts {
537
- label?: string;
538
- required?: boolean;
539
469
  }
540
470
  export declare function geo(o: GeoOpts & {
541
471
  key: string;
@@ -548,38 +478,21 @@ export declare function geo(o: GeoOpts & {
548
478
  key?: undefined;
549
479
  value?: undefined;
550
480
  }): FieldMeta;
551
- export interface PerWeekdayOpts extends FieldCoreOpts {
552
- label?: string;
553
- required?: boolean;
554
- }
555
- export declare function perWeekday(o: PerWeekdayOpts & {
481
+ export declare function perWeekday(o: {
556
482
  key: string;
557
- }): FieldItem;
558
- export declare function perWeekday(o: PerWeekdayOpts & {
559
- value: unknown;
560
- key?: undefined;
561
- }): StaticEl;
562
- export declare function perWeekday(o: PerWeekdayOpts & {
563
- key?: undefined;
564
- value?: undefined;
565
- }): FieldMeta;
566
- /** Серіалізований сабфілд для клієнта (period/group): key + повний FieldClient. */
483
+ label: string;
484
+ rules?: {
485
+ min?: number;
486
+ max?: number;
487
+ step?: number;
488
+ };
489
+ }): GroupEl;
567
490
  export type RowSubField = FieldClient & {
568
491
  key: string;
569
492
  };
570
- /**
571
- * Віртуальний індикатор у композитних полях (group/period): показує поля related-запису
572
- * сусіднього relation-сабфілда (`from`) і, опційно, порівнює measured-значення.
573
- * Не зберігається, не валідується, у формі не редагується.
574
- */
575
493
  export interface LookupOpts extends FieldCoreOpts {
576
- label?: string;
577
- /** Ключ сусіднього relation-сабфілда в рядку. */
578
494
  from: string;
579
- /** Поля related-запису для відображення. */
580
495
  pick: string[];
581
- /** Сусідній measured-ключ → бейдж ✓/✗/частково (порівняння з pick[0]). */
582
- compareWith?: string;
583
496
  }
584
497
  export declare function lookup(o: LookupOpts & {
585
498
  key: string;
@@ -592,26 +505,11 @@ export declare function lookup(o: LookupOpts & {
592
505
  key?: undefined;
593
506
  value?: undefined;
594
507
  }): FieldMeta;
595
- /**
596
- * Відновлює FieldMeta з клієнтського FieldClient (для рекурсивного рендеру
597
- * сабфілдів групових полів через FieldInput/FieldValue). zod тут не потрібен —
598
- * валідація відбувається на рівні схеми батьківського поля.
599
- */
600
508
  export declare function clientToMeta(fc: FieldClient): FieldMeta;
601
- /**
602
- * Період дат {from, until}. multiple → масив періодів.
603
- * Самодостатній JSON-композит (раніше будувався на field.row, тепер незалежний).
604
- * Storage: `[{from,until}]`.
605
- */
606
- type PeriodOpts = {
607
- label?: string;
608
- required?: boolean;
609
- multiple?: boolean;
610
- granularity?: 'month' | 'day' | 'datetime';
611
- } & FieldCoreOpts;
509
+ type PeriodOpts = FieldCoreOpts;
612
510
  export declare function period(o: PeriodOpts & {
613
511
  key: string;
614
- }): FieldItem;
512
+ }): FieldItem | GroupEl;
615
513
  export declare function period(o: PeriodOpts & {
616
514
  value: unknown;
617
515
  key?: undefined;
@@ -620,13 +518,8 @@ export declare function period(o: PeriodOpts & {
620
518
  key?: undefined;
621
519
  value?: undefined;
622
520
  }): FieldMeta;
623
- /** Файл/медіа — спільний інтерфейс для всієї file-родини. */
624
521
  export interface FileOpts extends FieldCoreOpts {
625
- label?: string;
626
- required?: boolean;
627
- multiple?: boolean;
628
522
  }
629
- /** @deprecated Use FileOpts */
630
523
  export type ImageOpts = FileOpts;
631
524
  export declare function file(o: FileOpts & {
632
525
  key: string;
@@ -694,46 +587,38 @@ export declare function media(o: FileOpts & {
694
587
  key?: undefined;
695
588
  value?: undefined;
696
589
  }): FieldMeta;
697
- /**
698
- * Загальний тип «ключ/значення».
699
- * Зберігає JSON-масив `[{ key, value }]`.
700
- * - multiple=false UI обмежує до однієї пари (масив усе одно).
701
- * - option → вкладене поле-визначення для типу VALUE (FieldMeta).
702
- * Default: plain string. Задає віджет/маскування значення.
703
- * Приклад: field.keyValue({ option: field.password() }) — маскування.
704
- *
705
- * Приклад: secrets: field.keyValue({ label: 'Секрети', multiple: true, option: field.password() })
706
- */
707
- export interface KeyValueOpts extends FieldCoreOpts {
708
- label?: string;
709
- required?: boolean;
710
- /** Дозволити більше однієї пари (default: true). */
711
- multiple?: boolean;
712
- /** Тип value-комірки (будь-який FieldMeta). Default: string. */
713
- option?: FieldMeta;
714
- /** Підписи колонок у формі. */
715
- keyLabel?: string;
716
- valueLabel?: string;
717
- }
718
- export declare function keyValue(o: KeyValueOpts & {
590
+ export declare function avatar(o: FileOpts & {
591
+ key: string;
592
+ }): FieldItem;
593
+ export declare function avatar(o: FileOpts & {
594
+ value: unknown;
595
+ key?: undefined;
596
+ }): StaticEl;
597
+ export declare function avatar(o: FileOpts & {
598
+ key?: undefined;
599
+ value?: undefined;
600
+ }): FieldMeta;
601
+ export declare function cover(o: FileOpts & {
719
602
  key: string;
720
603
  }): FieldItem;
721
- export declare function keyValue(o: KeyValueOpts & {
604
+ export declare function cover(o: FileOpts & {
722
605
  value: unknown;
723
606
  key?: undefined;
724
607
  }): StaticEl;
725
- export declare function keyValue(o: KeyValueOpts & {
608
+ export declare function cover(o: FileOpts & {
726
609
  key?: undefined;
727
610
  value?: undefined;
728
611
  }): FieldMeta;
612
+ export interface KeyValueOpts extends FieldCoreOpts {
613
+ option?: FieldMeta;
614
+ keyLabel?: string;
615
+ valueLabel?: string;
616
+ container?: ContainerFactory;
617
+ }
618
+ export declare function keyValue(raw: KeyValueOpts & {
619
+ key: string;
620
+ }): GroupEl;
729
621
  export interface RangeOpts extends FieldCoreOpts {
730
- label?: string;
731
- required?: boolean;
732
- config?: FieldConfig & {
733
- min?: number;
734
- max?: number;
735
- step?: number;
736
- };
737
622
  }
738
623
  export declare function numberRange(o: RangeOpts & {
739
624
  key: string;
@@ -757,9 +642,26 @@ export declare function realRange(o: RangeOpts & {
757
642
  key?: undefined;
758
643
  value?: undefined;
759
644
  }): FieldMeta;
760
- export declare const field: {
645
+ export interface EmbedOpts extends FieldCoreOpts {
646
+ }
647
+ export declare function embed(o: EmbedOpts & {
648
+ key: string;
649
+ }): FieldItem;
650
+ export declare function embed(o: EmbedOpts & {
651
+ value: unknown;
652
+ key?: undefined;
653
+ }): StaticEl;
654
+ export declare function embed(o: EmbedOpts & {
655
+ key?: undefined;
656
+ value?: undefined;
657
+ }): FieldMeta;
658
+ declare const PRIMITIVES: {
761
659
  string: typeof string;
762
660
  text: typeof text;
661
+ i18n: typeof i18n;
662
+ smallText: typeof smallText;
663
+ localDir: typeof localDir;
664
+ localFile: typeof localFile;
763
665
  real: typeof real;
764
666
  int: typeof int;
765
667
  date: typeof date;
@@ -770,7 +672,7 @@ export declare const field: {
770
672
  select: typeof select;
771
673
  relation: typeof relation;
772
674
  json: typeof json;
773
- checklist: typeof checklist;
675
+ check: typeof check;
774
676
  measured: typeof measured;
775
677
  money: typeof money;
776
678
  code: typeof code;
@@ -784,34 +686,22 @@ export declare const field: {
784
686
  video: typeof video;
785
687
  image: typeof image;
786
688
  media: typeof media;
689
+ avatar: typeof avatar;
690
+ cover: typeof cover;
691
+ embed: typeof embed;
787
692
  keyValue: typeof keyValue;
788
693
  numberRange: typeof numberRange;
789
694
  realRange: typeof realRange;
790
695
  group: typeof group;
696
+ row: typeof row;
697
+ table: typeof table;
698
+ sheet: typeof sheet;
699
+ keyed: typeof keyed;
700
+ url: typeof url;
791
701
  divider: typeof divider;
702
+ break: typeof brk;
792
703
  info: typeof info;
793
704
  button: typeof button;
794
- } & {
795
- email: typeof import("./field-presets.js").email;
796
- url: typeof import("./field-presets.js").url;
797
- tel: typeof import("./field-presets.js").tel;
798
- slug: typeof import("./field-presets.js").slug;
799
- color: typeof import("./field-presets.js").color;
800
- colorname: typeof import("./field-presets.js").colorname;
801
- title: typeof import("./field-presets.js").title;
802
- password: typeof import("./field-presets.js").password;
803
- tags: typeof import("./field-presets.js").tags;
804
- imei: typeof import("./field-presets.js").imei;
805
- mac: typeof import("./field-presets.js").mac;
806
- iban: typeof import("./field-presets.js").iban;
807
- markdown: typeof import("./field-presets.js").markdown;
808
- snippet: typeof import("./field-presets.js").snippet;
809
- rating: typeof import("./field-presets.js").rating;
810
- duration: typeof import("./field-presets.js").duration;
811
- percent: typeof import("./field-presets.js").percent;
812
- year: typeof import("./field-presets.js").year;
813
- country: typeof import("./field-presets.js").country;
814
705
  };
706
+ export declare const field: typeof PRIMITIVES & typeof presets;
815
707
  export declare function toClient(field: FieldMeta): FieldClient;
816
- export {};
817
- //# sourceMappingURL=fields.d.ts.map