diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/accordion/demos.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/accordion/demos.mdx index df7f71b9693..ef3c5fae39e 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/accordion/demos.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/accordion/demos.mdx @@ -74,14 +74,14 @@ Accordion can be disabled, though is not exactly defined what the use case is. You can collapse all expanded accordions by sending a ref to the `collapseAllHandleRef` prop and calling the `.current()` function on your ref. ```tsx -const myCloseAllRef = React.useRef<() => void>() +const myCollapseAllRef = React.useRef<() => void>() return ( - + {/* ... your accordions */} ) diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/dropdown/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/dropdown/Examples.tsx index e17cd82284d..4cc4f3946ca 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/dropdown/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/dropdown/Examples.tsx @@ -15,7 +15,13 @@ import { P, Flex, } from '@dnb/eufemia/src' -import { download, trash } from '@dnb/eufemia/src/icons' +import { + chevron_down, + chevron_right, + download, + newspaper, + trash, +} from '@dnb/eufemia/src/icons' import type { DropdownAllProps } from '@dnb/eufemia/src/components/dropdown/Dropdown' @@ -659,3 +665,89 @@ export const DropdownListOpened = () => ( ) + +export const DropdownCustomizedLook = () => { + return ( + + + {() => { + const styles = { + customTrigger: { + backgroundColor: '#d4ecc5', + color: '#14555a', + border: 'none', + borderRadius: '8px', + padding: '8px 16px', + fontWeight: 600, + }, + customMenuItem: { + display: 'flex', + flexFlow: 'row nowrap', + justifyContent: 'space-between', + alignItems: 'center', + }, + customMenuItemTitle: { + display: 'flex', + flexFlow: 'column', + gap: '0.5rem', + }, + } + + const MenuItem = ({ title, content, key }) => ( + + + {title} + {content} + + + + ) + + const data = { + accounts: ( + + ), + loans: ( + + ), + cards: ( + + ), + stocks: ( + + ), + } + + return ( + ( + + )} + /> + ) + }} + + + ) +} diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/dropdown/demos.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/dropdown/demos.mdx index 326694441b8..3a28169c00b 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/dropdown/demos.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/dropdown/demos.mdx @@ -18,6 +18,7 @@ import { DropdownListOpened, DropdownDisabledTertiary, DropdownEllipsisOverflow, + DropdownCustomizedLook, } from 'Docs/uilib/components/dropdown/Examples' ## Demos @@ -86,6 +87,12 @@ With long list to make it scrollable and searchable +### Customized Dropdown + +An example of how you can customize the look of your `Dropdown` + + + ### DrawerList opened Only to visualize and used for visual testing diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/demos.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/demos.mdx index bd88c286958..a0d1fd25799 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/demos.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/demos.mdx @@ -32,13 +32,13 @@ You can also use the file blob in combination with the [FileReader](https://deve ### Upload loading state -When uploading the file you can set the loading state of the request using the `Upload.useUpload` hook and passing isLoading to the file that is being uploaded. +When uploading the file you can set the loading state of the request using the `Upload.useUpload` hook and passing `isLoading` to the file that is being uploaded. ### Upload error message -The only checks we do currently is for the file size and the file type. These errors are handled by the HTML element ´input´ so they aren't selectable. If you want any other error messages you can use the `Upload.useUpload` the same way as with the loading state. +The only file verification the Upload component does is for the file size and the file type. These errors are handled by the HTML element `input` so they aren't selectable. If you want any other error messages you can use the `Upload.useUpload` hook the same way as with the loading state. diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/events.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/events.mdx index 434952b0c81..c03e28485cd 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/events.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/events.mdx @@ -2,11 +2,11 @@ showTabs: true --- +import PropertiesTable from 'dnb-design-system-portal/src/shared/parts/PropertiesTable' +import { UploadEvents } from '@dnb/eufemia/src/components/upload/UploadDocs' + ## Events -| Events | Description | -| -------------- | ---------------------------------------------------------------------------------------------------------------------------------- | -| `onChange` | _(optional)_ will be called on `files` changes made by the user. Access the files with `{ files }` (containing each a `fileItem`). | -| `onFileDelete` | _(optional)_ will be called once a file gets deleted by the user. Access the deleted file with `{ fileItem }`. | + Each `fileItem` will contain a `{ file, id }` (File Object and an unique ID) along with other information. diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/info.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/info.mdx index 506565f0c36..de771b1e274 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/info.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/info.mdx @@ -10,7 +10,7 @@ The Upload component should be used in scenarios where the user has to upload an - Files selected by the user should be uploaded immediately (temporary location). - The user should be able to remove them (files) during the session. -- If the Upload component is shown in a submit form, then a [GlobalStatus](/uilib/components/global-status) should be a part of the form. +- The Upload component connects to the [GlobalStatus](/uilib/components/global-status) and displays file error messages there as well. - Validation messages coming from the "backend" should be displayed for each file via the `useUpload` hook. See [example](/uilib/components/upload/#upload-error-message) below. - The `useUpload` hook can be placed on any location in your application, and does not need to be where the `Upload` component is used. @@ -33,6 +33,10 @@ function YourComponent() { } ``` +## JPG vs JPEG + +When `jpg` is defined (most commonly used), then the component will also accept `jpeg` files. + ## Backend integration The "backend" receiving the files is decoupled and can be any existing or new system. diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/properties.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/properties.mdx index 99c1302d50f..c506d6001ca 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/upload/properties.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/upload/properties.mdx @@ -2,28 +2,16 @@ showTabs: true --- +import TranslationsTable from 'dnb-design-system-portal/src/shared/parts/TranslationsTable' +import PropertiesTable from 'dnb-design-system-portal/src/shared/parts/PropertiesTable' +import { UploadProperties } from '@dnb/eufemia/src/components/upload/UploadDocs' + ## Properties -| Properties | Description | -| --------------------------------------- | ----------------------------------------------------------------------------------------- | -| `acceptedFileTypes` | _(required)_ List of accepted file types. More details above. | -| `filesAmountLimit` | _(optional)_ Defines the amount of files the user can select and upload. Defaults to 100. | -| `fileMaxSize` | _(optional)_ `fileMaxSize` is max size of each file in MB. Defaults to 5 MB. | -| `title` | _(optional)_ Custom text property. Replaces the default title. | -| `text` | _(optional)_ Custom text property. Replaces the default text. | -| `fileTypeDescription` | _(optional)_ Custom text property. Replaces the default accepted format description. | -| `fileSizeDescription` | _(optional)_ Custom text property. Replaces the default max file size description. | -| `fileSizeContent` | _(optional)_ Custom text property. Replaces the default file size content. | -| `buttonText` | _(optional)_ Custom text property. Replaces the default upload button text. | -| `loadingText` | _(optional)_ Custom text property. Replaces the default loading text. | -| `errorLargeFile` | _(optional)_ Custom text property. Replaces the default file size error message. | -| `errorUnsupportedFile` | _(optional)_ Custom text property. Replaces the default file type error message. | -| `errorAmountLimit` | _(optional)_ Custom text property. Replaces the default amount limit error message. | -| `deleteButton` | _(optional)_ Custom text property. Replaces the default delete button text. | -| `fileListAriaLabel` | _(optional)_ Custom text property. Replaces the default list aria label. | -| `skeleton` | _(optional)_ Skeleton should be applied when loading content Default: `null`. | -| [Space](/uilib/layout/space/properties) | _(optional)_ Spacing properties like `top` or `bottom` are supported. | + + +## Translations -## JPG vs JPEG +All translation keys listed in the translations table below, can be used as a component property (like `title` or `text`). -When `jpg` is defined (most commonly used), then the component will also accept `jpeg` files. + diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/blocks/ChildrenWithAge.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/blocks/ChildrenWithAge.mdx index 509a8a3e149..87fe037e609 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/blocks/ChildrenWithAge.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/blocks/ChildrenWithAge.mdx @@ -21,7 +21,7 @@ import { ChildrenWithAge, ChildrenWithAgeWizard } from './Examples' ## Usage ```tsx -import { ChildrenWithAge } from '@dnb/eufemia/src/extensions/forms/blocks' +import { ChildrenWithAge } from '@dnb/eufemia/extensions/forms/blocks' render() ``` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/blocks/info.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/blocks/info.mdx index 12e3bca1f4c..05389ee5351 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/blocks/info.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/blocks/info.mdx @@ -20,7 +20,7 @@ Read about how to create a section (block) by using a [Form.Section](/uilib/exte You import a block like this: ```jsx -import { ChildrenWithAge } from '@dnb/eufemia/src/extensions/forms/blocks' +import { ChildrenWithAge } from '@dnb/eufemia/extensions/forms/blocks' render() ``` @@ -53,7 +53,7 @@ You can change the texts and translations used inside of a block via the [Form.H ```tsx import { Form } from '@dnb/eufemia/src/extensions/forms' -import { ChildrenWithAge } from '@dnb/eufemia/src/extensions/forms/blocks' +import { ChildrenWithAge } from '@dnb/eufemia/extensions/forms/blocks' const myTranslations = { 'nb-NO': { ChildrenWithAge: { hasChildren: { title: 'Egendefinert' } } }, diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/changelog.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/changelog.mdx index 382137a08f5..1aea4113039 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/changelog.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/changelog.mdx @@ -13,6 +13,10 @@ breadcrumb: Change log for the Eufemia Forms extension. +## v10.41 + +- Added [Field.Upload](/uilib/extensions/forms/Field/Upload/) component. + ## v10.38 - Added support for nesting fields inside of [Form.Section](/uilib/extensions/forms/Form/Section/) and [Form.ArraySelection](/uilib/extensions/forms/Form/ArraySelection/). diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Email/properties.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Email/properties.mdx index ac1e9e26917..c4a9cb65932 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Email/properties.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Email/properties.mdx @@ -10,10 +10,10 @@ import { fieldProperties } from '@dnb/eufemia/src/extensions/forms/Field/FieldDo ### Field-specific props -| Property | Type | Description | -| --------------------------------------------- | -------- | ------------------------------------------------------------------------------- | -| `help` | `object` | _(optional)_ Provide a help button. Object consisting of `title` and `content`. | -| `[Input](/uilib/components/input/properties)` | Various | _(optional)_ All `Input` properties are supported. | +| Property | Type | Description | +| ------------------------------------------- | -------- | ------------------------------------------------------------------------------- | +| `help` | `object` | _(optional)_ Provide a help button. Object consisting of `title` and `content`. | +| [Input](/uilib/components/input/properties) | Various | _(optional)_ All `Input` properties are supported. | ### General props diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Slider/info.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Slider/info.mdx index f932740efeb..fea631b429a 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Slider/info.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Slider/info.mdx @@ -11,7 +11,7 @@ import { Field } from '@dnb/eufemia/extensions/forms' render() ``` -## Multithub support +## Multithumb support You can use the `paths` property to define an array with JSON Pointers for multiple thumb buttons. diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload.mdx new file mode 100644 index 00000000000..df1e3685efc --- /dev/null +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload.mdx @@ -0,0 +1,29 @@ +--- +title: 'Upload' +description: '`Field.Upload` is a wrapper for the Upload component to make it easier to use inside a form.' +showTabs: true +theme: 'sbanken' +hideInMenu: true +tabs: + - title: Info + key: '/info' + - title: Demos + key: '/demos' + - title: Properties + key: '/properties' + - title: Events + key: '/events' +breadcrumb: + - text: Forms + href: /uilib/extensions/forms/ + - text: Feature fields + href: /uilib/extensions/forms/feature-fields/ + - text: Upload + href: /uilib/extensions/forms/feature-fields/Upload/ +--- + +import Info from 'Docs/uilib/extensions/forms/feature-fields/Upload/info' +import Demos from 'Docs/uilib/extensions/forms/feature-fields/Upload/demos' + + + diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/Examples.tsx new file mode 100644 index 00000000000..ff1e5e18130 --- /dev/null +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/Examples.tsx @@ -0,0 +1,89 @@ +import { Flex } from '@dnb/eufemia/src' +import ComponentBox from '../../../../../../shared/tags/ComponentBox' +import { Field, Form } from '@dnb/eufemia/src/extensions/forms' + +export const BasicUsage = () => { + return ( + + + + + + ) +} + +export const Required = () => { + return ( + + console.log('onSubmit', data)}> + + + + + + + ) +} + +export const WithHelp = () => { + return ( + + + + ) +} + +export const Customized = () => { + return ( + + + + ) +} + +export const WithPath = () => { + const createMockFile = (name: string, size: number, type: string) => { + const file = new File([], name, { type }) + Object.defineProperty(file, 'size', { + get() { + return size + }, + }) + return file + } + + return ( + + console.log('onChange', data)} + data={{ + myFiles: [ + { file: createMockFile('fileName-1.png', 100, 'image/png') }, + ], + }} + > + + + + ) +} diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/demos.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/demos.mdx new file mode 100644 index 00000000000..58b2f44838d --- /dev/null +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/demos.mdx @@ -0,0 +1,27 @@ +--- +showTabs: true +--- + +import * as Examples from './Examples' + +## Demos + +### Basic usage + + + +### Required + + + +### Path usage + + + +### With help + + + +### Customized + + diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/events.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/events.mdx new file mode 100644 index 00000000000..ff13268a03a --- /dev/null +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/events.mdx @@ -0,0 +1,10 @@ +--- +showTabs: true +--- + +import PropertiesTable from 'dnb-design-system-portal/src/shared/parts/PropertiesTable' +import { UploadFieldEvents } from '@dnb/eufemia/src/extensions/forms/Field/Upload/UploadDocs' + +## Events + + diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/info.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/info.mdx new file mode 100644 index 00000000000..16f40b7d6a0 --- /dev/null +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/info.mdx @@ -0,0 +1,56 @@ +--- +showTabs: true +--- + +## Description + +`Field.Upload` is a wrapper for the [Upload](/uilib/components/upload/) component to make it easier to use inside a form. + +```jsx +import { Field } from '@dnb/eufemia/extensions/forms' +render() +``` + +## The data and file format + +The returned data is an array of objects containing a file object and a unique ID. The file object contains the file itself and some additional properties like an unique ID. + +```tsx +{ + id: '1234', + file: { + name: 'file1.jpg', + size: 1234, + type: 'image/jpeg', + }, + errorMessage: 'error message ...', +} +``` + +This data format will be returned by the `onChange` and the `onSubmit` event handlers. + +## Validation + +The `required` prop will validate if there are valid files present. If there are files with an error, the validation will fail. + +If there are invalid files, the `onSubmit` event will not be called and a validation error will be shown. + +The `onChange` event handler will return an array with objects containing the file object and some additional properties – regardless of the validity of the file. + +## About the `value` and `path` prop + +The `path` prop represents an array with an object described above: + +```tsx +render( + + + , +) +``` + +The `value` prop represents an array with an object described above: + +```tsx +render() +``` diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/properties.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/properties.mdx new file mode 100644 index 00000000000..f6069384a86 --- /dev/null +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/feature-fields/Upload/properties.mdx @@ -0,0 +1,26 @@ +--- +showTabs: true +--- + +import TranslationsTable from 'dnb-design-system-portal/src/shared/parts/TranslationsTable' +import PropertiesTable from 'dnb-design-system-portal/src/shared/parts/PropertiesTable' +import { fieldProperties } from '@dnb/eufemia/src/extensions/forms/Field/FieldDocs' +import { UploadFieldProperties } from '@dnb/eufemia/src/extensions/forms/Field/Upload/UploadDocs' + +## Properties + +### Field-specific props + + + +### General props + +']} + omit={['layout', 'onBlurValidator', 'contentWidth']} +/> + +## Translations + + diff --git a/packages/dnb-design-system-portal/src/shared/menu/StickyMenuBar.tsx b/packages/dnb-design-system-portal/src/shared/menu/StickyMenuBar.tsx index d868153df5c..d107eb380fd 100644 --- a/packages/dnb-design-system-portal/src/shared/menu/StickyMenuBar.tsx +++ b/packages/dnb-design-system-portal/src/shared/menu/StickyMenuBar.tsx @@ -112,7 +112,8 @@ export default function StickyMenuBar({