optimized-react-component-library-xyz123 0.1.111 → 0.1.112

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 CHANGED
@@ -502,6 +502,22 @@ declare const useInputMethodDetection: ({ mouseClassName, keyboardToggleKey, }?:
502
502
  keyboardToggleKey?: string;
503
503
  }) => void;
504
504
 
505
+ interface UseCookieConsentConfig extends CookieConsentConfig {
506
+ /**
507
+ * Körs när cookies ändrar status (true = accepterade, false = ej)
508
+ */
509
+ cookieName: string;
510
+ choiceKey: string;
511
+ expiryYears?: number;
512
+ onConsentChange?: (accepted: boolean) => void;
513
+ }
514
+ declare const useCookieConsent: ({ cookieName, choiceKey, expiryYears, onConsentChange, }: UseCookieConsentConfig) => {
515
+ showBanner: boolean;
516
+ handleCookieStateChange: () => void;
517
+ acceptCookies: () => void;
518
+ rejectCookies: () => void;
519
+ };
520
+
505
521
  declare const RenderQuestion: ({ question, isTouched, activatedLanguage, showPreview, hideValidationMessage, }: any) => react_jsx_runtime.JSX.Element;
506
522
 
507
523
  declare const RenderQuestionGroup: ({ questionArray, wrapper, legend, isTouched, activatedLanguage, showPreview, AddQuestionDisplayed, hideValidationMessage, }: any) => react_jsx_runtime.JSX.Element;
@@ -608,4 +624,4 @@ interface CookieBannerProps {
608
624
 
609
625
  declare const CookieBanner: React.FC<CookieBannerProps>;
610
626
 
611
- export { AddFiles as AddFilesStandard, CookieBanner, type CookieConsentConfig, CreateApiDataObject, doCategoriesAndQuestionsVisible as DoCategoriesAndQuestionsVisible, EditPreviewLink as EditPreviewLinkStandard, FilesUpload as FilesUploadStandard, Footer as FooterStandard, groupQuestionByStepPreviewPage as GroupQuestionByStepPreviewPage, groupQuestionsByStepCategoryGroup as GroupQuestionsByStepCategoryGroup, Header as HeaderStandard, type IApplicationContent, type IFormState, type ILanguage, type ILanguageSupport, ILanguageSupportinitialState, type IOption, type IPTSLink, type IQuestion, type IQuestionExtraAttribute, type IStepObject, type IStepQuestionData, type ITextBlock, InfoOnly as InfoOnlyStandard, isDependsOnOtherQuestionTrue as IsDependsOnOtherQuestionTrue, type LanguageSupportConfig, Modal as ModalStandard, MultipleCheckboxes as MultipleCheckboxesStandard, PrincipleOfPublicity as PrincipleOfPublicityStandard, questionHasValidationError as QuestionHasValidationError, QuestioninitialState, InputRadio as RadioMultipleStandard, RenderQuestion, RenderQuestionGroup, ServiceHeadlineAndBody as ServiceHeadlineAndBodyStandard, SkipLink as SkipLinkStandard, StepperButtons as StepperButtonsStandard, Stepper as StepperStandard, InputTextarea as TextAreaStandard, TextFieldStandard, TextHeadlineAndBody as TextHeadlineAndBodyStandard, validationCheckAllVisibleQuestions as ValidationCheckAllVisibleQuestion, ValidationErrorSummaryList, createCookieConsent, createLanguageSlice, createQuestionsSlice, focusElement, getIdsGroupCheckValidationTypes, isScriptLoaded, makeLanguageSelectors, makeQuestionsSelectors, removeScriptById, toggleScriptByConsent, useFormStatusModal, useInputMethodDetection, usePTSPageTitle };
627
+ export { AddFiles as AddFilesStandard, CookieBanner, type CookieConsentConfig, CreateApiDataObject, doCategoriesAndQuestionsVisible as DoCategoriesAndQuestionsVisible, EditPreviewLink as EditPreviewLinkStandard, FilesUpload as FilesUploadStandard, Footer as FooterStandard, groupQuestionByStepPreviewPage as GroupQuestionByStepPreviewPage, groupQuestionsByStepCategoryGroup as GroupQuestionsByStepCategoryGroup, Header as HeaderStandard, type IApplicationContent, type IFormState, type ILanguage, type ILanguageSupport, ILanguageSupportinitialState, type IOption, type IPTSLink, type IQuestion, type IQuestionExtraAttribute, type IStepObject, type IStepQuestionData, type ITextBlock, InfoOnly as InfoOnlyStandard, isDependsOnOtherQuestionTrue as IsDependsOnOtherQuestionTrue, type LanguageSupportConfig, Modal as ModalStandard, MultipleCheckboxes as MultipleCheckboxesStandard, PrincipleOfPublicity as PrincipleOfPublicityStandard, questionHasValidationError as QuestionHasValidationError, QuestioninitialState, InputRadio as RadioMultipleStandard, RenderQuestion, RenderQuestionGroup, ServiceHeadlineAndBody as ServiceHeadlineAndBodyStandard, SkipLink as SkipLinkStandard, StepperButtons as StepperButtonsStandard, Stepper as StepperStandard, InputTextarea as TextAreaStandard, TextFieldStandard, TextHeadlineAndBody as TextHeadlineAndBodyStandard, validationCheckAllVisibleQuestions as ValidationCheckAllVisibleQuestion, ValidationErrorSummaryList, createCookieConsent, createLanguageSlice, createQuestionsSlice, focusElement, getIdsGroupCheckValidationTypes, isScriptLoaded, makeLanguageSelectors, makeQuestionsSelectors, removeScriptById, toggleScriptByConsent, useCookieConsent, useFormStatusModal, useInputMethodDetection, usePTSPageTitle };
package/dist/index.d.ts CHANGED
@@ -502,6 +502,22 @@ declare const useInputMethodDetection: ({ mouseClassName, keyboardToggleKey, }?:
502
502
  keyboardToggleKey?: string;
503
503
  }) => void;
504
504
 
505
+ interface UseCookieConsentConfig extends CookieConsentConfig {
506
+ /**
507
+ * Körs när cookies ändrar status (true = accepterade, false = ej)
508
+ */
509
+ cookieName: string;
510
+ choiceKey: string;
511
+ expiryYears?: number;
512
+ onConsentChange?: (accepted: boolean) => void;
513
+ }
514
+ declare const useCookieConsent: ({ cookieName, choiceKey, expiryYears, onConsentChange, }: UseCookieConsentConfig) => {
515
+ showBanner: boolean;
516
+ handleCookieStateChange: () => void;
517
+ acceptCookies: () => void;
518
+ rejectCookies: () => void;
519
+ };
520
+
505
521
  declare const RenderQuestion: ({ question, isTouched, activatedLanguage, showPreview, hideValidationMessage, }: any) => react_jsx_runtime.JSX.Element;
506
522
 
507
523
  declare const RenderQuestionGroup: ({ questionArray, wrapper, legend, isTouched, activatedLanguage, showPreview, AddQuestionDisplayed, hideValidationMessage, }: any) => react_jsx_runtime.JSX.Element;
@@ -608,4 +624,4 @@ interface CookieBannerProps {
608
624
 
609
625
  declare const CookieBanner: React.FC<CookieBannerProps>;
610
626
 
611
- export { AddFiles as AddFilesStandard, CookieBanner, type CookieConsentConfig, CreateApiDataObject, doCategoriesAndQuestionsVisible as DoCategoriesAndQuestionsVisible, EditPreviewLink as EditPreviewLinkStandard, FilesUpload as FilesUploadStandard, Footer as FooterStandard, groupQuestionByStepPreviewPage as GroupQuestionByStepPreviewPage, groupQuestionsByStepCategoryGroup as GroupQuestionsByStepCategoryGroup, Header as HeaderStandard, type IApplicationContent, type IFormState, type ILanguage, type ILanguageSupport, ILanguageSupportinitialState, type IOption, type IPTSLink, type IQuestion, type IQuestionExtraAttribute, type IStepObject, type IStepQuestionData, type ITextBlock, InfoOnly as InfoOnlyStandard, isDependsOnOtherQuestionTrue as IsDependsOnOtherQuestionTrue, type LanguageSupportConfig, Modal as ModalStandard, MultipleCheckboxes as MultipleCheckboxesStandard, PrincipleOfPublicity as PrincipleOfPublicityStandard, questionHasValidationError as QuestionHasValidationError, QuestioninitialState, InputRadio as RadioMultipleStandard, RenderQuestion, RenderQuestionGroup, ServiceHeadlineAndBody as ServiceHeadlineAndBodyStandard, SkipLink as SkipLinkStandard, StepperButtons as StepperButtonsStandard, Stepper as StepperStandard, InputTextarea as TextAreaStandard, TextFieldStandard, TextHeadlineAndBody as TextHeadlineAndBodyStandard, validationCheckAllVisibleQuestions as ValidationCheckAllVisibleQuestion, ValidationErrorSummaryList, createCookieConsent, createLanguageSlice, createQuestionsSlice, focusElement, getIdsGroupCheckValidationTypes, isScriptLoaded, makeLanguageSelectors, makeQuestionsSelectors, removeScriptById, toggleScriptByConsent, useFormStatusModal, useInputMethodDetection, usePTSPageTitle };
627
+ export { AddFiles as AddFilesStandard, CookieBanner, type CookieConsentConfig, CreateApiDataObject, doCategoriesAndQuestionsVisible as DoCategoriesAndQuestionsVisible, EditPreviewLink as EditPreviewLinkStandard, FilesUpload as FilesUploadStandard, Footer as FooterStandard, groupQuestionByStepPreviewPage as GroupQuestionByStepPreviewPage, groupQuestionsByStepCategoryGroup as GroupQuestionsByStepCategoryGroup, Header as HeaderStandard, type IApplicationContent, type IFormState, type ILanguage, type ILanguageSupport, ILanguageSupportinitialState, type IOption, type IPTSLink, type IQuestion, type IQuestionExtraAttribute, type IStepObject, type IStepQuestionData, type ITextBlock, InfoOnly as InfoOnlyStandard, isDependsOnOtherQuestionTrue as IsDependsOnOtherQuestionTrue, type LanguageSupportConfig, Modal as ModalStandard, MultipleCheckboxes as MultipleCheckboxesStandard, PrincipleOfPublicity as PrincipleOfPublicityStandard, questionHasValidationError as QuestionHasValidationError, QuestioninitialState, InputRadio as RadioMultipleStandard, RenderQuestion, RenderQuestionGroup, ServiceHeadlineAndBody as ServiceHeadlineAndBodyStandard, SkipLink as SkipLinkStandard, StepperButtons as StepperButtonsStandard, Stepper as StepperStandard, InputTextarea as TextAreaStandard, TextFieldStandard, TextHeadlineAndBody as TextHeadlineAndBodyStandard, validationCheckAllVisibleQuestions as ValidationCheckAllVisibleQuestion, ValidationErrorSummaryList, createCookieConsent, createLanguageSlice, createQuestionsSlice, focusElement, getIdsGroupCheckValidationTypes, isScriptLoaded, makeLanguageSelectors, makeQuestionsSelectors, removeScriptById, toggleScriptByConsent, useCookieConsent, useFormStatusModal, useInputMethodDetection, usePTSPageTitle };
package/dist/index.js CHANGED
@@ -70,6 +70,7 @@ __export(index_exports, {
70
70
  makeQuestionsSelectors: () => makeQuestionsSelectors,
71
71
  removeScriptById: () => removeScriptById,
72
72
  toggleScriptByConsent: () => toggleScriptByConsent,
73
+ useCookieConsent: () => useCookieConsent,
73
74
  useFormStatusModal: () => useFormStatusModal,
74
75
  useInputMethodDetection: () => useInputMethodDetection,
75
76
  usePTSPageTitle: () => usePTSPageTitle
@@ -1990,6 +1991,60 @@ var useInputMethodDetection = ({
1990
1991
  }, [mouseClassName, keyboardToggleKey]);
1991
1992
  };
1992
1993
 
1994
+ // src/NewHelpMethodsStandard/useCookieConsent/useCookieConsent.ts
1995
+ var import_react10 = require("react");
1996
+ var useCookieConsent = ({
1997
+ cookieName,
1998
+ choiceKey,
1999
+ expiryYears = 1,
2000
+ onConsentChange
2001
+ }) => {
2002
+ const {
2003
+ acceptCookies,
2004
+ rejectCookies,
2005
+ areCookiesAccepted,
2006
+ hasChoiceBeenMade,
2007
+ clearChoiceFromSession
2008
+ } = (0, import_react10.useMemo)(
2009
+ () => createCookieConsent({
2010
+ cookieName,
2011
+ choiceKey,
2012
+ expiryYears
2013
+ }),
2014
+ [cookieName, choiceKey, expiryYears]
2015
+ );
2016
+ const [showBanner, setShowBanner] = (0, import_react10.useState)(false);
2017
+ const handleCookieStateChange = (0, import_react10.useCallback)(() => {
2018
+ const cookiesNowAccepted = areCookiesAccepted();
2019
+ if (onConsentChange) {
2020
+ onConsentChange(cookiesNowAccepted);
2021
+ }
2022
+ setShowBanner(false);
2023
+ }, [areCookiesAccepted, onConsentChange]);
2024
+ (0, import_react10.useEffect)(() => {
2025
+ const cookiesAccepted = areCookiesAccepted();
2026
+ const choiceMade = hasChoiceBeenMade();
2027
+ setShowBanner(!cookiesAccepted && !choiceMade);
2028
+ if (cookiesAccepted && onConsentChange) {
2029
+ onConsentChange(true);
2030
+ }
2031
+ const handleShowBannerEvent = () => {
2032
+ clearChoiceFromSession();
2033
+ setShowBanner(true);
2034
+ };
2035
+ window.addEventListener("showCookieBanner", handleShowBannerEvent);
2036
+ return () => {
2037
+ window.removeEventListener("showCookieBanner", handleShowBannerEvent);
2038
+ };
2039
+ }, [areCookiesAccepted, hasChoiceBeenMade, clearChoiceFromSession, onConsentChange]);
2040
+ return {
2041
+ showBanner,
2042
+ handleCookieStateChange,
2043
+ acceptCookies,
2044
+ rejectCookies
2045
+ };
2046
+ };
2047
+
1993
2048
  // src/NewRenderFormComponentStandard/RenderQuestion/RenderQuestion.tsx
1994
2049
  var import_jsx_runtime12 = require("react/jsx-runtime");
1995
2050
  var RenderQuestion = ({
@@ -2042,7 +2097,7 @@ var RenderQuestion = ({
2042
2097
  var RenderQuestion_default = RenderQuestion;
2043
2098
 
2044
2099
  // src/NewRenderFormComponentStandard/RenderQuestionGroup/RenderQuestionGroup.tsx
2045
- var import_react10 = __toESM(require("react"));
2100
+ var import_react11 = __toESM(require("react"));
2046
2101
  var import_jsx_runtime13 = require("react/jsx-runtime");
2047
2102
  var RenderQuestionGroup = ({
2048
2103
  questionArray,
@@ -2054,7 +2109,7 @@ var RenderQuestionGroup = ({
2054
2109
  AddQuestionDisplayed,
2055
2110
  hideValidationMessage
2056
2111
  }) => {
2057
- import_react10.default.useEffect(() => {
2112
+ import_react11.default.useEffect(() => {
2058
2113
  questionArray.forEach((question) => {
2059
2114
  if (question.visible && !question.isDisplayed) {
2060
2115
  AddQuestionDisplayed(question);
@@ -2062,7 +2117,7 @@ var RenderQuestionGroup = ({
2062
2117
  });
2063
2118
  }, [questionArray]);
2064
2119
  const questions = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: questionArray.map((question, index) => {
2065
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react10.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2120
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react11.default.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2066
2121
  RenderQuestion_default,
2067
2122
  {
2068
2123
  question,
@@ -2105,7 +2160,7 @@ var RenderQuestionGroup = ({
2105
2160
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "pts-root-question-group-div", children: questions });
2106
2161
  case "none":
2107
2162
  default:
2108
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react10.default.Fragment, { children: questions });
2163
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react11.default.Fragment, { children: questions });
2109
2164
  }
2110
2165
  };
2111
2166
  var RenderQuestionGroup_default = RenderQuestionGroup;
@@ -2749,7 +2804,7 @@ var Header = ({
2749
2804
  var HeaderStandard_default = Header;
2750
2805
 
2751
2806
  // src/NewTextComponentStandard/InfoOnlyStandard/InfoOnlyStandard.tsx
2752
- var import_react11 = require("react");
2807
+ var import_react12 = require("react");
2753
2808
  var import_dompurify4 = __toESM(require("dompurify"));
2754
2809
  var import_jsx_runtime18 = require("react/jsx-runtime");
2755
2810
  var cleanText = (text) => import_dompurify4.default.sanitize(text, { ADD_ATTR: ["target", "class"] });
@@ -2763,7 +2818,7 @@ var InfoOnly = ({
2763
2818
  tabIndex = -1,
2764
2819
  activatedLanguage = "sv"
2765
2820
  }) => {
2766
- (0, import_react11.useEffect)(() => {
2821
+ (0, import_react12.useEffect)(() => {
2767
2822
  handleSeenText(questionObject);
2768
2823
  }, []);
2769
2824
  const handleSeenText = (questionObject2) => {
@@ -2822,7 +2877,7 @@ var Modal = ({ showModal: isOpen, activatedLanguage = "" }) => {
2822
2877
  var ModalStandard_default = Modal;
2823
2878
 
2824
2879
  // src/NewTextComponentStandard/TextHeadlineAndBodyStandard/TextHeadlineAndBodyStandard.tsx
2825
- var import_react12 = require("react");
2880
+ var import_react13 = require("react");
2826
2881
  var import_dompurify5 = __toESM(require("dompurify"));
2827
2882
  var import_jsx_runtime20 = require("react/jsx-runtime");
2828
2883
  var TextHeadlineAndBody = ({ data, headlineType = "h2" }) => {
@@ -2831,7 +2886,7 @@ var TextHeadlineAndBody = ({ data, headlineType = "h2" }) => {
2831
2886
  {
2832
2887
  className: "pts-textHeadlineAndBody-container",
2833
2888
  children: [
2834
- data.headline && (0, import_react12.createElement)(headlineType, { id: "textHeadlineAndBody-headline" }, data.headline),
2889
+ data.headline && (0, import_react13.createElement)(headlineType, { id: "textHeadlineAndBody-headline" }, data.headline),
2835
2890
  data.body && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { dangerouslySetInnerHTML: { __html: import_dompurify5.default.sanitize(data.body) } }),
2836
2891
  data.linksForMoreInfo && data.linksForMoreInfo.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ul", { className: "pts-moreinfo-list", children: data.linksForMoreInfo.map((link, index) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("li", { className: index > 0 ? "notFirstInList" : "", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2837
2892
  "a",
@@ -3067,14 +3122,14 @@ var StepperButtons = ({
3067
3122
  var StepperButtonsStandard_default = StepperButtons;
3068
3123
 
3069
3124
  // src/NewTextComponentStandard/StepperStandard/StepperStandard.tsx
3070
- var import_react13 = __toESM(require("react"));
3125
+ var import_react14 = __toESM(require("react"));
3071
3126
  var import_jsx_runtime25 = require("react/jsx-runtime");
3072
3127
  var Stepper = ({ arraySteps = [], activeStep = 1 }) => {
3073
3128
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "pts-stepper-container", "aria-hidden": "true", children: arraySteps.map((step, index) => {
3074
3129
  const isActive = step.step === activeStep;
3075
3130
  const lastElement = arraySteps.length;
3076
3131
  const isDone = step.step < activeStep;
3077
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_react13.default.Fragment, { children: [
3132
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_react14.default.Fragment, { children: [
3078
3133
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "pts-stepper-step", children: [
3079
3134
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3080
3135
  "div",
@@ -3290,6 +3345,7 @@ var CookieBanner_default = CookieBanner;
3290
3345
  makeQuestionsSelectors,
3291
3346
  removeScriptById,
3292
3347
  toggleScriptByConsent,
3348
+ useCookieConsent,
3293
3349
  useFormStatusModal,
3294
3350
  useInputMethodDetection,
3295
3351
  usePTSPageTitle