optimized-react-component-library-xyz123 0.1.35 → 0.1.37
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.js +22 -3
- package/dist/index.mjs +22 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2066,6 +2066,24 @@ var ValidationErrorSummaryList = ({
|
|
|
2066
2066
|
}) => {
|
|
2067
2067
|
console.log(formQuestions);
|
|
2068
2068
|
console.log(validationErrorsList);
|
|
2069
|
+
function filterIdsByGroupCheck(ids, questions) {
|
|
2070
|
+
var _a;
|
|
2071
|
+
const tailIds = /* @__PURE__ */ new Set();
|
|
2072
|
+
for (const q of questions) {
|
|
2073
|
+
const rules = (_a = q.validationType) != null ? _a : [];
|
|
2074
|
+
for (const rule of rules) {
|
|
2075
|
+
const m = /^groupCheck-(\d+(?:-\d+)*)$/.exec(rule.trim());
|
|
2076
|
+
if (!m) continue;
|
|
2077
|
+
const nums = m[1].split("-").map((s) => Number(s)).filter((n) => Number.isFinite(n));
|
|
2078
|
+
if (nums.length > 1) {
|
|
2079
|
+
for (let i = 1; i < nums.length; i++) {
|
|
2080
|
+
tailIds.add(nums[i]);
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
return ids.filter((id) => !tailIds.has(id));
|
|
2086
|
+
}
|
|
2069
2087
|
function scrollToQuestion(questionId) {
|
|
2070
2088
|
const container = document.getElementById(`question-${questionId}`);
|
|
2071
2089
|
if (container) {
|
|
@@ -2079,7 +2097,8 @@ var ValidationErrorSummaryList = ({
|
|
|
2079
2097
|
}
|
|
2080
2098
|
}
|
|
2081
2099
|
if (!validationErrorsList.length) return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, {});
|
|
2082
|
-
const
|
|
2100
|
+
const filteredIds = filterIdsByGroupCheck(validationErrorsList, formQuestions);
|
|
2101
|
+
const count = filteredIds.length;
|
|
2083
2102
|
const title = summaryText.replace("{count}", count.toString()).replace("{plural}", count === 1 ? "sak" : "saker");
|
|
2084
2103
|
function getQuestionLabelById(id) {
|
|
2085
2104
|
const found = formQuestions.find((item) => item.id === id);
|
|
@@ -2089,12 +2108,12 @@ var ValidationErrorSummaryList = ({
|
|
|
2089
2108
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { "aria-hidden": "true", className: "errorDot", children: "!" }),
|
|
2090
2109
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "errorSummary-content", id: "pts-errorSummary-content", children: [
|
|
2091
2110
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h2", { children: title }),
|
|
2092
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ul", { children:
|
|
2111
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("ul", { children: filteredIds.map((questionId, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2093
2112
|
"a",
|
|
2094
2113
|
{
|
|
2095
2114
|
href: `#question-${questionId}`,
|
|
2096
2115
|
onClick: (e) => {
|
|
2097
|
-
e.preventDefault;
|
|
2116
|
+
e.preventDefault();
|
|
2098
2117
|
scrollToQuestion(questionId);
|
|
2099
2118
|
},
|
|
2100
2119
|
className: "errorSummary-text",
|
package/dist/index.mjs
CHANGED
|
@@ -2002,6 +2002,24 @@ var ValidationErrorSummaryList = ({
|
|
|
2002
2002
|
}) => {
|
|
2003
2003
|
console.log(formQuestions);
|
|
2004
2004
|
console.log(validationErrorsList);
|
|
2005
|
+
function filterIdsByGroupCheck(ids, questions) {
|
|
2006
|
+
var _a;
|
|
2007
|
+
const tailIds = /* @__PURE__ */ new Set();
|
|
2008
|
+
for (const q of questions) {
|
|
2009
|
+
const rules = (_a = q.validationType) != null ? _a : [];
|
|
2010
|
+
for (const rule of rules) {
|
|
2011
|
+
const m = /^groupCheck-(\d+(?:-\d+)*)$/.exec(rule.trim());
|
|
2012
|
+
if (!m) continue;
|
|
2013
|
+
const nums = m[1].split("-").map((s) => Number(s)).filter((n) => Number.isFinite(n));
|
|
2014
|
+
if (nums.length > 1) {
|
|
2015
|
+
for (let i = 1; i < nums.length; i++) {
|
|
2016
|
+
tailIds.add(nums[i]);
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
return ids.filter((id) => !tailIds.has(id));
|
|
2022
|
+
}
|
|
2005
2023
|
function scrollToQuestion(questionId) {
|
|
2006
2024
|
const container = document.getElementById(`question-${questionId}`);
|
|
2007
2025
|
if (container) {
|
|
@@ -2015,7 +2033,8 @@ var ValidationErrorSummaryList = ({
|
|
|
2015
2033
|
}
|
|
2016
2034
|
}
|
|
2017
2035
|
if (!validationErrorsList.length) return /* @__PURE__ */ jsx20(Fragment9, {});
|
|
2018
|
-
const
|
|
2036
|
+
const filteredIds = filterIdsByGroupCheck(validationErrorsList, formQuestions);
|
|
2037
|
+
const count = filteredIds.length;
|
|
2019
2038
|
const title = summaryText.replace("{count}", count.toString()).replace("{plural}", count === 1 ? "sak" : "saker");
|
|
2020
2039
|
function getQuestionLabelById(id) {
|
|
2021
2040
|
const found = formQuestions.find((item) => item.id === id);
|
|
@@ -2025,12 +2044,12 @@ var ValidationErrorSummaryList = ({
|
|
|
2025
2044
|
/* @__PURE__ */ jsx20("span", { "aria-hidden": "true", className: "errorDot", children: "!" }),
|
|
2026
2045
|
/* @__PURE__ */ jsxs18("div", { className: "errorSummary-content", id: "pts-errorSummary-content", children: [
|
|
2027
2046
|
/* @__PURE__ */ jsx20("h2", { children: title }),
|
|
2028
|
-
/* @__PURE__ */ jsx20("ul", { children:
|
|
2047
|
+
/* @__PURE__ */ jsx20("ul", { children: filteredIds.map((questionId, i) => /* @__PURE__ */ jsx20("li", { children: /* @__PURE__ */ jsx20(
|
|
2029
2048
|
"a",
|
|
2030
2049
|
{
|
|
2031
2050
|
href: `#question-${questionId}`,
|
|
2032
2051
|
onClick: (e) => {
|
|
2033
|
-
e.preventDefault;
|
|
2052
|
+
e.preventDefault();
|
|
2034
2053
|
scrollToQuestion(questionId);
|
|
2035
2054
|
},
|
|
2036
2055
|
className: "errorSummary-text",
|
package/package.json
CHANGED