Skip to content

Commit

Permalink
feat(@dpc-sdp/ripple-ui-forms): add webform autocomplete attribute su…
Browse files Browse the repository at this point in the history
…pport
  • Loading branch information
David Featherston committed Sep 4, 2024
1 parent cd987b4 commit 2e21be5
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/nuxt-app/test/features/landingpage/forms.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ Feature: Forms
| help | required |
| Enter your message | true |
Then a hidden field named "site_section" should exist with the value "DPC"
And the following field attributes should exist
| field | attribute | value |
| Last name | autocomplete | on |
| Role | autocomplete | off |
| Email | autocomplete | email |

@mockserver
Scenario: Error summary
Expand Down
3 changes: 3 additions & 0 deletions examples/nuxt-app/test/fixtures/landingpage/full-form.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"$formkit": "RplFormText",
"name": "last_name",
"label": "Last name",
"autocomplete": "on",
"id": "last_name",
"validation": "",
"validationMessages": {}
Expand All @@ -84,6 +85,7 @@
"label": "Role",
"id": "role",
"help": "Enter your role",
"autocomplete": "off",
"counter": "word",
"counterMin": 0,
"counterMax": 5,
Expand All @@ -97,6 +99,7 @@
"name": "email",
"label": "Email",
"id": "email",
"autocomplete": "email",
"validation": "email",
"validationMessages": {
"email": "Email must be a valid email address"
Expand Down
13 changes: 13 additions & 0 deletions packages/ripple-test-utils/step_definitions/components/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,19 @@ Then(
}
)

Then('the following field attributes should exist', (dataTable: DataTable) => {
const table = dataTable.hashes()

table.forEach((row) => {
cy.get('label.rpl-form-label')
.contains(row.field)
.closest('.rpl-form__outer')
.as('field')

cy.get('@field').find('input').should('have.attr', row.attribute, row.value)
})
})

// Extended
Then(
'a field labelled {string} should exist with the CSS class {string}',
Expand Down
6 changes: 6 additions & 0 deletions packages/ripple-tide-webform/mapping/webforms-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const getFormSchemaFromMapping = async (
id: fieldID,
help: field['#description'] || field['#help_title'],
value: field['#default_value'],
autocomplete: field['#autocomplete'],
...getValidationAndConditionals(field),
...getInputIcons(field)
}
Expand All @@ -67,6 +68,7 @@ export const getFormSchemaFromMapping = async (
id: fieldID,
help: field['#description'] || field['#help_title'],
value: field['#default_value'],
autocomplete: field['#autocomplete'],
...getValidationAndConditionals(field),
...getInputIcons(field)
}
Expand All @@ -82,6 +84,7 @@ export const getFormSchemaFromMapping = async (
id: fieldID,
help: field['#description'] || field['#help_title'],
value: field['#default_value'],
autocomplete: field['#autocomplete'],
min: field['#min'],
max: field['#max'],
step: field['#step'],
Expand All @@ -100,6 +103,7 @@ export const getFormSchemaFromMapping = async (
id: fieldID,
help: field['#description'] || field['#help_title'],
value: field['#default_value'],
autocomplete: field['#autocomplete'],
...getValidationAndConditionals(field),
...getInputIcons(field)
}
Expand All @@ -115,6 +119,7 @@ export const getFormSchemaFromMapping = async (
id: fieldID,
help: field['#description'] || field['#help_title'],
value: field['#default_value'],
autocomplete: field['#autocomplete'],
...getValidationAndConditionals(field),
...getInputIcons(field)
}
Expand All @@ -131,6 +136,7 @@ export const getFormSchemaFromMapping = async (
rows: field['#rows'],
help: field['#description'] || field['#help_title'],
value: field['#default_value'],
autocomplete: field['#autocomplete'],
...getValidationAndConditionals(field)
}
break
Expand Down
1 change: 1 addition & 0 deletions packages/ripple-ui-forms/src/inputs/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const email: FormKitTypeDefinition = {
props: [
...minMaxProps,
'placeholder',
'autocomplete',
'validationMeta',
'columnClasses',
'pii'
Expand Down
1 change: 1 addition & 0 deletions packages/ripple-ui-forms/src/inputs/input-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export const defaultRplFormInputProps = {
prefixIcon: '$node.props.prefixIcon',
suffixIcon: '$node.props.suffixIcon',
value: '$_value',
autocomplete: '$node.props.autocomplete',
disabled: '$node.context.disabled',
placeholder: '$node.context.placeholder',
options: '$node.context.options',
Expand Down
1 change: 1 addition & 0 deletions packages/ripple-ui-forms/src/inputs/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const number: FormKitTypeDefinition = {
'max',
'step',
'placeholder',
'autocomplete',
'validationMeta',
'columnClasses',
'pii',
Expand Down
1 change: 1 addition & 0 deletions packages/ripple-ui-forms/src/inputs/tel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const tel: FormKitTypeDefinition = {
props: [
...minMaxProps,
'placeholder',
'autocomplete',
'validationMeta',
'columnClasses',
'pii'
Expand Down
1 change: 1 addition & 0 deletions packages/ripple-ui-forms/src/inputs/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const text: FormKitTypeDefinition = {
...minMaxProps,
...counterProps,
'placeholder',
'autocomplete',
'validationMeta',
'columnClasses',
'pii'
Expand Down
2 changes: 2 additions & 0 deletions packages/ripple-ui-forms/src/inputs/textarea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const textarea: FormKitTypeDefinition = {
label: '$label',
disabled: '$node.context.disabled',
placeholder: '$node.props.placeholder',
autocomplete: '$node.props.autocomplete',
rows: '$node.props.rows',
options: '$node.props.options',
validationMeta: '$node.props.validationMeta',
Expand Down Expand Up @@ -56,6 +57,7 @@ export const textarea: FormKitTypeDefinition = {
...counterProps,
'rows',
'placeholder',
'autocomplete',
'validationMeta',
'columnClasses',
'pii'
Expand Down
1 change: 1 addition & 0 deletions packages/ripple-ui-forms/src/inputs/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const url: FormKitTypeDefinition = {
props: [
...minMaxProps,
'placeholder',
'autocomplete',
'validationMeta',
'columnClasses',
'pii'
Expand Down

0 comments on commit 2e21be5

Please sign in to comment.