Skip to content

Commit 005f5fe

Browse files
committed
fix: added a few use client and if provider is not used asContainer, the consumer needs to create a container themself
1 parent 8d872c8 commit 005f5fe

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

packages/core/src/components/error-popup/ErrorPopup.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import React, { useState, useEffect } from 'react';
23
import { useQuickForm } from "../../state/QuickFormContext";
34
import { quickformtokens } from '../../style/quickFormTokensDefinition';

packages/core/src/components/paragraph/Paragraph.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import { ReactNode } from "react";
23
import React from "react";
34
import { quickformtokens } from "../../style/quickFormTokensDefinition";

packages/core/src/components/renderers/slide-renderer/SlideRenderer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import React, { useEffect, useRef, useState } from 'react';
23
import { useQuickForm } from '../../../state/QuickFormContext';
34
import { Button } from '../../button/Button';

packages/core/src/state/QuickFormContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface IQuickFormContext {
1616
isFirstQuestionInCurrentSlide: (questionLogicalName: string) => boolean;
1717
getCurrentSlide: () => SlideModel;
1818
onSubmitAsync: (formdata: any) => Promise<string>;
19+
cssVariables: { [key: string]: string };
1920
}
2021

2122
export const QuickFormContext = React.createContext<IQuickFormContext>(
@@ -33,6 +34,7 @@ export const QuickFormContext = React.createContext<IQuickFormContext>(
3334
{ questions: [], rows: [], isAnswered: false, addQuestion: () => ({ type: "question", ref: "" }) }
3435
),
3536
onSubmitAsync: async (formdata) => { return "" },
37+
cssVariables: {}
3638
}
3739
);
3840

packages/core/src/state/QuickformProvider.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { kbaQuickFormTokens } from "../style/kbaQuickFormTokens";
1010
import { isFirstQInCurrentSlide } from "../utils/isFirstQuestionInSlide";
1111

1212
type QuickFormProviderProps = {
13+
className?:string,
1314
children: React.ReactNode;
1415
definition: QuickFormDefinition;
1516
tokens?: Partial<QuickFormTokens>;
@@ -20,6 +21,7 @@ type QuickFormProviderProps = {
2021

2122
export const QuickFormProvider: React.FC<QuickFormProviderProps> = (
2223
{
24+
className,
2325
children,
2426
definition,
2527
payload,
@@ -50,7 +52,7 @@ export const QuickFormProvider: React.FC<QuickFormProviderProps> = (
5052
const setErrorMsg = (msg: string) => { dispatch({ type: "SET_ERROR_MSG", msg: msg }) };
5153
const isFirstQuestionInCurrentSlide = (questionLogicalName: string) => { return isFirstQInCurrentSlide(questionLogicalName, state); }
5254
const getCurrentSlide = () => (state.slides[state.currIdx]);
53-
55+
console.log("children", children);
5456
return (
5557
<QuickFormContext.Provider value={{
5658
state,
@@ -64,6 +66,7 @@ export const QuickFormProvider: React.FC<QuickFormProviderProps> = (
6466
isFirstQuestionInCurrentSlide,
6567
getCurrentSlide,
6668
onSubmitAsync,
69+
cssVariables
6770
}}>
6871

6972
{asContainer ? (
@@ -72,10 +75,8 @@ export const QuickFormProvider: React.FC<QuickFormProviderProps> = (
7275
{children}
7376
</QuickFormContainer>
7477
) : (
75-
<div style={cssVariables}>
76-
<ErrorPopup message={state.errorMsg} />
77-
{children}
78-
</div>
78+
children
79+
7980
)
8081
}
8182
</QuickFormContext.Provider>

0 commit comments

Comments
 (0)