@kbss-cvut/s-forms 0.4.1 → 0.4.2-alpha-f760ea7.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 (97) hide show
  1. package/css/s-forms.min.css +1 -0
  2. package/dist/s-forms.cjs.map +1 -1
  3. package/dist/s-forms.js.map +1 -1
  4. package/dist/s-forms.modern.js.map +1 -1
  5. package/dist/s-forms.umd.js.map +1 -1
  6. package/package.json +20 -10
  7. package/{dist → types}/components/Answer.d.ts +0 -0
  8. package/{dist → types}/components/DefaultInput.d.ts +0 -0
  9. package/{dist → types}/components/FormManager.d.ts +0 -0
  10. package/{dist → types}/components/FormWindow.d.ts +0 -0
  11. package/{dist → types}/components/HelpIcon.d.ts +0 -0
  12. package/{dist → types}/components/IconOverlay.d.ts +0 -0
  13. package/{dist → types}/components/LinkIcon.d.ts +0 -0
  14. package/{dist → types}/components/MaskedInput.d.ts +0 -0
  15. package/{dist → types}/components/MediaContent.d.ts +0 -0
  16. package/{dist → types}/components/PrefixIcon.d.ts +0 -0
  17. package/{dist → types}/components/Question.d.ts +0 -0
  18. package/{dist → types}/components/QuestionStatic.d.ts +0 -0
  19. package/{dist → types}/components/SForms.d.ts +0 -0
  20. package/{dist → types}/components/answer/CheckboxAnswer.d.ts +0 -0
  21. package/{dist → types}/components/answer/DateTimeAnswer.d.ts +0 -0
  22. package/{dist → types}/components/answer/InputAnswer.d.ts +0 -0
  23. package/{dist → types}/components/answer/MaskedInputAnswer.d.ts +0 -0
  24. package/{dist → types}/components/answer/OptimizedMenuList.d.ts +0 -0
  25. package/{dist → types}/components/answer/SelectAnswer.d.ts +0 -0
  26. package/{dist → types}/components/answer/TypeaheadAnswer.d.ts +0 -0
  27. package/{dist → types}/components/comment/CommentForm.d.ts +0 -0
  28. package/{dist → types}/components/comment/CommentList.d.ts +0 -0
  29. package/{dist → types}/components/comment/CommentView.d.ts +0 -0
  30. package/{dist → types}/components/comment/QuestionCommentIcon.d.ts +0 -0
  31. package/{dist → types}/components/wizard/HorizontalWizardNav.d.ts +0 -0
  32. package/{dist → types}/components/wizard/VerticalWizardNav.d.ts +0 -0
  33. package/{dist → types}/components/wizard/Wizard.d.ts +0 -0
  34. package/{dist → types}/components/wizard/WizardStep.d.ts +0 -0
  35. package/{dist → types}/constants/Constants.d.ts +0 -0
  36. package/{dist → types}/contexts/ConfigurationContext.d.ts +0 -0
  37. package/{dist → types}/contexts/FormGenContext.d.ts +0 -0
  38. package/{dist → types}/contexts/FormQuestionsContext.d.ts +0 -0
  39. package/{dist → types}/contexts/IntlContextProvider.d.ts +2 -2
  40. package/{dist → types}/model/DefaultFormGenerator.d.ts +0 -0
  41. package/{dist → types}/model/FormGenerator.d.ts +0 -0
  42. package/{dist → types}/model/QuestionAnswerProcessor.d.ts +0 -0
  43. package/{dist → types}/model/ValidatorFactory.d.ts +0 -0
  44. package/types/s-forms.d.ts +16 -216
  45. package/{dist → types}/stories/Answer.stories.d.ts +0 -0
  46. package/{dist → types}/stories/CommentForm.stories.d.ts +0 -0
  47. package/{dist → types}/stories/HelpIcon.stories.d.ts +0 -0
  48. package/{dist → types}/stories/LinkIcon.stories.d.ts +0 -0
  49. package/{dist → types}/stories/MediaContent.stories.d.ts +0 -0
  50. package/{dist → types}/stories/PrefixIcon.stories.d.ts +0 -0
  51. package/{dist → types}/stories/Question.stories.d.ts +0 -0
  52. package/{dist → types}/stories/QuestionCommentIcon.stories.d.ts +0 -0
  53. package/{dist → types}/stories/SForms.stories.d.ts +0 -0
  54. package/{dist → types}/styles/icons/ArrowRight.d.ts +0 -0
  55. package/{dist → types}/styles/icons/CaretSquareDown.d.ts +0 -0
  56. package/{dist → types}/styles/icons/CaretSquareUp.d.ts +0 -0
  57. package/{dist → types}/styles/icons/Close.d.ts +0 -0
  58. package/{dist → types}/styles/icons/CommentBubble.d.ts +0 -0
  59. package/{dist → types}/styles/icons/ExternalLink.d.ts +0 -0
  60. package/{dist → types}/styles/icons/InfoCircle.d.ts +0 -0
  61. package/{dist → types}/styles/icons/QuestionCircle.d.ts +0 -0
  62. package/{dist → types}/styles/icons/RecycleBin.d.ts +0 -0
  63. package/{dist → types}/styles/icons/index.d.ts +0 -0
  64. package/{dist → types}/util/FormUtils.d.ts +0 -0
  65. package/{dist → types}/util/JsonLdFramingUtils.d.ts +0 -0
  66. package/{dist → types}/util/JsonLdObjectMap.d.ts +0 -0
  67. package/{dist → types}/util/JsonLdObjectUtils.d.ts +0 -0
  68. package/{dist → types}/util/Logger.d.ts +0 -0
  69. package/{dist → types}/util/MaskMapper.d.ts +0 -0
  70. package/{dist → types}/util/Utils.d.ts +0 -0
  71. package/.babelrc +0 -22
  72. package/.github/workflows/check-format.yml +0 -21
  73. package/.github/workflows/chromatic.yml +0 -24
  74. package/.husky/pre-commit +0 -4
  75. package/.prettierignore +0 -4
  76. package/.storybook/main.cjs +0 -11
  77. package/.storybook/preview.js +0 -103
  78. package/dist/s-forms.css +0 -2
  79. package/dist/s-forms.css.map +0 -1
  80. package/dist/s-forms.d.ts +0 -16
  81. package/jest.config.cjs +0 -20
  82. package/test/__mocks__/styleMock.js +0 -1
  83. package/test/__tests__/Answer.test.js +0 -399
  84. package/test/__tests__/DefaultFormGenerator.test.js +0 -34
  85. package/test/__tests__/FormUtils.test.js +0 -297
  86. package/test/__tests__/InputAnswer.test.js +0 -193
  87. package/test/__tests__/JsonLdFramingUtils.test.js +0 -29
  88. package/test/__tests__/JsonLdObjectUtils.test.js +0 -86
  89. package/test/__tests__/MaskMapper.test.js +0 -32
  90. package/test/__tests__/MaskedInputAnswer.test.js +0 -90
  91. package/test/__tests__/Question.test.js +0 -102
  92. package/test/__tests__/QuestionAnswerProcessor.test.js +0 -183
  93. package/test/__tests__/QuestionCommentIcon.test.js +0 -77
  94. package/test/__tests__/TypeheadAnswer.test.js +0 -102
  95. package/test/environment/Generator.js +0 -44
  96. package/test/setup.js +0 -19
  97. package/tsconfig.json +0 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbss-cvut/s-forms",
3
- "version": "0.4.1",
3
+ "version": "0.4.2-alpha-f760ea7.0",
4
4
  "description": "Semantic forms generator and processor",
5
5
  "keywords": [
6
6
  "react",
@@ -36,6 +36,7 @@
36
36
  },
37
37
  "type": "module",
38
38
  "source": "src/s-forms.js",
39
+ "main": "dist/s-forms.js",
39
40
  "exports": "./dist/s-forms.modern.js",
40
41
  "module": "./dist/s-forms.js",
41
42
  "unpkg": "./dist/s-forms.umd.js",
@@ -71,7 +72,6 @@
71
72
  "react-bootstrap": "1.0.1",
72
73
  "react-dom": ">= 17.0.2"
73
74
  },
74
- "main": "dist/s-forms.js",
75
75
  "devDependencies": {
76
76
  "@storybook/addon-a11y": "^6.4.19",
77
77
  "@storybook/addon-actions": "^6.4.19",
@@ -87,6 +87,7 @@
87
87
  "@types/jsonld": "^1.5.1",
88
88
  "@wojtekmaj/enzyme-adapter-react-17": "^0.6.6",
89
89
  "chromatic": "^6.5.3",
90
+ "clean-css-cli": "^4.3.0",
90
91
  "css-loader": "^3.5.3",
91
92
  "enzyme": "^3.11.0",
92
93
  "jest": "^26.0.1",
@@ -94,20 +95,29 @@
94
95
  "query-string": "^6.13.5",
95
96
  "react": "~17.0.2",
96
97
  "react-dom": "~17.0.2",
98
+ "standard-version": "^9.3.2",
97
99
  "style-loader": "^1.2.1",
98
100
  "typescript": "^4.5.5",
99
- "watchify": "^3.11.1",
100
- "husky": "^7.0.0"
101
+ "watchify": "^3.11.1"
101
102
  },
102
103
  "scripts": {
103
104
  "test": "jest",
104
105
  "dev": "start-storybook -p 6006",
105
- "build": "microbundle --jsx React.createElement",
106
+ "build": "microbundle --jsx React.createElement && npm run build:css",
107
+ "build:css": "cleancss --skip-rebase -d -o ./css/s-forms.min.css ./src/styles/s-forms.css",
106
108
  "build-storybook": "build-storybook",
107
- "chromatic": "npx chromatic",
108
- "prettier:check": "npx prettier --check .",
109
- "prettier:format": "npx prettier --write .",
110
- "prepare": "husky install"
109
+ "release:patch": "npm test && standard-version --release-as patch && npm publish",
110
+ "release:major": "npm test && standard-version --release-as major && npm publish",
111
+ "release:minor": "npm test && standard-version --release-as minor && npm publish",
112
+ "chromatic": "npx chromatic"
111
113
  },
112
- "types": "./dist/s-forms.d.ts"
114
+ "standard-version": {
115
+ "releaseCommitMessageFormat": "[{{currentTag}}] Bump version"
116
+ },
117
+ "files": [
118
+ "dist/",
119
+ "css/",
120
+ "types/"
121
+ ],
122
+ "types": "types/s-forms.d.ts"
113
123
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,8 +1,8 @@
1
- import React, { ReactNode } from "react";
1
+ import React, { ReactNode } from 'react';
2
2
  export declare const IntlContext: React.Context<{}>;
3
3
  interface Props {
4
4
  children: ReactNode;
5
5
  locale?: string;
6
6
  }
7
- declare const IntlContextProvider: ({ children, locale, }: Props) => JSX.Element;
7
+ declare const IntlContextProvider: ({ children, locale }: Props) => JSX.Element;
8
8
  export default IntlContextProvider;
File without changes
File without changes
File without changes
@@ -1,216 +1,16 @@
1
- import * as React from "react";
2
- import { Modal } from "react-bootstrap";
3
- import { JsonLdObj } from "jsonld/jsonld-spec";
4
-
5
- export type Intl = {
6
- locale?: string;
7
- };
8
-
9
- export interface SOptions {
10
- intl?: Intl; // default 'en'
11
- i18n?: {
12
- "wizard.next": string; // default 'Next'
13
- "wizard.previous": string; // default 'Previous'
14
- "section.expand": string; // default 'Expand'
15
- "section.collapse": string; // default 'Collapse'
16
- };
17
- modalView?: boolean; // default false
18
- modalProps?: Modal;
19
- horizontalWizardNav?: boolean; // default true
20
- wizardStepButtons?: boolean; // default true
21
- enableForwardSkip?: boolean; // default false
22
- startingStep?: number; // default 0; indexed from 0
23
- startingQuestionId?: string; // default undefined; overrides startingStep
24
- }
25
-
26
- export interface SComponents {
27
- inputComponent?: React.ElementType;
28
- }
29
-
30
- export interface SComponentsOptions {
31
- dateTimeAnswer?: {
32
- dateFormat: string; // default 'yyyy-MM-dd'
33
- timeFormat: string; // default 'HH:mm:ss'
34
- dateTimeFormat: string; // default 'yyyy-MM-dd HH:mm:ss'
35
- };
36
- readOnly?: boolean; // default false
37
- }
38
-
39
- export interface SFormsProps {
40
- ref?: React.RefObject<HTMLDivElement>;
41
- form: object;
42
- options?: SOptions;
43
- components?: SComponents;
44
- componentsOptions?: SComponentsOptions;
45
- fetchTypeAheadValues: (query: string) => Promise<object>;
46
- isFormValid?: (isFormValid: boolean) => void;
47
- loader?: React.ElementType; // default <div>Loading SForms...</div>
48
- }
49
-
50
- type ArrayLengthMutationKeys =
51
- | "category-1"
52
- | "category-2"
53
- | "category-3"
54
- | "category-4"
55
- | "category-5";
56
- type ArrayItems<T extends Array<any>> = T extends Array<infer TItems>
57
- ? TItems
58
- : never;
59
- type FixedLengthArray<T extends any[]> = Pick<
60
- T,
61
- Exclude<keyof T, ArrayLengthMutationKeys>
62
- > & {
63
- [Symbol.iterator]: () => IterableIterator<ArrayItems<T>>;
64
- };
65
-
66
- export class Constants {
67
- static COLUMN_COUNT: string;
68
- static INPUT_LENGTH_THRESHOLD: string;
69
- static DATETIME_NUMBER_FORMAT: string;
70
- static FORM: string;
71
- static HAS_SUBQUESTION: string;
72
- static HAS_ANSWER: string;
73
- static HAS_OPTION: string;
74
- static HAS_OPTIONS_QUERY: string;
75
- static HAS_VALUE_TYPE: string;
76
- static IS_DISABLED: string;
77
- static INPUT_MASK: string;
78
- static LAYOUT_CLASS: string;
79
- static LAYOUT: {
80
- FORM: string;
81
- QUESTION_SECTION: string;
82
- WIZARD_STEP: string;
83
- DATE: string;
84
- TIME: string;
85
- DATETIME: string;
86
- TEXTAREA: string;
87
- TEXT: string;
88
- CHECKBOX: string;
89
- QUESTION_TYPEAHEAD: string;
90
- MASKED_INPUT: string;
91
- SPARQL: string;
92
- TURTLE: string;
93
- ANSWERABLE: string;
94
- COLLAPSED: string;
95
- DISABLED: string;
96
- EMPHASISED: string;
97
- HIDDEN: string;
98
- CATEGORY: FixedLengthArray<[string, string, string, string, string]>;
99
- };
100
- static VALUE_TYPE_CODE: string;
101
- static VALUE_TYPE_TEXT: string;
102
- static GENERATED_ROW_SIZE: string;
103
- static HAS_QUESTION_ORIGIN: string;
104
- static HAS_ANSWER_ORIGIN: string;
105
- static HAS_DATA_VALUE: string;
106
- static HAS_OBJECT_VALUE: string;
107
- static HELP_DESCRIPTION: string;
108
- static XSD: {
109
- MAX_EXCLUSIVE: string;
110
- MAX_INCLUSIVE: string;
111
- MIN_EXCLUSIVE: string;
112
- MIN_INCLUSIVE: string;
113
- INT: string;
114
- INTEGER: string;
115
- NEGATIVE_INTEGER: string;
116
- NON_NEGATIVE_INTEGER: string;
117
- NON_POSITIVE_INTEGER: string;
118
- POSITIVE_INTEGER: string;
119
- BOOLEAN: string;
120
- };
121
- static ACCEPTS_ANSWER_VALUE: string;
122
- static HAS_DATATYPE: string;
123
- static HAS_LAYOUT_CLASS: string;
124
- static HAS_POSSIBLE_VALUES_QUERY: string;
125
- static HAS_REQUIRED_VALUE: string;
126
- static HAS_TESTED_QUESTION: string;
127
- static HAS_UNIT: string;
128
- static HAS_VALID_ANSWER: string;
129
- static IS_RELEVANT_IF: string;
130
- static ACCEPTS_VALIDATION_VALUE: string;
131
- static HAS_VALIDATION_MESSAGE: string;
132
- static NEGATIVE_CONDITION: string;
133
- static REQUIRES_ANSWER: string;
134
- static REQUIRES_ANSWER_DESCRIPTION_IF: string;
135
- static REQUIRES_ANSWER_IF: string;
136
- static REQUIRES_ANSWER_VALUE: string;
137
- static REQUIRES_DESCRIPTION: string;
138
- static HAS_PRECEDING_QUESTION: string;
139
- static HAS_PRECEDING_VALUE: string;
140
- static HAS_MEDIA_CONTENT: string;
141
- static CONDITION: string;
142
- static HAS_PATTERN: string;
143
- static HAS_DECLARED_PREFIX: string;
144
- static PREFIX: string;
145
- static NAMESPACE: string;
146
-
147
- static RDFS_LABEL: string;
148
- static RDFS_COMMENT: string;
149
- static DEFAULT_HAS_CHILD: string;
150
-
151
- static ICONS: {
152
- QUESTION_COMMENTS: string;
153
- QUESTION_HELP: string;
154
- QUESTION_LINK: string;
155
- };
156
-
157
- static ICON_BEHAVIOR: {
158
- ENABLE: string;
159
- DISABLE: string;
160
- ON_HOVER: string;
161
- };
162
- }
163
-
164
- export class JsonLdObjectUtils {
165
- static getFirstObject(subject, predicate): any;
166
- static compareValues(jsonLdValue1, jsonLdValue2): any;
167
- static toplogicalSort(data, gtProperty): any;
168
- static orderPreservingToplogicalSort(data, gtProperty): any;
169
- static getCompareLocalizedLabelFunction(intl): any;
170
- static orderByLocalizedLabels(data, intl): any;
171
- }
172
-
173
- export class JsonLdFramingUtils {
174
- static customFrame(input, shape, callback): any;
175
- static expandStructure(structure: JsonLdObj): JsonLdObj;
176
- static compressStructure(structure: JsonLdObj): JsonLdObj;
177
- }
178
-
179
- export class JsonLdObjectMap {
180
- static putObject(id, question): void;
181
- static getObject(id): any;
182
- }
183
-
184
- export class FormUtils {
185
- static isForm(structure): boolean;
186
- static isWizardStep(structure): boolean;
187
- static isSection(question): boolean;
188
- static isAnswerable(question): boolean;
189
- static isTypeahead(question): boolean;
190
- static getPossibleValuesQuery(question): boolean;
191
- static isDisabled(question): boolean;
192
- static isHidden(question): boolean;
193
- static isTextarea(question, answerValue): boolean;
194
- static isText(question): boolean;
195
- static isCalendar(question): boolean;
196
- static isDate(question): boolean;
197
- static isTime(question): boolean;
198
- static isDateTime(question): boolean;
199
- static isCheckbox(question): boolean;
200
- static isMaskedInput(question): boolean;
201
- static isSparqlInput(question): boolean;
202
- static isTurtleInput(question): boolean;
203
- static isCollapsed(question): boolean;
204
- static getCategory(question): string;
205
- static isEmphasised(question): boolean;
206
- static resolveValue(answer): any;
207
- static resolveValueObject(answer): any;
208
- static isRelevant(question): boolean;
209
- static hasValidationLogic(question): boolean;
210
- static isValid(question): boolean;
211
- static testCondition(condition): boolean;
212
- }
213
-
214
- declare const SForms: React.ForwardRefExoticComponent<SFormsProps>;
215
-
216
- export default SForms;
1
+ export default SForms;
2
+ import SForms from "./components/SForms";
3
+ import Constants from "./constants/Constants";
4
+ import JsonLdObjectUtils from "./util/JsonLdObjectUtils";
5
+ import JsonLdFramingUtils from "./util/JsonLdFramingUtils";
6
+ import JsonLdObjectMap from "./util/JsonLdObjectMap";
7
+ import FormUtils from "./util/FormUtils";
8
+ import Question from "./components/Question";
9
+ import Answer from "./components/Answer";
10
+ import HelpIcon from "./components/HelpIcon";
11
+ import { ConfigurationContext } from "./contexts/ConfigurationContext";
12
+ import { FormQuestionsContext } from "./contexts/FormQuestionsContext";
13
+ import WizardStep from "./components/wizard/WizardStep";
14
+ import QuestionStatic from "./components/QuestionStatic";
15
+ import IntlContextProvider from "./contexts/IntlContextProvider.js";
16
+ export { Constants, JsonLdObjectUtils, JsonLdFramingUtils, JsonLdObjectMap, FormUtils, Question, Answer, HelpIcon, ConfigurationContext, FormQuestionsContext, WizardStep, QuestionStatic, IntlContextProvider };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/.babelrc DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "presets": [
3
- "@babel/preset-typescript",
4
- [
5
- "@babel/preset-env",
6
- {
7
- "modules": false,
8
- "useBuiltIns": "usage",
9
- "corejs": {
10
- "version": 3,
11
- "proposals": true
12
- }
13
- }
14
- ],
15
- "@babel/preset-react"
16
- ],
17
- "env": {
18
- "test": {
19
- "presets": ["@babel/preset-env", "@babel/preset-react"]
20
- }
21
- }
22
- }
@@ -1,21 +0,0 @@
1
- name: Check code format
2
-
3
- on:
4
- push:
5
- branches:
6
- - "*"
7
-
8
- jobs:
9
- check-format:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - uses: actions/checkout@v2
13
- with:
14
- fetch-depth: 0
15
-
16
- - uses: actions/setup-node@v2
17
- with:
18
- node-version: 16
19
- registry-url: https://registry.npmjs.org
20
- - run: npm ci
21
- - run: npm run prettier:check
@@ -1,24 +0,0 @@
1
- # Workflow name
2
- name: "Chromatic"
3
-
4
- # Event for the workflow
5
- on: push
6
-
7
- # List of jobs
8
- jobs:
9
- chromatic-deployment:
10
- # Operating System
11
- runs-on: ubuntu-latest
12
- # Job steps
13
- steps:
14
- - uses: actions/checkout@v1
15
- - name: Install dependencies
16
- run: npm install
17
- # 👇 Adds Chromatic as a step in the workflow
18
- - name: Publish to Chromatic
19
- uses: chromaui/action@v1
20
- # Chromatic GitHub Action options
21
- with:
22
- # 👇 Chromatic projectToken, refer to the manage page to obtain it.
23
- projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
24
- exitZeroOnChanges: true # 👈 Option to prevent the workflow from failing
package/.husky/pre-commit DELETED
@@ -1,4 +0,0 @@
1
- #!/bin/sh
2
- . "$(dirname "$0")/_/husky.sh"
3
-
4
- npm run prettier:check
package/.prettierignore DELETED
@@ -1,4 +0,0 @@
1
- package.json
2
- package-lock.json
3
- dist
4
- README.md
@@ -1,11 +0,0 @@
1
- module.exports = {
2
- stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
3
- addons: [
4
- "@storybook/addon-links",
5
- "@storybook/addon-essentials",
6
- "@storybook/addon-interactions",
7
- "@luigiminardim/storybook-addon-globals-controls",
8
- "@storybook/addon-a11y",
9
- ],
10
- framework: "@storybook/react",
11
- };