optimized-react-component-library-xyz123 0.1.95 → 0.1.97

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
@@ -459,6 +459,22 @@ declare const createCookieConsent: (config: CookieConsentConfig) => {
459
459
  clearChoiceFromSession: () => void;
460
460
  };
461
461
 
462
+ declare const toggleScriptByConsent: (consent: boolean, options: {
463
+ id: string;
464
+ src: string;
465
+ attributes?: Record<string, string>;
466
+ }) => void;
467
+ declare const isScriptLoaded: (id: string) => boolean;
468
+ declare const removeScriptById: (id: string) => void;
469
+
470
+ /**
471
+ * Sätter fokus på ett element med givet id (eller HTMLElement),
472
+ * sätter tabindex="-1" om inte redan finns, och scrollar dit smidigt.
473
+ *
474
+ * @param target Elementets id (t.ex. 'main-content') eller själva elementet.
475
+ */
476
+ declare const focusElement: (target: string | HTMLElement | null) => void;
477
+
462
478
  declare const RenderQuestion: ({ question, isTouched, activatedLanguage, showPreview, hideValidationMessage, }: any) => react_jsx_runtime.JSX.Element;
463
479
 
464
480
  declare const RenderQuestionGroup: ({ questionArray, wrapper, legend, isTouched, activatedLanguage, showPreview, AddQuestionDisplayed, hideValidationMessage, }: any) => react_jsx_runtime.JSX.Element;
@@ -565,4 +581,4 @@ interface CookieBannerProps {
565
581
 
566
582
  declare const CookieBanner: React.FC<CookieBannerProps>;
567
583
 
568
- 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, makeLanguageSelectors, makeQuestionsSelectors };
584
+ 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, isScriptLoaded, makeLanguageSelectors, makeQuestionsSelectors, removeScriptById, toggleScriptByConsent };
package/dist/index.d.ts CHANGED
@@ -459,6 +459,22 @@ declare const createCookieConsent: (config: CookieConsentConfig) => {
459
459
  clearChoiceFromSession: () => void;
460
460
  };
461
461
 
462
+ declare const toggleScriptByConsent: (consent: boolean, options: {
463
+ id: string;
464
+ src: string;
465
+ attributes?: Record<string, string>;
466
+ }) => void;
467
+ declare const isScriptLoaded: (id: string) => boolean;
468
+ declare const removeScriptById: (id: string) => void;
469
+
470
+ /**
471
+ * Sätter fokus på ett element med givet id (eller HTMLElement),
472
+ * sätter tabindex="-1" om inte redan finns, och scrollar dit smidigt.
473
+ *
474
+ * @param target Elementets id (t.ex. 'main-content') eller själva elementet.
475
+ */
476
+ declare const focusElement: (target: string | HTMLElement | null) => void;
477
+
462
478
  declare const RenderQuestion: ({ question, isTouched, activatedLanguage, showPreview, hideValidationMessage, }: any) => react_jsx_runtime.JSX.Element;
463
479
 
464
480
  declare const RenderQuestionGroup: ({ questionArray, wrapper, legend, isTouched, activatedLanguage, showPreview, AddQuestionDisplayed, hideValidationMessage, }: any) => react_jsx_runtime.JSX.Element;
@@ -565,4 +581,4 @@ interface CookieBannerProps {
565
581
 
566
582
  declare const CookieBanner: React.FC<CookieBannerProps>;
567
583
 
568
- 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, makeLanguageSelectors, makeQuestionsSelectors };
584
+ 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, isScriptLoaded, makeLanguageSelectors, makeQuestionsSelectors, removeScriptById, toggleScriptByConsent };
package/dist/index.js CHANGED
@@ -63,8 +63,12 @@ __export(index_exports, {
63
63
  createCookieConsent: () => createCookieConsent,
64
64
  createLanguageSlice: () => createLanguageSlice,
65
65
  createQuestionsSlice: () => createQuestionsSlice,
66
+ focusElement: () => focusElement,
67
+ isScriptLoaded: () => isScriptLoaded,
66
68
  makeLanguageSelectors: () => makeLanguageSelectors,
67
- makeQuestionsSelectors: () => makeQuestionsSelectors
69
+ makeQuestionsSelectors: () => makeQuestionsSelectors,
70
+ removeScriptById: () => removeScriptById,
71
+ toggleScriptByConsent: () => toggleScriptByConsent
68
72
  });
69
73
  module.exports = __toCommonJS(index_exports);
70
74
 
@@ -1865,6 +1869,50 @@ var createCookieConsent = (config) => {
1865
1869
  };
1866
1870
  };
1867
1871
 
1872
+ // src/NewHelpMethodsStandard/ScriptHandler/scriptHandler.ts
1873
+ var toggleScriptByConsent = (consent, options) => {
1874
+ if (typeof document === "undefined") return;
1875
+ const existingScript = document.getElementById(options.id);
1876
+ if (consent) {
1877
+ if (!existingScript) {
1878
+ const script = document.createElement("script");
1879
+ script.id = options.id;
1880
+ script.async = true;
1881
+ script.src = options.src;
1882
+ if (options.attributes) {
1883
+ Object.entries(options.attributes).forEach(
1884
+ ([key, value]) => script.setAttribute(key, value)
1885
+ );
1886
+ }
1887
+ document.body.appendChild(script);
1888
+ }
1889
+ } else {
1890
+ if (existingScript) {
1891
+ existingScript.remove();
1892
+ }
1893
+ }
1894
+ };
1895
+ var isScriptLoaded = (id) => {
1896
+ if (typeof document === "undefined") return false;
1897
+ return !!document.getElementById(id);
1898
+ };
1899
+ var removeScriptById = (id) => {
1900
+ if (typeof document === "undefined") return;
1901
+ const el = document.getElementById(id);
1902
+ if (el) el.remove();
1903
+ };
1904
+
1905
+ // src/NewHelpMethodsStandard/FocusElement/focusElement.ts
1906
+ var focusElement = (target) => {
1907
+ const element = typeof target === "string" ? document.getElementById(target) : target;
1908
+ if (!element) return;
1909
+ if (!element.hasAttribute("tabindex")) {
1910
+ element.setAttribute("tabindex", "-1");
1911
+ }
1912
+ element.focus();
1913
+ element.scrollIntoView({ behavior: "smooth" });
1914
+ };
1915
+
1868
1916
  // src/NewRenderFormComponentStandard/RenderQuestion/RenderQuestion.tsx
1869
1917
  var import_jsx_runtime12 = require("react/jsx-runtime");
1870
1918
  var RenderQuestion = ({
@@ -3158,6 +3206,10 @@ var CookieBanner_default = CookieBanner;
3158
3206
  createCookieConsent,
3159
3207
  createLanguageSlice,
3160
3208
  createQuestionsSlice,
3209
+ focusElement,
3210
+ isScriptLoaded,
3161
3211
  makeLanguageSelectors,
3162
- makeQuestionsSelectors
3212
+ makeQuestionsSelectors,
3213
+ removeScriptById,
3214
+ toggleScriptByConsent
3163
3215
  });
package/dist/index.mjs CHANGED
@@ -1798,6 +1798,50 @@ var createCookieConsent = (config) => {
1798
1798
  };
1799
1799
  };
1800
1800
 
1801
+ // src/NewHelpMethodsStandard/ScriptHandler/scriptHandler.ts
1802
+ var toggleScriptByConsent = (consent, options) => {
1803
+ if (typeof document === "undefined") return;
1804
+ const existingScript = document.getElementById(options.id);
1805
+ if (consent) {
1806
+ if (!existingScript) {
1807
+ const script = document.createElement("script");
1808
+ script.id = options.id;
1809
+ script.async = true;
1810
+ script.src = options.src;
1811
+ if (options.attributes) {
1812
+ Object.entries(options.attributes).forEach(
1813
+ ([key, value]) => script.setAttribute(key, value)
1814
+ );
1815
+ }
1816
+ document.body.appendChild(script);
1817
+ }
1818
+ } else {
1819
+ if (existingScript) {
1820
+ existingScript.remove();
1821
+ }
1822
+ }
1823
+ };
1824
+ var isScriptLoaded = (id) => {
1825
+ if (typeof document === "undefined") return false;
1826
+ return !!document.getElementById(id);
1827
+ };
1828
+ var removeScriptById = (id) => {
1829
+ if (typeof document === "undefined") return;
1830
+ const el = document.getElementById(id);
1831
+ if (el) el.remove();
1832
+ };
1833
+
1834
+ // src/NewHelpMethodsStandard/FocusElement/focusElement.ts
1835
+ var focusElement = (target) => {
1836
+ const element = typeof target === "string" ? document.getElementById(target) : target;
1837
+ if (!element) return;
1838
+ if (!element.hasAttribute("tabindex")) {
1839
+ element.setAttribute("tabindex", "-1");
1840
+ }
1841
+ element.focus();
1842
+ element.scrollIntoView({ behavior: "smooth" });
1843
+ };
1844
+
1801
1845
  // src/NewRenderFormComponentStandard/RenderQuestion/RenderQuestion.tsx
1802
1846
  import { Fragment as Fragment12, jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
1803
1847
  var RenderQuestion = ({
@@ -3090,6 +3134,10 @@ export {
3090
3134
  createCookieConsent,
3091
3135
  createLanguageSlice,
3092
3136
  createQuestionsSlice,
3137
+ focusElement,
3138
+ isScriptLoaded,
3093
3139
  makeLanguageSelectors,
3094
- makeQuestionsSelectors
3140
+ makeQuestionsSelectors,
3141
+ removeScriptById,
3142
+ toggleScriptByConsent
3095
3143
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "optimized-react-component-library-xyz123",
3
- "version": "0.1.95",
3
+ "version": "0.1.97",
4
4
  "description": "A modern React component library using TypeScript with React 19 support.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",