@redneckz/wildless-cms-uni-blocks 0.8.31 → 0.9.0

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.
Files changed (197) hide show
  1. package/bundle/blocks.schema.json +1 -1
  2. package/bundle/bundle.umd.js +93 -22
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/Filtration/Filtration.d.ts +6 -0
  5. package/bundle/components/Filtration/FiltrationContent.d.ts +78 -0
  6. package/bundle/components/Filtration/FiltrationInner.d.ts +7 -0
  7. package/bundle/components/Filtration/checkShouldRenderBlock.d.ts +1 -0
  8. package/bundle/components/Filtration/renderFormItem.d.ts +4 -0
  9. package/bundle/hooks/useForm.d.ts +12 -0
  10. package/bundle/model/JSXBlock.d.ts +2 -0
  11. package/bundle/ui-kit/ControlProps.d.ts +4 -0
  12. package/bundle/ui-kit/Foldable/DefaultFoldButton.d.ts +1 -0
  13. package/bundle/ui-kit/SlideCheckbox/SlideCheckbox.d.ts +3 -2
  14. package/bundle/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.d.ts +15 -0
  15. package/dist/components/ApplicationForm/renderSlideCheckboxes.js +1 -1
  16. package/dist/components/ApplicationForm/renderSlideCheckboxes.js.map +1 -1
  17. package/dist/components/Blocks.js +2 -0
  18. package/dist/components/Blocks.js.map +1 -1
  19. package/dist/components/Filtration/Filtration.d.ts +6 -0
  20. package/dist/components/Filtration/Filtration.js +17 -0
  21. package/dist/components/Filtration/Filtration.js.map +1 -0
  22. package/dist/components/Filtration/FiltrationContent.d.ts +78 -0
  23. package/dist/components/Filtration/FiltrationContent.js +2 -0
  24. package/dist/components/Filtration/FiltrationContent.js.map +1 -0
  25. package/dist/components/Filtration/FiltrationInner.d.ts +7 -0
  26. package/dist/components/Filtration/FiltrationInner.js +23 -0
  27. package/dist/components/Filtration/FiltrationInner.js.map +1 -0
  28. package/dist/components/Filtration/checkShouldRenderBlock.d.ts +1 -0
  29. package/dist/components/Filtration/checkShouldRenderBlock.js +11 -0
  30. package/dist/components/Filtration/checkShouldRenderBlock.js.map +1 -0
  31. package/dist/components/Filtration/renderFormItem.d.ts +4 -0
  32. package/dist/components/Filtration/renderFormItem.js +21 -0
  33. package/dist/components/Filtration/renderFormItem.js.map +1 -0
  34. package/dist/hooks/useForm.d.ts +12 -0
  35. package/dist/hooks/useForm.js +21 -0
  36. package/dist/hooks/useForm.js.map +1 -0
  37. package/dist/model/JSXBlock.d.ts +2 -0
  38. package/dist/ui-kit/ControlProps.d.ts +4 -0
  39. package/dist/ui-kit/ControlProps.js +2 -0
  40. package/dist/ui-kit/ControlProps.js.map +1 -0
  41. package/dist/ui-kit/Foldable/DefaultFoldButton.d.ts +1 -0
  42. package/dist/ui-kit/Foldable/DefaultFoldButton.js +5 -7
  43. package/dist/ui-kit/Foldable/DefaultFoldButton.js.map +1 -1
  44. package/dist/ui-kit/SlideCheckbox/SlideCheckbox.d.ts +3 -2
  45. package/dist/ui-kit/SlideCheckbox/SlideCheckbox.js +2 -2
  46. package/dist/ui-kit/SlideCheckbox/SlideCheckbox.js.map +1 -1
  47. package/dist/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.d.ts +15 -0
  48. package/dist/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js +19 -0
  49. package/dist/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js.map +1 -0
  50. package/lib/common.css +1 -1
  51. package/lib/components/ApplicationForm/renderSlideCheckboxes.js +1 -1
  52. package/lib/components/ApplicationForm/renderSlideCheckboxes.js.map +1 -1
  53. package/lib/components/Blocks.js +2 -0
  54. package/lib/components/Blocks.js.map +1 -1
  55. package/lib/components/Filtration/Filtration.d.ts +6 -0
  56. package/lib/components/Filtration/Filtration.fixture.d.ts +5 -0
  57. package/lib/components/Filtration/Filtration.js +15 -0
  58. package/lib/components/Filtration/Filtration.js.map +1 -0
  59. package/lib/components/Filtration/FiltrationContent.d.ts +78 -0
  60. package/lib/components/Filtration/FiltrationContent.js +2 -0
  61. package/lib/components/Filtration/FiltrationContent.js.map +1 -0
  62. package/lib/components/Filtration/FiltrationInner.d.ts +7 -0
  63. package/lib/components/Filtration/FiltrationInner.js +21 -0
  64. package/lib/components/Filtration/FiltrationInner.js.map +1 -0
  65. package/lib/components/Filtration/checkShouldRenderBlock.d.ts +1 -0
  66. package/lib/components/Filtration/checkShouldRenderBlock.js +8 -0
  67. package/lib/components/Filtration/checkShouldRenderBlock.js.map +1 -0
  68. package/lib/components/Filtration/renderFormItem.d.ts +4 -0
  69. package/lib/components/Filtration/renderFormItem.js +18 -0
  70. package/lib/components/Filtration/renderFormItem.js.map +1 -0
  71. package/lib/hooks/useForm.d.ts +12 -0
  72. package/lib/hooks/useForm.js +18 -0
  73. package/lib/hooks/useForm.js.map +1 -0
  74. package/lib/model/JSXBlock.d.ts +2 -0
  75. package/lib/ui-kit/ControlProps.d.ts +4 -0
  76. package/lib/ui-kit/ControlProps.js +2 -0
  77. package/lib/ui-kit/ControlProps.js.map +1 -0
  78. package/lib/ui-kit/Foldable/DefaultFoldButton.d.ts +1 -0
  79. package/lib/ui-kit/Foldable/DefaultFoldButton.js +5 -7
  80. package/lib/ui-kit/Foldable/DefaultFoldButton.js.map +1 -1
  81. package/lib/ui-kit/SlideCheckbox/SlideCheckbox.d.ts +3 -2
  82. package/lib/ui-kit/SlideCheckbox/SlideCheckbox.js +2 -2
  83. package/lib/ui-kit/SlideCheckbox/SlideCheckbox.js.map +1 -1
  84. package/lib/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.d.ts +15 -0
  85. package/lib/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js +17 -0
  86. package/lib/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js.map +1 -0
  87. package/mobile/bundle/bundle.umd.js +5 -8
  88. package/mobile/bundle/bundle.umd.min.js +1 -1
  89. package/mobile/bundle/components/Filtration/Filtration.d.ts +6 -0
  90. package/mobile/bundle/components/Filtration/FiltrationContent.d.ts +78 -0
  91. package/mobile/bundle/components/Filtration/FiltrationInner.d.ts +7 -0
  92. package/mobile/bundle/components/Filtration/checkShouldRenderBlock.d.ts +1 -0
  93. package/mobile/bundle/components/Filtration/renderFormItem.d.ts +4 -0
  94. package/mobile/bundle/hooks/useForm.d.ts +12 -0
  95. package/mobile/bundle/model/JSXBlock.d.ts +2 -0
  96. package/mobile/bundle/ui-kit/ControlProps.d.ts +4 -0
  97. package/mobile/bundle/ui-kit/Foldable/DefaultFoldButton.d.ts +1 -0
  98. package/mobile/bundle/ui-kit/SlideCheckbox/SlideCheckbox.d.ts +3 -2
  99. package/mobile/bundle/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.d.ts +15 -0
  100. package/mobile/dist/components/ApplicationForm/renderSlideCheckboxes.js +1 -1
  101. package/mobile/dist/components/ApplicationForm/renderSlideCheckboxes.js.map +1 -1
  102. package/mobile/dist/components/Filtration/Filtration.d.ts +6 -0
  103. package/mobile/dist/components/Filtration/Filtration.js +17 -0
  104. package/mobile/dist/components/Filtration/Filtration.js.map +1 -0
  105. package/mobile/dist/components/Filtration/FiltrationContent.d.ts +78 -0
  106. package/mobile/dist/components/Filtration/FiltrationContent.js +2 -0
  107. package/mobile/dist/components/Filtration/FiltrationContent.js.map +1 -0
  108. package/mobile/dist/components/Filtration/FiltrationInner.d.ts +7 -0
  109. package/mobile/dist/components/Filtration/FiltrationInner.js +23 -0
  110. package/mobile/dist/components/Filtration/FiltrationInner.js.map +1 -0
  111. package/mobile/dist/components/Filtration/checkShouldRenderBlock.d.ts +1 -0
  112. package/mobile/dist/components/Filtration/checkShouldRenderBlock.js +11 -0
  113. package/mobile/dist/components/Filtration/checkShouldRenderBlock.js.map +1 -0
  114. package/mobile/dist/components/Filtration/renderFormItem.d.ts +4 -0
  115. package/mobile/dist/components/Filtration/renderFormItem.js +21 -0
  116. package/mobile/dist/components/Filtration/renderFormItem.js.map +1 -0
  117. package/mobile/dist/hooks/useForm.d.ts +12 -0
  118. package/mobile/dist/hooks/useForm.js +21 -0
  119. package/mobile/dist/hooks/useForm.js.map +1 -0
  120. package/mobile/dist/model/JSXBlock.d.ts +2 -0
  121. package/mobile/dist/ui-kit/ControlProps.d.ts +4 -0
  122. package/mobile/dist/ui-kit/ControlProps.js +2 -0
  123. package/mobile/dist/ui-kit/ControlProps.js.map +1 -0
  124. package/mobile/dist/ui-kit/Foldable/DefaultFoldButton.d.ts +1 -0
  125. package/mobile/dist/ui-kit/Foldable/DefaultFoldButton.js +5 -7
  126. package/mobile/dist/ui-kit/Foldable/DefaultFoldButton.js.map +1 -1
  127. package/mobile/dist/ui-kit/SlideCheckbox/SlideCheckbox.d.ts +3 -2
  128. package/mobile/dist/ui-kit/SlideCheckbox/SlideCheckbox.js +2 -2
  129. package/mobile/dist/ui-kit/SlideCheckbox/SlideCheckbox.js.map +1 -1
  130. package/mobile/dist/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.d.ts +15 -0
  131. package/mobile/dist/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js +19 -0
  132. package/mobile/dist/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js.map +1 -0
  133. package/mobile/lib/components/ApplicationForm/renderSlideCheckboxes.js +1 -1
  134. package/mobile/lib/components/ApplicationForm/renderSlideCheckboxes.js.map +1 -1
  135. package/mobile/lib/components/Filtration/Filtration.d.ts +6 -0
  136. package/mobile/lib/components/Filtration/Filtration.js +15 -0
  137. package/mobile/lib/components/Filtration/Filtration.js.map +1 -0
  138. package/mobile/lib/components/Filtration/FiltrationContent.d.ts +78 -0
  139. package/mobile/lib/components/Filtration/FiltrationContent.js +2 -0
  140. package/mobile/lib/components/Filtration/FiltrationContent.js.map +1 -0
  141. package/mobile/lib/components/Filtration/FiltrationInner.d.ts +7 -0
  142. package/mobile/lib/components/Filtration/FiltrationInner.js +21 -0
  143. package/mobile/lib/components/Filtration/FiltrationInner.js.map +1 -0
  144. package/mobile/lib/components/Filtration/checkShouldRenderBlock.d.ts +1 -0
  145. package/mobile/lib/components/Filtration/checkShouldRenderBlock.js +8 -0
  146. package/mobile/lib/components/Filtration/checkShouldRenderBlock.js.map +1 -0
  147. package/mobile/lib/components/Filtration/renderFormItem.d.ts +4 -0
  148. package/mobile/lib/components/Filtration/renderFormItem.js +18 -0
  149. package/mobile/lib/components/Filtration/renderFormItem.js.map +1 -0
  150. package/mobile/lib/hooks/useForm.d.ts +12 -0
  151. package/mobile/lib/hooks/useForm.js +18 -0
  152. package/mobile/lib/hooks/useForm.js.map +1 -0
  153. package/mobile/lib/model/JSXBlock.d.ts +2 -0
  154. package/mobile/lib/ui-kit/ControlProps.d.ts +4 -0
  155. package/mobile/lib/ui-kit/ControlProps.js +2 -0
  156. package/mobile/lib/ui-kit/ControlProps.js.map +1 -0
  157. package/mobile/lib/ui-kit/Foldable/DefaultFoldButton.d.ts +1 -0
  158. package/mobile/lib/ui-kit/Foldable/DefaultFoldButton.js +5 -7
  159. package/mobile/lib/ui-kit/Foldable/DefaultFoldButton.js.map +1 -1
  160. package/mobile/lib/ui-kit/SlideCheckbox/SlideCheckbox.d.ts +3 -2
  161. package/mobile/lib/ui-kit/SlideCheckbox/SlideCheckbox.js +2 -2
  162. package/mobile/lib/ui-kit/SlideCheckbox/SlideCheckbox.js.map +1 -1
  163. package/mobile/lib/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.d.ts +15 -0
  164. package/mobile/lib/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js +17 -0
  165. package/mobile/lib/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js.map +1 -0
  166. package/mobile/src/components/ApplicationForm/renderSlideCheckboxes.tsx +4 -4
  167. package/mobile/src/components/Filtration/Filtration.example.json +37 -0
  168. package/mobile/src/components/Filtration/Filtration.tsx +41 -0
  169. package/mobile/src/components/Filtration/Filtration.ui.json +1 -0
  170. package/mobile/src/components/Filtration/FiltrationContent.ts +87 -0
  171. package/mobile/src/components/Filtration/FiltrationInner.tsx +67 -0
  172. package/mobile/src/components/Filtration/checkShouldRenderBlock.ts +18 -0
  173. package/mobile/src/components/Filtration/renderFormItem.tsx +36 -0
  174. package/mobile/src/hooks/useForm.ts +29 -0
  175. package/mobile/src/model/JSXBlock.ts +2 -0
  176. package/mobile/src/ui-kit/ControlProps.ts +4 -0
  177. package/mobile/src/ui-kit/Foldable/DefaultFoldButton.tsx +10 -4
  178. package/mobile/src/ui-kit/SlideCheckbox/SlideCheckbox.tsx +26 -23
  179. package/mobile/src/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.tsx +44 -0
  180. package/package.json +2 -1
  181. package/src/components/ApplicationForm/renderSlideCheckboxes.tsx +4 -4
  182. package/src/components/Blocks.ts +2 -0
  183. package/src/components/Filtration/Filtration.example.json +37 -0
  184. package/src/components/Filtration/Filtration.fixture.tsx +147 -0
  185. package/src/components/Filtration/Filtration.tsx +41 -0
  186. package/src/components/Filtration/Filtration.ui.json +1 -0
  187. package/src/components/Filtration/FiltrationContent.ts +87 -0
  188. package/src/components/Filtration/FiltrationInner.tsx +67 -0
  189. package/src/components/Filtration/checkShouldRenderBlock.ts +18 -0
  190. package/src/components/Filtration/renderFormItem.tsx +36 -0
  191. package/src/hooks/useForm.ts +29 -0
  192. package/src/model/JSXBlock.ts +2 -0
  193. package/src/ui-kit/ControlProps.ts +4 -0
  194. package/src/ui-kit/Foldable/DefaultFoldButton.tsx +10 -4
  195. package/src/ui-kit/SlideCheckbox/SlideCheckbox.fixture.tsx +1 -1
  196. package/src/ui-kit/SlideCheckbox/SlideCheckbox.tsx +26 -23
  197. package/src/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.tsx +44 -0
@@ -763,9 +763,9 @@
763
763
 
764
764
  const renderSelects = ({ acquiringType, regions, region, handleChange }) => (jsxs("div", { className: "flex justify-between gap-5 mb-7", children: [jsx("div", { className: "w-1/2", children: jsx(WrapperSelect$1, { data: ACQUIRING_TYPES, fieldValue: "name", fieldLabel: "name", selected: acquiringType, setSelected: (value) => handleChange({ acquiringType: value }), label: "\u0412\u0438\u0434 \u044D\u043A\u0432\u0430\u0439\u0440\u0438\u043D\u0433\u0430", placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u044D\u043A\u0432\u0430\u0439\u0440\u0438\u043D\u0433" }) }), jsx("div", { className: "w-1/2", children: jsx(WrapperSelect$1, { data: regions, fieldValue: "code", fieldLabel: "name", selected: region, setSelected: (value) => handleChange({ region: value }), label: "\u0410\u0434\u0440\u0435\u0441", placeholder: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0430\u0434\u0440\u0435\u0441" }) })] }));
765
765
 
766
- const SlideCheckbox = JSX(({ checked, text, onClick }) => (jsxs("div", { role: "checkbox", "aria-checked": checked, className: "flex justify-start items-center w-full cursor-pointer mb-4", onClick: () => onClick && onClick(), children: [jsx("div", { className: `relative duration-300 w-9 h-5 mr-3 rounded rounded-2xl ${checked ? 'bg-primary-main' : 'bg-main-divider'}`, children: jsx("div", { className: `absolute opacity-80 duration-500 top-0.5 w-4 h-4 bg-white rounded rounded-full ${checked ? 'left-[50%]' : 'left-[5%]'}` }) }), jsx("div", { children: jsx(Text, { size: "text-m", font: "font-light", color: "text-primary-text", children: text }) })] })));
766
+ const SlideCheckbox = JSX(({ value = false, text, type = 'checkbox', onChange }) => (jsxs("div", { role: type, "aria-checked": value, className: "flex justify-start items-center w-full cursor-pointer mb-4", onClick: () => onChange && onChange(!value), children: [jsx("div", { className: `relative flex-shrink-0 duration-300 w-9 h-5 mr-3 rounded-2xl ${value ? 'bg-primary-main' : 'bg-main-divider'}`, children: jsx("div", { className: `absolute opacity-80 duration-500 top-0.5 w-4 h-4 bg-white rounded-full ${value ? 'left-[50%]' : 'left-[5%]'}` }) }), jsx("div", { children: jsx(Text, { size: "text-m", font: "font-light", color: "text-primary-text", children: text }) })] })));
767
767
 
768
- const renderSlideCheckboxes = ({ onlineСheckout, posTerminal, handleChange, }) => (jsxs("div", { className: "mb-5", children: [jsx(SlideCheckbox, { checked: onlineСheckout, text: "\u0425\u043E\u0447\u0443 \u043A\u0443\u043F\u0438\u0442\u044C \u043E\u043D\u043B\u0430\u0439\u043D-\u043A\u0430\u0441\u0441\u0443", onClick: () => handleChange({ onlineСheckout: !onlineСheckout }) }), jsx(SlideCheckbox, { checked: posTerminal, text: "\u0425\u043E\u0447\u0443 \u043A\u0443\u043F\u0438\u0442\u044C POS-\u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B", onClick: () => handleChange({ posTerminal: !posTerminal }) })] }));
768
+ const renderSlideCheckboxes = ({ onlineСheckout, posTerminal, handleChange, }) => (jsxs("div", { className: "mb-5", children: [jsx(SlideCheckbox, { value: onlineСheckout, text: "\u0425\u043E\u0447\u0443 \u043A\u0443\u043F\u0438\u0442\u044C \u043E\u043D\u043B\u0430\u0439\u043D-\u043A\u0430\u0441\u0441\u0443", onChange: () => handleChange({ onlineСheckout: !onlineСheckout }) }), jsx(SlideCheckbox, { value: posTerminal, text: "\u0425\u043E\u0447\u0443 \u043A\u0443\u043F\u0438\u0442\u044C POS-\u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B", onChange: () => handleChange({ posTerminal: !posTerminal }) })] }));
769
769
 
770
770
  const renderSubmitButton = (button, className) => {
771
771
  const buttonStyle = getRegularButtonClasses({
@@ -2524,6 +2524,95 @@
2524
2524
  return currencies?.filter((_) => _?.currency?.id === 1 || _?.currency?.id === 2) || [];
2525
2525
  };
2526
2526
 
2527
+ const useForm = (initialState = {}) => {
2528
+ const [formState, setFormState] = useState(initialState);
2529
+ const handlersMap = useRef({});
2530
+ const register = (fieldName) => {
2531
+ if (!handlersMap.current) {
2532
+ return {};
2533
+ }
2534
+ const handler = (value) => {
2535
+ setFormState((prev) => ({ ...prev, [fieldName]: value }));
2536
+ };
2537
+ handlersMap.current[fieldName] ||= handler;
2538
+ return { value: formState?.[fieldName], onChange: handlersMap.current[fieldName] };
2539
+ };
2540
+ const resetForm = useCallback(() => setFormState({}), []);
2541
+ return { formState, register, resetForm };
2542
+ };
2543
+
2544
+ const DefaultFoldButton = JSX(({ className = '', label, icon, dataTheme = '', disabled = false, onClick }) => {
2545
+ const STATE_STYLE = 'hover:bg-primary-hover focus:border-primary-text active:bg-primary-active outline-none';
2546
+ const DIMENSIONS_STYLE = 'flex justify-center w-full px-0 py-5';
2547
+ return (jsxs("button", { className: style('border border-transparent bg-primary-main font-sans text-white cursor-pointer', STATE_STYLE, DIMENSIONS_STYLE, disabled
2548
+ ? 'bg-main-divider text-main-disabled cursor-not-allowed hover:bg-main-divider active:bg-main-divider'
2549
+ : '', className), onClick: onClick, disabled: disabled, "data-theme": dataTheme, children: [jsx("span", { className: "text-h4 pr-3", children: label }), icon ? (jsx(ImgInner, { image: {
2550
+ icon,
2551
+ iconVersion: 'white',
2552
+ }, className: "flex-shrink-0 my-auto", width: "20", height: "20", asSVG: true })) : null] }));
2553
+ });
2554
+ const renderDefaultFoldButton = ({ isUnfolded, onToggle }) => {
2555
+ const labels = ['Развернуть', 'Скрыть'];
2556
+ const icons = ['ArrowDownIcon', 'ArrowUpIcon'];
2557
+ return (jsx(DefaultFoldButton, { icon: icons[Number(isUnfolded)], label: labels[Number(isUnfolded)], onClick: onToggle }));
2558
+ };
2559
+
2560
+ const isSingularFieldMatch = (key, pattern) => (target) => pattern[key] === undefined || pattern[key] === target[key];
2561
+ const isMultipleFieldMatch = (key, pattern) => (target) => pattern[key] === undefined || pattern[key]?.every((_) => target[key]?.includes(_));
2562
+ const checkShouldRenderBlock = (pattern, target) => Object.entries(pattern)
2563
+ .map(([key, subPattern]) => Array.isArray(subPattern)
2564
+ ? isMultipleFieldMatch(key, pattern)
2565
+ : isSingularFieldMatch(key, pattern))
2566
+ .every((predicate) => predicate(target));
2567
+
2568
+ const ICONS = ['ArrowDownIcon', 'ArrowUpIcon'];
2569
+ const resultsGridStyle = 'grid grid-cols-12 gap-1 border-box';
2570
+ const FiltrationInner = JSX(({ label = '', filtrationState = {}, topItemsCount = 0, block, ...rest }) => {
2571
+ const blocksToRender = block?.blocks?.filter((b) => checkShouldRenderBlock(filtrationState, b.content || {})) || [];
2572
+ const [visibleBlocks, hiddenBlocks] = topItemsCount > 0
2573
+ ? [blocksToRender.slice(0, topItemsCount), blocksToRender.slice(topItemsCount)]
2574
+ : [blocksToRender, []];
2575
+ return (jsxs("div", { children: [jsx("div", { className: style(blocksToRender.length ? 'hidden' : ''), children: jsx(ErrorBlock, { error: { errorContentType: 'Image' }, title: "\u041D\u0435\u0442 \u043F\u043E\u0434\u0445\u043E\u0434\u044F\u0449\u0435\u0439 \u0438\u043F\u043E\u0442\u0435\u0447\u043D\u043E\u0439 \u043F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u044B", subtitle: "\u041F\u043E\u043F\u0440\u043E\u0431\u0443\u0439\u0442\u0435 \u043E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0444\u0438\u043B\u044C\u0442\u0440\u044B" }) }), jsxs("div", { className: style(blocksToRender.length ? '' : 'hidden'), children: [jsx("div", { className: resultsGridStyle, children: renderBlocksList(visibleBlocks, { ...rest.options, parent: block }) }), jsx(Foldable, { renderFoldableSection: ({ isUnfolded }) => {
2576
+ return (jsx(FoldableSection, { className: resultsGridStyle, isUnfolded: isUnfolded, children: renderBlocksList(hiddenBlocks, { ...rest.options, parent: block }) }));
2577
+ }, renderFoldButton: ({ isUnfolded, onToggle }) => (jsx(DefaultFoldButton, { className: "mt-11", disabled: topItemsCount > hiddenBlocks.length, label: label, icon: ICONS[Number(isUnfolded)], dataTheme: rest.options?.page?.colorPalette, onClick: onToggle })) })] })] }));
2578
+ });
2579
+
2580
+ const SlideCheckboxGroup = JSX(({ value, onChange, items = [], multiple }) => {
2581
+ const handleChange = (newValue) => {
2582
+ if (multiple) {
2583
+ const hasAlready = value?.includes(newValue);
2584
+ onChange &&
2585
+ onChange(hasAlready ? value?.filter((v) => v !== newValue) : [...(value || []), newValue]);
2586
+ }
2587
+ else {
2588
+ onChange && onChange(value === newValue ? undefined : newValue);
2589
+ }
2590
+ };
2591
+ 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)));
2592
+ });
2593
+
2594
+ const renderFormItem = (filtrationSchema, register) => (key) => {
2595
+ const item = filtrationSchema[key];
2596
+ const type = item?.type;
2597
+ switch (type) {
2598
+ case 'string':
2599
+ return renderRadioButtons(key, register)(item);
2600
+ default:
2601
+ return null;
2602
+ }
2603
+ };
2604
+ const renderRadioButtons = (key, register) => (item) => {
2605
+ const options = item?.enum?.map((e, i) => ({ value: e, title: item?.enumNames?.[i] || '' })) || [];
2606
+ return (jsxs("div", { role: "radiogroup", children: [item?.title ? (jsx("div", { className: "mb-4", children: jsx(Text, { size: "text-m", font: "font-light", color: "text-secondary-text", children: item.title }) })) : null, jsx(SlideCheckboxGroup, { items: options, multiple: false, ...register(key) })] }, key));
2607
+ };
2608
+
2609
+ const Filtration = JSX(({ className, filtrationSchema = {}, resetButton, ...rest }) => {
2610
+ const { formState, register, resetForm } = useForm();
2611
+ return (jsxs(BlockWrapper, { className: style('p-9', className), ...rest, children: [jsxs("form", { className: "flex justify-between", children: [jsx("div", { className: "flex gap-11", children: Object.keys(filtrationSchema).map(renderFormItem(filtrationSchema, register)) }), resetButton ? (jsx("div", { children: jsx(Button, { className: "w-72", text: resetButton.text, version: resetButton.buttonVersion, onClick: resetForm }) })) : null] }), jsx(FiltrationInner, { filtrationState: formState, ...rest })] }));
2612
+ });
2613
+ Filtration.childrenTypes = ['ProductTile'];
2614
+ Filtration.childSchema = (content) => content?.filtrationSchema || {};
2615
+
2527
2616
  function useSWRResource(filename, fallback = {}) {
2528
2617
  const { data } = useAsyncData(`/wcms-resources/${filename}.json`, fetchJSONUnsafe, {
2529
2618
  fallback,
@@ -3920,25 +4009,6 @@
3920
4009
  return (jsx(BlockWrapper, { ...rest, children: jsx(RichText, { __html: __html }) }));
3921
4010
  });
3922
4011
 
3923
- const DefaultFoldButton = JSX(({ className = '', label, icon, dataTheme = '', onClick }) => {
3924
- const STATE_STYLE = 'hover:bg-primary-hover focus:border-primary-text active:bg-primary-active outline-none';
3925
- const DIMENSIONS_STYLE = 'flex justify-center w-full px-0 py-5';
3926
- return (jsxs("button", { className: [
3927
- 'border border-transparent bg-primary-main font-sans text-white cursor-pointer',
3928
- STATE_STYLE,
3929
- DIMENSIONS_STYLE,
3930
- className,
3931
- ].join(' '), "data-theme": dataTheme, onClick: onClick, children: [jsx("span", { className: "text-h4 pr-3", children: label }), icon ? (jsx(ImgInner, { image: {
3932
- icon,
3933
- iconVersion: 'white',
3934
- }, className: "flex-shrink-0 my-auto", width: "20", height: "20", asSVG: true })) : null] }));
3935
- });
3936
- const renderDefaultFoldButton = ({ isUnfolded, onToggle }) => {
3937
- const labels = ['Развернуть', 'Скрыть'];
3938
- const icons = ['ArrowDownIcon', 'ArrowUpIcon'];
3939
- return (jsx(DefaultFoldButton, { icon: icons[Number(isUnfolded)], label: labels[Number(isUnfolded)], onClick: onToggle }));
3940
- };
3941
-
3942
4012
  const RollupItem = JSX(({ className = '', label = 'Развернуть', isExpanded, isFoldButtonOnTop = true, version = 'primary', ...rest }) => (jsx(BlockWrapper, { className: `w-full border-0 border-b border-solid border-main-divider last:border-b-0 ${className}`, tag: "div", version: "transparent", ...rest, children: jsx(Foldable, { isFoldButtonOnTop: isFoldButtonOnTop, unfoldedByDefault: isExpanded, renderFoldableSection: ({ isUnfolded }) => (jsx(FoldableSection, { className: `grid grid-cols-12 gap-5 [&>*]:p-0`, isUnfolded: isUnfolded, children: renderChildren(rest) })), renderFoldButton: ({ isUnfolded, onToggle }) => renderFoldButton({ version, label, isUnfolded, onToggle }) }) })));
3943
4013
  RollupItem.childrenTypes = {
3944
4014
  exclude: ['RollupItem', 'Accordion', 'OtherProducts'],
@@ -4583,6 +4653,7 @@
4583
4653
  ContactsBlock,
4584
4654
  ErrorBlock,
4585
4655
  ExchangeRateTile,
4656
+ Filtration,
4586
4657
  Footer,
4587
4658
  GracePeriod,
4588
4659
  Header,
@@ -4743,7 +4814,7 @@
4743
4814
  return (jsx("div", { className: "flex items-end absolute bottom-0 right-0 h-full pointer-events-none", children: jsx(LikeControl, { className: "rounded-tl-lg sticky bottom-0 pointer-events-auto" }) }));
4744
4815
  }
4745
4816
 
4746
- const packageVersion = "0.8.31";
4817
+ const packageVersion = "0.9.0";
4747
4818
 
4748
4819
  exports.Blocks = Blocks;
4749
4820
  exports.ContentPage = ContentPage;