@tempots/beatui 0.75.0 → 0.76.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.
@@ -11,9 +11,17 @@ export declare function JSONSchemaGenericControl<T>({ ctx, controller, }: {
11
11
  /**
12
12
  * Main entry point for JSON Schema controls
13
13
  */
14
- export declare function JSONSchemaControl<T>({ schema, controller, ajv, widgetRegistry, }: {
14
+ export declare function JSONSchemaControl<T>({ schema, controller, ajv, widgetRegistry, setStatus, formValue, validationMode, submitting, }: {
15
15
  schema: JSONSchemaDefinition;
16
16
  controller: Controller<T>;
17
17
  ajv?: import('ajv').default;
18
18
  widgetRegistry?: import('../widgets/widget-customization').WidgetRegistry;
19
+ /** Function to set the form's validation status, available to custom widgets */
20
+ setStatus?: (status: import('../../form').ControllerValidation) => void;
21
+ /** Signal containing the entire form's current value */
22
+ formValue?: import('@tempots/dom').Signal<unknown>;
23
+ /** Current validation mode */
24
+ validationMode?: import('../../form').ValidationMode;
25
+ /** Signal indicating whether the form is currently submitting */
26
+ submitting?: import('@tempots/dom').Signal<boolean>;
19
27
  }): Renderable;
@@ -1,5 +1,5 @@
1
1
  import { type SchemaObject } from 'ajv';
2
- import { Value, Renderable } from '@tempots/dom';
2
+ import { Value, Renderable, Signal } from '@tempots/dom';
3
3
  import { Controller, ControllerValidation } from '../form';
4
4
  import { type CustomWidgets } from './widgets/widget-customization';
5
5
  /**
@@ -93,8 +93,14 @@ export interface JSONSchemaFormProps<T> extends JSONSchemaFormExternalOptions {
93
93
  * @default true
94
94
  */
95
95
  applySchemaDefaults?: boolean;
96
+ /**
97
+ * Optional signal indicating whether the form is currently submitting.
98
+ * When provided, custom widgets can disable themselves during submission.
99
+ * This is passed through to custom widgets via ctx.submitting.
100
+ */
101
+ submitting?: Signal<boolean>;
96
102
  }
97
- export declare function JSONSchemaForm<T>({ schema, initialValue, externalSchemas, refResolver, sanitizeAdditional, validationMode, validateDebounceMs, customWidgets, applySchemaDefaults, }: JSONSchemaFormProps<T>, fn: ({ Form, controller, setStatus, }: {
103
+ export declare function JSONSchemaForm<T>({ schema, initialValue, externalSchemas, refResolver, sanitizeAdditional, validationMode, validateDebounceMs, customWidgets, applySchemaDefaults, submitting, }: JSONSchemaFormProps<T>, fn: ({ Form, controller, setStatus, }: {
98
104
  Form: Renderable;
99
105
  controller: Controller<T>;
100
106
  setStatus: (result: ControllerValidation) => void;
@@ -1,6 +1,9 @@
1
1
  import type Ajv from 'ajv';
2
+ import type { Signal } from '@tempots/dom';
2
3
  import type { JSONSchemaDefinition, JSONSchemaType, SchemaConflict, NotViolation } from './schema-types';
3
4
  import type { WidgetRegistry } from './widgets/widget-customization';
5
+ import type { ControllerValidation } from '../form/controller/controller-validation';
6
+ import type { ValidationMode } from '../form/controller/union-controller';
4
7
  export type { JSONSchema, JSONSchemaDefinition, JSONSchemaType, SchemaConflict, AllOfMergeResult, NotViolation, } from './schema-types';
5
8
  export { mergeAllOf } from './schema-merge';
6
9
  export { evaluateNotViolation, composeEffectiveObjectSchema, evaluateIfThenElseOverlay, getEvaluatedProperties, } from './schema-conditionals';
@@ -15,6 +18,26 @@ export type SchemaContextOptions = {
15
18
  schemaConflicts?: readonly SchemaConflict[];
16
19
  notViolations?: readonly NotViolation[];
17
20
  widgetRegistry?: WidgetRegistry;
21
+ /**
22
+ * Function to set the form's validation status.
23
+ * Available for custom widgets that need to perform their own validation.
24
+ */
25
+ setStatus?: (status: ControllerValidation) => void;
26
+ /**
27
+ * Signal containing the entire form's current value.
28
+ * Useful for cross-field validation or conditional rendering.
29
+ */
30
+ formValue?: Signal<unknown>;
31
+ /**
32
+ * Current validation mode ('eager', 'onTouched', 'onSubmit').
33
+ * Custom widgets may want to behave differently based on this.
34
+ */
35
+ validationMode?: ValidationMode;
36
+ /**
37
+ * Signal indicating whether the form is currently submitting.
38
+ * Widgets should typically disable during submission.
39
+ */
40
+ submitting?: Signal<boolean>;
18
41
  };
19
42
  export declare class SchemaContext {
20
43
  readonly schema: JSONSchemaDefinition;
@@ -27,6 +50,26 @@ export declare class SchemaContext {
27
50
  readonly schemaConflicts: readonly SchemaConflict[];
28
51
  readonly notViolations: readonly NotViolation[];
29
52
  readonly widgetRegistry: WidgetRegistry | undefined;
53
+ /**
54
+ * Function to set the form's validation status.
55
+ * Available for custom widgets that need to perform their own validation.
56
+ */
57
+ readonly setStatus: ((status: ControllerValidation) => void) | undefined;
58
+ /**
59
+ * Signal containing the entire form's current value.
60
+ * Useful for cross-field validation or conditional rendering.
61
+ */
62
+ readonly formValue: Signal<unknown> | undefined;
63
+ /**
64
+ * Current validation mode ('eager', 'onTouched', 'onSubmit').
65
+ * Custom widgets may want to behave differently based on this.
66
+ */
67
+ readonly validationMode: ValidationMode | undefined;
68
+ /**
69
+ * Signal indicating whether the form is currently submitting.
70
+ * Widgets should typically disable during submission.
71
+ */
72
+ readonly submitting: Signal<boolean> | undefined;
30
73
  constructor(options: SchemaContextOptions);
31
74
  readonly with: (options: Partial<SchemaContextOptions>) => SchemaContext;
32
75
  readonly append: (segment: PropertyKey) => SchemaContext;
@@ -1,7 +1,8 @@
1
- import type { Renderable } from '@tempots/dom';
2
- import type { Controller } from '../../form';
1
+ import type { Renderable, Signal } from '@tempots/dom';
2
+ import type { Controller, ControllerValidation } from '../../form';
3
3
  import type { SchemaContext, JSONSchema } from '../schema-context';
4
4
  import { type ResolvedWidget } from './utils';
5
+ import type { ValidationMode } from '../../form/controller/union-controller';
5
6
  /**
6
7
  * Widget factory function signature
7
8
  */
@@ -9,6 +10,28 @@ export type WidgetFactory<T = unknown> = (props: {
9
10
  controller: Controller<T>;
10
11
  ctx: SchemaContext;
11
12
  options?: Record<string, unknown>;
13
+ /**
14
+ * Function to set the form's validation status.
15
+ * Use this for advanced widgets that need custom validation.
16
+ * Also available via `ctx.setStatus`.
17
+ */
18
+ setStatus?: (status: ControllerValidation) => void;
19
+ /**
20
+ * Signal containing the entire form's current value.
21
+ * Useful for cross-field validation or conditional rendering.
22
+ * Also available via `ctx.formValue`.
23
+ */
24
+ formValue?: Signal<unknown>;
25
+ /**
26
+ * Current validation mode ('eager', 'onTouched', 'onSubmit').
27
+ * Also available via `ctx.validationMode`.
28
+ */
29
+ validationMode?: ValidationMode;
30
+ /**
31
+ * Signal indicating whether the form is currently submitting.
32
+ * Also available via `ctx.submitting`.
33
+ */
34
+ submitting?: Signal<boolean>;
12
35
  }) => Renderable;
13
36
  /**
14
37
  * Widget registration entry
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/beatui",
3
- "version": "0.75.0",
3
+ "version": "0.76.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.es.js",