@kbss-cvut/s-forms 0.7.1-alpha-82d34b0.0 → 0.7.1-alpha-8469faf.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.
Files changed (38) hide show
  1. package/README.md +8 -27
  2. package/dist/components/Answer.d.ts +1 -1
  3. package/dist/components/DefaultInput.d.ts +2 -2
  4. package/dist/components/FormManager.d.ts +22 -1
  5. package/dist/components/IconOverlay.d.ts +0 -3
  6. package/dist/components/Question.d.ts +2 -6
  7. package/dist/components/answer/CheckboxAnswer.d.ts +2 -2
  8. package/dist/components/answer/DateTimeAnswer.d.ts +0 -1
  9. package/dist/components/answer/InputAnswer.d.ts +2 -4
  10. package/dist/components/answer/MaskedInputAnswer.d.ts +0 -1
  11. package/dist/components/answer/SelectAnswer.d.ts +0 -2
  12. package/dist/components/answer/TypeaheadAnswer.d.ts +0 -1
  13. package/dist/components/wizard/WizardStep.d.ts +13 -3
  14. package/dist/constants/Constants.d.ts +2 -30
  15. package/dist/model/FormGenerator.d.ts +5 -5
  16. package/dist/model/ValidatorFactory.d.ts +5 -1
  17. package/dist/s-forms.cjs +1 -1
  18. package/dist/s-forms.cjs.map +1 -1
  19. package/dist/s-forms.css +1 -1
  20. package/dist/s-forms.css.map +1 -1
  21. package/dist/s-forms.js +1 -1
  22. package/dist/s-forms.js.map +1 -1
  23. package/dist/s-forms.modern.js +1 -1
  24. package/dist/s-forms.modern.js.map +1 -1
  25. package/dist/s-forms.umd.js +1 -1
  26. package/dist/s-forms.umd.js.map +1 -1
  27. package/dist/stories/Answer.stories.d.ts +2 -8
  28. package/dist/stories/CommentForm.stories.d.ts +2 -2
  29. package/dist/stories/HelpIcon.stories.d.ts +3 -3
  30. package/dist/stories/LinkIcon.stories.d.ts +2 -2
  31. package/dist/stories/PrefixIcon.stories.d.ts +2 -2
  32. package/dist/stories/Question.stories.d.ts +10 -10
  33. package/dist/stories/QuestionCommentIcon.stories.d.ts +3 -3
  34. package/dist/stories/SForms.stories.d.ts +6 -6
  35. package/dist/util/FormUtils.d.ts +0 -17
  36. package/dist/util/Utils.d.ts +0 -8
  37. package/package.json +9 -12
  38. package/dist/model/ValidationProcessor.d.ts +0 -16
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # SForms
2
2
  [![Netlify Status](https://api.netlify.com/api/v1/badges/004d6408-4ff5-4719-905e-5d83d5feef01/deploy-status)](https://app.netlify.com/sites/s-forms-kbss/deploys)
3
3
 
4
- **S**emantic **form** generator and processor for ontology-based smart forms. Besides this core library, there exists also [library of advanced components](https://github.com/kbss-cvut/s-forms-components).
4
+ **S**emantic **form** generator and processor for ontology-based smart forms. Beside this core library, there exists also [library of advanced components](https://github.com/kbss-cvut/s-forms-components).
5
5
 
6
6
  ## Live Demo
7
7
 
@@ -9,15 +9,8 @@ Checkout [live demo using storybook](https://s-forms-kbss.netlify.app).
9
9
 
10
10
  ## Supported features
11
11
 
12
- - Validation
13
- - Question comments
14
- - Navigation to the selected question
15
- - Emphasizing selected questions
16
-
17
- ### Components
18
-
19
12
  - Input/Textarea
20
- - Tree Typeahead
13
+ - Typeahead
21
14
  - Datetime picker
22
15
  - Select
23
16
  - Checkbox
@@ -25,31 +18,19 @@ Checkout [live demo using storybook](https://s-forms-kbss.netlify.app).
25
18
 
26
19
  ## Representation in JSON-LD
27
20
 
28
- Semantic form is a structure that holds a form (set of questions) and its data (set of answers).
29
- A conceptual model of Semantic forms is [questions/answers model](https://github.com/kbss-cvut/s-forms-model).
21
+ Semantic form is structure that holds a form (set of questions) as well as its data (set of answers).
22
+ A conceptual model of Semantic forms is [questions/answers model](https://kbss.felk.cvut.cz/gitblit/summary/s-forms-model.git).
30
23
  The conceptual model is described in RDF language. This library processes and generates Semantic forms using JSON-LD
31
- format which is JSON-compatible serialization of the RDF language.
24
+ format which is JSON compatible serialization of the RDF language.
32
25
 
33
26
  ## Development
34
27
 
35
28
  Building SForms library can be done using `npm run build:lib`.
36
29
 
37
- ### StorybookJS
38
-
39
- #### Debugging forms and components with StorybookJS
40
-
41
- Storybook is an open-source tool for building UI components and pages in isolation. Rendering of a form or a specific component can be tested through a story provided in `./src/stories/`. The application can be started by executing npm script through `npm run dev` and then accessing `localhost:6006` from a browser. It renders the forms provided by the file `./src/stories/assets/`. See `./src/stories/SForms/SForms.stories.tsx` for more details.
30
+ ### Debugging a form & components with StorybookJS
42
31
 
43
- #### Testing forms with the toolbar
44
- With the Storybook [toolbar](https://storybook.js.org/docs/essentials/toolbars-and-globals), it is possible to test a set of predefined global variables. The toolbar supports the following features:
45
- - Icon behavior: Set the behavior for the icons
46
- - Locale: Set the internationalization locale
47
- - Debug mode: Show irrelevant questions
48
- - Navbar position: Set the navigation bar to horizontal/vertical position
49
- - Timeout: Set time-out for possible values (in ms)
50
- - Print form specification: Print the form specification in the console
51
- - Validate form: Triggers the form validation
32
+ Storybook is an open source tool for building UI components and pages in isolation. Rendering of a form or a specific component can be tested through a story provided in `./src/stories/`. The application can be started by executing npm script through `npm run dev` and then accessing `localhost:6006` from a browser. It renders the forms provided by the file `./src/stories/assets/`. See `./src/stories/SForms/SForms.stories.tsx` for more details.
52
33
 
53
- ### NPM release workflow
34
+ ### NPM release worklow
54
35
 
55
36
  NPM packages are created automatically for each commit to this repository, see [npm release workflow guide](./docs/npm-release-workflow.md).
@@ -1,5 +1,5 @@
1
1
  export default Answer;
2
- declare function Answer(props: any): import("react/jsx-runtime").JSX.Element;
2
+ declare function Answer(props: any): import("react/jsx-runtime").JSX.Element | null;
3
3
  declare namespace Answer {
4
4
  namespace propTypes {
5
5
  let answer: PropTypes.Validator<object>;
@@ -17,6 +17,7 @@ declare class DefaultInput extends React.Component<any, any, any> {
17
17
  _renderSelect(): import("react/jsx-runtime").JSX.Element;
18
18
  _renderLabel(): import("react/jsx-runtime").JSX.Element | null;
19
19
  _renderTextArea(): import("react/jsx-runtime").JSX.Element;
20
+ _renderHelp(): import("react/jsx-runtime").JSX.Element | null;
20
21
  _renderInput(): import("react/jsx-runtime").JSX.Element;
21
22
  }
22
23
  declare namespace DefaultInput {
@@ -26,8 +27,7 @@ declare namespace DefaultInput {
26
27
  let value: PropTypes.Requireable<any>;
27
28
  let onChange: PropTypes.Requireable<(...args: any[]) => any>;
28
29
  let help: PropTypes.Requireable<string>;
29
- let validation: PropTypes.Requireable<object>;
30
- let placeholder: PropTypes.Requireable<string>;
30
+ let validation: PropTypes.Requireable<string>;
31
31
  }
32
32
  namespace defaultProps {
33
33
  let type_1: string;
@@ -1,2 +1,23 @@
1
1
  export default FormManager;
2
- declare function FormManager(props: any): import("react/jsx-runtime").JSX.Element;
2
+ declare class FormManager extends React.Component<any, any, any> {
3
+ constructor(props: any);
4
+ constructor(props: any, context: any);
5
+ getFormData: () => {
6
+ subQuestions: never[];
7
+ };
8
+ getFormQuestionsData: () => any;
9
+ handleStepChange: (question: any, index: any, change: any) => void;
10
+ renderWizardlessForm: () => import("react/jsx-runtime").JSX.Element;
11
+ _mapQuestion(question: any, index: any): React.DetailedReactHTMLElement<{
12
+ key: any;
13
+ question: any;
14
+ onChange: (index: any, change: any) => void;
15
+ index: any;
16
+ }, HTMLElement>;
17
+ render(): import("react/jsx-runtime").JSX.Element;
18
+ }
19
+ declare namespace FormManager {
20
+ export { FormQuestionsContext as contextType };
21
+ }
22
+ import React from "react";
23
+ import { FormQuestionsContext } from "../contexts/FormQuestionsContext";
@@ -6,15 +6,12 @@ declare namespace IconOverlay {
6
6
  let id: PropTypes.Validator<string>;
7
7
  let overlayPlacement: PropTypes.Requireable<string>;
8
8
  let absolutePosition: PropTypes.Requireable<boolean>;
9
- let show: PropTypes.Requireable<boolean>;
10
9
  }
11
10
  namespace defaultProps {
12
11
  export let iconClassContainer: string;
13
12
  export let iconClass: string;
14
13
  let absolutePosition_1: boolean;
15
14
  export { absolutePosition_1 as absolutePosition };
16
- let show_1: boolean;
17
- export { show_1 as show };
18
15
  }
19
16
  }
20
17
  import PropTypes from "prop-types";
@@ -2,10 +2,10 @@ declare class Question extends React.Component<any, any, any> {
2
2
  static _getAnswerClass(question: any, isTextarea: any): string;
3
3
  static _getQuestionCategoryClass(question: any): string;
4
4
  static getEmphasizedClass(question: any): "" | "bg-warning";
5
- static getEmphasizedOnRelevantClass(question: any): "" | "emphasise-on-relevant";
5
+ static getEmphasizedOnRelevantClass(question: any): "emphasise-on-relevant" | "";
6
6
  constructor(props: any);
7
7
  state: {
8
- validator: {};
8
+ validator: null;
9
9
  expanded: boolean;
10
10
  showIcon: boolean;
11
11
  };
@@ -27,13 +27,11 @@ declare class Question extends React.Component<any, any, any> {
27
27
  question: any;
28
28
  onChange: (subQuestionIndex: any, change: any) => void;
29
29
  index: number;
30
- intl: any;
31
30
  }, React.Component<{
32
31
  key: string;
33
32
  question: any;
34
33
  onChange: (subQuestionIndex: any, change: any) => void;
35
34
  index: number;
36
- intl: any;
37
35
  }, any, any>> | null)[])[];
38
36
  renderQuestionIcons(): import("react/jsx-runtime").JSX.Element;
39
37
  renderAnswerableSection(): import("react/jsx-runtime").JSX.Element;
@@ -57,13 +55,11 @@ declare class Question extends React.Component<any, any, any> {
57
55
  question: any;
58
56
  onChange: (subQuestionIndex: any, change: any) => void;
59
57
  index: number;
60
- intl: any;
61
58
  }, React.Component<{
62
59
  key: string;
63
60
  question: any;
64
61
  onChange: (subQuestionIndex: any, change: any) => void;
65
62
  index: number;
66
- intl: any;
67
63
  }, any, any>> | null)[];
68
64
  _getSubQuestions(): any;
69
65
  _getFirstAnswerValue(): any;
@@ -4,9 +4,10 @@ declare function CheckboxAnswer(props: any): React.DetailedReactHTMLElement<{
4
4
  label: any;
5
5
  title: any;
6
6
  checked: boolean;
7
- validation: any;
8
7
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
9
8
  disabled: any;
9
+ validation: string;
10
+ help: any;
10
11
  }, HTMLElement>;
11
12
  declare namespace CheckboxAnswer {
12
13
  namespace propTypes {
@@ -16,7 +17,6 @@ declare namespace CheckboxAnswer {
16
17
  let value: PropTypes.Requireable<NonNullable<string | boolean | null | undefined>>;
17
18
  let onChange: PropTypes.Validator<(...args: any[]) => any>;
18
19
  let mouseHover: PropTypes.Requireable<boolean>;
19
- let validation: PropTypes.Requireable<object>;
20
20
  }
21
21
  }
22
22
  import React from "react";
@@ -7,7 +7,6 @@ declare namespace DateTimeAnswer {
7
7
  let title: PropTypes.Requireable<string>;
8
8
  let value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
9
9
  let onChange: PropTypes.Validator<(...args: any[]) => any>;
10
- let validation: PropTypes.Requireable<object>;
11
10
  }
12
11
  }
13
12
  import PropTypes from "prop-types";
@@ -1,16 +1,15 @@
1
1
  export default InputAnswer;
2
2
  declare function InputAnswer(props: any): React.DetailedReactHTMLElement<{
3
- validation: any;
4
3
  label: any;
5
4
  title: any;
6
5
  value: any;
7
- placeholder: any;
8
- onKeyPress: (e: React.KeyboardEvent<HTMLInputElement>) => void;
9
6
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
10
7
  onFocus: (e: React.FocusEvent<HTMLInputElement, Element>) => void;
11
8
  type: string;
12
9
  rows: number;
13
10
  disabled: any;
11
+ validation: string;
12
+ help: any;
14
13
  }, HTMLElement>;
15
14
  declare namespace InputAnswer {
16
15
  namespace propTypes {
@@ -20,7 +19,6 @@ declare namespace InputAnswer {
20
19
  let title: PropTypes.Requireable<string>;
21
20
  let value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
22
21
  let onChange: PropTypes.Validator<(...args: any[]) => any>;
23
- let validation: PropTypes.Requireable<object>;
24
22
  }
25
23
  }
26
24
  import React from "react";
@@ -8,7 +8,6 @@ declare namespace MaskedInputAnswer {
8
8
  let title: PropTypes.Requireable<string>;
9
9
  let value: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
10
10
  let onChange: PropTypes.Validator<(...args: any[]) => any>;
11
- let validation: PropTypes.Requireable<object>;
12
11
  }
13
12
  }
14
13
  import PropTypes from "prop-types";
@@ -7,7 +7,6 @@ declare class SelectAnswer extends React.Component<any, any, any> {
7
7
  label: any;
8
8
  value: any;
9
9
  title: any;
10
- validation: any;
11
10
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
12
11
  disabled: any;
13
12
  }, HTMLElement>;
@@ -20,7 +19,6 @@ declare namespace SelectAnswer {
20
19
  let title: PropTypes.Requireable<string>;
21
20
  let value: PropTypes.Requireable<string>;
22
21
  let onChange: PropTypes.Validator<(...args: any[]) => any>;
23
- let validation: PropTypes.Requireable<object>;
24
22
  }
25
23
  }
26
24
  export default SelectAnswer;
@@ -8,7 +8,6 @@ declare namespace TypeaheadAnswer {
8
8
  let title: PropTypes.Requireable<string>;
9
9
  let value: PropTypes.Requireable<string>;
10
10
  let onChange: PropTypes.Validator<(...args: any[]) => any>;
11
- let validation: PropTypes.Requireable<object>;
12
11
  }
13
12
  }
14
13
  import PropTypes from "prop-types";
@@ -1,7 +1,13 @@
1
- export default WizardStep;
2
- declare function WizardStep(props: any): import("react/jsx-runtime").JSX.Element;
1
+ declare class WizardStep extends React.Component<any, any, any> {
2
+ constructor(props: any);
3
+ onNextStep: () => void;
4
+ onPreviousStep: () => void;
5
+ _renderWizardStepButtons: () => import("react/jsx-runtime").JSX.Element;
6
+ onChange: (index: any, change: any) => void;
7
+ render(): import("react/jsx-runtime").JSX.Element;
8
+ }
3
9
  declare namespace WizardStep {
4
- namespace propTypes {
10
+ export namespace propTypes {
5
11
  let options: PropTypes.Validator<object>;
6
12
  let question: PropTypes.Validator<object>;
7
13
  let index: PropTypes.Validator<number>;
@@ -11,5 +17,9 @@ declare namespace WizardStep {
11
17
  let isFirstStep: PropTypes.Requireable<boolean>;
12
18
  let isLastStep: PropTypes.Requireable<boolean>;
13
19
  }
20
+ export { FormQuestionsContext as contextType };
14
21
  }
22
+ export default WizardStep;
23
+ import React from "react";
15
24
  import PropTypes from "prop-types";
25
+ import { FormQuestionsContext } from "../../contexts/FormQuestionsContext";
@@ -57,13 +57,9 @@ export default class Constants {
57
57
  NON_NEGATIVE_INTEGER: string;
58
58
  NON_POSITIVE_INTEGER: string;
59
59
  POSITIVE_INTEGER: string;
60
- FLOAT: string;
61
- POSITIVE_FLOAT: string;
62
- NEGATIVE_FLOAT: string;
63
60
  BOOLEAN: string;
64
61
  };
65
62
  static STEP: string;
66
- static PATTERN: string;
67
63
  static ACCEPTS_ANSWER_VALUE: string;
68
64
  static ACCEPTS: string;
69
65
  static HAS_DATATYPE: string;
@@ -79,9 +75,10 @@ export default class Constants {
79
75
  static HAS_VALIDATION_MESSAGE: string;
80
76
  static NEGATIVE_CONDITION: string;
81
77
  static REQUIRES_ANSWER: string;
82
- static USED_ONLY_FOR_COMPLETENESS: string;
83
78
  static REQUIRES_ANSWER_DESCRIPTION_IF: string;
84
79
  static REQUIRES_ANSWER_IF: string;
80
+ static REQUIRES_ANSWER_VALUE: string;
81
+ static REQUIRES_DESCRIPTION: string;
85
82
  static HAS_PRECEDING_QUESTION: string;
86
83
  static HAS_PRECEDING_VALUE: string;
87
84
  static HAS_MEDIA_CONTENT: string;
@@ -96,18 +93,11 @@ export default class Constants {
96
93
  static HAS_COMMENT_VALUE: string;
97
94
  static HAS_AUTHOR: string;
98
95
  static HAS_TIMESTAMP: string;
99
- static TIME_FORMAT: string;
100
- static DATE_FORMAT: string;
101
- static DATETIME_FORMAT: string;
102
96
  static NOT_ANSWERED_QUESTION: string;
103
97
  static ANSWERED_QUESTION: string;
104
- static HAS_VALIDATION_SEVERITY: string;
105
98
  static RDFS_LABEL: any;
106
99
  static RDFS_COMMENT: any;
107
100
  static DEFAULT_HAS_CHILD: any;
108
- static BROADER: string;
109
- static HAS_NON_SELECTABLE_VALUE: string;
110
- static PROVIDES_DEREFERENCEABLE_ANSWER_VALUES: string;
111
101
  static ICONS: {
112
102
  QUESTION_COMMENTS: string;
113
103
  QUESTION_HELP: string;
@@ -134,22 +124,4 @@ export default class Constants {
134
124
  label: string;
135
125
  };
136
126
  };
137
- static VALIDATION: {
138
- SEVERITY: {
139
- ERROR: string;
140
- WARNING: string;
141
- };
142
- DEFAULT_MESSAGE: {
143
- REQUIRED: string;
144
- REQUIRED_ONLY_FOR_COMPLETENESS: string;
145
- INVALID: string;
146
- CHECK: string;
147
- LOWER_OR_EQUAL: string;
148
- GREATER_OR_EQUAL: string;
149
- };
150
- CLASSNAME: {
151
- ERROR: string;
152
- WARNING: string;
153
- };
154
- };
155
127
  }
@@ -8,13 +8,13 @@ export default class FormGenerator {
8
8
  */
9
9
  static constructDefaultForm(intl: any): any[];
10
10
  /**
11
- * Asynchronously generates form definition from the specified data-enriched template.
11
+ * Generates form definition from the specified data-enriched template.
12
12
  *
13
- * @param {Object} structure The form structure in JSON-LD
14
- * @param {string} intl Preferred language of questions
13
+ * @param structure The form structure in JSON-LD
14
+ * @param intl Preferred language of questions
15
15
  *
16
- * @return {Promise<Object>} Promise with generated form definition and form data
16
+ * @return Promise with generated form definition and form data
17
17
  */
18
- static constructForm(structure: Object, intl: string): Promise<Object>;
18
+ static constructForm(structure: any, intl: any): Promise<any>;
19
19
  static _constructFormQuestions(structure: any, intl: any): any[];
20
20
  }
@@ -1 +1,5 @@
1
- export function createValidator(question: any, intl: any): () => {} | undefined;
1
+ export default class ValidatorFactory {
2
+ static createValidator(question: any, intl: any): (answer: any) => {};
3
+ static _generateRequiresAnswerValidator(question: any, intl: any): (answer: any) => {};
4
+ static _generateRequiresAnswerCheckBoxValidator(question: any, intl: any): (answer: any) => {};
5
+ }