-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66ddb48
commit d549870
Showing
28 changed files
with
483 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
...es/dnb-design-system-portal/src/docs/uilib/extensions/forms/Form/FieldProps.mdx
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...gn-system-portal/src/docs/uilib/extensions/forms/Form/FieldProps/properties.mdx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...esign-system-portal/src/docs/uilib/extensions/forms/feature-fields/Provider.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: 'Field.Provider' | ||
description: '`Field.Provider` is a provider for forwarding fields properties, such as `required` or `disabled` to all nested field components.' | ||
hideInMenu: true | ||
showTabs: true | ||
tabs: | ||
- title: Info | ||
key: '/info' | ||
- title: Demos | ||
key: '/demos' | ||
- title: Properties | ||
key: '/properties' | ||
breadcrumb: | ||
- text: Forms | ||
href: /uilib/extensions/forms/ | ||
- text: Feature fields | ||
href: /uilib/extensions/forms/feature-fields/ | ||
- text: Field.Provider | ||
href: /uilib/extensions/forms/feature-fields/Provider | ||
--- | ||
|
||
import Info from 'Docs/uilib/extensions/forms/feature-fields/Provider/info' | ||
import Demos from 'Docs/uilib/extensions/forms/feature-fields/Provider/demos' | ||
|
||
<Info /> | ||
<Demos /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...m-portal/src/docs/uilib/extensions/forms/feature-fields/Provider/properties.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
import PropertiesTable from 'dnb-design-system-portal/src/shared/parts/PropertiesTable' | ||
import { FieldProviderProperties } from '@dnb/eufemia/src/extensions/forms/Field/Provider/FieldProviderDocs' | ||
|
||
## Properties | ||
|
||
<PropertiesTable props={FieldProviderProperties} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/dnb-eufemia/src/extensions/forms/Field/Provider/FieldProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react' | ||
import { Props as DataContextProps } from '../../DataContext/Provider' | ||
import { FormStatusProps } from '../../../../components/FormStatus' | ||
import FieldProviderContext from './FieldProviderContext' | ||
import SharedProvider from '../../../../shared/Provider' | ||
import { ContextProps } from '../../../../shared/Context' | ||
import useFieldProvider from './useFieldProvider' | ||
import { FieldProps, Path } from '../../types' | ||
|
||
export type FieldProviderProps = FieldProps & { | ||
children: React.ReactNode | ||
|
||
/** | ||
* Locale to use for all nested Eufemia components | ||
*/ | ||
locale?: DataContextProps<unknown>['locale'] | ||
|
||
/** | ||
* Provide your own translations. Use the same format as defined in the translation files | ||
*/ | ||
translations?: DataContextProps<unknown>['translations'] | ||
|
||
/** For internal use only */ | ||
overwriteProps?: { | ||
[key: Path]: FieldProps | ||
} | ||
|
||
/** For internal use only */ | ||
formElement?: ContextProps['formElement'] | ||
|
||
/** For internal use only */ | ||
FormStatus?: { globalStatus: FormStatusProps } | ||
} | ||
|
||
function FieldProviderProvider(props: FieldProviderProps) { | ||
const { children, ...restProps } = props | ||
const { sharedProviderParams, ...providerValue } = | ||
useFieldProvider(restProps) | ||
|
||
return ( | ||
<FieldProviderContext.Provider value={providerValue}> | ||
<SharedProvider {...sharedProviderParams}>{children}</SharedProvider> | ||
</FieldProviderContext.Provider> | ||
) | ||
} | ||
|
||
FieldProviderProvider._supportsSpacingProps = 'children' | ||
export default FieldProviderProvider |
16 changes: 16 additions & 0 deletions
16
packages/dnb-eufemia/src/extensions/forms/Field/Provider/FieldProviderContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react' | ||
import { UseFieldProps } from '../../types' | ||
|
||
export type FieldProviderContextProps = { | ||
extend: <T = UseFieldProps>(props: T) => T | ||
inheritedProps?: UseFieldProps | ||
inheritedContext?: UseFieldProps | ||
} | ||
|
||
const extend: FieldProviderContextProps['extend'] = (props) => props | ||
const FieldProviderContext = | ||
React.createContext<FieldProviderContextProps>({ | ||
extend, | ||
}) | ||
|
||
export default FieldProviderContext |
2 changes: 1 addition & 1 deletion
2
...s/forms/Form/FieldProps/FieldPropsDocs.ts → ...forms/Field/Provider/FieldProviderDocs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.