optimized-react-component-library-xyz123 0.1.7 → 0.1.8
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 +0 -5
- package/dist/index.d.ts +0 -5
- package/dist/index.js +28 -53
- package/dist/index.mjs +28 -53
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -289,16 +289,11 @@ interface TextHeadlineAndBodyProps {
|
|
|
289
289
|
|
|
290
290
|
declare const TextHeadlineAndBody: FC<TextHeadlineAndBodyProps>;
|
|
291
291
|
|
|
292
|
-
interface ValidationError {
|
|
293
|
-
id: string;
|
|
294
|
-
fieldName: string;
|
|
295
|
-
}
|
|
296
292
|
interface ValidationErrorSummaryListProps {
|
|
297
293
|
formQuestions: any[];
|
|
298
294
|
activatedLanguage: string;
|
|
299
295
|
validationErrorsList: any[];
|
|
300
296
|
summaryText?: string;
|
|
301
|
-
onErrorClick?: (error: ValidationError) => void;
|
|
302
297
|
}
|
|
303
298
|
|
|
304
299
|
declare const ValidationErrorSummaryList: React.FC<ValidationErrorSummaryListProps>;
|
package/dist/index.d.ts
CHANGED
|
@@ -289,16 +289,11 @@ interface TextHeadlineAndBodyProps {
|
|
|
289
289
|
|
|
290
290
|
declare const TextHeadlineAndBody: FC<TextHeadlineAndBodyProps>;
|
|
291
291
|
|
|
292
|
-
interface ValidationError {
|
|
293
|
-
id: string;
|
|
294
|
-
fieldName: string;
|
|
295
|
-
}
|
|
296
292
|
interface ValidationErrorSummaryListProps {
|
|
297
293
|
formQuestions: any[];
|
|
298
294
|
activatedLanguage: string;
|
|
299
295
|
validationErrorsList: any[];
|
|
300
296
|
summaryText?: string;
|
|
301
|
-
onErrorClick?: (error: ValidationError) => void;
|
|
302
297
|
}
|
|
303
298
|
|
|
304
299
|
declare const ValidationErrorSummaryList: React.FC<ValidationErrorSummaryListProps>;
|
package/dist/index.js
CHANGED
|
@@ -1960,78 +1960,53 @@ var Stepper = ({ arraySteps = [], activeStep = 1 }) => {
|
|
|
1960
1960
|
var StepperStandard_default = Stepper;
|
|
1961
1961
|
|
|
1962
1962
|
// src/NewTextComponentStandard/ValidationErrorSummaryList/ValidationErrorSummaryList.tsx
|
|
1963
|
-
var import_react6 = require("react");
|
|
1964
1963
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1965
1964
|
var ValidationErrorSummaryList = ({
|
|
1966
1965
|
validationErrorsList,
|
|
1967
1966
|
formQuestions,
|
|
1968
1967
|
activatedLanguage,
|
|
1969
|
-
summaryText = "Du beh\xF6ver \xE5tg\xE4rda {count} {plural}"
|
|
1970
|
-
onErrorClick
|
|
1968
|
+
summaryText = "Du beh\xF6ver \xE5tg\xE4rda {count} {plural}"
|
|
1971
1969
|
}) => {
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
const
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
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 {
|
|
1970
|
+
console.log(formQuestions);
|
|
1971
|
+
console.log(validationErrorsList);
|
|
1972
|
+
function scrollToQuestion(questionId) {
|
|
1973
|
+
const container = document.getElementById(`question-${questionId}`);
|
|
1974
|
+
if (container) {
|
|
1975
|
+
container.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
1976
|
+
setTimeout(() => {
|
|
1977
|
+
const input = container.querySelector("input, textarea, select");
|
|
1978
|
+
if (input) {
|
|
1979
|
+
input.focus();
|
|
2015
1980
|
}
|
|
2016
|
-
|
|
2017
|
-
}
|
|
1981
|
+
}, 300);
|
|
2018
1982
|
}
|
|
2019
|
-
}
|
|
2020
|
-
if (!
|
|
2021
|
-
const count =
|
|
1983
|
+
}
|
|
1984
|
+
if (!validationErrorsList.length) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, {});
|
|
1985
|
+
const count = validationErrorsList.length;
|
|
2022
1986
|
const title = summaryText.replace("{count}", count.toString()).replace("{plural}", count === 1 ? "sak" : "saker");
|
|
1987
|
+
function getQuestionLabelById(id) {
|
|
1988
|
+
const found = formQuestions.find((item) => item.id === id);
|
|
1989
|
+
return found == null ? void 0 : found.questionLabel;
|
|
1990
|
+
}
|
|
2023
1991
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2024
1992
|
"div",
|
|
2025
1993
|
{
|
|
2026
1994
|
id: "pts-form-id-error-summary",
|
|
2027
|
-
role: "alert",
|
|
2028
1995
|
className: "pts-errorSummary-container pts-root-error",
|
|
2029
1996
|
tabIndex: -1,
|
|
2030
1997
|
children: [
|
|
2031
1998
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { "aria-hidden": "true", className: "errorDot", children: "!" }),
|
|
2032
1999
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "errorSummary-content", children: [
|
|
2033
2000
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h2", { children: title }),
|
|
2034
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ul", { children:
|
|
2001
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ul", { children: validationErrorsList.map((questionId, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2002
|
+
"a",
|
|
2003
|
+
{
|
|
2004
|
+
href: "#",
|
|
2005
|
+
onClick: (e) => scrollToQuestion(questionId),
|
|
2006
|
+
className: "errorSummary-text",
|
|
2007
|
+
children: getQuestionLabelById(questionId)
|
|
2008
|
+
}
|
|
2009
|
+
) }, questionId || i)) })
|
|
2035
2010
|
] })
|
|
2036
2011
|
]
|
|
2037
2012
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1897,78 +1897,53 @@ var Stepper = ({ arraySteps = [], activeStep = 1 }) => {
|
|
|
1897
1897
|
var StepperStandard_default = Stepper;
|
|
1898
1898
|
|
|
1899
1899
|
// src/NewTextComponentStandard/ValidationErrorSummaryList/ValidationErrorSummaryList.tsx
|
|
1900
|
-
import { useState as useState4, useEffect as useEffect4 } from "react";
|
|
1901
1900
|
import { Fragment as Fragment9, jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1902
1901
|
var ValidationErrorSummaryList = ({
|
|
1903
1902
|
validationErrorsList,
|
|
1904
1903
|
formQuestions,
|
|
1905
1904
|
activatedLanguage,
|
|
1906
|
-
summaryText = "Du beh\xF6ver \xE5tg\xE4rda {count} {plural}"
|
|
1907
|
-
onErrorClick
|
|
1905
|
+
summaryText = "Du beh\xF6ver \xE5tg\xE4rda {count} {plural}"
|
|
1908
1906
|
}) => {
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
const
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
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 {
|
|
1907
|
+
console.log(formQuestions);
|
|
1908
|
+
console.log(validationErrorsList);
|
|
1909
|
+
function scrollToQuestion(questionId) {
|
|
1910
|
+
const container = document.getElementById(`question-${questionId}`);
|
|
1911
|
+
if (container) {
|
|
1912
|
+
container.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
1913
|
+
setTimeout(() => {
|
|
1914
|
+
const input = container.querySelector("input, textarea, select");
|
|
1915
|
+
if (input) {
|
|
1916
|
+
input.focus();
|
|
1952
1917
|
}
|
|
1953
|
-
|
|
1954
|
-
}
|
|
1918
|
+
}, 300);
|
|
1955
1919
|
}
|
|
1956
|
-
}
|
|
1957
|
-
if (!
|
|
1958
|
-
const count =
|
|
1920
|
+
}
|
|
1921
|
+
if (!validationErrorsList.length) return /* @__PURE__ */ jsx20(Fragment9, {});
|
|
1922
|
+
const count = validationErrorsList.length;
|
|
1959
1923
|
const title = summaryText.replace("{count}", count.toString()).replace("{plural}", count === 1 ? "sak" : "saker");
|
|
1924
|
+
function getQuestionLabelById(id) {
|
|
1925
|
+
const found = formQuestions.find((item) => item.id === id);
|
|
1926
|
+
return found == null ? void 0 : found.questionLabel;
|
|
1927
|
+
}
|
|
1960
1928
|
return /* @__PURE__ */ jsxs18(
|
|
1961
1929
|
"div",
|
|
1962
1930
|
{
|
|
1963
1931
|
id: "pts-form-id-error-summary",
|
|
1964
|
-
role: "alert",
|
|
1965
1932
|
className: "pts-errorSummary-container pts-root-error",
|
|
1966
1933
|
tabIndex: -1,
|
|
1967
1934
|
children: [
|
|
1968
1935
|
/* @__PURE__ */ jsx20("span", { "aria-hidden": "true", className: "errorDot", children: "!" }),
|
|
1969
1936
|
/* @__PURE__ */ jsxs18("div", { className: "errorSummary-content", children: [
|
|
1970
1937
|
/* @__PURE__ */ jsx20("h2", { children: title }),
|
|
1971
|
-
/* @__PURE__ */ jsx20("ul", { children:
|
|
1938
|
+
/* @__PURE__ */ jsx20("ul", { children: validationErrorsList.map((questionId, i) => /* @__PURE__ */ jsx20("li", { children: /* @__PURE__ */ jsx20(
|
|
1939
|
+
"a",
|
|
1940
|
+
{
|
|
1941
|
+
href: "#",
|
|
1942
|
+
onClick: (e) => scrollToQuestion(questionId),
|
|
1943
|
+
className: "errorSummary-text",
|
|
1944
|
+
children: getQuestionLabelById(questionId)
|
|
1945
|
+
}
|
|
1946
|
+
) }, questionId || i)) })
|
|
1972
1947
|
] })
|
|
1973
1948
|
]
|
|
1974
1949
|
}
|