optimized-react-component-library-xyz123 0.1.6 → 0.1.7
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 +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +84 -2
- package/dist/index.mjs +82 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -289,4 +289,18 @@ interface TextHeadlineAndBodyProps {
|
|
|
289
289
|
|
|
290
290
|
declare const TextHeadlineAndBody: FC<TextHeadlineAndBodyProps>;
|
|
291
291
|
|
|
292
|
-
|
|
292
|
+
interface ValidationError {
|
|
293
|
+
id: string;
|
|
294
|
+
fieldName: string;
|
|
295
|
+
}
|
|
296
|
+
interface ValidationErrorSummaryListProps {
|
|
297
|
+
formQuestions: any[];
|
|
298
|
+
activatedLanguage: string;
|
|
299
|
+
validationErrorsList: any[];
|
|
300
|
+
summaryText?: string;
|
|
301
|
+
onErrorClick?: (error: ValidationError) => void;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
declare const ValidationErrorSummaryList: React.FC<ValidationErrorSummaryListProps>;
|
|
305
|
+
|
|
306
|
+
export { 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
|
@@ -289,4 +289,18 @@ interface TextHeadlineAndBodyProps {
|
|
|
289
289
|
|
|
290
290
|
declare const TextHeadlineAndBody: FC<TextHeadlineAndBodyProps>;
|
|
291
291
|
|
|
292
|
-
|
|
292
|
+
interface ValidationError {
|
|
293
|
+
id: string;
|
|
294
|
+
fieldName: string;
|
|
295
|
+
}
|
|
296
|
+
interface ValidationErrorSummaryListProps {
|
|
297
|
+
formQuestions: any[];
|
|
298
|
+
activatedLanguage: string;
|
|
299
|
+
validationErrorsList: any[];
|
|
300
|
+
summaryText?: string;
|
|
301
|
+
onErrorClick?: (error: ValidationError) => void;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
declare const ValidationErrorSummaryList: React.FC<ValidationErrorSummaryListProps>;
|
|
305
|
+
|
|
306
|
+
export { 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
|
@@ -56,7 +56,8 @@ __export(index_exports, {
|
|
|
56
56
|
TextAreaStandard: () => TextAreaStandard_default,
|
|
57
57
|
TextFieldStandard: () => TextFieldStandard_default,
|
|
58
58
|
TextHeadlineAndBodyStandard: () => TextHeadlineAndBodyStandard_default,
|
|
59
|
-
ValidationCheckAllVisibleQuestion: () => ValidationCheckAllVisibleQuestion_default
|
|
59
|
+
ValidationCheckAllVisibleQuestion: () => ValidationCheckAllVisibleQuestion_default,
|
|
60
|
+
ValidationErrorSummaryList: () => ValidationErrorSummaryList_default
|
|
60
61
|
});
|
|
61
62
|
module.exports = __toCommonJS(index_exports);
|
|
62
63
|
|
|
@@ -1957,6 +1958,86 @@ var Stepper = ({ arraySteps = [], activeStep = 1 }) => {
|
|
|
1957
1958
|
}) });
|
|
1958
1959
|
};
|
|
1959
1960
|
var StepperStandard_default = Stepper;
|
|
1961
|
+
|
|
1962
|
+
// src/NewTextComponentStandard/ValidationErrorSummaryList/ValidationErrorSummaryList.tsx
|
|
1963
|
+
var import_react6 = require("react");
|
|
1964
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1965
|
+
var ValidationErrorSummaryList = ({
|
|
1966
|
+
validationErrorsList,
|
|
1967
|
+
formQuestions,
|
|
1968
|
+
activatedLanguage,
|
|
1969
|
+
summaryText = "Du beh\xF6ver \xE5tg\xE4rda {count} {plural}",
|
|
1970
|
+
onErrorClick
|
|
1971
|
+
}) => {
|
|
1972
|
+
const [validationErrors, setValidationErrors] = (0, import_react6.useState)([]);
|
|
1973
|
+
const getFieldName = (errorId) => {
|
|
1974
|
+
const questionId = errorId.replace("error-", "");
|
|
1975
|
+
const selectors = [
|
|
1976
|
+
`#label-${questionId}`,
|
|
1977
|
+
`label[for*="${questionId}"]`,
|
|
1978
|
+
`legend[id*="${questionId}"]`
|
|
1979
|
+
];
|
|
1980
|
+
for (const selector of selectors) {
|
|
1981
|
+
const element = document.querySelector(selector);
|
|
1982
|
+
if (element == null ? void 0 : element.textContent) return element.textContent.trim().replace("*", "").trim();
|
|
1983
|
+
}
|
|
1984
|
+
return "Ok\xE4nt f\xE4lt";
|
|
1985
|
+
};
|
|
1986
|
+
const detectValidationErrors = () => {
|
|
1987
|
+
const errors = [];
|
|
1988
|
+
document.querySelectorAll("#pts-form-id .pts-root-error").forEach((container) => {
|
|
1989
|
+
var _a, _b;
|
|
1990
|
+
if (!container.offsetParent) return;
|
|
1991
|
+
const errorText = (_b = (_a = container.querySelector(".errorText")) == null ? void 0 : _a.textContent) == null ? void 0 : _b.trim();
|
|
1992
|
+
if (!errorText) return;
|
|
1993
|
+
const errorId = container.id || `error-${Date.now()}`;
|
|
1994
|
+
errors.push({ id: errorId, fieldName: getFieldName(errorId) });
|
|
1995
|
+
});
|
|
1996
|
+
setValidationErrors(errors);
|
|
1997
|
+
};
|
|
1998
|
+
(0, import_react6.useEffect)(detectValidationErrors, [validationErrorsList]);
|
|
1999
|
+
const handleErrorClick = (error, e) => {
|
|
2000
|
+
e.preventDefault();
|
|
2001
|
+
if (onErrorClick) onErrorClick(error);
|
|
2002
|
+
const questionId = error.id.replace("error-", "");
|
|
2003
|
+
const selectors = [
|
|
2004
|
+
`#radio-group-${questionId}`,
|
|
2005
|
+
`input[name*="${questionId}"]`,
|
|
2006
|
+
`#${questionId}`
|
|
2007
|
+
];
|
|
2008
|
+
for (const selector of selectors) {
|
|
2009
|
+
const element = document.querySelector(selector);
|
|
2010
|
+
if (element) {
|
|
2011
|
+
element.scrollIntoView();
|
|
2012
|
+
try {
|
|
2013
|
+
element.focus();
|
|
2014
|
+
} catch {
|
|
2015
|
+
}
|
|
2016
|
+
break;
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
};
|
|
2020
|
+
if (!validationErrors.length) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, {});
|
|
2021
|
+
const count = validationErrors.length;
|
|
2022
|
+
const title = summaryText.replace("{count}", count.toString()).replace("{plural}", count === 1 ? "sak" : "saker");
|
|
2023
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2024
|
+
"div",
|
|
2025
|
+
{
|
|
2026
|
+
id: "pts-form-id-error-summary",
|
|
2027
|
+
role: "alert",
|
|
2028
|
+
className: "pts-errorSummary-container pts-root-error",
|
|
2029
|
+
tabIndex: -1,
|
|
2030
|
+
children: [
|
|
2031
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { "aria-hidden": "true", className: "errorDot", children: "!" }),
|
|
2032
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "errorSummary-content", children: [
|
|
2033
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h2", { children: title }),
|
|
2034
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ul", { children: validationErrors.map((error, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("a", { href: "#", onClick: (e) => handleErrorClick(error, e), className: "errorSummary-text", children: error.fieldName }) }, error.id || i)) })
|
|
2035
|
+
] })
|
|
2036
|
+
]
|
|
2037
|
+
}
|
|
2038
|
+
);
|
|
2039
|
+
};
|
|
2040
|
+
var ValidationErrorSummaryList_default = ValidationErrorSummaryList;
|
|
1960
2041
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1961
2042
|
0 && (module.exports = {
|
|
1962
2043
|
CreateApiDataObject,
|
|
@@ -1985,5 +2066,6 @@ var StepperStandard_default = Stepper;
|
|
|
1985
2066
|
TextAreaStandard,
|
|
1986
2067
|
TextFieldStandard,
|
|
1987
2068
|
TextHeadlineAndBodyStandard,
|
|
1988
|
-
ValidationCheckAllVisibleQuestion
|
|
2069
|
+
ValidationCheckAllVisibleQuestion,
|
|
2070
|
+
ValidationErrorSummaryList
|
|
1989
2071
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1895,6 +1895,86 @@ var Stepper = ({ arraySteps = [], activeStep = 1 }) => {
|
|
|
1895
1895
|
}) });
|
|
1896
1896
|
};
|
|
1897
1897
|
var StepperStandard_default = Stepper;
|
|
1898
|
+
|
|
1899
|
+
// src/NewTextComponentStandard/ValidationErrorSummaryList/ValidationErrorSummaryList.tsx
|
|
1900
|
+
import { useState as useState4, useEffect as useEffect4 } from "react";
|
|
1901
|
+
import { Fragment as Fragment9, jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1902
|
+
var ValidationErrorSummaryList = ({
|
|
1903
|
+
validationErrorsList,
|
|
1904
|
+
formQuestions,
|
|
1905
|
+
activatedLanguage,
|
|
1906
|
+
summaryText = "Du beh\xF6ver \xE5tg\xE4rda {count} {plural}",
|
|
1907
|
+
onErrorClick
|
|
1908
|
+
}) => {
|
|
1909
|
+
const [validationErrors, setValidationErrors] = useState4([]);
|
|
1910
|
+
const getFieldName = (errorId) => {
|
|
1911
|
+
const questionId = errorId.replace("error-", "");
|
|
1912
|
+
const selectors = [
|
|
1913
|
+
`#label-${questionId}`,
|
|
1914
|
+
`label[for*="${questionId}"]`,
|
|
1915
|
+
`legend[id*="${questionId}"]`
|
|
1916
|
+
];
|
|
1917
|
+
for (const selector of selectors) {
|
|
1918
|
+
const element = document.querySelector(selector);
|
|
1919
|
+
if (element == null ? void 0 : element.textContent) return element.textContent.trim().replace("*", "").trim();
|
|
1920
|
+
}
|
|
1921
|
+
return "Ok\xE4nt f\xE4lt";
|
|
1922
|
+
};
|
|
1923
|
+
const detectValidationErrors = () => {
|
|
1924
|
+
const errors = [];
|
|
1925
|
+
document.querySelectorAll("#pts-form-id .pts-root-error").forEach((container) => {
|
|
1926
|
+
var _a, _b;
|
|
1927
|
+
if (!container.offsetParent) return;
|
|
1928
|
+
const errorText = (_b = (_a = container.querySelector(".errorText")) == null ? void 0 : _a.textContent) == null ? void 0 : _b.trim();
|
|
1929
|
+
if (!errorText) return;
|
|
1930
|
+
const errorId = container.id || `error-${Date.now()}`;
|
|
1931
|
+
errors.push({ id: errorId, fieldName: getFieldName(errorId) });
|
|
1932
|
+
});
|
|
1933
|
+
setValidationErrors(errors);
|
|
1934
|
+
};
|
|
1935
|
+
useEffect4(detectValidationErrors, [validationErrorsList]);
|
|
1936
|
+
const handleErrorClick = (error, e) => {
|
|
1937
|
+
e.preventDefault();
|
|
1938
|
+
if (onErrorClick) onErrorClick(error);
|
|
1939
|
+
const questionId = error.id.replace("error-", "");
|
|
1940
|
+
const selectors = [
|
|
1941
|
+
`#radio-group-${questionId}`,
|
|
1942
|
+
`input[name*="${questionId}"]`,
|
|
1943
|
+
`#${questionId}`
|
|
1944
|
+
];
|
|
1945
|
+
for (const selector of selectors) {
|
|
1946
|
+
const element = document.querySelector(selector);
|
|
1947
|
+
if (element) {
|
|
1948
|
+
element.scrollIntoView();
|
|
1949
|
+
try {
|
|
1950
|
+
element.focus();
|
|
1951
|
+
} catch {
|
|
1952
|
+
}
|
|
1953
|
+
break;
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
};
|
|
1957
|
+
if (!validationErrors.length) return /* @__PURE__ */ jsx20(Fragment9, {});
|
|
1958
|
+
const count = validationErrors.length;
|
|
1959
|
+
const title = summaryText.replace("{count}", count.toString()).replace("{plural}", count === 1 ? "sak" : "saker");
|
|
1960
|
+
return /* @__PURE__ */ jsxs18(
|
|
1961
|
+
"div",
|
|
1962
|
+
{
|
|
1963
|
+
id: "pts-form-id-error-summary",
|
|
1964
|
+
role: "alert",
|
|
1965
|
+
className: "pts-errorSummary-container pts-root-error",
|
|
1966
|
+
tabIndex: -1,
|
|
1967
|
+
children: [
|
|
1968
|
+
/* @__PURE__ */ jsx20("span", { "aria-hidden": "true", className: "errorDot", children: "!" }),
|
|
1969
|
+
/* @__PURE__ */ jsxs18("div", { className: "errorSummary-content", children: [
|
|
1970
|
+
/* @__PURE__ */ jsx20("h2", { children: title }),
|
|
1971
|
+
/* @__PURE__ */ jsx20("ul", { children: validationErrors.map((error, i) => /* @__PURE__ */ jsx20("li", { children: /* @__PURE__ */ jsx20("a", { href: "#", onClick: (e) => handleErrorClick(error, e), className: "errorSummary-text", children: error.fieldName }) }, error.id || i)) })
|
|
1972
|
+
] })
|
|
1973
|
+
]
|
|
1974
|
+
}
|
|
1975
|
+
);
|
|
1976
|
+
};
|
|
1977
|
+
var ValidationErrorSummaryList_default = ValidationErrorSummaryList;
|
|
1898
1978
|
export {
|
|
1899
1979
|
CreateApiDataObject_default as CreateApiDataObject,
|
|
1900
1980
|
DoCategoriesAndQuestionsVisible_default as DoCategoriesAndQuestionsVisible,
|
|
@@ -1922,5 +2002,6 @@ export {
|
|
|
1922
2002
|
TextAreaStandard_default as TextAreaStandard,
|
|
1923
2003
|
TextFieldStandard_default as TextFieldStandard,
|
|
1924
2004
|
TextHeadlineAndBodyStandard_default as TextHeadlineAndBodyStandard,
|
|
1925
|
-
ValidationCheckAllVisibleQuestion_default as ValidationCheckAllVisibleQuestion
|
|
2005
|
+
ValidationCheckAllVisibleQuestion_default as ValidationCheckAllVisibleQuestion,
|
|
2006
|
+
ValidationErrorSummaryList_default as ValidationErrorSummaryList
|
|
1926
2007
|
};
|