graphql-form 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,15 @@
1
- /// <reference types="react" />
2
1
  import { PassedFormProps, CastToWidgetSettingsPassedForm } from "./models";
3
- export declare function createWidget<Props>({ name, Component, Settings, requirements, }: {
2
+ import React from 'react';
3
+ export declare function createWidget<Props>({ name, Component, Settings, Description, requirements, }: {
4
4
  name: string;
5
5
  Component: React.FC<PassedFormProps<Props>>;
6
6
  Settings?: React.FC<CastToWidgetSettingsPassedForm<Props>>;
7
+ Description?: React.FC;
7
8
  requirements: (props: PassedFormProps) => boolean;
8
9
  }): {
9
- Component: import("react").FC<PassedFormProps<Props>>;
10
- Settings: import("react").FC<CastToWidgetSettingsPassedForm<Props>> | undefined;
10
+ Component: React.FC<PassedFormProps<Props>>;
11
+ Settings: React.FC<CastToWidgetSettingsPassedForm<Props>> | undefined;
12
+ Description: React.FC<{}> | undefined;
11
13
  requirements: (props: PassedFormProps) => boolean;
12
14
  props: Props;
13
15
  name: string;
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createWidget = void 0;
4
4
  function createWidget(_a) {
5
- var name = _a.name, Component = _a.Component, Settings = _a.Settings, requirements = _a.requirements;
5
+ var name = _a.name, Component = _a.Component, Settings = _a.Settings, Description = _a.Description, requirements = _a.requirements;
6
6
  return {
7
7
  Component: Component,
8
8
  Settings: Settings,
9
+ Description: Description,
9
10
  requirements: requirements,
10
11
  props: {},
11
12
  name: name,
@@ -1 +1 @@
1
- {"version":3,"file":"createWidget.js","sourceRoot":"","sources":["../src/createWidget.tsx"],"names":[],"mappings":";;;AAEA,SAAgB,YAAY,CAAQ,EAUnC;QATG,IAAI,UAAA,EACJ,SAAS,eAAA,EACT,QAAQ,cAAA,EACR,YAAY,kBAAA;IAOZ,OAAO;QACH,SAAS,WAAA;QACT,QAAQ,UAAA;QACR,YAAY,cAAA;QACZ,KAAK,EAAE,EAAW;QAClB,IAAI,MAAA;KACP,CAAC;AACN,CAAC;AAlBD,oCAkBC"}
1
+ {"version":3,"file":"createWidget.js","sourceRoot":"","sources":["../src/createWidget.tsx"],"names":[],"mappings":";;;AAGA,SAAgB,YAAY,CAAQ,EAYnC;QAXG,IAAI,UAAA,EACJ,SAAS,eAAA,EACT,QAAQ,cAAA,EACR,WAAW,iBAAA,EACX,YAAY,kBAAA;IAQZ,OAAO;QACH,SAAS,WAAA;QACT,QAAQ,UAAA;QACR,WAAW,aAAA;QACX,YAAY,cAAA;QACZ,KAAK,EAAE,EAAW;QAClB,IAAI,MAAA;KACP,CAAC;AACN,CAAC;AArBD,oCAqBC"}
package/lib/models.d.ts CHANGED
@@ -7,7 +7,7 @@ export declare type FormLabelProps = React.FC<PassedFormProps & {
7
7
  }>;
8
8
  export declare type WidgetSavedData = {
9
9
  widget: string;
10
- [x: string]: any;
10
+ [x: string]: unknown;
11
11
  };
12
12
  export declare type SavedWidgets = {
13
13
  [selector: string]: WidgetSavedData | undefined;
@@ -15,14 +15,14 @@ export declare type SavedWidgets = {
15
15
  export declare type SavedForms = {
16
16
  [selector: string]: FormObject;
17
17
  };
18
- export declare type PassedFormProps<WidgetData = any> = {
18
+ export declare type PassedFormProps<WidgetData = unknown> = {
19
19
  f: ParserField;
20
20
  nodes: ParserField[];
21
21
  formObject: FormObject;
22
22
  onChange: (formObject: FormObject) => void;
23
23
  changeWidget: (widgetData: WidgetSavedData | undefined, path: string) => void;
24
24
  required?: boolean;
25
- runQuery: (q: string) => Promise<any>;
25
+ runQuery: (q: string) => Promise<unknown>;
26
26
  widgetComponents: WidgetType[];
27
27
  currentPath: string;
28
28
  widgets?: SavedWidgets;
@@ -53,13 +53,13 @@ export declare type FormDisplayerProps = Omit<PassedFormProps, 'formObject' | 'o
53
53
  };
54
54
  export declare type FormLibraryProps = Omit<FormDisplayerProps, 'required' | 'components'>;
55
55
  export declare type CastToWidgetSettingsPassedForm<WidgetData> = PassedFormProps<Partial<WidgetData>> & {
56
- close: () => void;
56
+ widgetSettingsChange: (data: WidgetData) => void;
57
57
  };
58
58
  export declare type WidgetType = {
59
59
  Component: React.FC<PassedFormProps>;
60
- Settings: React.FC<CastToWidgetSettingsPassedForm<any>> | undefined;
60
+ Settings: React.FC<CastToWidgetSettingsPassedForm<unknown>> | undefined;
61
61
  requirements: (props: PassedFormProps) => boolean;
62
- props?: Record<string, any>;
62
+ props?: Record<string, unknown>;
63
63
  name: string;
64
64
  };
65
65
  export declare type FormValue = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-form",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Easy form creation with GraphQL Editor and React",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,19 +1,23 @@
1
1
  import { PassedFormProps, CastToWidgetSettingsPassedForm } from '@/models';
2
+ import React from 'react';
2
3
 
3
4
  export function createWidget<Props>({
4
5
  name,
5
6
  Component,
6
7
  Settings,
8
+ Description,
7
9
  requirements,
8
10
  }: {
9
11
  name: string;
10
12
  Component: React.FC<PassedFormProps<Props>>;
11
13
  Settings?: React.FC<CastToWidgetSettingsPassedForm<Props>>;
14
+ Description?: React.FC;
12
15
  requirements: (props: PassedFormProps) => boolean;
13
16
  }) {
14
17
  return {
15
18
  Component,
16
19
  Settings,
20
+ Description,
17
21
  requirements,
18
22
  props: {} as Props,
19
23
  name,
package/src/models.ts CHANGED
@@ -7,7 +7,7 @@ export type FormLabelProps = React.FC<PassedFormProps & { open?: boolean; setOpe
7
7
 
8
8
  export type WidgetSavedData = {
9
9
  widget: string;
10
- [x: string]: any;
10
+ [x: string]: unknown;
11
11
  };
12
12
 
13
13
  export type SavedWidgets = {
@@ -17,14 +17,14 @@ export type SavedForms = {
17
17
  [selector: string]: FormObject;
18
18
  };
19
19
 
20
- export type PassedFormProps<WidgetData = any> = {
20
+ export type PassedFormProps<WidgetData = unknown> = {
21
21
  f: ParserField;
22
22
  nodes: ParserField[];
23
23
  formObject: FormObject;
24
24
  onChange: (formObject: FormObject) => void;
25
25
  changeWidget: (widgetData: WidgetSavedData | undefined, path: string) => void;
26
26
  required?: boolean;
27
- runQuery: (q: string) => Promise<any>;
27
+ runQuery: (q: string) => Promise<unknown>;
28
28
  widgetComponents: WidgetType[];
29
29
  currentPath: string;
30
30
  widgets?: SavedWidgets;
@@ -65,14 +65,14 @@ export type FormDisplayerProps = Omit<
65
65
  export type FormLibraryProps = Omit<FormDisplayerProps, 'required' | 'components'>;
66
66
 
67
67
  export type CastToWidgetSettingsPassedForm<WidgetData> = PassedFormProps<Partial<WidgetData>> & {
68
- close: () => void;
68
+ widgetSettingsChange: (data: WidgetData) => void;
69
69
  };
70
70
 
71
71
  export type WidgetType = {
72
72
  Component: React.FC<PassedFormProps>;
73
- Settings: React.FC<CastToWidgetSettingsPassedForm<any>> | undefined;
73
+ Settings: React.FC<CastToWidgetSettingsPassedForm<unknown>> | undefined;
74
74
  requirements: (props: PassedFormProps) => boolean;
75
- props?: Record<string, any>;
75
+ props?: Record<string, unknown>;
76
76
  name: string;
77
77
  };
78
78