From 88768edf736c8770e9edf4ec52d70455c77a2172 Mon Sep 17 00:00:00 2001 From: Franz Heidl Date: Thu, 8 Aug 2024 11:21:24 +0200 Subject: [PATCH 01/10] feat(ui) ComboBox: add `wrapperClassname` prop --- .../src/components/ComboBox/ComboBox.component.js | 4 ++++ .../ui-components/src/components/ComboBox/ComboBox.test.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/ui-components/src/components/ComboBox/ComboBox.component.js b/packages/ui-components/src/components/ComboBox/ComboBox.component.js index 2a31f69c9..238963131 100644 --- a/packages/ui-components/src/components/ComboBox/ComboBox.component.js +++ b/packages/ui-components/src/components/ComboBox/ComboBox.component.js @@ -161,6 +161,7 @@ export const ComboBox = ({ value = "", valueLabel, width = "full", + wrapperClassName = "", ...props }) => { const isNotEmptyString = (str) => { @@ -286,6 +287,7 @@ export const ComboBox = ({ jn-relative ${width == "auto" ? "jn-inline-block" : "jn-block"} ${width == "auto" ? "jn-w-auto" : "jn-w-full"} + ${wrapperClassName} `} > element */ + wrapperClassName: PropTypes.string, } diff --git a/packages/ui-components/src/components/ComboBox/ComboBox.test.js b/packages/ui-components/src/components/ComboBox/ComboBox.test.js index e14fdadc7..d165de214 100644 --- a/packages/ui-components/src/components/ComboBox/ComboBox.test.js +++ b/packages/ui-components/src/components/ComboBox/ComboBox.test.js @@ -533,6 +533,12 @@ describe("ComboBox", () => { expect(cbox).toHaveValue("option 2") }) + test("renders a wrapperClassName to the outer wrapping
element", async () => { + render() + expect(document.querySelector(".juno-combobox-wrapper")).toBeInTheDocument() + expect(document.querySelector(".juno-combobox-wrapper")).toHaveClass("my-wrapper-class") + }) + test("renders a ComboBox with a custom className as passed", async () => { await waitFor(() => render( From 4faba4a1f4ad34d98b7ac55f08de77c99ca402f5 Mon Sep 17 00:00:00 2001 From: Franz Heidl Date: Thu, 8 Aug 2024 11:27:52 +0200 Subject: [PATCH 02/10] feat(ui) DateTimePicker: add `wrapperClassname` prop --- .../components/DateTimePicker/DateTimePicker.component.js | 5 +++++ .../src/components/DateTimePicker/DateTimePicker.test.js | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/packages/ui-components/src/components/DateTimePicker/DateTimePicker.component.js b/packages/ui-components/src/components/DateTimePicker/DateTimePicker.component.js index 1b076bded..48daabb94 100644 --- a/packages/ui-components/src/components/DateTimePicker/DateTimePicker.component.js +++ b/packages/ui-components/src/components/DateTimePicker/DateTimePicker.component.js @@ -129,6 +129,7 @@ export const DateTimePicker = ({ value, weekNumbers, width, + wrapperClassName, ...props }) => { // always generate auto-id string using the useId hook to avoid "more hooks than in previous render" error when removing custom id: @@ -434,6 +435,7 @@ export const DateTimePicker = ({ juno-datetimepicker-wrapper ${width == "auto" ? "jn-inline-block" : "jn-block"} ${width == "auto" ? "jn-w-auto" : "jn-w-full"} + ${wrapperClassName} `} >
@@ -594,6 +596,8 @@ DateTimePicker.propTypes = { weekNumbers: PropTypes.bool, /** The width of the datepicker input. Either 'full' (default) or 'auto'. */ width: PropTypes.oneOf(["full", "auto"]), + /** Pass a custom className to the wrapping element */ + wrapperClassName: PropTypes.string, } // can't get rid of this, as if we transform it to a default values using vanilla JS, two tests will fail @@ -646,4 +650,5 @@ DateTimePicker.defaultProps = { value: "", weekNumbers: false, width: "full", + wrapperClassName: "", } diff --git a/packages/ui-components/src/components/DateTimePicker/DateTimePicker.test.js b/packages/ui-components/src/components/DateTimePicker/DateTimePicker.test.js index 009fe6806..4fd99f11e 100644 --- a/packages/ui-components/src/components/DateTimePicker/DateTimePicker.test.js +++ b/packages/ui-components/src/components/DateTimePicker/DateTimePicker.test.js @@ -941,6 +941,12 @@ describe("DateTimePicker", () => { expect(mockOnMonthChange).toHaveBeenCalled() }) + test("renders a wrapperClassName to the outer wrapping element", async () => { + render() + expect(document.querySelector(".juno-datetimepicker-wrapper")).toBeInTheDocument() + expect(document.querySelector(".juno-datetimepicker-wrapper")).toHaveClass("my-wrapper-class") + }) + test("renders a className as passed", async () => { await waitFor(() => render( From 716c92bd70aa67206ba2536c7f25b2e5c1de0ae8 Mon Sep 17 00:00:00 2001 From: Franz Heidl Date: Thu, 8 Aug 2024 11:32:25 +0200 Subject: [PATCH 03/10] feat(ui) NativeSelect: add `wrapperClassname` prop --- .../components/NativeSelect/NativeSelect.component.js | 10 +++++++++- .../src/components/NativeSelect/NativeSelect.test.js | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/ui-components/src/components/NativeSelect/NativeSelect.component.js b/packages/ui-components/src/components/NativeSelect/NativeSelect.component.js index fc408926a..71d20f1fe 100644 --- a/packages/ui-components/src/components/NativeSelect/NativeSelect.component.js +++ b/packages/ui-components/src/components/NativeSelect/NativeSelect.component.js @@ -119,6 +119,7 @@ export const NativeSelect = ({ error = false, onChange, onClick, + wrapperClassName = "", ...props }) => { const [isLoading, setIsLoading] = useState(false) @@ -183,7 +184,12 @@ export const NativeSelect = ({ } return ( -
+
+ Option 1 + + ) + expect(document.querySelector(".juno-select-wrapper ")).toBeInTheDocument() + expect(document.querySelector(".juno-select-wrapper ")).toHaveClass("my-wrapper-class") +}) From 5f978586030425d292e96881c5cba0f71fab0891 Mon Sep 17 00:00:00 2001 From: Franz Heidl Date: Thu, 8 Aug 2024 11:44:58 +0200 Subject: [PATCH 05/10] feat(ui) Switch: add `wrapperClassname` prop --- .../ui-components/src/components/Switch/Switch.component.js | 4 ++++ packages/ui-components/src/components/Switch/Switch.test.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/ui-components/src/components/Switch/Switch.component.js b/packages/ui-components/src/components/Switch/Switch.component.js index 1dd1e1aea..1e674ae34 100644 --- a/packages/ui-components/src/components/Switch/Switch.component.js +++ b/packages/ui-components/src/components/Switch/Switch.component.js @@ -124,6 +124,7 @@ export const Switch = ({ className = "", onChange = undefined, onClick = undefined, + wrapperClassName = "", ...props }) => { const isNotEmptyString = (str) => { @@ -171,6 +172,7 @@ export const Switch = ({ className={` juno-switch-wrapper ${switchWrapperStyles} + ${wrapperClassName} `} >