-
Notifications
You must be signed in to change notification settings - Fork 33
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
Showing
90 changed files
with
2,383 additions
and
165 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
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
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
28 changes: 28 additions & 0 deletions
28
...ign-system-portal/src/docs/uilib/extensions/forms/base-fields/Indeterminate.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,28 @@ | ||
--- | ||
title: 'Indeterminate' | ||
description: 'The `Field.Indeterminate` component is used to display and handle the indeterminate state of a checkbox.' | ||
componentType: 'primitive' | ||
hideInMenu: true | ||
showTabs: true | ||
theme: 'sbanken' | ||
tabs: | ||
- title: Info | ||
key: '/info' | ||
- title: Demos | ||
key: '/demos' | ||
- title: Properties | ||
key: '/properties' | ||
breadcrumb: | ||
- text: Forms | ||
href: /uilib/extensions/forms/ | ||
- text: Base fields | ||
href: /uilib/extensions/forms/base-fields/ | ||
- text: Indeterminate | ||
href: /uilib/extensions/forms/base-fields/Indeterminate/ | ||
--- | ||
|
||
import Info from 'Docs/uilib/extensions/forms/base-fields/Indeterminate/info' | ||
import Demos from 'Docs/uilib/extensions/forms/base-fields/Indeterminate/demos' | ||
|
||
<Info /> | ||
<Demos /> |
74 changes: 74 additions & 0 deletions
74
...sign-system-portal/src/docs/uilib/extensions/forms/base-fields/Indeterminate/Examples.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,74 @@ | ||
import { Card, Flex } from '@dnb/eufemia/src' | ||
import ComponentBox from '../../../../../../shared/tags/ComponentBox' | ||
import { Field, Form } from '@dnb/eufemia/src/extensions/forms' | ||
|
||
export const MixedIndeterminateDependence = () => { | ||
return ( | ||
<ComponentBox> | ||
<Form.Handler onChange={console.log}> | ||
<Card stack> | ||
<Field.Indeterminate | ||
dependencePaths={['/child1', '/child2', '/child3']} | ||
label="Indeterminate" | ||
/> | ||
|
||
<Field.Toggle | ||
label="Checkbox 1" | ||
path="/child1" | ||
valueOn="what-ever" | ||
valueOff="you-name-it" | ||
required | ||
/> | ||
|
||
<Field.Boolean label="Checkbox 2" path="/child2" required /> | ||
|
||
<Field.Toggle | ||
label="Checkbox 3" | ||
path="/child3" | ||
valueOn="on" | ||
valueOff="off" | ||
/> | ||
</Card> | ||
|
||
<Form.SubmitButton /> | ||
</Form.Handler> | ||
</ComponentBox> | ||
) | ||
} | ||
|
||
export const NestedIndeterminateDependence = () => { | ||
return ( | ||
<ComponentBox> | ||
<Form.Handler onChange={console.log}> | ||
<Card stack> | ||
<Field.Indeterminate | ||
label="1" | ||
path="/p1" | ||
dependencePaths={['/c2.1', '/p2.2', '/c3.1', '/c3.2']} | ||
/> | ||
|
||
<Flex.Stack left="large"> | ||
<Field.Boolean label="2.1" path="/c2.1" /> | ||
<Field.Indeterminate | ||
label="2.2" | ||
valueOn="what-ever" | ||
valueOff="you-name-it" | ||
path="/p2.2" | ||
dependencePaths={['/c3.1', '/c3.2']} | ||
/> | ||
|
||
<Flex.Stack left="large"> | ||
<Field.Boolean label="3.1" path="/c3.1" /> | ||
<Field.Toggle | ||
label="3.2" | ||
path="/c3.2" | ||
valueOn="what-ever" | ||
valueOff="you-name-it" | ||
/> | ||
</Flex.Stack> | ||
</Flex.Stack> | ||
</Card> | ||
</Form.Handler> | ||
</ComponentBox> | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
...stem-portal/src/docs/uilib/extensions/forms/base-fields/Indeterminate/demos.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,15 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
import * as Examples from './Examples' | ||
|
||
## Demos | ||
|
||
### Indeterminate state (partially checked) | ||
|
||
<Examples.MixedIndeterminateDependence /> | ||
|
||
### Nested indeterminate state | ||
|
||
<Examples.NestedIndeterminateDependence /> |
3 changes: 3 additions & 0 deletions
3
...tem-portal/src/docs/uilib/extensions/forms/base-fields/Indeterminate/events.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,3 @@ | ||
--- | ||
showTabs: false | ||
--- |
32 changes: 32 additions & 0 deletions
32
...ystem-portal/src/docs/uilib/extensions/forms/base-fields/Indeterminate/info.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,32 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
## Description | ||
|
||
The `Field.Indeterminate` component is used to display and handle the indeterminate state of a checkbox. It is an uncontrolled component, meaning that the state is managed automatically. | ||
|
||
```tsx | ||
import { Field } from '@dnb/eufemia/extensions/forms' | ||
render( | ||
<Field.Indeterminate | ||
dependencePaths={['/checkbox1', '/checkbox2', '/checkbox3']} | ||
path="/checkboxParent" | ||
/>, | ||
) | ||
``` | ||
|
||
It should only be used in combination with checkbox looking variants. | ||
|
||
Under the hood the [Toggle](/uilib/extensions/forms/base-fields/Toggle/) base field is used. That means you can use all the props from the `Toggle` component. | ||
|
||
## Details about the state handling | ||
|
||
The indeterminate state of a parent checkbox should be shown when some children checkboxes are checked, but not all. In detail: | ||
|
||
- When all children are checked, the the parent should get checked. | ||
- When the parent gets checked (clicked), all children should get checked. | ||
- When all children are unchecked, the parent should get unchecked. | ||
- When the parent gets unchecked (clicked), all children should get unchecked. | ||
- When some children are checked, the parent should be set in an indeterminate state. | ||
- When the parent gets clicked, all children should get checked. This behavior can be changed to the opposite or `auto` by using the `propagateIndeterminateState` prop. Auto means that the parent will switch from its current state to be inverted. |
17 changes: 17 additions & 0 deletions
17
...portal/src/docs/uilib/extensions/forms/base-fields/Indeterminate/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,17 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
import PropertiesTable from 'dnb-design-system-portal/src/shared/parts/PropertiesTable' | ||
import { fieldProperties } from '@dnb/eufemia/src/extensions/forms/Field/FieldDocs' | ||
import { IndeterminateProperties } from '@dnb/eufemia/src/extensions/forms/Field/Indeterminate/IndeterminateDocs' | ||
|
||
## Properties | ||
|
||
### Field-specific props | ||
|
||
<PropertiesTable props={IndeterminateProperties} /> | ||
|
||
### General props | ||
|
||
<PropertiesTable props={fieldProperties} valueType="any" /> |
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
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
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
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.