@graffiticode/l0000-view 0.1.1 → 0.1.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.
package/dist/index.d.ts CHANGED
@@ -11,19 +11,38 @@ export declare const Form: ({ state }: FormProps) => JSX_2.Element;
11
11
 
12
12
  export declare type FormComponent = ComponentType<FormProps>;
13
13
 
14
+ /**
15
+ * Which model the Form renders from.
16
+ *
17
+ * `live` — everything, including the Form's own edits coming back (a controlled Form).
18
+ * `loaded` — only the model as last loaded from outside the Form (an uncontrolled Form that
19
+ * seeds itself from the model and owns its editing state thereafter).
20
+ */
21
+ export declare type FormModel = "live" | "loaded";
22
+
14
23
  export declare interface FormProps {
15
24
  state: {
16
25
  data: any;
17
26
  errors: CompileError[];
18
- apply: (action: {
19
- type: string;
20
- args?: any;
21
- }) => void;
27
+ apply: (action: StateAction) => void;
22
28
  };
23
29
  }
24
30
 
25
- export declare const View: ({ Form }: {
31
+ /**
32
+ * A language's extra reducer cases. Return the next data model to claim an action, or
33
+ * `undefined` to fall through to the generic handling below.
34
+ */
35
+ export declare type LanguageReducer = (data: any, action: StateAction) => any | undefined;
36
+
37
+ export declare interface StateAction {
38
+ type: string;
39
+ args?: any;
40
+ }
41
+
42
+ export declare const View: ({ Form, reduce, formModel, }: {
26
43
  Form: FormComponent;
44
+ reduce?: LanguageReducer;
45
+ formModel?: FormModel;
27
46
  }) => JSX_2.Element;
28
47
 
29
48
  export { }