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): add Value.Upload component #4233

Merged
merged 16 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ import ComponentBox from '../../../../../../shared/tags/ComponentBox'
import { Card } from '@dnb/eufemia/src'
import { Field, Form, Value } from '@dnb/eufemia/src/extensions/forms'

function createMockFile(name: string, size: number, type: string) {
const file = new File([], name, { type })
Object.defineProperty(file, 'size', {
get() {
return size
},
})
return file
}

export const DefaultLayout = () => {
return (
<ComponentBox data-visual-test="forms-value-summary-list-default">
Expand Down Expand Up @@ -132,15 +142,36 @@ export function InheritVisibility() {

export function InheritLabel() {
return (
<ComponentBox>
<ComponentBox scope={{ createMockFile }}>
<Form.Handler>
<Card stack>
<Field.String path="/foo" defaultValue="foo" label="foo label" />
<Field.String path="/bar" defaultValue="bar" label="bar label" />
<Field.Upload
path="/baz"
defaultValue={[
{
file: createMockFile(
'fileName-1.png',
1000000,
'image/png',
),
},
{
file: createMockFile(
'fileName-2.png',
2000000,
'image/png',
),
},
]}
label="baz label"
/>

<Value.SummaryList inheritLabel>
<Value.String path="/foo" />
<Value.String path="/bar" />
<Value.Upload path="/baz" />
</Value.SummaryList>
</Card>
</Form.Handler>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: 'Upload'
description: '`Value.Upload` is a wrapper component for displaying Upload files, with user experience tailored for an array of files.'
componentType: 'feature-value'
showTabs: true
tabs:
- title: Info
key: '/info'
- title: Demos
key: '/demos'
- title: Properties
key: '/properties'
breadcrumb:
- text: Forms
href: /uilib/extensions/forms/
- text: Value
href: /uilib/extensions/forms/Value/
- text: Upload
href: /uilib/extensions/forms/Value/Upload/
---

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

<Info />
<Demos />
Loading
Loading