From a8442b1d0b06d66070c0cdcc2e423f5302111186 Mon Sep 17 00:00:00 2001 From: robinvandermolen Date: Wed, 25 Sep 2024 15:59:32 +0200 Subject: [PATCH 1/4] :bug: [open-formulieren/open-forms#4636] Preventing large values to breaking the table --- src/components/builder/i18n.tsx | 8 ++++++-- src/components/builder/table.scss | 11 +++++++++++ src/components/builder/values/i18n.tsx | 23 +++++++++++++++++++---- 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 src/components/builder/table.scss diff --git a/src/components/builder/i18n.tsx b/src/components/builder/i18n.tsx index 767ca12d..a6c3022d 100644 --- a/src/components/builder/i18n.tsx +++ b/src/components/builder/i18n.tsx @@ -12,6 +12,7 @@ import {AnyComponentSchema} from '@/types/schemas'; import {Component, TextField} from '../formio'; import ComponentLabel from '../formio/component-label'; import './i18n.scss'; +import './table.scss'; type ExtractTranslatableProperties = T extends OFExtensions ? TK : never; type StringValueProperties = S extends AnyComponentSchema @@ -53,7 +54,7 @@ export function ComponentTranslations({ return ( - +
diff --git a/src/components/builder/table.scss b/src/components/builder/table.scss new file mode 100644 index 00000000..d7961629 --- /dev/null +++ b/src/components/builder/table.scss @@ -0,0 +1,11 @@ +.offb-table { + // Ensures that the column widths are respected + table-layout: fixed; + + &__content { + &--allow-break { + overflow-wrap: break-word; + hyphens: auto; + } + } +} diff --git a/src/components/builder/values/i18n.tsx b/src/components/builder/values/i18n.tsx index 64f6e62d..d1cb52e2 100644 --- a/src/components/builder/values/i18n.tsx +++ b/src/components/builder/values/i18n.tsx @@ -7,6 +7,7 @@ import {TextArea, TextField} from '@/components/formio'; import {PathsForValueType} from '@/types'; import {ComponentTranslationsContext} from '../i18n'; +import '../table.scss'; export interface ValuesTranslationsProps { /** @@ -45,10 +46,17 @@ export function ValuesTranslations({name, withOptionDescription}: ValuesTrans <>
@@ -122,7 +123,10 @@ export function ComponentTranslations({ -
+
{(values?.[property] || '-') as string}
- {label} + + {label} + -
{value || '-'}
+
+ {value || '-'} +
({name, withOptionDescription}: ValuesTrans description="Label for option description location" defaultMessage="Option description ()" values={{ - option: () => {value || '-'}, + option: () => ( + {value || '-'} + ), }} /> -
{description || '-'}
+
+ {description || '-'} +
From 094a19a920be3e3c44518ebdb924fef1bfdb0df0 Mon Sep 17 00:00:00 2001 From: robinvandermolen Date: Tue, 8 Oct 2024 14:23:10 +0200 Subject: [PATCH 2/4] :lipstick: [open-formulieren/open-forms#4636] Fixed custom table styling --- src/components/builder/i18n.tsx | 15 +++++++++------ src/components/builder/table.scss | 10 ++++++++++ src/components/builder/values/i18n.tsx | 13 +++++++++---- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/components/builder/i18n.tsx b/src/components/builder/i18n.tsx index a6c3022d..50b10d85 100644 --- a/src/components/builder/i18n.tsx +++ b/src/components/builder/i18n.tsx @@ -57,7 +57,10 @@ export function ComponentTranslations({ - - - - -
+ ({ })} /> +
    {supportedLanguageCodes.map(code => (
  • @@ -93,19 +96,19 @@ export function ComponentTranslations({
+ + + ({
{(values?.[property] || '-') as string}
diff --git a/src/components/builder/table.scss b/src/components/builder/table.scss index d7961629..1ae04bd8 100644 --- a/src/components/builder/table.scss +++ b/src/components/builder/table.scss @@ -1,6 +1,7 @@ .offb-table { // Ensures that the column widths are respected table-layout: fixed; + width: 100%; &__content { &--allow-break { @@ -8,4 +9,13 @@ hyphens: auto; } } + + &__col { + &--width-25 { + width: 25%; + } + &--width-50 { + width: 50%; + } + } } diff --git a/src/components/builder/values/i18n.tsx b/src/components/builder/values/i18n.tsx index d1cb52e2..9a0af867 100644 --- a/src/components/builder/values/i18n.tsx +++ b/src/components/builder/values/i18n.tsx @@ -46,14 +46,17 @@ export function ValuesTranslations({name, withOptionDescription}: ValuesTrans <>
- + {label}
{value || '-'}
@@ -94,7 +97,9 @@ export function ValuesTranslations({name, withOptionDescription}: ValuesTrans defaultMessage="Option description ()" values={{ option: () => ( - {value || '-'} + + {value || '-'} + ), }} /> @@ -104,7 +109,7 @@ export function ValuesTranslations({name, withOptionDescription}: ValuesTrans
{description || '-'}
From 22a5ab3d7f3b572a27c62aa83ffa005516c5fc92 Mon Sep 17 00:00:00 2001 From: robinvandermolen Date: Tue, 8 Oct 2024 14:37:08 +0200 Subject: [PATCH 3/4] :truck: [open-formulieren/open-forms#4636] Moved styling import to library index --- src/components/builder/i18n.tsx | 1 - src/components/builder/index.ts | 2 ++ src/components/builder/values/i18n.tsx | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/builder/i18n.tsx b/src/components/builder/i18n.tsx index 50b10d85..b57d6ec4 100644 --- a/src/components/builder/i18n.tsx +++ b/src/components/builder/i18n.tsx @@ -12,7 +12,6 @@ import {AnyComponentSchema} from '@/types/schemas'; import {Component, TextField} from '../formio'; import ComponentLabel from '../formio/component-label'; import './i18n.scss'; -import './table.scss'; type ExtractTranslatableProperties = T extends OFExtensions ? TK : never; type StringValueProperties = S extends AnyComponentSchema diff --git a/src/components/builder/index.ts b/src/components/builder/index.ts index ae81440f..c329d97a 100644 --- a/src/components/builder/index.ts +++ b/src/components/builder/index.ts @@ -4,6 +4,8 @@ * These components are commonly re-used in the component edit form, built using the * formio component 'primitives'. */ +import './table.scss'; + export {default as Label} from './label'; export {default as Description} from './description'; export {default as Tooltip} from './tooltip'; diff --git a/src/components/builder/values/i18n.tsx b/src/components/builder/values/i18n.tsx index 9a0af867..4c65efba 100644 --- a/src/components/builder/values/i18n.tsx +++ b/src/components/builder/values/i18n.tsx @@ -7,7 +7,6 @@ import {TextArea, TextField} from '@/components/formio'; import {PathsForValueType} from '@/types'; import {ComponentTranslationsContext} from '../i18n'; -import '../table.scss'; export interface ValuesTranslationsProps { /** From 4b009bb1e703ead50f7a41597b175c9e1f87b19a Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Thu, 10 Oct 2024 12:16:37 +0200 Subject: [PATCH 4/4] :white_check_mark: [open-formulieren/open-forms#4636] Add story for text wrapping in translations table --- src/components/builder/i18n.stories.tsx | 24 ++++++++++++++++++++++++ src/components/builder/i18n.tsx | 1 + src/components/builder/index.ts | 2 -- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/components/builder/i18n.stories.tsx b/src/components/builder/i18n.stories.tsx index 33ebb568..781de925 100644 --- a/src/components/builder/i18n.stories.tsx +++ b/src/components/builder/i18n.stories.tsx @@ -3,6 +3,7 @@ import {expect, userEvent, waitFor, within} from '@storybook/test'; import {Formik} from 'formik'; import {TextField} from '@/components/formio'; +import {withFormik} from '@/sb-decorators'; import {ComponentTranslations} from './i18n'; @@ -108,3 +109,26 @@ export const Default: Story = { expect(translationField2).toBeNull(); }, }; + +export const LongStringsWrap: StoryObj> = { + decorators: [withFormik], + args: { + propertyLabels: { + label: 'Label', + }, + }, + parameters: { + formik: { + initialValues: { + label: Array(100).fill('a').join(''), + openForms: { + translations: { + nl: { + label: 'Insgelijks', + }, + }, + }, + }, + }, + }, +}; diff --git a/src/components/builder/i18n.tsx b/src/components/builder/i18n.tsx index b57d6ec4..50b10d85 100644 --- a/src/components/builder/i18n.tsx +++ b/src/components/builder/i18n.tsx @@ -12,6 +12,7 @@ import {AnyComponentSchema} from '@/types/schemas'; import {Component, TextField} from '../formio'; import ComponentLabel from '../formio/component-label'; import './i18n.scss'; +import './table.scss'; type ExtractTranslatableProperties = T extends OFExtensions ? TK : never; type StringValueProperties = S extends AnyComponentSchema diff --git a/src/components/builder/index.ts b/src/components/builder/index.ts index c329d97a..ae81440f 100644 --- a/src/components/builder/index.ts +++ b/src/components/builder/index.ts @@ -4,8 +4,6 @@ * These components are commonly re-used in the component edit form, built using the * formio component 'primitives'. */ -import './table.scss'; - export {default as Label} from './label'; export {default as Description} from './description'; export {default as Tooltip} from './tooltip';