@nolwenture/formik-jsonschema-form 1.0.0-beta.2 → 1.0.0-beta.21

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 (134) hide show
  1. package/README.md +25 -3
  2. package/dist/cjs/Form/components/Clickable.js +0 -7
  3. package/dist/cjs/Form/components/ErrorMessage.js +17 -7
  4. package/dist/cjs/Form/components/FieldInfo.js +26 -22
  5. package/dist/cjs/Form/components/FieldInput.js +38 -23
  6. package/dist/cjs/Form/components/Form.js +25 -15
  7. package/dist/cjs/Form/components/index.js +17 -7
  8. package/dist/cjs/Form/fields/AnyField/index.js +17 -7
  9. package/dist/cjs/Form/fields/ArrayField/ArrayField.js +20 -8
  10. package/dist/cjs/Form/fields/ArrayField/index.js +17 -7
  11. package/dist/cjs/Form/fields/BooleanField/BooleanField.js +1 -1
  12. package/dist/cjs/Form/fields/BooleanField/index.js +17 -7
  13. package/dist/cjs/Form/fields/BooleanField/styledComponents.js +5 -1
  14. package/dist/cjs/Form/fields/DateField/DateField.js +1 -1
  15. package/dist/cjs/Form/fields/DateField/index.js +17 -7
  16. package/dist/cjs/Form/fields/FileUploadField/index.js +17 -7
  17. package/dist/cjs/Form/fields/FileUploadField/styledComponents.js +6 -6
  18. package/dist/cjs/Form/fields/MultipleChoiceField/MultipleChoiceField.js +1 -1
  19. package/dist/cjs/Form/fields/MultipleChoiceField/index.js +17 -7
  20. package/dist/cjs/Form/fields/MultipleChoiceField/styledComponents.js +2 -0
  21. package/dist/cjs/Form/fields/NullField/index.js +17 -7
  22. package/dist/cjs/Form/fields/NumberField/index.js +17 -7
  23. package/dist/cjs/Form/fields/ObjectField/ObjectField.js +32 -13
  24. package/dist/cjs/Form/fields/ObjectField/index.js +17 -7
  25. package/dist/cjs/Form/fields/ObjectField/styledComponents.js +5 -5
  26. package/dist/cjs/Form/fields/RadioField/RadioField.js +1 -1
  27. package/dist/cjs/Form/fields/RadioField/index.js +17 -7
  28. package/dist/cjs/Form/fields/RadioField/styledComponents.js +5 -1
  29. package/dist/cjs/Form/fields/SchemaField/index.js +17 -7
  30. package/dist/cjs/Form/fields/SearchableMultiTagSelectField/index.js +17 -7
  31. package/dist/cjs/Form/fields/SearchableMultiTagSelectField/styledComponents.js +8 -8
  32. package/dist/cjs/Form/fields/SearchableSelectField/index.js +17 -7
  33. package/dist/cjs/Form/fields/SearchableSelectField/styledComponents.js +11 -8
  34. package/dist/cjs/Form/fields/StringField/StringField.js +4 -2
  35. package/dist/cjs/Form/fields/StringField/index.js +17 -7
  36. package/dist/cjs/Form/fields/TextAreaField/TextAreaField.js +1 -1
  37. package/dist/cjs/Form/fields/TextAreaField/index.js +17 -7
  38. package/dist/cjs/Form/fields/TextAreaField/styledComponents.js +5 -4
  39. package/dist/cjs/Form/fields/ToggleField/ToggleField.js +1 -1
  40. package/dist/cjs/Form/fields/ToggleField/index.js +17 -7
  41. package/dist/cjs/Form/fields/ToggleField/styledComponents.js +8 -4
  42. package/dist/cjs/Form/fields/index.js +17 -7
  43. package/dist/cjs/Form/index.js +1 -0
  44. package/dist/cjs/Form/styles/common.js +50 -32
  45. package/dist/cjs/Form/templates/ArrayFieldTemplate/index.js +17 -7
  46. package/dist/cjs/Form/templates/CollapsibleObjectFieldTemplate/CollapsibleObjectFieldTemplate.js +2 -2
  47. package/dist/cjs/Form/templates/CollapsibleObjectFieldTemplate/index.js +17 -7
  48. package/dist/cjs/Form/templates/FieldTemplate/index.js +17 -7
  49. package/dist/cjs/Form/templates/ObjectFieldTemplate/index.js +17 -7
  50. package/dist/cjs/Form/templates/ObjectFieldTemplate/styledComponents.js +2 -2
  51. package/dist/cjs/Form/templates/index.js +17 -7
  52. package/dist/cjs/FormView/FormView.js +11 -4
  53. package/dist/cjs/FormView/components/Field.js +115 -9
  54. package/dist/cjs/FormView/components/index.js +17 -9
  55. package/dist/cjs/FormView/fields/ObjectField/ObjectField.js +1 -1
  56. package/dist/cjs/FormView/fields/ObjectField/index.js +17 -7
  57. package/dist/cjs/FormView/fields/index.js +17 -7
  58. package/dist/cjs/FormView/index.js +12 -2
  59. package/dist/cjs/FormView/templates/ArrayFieldTemplate/index.js +17 -7
  60. package/dist/cjs/FormView/templates/CollapsibleObjectFieldTemplate/index.js +17 -7
  61. package/dist/cjs/FormView/templates/FieldTemplate/index.js +17 -7
  62. package/dist/cjs/FormView/templates/ObjectFieldTemplate/index.js +17 -7
  63. package/dist/cjs/FormView/templates/ObjectFieldTemplate/styledComponents.js +8 -1
  64. package/dist/cjs/FormView/templates/index.js +17 -7
  65. package/dist/cjs/FormView/types/index.js +2 -0
  66. package/dist/cjs/index.js +1 -14
  67. package/dist/cjs/styles/types.js +2 -0
  68. package/dist/cjs/utils/createValidationSchema.js +17 -7
  69. package/dist/cjs/utils/getTitleAndDescription.js +6 -5
  70. package/dist/cjs/utils/index.js +1 -0
  71. package/dist/cjs/utils/orderAdditionalProperties.js +46 -0
  72. package/dist/esm/Form/components/Clickable.js +0 -7
  73. package/dist/esm/Form/components/FieldInfo.js +26 -22
  74. package/dist/esm/Form/components/FieldInput.js +20 -15
  75. package/dist/esm/Form/components/Form.js +8 -8
  76. package/dist/esm/Form/fields/ArrayField/ArrayField.js +20 -8
  77. package/dist/esm/Form/fields/BooleanField/BooleanField.js +1 -1
  78. package/dist/esm/Form/fields/BooleanField/styledComponents.js +5 -1
  79. package/dist/esm/Form/fields/DateField/DateField.js +1 -1
  80. package/dist/esm/Form/fields/FileUploadField/styledComponents.js +6 -6
  81. package/dist/esm/Form/fields/MultipleChoiceField/MultipleChoiceField.js +1 -1
  82. package/dist/esm/Form/fields/MultipleChoiceField/styledComponents.js +2 -0
  83. package/dist/esm/Form/fields/ObjectField/ObjectField.js +33 -14
  84. package/dist/esm/Form/fields/ObjectField/styledComponents.js +5 -5
  85. package/dist/esm/Form/fields/RadioField/RadioField.js +1 -1
  86. package/dist/esm/Form/fields/RadioField/styledComponents.js +5 -1
  87. package/dist/esm/Form/fields/SearchableMultiTagSelectField/styledComponents.js +8 -8
  88. package/dist/esm/Form/fields/SearchableSelectField/styledComponents.js +11 -8
  89. package/dist/esm/Form/fields/StringField/StringField.js +4 -2
  90. package/dist/esm/Form/fields/TextAreaField/TextAreaField.js +1 -1
  91. package/dist/esm/Form/fields/TextAreaField/styledComponents.js +5 -4
  92. package/dist/esm/Form/fields/ToggleField/ToggleField.js +1 -1
  93. package/dist/esm/Form/fields/ToggleField/styledComponents.js +8 -4
  94. package/dist/esm/Form/index.js +1 -0
  95. package/dist/esm/Form/styles/common.js +50 -32
  96. package/dist/esm/Form/templates/CollapsibleObjectFieldTemplate/CollapsibleObjectFieldTemplate.js +2 -2
  97. package/dist/esm/Form/templates/ObjectFieldTemplate/styledComponents.js +2 -2
  98. package/dist/esm/FormView/FormView.js +7 -3
  99. package/dist/esm/FormView/components/Field.js +108 -7
  100. package/dist/esm/FormView/components/index.js +0 -2
  101. package/dist/esm/FormView/fields/ObjectField/ObjectField.js +1 -1
  102. package/dist/esm/FormView/index.js +9 -2
  103. package/dist/esm/FormView/templates/ObjectFieldTemplate/styledComponents.js +8 -1
  104. package/dist/esm/FormView/types/index.js +1 -0
  105. package/dist/esm/index.js +1 -1
  106. package/dist/esm/styles/types.js +1 -0
  107. package/dist/esm/utils/getTitleAndDescription.js +6 -5
  108. package/dist/esm/utils/index.js +1 -0
  109. package/dist/esm/utils/orderAdditionalProperties.js +43 -0
  110. package/dist/types/Form/components/FieldInput.d.ts +5 -0
  111. package/dist/types/Form/components/index.d.ts +5 -0
  112. package/dist/types/Form/index.d.ts +1 -0
  113. package/dist/types/Form/templates/ArrayFieldTemplate/types.d.ts +0 -4
  114. package/dist/types/Form/templates/FieldTemplate/types.d.ts +0 -4
  115. package/dist/types/FormView/FormView.d.ts +3 -3
  116. package/dist/types/FormView/components/Field.d.ts +36 -3
  117. package/dist/types/FormView/components/index.d.ts +15 -14
  118. package/dist/types/FormView/index.d.ts +10 -2
  119. package/dist/types/FormView/templates/ArrayFieldTemplate/types.d.ts +0 -4
  120. package/dist/types/FormView/templates/CollapsibleObjectFieldTemplate/CollapsibleObjectFieldTemplate.d.ts +1 -1
  121. package/dist/types/FormView/templates/FieldTemplate/types.d.ts +0 -4
  122. package/dist/types/FormView/templates/index.d.ts +1 -1
  123. package/dist/types/FormView/types/index.d.ts +1 -0
  124. package/dist/types/common/types/Field.d.ts +0 -3
  125. package/dist/types/common/types/Schemas.d.ts +11 -8
  126. package/dist/types/index.d.ts +1 -1
  127. package/dist/types/styles/types.d.ts +216 -0
  128. package/dist/types/utils/getTitleAndDescription.d.ts +1 -1
  129. package/dist/types/utils/index.d.ts +1 -0
  130. package/dist/types/utils/orderAdditionalProperties.d.ts +1 -0
  131. package/package.json +23 -14
  132. package/dist/cjs/FormView/components/old_styledComponents.js +0 -65
  133. package/dist/esm/FormView/components/old_styledComponents.js +0 -57
  134. package/dist/types/FormView/components/old_styledComponents.d.ts +0 -32
@@ -7,8 +7,8 @@ export const ToggleFieldToggle = styled.span `
7
7
  left: 0;
8
8
  right: 0;
9
9
  bottom: 0;
10
- background: ${(props) => props.theme.intent.none};
11
- border: ${(props) => `${props.theme.strokeWidth.thin} solid ${props.theme.border.default}`};
10
+ background: ${(props) => props.theme.color.intent.default.none};
11
+ border: ${(props) => `${props.theme.strokeWidth.thin} solid ${props.theme.color.border.default}`};
12
12
  -webkit-transition: 0.4s;
13
13
  transition: 0.4s;
14
14
  border-radius: ${(props) => props.theme.borderRadius.circle};
@@ -18,7 +18,7 @@ export const ToggleFieldToggle = styled.span `
18
18
  content: "";
19
19
  height: 0.9rem;
20
20
  width: 0.9rem;
21
- background: ${(props) => props.theme.background.default};
21
+ background: ${(props) => props.theme.color.background.default};
22
22
  -webkit-transition: 0.4s;
23
23
  transition: 0.4s;
24
24
  border-radius: ${(props) => props.theme.borderRadius.circle};
@@ -30,6 +30,10 @@ export const ToggleFieldLabel = styled.label `
30
30
  position: relative;
31
31
  display: inline-block;
32
32
  width: 2rem;
33
+
34
+ &:has(input[readonly]) {
35
+ pointer-events: none;
36
+ }
33
37
  `;
34
38
  export const ToggleFieldInputElement = styled(FieldInput) `
35
39
  opacity: 0;
@@ -37,7 +41,7 @@ export const ToggleFieldInputElement = styled(FieldInput) `
37
41
  height: 0;
38
42
 
39
43
  &:checked + ${ToggleFieldToggle} {
40
- //background: ${(props) => props.theme.background.input};
44
+ //background: ${(props) => props.theme.color.background.input};
41
45
  }
42
46
 
43
47
  &:focus + ${ToggleFieldToggle} {
@@ -7,4 +7,5 @@ import { fields as FormFields } from "./fields";
7
7
  import { components as FormComponents } from "./components";
8
8
  import { templates as FormTemplates } from "./templates";
9
9
  export * from "./Form";
10
+ export * from "./FormRegistry";
10
11
  export { FormComponents, FormFields, FormTemplates };
@@ -2,12 +2,12 @@ import { css } from "styled-components";
2
2
  import { darken, readableColor } from "polished";
3
3
  export const commonButtonStyles = css `
4
4
  button {
5
- background-color: ${(props) => props.theme.intent.none};
5
+ background-color: ${(props) => props.theme.color.intent.default.none};
6
6
  border: none;
7
7
  font-size: ${(props) => props.theme.typography.size.base};
8
8
  &:hover {
9
- background: ${(props) => darken(0.1, props.theme.intent.none)};
10
- color: ${(props) => readableColor(darken(0.1, props.theme.intent.none))};
9
+ background: ${(props) => darken(0.1, props.theme.color.intent.default.none)};
10
+ color: ${(props) => readableColor(darken(0.1, props.theme.color.intent.default.none))};
11
11
  }
12
12
  padding: ${(props) => `${props.theme.spacing.m} ${props.theme.spacing.l}`};
13
13
 
@@ -18,17 +18,17 @@ export const commonButtonStyles = css `
18
18
  `;
19
19
  export const commonInputStyles = css `
20
20
  input {
21
- background-color: ${(props) => props.theme.background.input};
21
+ background-color: ${(props) => props.theme.color.background.input};
22
22
  border-radius: ${(props) => props.theme.borderRadius.none};
23
23
  border: ${(props) => `${props.theme.strokeWidth.thin} solid
24
- ${props.theme.border.default}`};
25
- color: ${(props) => props.theme.text.default};
24
+ ${props.theme.color.border.default}`};
25
+ color: ${(props) => props.theme.color.text.default};
26
26
  font-family: ${(props) => props.theme.typography.fontFamily.base};
27
27
  font-size: ${(props) => props.theme.typography.size.base};
28
28
  padding: ${(props) => props.theme.spacing.s};
29
29
 
30
30
  ::placeholder {
31
- color: ${(props) => props.theme.text.muted};
31
+ color: ${(props) => props.theme.color.text.muted};
32
32
  }
33
33
 
34
34
  &:focus {
@@ -41,11 +41,11 @@ export const commonCheckboxStyles = css `
41
41
  margin-left: 0;
42
42
  -webkit-appearance: none;
43
43
  appearance: none;
44
- background-color: ${(props) => props.theme.background.input};
44
+ background-color: ${(props) => props.theme.color.background.input};
45
45
  border-radius: ${(props) => props.theme.borderRadius.none};
46
46
  border: ${(props) => props.theme.strokeWidth.thin} solid
47
- ${(props) => props.theme.border.default};
48
- color: ${(props) => readableColor(props.theme.background.input)};
47
+ ${(props) => props.theme.color.border.default};
48
+ color: ${(props) => readableColor(props.theme.color.background.input)};
49
49
  cursor: pointer;
50
50
  display: grid;
51
51
  font: inherit;
@@ -133,7 +133,7 @@ export const commonCheckboxStyles = css `
133
133
  }
134
134
 
135
135
  &:checked {
136
- background-color: ${(props) => props.theme.intent.none};
136
+ background-color: ${(props) => props.theme.color.intent.default.none};
137
137
 
138
138
  &:before {
139
139
  transform: scale(1);
@@ -145,11 +145,11 @@ export const commonRadioStyles = css `
145
145
  input[type="radio"] {
146
146
  -webkit-appearance: none;
147
147
  appearance: none;
148
- background-color: ${(props) => props.theme.background.input};
148
+ background-color: ${(props) => props.theme.color.background.input};
149
149
  border-radius: ${(props) => props.theme.borderRadius.circle};
150
150
  border: ${(props) => props.theme.strokeWidth.thin} solid
151
- ${(props) => props.theme.border.default};
152
- color: ${(props) => readableColor(props.theme.background.input)};
151
+ ${(props) => props.theme.color.border.default};
152
+ color: ${(props) => readableColor(props.theme.color.background.input)};
153
153
  cursor: pointer;
154
154
  display: grid;
155
155
  font: inherit;
@@ -174,7 +174,7 @@ export const commonRadioStyles = css `
174
174
  }
175
175
 
176
176
  &:checked {
177
- background-color: ${(props) => props.theme.intent.none};
177
+ background-color: ${(props) => props.theme.color.intent.default.none};
178
178
 
179
179
  &:before {
180
180
  transform: scale(1);
@@ -183,26 +183,44 @@ export const commonRadioStyles = css `
183
183
  }
184
184
  `;
185
185
  export const commonSelectStyles = css `
186
- select {
187
- background-color: ${(props) => props.theme.background.input};
188
- border-radius: ${(props) => props.theme.borderRadius.none};
189
- border: ${(props) => `${props.theme.strokeWidth.thin} solid
190
- ${props.theme.border.default}`};
191
- color: ${(props) => props.theme.text.default};
192
- font-family: ${(props) => props.theme.typography.fontFamily.base};
193
- font-size: ${(props) => props.theme.typography.size.base};
194
- font-weight: ${(props) => props.theme.typography.weight.base};
195
- padding: ${(props) => `${props.theme.spacing.s}`};
186
+ select {
187
+ appearance: none;
188
+ -webkit-appearance: none;
189
+ -moz-appearance: none;
190
+ background-color: ${(props) => props.theme.color.background.input};
191
+ border-radius: ${(props) => props.theme.borderRadius.none};
192
+ border: ${(props) => `${props.theme.strokeWidth.thin} solid
193
+ ${props.theme.color.border.default}`};
194
+ color: ${(props) => props.theme.color.text.default};
195
+ cursor: pointer;
196
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
197
+ font-size: ${(props) => props.theme.typography.size.base};
198
+ font-weight: ${(props) => props.theme.typography.weight.normal};
199
+ outline: none;
200
+ padding: ${(props) => `${props.theme.spacing.s} ${props.theme.spacing.m}`};
201
+ width: 100%;
202
+
203
+ background-image: ${(props) => `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 320 512'%3E%3Cpath fill='${encodeURIComponent(props.theme.color.text.default)}' d='M31 192h258c17 0 26 21 14 33l-129 129c-8 8-21 8-29 0L17 225c-12-12-3-33 14-33z'/%3E%3C/svg%3E")`};
204
+ background-position: ${(props) => `right ${props.theme.spacing.m} top 50%`};
205
+ background-repeat: no-repeat;
206
+ background-size: ${(props) => props.theme.spacing.l}; auto;
196
207
 
197
- &:focus {
198
- ${(props) => props.theme.focus.default};
208
+ &:focus {
209
+ ${(props) => props.theme.focus.default};
210
+ }
211
+ }
212
+
213
+ select[multiple] {
214
+ appearance: auto;
215
+ background-image: none;
216
+ overflow: auto;
199
217
  }
200
- }
201
218
  `;
202
219
  export const datePickerIconStyles = css `
203
- ::-webkit-calendar-picker-indicator {
204
- background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="15" viewBox="0 0 24 24"><path fill="${(props) => props.theme.text.default}" d="M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 18H4V8h16v13z"/></svg>');
220
+ ::-webkit-calendar-picker-indicator {
221
+ background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="15" viewBox="0 0 24 24"><path fill="${(props) => props.theme.color.text
222
+ .default}" d="M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 18H4V8h16v13z"/></svg>');
205
223
 
206
- cursor: pointer;
207
- }
224
+ cursor: pointer;
225
+ }
208
226
  `;
@@ -9,9 +9,9 @@ export const CollapsibleObjectFieldTemplate = (props) => {
9
9
  const { children, name, uiSchema, ...otherProps } = props;
10
10
  const title = getTitle(props);
11
11
  const description = getDescription(props);
12
- const { help, info,
12
+ const { help, info, isCollapsedOnLoad = true, openIcon, collapsedIcon,
13
13
  //TODO: This is not right
14
- props: { wrapper: wrapperProps = {}, title: titleProps, description: descriptionProps, help: helpProps, isCollapsedOnLoad = true, openIcon, collapsedIcon, ariaLabel,
14
+ props: { wrapper: wrapperProps = {}, title: titleProps, description: descriptionProps, help: helpProps, ariaLabel,
15
15
  // error: errorProps,
16
16
  } = {}, } = useMemo(() => extractUiSchema(uiSchema), [uiSchema]);
17
17
  const dataAttributes = Object.keys(otherProps)
@@ -1,7 +1,7 @@
1
1
  import { styled } from "styled-components";
2
2
  import { commonInputStyles, commonSelectStyles } from "../../styles/common";
3
3
  export const ObjectFieldTemplateWrapper = styled.fieldset `
4
- color: ${(props) => props.theme.text.default};
4
+ color: ${(props) => props.theme.color.text.default};
5
5
  font-family: ${(props) => props.theme.typography.fontFamily.base};
6
6
  margin-inline: 0;
7
7
  margin-bottom: ${(props) => props.theme.spacing.xs};
@@ -9,7 +9,7 @@ export const ObjectFieldTemplateWrapper = styled.fieldset `
9
9
  ${commonSelectStyles}
10
10
  `;
11
11
  export const ObjectFieldTemplateTitle = styled.legend `
12
- color: ${(props) => props.theme.text.default};
12
+ color: ${(props) => props.theme.color.text.default};
13
13
  font-family: ${(props) => props.theme.typography.fontFamily.base};
14
14
  `;
15
15
  export const ObjectFieldTemplateDescription = undefined;
@@ -1,9 +1,14 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import styled from "styled-components";
2
3
  import { warnFromUnsupportedKeys } from "../utils";
3
4
  import { fields as defaultFields } from "./fields";
4
5
  import { components as defaultComponents } from "./components";
5
6
  import { templates as defaultTemplates } from "./templates";
6
7
  import { FormViewRegistry } from "./FormViewRegistry";
8
+ export const FormWrapper = styled.div `
9
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
10
+ //padding: ${(props) => props.theme.spacing.xxxxxl};
11
+ `;
7
12
  export const FormView = (props) => {
8
13
  warnFromUnsupportedKeys("Form", props, [
9
14
  "schema",
@@ -17,9 +22,8 @@ export const FormView = (props) => {
17
22
  "formContext",
18
23
  "components",
19
24
  "hideUnmarkedAdditionalProperties",
20
- "values",
21
25
  ]);
22
- const { schema, uiSchema = {}, className, fields = {}, templates = {}, components = {}, formContext = {}, useItemsAsAdditionalItems = false, hideUnmarkedAdditionalProperties = false, values = {}, } = props;
26
+ const { schema, uiSchema = {}, className, fields = {}, templates = {}, components = {}, formContext = {}, useItemsAsAdditionalItems = false, hideUnmarkedAdditionalProperties = false, } = props;
23
27
  const schemaDefinitions = schema.definitions;
24
28
  const uiSchemaDefinitions = uiSchema.definitions;
25
29
  const registry = {
@@ -34,5 +38,5 @@ export const FormView = (props) => {
34
38
  };
35
39
  const { Form: FormEl } = registry.components;
36
40
  const SchemaField = registry.fields.SchemaField;
37
- return (_jsx(FormViewRegistry.Provider, { value: registry, children: _jsx(FormEl, { className: className, children: _jsx(SchemaField, { name: "", schema: schema, uiSchema: uiSchema, values: values }) }) }));
41
+ return (_jsx(FormWrapper, { children: _jsx(FormViewRegistry.Provider, { value: registry, children: _jsx(FormEl, { className: className, children: _jsx(SchemaField, { name: "", schema: schema, uiSchema: uiSchema }) }) }) }));
38
42
  };
@@ -1,10 +1,111 @@
1
- import { styled } from "styled-components";
2
- export const FieldWrapper = styled.div ``;
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import styled from "styled-components";
3
+ import { MultipleChoiceFieldContainer, MultipleChoiceFieldElement, MultipleChoiceFieldLabel, } from "../../Form/fields/MultipleChoiceField/styledComponents";
4
+ import { getStyle } from "../../utils/getStyle";
5
+ export const FieldWrapper = styled.div `
6
+ color: ${(props) => props.theme.color.text.default};
7
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
8
+ margin: ${(props) => `${props.theme.spacing.l} 0`};
9
+ width: clamp(20rem, 100%, 70rem);
10
+ `;
3
11
  export const FieldTitle = styled.label `
4
- font-size: ${(props) => props.theme.typography.size.base};
12
+ break-before: avoid;
13
+ color: ${(props) => props.theme.color.text.default};
14
+ display: inline-block;
15
+ font-family: ${(props) => props.theme.typography.fontFamily.heading};
16
+ font-size: ${(props) => props.theme.typography.size.base};
17
+ font-weight: ${(props) => props.theme.typography.weight.bold};
18
+ margin: ${(props) => `${props.theme.spacing.xs} 0`};
19
+ padding-top: ${(props) => props.theme.spacing.s};
20
+ width: 100%;
21
+ `;
22
+ export const FieldDescription = styled.div `
23
+ break-before: avoid;
24
+ color: ${(props) => props.theme.color.text.default};
25
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
26
+ font-weight: ${(props) => props.theme.typography.weight.normal};
27
+ font-style: italic;
28
+ font-size: ${(props) => props.theme.typography.size.base};
29
+ margin-bottom: ${(props) => props.theme.spacing.xs};
30
+ max-width: 66ch;
31
+ `;
32
+ export const StringFieldValue = styled.div `
33
+ break-before: avoid;
34
+ color: ${(props) => props.theme.color.text.default};
35
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
36
+ margin-bottom: ${(props) => props.theme.spacing.m};
37
+ max-width: 66ch;
38
+ white-space: pre-line;
39
+ `;
40
+ export const TextAreaValue = styled.div `
41
+ break-before: avoid;
42
+ color: ${(props) => props.theme.color.text.default};
43
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
44
+ margin-bottom: ${(props) => props.theme.spacing.m};
45
+ max-width: 66ch;
46
+ white-space: pre-line;
47
+ `;
48
+ export const ArrayFieldItem = styled.div `
49
+ break-before: avoid;
50
+ color: ${(props) => props.theme.color.text.default};
51
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
52
+ `;
53
+ export const EJSFieldValue = styled.div `
54
+ break-before: avoid;
55
+ color: ${(props) => props.theme.color.text.default};
56
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
57
+ width: 100%;
58
+ `;
59
+ const NotSelected = styled.div `
60
+ opacity: 0.3;
61
+ display: flex;
62
+ align-items: start;
63
+ `;
64
+ const Selected = styled.div `
65
+ display: flex;
66
+ align-items: start;
67
+ `;
68
+ const SelectedBox = styled.span `
69
+ color: ${(props) => props.theme.color.background.default};
70
+ background: ${(props) => props.theme.color.text.default};
71
+ padding: ${(props) => `0 ${props.theme.spacing.xs}`};
72
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
73
+ font-size: ${(props) => props.theme.typography.size.small};
74
+ display: inline-flex;
75
+ justify-content: center;
76
+ align-items: start;
77
+ `;
78
+ const NotSelectedCircle = styled.span `
79
+ color: ${(props) => props.theme.color.background.default};
80
+ background: ${(props) => props.theme.color.text.default};
81
+ padding: ${(props) => props.theme.spacing.xxs};
82
+ border-radius: ${(props) => props.theme.borderRadius.circle};
5
83
  font-family: ${(props) => props.theme.typography.fontFamily.base};
6
- font-weight: ${(props) => props.theme.typography.weight.medium};
7
- margin-right: ${(props) => props.theme.spacing.s};
8
- color: ${(props) => props.theme.text.default};
84
+ font-size: ${(props) => props.theme.typography.size.small};
85
+ line-height: 1.1;
86
+ display: inline-flex;
87
+ justify-content: center;
88
+ align-items: start;
89
+ flex: 0 0 1rem;
90
+ `;
91
+ export const BooleanFieldWrapper = styled.div `
92
+ break-before: avoid;
93
+ font-family: ${(props) => props.theme.typography.fontFamily.base};
94
+
95
+ `;
96
+ export const MultipleChoiceFieldWrapper = styled.div `
97
+ break-before: avoid;
98
+ label {
99
+ align-items: start;
100
+ }
9
101
  `;
10
- export const FieldDescription = styled.div ``;
102
+ export const BooleanFieldValue = ({ name, className, value, label, }) => {
103
+ return (_jsx("div", { className: className, children: value === true ? (_jsxs("div", { children: [_jsx("span", { children: "\u2713" }), _jsx("span", { children: label !== undefined ? label : "Selected" })] })) : (_jsxs("div", { children: [_jsx("span", { children: "\u2716" }), _jsx("span", { children: label !== undefined ? label : "Not selected" })] })) }));
104
+ };
105
+ export const MultipleChoiceFieldValue = ({ inputProps, name, className, style, selected, notSelected }) => {
106
+ return (_jsx(MultipleChoiceFieldWrapper, { children: _jsxs(MultipleChoiceFieldContainer, { className: className, style: getStyle(style ?? ""), children: [!selected && !notSelected && _jsx(_Fragment, { children: "Nothing was selected" }), selected &&
107
+ selected.length > 0 &&
108
+ selected.map((s) => (_jsx(MultipleChoiceFieldElement, { children: _jsxs(Selected, { children: [_jsx(SelectedBox, { children: "\u2713" }), _jsx(MultipleChoiceFieldLabel, { children: s.title ?? "Hello" })] }) }, s.title ?? s))), notSelected &&
109
+ notSelected?.length > 0 &&
110
+ notSelected.map((n) => (_jsx(MultipleChoiceFieldElement, { children: _jsxs(NotSelected, { children: [_jsx(NotSelectedCircle, { children: "\u2715" }), _jsx(MultipleChoiceFieldLabel, { children: n.title })] }) }, n.title ?? n)))] }) }));
111
+ };
@@ -7,9 +7,7 @@ import { templateComponents } from "../templates";
7
7
  import * as Field from "./Field";
8
8
  import * as Form from "./Form";
9
9
  import * as Icon from "./Icon";
10
- import * as oldComponents from "./old_styledComponents";
11
10
  export const components = {
12
- ...oldComponents,
13
11
  ...fieldComponents,
14
12
  ...templateComponents,
15
13
  //Please keep this in alphabetical order
@@ -27,7 +27,7 @@ export const ObjectField = (props) => {
27
27
  setValue(newValue);
28
28
  }
29
29
  }, [valuesToRemove]);
30
- const FieldTemplateComponent = props.uiSchema?.props?.isCollapsible
30
+ const FieldTemplateComponent = props.uiSchema?.["ui:options"]?.isCollapsible
31
31
  ? CollapsibleObjectFieldTemplate
32
32
  : ObjectFieldTemplate;
33
33
  const orderedProperties = orderByUiSchema(uiSchema?.["ui:order"], Object.keys(properties || {}));
@@ -1,3 +1,10 @@
1
- export * from "./fields";
2
- export * from "./templates";
1
+ export * from "../utils";
2
+ export * from "../common/types";
3
+ export * from "../common/constants";
4
+ export * from "../common/FileUploadContext";
5
+ import { fields as FormViewFields } from "./fields";
6
+ import { components as FormViewComponents } from "./components";
7
+ import { templates as FormViewTemplates } from "./templates";
3
8
  export * from "./FormView";
9
+ export * from "./FormViewRegistry";
10
+ export { FormViewComponents, FormViewFields, FormViewTemplates };
@@ -1,6 +1,13 @@
1
1
  import styled from "styled-components";
2
2
  export const ObjectFieldTemplateWrapper = styled.div ``;
3
- export const ObjectFieldTemplateTitle = styled.div ``;
3
+ export const ObjectFieldTemplateTitle = styled.div `
4
+ break-before: avoid;
5
+ color: ${(props) => props.theme.color.text.default};
6
+ font-family: ${(props) => props.theme.typography.fontFamily.heading};
7
+ font-size: ${(props) => props.theme.typography.size.h4};
8
+ font-weight: ${(props) => props.theme.typography.weight.bold};
9
+ margin: ${(props) => `${props.theme.spacing.l} 0`};
10
+ `;
4
11
  export const ObjectFieldTemplateDescription = undefined;
5
12
  export function getComponents(components) {
6
13
  return {
@@ -0,0 +1 @@
1
+ export {};
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  //This file exists for purpose releasing "moduleResolution": "node" compatible version (until we split this to multiple packages)
2
2
  export * from "./Form";
3
- export * as view from "./FormView";
3
+ export * from "./FormView";
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,10 @@
1
1
  export const getTitle = ({ title, uiSchema, schema, name, }) => {
2
- return (title ||
3
- uiSchema?.["ui:options"]?.title ||
4
- uiSchema?.["ui:title"] ||
5
- schema?.title ||
6
- name?.split(".")[name?.split(".").length - 1]);
2
+ return uiSchema?.["ui:options"]?.hideTitle
3
+ ? undefined
4
+ : title ||
5
+ uiSchema?.["ui:title"] ||
6
+ schema?.title ||
7
+ name?.split(".")[name?.split(".").length - 1];
7
8
  };
8
9
  export const getDescription = ({ description, uiSchema, schema, }) => {
9
10
  return (description ||
@@ -9,6 +9,7 @@ export * from "./solveReferences";
9
9
  export * from "./createInitialValues";
10
10
  export * from "./createValidationSchema";
11
11
  export * from "./orderByUiSchema";
12
+ export * from "./orderAdditionalProperties";
12
13
  //TODO: REMOVE WHEN ALL SUPPORTED
13
14
  export const warnFromUnsupportedKeys = (componentName, data, supportedKeys) => {
14
15
  Object.keys(data).forEach((key) => {
@@ -0,0 +1,43 @@
1
+ export function orderAdditionalProperties(uiOrderArray, valuesArray) {
2
+ if (uiOrderArray.length === 0)
3
+ return valuesArray;
4
+ const includesAsterisk = uiOrderArray.includes("*");
5
+ const filteredValues = (arr) => arr.filter((element) => valuesArray.includes(element));
6
+ let finalArray = [];
7
+ if (!includesAsterisk) {
8
+ finalArray = filteredValues(uiOrderArray);
9
+ }
10
+ else {
11
+ const uiOrderArrayWithoutAsterisk = uiOrderArray.filter((item) => item !== "*");
12
+ if (uiOrderArray.length === 1) {
13
+ finalArray = valuesArray;
14
+ }
15
+ else if (uiOrderArray.indexOf("*") === 0) {
16
+ // wildcard is first element
17
+ const individualValues = valuesArray.filter((element) => !uiOrderArrayWithoutAsterisk.includes(element));
18
+ const commonValues = filteredValues(uiOrderArrayWithoutAsterisk);
19
+ finalArray = [...individualValues, ...commonValues];
20
+ }
21
+ else if (uiOrderArray.indexOf("*") === uiOrderArray.length - 1) {
22
+ // wildcard is final element
23
+ const individualValues = valuesArray.filter((element) => !uiOrderArrayWithoutAsterisk.includes(element));
24
+ const commonValues = filteredValues(uiOrderArrayWithoutAsterisk);
25
+ finalArray = [...commonValues, ...individualValues];
26
+ }
27
+ else {
28
+ // wildcard is somewhere in the middle
29
+ const indexForUnspecified = uiOrderArray.indexOf("*");
30
+ const definedBefore = uiOrderArray.slice(0, indexForUnspecified);
31
+ const definedAfter = uiOrderArray.slice(indexForUnspecified + 1);
32
+ const commonBeforeValues = filteredValues(definedBefore);
33
+ const commonAfterValues = filteredValues(definedAfter);
34
+ const individualValues = valuesArray.filter((element) => ![...commonBeforeValues, ...commonAfterValues].includes(element));
35
+ finalArray = [
36
+ ...commonBeforeValues,
37
+ ...individualValues,
38
+ ...commonAfterValues,
39
+ ];
40
+ }
41
+ }
42
+ return finalArray;
43
+ }
@@ -7,3 +7,8 @@ export declare const FieldHelp: import("styled-components/dist/types").IStyledCo
7
7
  export declare const FieldInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<any, "as">, "ref"> & {
8
8
  ref?: unknown;
9
9
  }, never>> & string & Omit<({ formikAs, ...props }: Omit<formik.FieldAttributes<any>, "as">) => import("react/jsx-runtime").JSX.Element, keyof React.Component<any, {}, any>>;
10
+ export declare const SelectFieldInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<Omit<Omit<any, "as">, "ref"> & {
11
+ ref?: unknown;
12
+ }, never>, "ref"> & {
13
+ ref?: unknown;
14
+ }, never>> & string;
@@ -19,6 +19,11 @@ export declare const components: {
19
19
  FieldInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<any, "as">, "ref"> & {
20
20
  ref?: unknown;
21
21
  }, never>> & string & Omit<({ formikAs, ...props }: Omit<import("formik").FieldAttributes<any>, "as">) => import("react/jsx-runtime").JSX.Element, keyof import("react").Component<any, {}, any>>;
22
+ SelectFieldInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<Omit<Omit<any, "as">, "ref"> & {
23
+ ref?: unknown;
24
+ }, never>, "ref"> & {
25
+ ref?: unknown;
26
+ }, never>> & string;
22
27
  FieldInfoBoxElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, import("../../common/types/FieldInfo").FieldInfoBoxElementProps>> & string;
23
28
  FieldInfoBoxArrowElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, import("../../common/types/FieldInfo").FieldInfoBoxElementProps>> & string;
24
29
  FieldInfoBoxInnerElement: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -7,5 +7,6 @@ import { fields as FormFields } from "./fields";
7
7
  import { components as FormComponents } from "./components";
8
8
  import { templates as FormTemplates } from "./templates";
9
9
  export * from "./Form";
10
+ export * from "./FormRegistry";
10
11
  export { FormComponents, FormFields, FormTemplates };
11
12
  export type * from "./types";
@@ -4,8 +4,4 @@ export type ArrayFieldTemplateProps = React.PropsWithChildren<{
4
4
  schema: Schema;
5
5
  [key: string]: any;
6
6
  uiSchema?: UiSchema;
7
- hidden?: boolean;
8
- required?: boolean;
9
- readonly?: boolean;
10
- disabled?: boolean;
11
7
  }>;
@@ -4,8 +4,4 @@ export type FieldTemplateProps = React.PropsWithChildren<{
4
4
  schema: Schema;
5
5
  [key: string]: any;
6
6
  uiSchema?: UiSchema;
7
- hidden?: boolean;
8
- required?: boolean;
9
- readonly?: boolean;
10
- disabled?: boolean;
11
7
  }>;
@@ -1,4 +1,4 @@
1
1
  import type { FormProps } from "../common/types";
2
- export declare const FormView: <T>(props: FormProps<T> & {
3
- values: Record<string, any>;
4
- }) => import("react/jsx-runtime").JSX.Element;
2
+ import React from "react";
3
+ export declare const FormWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
4
+ export declare const FormView: <T>(props: FormProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,36 @@
1
- export declare const FieldWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
2
- export declare const FieldTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, never>> & string;
3
- export declare const FieldDescription: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
1
+ import * as formik from "formik";
2
+ import React from "react";
3
+ export declare const FieldWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
4
+ export declare const FieldTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, never>> & string;
5
+ export declare const FieldDescription: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
6
+ export declare const StringFieldValue: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
7
+ export declare const TextAreaValue: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
8
+ export declare const ArrayFieldItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
9
+ export declare const EJSFieldValue: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
10
+ export declare const BooleanFieldWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
11
+ export declare const MultipleChoiceFieldWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
12
+ type BooleanValueFieldProps = {
13
+ name: string;
14
+ className?: string;
15
+ value: boolean;
16
+ label?: string;
17
+ };
18
+ export declare const BooleanFieldValue: React.FC<BooleanValueFieldProps>;
19
+ type MultipleChoiceFieldValueProps = {
20
+ selected: {
21
+ const: string | number;
22
+ title: string;
23
+ }[] | undefined;
24
+ notSelected: {
25
+ const: string | number;
26
+ title: string;
27
+ }[] | undefined;
28
+ inputProps?: any;
29
+ name?: React.ReactNode;
30
+ className?: string;
31
+ style?: string;
32
+ value?: string | number;
33
+ form?: formik.FormikContextType<unknown>;
34
+ };
35
+ export declare const MultipleChoiceFieldValue: React.FC<MultipleChoiceFieldValueProps>;
36
+ export {};