From ed2f7262799f203c944de2572e4d3604328e581c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20H=C3=B8egh?= Date: Fri, 12 Jan 2024 11:23:39 +0100 Subject: [PATCH] feat(Form.useData): add data handler to get forms data outside of the context --- .../docs/uilib/components/button/demos.mdx | 12 +- .../docs/uilib/components/visually-hidden.mdx | 2 + .../src/docs/uilib/extensions/forms.mdx | 22 ++++ .../forms/base-fields/Selection/Examples.tsx | 5 +- .../extended-features/Form/Handler/info.mdx | 28 +++++ .../src/components/flex/Container.tsx | 7 ++ .../dnb-eufemia/src/components/flex/utils.tsx | 21 +++- .../src/components/upload/useUpload.ts | 2 +- .../visually-hidden/VisuallyHidden.tsx | 3 +- .../forms/DataContext/Provider/Provider.tsx | 18 ++- .../Provider/__tests__/Provider.test.tsx | 72 ++++++++++++ .../src/extensions/forms/Field/Date/Date.tsx | 2 +- .../forms/Field/Selection/Selection.tsx | 3 +- .../extensions/forms/Field/String/String.tsx | 2 +- .../extensions/forms/Form/Handler/Handler.tsx | 1 + .../Form/Handler/__tests__/Handler.test.tsx | 2 +- .../Form/hooks/__tests__/useData.test.tsx | 107 ++++++++++++++++++ .../extensions/forms/Form/hooks/useData.tsx | 31 +++++ .../src/extensions/forms/Form/index.ts | 1 + .../extensions/forms/hooks/useDataValue.ts | 2 +- .../src/shared/helpers/EventEmitter.ts | 4 +- .../__tests__/useEventEmitter.test.tsx | 30 +++-- .../src/shared/helpers/useEventEmitter.tsx | 43 ++++--- 23 files changed, 376 insertions(+), 44 deletions(-) create mode 100644 packages/dnb-eufemia/src/extensions/forms/Form/hooks/__tests__/useData.test.tsx create mode 100644 packages/dnb-eufemia/src/extensions/forms/Form/hooks/useData.tsx diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/button/demos.mdx b/packages/dnb-design-system-portal/src/docs/uilib/components/button/demos.mdx index 3bb39ff40c6..acce0f4c64c 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/button/demos.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/button/demos.mdx @@ -59,12 +59,6 @@ Tertiary button with long text and text `wrap` enabled. -### Error state - -Buttons can have an error state - - -