Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Forms): Extension (beta) for simplified implementation of web forms through tailored functionality for layout and data handling #2420

Merged
merged 41 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a265f46
feat(Forms): Reusable components for data input forms, data display a…
May 16, 2023
305b391
Move type package to devDeps, while relay on browser for `structuredC…
tujoworker Jun 22, 2023
cc99ef7
Move Option into Select
tujoworker Jun 22, 2023
526a60a
Run prettier --write
tujoworker Jul 3, 2023
1073596
Update yarn.lock
tujoworker Jul 5, 2023
7ce39ea
Remove size="medium"
tujoworker Jul 5, 2023
284fea1
Remove stretch = true so input fields behave like Eufemia default
tujoworker Jul 5, 2023
f72c106
Make tests React v18 compatible
tujoworker Jul 5, 2023
685d181
Beginning of first case demo example, field group component, some new…
henit Jul 21, 2023
a197134
Renaming forms-components
henit Jul 21, 2023
75812d8
Selection component extended and two level field component menu struc…
henit Aug 3, 2023
047f5c5
Rewrite Boolean field to Toggle for flexible on and off values and ad…
henit Aug 4, 2023
5d28336
At component
henit Aug 4, 2023
4857279
Fixing bugs on width and field layout, add missing property-docs
henit Aug 7, 2023
6974f06
Bank account number field and value component
henit Aug 8, 2023
47fae4b
Fix test
henit Aug 8, 2023
91063ac
Renamed useInput to useField, menu and doc cleanup
henit Aug 8, 2023
eb82902
Bugfixes
henit Aug 9, 2023
b8918fe
Review-cleanup
henit Aug 9, 2023
da30d35
Spacing in FlexContainer adds wrapper for unknown elements to ensure …
henit Aug 10, 2023
a46ac36
Cleanup
henit Aug 10, 2023
9cfd5bf
Cleanup
henit Aug 10, 2023
6f622ca
PostalCodeAndCity messages, error handling fix
henit Aug 10, 2023
7cf85f4
Value component bugfix, docs cleanup
henit Aug 11, 2023
7bd2887
Spacing-bugfix
henit Aug 11, 2023
8126143
Updated card border style
henit Aug 11, 2023
5001dbd
Fix id-bug on StepsLayout
henit Aug 11, 2023
be3193f
minor text improvements
langz Aug 15, 2023
66b9190
Callbck race condition fix
henit Aug 15, 2023
494850f
minor spelling improvements
langz Aug 15, 2023
47d3c0b
class dnb-forms-value to dnb-forms-value-block
langz Aug 15, 2023
c4f4f9b
minor spelling improvements
langz Aug 15, 2023
1c8d11f
fix: Warning: validateDOMNesting(...): <p> cannot appear as a descend…
langz Aug 15, 2023
89427e8
minor spelling improvement
langz Aug 15, 2023
99ff9fe
Internal state endless loop fix for Provider
henit Aug 15, 2023
94b2b7c
change status of forms to beta
langz Aug 15, 2023
c834ebe
Remove test-id in forms
henit Aug 16, 2023
d86822b
Remove forms case demo from index page
henit Aug 16, 2023
4cef5db
Move demo case to /demo-cases/Examples
tujoworker Aug 16, 2023
78defd3
Global status field fix
henit Aug 16, 2023
3992d54
Fix on masked text inputs
henit Aug 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions packages/dnb-design-system-portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@babel/node": "7.22.5",
"@emotion/cache": "11.11.0",
"@playwright/test": "1.35.1",
"@types/json-schema": "7.0.12",
"@types/react": "18.2.13",
"@types/react-dom": "18.2.6",
"@typescript-eslint/parser": "5.60.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: 'Forms'
description: 'Reusable components for data input, data display and surrounding layout for simplified user interface creation in React, built on top of base Eufemia components.'
showTabs: true
status: 'beta'
order: 2
tabs:
- title: Info
key: /uilib/extensions/forms/info
- title: Demos
key: /uilib/extensions/forms/demos
- title: Case demo 1
key: /uilib/extensions/forms/casedemo1
---

import Info from 'Docs/uilib/extensions/forms/info'
import Demos from 'Docs/uilib/extensions/forms/demos'

<Info />
<Demos />
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: 'DataContext'
order: 0
showTabs: true
tabs:
- title: Info
key: '/info'
- title: Components
key: '/components'
---

import Info from 'Docs/uilib/extensions/forms/DataContext/info'
import Components from 'Docs/uilib/extensions/forms/DataContext/components'

<Info />
<Components />
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: 'At'
description: '`DataContext.At` makes it possible to dig into a data set to set a pointer as the root for sub components, as well as iterate array-data'
showTabs: true
tabs:
- title: Info
key: '/info'
- title: Demos
key: '/demos'
- title: Properties
key: '/properties'
---

import Info from 'Docs/uilib/extensions/forms/DataContext/At/info'
import Demos from 'Docs/uilib/extensions/forms/DataContext/At/demos'
import Properties from 'Docs/uilib/extensions/forms/DataContext/At/properties'

<Info />
<Demos />
<Properties />
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import ComponentBox from '../../../../../../shared/tags/ComponentBox'
import {
DataContext,
Field,
Value,
} from '@dnb/eufemia/src/extensions/forms'

export const Path = () => {
return (
<ComponentBox scope={{ DataContext, Field }}>
<DataContext.Provider
data={{
foo: {
one: 1,
two: 2,
},
bar: 'Bar',
}}
>
<DataContext.At path="/foo">
<Field.Number path="/one" label="One" />
<Field.Number path="/two" label="Two" />
</DataContext.At>
</DataContext.Provider>
</ComponentBox>
)
}

export const IteratePath = () => {
return (
<ComponentBox scope={{ DataContext, Field, Value }}>
<DataContext.Provider
data={{
list: [
{
title: 'Object 1',
},
{
title: 'Object 2',
},
],
bar: 'Bar',
}}
onChange={(data) => console.log('onChange', data)}
onPathChange={(path, value) =>
console.log('onPathChange', path, value)
}
>
<DataContext.At path="/list" iterate>
<Value.String path="/title" label="Title" />
<Field.String path="/title" label="Title" />
</DataContext.At>
</DataContext.Provider>
</ComponentBox>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
showTabs: true
---

import * as Examples from './Examples'

## Demos

### At path

<Examples.Path />

### Iterate path

<Examples.IteratePath />
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
showTabs: true
---

## Description

`DataContext.At` makes it possible to dig into a data set to set a pointer as the root for sub components, as well as iterate array-data.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
showTabs: true
---

## Properties

| Property | Type | Description |
| ---------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `children` | `React.Node` | _(optional)_ Features with given path as root for the DataContext. |
| `path` | `string` | _(optional)_ JSON Pointer path to where in the outer DataContext source to point at. |
| `iterate` | `boolean` | _(optional)_ True to iterate elements at given path based on the source data, including the index in the outer path, instead of just rendering children once. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: 'Context'
description: 'The context object used in `DataContext.Provider`.'
showTabs: false
---

# DataContext.Context

## Description

The main context for [DataContext.Provider](/uilib/extensions/forms/DataContext/Provider) which the [Field](/uilib/extensions/forms/Field/) and [Value](/uilib/extensions/forms/Value/) components connect to (optional) for sources and callbacks when it is present. It can be used for creating custom components in similar ways.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react'
import { useStaticQuery, graphql } from 'gatsby'
import ListSummaryFromEdges from '../../../../../shared/parts/ListSummaryFromEdges'

export default function ListComponents() {
const {
allMdx: { edges },
} = useStaticQuery(graphql`
{
allMdx(
filter: {
frontmatter: {
title: { ne: null, nin: "Fragments" }
draft: { ne: true }
}
internal: {
contentFilePath: {
glob: "**/uilib/extensions/forms/DataContext/**/*"
}
}
}
sort: [
{ frontmatter: { order: ASC } }
{ frontmatter: { title: ASC } }
]
) {
edges {
node {
fields {
slug
}
frontmatter {
title
description
}
}
}
}
}
`)

return <ListSummaryFromEdges edges={edges} />
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: 'Provider'
description: '`DataContext.Provider` is the context provider that has to wrap the features if components of Field and Value is to be used with a common source instead of distributing values and events individually.'
showTabs: true
tabs:
- title: Info
key: '/info'
- title: Demos
key: '/demos'
- title: Properties
key: '/properties'
- title: Events
key: '/events'
---

import Info from 'Docs/uilib/extensions/forms/DataContext/Provider/info'
import Demos from 'Docs/uilib/extensions/forms/DataContext/Provider/demos'
import Properties from 'Docs/uilib/extensions/forms/DataContext/Provider/properties'
import Events from 'Docs/uilib/extensions/forms/DataContext/Provider/events'

<Info />
<Demos />
<Properties />
<Events />
Loading