optimized-react-component-library-xyz123 0.1.129 → 0.1.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +53 -8
- package/dist/index.d.ts +53 -8
- package/dist/index.js +32 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -36
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React$1, { FC } from 'react';
|
|
2
2
|
import * as reselect from 'reselect';
|
|
3
3
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
4
4
|
import { PayloadAction, ActionReducerMapBuilder } from '@reduxjs/toolkit';
|
|
@@ -34,7 +34,7 @@ interface IFormState {
|
|
|
34
34
|
steps: Array<IStepObject>;
|
|
35
35
|
questions: Array<IQuestion>;
|
|
36
36
|
formLoaded: boolean;
|
|
37
|
-
|
|
37
|
+
formStatus: 'notloaded' | 'idle' | 'loading' | 'failed' | 'success';
|
|
38
38
|
}
|
|
39
39
|
interface IOption {
|
|
40
40
|
label: string;
|
|
@@ -598,7 +598,52 @@ declare const useCookieConsent: ({ cookieName, choiceKey, expiryYears, onConsent
|
|
|
598
598
|
|
|
599
599
|
declare const QuestionRenderer: ({ question, isTouched, activatedLanguage, showPreview, }: any) => react_jsx_runtime.JSX.Element;
|
|
600
600
|
|
|
601
|
-
|
|
601
|
+
type WrapperElement = 'fieldset' | 'section' | 'div' | 'none';
|
|
602
|
+
interface Question {
|
|
603
|
+
id: number | string;
|
|
604
|
+
visible: boolean;
|
|
605
|
+
isDisplayed: boolean;
|
|
606
|
+
isQuestionMandatory?: boolean;
|
|
607
|
+
hasValidationError?: boolean;
|
|
608
|
+
validationDefaultMessesege?: string;
|
|
609
|
+
[key: string]: any;
|
|
610
|
+
}
|
|
611
|
+
interface QuestionGroupProps {
|
|
612
|
+
/**
|
|
613
|
+
* Alla frågor som ingår i den här gruppen.
|
|
614
|
+
* Första frågan används som "bärare" av felstatus och obligatorisk-status
|
|
615
|
+
* när wrappern är ett fieldset.
|
|
616
|
+
*/
|
|
617
|
+
questions: Question[];
|
|
618
|
+
/**
|
|
619
|
+
* Vilket HTML-element gruppen ska renderas i (t.ex. fieldset för flera inputs).
|
|
620
|
+
*/
|
|
621
|
+
wrapperElement?: WrapperElement;
|
|
622
|
+
/**
|
|
623
|
+
* Texten som visas i <legend> när wrapperElement är 'fieldset'.
|
|
624
|
+
*/
|
|
625
|
+
legendLabel?: string;
|
|
626
|
+
/**
|
|
627
|
+
* Aktivt språk, används för att rendera t.ex. texter i QuestionRenderer.
|
|
628
|
+
*/
|
|
629
|
+
activatedLanguage: string;
|
|
630
|
+
/**
|
|
631
|
+
* Om true visas komponenten i gransknings-/preview-läge.
|
|
632
|
+
*/
|
|
633
|
+
showPreview?: boolean;
|
|
634
|
+
/**
|
|
635
|
+
* Callback som anropas när en fråga ändras.
|
|
636
|
+
* Skickar med både frågeobjektet och själva eventet.
|
|
637
|
+
*/
|
|
638
|
+
handleQuestionInputChange: (question: Question, event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>) => void;
|
|
639
|
+
/**
|
|
640
|
+
* Anropas när en fråga visas för att markera den som "displayed"
|
|
641
|
+
* i global state.
|
|
642
|
+
*/
|
|
643
|
+
markQuestionAsDisplayed: (question: Question) => void;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
declare const QuestionGroup: React$1.FC<QuestionGroupProps>;
|
|
602
647
|
|
|
603
648
|
interface CookieBannerProps {
|
|
604
649
|
isTouched?: any;
|
|
@@ -609,7 +654,7 @@ interface CookieBannerProps {
|
|
|
609
654
|
rejectCookies: () => void;
|
|
610
655
|
}
|
|
611
656
|
|
|
612
|
-
declare const CookieBanner: React.FC<CookieBannerProps>;
|
|
657
|
+
declare const CookieBanner: React$1.FC<CookieBannerProps>;
|
|
613
658
|
|
|
614
659
|
interface FooterProps {
|
|
615
660
|
activatedLanguage?: string;
|
|
@@ -668,14 +713,14 @@ interface EditPreviewLinkProps {
|
|
|
668
713
|
declare const EditPreviewLink: FC<EditPreviewLinkProps>;
|
|
669
714
|
|
|
670
715
|
interface StartApplicationButtonProps {
|
|
671
|
-
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
716
|
+
onClick: (event: React$1.MouseEvent<HTMLButtonElement>) => void;
|
|
672
717
|
label?: string;
|
|
673
718
|
className?: string;
|
|
674
719
|
}
|
|
675
720
|
/**
|
|
676
721
|
* En standardiserad knapp för att starta e-tjänsten.
|
|
677
722
|
*/
|
|
678
|
-
declare const StartApplicationButton: React.FC<StartApplicationButtonProps>;
|
|
723
|
+
declare const StartApplicationButton: React$1.FC<StartApplicationButtonProps>;
|
|
679
724
|
|
|
680
725
|
interface StepperButtonsProps {
|
|
681
726
|
languageSupported?: any;
|
|
@@ -702,7 +747,7 @@ interface ValidationErrorSummaryListProps {
|
|
|
702
747
|
summaryText?: string;
|
|
703
748
|
}
|
|
704
749
|
|
|
705
|
-
declare const ValidationErrorSummaryList: React.FC<ValidationErrorSummaryListProps>;
|
|
750
|
+
declare const ValidationErrorSummaryList: React$1.FC<ValidationErrorSummaryListProps>;
|
|
706
751
|
|
|
707
752
|
interface FormStatusMessagesProps {
|
|
708
753
|
formStatus: string;
|
|
@@ -711,6 +756,6 @@ interface FormStatusMessagesProps {
|
|
|
711
756
|
* Visar statusmeddelanden för formulär på ett tillgängligt sätt.
|
|
712
757
|
* Använder aria-live-regioner för att informera användare med skärmläsare.
|
|
713
758
|
*/
|
|
714
|
-
declare const FormStatusMessagesScreenReader: React.FC<FormStatusMessagesProps>;
|
|
759
|
+
declare const FormStatusMessagesScreenReader: React$1.FC<FormStatusMessagesProps>;
|
|
715
760
|
|
|
716
761
|
export { AddFiles as AddFilesStandard, CookieBanner, type CookieConsentConfig, EditPreviewLink as EditPreviewLinkStandard, Footer as FooterStandard, FormStatusMessagesScreenReader, Header as HeaderStandard, type IApplicationContent, type IFormState, type IOption, type IPTSLink, type IQuestion, type IQuestionExtraAttribute, type IStepObject, type IStepQuestionData, type ITextBlock, InfoOnly as InfoOnlyStandard, type LanguageSupportConfig, Modal as ModalStandard, MultipleCheckboxes as MultipleCheckboxesStandard, PrincipleOfPublicity as PrincipleOfPublicityStandard, QuestionGroup, QuestionRenderer, InputRadio as RadioMultipleStandard, SkipLink as SkipLinkStandard, StartApplicationButton, StepperButtons as StepperButtonsStandard, Stepper as StepperStandard, InputTextarea as TextAreaStandard, TextBody, TextFieldStandard, ValidationErrorSummaryList, buildStepCategoryGroupQuestionStructure, createApiDataObject, createCookieConsent, createFormSlice, createGlobalLanguageSlice, createGlobalLanguageSlice as createLanguageSlice, createFormSlice as createQuestionsSlice, findVisibleQuestionsWithValidationErrors, focusElement, getGroupCheckIds, hasQuestionValidationError, isQuestionDependencySatisfied, isScriptLoaded, makeFormSelectors, makeglobalLanguageSelectors as makeLanguageSelectors, makeFormSelectors as makeQuestionsSelectors, makeglobalLanguageSelectors, preparePreviewData, removeScriptById, toggleScriptByConsent, updateQuestionsAndCategoriesVisibilityAndErrors, useCookieConsent, useFormStatusModal, useInputMethodDetection, usePTSPageTitle };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React$1, { FC } from 'react';
|
|
2
2
|
import * as reselect from 'reselect';
|
|
3
3
|
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
4
4
|
import { PayloadAction, ActionReducerMapBuilder } from '@reduxjs/toolkit';
|
|
@@ -34,7 +34,7 @@ interface IFormState {
|
|
|
34
34
|
steps: Array<IStepObject>;
|
|
35
35
|
questions: Array<IQuestion>;
|
|
36
36
|
formLoaded: boolean;
|
|
37
|
-
|
|
37
|
+
formStatus: 'notloaded' | 'idle' | 'loading' | 'failed' | 'success';
|
|
38
38
|
}
|
|
39
39
|
interface IOption {
|
|
40
40
|
label: string;
|
|
@@ -598,7 +598,52 @@ declare const useCookieConsent: ({ cookieName, choiceKey, expiryYears, onConsent
|
|
|
598
598
|
|
|
599
599
|
declare const QuestionRenderer: ({ question, isTouched, activatedLanguage, showPreview, }: any) => react_jsx_runtime.JSX.Element;
|
|
600
600
|
|
|
601
|
-
|
|
601
|
+
type WrapperElement = 'fieldset' | 'section' | 'div' | 'none';
|
|
602
|
+
interface Question {
|
|
603
|
+
id: number | string;
|
|
604
|
+
visible: boolean;
|
|
605
|
+
isDisplayed: boolean;
|
|
606
|
+
isQuestionMandatory?: boolean;
|
|
607
|
+
hasValidationError?: boolean;
|
|
608
|
+
validationDefaultMessesege?: string;
|
|
609
|
+
[key: string]: any;
|
|
610
|
+
}
|
|
611
|
+
interface QuestionGroupProps {
|
|
612
|
+
/**
|
|
613
|
+
* Alla frågor som ingår i den här gruppen.
|
|
614
|
+
* Första frågan används som "bärare" av felstatus och obligatorisk-status
|
|
615
|
+
* när wrappern är ett fieldset.
|
|
616
|
+
*/
|
|
617
|
+
questions: Question[];
|
|
618
|
+
/**
|
|
619
|
+
* Vilket HTML-element gruppen ska renderas i (t.ex. fieldset för flera inputs).
|
|
620
|
+
*/
|
|
621
|
+
wrapperElement?: WrapperElement;
|
|
622
|
+
/**
|
|
623
|
+
* Texten som visas i <legend> när wrapperElement är 'fieldset'.
|
|
624
|
+
*/
|
|
625
|
+
legendLabel?: string;
|
|
626
|
+
/**
|
|
627
|
+
* Aktivt språk, används för att rendera t.ex. texter i QuestionRenderer.
|
|
628
|
+
*/
|
|
629
|
+
activatedLanguage: string;
|
|
630
|
+
/**
|
|
631
|
+
* Om true visas komponenten i gransknings-/preview-läge.
|
|
632
|
+
*/
|
|
633
|
+
showPreview?: boolean;
|
|
634
|
+
/**
|
|
635
|
+
* Callback som anropas när en fråga ändras.
|
|
636
|
+
* Skickar med både frågeobjektet och själva eventet.
|
|
637
|
+
*/
|
|
638
|
+
handleQuestionInputChange: (question: Question, event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>) => void;
|
|
639
|
+
/**
|
|
640
|
+
* Anropas när en fråga visas för att markera den som "displayed"
|
|
641
|
+
* i global state.
|
|
642
|
+
*/
|
|
643
|
+
markQuestionAsDisplayed: (question: Question) => void;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
declare const QuestionGroup: React$1.FC<QuestionGroupProps>;
|
|
602
647
|
|
|
603
648
|
interface CookieBannerProps {
|
|
604
649
|
isTouched?: any;
|
|
@@ -609,7 +654,7 @@ interface CookieBannerProps {
|
|
|
609
654
|
rejectCookies: () => void;
|
|
610
655
|
}
|
|
611
656
|
|
|
612
|
-
declare const CookieBanner: React.FC<CookieBannerProps>;
|
|
657
|
+
declare const CookieBanner: React$1.FC<CookieBannerProps>;
|
|
613
658
|
|
|
614
659
|
interface FooterProps {
|
|
615
660
|
activatedLanguage?: string;
|
|
@@ -668,14 +713,14 @@ interface EditPreviewLinkProps {
|
|
|
668
713
|
declare const EditPreviewLink: FC<EditPreviewLinkProps>;
|
|
669
714
|
|
|
670
715
|
interface StartApplicationButtonProps {
|
|
671
|
-
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
716
|
+
onClick: (event: React$1.MouseEvent<HTMLButtonElement>) => void;
|
|
672
717
|
label?: string;
|
|
673
718
|
className?: string;
|
|
674
719
|
}
|
|
675
720
|
/**
|
|
676
721
|
* En standardiserad knapp för att starta e-tjänsten.
|
|
677
722
|
*/
|
|
678
|
-
declare const StartApplicationButton: React.FC<StartApplicationButtonProps>;
|
|
723
|
+
declare const StartApplicationButton: React$1.FC<StartApplicationButtonProps>;
|
|
679
724
|
|
|
680
725
|
interface StepperButtonsProps {
|
|
681
726
|
languageSupported?: any;
|
|
@@ -702,7 +747,7 @@ interface ValidationErrorSummaryListProps {
|
|
|
702
747
|
summaryText?: string;
|
|
703
748
|
}
|
|
704
749
|
|
|
705
|
-
declare const ValidationErrorSummaryList: React.FC<ValidationErrorSummaryListProps>;
|
|
750
|
+
declare const ValidationErrorSummaryList: React$1.FC<ValidationErrorSummaryListProps>;
|
|
706
751
|
|
|
707
752
|
interface FormStatusMessagesProps {
|
|
708
753
|
formStatus: string;
|
|
@@ -711,6 +756,6 @@ interface FormStatusMessagesProps {
|
|
|
711
756
|
* Visar statusmeddelanden för formulär på ett tillgängligt sätt.
|
|
712
757
|
* Använder aria-live-regioner för att informera användare med skärmläsare.
|
|
713
758
|
*/
|
|
714
|
-
declare const FormStatusMessagesScreenReader: React.FC<FormStatusMessagesProps>;
|
|
759
|
+
declare const FormStatusMessagesScreenReader: React$1.FC<FormStatusMessagesProps>;
|
|
715
760
|
|
|
716
761
|
export { AddFiles as AddFilesStandard, CookieBanner, type CookieConsentConfig, EditPreviewLink as EditPreviewLinkStandard, Footer as FooterStandard, FormStatusMessagesScreenReader, Header as HeaderStandard, type IApplicationContent, type IFormState, type IOption, type IPTSLink, type IQuestion, type IQuestionExtraAttribute, type IStepObject, type IStepQuestionData, type ITextBlock, InfoOnly as InfoOnlyStandard, type LanguageSupportConfig, Modal as ModalStandard, MultipleCheckboxes as MultipleCheckboxesStandard, PrincipleOfPublicity as PrincipleOfPublicityStandard, QuestionGroup, QuestionRenderer, InputRadio as RadioMultipleStandard, SkipLink as SkipLinkStandard, StartApplicationButton, StepperButtons as StepperButtonsStandard, Stepper as StepperStandard, InputTextarea as TextAreaStandard, TextBody, TextFieldStandard, ValidationErrorSummaryList, buildStepCategoryGroupQuestionStructure, createApiDataObject, createCookieConsent, createFormSlice, createGlobalLanguageSlice, createGlobalLanguageSlice as createLanguageSlice, createFormSlice as createQuestionsSlice, findVisibleQuestionsWithValidationErrors, focusElement, getGroupCheckIds, hasQuestionValidationError, isQuestionDependencySatisfied, isScriptLoaded, makeFormSelectors, makeglobalLanguageSelectors as makeLanguageSelectors, makeFormSelectors as makeQuestionsSelectors, makeglobalLanguageSelectors, preparePreviewData, removeScriptById, toggleScriptByConsent, updateQuestionsAndCategoriesVisibilityAndErrors, useCookieConsent, useFormStatusModal, useInputMethodDetection, usePTSPageTitle };
|
package/dist/index.js
CHANGED
|
@@ -1718,69 +1718,73 @@ var QuestionRenderer = ({
|
|
|
1718
1718
|
var QuestionRenderer_default = QuestionRenderer;
|
|
1719
1719
|
|
|
1720
1720
|
// src/components/question-rendering/QuestionGroup/QuestionGroup.tsx
|
|
1721
|
-
var import_react10 =
|
|
1721
|
+
var import_react10 = require("react");
|
|
1722
1722
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1723
1723
|
var QuestionGroup = ({
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1724
|
+
questions,
|
|
1725
|
+
wrapperElement = "none",
|
|
1726
|
+
legendLabel,
|
|
1727
|
+
handleQuestionInputChange,
|
|
1728
1728
|
activatedLanguage,
|
|
1729
|
-
showPreview,
|
|
1730
|
-
|
|
1729
|
+
showPreview = false,
|
|
1730
|
+
markQuestionAsDisplayed
|
|
1731
1731
|
}) => {
|
|
1732
|
+
if (!questions || questions.length === 0) {
|
|
1733
|
+
return null;
|
|
1734
|
+
}
|
|
1735
|
+
const firstQuestion = questions[0];
|
|
1732
1736
|
(0, import_react10.useEffect)(() => {
|
|
1733
|
-
|
|
1737
|
+
questions.forEach((question) => {
|
|
1734
1738
|
if (question.visible && !question.isDisplayed) {
|
|
1735
|
-
|
|
1739
|
+
markQuestionAsDisplayed(question);
|
|
1736
1740
|
}
|
|
1737
1741
|
});
|
|
1738
|
-
}, [
|
|
1739
|
-
const
|
|
1740
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react10.
|
|
1742
|
+
}, [questions]);
|
|
1743
|
+
const groupQuestions = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: questions.map((question, index) => {
|
|
1744
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react10.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1741
1745
|
QuestionRenderer_default,
|
|
1742
1746
|
{
|
|
1743
1747
|
question,
|
|
1744
|
-
isTouched,
|
|
1748
|
+
isTouched: handleQuestionInputChange,
|
|
1745
1749
|
activatedLanguage,
|
|
1746
1750
|
showPreview,
|
|
1747
1751
|
showConfigure: !showPreview
|
|
1748
1752
|
}
|
|
1749
1753
|
) }, "question-" + index);
|
|
1750
1754
|
}) });
|
|
1751
|
-
switch (
|
|
1755
|
+
switch (wrapperElement) {
|
|
1752
1756
|
case "fieldset":
|
|
1753
1757
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1754
1758
|
"fieldset",
|
|
1755
1759
|
{
|
|
1756
1760
|
className: "pts-root-question-group-fieldset",
|
|
1757
|
-
"aria-required":
|
|
1758
|
-
"aria-invalid":
|
|
1759
|
-
"aria-errormessage":
|
|
1760
|
-
"aria-describedby":
|
|
1761
|
+
"aria-required": firstQuestion.isQuestionMandatory || void 0,
|
|
1762
|
+
"aria-invalid": firstQuestion.hasValidationError || void 0,
|
|
1763
|
+
"aria-errormessage": firstQuestion.hasValidationError ? `${firstQuestion.id}-error` : void 0,
|
|
1764
|
+
"aria-describedby": firstQuestion.hasValidationError ? `${firstQuestion.id}-error` : void 0,
|
|
1761
1765
|
children: [
|
|
1762
|
-
|
|
1763
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "pts-legend", children:
|
|
1764
|
-
|
|
1766
|
+
legendLabel && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("legend", { children: [
|
|
1767
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "pts-legend", children: legendLabel }),
|
|
1768
|
+
firstQuestion.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "sr-only", children: [
|
|
1765
1769
|
"Valideringsfel. ",
|
|
1766
|
-
|
|
1770
|
+
firstQuestion.validationDefaultMessesege
|
|
1767
1771
|
] })
|
|
1768
1772
|
] }),
|
|
1769
|
-
|
|
1773
|
+
firstQuestion.hasValidationError && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "pts-root-error", id: firstQuestion.id + "-error", children: [
|
|
1770
1774
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { "aria-label": "Valideringsfel", className: "errorDot", children: "!" }),
|
|
1771
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "errorText", children:
|
|
1775
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "errorText", children: firstQuestion.validationDefaultMessesege })
|
|
1772
1776
|
] }),
|
|
1773
|
-
|
|
1777
|
+
groupQuestions
|
|
1774
1778
|
]
|
|
1775
1779
|
}
|
|
1776
1780
|
);
|
|
1777
1781
|
case "section":
|
|
1778
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("section", { className: "pts-root-question-group-section", children:
|
|
1782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("section", { className: "pts-root-question-group-section", children: groupQuestions });
|
|
1779
1783
|
case "div":
|
|
1780
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "pts-root-question-group-div", children:
|
|
1784
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "pts-root-question-group-div", children: groupQuestions });
|
|
1781
1785
|
case "none":
|
|
1782
1786
|
default:
|
|
1783
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react10.
|
|
1787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react10.Fragment, { children: groupQuestions });
|
|
1784
1788
|
}
|
|
1785
1789
|
};
|
|
1786
1790
|
var QuestionGroup_default = QuestionGroup;
|