optimized-react-component-library-xyz123 0.1.16 → 0.1.17

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
@@ -299,10 +299,14 @@ interface ValidationErrorSummaryListProps {
299
299
  declare const ValidationErrorSummaryList: React.FC<ValidationErrorSummaryListProps>;
300
300
 
301
301
  interface CookieBannerProps {
302
- isTouched: any;
302
+ isTouched?: any;
303
+ onCookieStateChange?: () => void;
303
304
  visible?: boolean;
305
+ onClose?: () => void;
306
+ acceptCookies: () => void;
307
+ rejectCookies: () => void;
304
308
  }
305
309
 
306
- declare const CookieBanner: FC<CookieBannerProps>;
310
+ declare const CookieBanner: React.FC<CookieBannerProps>;
307
311
 
308
312
  export { CookieBanner, 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, 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 };
package/dist/index.d.ts CHANGED
@@ -299,10 +299,14 @@ interface ValidationErrorSummaryListProps {
299
299
  declare const ValidationErrorSummaryList: React.FC<ValidationErrorSummaryListProps>;
300
300
 
301
301
  interface CookieBannerProps {
302
- isTouched: any;
302
+ isTouched?: any;
303
+ onCookieStateChange?: () => void;
303
304
  visible?: boolean;
305
+ onClose?: () => void;
306
+ acceptCookies: () => void;
307
+ rejectCookies: () => void;
304
308
  }
305
309
 
306
- declare const CookieBanner: FC<CookieBannerProps>;
310
+ declare const CookieBanner: React.FC<CookieBannerProps>;
307
311
 
308
312
  export { CookieBanner, 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, 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 };
package/dist/index.js CHANGED
@@ -2050,12 +2050,43 @@ var ValidationErrorSummaryList = ({
2050
2050
  var ValidationErrorSummaryList_default = ValidationErrorSummaryList;
2051
2051
 
2052
2052
  // src/NewTextComponentStandard/CookieBanner/CookieBanner.tsx
2053
+ var import_react6 = require("react");
2053
2054
  var import_jsx_runtime21 = require("react/jsx-runtime");
2054
- var CookieBanner = ({ isTouched, visible = true }) => {
2055
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: visible && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "pts-cookieBanner", children: [
2055
+ var CookieBanner = ({
2056
+ visible = false,
2057
+ onCookieStateChange,
2058
+ onClose,
2059
+ acceptCookies,
2060
+ rejectCookies
2061
+ }) => {
2062
+ (0, import_react6.useEffect)(() => {
2063
+ if (visible) {
2064
+ document.body.classList.add("has-cookie-banner");
2065
+ } else {
2066
+ document.body.classList.remove("has-cookie-banner");
2067
+ }
2068
+ return () => {
2069
+ document.body.classList.remove("has-cookie-banner");
2070
+ };
2071
+ }, [visible]);
2072
+ if (!visible) return null;
2073
+ const handleCookieChoice = (accepted) => {
2074
+ if (accepted) {
2075
+ acceptCookies();
2076
+ } else {
2077
+ rejectCookies();
2078
+ }
2079
+ if (onCookieStateChange) {
2080
+ onCookieStateChange();
2081
+ }
2082
+ if (onClose) {
2083
+ onClose();
2084
+ }
2085
+ };
2086
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "pts-cookieBanner", role: "dialog", "aria-labelledby": "cookie-banner-title", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "content", children: [
2056
2087
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h3", { children: "Kakor (cookies)" }),
2057
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { children: "PTS skulle vilja anv\xE4nda en statistikkaka i syfte att rapportera anv\xE4ndarstatistik till Europeiska kommissionen. Samtycker du till det? Du kan n\xE4r som helst \xE4ndra ditt val. F\xF6r att \xE5terkalla ditt samtycke klickar du p\xE5 \u201DKakor\u201D l\xE4ngst ned till v\xE4nster p\xE5 webbplatsen." }),
2058
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "pts-cookieBanner-link", children: [
2088
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { children: 'PTS skulle vilja anv\xE4nda en statistikkaka i syfte att rapportera anv\xE4ndarstatistik till Europeiska kommissionen. Samtycker du till det? Du kan n\xE4r som helst \xE4ndra ditt val. F\xF6r att \xE5terkalla ditt samtycke klickar du p\xE5 "Kakor" l\xE4ngst ned till v\xE4nster p\xE5 webbplatsen.' }),
2089
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "pts-cookieBanner-Links", children: [
2059
2090
  /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2060
2091
  "svg",
2061
2092
  {
@@ -2064,6 +2095,7 @@ var CookieBanner = ({ isTouched, visible = true }) => {
2064
2095
  viewBox: "0 0 27 27",
2065
2096
  fill: "none",
2066
2097
  xmlns: "http://www.w3.org/2000/svg",
2098
+ "aria-hidden": "true",
2067
2099
  children: [
2068
2100
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("rect", { width: "27", height: "27", rx: "13.5", fill: "#6E3282" }),
2069
2101
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
@@ -2076,27 +2108,11 @@ var CookieBanner = ({ isTouched, visible = true }) => {
2076
2108
  ]
2077
2109
  }
2078
2110
  ),
2079
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("a", { href: "www.pts.se", target: "blank", children: "Kakor (cookies) p\xE5 pts.se (\xF6ppnas i ny flik)" })
2111
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("a", { href: "www.pts.se", target: "_blank", rel: "noopener noreferrer", children: "Kakor (cookies) p\xE5 pts.se" })
2080
2112
  ] }),
2081
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "pts-cookieBanner-buttons", children: [
2082
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2083
- "button",
2084
- {
2085
- onClick: () => {
2086
- isTouched(true);
2087
- },
2088
- children: "Ja, jag samtycker"
2089
- }
2090
- ),
2091
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2092
- "button",
2093
- {
2094
- onClick: () => {
2095
- isTouched(false);
2096
- },
2097
- children: "Nej, jag samtycker inte"
2098
- }
2099
- )
2113
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "pts-cookieBanner-Buttons", children: [
2114
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { onClick: () => handleCookieChoice(true), children: "Ja, jag samtycker" }),
2115
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("button", { onClick: () => handleCookieChoice(false), children: "Nej, jag samtycker inte" })
2100
2116
  ] })
2101
2117
  ] }) });
2102
2118
  };
package/dist/index.mjs CHANGED
@@ -1986,12 +1986,43 @@ var ValidationErrorSummaryList = ({
1986
1986
  var ValidationErrorSummaryList_default = ValidationErrorSummaryList;
1987
1987
 
1988
1988
  // src/NewTextComponentStandard/CookieBanner/CookieBanner.tsx
1989
- import { Fragment as Fragment10, jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
1990
- var CookieBanner = ({ isTouched, visible = true }) => {
1991
- return /* @__PURE__ */ jsx21(Fragment10, { children: visible && /* @__PURE__ */ jsxs19("div", { className: "pts-cookieBanner", children: [
1989
+ import { useEffect as useEffect4 } from "react";
1990
+ import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
1991
+ var CookieBanner = ({
1992
+ visible = false,
1993
+ onCookieStateChange,
1994
+ onClose,
1995
+ acceptCookies,
1996
+ rejectCookies
1997
+ }) => {
1998
+ useEffect4(() => {
1999
+ if (visible) {
2000
+ document.body.classList.add("has-cookie-banner");
2001
+ } else {
2002
+ document.body.classList.remove("has-cookie-banner");
2003
+ }
2004
+ return () => {
2005
+ document.body.classList.remove("has-cookie-banner");
2006
+ };
2007
+ }, [visible]);
2008
+ if (!visible) return null;
2009
+ const handleCookieChoice = (accepted) => {
2010
+ if (accepted) {
2011
+ acceptCookies();
2012
+ } else {
2013
+ rejectCookies();
2014
+ }
2015
+ if (onCookieStateChange) {
2016
+ onCookieStateChange();
2017
+ }
2018
+ if (onClose) {
2019
+ onClose();
2020
+ }
2021
+ };
2022
+ return /* @__PURE__ */ jsx21("div", { className: "pts-cookieBanner", role: "dialog", "aria-labelledby": "cookie-banner-title", children: /* @__PURE__ */ jsxs19("div", { className: "content", children: [
1992
2023
  /* @__PURE__ */ jsx21("h3", { children: "Kakor (cookies)" }),
1993
- /* @__PURE__ */ jsx21("p", { children: "PTS skulle vilja anv\xE4nda en statistikkaka i syfte att rapportera anv\xE4ndarstatistik till Europeiska kommissionen. Samtycker du till det? Du kan n\xE4r som helst \xE4ndra ditt val. F\xF6r att \xE5terkalla ditt samtycke klickar du p\xE5 \u201DKakor\u201D l\xE4ngst ned till v\xE4nster p\xE5 webbplatsen." }),
1994
- /* @__PURE__ */ jsxs19("div", { className: "pts-cookieBanner-link", children: [
2024
+ /* @__PURE__ */ jsx21("p", { children: 'PTS skulle vilja anv\xE4nda en statistikkaka i syfte att rapportera anv\xE4ndarstatistik till Europeiska kommissionen. Samtycker du till det? Du kan n\xE4r som helst \xE4ndra ditt val. F\xF6r att \xE5terkalla ditt samtycke klickar du p\xE5 "Kakor" l\xE4ngst ned till v\xE4nster p\xE5 webbplatsen.' }),
2025
+ /* @__PURE__ */ jsxs19("div", { className: "pts-cookieBanner-Links", children: [
1995
2026
  /* @__PURE__ */ jsxs19(
1996
2027
  "svg",
1997
2028
  {
@@ -2000,6 +2031,7 @@ var CookieBanner = ({ isTouched, visible = true }) => {
2000
2031
  viewBox: "0 0 27 27",
2001
2032
  fill: "none",
2002
2033
  xmlns: "http://www.w3.org/2000/svg",
2034
+ "aria-hidden": "true",
2003
2035
  children: [
2004
2036
  /* @__PURE__ */ jsx21("rect", { width: "27", height: "27", rx: "13.5", fill: "#6E3282" }),
2005
2037
  /* @__PURE__ */ jsx21(
@@ -2012,27 +2044,11 @@ var CookieBanner = ({ isTouched, visible = true }) => {
2012
2044
  ]
2013
2045
  }
2014
2046
  ),
2015
- /* @__PURE__ */ jsx21("a", { href: "www.pts.se", target: "blank", children: "Kakor (cookies) p\xE5 pts.se (\xF6ppnas i ny flik)" })
2047
+ /* @__PURE__ */ jsx21("a", { href: "www.pts.se", target: "_blank", rel: "noopener noreferrer", children: "Kakor (cookies) p\xE5 pts.se" })
2016
2048
  ] }),
2017
- /* @__PURE__ */ jsxs19("div", { className: "pts-cookieBanner-buttons", children: [
2018
- /* @__PURE__ */ jsx21(
2019
- "button",
2020
- {
2021
- onClick: () => {
2022
- isTouched(true);
2023
- },
2024
- children: "Ja, jag samtycker"
2025
- }
2026
- ),
2027
- /* @__PURE__ */ jsx21(
2028
- "button",
2029
- {
2030
- onClick: () => {
2031
- isTouched(false);
2032
- },
2033
- children: "Nej, jag samtycker inte"
2034
- }
2035
- )
2049
+ /* @__PURE__ */ jsxs19("div", { className: "pts-cookieBanner-Buttons", children: [
2050
+ /* @__PURE__ */ jsx21("button", { onClick: () => handleCookieChoice(true), children: "Ja, jag samtycker" }),
2051
+ /* @__PURE__ */ jsx21("button", { onClick: () => handleCookieChoice(false), children: "Nej, jag samtycker inte" })
2036
2052
  ] })
2037
2053
  ] }) });
2038
2054
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "optimized-react-component-library-xyz123",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "A modern React component library using TypeScript.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",