From 6333591b6e560f2759ce88295e8d2d070f072530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Thu, 16 May 2024 13:31:16 +0200 Subject: [PATCH 001/118] fix: removed default tokens as it results in them being used when no tokens is defined overriding the quickform default tokens --- packages/core/src/state/QuickformProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/state/QuickformProvider.tsx b/packages/core/src/state/QuickformProvider.tsx index a97744a..81cda08 100644 --- a/packages/core/src/state/QuickformProvider.tsx +++ b/packages/core/src/state/QuickformProvider.tsx @@ -25,7 +25,7 @@ export const QuickFormProvider: React.FC = ( children, definition, payload, - tokens = kbaQuickFormTokens, + tokens, asContainer, onSubmitAsync = async (data) => { return "" } } From 1ad908b595ecacf82f9b4fa91aa1b717f8549e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Wed, 22 May 2024 02:16:44 +0200 Subject: [PATCH 002/118] fix: regression on breaking change - icon changes to a more slim version --- .../src/components/icons/ImArrowRightIcon.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/core/src/components/icons/ImArrowRightIcon.tsx b/packages/core/src/components/icons/ImArrowRightIcon.tsx index 792c1bb..b8df16d 100644 --- a/packages/core/src/components/icons/ImArrowRightIcon.tsx +++ b/packages/core/src/components/icons/ImArrowRightIcon.tsx @@ -2,12 +2,15 @@ import React from "react"; import { IconProps } from "./iconProps"; import { quickformtokens } from "../../style/quickFormTokensDefinition"; -export const ImArrowRightIcon: React.FC = ({ size = '20px' }) => { +export const ImArrowRightIcon: React.FC = ({ size = '20px', style }) => { return ( - <> - - - - + + + + //<> + // + // + // + // ); }; \ No newline at end of file From 03ea6852f8c141bca9b024aa998d2a5ac9abd0ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Wed, 22 May 2024 02:18:15 +0200 Subject: [PATCH 003/118] fix: regression on breaking change - question numbers hould be hanging to the left such headline/subline is aligned under eachother. Layout controls if shown still. --- .../question-number/QuestionNumber.tsx | 5 +++++ .../question/components/QuestionHeading.tsx | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/core/src/components/question-number/QuestionNumber.tsx b/packages/core/src/components/question-number/QuestionNumber.tsx index ade4ae8..ead3126 100644 --- a/packages/core/src/components/question-number/QuestionNumber.tsx +++ b/packages/core/src/components/question-number/QuestionNumber.tsx @@ -10,6 +10,11 @@ const defaultHeadingNumberDisplayProvider: HeadingNumberDisplayProvider = () => registerQuickFormService("headingNumberDisplayProvider", defaultHeadingNumberDisplayProvider); +/** + * Deprecated: Use QuestionHeading instead + * @param param0 + * @returns + */ export const QuestionNumber: React.FC<{ questionNum?: number }> = ({ questionNum }) => { const shouldDisplayNumber = resolveQuickFormService("headingNumberDisplayProvider")(); if (!shouldDisplayNumber) { diff --git a/packages/core/src/components/question/components/QuestionHeading.tsx b/packages/core/src/components/question/components/QuestionHeading.tsx index 246550c..de4c717 100644 --- a/packages/core/src/components/question/components/QuestionHeading.tsx +++ b/packages/core/src/components/question/components/QuestionHeading.tsx @@ -4,6 +4,7 @@ import { useQuickForm } from "../../../state/QuickFormContext"; import { quickformtokens } from "../../../style/quickFormTokensDefinition"; import { HeadingNumberDisplayProvider, registerQuickFormService, resolveQuickFormService } from "../../../services/QuickFormServices"; + type QuestionHeadingProps = { readonly children: ReactNode; readonly style?: React.CSSProperties; @@ -28,10 +29,19 @@ export const QuestionHeading: React.FC = ({ children, labe return (

- {shouldDisplayNumber && - {label} + {shouldDisplayNumber &&
+ {label} - } +
} {children}

); From 66b0f7f4b412c9cf580eaf768e3a47fe6d144ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Poul=20Kjeldager=20S=C3=B8rensen?= Date: Wed, 22 May 2024 02:21:40 +0200 Subject: [PATCH 004/118] feat: Added enter support on active questions and support for knowing which question is currently active. Answering on enter and onblur for multiline --- .../baseinput/BaseInputComponent.tsx | 41 ++++++++++++++++++- .../input-types/multiline/MultilineInput.tsx | 2 +- .../slide-renderer/SlideRenderer.tsx | 2 +- packages/core/src/model/QuestionModel.ts | 4 ++ 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/packages/core/src/components/question/input-types/baseinput/BaseInputComponent.tsx b/packages/core/src/components/question/input-types/baseinput/BaseInputComponent.tsx index 81619b0..22bf772 100644 --- a/packages/core/src/components/question/input-types/baseinput/BaseInputComponent.tsx +++ b/packages/core/src/components/question/input-types/baseinput/BaseInputComponent.tsx @@ -1,11 +1,15 @@ "use client"; -import { quickformtokens, useQuickForm } from "@eavfw/quickform-core"; +import { quickformtokens, useHandleEnterKeypress, useQuickForm } from "@eavfw/quickform-core"; import { useFocusableQuestion } from "@eavfw/quickform-core/src/hooks/useFocusableQuestion"; -import { CSSProperties, ChangeEvent, InputHTMLAttributes, useState } from "react"; +import { CSSProperties, ChangeEvent, InputHTMLAttributes, useEffect, useState } from "react"; import { makeStyles, mergeClasses, shorthands } from '@griffel/react'; import { QuestionModel } from "@eavfw/quickform-core/src/model"; import { IconResolver, IconType } from "../../../icons/IconResolver"; +import { trace } from "@opentelemetry/api"; + +const tracer = trace.getTracer("quickform", "1.0.0"); + const useInputTextStyles = makeStyles({ inputContainer: { display: 'flex', @@ -63,6 +67,8 @@ type BaseInputComponentProps = { className?: string, } + + export const BaseInputComponent: React.FC = ({ questionModel, className, style, type, beforeIcon, afterIcon }) => { const [text, setText] = useState(questionModel!.output); @@ -70,6 +76,14 @@ export const BaseInputComponent: React.FC = ({ question const { answerQuestion } = useQuickForm(); const styles = useInputTextStyles(); + const span = trace.getActiveSpan(); + + if (span) { + span.addEvent("BaseInputComponent:render"); + } + + + const resize = () => { const input = ref.current; if (!input) @@ -90,13 +104,36 @@ export const BaseInputComponent: React.FC = ({ question } const handleChange = (event: ChangeEvent) => { + console.log("BaseInputComponent:handleChange", event.target.value); + if (span) { + span.addEvent("BaseInputComponent:handleChange", { 'value': event.target.value }); + } + //EXPLAIN: WHY IS THIS HERE? If no reason, lets remove. if (event.target.value === "") questionModel.errorMsg = ""; + + setText(() => event.target.value); answerQuestion(questionModel.logicalName, event.target.value, true); resize(); } + /** + * The input control is responsible of setting it self focus when becoming active. + * - We should also listen to input controls being focused and if not active, trigger a reducer that its set active. + * Ultimatly removing active from other questions. This happens right now when an answer is given (intermediate or not), so not critical. + */ + useEffect(() => { + if (questionModel.isActive) + ref.current?.focus(); + }, [questionModel.isActive]); + + /** + * While a base input component is active we should answer the question upon enter. + */ + useHandleEnterKeypress("baseinput", !questionModel.isActive, () => { + answerQuestion(questionModel.logicalName, text,false); + }); return (
diff --git a/packages/core/src/components/question/input-types/multiline/MultilineInput.tsx b/packages/core/src/components/question/input-types/multiline/MultilineInput.tsx index 93fbba4..d9258bf 100644 --- a/packages/core/src/components/question/input-types/multiline/MultilineInput.tsx +++ b/packages/core/src/components/question/input-types/multiline/MultilineInput.tsx @@ -61,7 +61,7 @@ export const MultilineInput: InputComponentType = ({ questi }, [ref, isFirstQuestionInCurrentSlide, questionModel.logicalName]); return ( -