@redneckz/wildless-cms-uni-blocks 0.14.197 → 0.14.199
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/bin/migration-scripts/0.14.189.js +22 -0
- package/bundle/bundle.umd.js +77 -79
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/hooks/useForm.d.ts +8 -7
- package/bundle/hooks/useJSONRef/resolveBlockProps.d.ts +1 -0
- package/bundle/ui-kit/BaseFiltration/filterBlocks.d.ts +1 -1
- package/bundle/ui-kit/BaseFiltration/useFiltrationForm.d.ts +10 -0
- package/dist/components/DepositFiltration/DepositFiltration.js +20 -11
- package/dist/components/DepositFiltration/DepositFiltration.js.map +1 -1
- package/dist/components/MortgageFiltration/MortgageFiltration.js +6 -7
- package/dist/components/MortgageFiltration/MortgageFiltration.js.map +1 -1
- package/dist/content-page-repository/replaceHeadingTags.js +1 -1
- package/dist/content-page-repository/replaceHeadingTags.js.map +1 -1
- package/dist/hooks/useForm.d.ts +8 -7
- package/dist/hooks/useForm.js.map +1 -1
- package/dist/hooks/useJSONRef/resolveBlockProps.d.ts +1 -0
- package/dist/hooks/useJSONRef/resolveBlockProps.js +6 -0
- package/dist/hooks/useJSONRef/resolveBlockProps.js.map +1 -0
- package/dist/hooks/useJSONRef/useJSONRef.js +2 -3
- package/dist/hooks/useJSONRef/useJSONRef.js.map +1 -1
- package/dist/ui-kit/BaseFiltration/filterBlocks.d.ts +1 -1
- package/dist/ui-kit/BaseFiltration/filterBlocks.js +3 -1
- package/dist/ui-kit/BaseFiltration/filterBlocks.js.map +1 -1
- package/dist/ui-kit/BaseFiltration/useFiltrationForm.d.ts +10 -0
- package/dist/ui-kit/BaseFiltration/useFiltrationForm.js +23 -0
- package/dist/ui-kit/BaseFiltration/useFiltrationForm.js.map +1 -0
- package/lib/components/DepositFiltration/DepositFiltration.js +20 -11
- package/lib/components/DepositFiltration/DepositFiltration.js.map +1 -1
- package/lib/components/MortgageFiltration/MortgageFiltration.js +6 -7
- package/lib/components/MortgageFiltration/MortgageFiltration.js.map +1 -1
- package/lib/content-page-repository/replaceHeadingTags.js +1 -1
- package/lib/content-page-repository/replaceHeadingTags.js.map +1 -1
- package/lib/hooks/useForm.d.ts +8 -7
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useJSONRef/resolveBlockProps.d.ts +1 -0
- package/lib/hooks/useJSONRef/resolveBlockProps.js +3 -0
- package/lib/hooks/useJSONRef/resolveBlockProps.js.map +1 -0
- package/lib/hooks/useJSONRef/useJSONRef.js +3 -4
- package/lib/hooks/useJSONRef/useJSONRef.js.map +1 -1
- package/lib/ui-kit/BaseFiltration/filterBlocks.d.ts +1 -1
- package/lib/ui-kit/BaseFiltration/filterBlocks.js +3 -1
- package/lib/ui-kit/BaseFiltration/filterBlocks.js.map +1 -1
- package/lib/ui-kit/BaseFiltration/useFiltrationForm.d.ts +10 -0
- package/lib/ui-kit/BaseFiltration/useFiltrationForm.js +20 -0
- package/lib/ui-kit/BaseFiltration/useFiltrationForm.js.map +1 -0
- package/mobile/bundle/bundle.umd.js +77 -79
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/hooks/useForm.d.ts +8 -7
- package/mobile/bundle/hooks/useJSONRef/resolveBlockProps.d.ts +1 -0
- package/mobile/bundle/ui-kit/BaseFiltration/filterBlocks.d.ts +1 -1
- package/mobile/bundle/ui-kit/BaseFiltration/useFiltrationForm.d.ts +10 -0
- package/mobile/dist/components/DepositFiltration/DepositFiltration.js +20 -11
- package/mobile/dist/components/DepositFiltration/DepositFiltration.js.map +1 -1
- package/mobile/dist/components/MortgageFiltration/MortgageFiltration.js +6 -7
- package/mobile/dist/components/MortgageFiltration/MortgageFiltration.js.map +1 -1
- package/mobile/dist/content-page-repository/replaceHeadingTags.js +1 -1
- package/mobile/dist/content-page-repository/replaceHeadingTags.js.map +1 -1
- package/mobile/dist/hooks/useForm.d.ts +8 -7
- package/mobile/dist/hooks/useForm.js.map +1 -1
- package/mobile/dist/hooks/useJSONRef/resolveBlockProps.d.ts +1 -0
- package/mobile/dist/hooks/useJSONRef/resolveBlockProps.js +6 -0
- package/mobile/dist/hooks/useJSONRef/resolveBlockProps.js.map +1 -0
- package/mobile/dist/hooks/useJSONRef/useJSONRef.js +2 -3
- package/mobile/dist/hooks/useJSONRef/useJSONRef.js.map +1 -1
- package/mobile/dist/ui-kit/BaseFiltration/filterBlocks.d.ts +1 -1
- package/mobile/dist/ui-kit/BaseFiltration/filterBlocks.js +3 -1
- package/mobile/dist/ui-kit/BaseFiltration/filterBlocks.js.map +1 -1
- package/mobile/dist/ui-kit/BaseFiltration/useFiltrationForm.d.ts +10 -0
- package/mobile/dist/ui-kit/BaseFiltration/useFiltrationForm.js +23 -0
- package/mobile/dist/ui-kit/BaseFiltration/useFiltrationForm.js.map +1 -0
- package/mobile/lib/components/DepositFiltration/DepositFiltration.js +20 -11
- package/mobile/lib/components/DepositFiltration/DepositFiltration.js.map +1 -1
- package/mobile/lib/components/MortgageFiltration/MortgageFiltration.js +6 -7
- package/mobile/lib/components/MortgageFiltration/MortgageFiltration.js.map +1 -1
- package/mobile/lib/content-page-repository/replaceHeadingTags.js +1 -1
- package/mobile/lib/content-page-repository/replaceHeadingTags.js.map +1 -1
- package/mobile/lib/hooks/useForm.d.ts +8 -7
- package/mobile/lib/hooks/useForm.js.map +1 -1
- package/mobile/lib/hooks/useJSONRef/resolveBlockProps.d.ts +1 -0
- package/mobile/lib/hooks/useJSONRef/resolveBlockProps.js +3 -0
- package/mobile/lib/hooks/useJSONRef/resolveBlockProps.js.map +1 -0
- package/mobile/lib/hooks/useJSONRef/useJSONRef.js +3 -4
- package/mobile/lib/hooks/useJSONRef/useJSONRef.js.map +1 -1
- package/mobile/lib/ui-kit/BaseFiltration/filterBlocks.d.ts +1 -1
- package/mobile/lib/ui-kit/BaseFiltration/filterBlocks.js +3 -1
- package/mobile/lib/ui-kit/BaseFiltration/filterBlocks.js.map +1 -1
- package/mobile/lib/ui-kit/BaseFiltration/useFiltrationForm.d.ts +10 -0
- package/mobile/lib/ui-kit/BaseFiltration/useFiltrationForm.js +20 -0
- package/mobile/lib/ui-kit/BaseFiltration/useFiltrationForm.js.map +1 -0
- package/mobile/src/components/DepositFiltration/DepositFiltration.tsx +32 -16
- package/mobile/src/components/MortgageFiltration/MortgageFiltration.tsx +9 -13
- package/mobile/src/content-page-repository/replaceHeadingTags.ts +1 -1
- package/mobile/src/hooks/useForm.ts +9 -10
- package/mobile/src/hooks/useJSONRef/resolveBlockProps.ts +4 -0
- package/mobile/src/hooks/useJSONRef/useJSONRef.ts +3 -4
- package/mobile/src/ui-kit/BaseFiltration/filterBlocks.ts +8 -3
- package/mobile/src/ui-kit/BaseFiltration/useFiltrationForm.ts +52 -0
- package/package.json +1 -1
- package/src/components/DepositFiltration/DepositFiltration.fixture.mobile.tsx +3 -3
- package/src/components/DepositFiltration/DepositFiltration.fixture.tsx +10 -3
- package/src/components/DepositFiltration/DepositFiltration.tsx +32 -16
- package/src/components/MortgageFiltration/MortgageFiltration.tsx +9 -13
- package/src/content-page-repository/replaceHeadingTags.ts +1 -1
- package/src/hooks/useForm.ts +9 -10
- package/src/hooks/useJSONRef/resolveBlockProps.ts +4 -0
- package/src/hooks/useJSONRef/useJSONRef.ts +3 -4
- package/src/ui-kit/BaseFiltration/filterBlocks.ts +8 -3
- package/src/ui-kit/BaseFiltration/useFiltrationForm.ts +52 -0
- package/bundle/components/DepositFiltration/SourceItem.d.ts +0 -4
- package/bundle/components/DepositFiltration/getChildSourceBook.d.ts +0 -2
- package/bundle/components/DepositFiltration/getPeriod.d.ts +0 -4
- package/bundle/components/DepositFiltration/useDepositsPeriods.d.ts +0 -8
- package/dist/components/DepositFiltration/SourceItem.d.ts +0 -4
- package/dist/components/DepositFiltration/SourceItem.js +0 -2
- package/dist/components/DepositFiltration/SourceItem.js.map +0 -1
- package/dist/components/DepositFiltration/getChildSourceBook.d.ts +0 -2
- package/dist/components/DepositFiltration/getChildSourceBook.js +0 -6
- package/dist/components/DepositFiltration/getChildSourceBook.js.map +0 -1
- package/dist/components/DepositFiltration/getPeriod.d.ts +0 -4
- package/dist/components/DepositFiltration/getPeriod.js +0 -10
- package/dist/components/DepositFiltration/getPeriod.js.map +0 -1
- package/dist/components/DepositFiltration/useDepositsPeriods.d.ts +0 -8
- package/dist/components/DepositFiltration/useDepositsPeriods.js +0 -26
- package/dist/components/DepositFiltration/useDepositsPeriods.js.map +0 -1
- package/lib/components/DepositFiltration/SourceItem.d.ts +0 -4
- package/lib/components/DepositFiltration/SourceItem.js +0 -2
- package/lib/components/DepositFiltration/SourceItem.js.map +0 -1
- package/lib/components/DepositFiltration/getChildSourceBook.d.ts +0 -2
- package/lib/components/DepositFiltration/getChildSourceBook.js +0 -3
- package/lib/components/DepositFiltration/getChildSourceBook.js.map +0 -1
- package/lib/components/DepositFiltration/getPeriod.d.ts +0 -4
- package/lib/components/DepositFiltration/getPeriod.js +0 -7
- package/lib/components/DepositFiltration/getPeriod.js.map +0 -1
- package/lib/components/DepositFiltration/useDepositsPeriods.d.ts +0 -8
- package/lib/components/DepositFiltration/useDepositsPeriods.js +0 -23
- package/lib/components/DepositFiltration/useDepositsPeriods.js.map +0 -1
- package/mobile/bundle/components/DepositFiltration/SourceItem.d.ts +0 -4
- package/mobile/bundle/components/DepositFiltration/getChildSourceBook.d.ts +0 -2
- package/mobile/bundle/components/DepositFiltration/getPeriod.d.ts +0 -4
- package/mobile/bundle/components/DepositFiltration/useDepositsPeriods.d.ts +0 -8
- package/mobile/dist/components/DepositFiltration/SourceItem.d.ts +0 -4
- package/mobile/dist/components/DepositFiltration/SourceItem.js +0 -2
- package/mobile/dist/components/DepositFiltration/SourceItem.js.map +0 -1
- package/mobile/dist/components/DepositFiltration/getChildSourceBook.d.ts +0 -2
- package/mobile/dist/components/DepositFiltration/getChildSourceBook.js +0 -6
- package/mobile/dist/components/DepositFiltration/getChildSourceBook.js.map +0 -1
- package/mobile/dist/components/DepositFiltration/getPeriod.d.ts +0 -4
- package/mobile/dist/components/DepositFiltration/getPeriod.js +0 -10
- package/mobile/dist/components/DepositFiltration/getPeriod.js.map +0 -1
- package/mobile/dist/components/DepositFiltration/useDepositsPeriods.d.ts +0 -8
- package/mobile/dist/components/DepositFiltration/useDepositsPeriods.js +0 -26
- package/mobile/dist/components/DepositFiltration/useDepositsPeriods.js.map +0 -1
- package/mobile/lib/components/DepositFiltration/SourceItem.d.ts +0 -4
- package/mobile/lib/components/DepositFiltration/SourceItem.js +0 -2
- package/mobile/lib/components/DepositFiltration/SourceItem.js.map +0 -1
- package/mobile/lib/components/DepositFiltration/getChildSourceBook.d.ts +0 -2
- package/mobile/lib/components/DepositFiltration/getChildSourceBook.js +0 -3
- package/mobile/lib/components/DepositFiltration/getChildSourceBook.js.map +0 -1
- package/mobile/lib/components/DepositFiltration/getPeriod.d.ts +0 -4
- package/mobile/lib/components/DepositFiltration/getPeriod.js +0 -7
- package/mobile/lib/components/DepositFiltration/getPeriod.js.map +0 -1
- package/mobile/lib/components/DepositFiltration/useDepositsPeriods.d.ts +0 -8
- package/mobile/lib/components/DepositFiltration/useDepositsPeriods.js +0 -23
- package/mobile/lib/components/DepositFiltration/useDepositsPeriods.js.map +0 -1
- package/mobile/src/components/DepositFiltration/SourceItem.ts +0 -5
- package/mobile/src/components/DepositFiltration/getChildSourceBook.ts +0 -7
- package/mobile/src/components/DepositFiltration/getPeriod.ts +0 -13
- package/mobile/src/components/DepositFiltration/useDepositsPeriods.ts +0 -34
- package/src/components/DepositFiltration/SourceItem.ts +0 -5
- package/src/components/DepositFiltration/getChildSourceBook.ts +0 -7
- package/src/components/DepositFiltration/getPeriod.ts +0 -13
- package/src/components/DepositFiltration/useDepositsPeriods.ts +0 -34
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFiltrationForm.js","sourceRoot":"","sources":["../../../src/ui-kit/BaseFiltration/useFiltrationForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,OAAO,EAA0B,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE7E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,gBAA2B,EAC3B,EACE,KAAK,EACL,IAAI,EACJ,SAAS,GAAG,QAAQ,GAKrB,EAQD,EAAE;IACF,MAAM,MAAM,GAAG,KAAK,EAAE,MAAM,IAAI,EAAE,CAAC;IAEnC,MAAM,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,sBAAsB,EAAE,CAAC,GACvE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAE5B,MAAM,eAAe,GAAG,OAAO,CAC7B,GAAG,EAAE,CACH,GAAG,CACD,MAAM,EACN,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAChE,EACH,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CACzB,CAAC;IAEF,MAAM,cAAc,GAClB,eAAe,KAAK,gBAAgB;QAClC,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,YAAY,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC;IAEhE,OAAO;QACL,eAAe;QACf,EAAE,cAAc,EAAE,eAAe,EAAE;QACnC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,sBAAsB,EAAE;KACjD,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -781,6 +781,8 @@
|
|
|
781
781
|
.filter((res) => res.status === 'fulfilled')
|
|
782
782
|
.map(({ value }) => value));
|
|
783
783
|
|
|
784
|
+
const resolveBlockProps = (content, fallback) => resolveRef(content, (_) => fallback?.[_]);
|
|
785
|
+
|
|
784
786
|
const useJSONRef = (content, fallback) => {
|
|
785
787
|
const refs = collectRef(content);
|
|
786
788
|
const [refsMap, setRefsMap] = useState({});
|
|
@@ -789,9 +791,7 @@
|
|
|
789
791
|
fetchRefs(refs).then(setRefsMap);
|
|
790
792
|
}
|
|
791
793
|
}, [refs.join()]);
|
|
792
|
-
return refs.length
|
|
793
|
-
? resolveRef(content, (_) => refsMap[_] || fallback?.[_])
|
|
794
|
-
: content;
|
|
794
|
+
return refs.length ? resolveBlockProps(content, { ...fallback, ...refsMap }) : content;
|
|
795
795
|
};
|
|
796
796
|
|
|
797
797
|
const extractContent = ({ block, options, className, defaultPadding, padding, isTheme, version, children, ...content }) => content;
|
|
@@ -3365,6 +3365,42 @@
|
|
|
3365
3365
|
}, renderFoldButton: ({ isUnfolded, onToggle }) => (jsx(DefaultFoldButton, { className: style(topItemsCount < 1 ? 'hidden' : ''), disabled: !hiddenBlocks?.length, label: label, icon: ICONS$1[Number(isUnfolded)], dataTheme: rest.options?.page?.colorPalette, onClick: onToggle })) })] })] }));
|
|
3366
3366
|
});
|
|
3367
3367
|
|
|
3368
|
+
const SlideCheckboxGroup = JSX(({ value, onChange, items = [], multiple }) => {
|
|
3369
|
+
const handleChange = (newValue) => {
|
|
3370
|
+
if (!onChange) {
|
|
3371
|
+
return;
|
|
3372
|
+
}
|
|
3373
|
+
const hasAlready = value?.includes(newValue);
|
|
3374
|
+
if (multiple) {
|
|
3375
|
+
onChange(hasAlready ? (value || []).filter((v) => v !== newValue) : [...(value || []), newValue]);
|
|
3376
|
+
}
|
|
3377
|
+
else {
|
|
3378
|
+
onChange(hasAlready ? [] : [newValue]);
|
|
3379
|
+
}
|
|
3380
|
+
};
|
|
3381
|
+
return items.map((item) => (jsx(SlideCheckbox, { text: item?.title, value: [value].flatMap((_) => _).includes(item.value), onChange: () => handleChange(item.value), type: multiple ? 'checkbox' : 'radio' }, item.value)));
|
|
3382
|
+
});
|
|
3383
|
+
|
|
3384
|
+
const renderFiltrationForm$1 = ({ field, reset, filtrationSchema, resetButton, children, }) => (jsxs("form", { className: "flex flex-col @4xl:flex-row justify-between bg-white p-4xl gap-s @4xl:gap-0", children: [jsxs("div", { className: "flex flex-col @4xl:flex-row gap-5xl", children: [children, Object.entries(filtrationSchema).map(renderFormItem(field))] }), resetButton ? (jsx("div", { children: jsx(Button, { type: "reset", className: "w-full @4xl:w-72 @4xl:ml-s", onClick: reset, children: resetButton?.text }) })) : null] }));
|
|
3385
|
+
const renderFormItem = (field) => ([key, item]) => {
|
|
3386
|
+
const type = item?.type;
|
|
3387
|
+
switch (type) {
|
|
3388
|
+
case 'array':
|
|
3389
|
+
return renderCheckboxes(key, field)(item);
|
|
3390
|
+
default:
|
|
3391
|
+
return null;
|
|
3392
|
+
}
|
|
3393
|
+
};
|
|
3394
|
+
const renderCheckboxes = (key, field) => (item) => {
|
|
3395
|
+
const options = item?.items?.enum?.map((e, i) => ({ value: e, title: item?.items?.enumNames?.[i] || '' })) ||
|
|
3396
|
+
[];
|
|
3397
|
+
return (jsxs("div", { children: [item?.title ? (jsx("div", { className: "mb-m", children: jsx(Text, { size: "text-m", font: "font-light", color: "text-secondary-text", children: item.title }) })) : null, jsx(SlideCheckboxGroup, { items: options, multiple: !item?.single, ...field(key) })] }, key));
|
|
3398
|
+
};
|
|
3399
|
+
|
|
3400
|
+
function zip(firstCol, ...restCols) {
|
|
3401
|
+
return firstCol.map((firstEl, rowIndex) => [firstEl, ...restCols.map((col) => col[rowIndex])]);
|
|
3402
|
+
}
|
|
3403
|
+
|
|
3368
3404
|
const isEmpty = (v) => v === null ||
|
|
3369
3405
|
v === undefined ||
|
|
3370
3406
|
v === '' ||
|
|
@@ -3400,38 +3436,22 @@
|
|
|
3400
3436
|
.every((predicate) => predicate(target));
|
|
3401
3437
|
const naturalNumber = (n) => Number(n || 0);
|
|
3402
3438
|
|
|
3403
|
-
const filterBlocks = (
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
}
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
});
|
|
3420
|
-
|
|
3421
|
-
const renderFiltrationForm$1 = ({ field, reset, filtrationSchema, resetButton, children, }) => (jsxs("form", { className: "flex flex-col @4xl:flex-row justify-between bg-white p-4xl gap-s @4xl:gap-0", children: [jsxs("div", { className: "flex flex-col @4xl:flex-row gap-5xl", children: [children, Object.entries(filtrationSchema).map(renderFormItem(field))] }), resetButton ? (jsx("div", { children: jsx(Button, { type: "reset", className: "w-full @4xl:w-72 @4xl:ml-s", onClick: reset, children: resetButton?.text }) })) : null] }));
|
|
3422
|
-
const renderFormItem = (field) => ([key, item]) => {
|
|
3423
|
-
const type = item?.type;
|
|
3424
|
-
switch (type) {
|
|
3425
|
-
case 'array':
|
|
3426
|
-
return renderCheckboxes(key, field)(item);
|
|
3427
|
-
default:
|
|
3428
|
-
return null;
|
|
3429
|
-
}
|
|
3430
|
-
};
|
|
3431
|
-
const renderCheckboxes = (key, field) => (item) => {
|
|
3432
|
-
const options = item?.items?.enum?.map((e, i) => ({ value: e, title: item?.items?.enumNames?.[i] || '' })) ||
|
|
3433
|
-
[];
|
|
3434
|
-
return (jsxs("div", { children: [item?.title ? (jsx("div", { className: "mb-m", children: jsx(Text, { size: "text-m", font: "font-light", color: "text-secondary-text", children: item.title }) })) : null, jsx(SlideCheckboxGroup, { items: options, multiple: !item?.single, ...field(key) })] }, key));
|
|
3439
|
+
const filterBlocks = (blocksWithProps, filtrationState) => (normalize = identity) => blocksWithProps
|
|
3440
|
+
?.filter(([, content]) => targetMatchPattern(filtrationState, normalize(content) || {}))
|
|
3441
|
+
.map(([block]) => block);
|
|
3442
|
+
|
|
3443
|
+
const useFiltrationForm = (initialFormState, { block, page, normalize = identity, }) => {
|
|
3444
|
+
const blocks = block?.blocks || [];
|
|
3445
|
+
const [filtrationState, { field, reset, update: replaceFiltrationState }] = useForm(initialFormState);
|
|
3446
|
+
const blocksWithProps = useMemo(() => zip(blocks, blocks.map((b) => resolveBlockProps(b.content, page?.fallback))), [blocks, page?.fallback]);
|
|
3447
|
+
const blocksToRender = filtrationState === initialFormState
|
|
3448
|
+
? blocks
|
|
3449
|
+
: filterBlocks(blocksWithProps, filtrationState)(normalize);
|
|
3450
|
+
return [
|
|
3451
|
+
filtrationState,
|
|
3452
|
+
{ blocksToRender, blocksWithProps },
|
|
3453
|
+
{ field, reset, update: replaceFiltrationState },
|
|
3454
|
+
];
|
|
3435
3455
|
};
|
|
3436
3456
|
|
|
3437
3457
|
const isRateRow = (rateRow) => {
|
|
@@ -3440,37 +3460,6 @@
|
|
|
3440
3460
|
|
|
3441
3461
|
const numberRange = (start, end) => Array.from({ length: end - start + 1 }, (_, i) => start + i);
|
|
3442
3462
|
|
|
3443
|
-
const getPeriod = (source, content) => unique((source[content?.sourceBook]?.rateRows || [])
|
|
3444
|
-
.filter(isRateRow)
|
|
3445
|
-
.flatMap((_) => numberRange(_.minMonths, _.maxMonths)));
|
|
3446
|
-
|
|
3447
|
-
const fetchMultitudeJSON = (...urls) => {
|
|
3448
|
-
const fetchPromises = urls.map((url) => fetchJSON(url));
|
|
3449
|
-
return Promise.all(fetchPromises);
|
|
3450
|
-
};
|
|
3451
|
-
|
|
3452
|
-
function zip(firstCol, ...restCols) {
|
|
3453
|
-
return firstCol.map((firstEl, rowIndex) => [firstEl, ...restCols.map((col) => col[rowIndex])]);
|
|
3454
|
-
}
|
|
3455
|
-
|
|
3456
|
-
const getChildSourceBook = (blocks) => blocks?.filter(hasSourceBook).map(({ content: { sourceBook } }) => sourceBook);
|
|
3457
|
-
const hasSourceBook = (block) => Boolean(block && block.content && typeof block.content.sourceBook === 'string');
|
|
3458
|
-
|
|
3459
|
-
function useDepositsPeriods(blocks) {
|
|
3460
|
-
const { dirs = [], source = [] } = useMemo(() => {
|
|
3461
|
-
const sourceBooks = getChildSourceBook(blocks);
|
|
3462
|
-
return { dirs: sourceBooks?.map((url) => `/wcms-resources/${url}.json`), source: sourceBooks };
|
|
3463
|
-
}, [blocks]);
|
|
3464
|
-
const { data = [] } = useAsyncData(dirs, fetchMultitudeJSON);
|
|
3465
|
-
return {
|
|
3466
|
-
source: Object.fromEntries(zip(source, data).filter(([, sourceData]) => Boolean(sourceData))),
|
|
3467
|
-
months: unique(data
|
|
3468
|
-
.flatMap((item) => item?.rateRows || [])
|
|
3469
|
-
.filter(isRateRow)
|
|
3470
|
-
.flatMap((_) => numberRange(_.minMonths, _.maxMonths))).sort((a, b) => a - b) || [],
|
|
3471
|
-
};
|
|
3472
|
-
}
|
|
3473
|
-
|
|
3474
3463
|
const DEFAULT_MIN_SUM = 500;
|
|
3475
3464
|
const DEFAULT_MAX_SUM = 1000000000;
|
|
3476
3465
|
const initialFiltrationState$1 = {
|
|
@@ -3481,11 +3470,13 @@
|
|
|
3481
3470
|
period: 3,
|
|
3482
3471
|
};
|
|
3483
3472
|
const DepositFiltration = UniBlock(({ className, filtrationSchema = {}, resetButton, sumInput, periodInput, ...rest }) => {
|
|
3484
|
-
const {
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3473
|
+
const [, { blocksToRender, blocksWithProps }, { field, reset }] = useFiltrationForm(initialFiltrationState$1, {
|
|
3474
|
+
block: rest.block,
|
|
3475
|
+
page: rest.options?.page,
|
|
3476
|
+
normalize: (content) => ({ ...content, period: getPeriod(content) }),
|
|
3477
|
+
});
|
|
3478
|
+
const rateRows = blocksWithProps.map(([, _]) => _?.paramsSource?.rateRows);
|
|
3479
|
+
const months = getMonths(rateRows);
|
|
3489
3480
|
const Inputs = (jsxs("div", { children: [jsx(CurrencyInput, { label: sumInput?.title, min: DEFAULT_MIN_SUM, max: DEFAULT_MAX_SUM, ...field('sum', {
|
|
3490
3481
|
parse: (min) => ({ min: Number(min), max: DEFAULT_MAX_SUM }),
|
|
3491
3482
|
format: ({ min }) => String(min),
|
|
@@ -3495,12 +3486,19 @@
|
|
|
3495
3486
|
childrenTypes: ['ProductBlock'],
|
|
3496
3487
|
childSchema: (content) => ({
|
|
3497
3488
|
...(content?.filtrationSchema || {}),
|
|
3498
|
-
|
|
3499
|
-
type: '
|
|
3489
|
+
paramsSource: {
|
|
3490
|
+
type: 'object',
|
|
3500
3491
|
title: 'Адрес справочника',
|
|
3501
3492
|
},
|
|
3502
3493
|
}),
|
|
3503
3494
|
});
|
|
3495
|
+
const getPeriod = (content) => unique((content?.paramsSource?.rateRows || [])
|
|
3496
|
+
.filter(isRateRow)
|
|
3497
|
+
.flatMap((_) => numberRange(_.minMonths, _.maxMonths)));
|
|
3498
|
+
const getMonths = (rateRows) => unique(rateRows
|
|
3499
|
+
.flatMap((item) => item || [])
|
|
3500
|
+
.filter(isRateRow)
|
|
3501
|
+
.flatMap((_) => numberRange(_.minMonths, _.maxMonths))).sort((a, b) => a - b) || [];
|
|
3504
3502
|
|
|
3505
3503
|
const renderErrorContent = (error) => {
|
|
3506
3504
|
if (error?.contentType === 'Image' && error?.image) {
|
|
@@ -4052,11 +4050,11 @@
|
|
|
4052
4050
|
stage: [],
|
|
4053
4051
|
};
|
|
4054
4052
|
const MortgageFiltration = UniBlock(({ className, hotFilters, filtrationSchema = {}, resetButton, ...rest }) => {
|
|
4055
|
-
const [filtrationState, { field, reset, update
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
const handleFiltrationStateChange = useCallback((_ = initialFiltrationState) =>
|
|
4053
|
+
const [filtrationState, { blocksToRender }, { field, reset, update }] = useFiltrationForm(initialFiltrationState, {
|
|
4054
|
+
block: rest.block,
|
|
4055
|
+
page: rest.options?.page,
|
|
4056
|
+
});
|
|
4057
|
+
const handleFiltrationStateChange = useCallback((_ = initialFiltrationState) => update(_), []);
|
|
4060
4058
|
const tabsControlProps = useHotFilters({
|
|
4061
4059
|
hotFilters,
|
|
4062
4060
|
filtrationState,
|
|
@@ -5695,7 +5693,7 @@
|
|
|
5695
5693
|
|
|
5696
5694
|
const joinList = (sep) => (list) => list.reduce((acc, el, i) => (acc.length ? acc.concat({ ...sep, key: `sep-${i}` }, el) : [el]), []);
|
|
5697
5695
|
|
|
5698
|
-
const packageVersion = "0.14.
|
|
5696
|
+
const packageVersion = "0.14.198";
|
|
5699
5697
|
|
|
5700
5698
|
exports.Blocks = Blocks;
|
|
5701
5699
|
exports.ContentPage = ContentPage;
|