Skip to content

Commit

Permalink
Add textUI textareaUI + mock form cleanup (#29658)
Browse files Browse the repository at this point in the history
* add textUI and textareaUI

* cleanup mock form
  • Loading branch information
rhasselle-oddball authored and agravell047 committed May 9, 2024
1 parent fbb5d0e commit 2a52c5c
Show file tree
Hide file tree
Showing 20 changed files with 352 additions and 287 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import ConfirmationPage from '../containers/ConfirmationPage';
// pages
import chapterSelect from '../pages/chapterSelect';
import textInput from '../pages/mockTextInput';
import textInputWidgets1 from '../pages/mockTextInputWidgets1';
import textEmailPhone from '../pages/mockTextEmailPhone';
import numberInput from '../pages/mockNumberInput';
import textInputFullName from '../pages/mockTextInputFullName';
import textInputAddress from '../pages/mockTextInputAddress';
import textInputSsn from '../pages/mockTextInputSsn';
import fullName from '../pages/mockFullName';
import address from '../pages/mockAddress';
import ssn from '../pages/mockSsn';
import checkboxAndTextInput from '../pages/mockCheckboxAndTextInput';
import checkboxGroup from '../pages/mockCheckboxGroup';
import radio from '../pages/mockRadio';
Expand Down Expand Up @@ -103,34 +103,34 @@ const formConfig = {
schema: textInput.schema,
depends: includeChapter('textInput'),
},
textInputWidgets1: {
textEmailPhone: {
path: 'text-input-widgets1',
title: 'Text Input Widgets 1', // for review page (has to be more than one word)
uiSchema: textInputWidgets1.uiSchema,
schema: textInputWidgets1.schema,
uiSchema: textEmailPhone.uiSchema,
schema: textEmailPhone.schema,
depends: includeChapter('textInput'),
},
textInputFullName: {
fullName: {
path: 'text-input-full-name',
title: 'Text Input Full Name', // for review page (has to be more than one word)
uiSchema: textInputFullName.uiSchema,
schema: textInputFullName.schema,
initialData: textInputFullName.initialData,
uiSchema: fullName.uiSchema,
schema: fullName.schema,
initialData: fullName.initialData,
depends: includeChapter('textInput'),
},
textInputAddress: {
address: {
title: 'Text Input Address', // for review page (has to be more than one word)
path: 'text-input-address',
uiSchema: textInputAddress.uiSchema,
schema: textInputAddress.schema,
initialData: textInputAddress.initialData,
uiSchema: address.uiSchema,
schema: address.schema,
initialData: address.initialData,
depends: includeChapter('textInput'),
},
textInputSsn: {
ssn: {
title: 'SSN Pattern', // for review page (has to be more than one word)
path: 'ssn-pattern',
uiSchema: textInputSsn.uiSchema,
schema: textInputSsn.schema,
uiSchema: ssn.uiSchema,
schema: ssn.schema,
depends: includeChapter('textInput'),
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {
addressSchema,
addressUI,
titleUI,
} from 'platform/forms-system/src/js/web-component-patterns';

/** @type {PageSchema} */
export default {
uiSchema: {
...titleUI('Web component v3 address'),
wcv3Address: addressUI(),
},
schema: {
type: 'object',
properties: {
wcv3Address: addressSchema(),
},
required: [],
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @ts-check
import {
titleUI,
fullNameUI,
fullNameSchema,
} from 'platform/forms-system/src/js/web-component-patterns';

/** @type {PageSchema} */
export default {
uiSchema: {
...titleUI('Web component v3 full name'),
wcv3SpouseFullNameNew: fullNameUI(),
},
schema: {
type: 'object',
properties: {
wcv3SpouseFullNameNew: fullNameSchema,
},
required: [],
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
titleUI,
ssnOrVaFileNumberNoHintUI,
ssnOrVaFileNumberNoHintSchema,
} from 'platform/forms-system/src/js/web-component-patterns';

/** @type {PageSchema} */
export default {
uiSchema: {
...titleUI(
'Identification information',
'You must enter a Social Security number or VA file number',
),
wcv3SsnNew: ssnOrVaFileNumberNoHintUI(),
},
schema: {
type: 'object',
properties: {
wcv3SsnNew: ssnOrVaFileNumberNoHintSchema,
},
required: ['wcv3SsnNew'],
},
initialData: {},
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
ssnUI,
ssnSchema,
titleUI,
emailUI,
emailSchema,
Expand All @@ -11,20 +9,18 @@ import {
/** @type {PageSchema} */
export default {
uiSchema: {
...titleUI('Web component v3'),
...titleUI('Web component v3 email and phone'),
wcv3TextEmailNew: emailUI({
description:
'By providing an email address, I agree to receive electronic correspondence from VA regarding my application',
}),
wcv3TextPhoneNew: phoneUI(),
wcv3TextSsnNew: ssnUI(),
},
schema: {
type: 'object',
properties: {
wcv3TextEmailNew: emailSchema,
wcv3TextPhoneNew: phoneSchema,
wcv3TextSsnNew: ssnSchema,
},
required: ['wcv3TextEmailNew'],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,135 +1,69 @@
/* eslint-disable no-unused-vars */
import React from 'react';
import VaTextInputField from 'platform/forms-system/src/js/web-component-fields/VaTextInputField';
import {
inlineTitleSchema,
inlineTitleUI,
titleUI,
} from 'platform/forms-system/src/js/web-component-patterns/titlePattern';
import VaTextareaField from 'platform/forms-system/src/js/web-component-fields/VaTextareaField';
textUI,
textSchema,
textareaUI,
} from 'platform/forms-system/src/js/web-component-patterns';

/** @type {PageSchema} */
export default {
uiSchema: {
// Example of using a function:
// Only use this if you need it because it will rerender every time (only on this page)
...titleUI(({ formData, formContext }) => {
return 'RJSF';
return 'Web component v3 text fields';
}),
simpleOld: {
'ui:title': 'TextWidget - with string description',
'ui:description': 'Text description',
},
requiredOld: {
'ui:title': 'TextWidget - with JSX description',
'ui:description': (
<va-additional-info trigger="JSX description">
We need the Veteran’s Social Security number or tax identification
number to process the application when it’s submitted online, but it’s
not a requirement to apply for the program.
</va-additional-info>
),
'ui:errorMessages': {
required: 'Please enter a value',
},
},
disabledOld: {
'ui:title': 'TextWidget - disabled',
'ui:disabled': true,
},
'view:wcv3Title': inlineTitleUI('Web component v3'),
wcv3SimpleNew: {
'ui:title': 'VaTextInputField - with string description',
'ui:webComponentField': VaTextInputField,
'ui:description': 'Text description',
},
wcv3RequiredNew: {
'ui:title': 'VaTextInputField - with JSX description',
'ui:webComponentField': VaTextInputField,
'ui:description': (
wcv3SimpleNew: textUI({
title: 'VaTextInputField - with string description',
description: 'Text description',
}),
wcv3RequiredNew: textUI({
title: 'VaTextInputField - with JSX description',
description: (
<va-additional-info trigger="JSX description">
We need the Veteran’s Social Security number or tax identification
number to process the application when it’s submitted online, but it’s
not a requirement to apply for the program.
</va-additional-info>
),
'ui:errorMessages': {
errorMessages: {
required: 'Please enter a value',
},
'ui:options': {
hideIf: formData => formData.hide,
hideOnReview: true,
},
},
wcv3HintNew: {
'ui:title': 'VaTextInputField - with string hint',
'ui:webComponentField': VaTextInputField,
'ui:options': {
hint: 'This is a hint',
},
},
wcv3InputmodeDecimalNew: {
'ui:title': 'VaTextInputField - with decimal inputmode',
'ui:webComponentField': VaTextInputField,
'ui:options': {
inputmode: 'decimal',
},
},
wcv3TextAreaNew: {
'ui:title': 'VaTextareaField (short hint)',
'ui:description': 'Text description',
'ui:webComponentField': VaTextareaField,
'ui:options': {
charcount: true,
hint: 'Normal hint',
},
},
wcv3DisabledNew: {
'ui:title': 'VaTextInputField - disabled',
'ui:description': (
<va-additional-info trigger="Disabled not supported for v3">
v3 does not support disabled fields. Solve with better pattern
instead, for example one question per page.
</va-additional-info>
),
'ui:webComponentField': VaTextInputField,
'ui:disabled': true, // not supported for v3
},
hideIf: formData => formData.hide,
hideOnReview: true,
}),
wcv3HintNew: textUI({
title: 'VaTextInputField with charcount',
hint: 'This is a hint',
width: 'md',
charcount: true,
}),
wcv3TextAreaNew: textareaUI({
title: 'VaTextareaField',
description: 'Text description',
hint: 'Normal hint',
charcount: true,
}),
},
schema: {
type: 'object',
properties: {
simpleOld: {
type: 'string',
},
requiredOld: {
type: 'string',
},
disabledOld: {
type: 'string',
},
'view:wcv3Title': inlineTitleSchema,
wcv3SimpleNew: {
type: 'string',
},
wcv3RequiredNew: {
type: 'string',
},
wcv3SimpleNew: textSchema,
wcv3RequiredNew: textSchema,
wcv3HintNew: {
type: 'string',
},
wcv3InputmodeDecimalNew: {
type: 'string',
maxLength: 24,
},
wcv3TextAreaNew: {
type: 'string',
maxLength: 30,
minLength: 10,
},
wcv3DisabledNew: {
type: 'string',
},
},
required: ['requiredOld', 'wcv3RequiredNew', 'wcv3TextAreaNew'],
required: ['wcv3RequiredNew', 'wcv3TextAreaNew'],
},
};

This file was deleted.

Loading

0 comments on commit 2a52c5c

Please sign in to comment.