@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.
- package/bundle/blocks.schema.json +1 -1
- package/bundle/bundle.umd.js +93 -22
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/Filtration/Filtration.d.ts +6 -0
- package/bundle/components/Filtration/FiltrationContent.d.ts +78 -0
- package/bundle/components/Filtration/FiltrationInner.d.ts +7 -0
- package/bundle/components/Filtration/checkShouldRenderBlock.d.ts +1 -0
- package/bundle/components/Filtration/renderFormItem.d.ts +4 -0
- package/bundle/hooks/useForm.d.ts +12 -0
- package/bundle/model/JSXBlock.d.ts +2 -0
- package/bundle/ui-kit/ControlProps.d.ts +4 -0
- package/bundle/ui-kit/Foldable/DefaultFoldButton.d.ts +1 -0
- package/bundle/ui-kit/SlideCheckbox/SlideCheckbox.d.ts +3 -2
- package/bundle/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.d.ts +15 -0
- package/dist/components/ApplicationForm/renderSlideCheckboxes.js +1 -1
- package/dist/components/ApplicationForm/renderSlideCheckboxes.js.map +1 -1
- package/dist/components/Blocks.js +2 -0
- package/dist/components/Blocks.js.map +1 -1
- package/dist/components/Filtration/Filtration.d.ts +6 -0
- package/dist/components/Filtration/Filtration.js +17 -0
- package/dist/components/Filtration/Filtration.js.map +1 -0
- package/dist/components/Filtration/FiltrationContent.d.ts +78 -0
- package/dist/components/Filtration/FiltrationContent.js +2 -0
- package/dist/components/Filtration/FiltrationContent.js.map +1 -0
- package/dist/components/Filtration/FiltrationInner.d.ts +7 -0
- package/dist/components/Filtration/FiltrationInner.js +23 -0
- package/dist/components/Filtration/FiltrationInner.js.map +1 -0
- package/dist/components/Filtration/checkShouldRenderBlock.d.ts +1 -0
- package/dist/components/Filtration/checkShouldRenderBlock.js +11 -0
- package/dist/components/Filtration/checkShouldRenderBlock.js.map +1 -0
- package/dist/components/Filtration/renderFormItem.d.ts +4 -0
- package/dist/components/Filtration/renderFormItem.js +21 -0
- package/dist/components/Filtration/renderFormItem.js.map +1 -0
- package/dist/hooks/useForm.d.ts +12 -0
- package/dist/hooks/useForm.js +21 -0
- package/dist/hooks/useForm.js.map +1 -0
- package/dist/model/JSXBlock.d.ts +2 -0
- package/dist/ui-kit/ControlProps.d.ts +4 -0
- package/dist/ui-kit/ControlProps.js +2 -0
- package/dist/ui-kit/ControlProps.js.map +1 -0
- package/dist/ui-kit/Foldable/DefaultFoldButton.d.ts +1 -0
- package/dist/ui-kit/Foldable/DefaultFoldButton.js +5 -7
- package/dist/ui-kit/Foldable/DefaultFoldButton.js.map +1 -1
- package/dist/ui-kit/SlideCheckbox/SlideCheckbox.d.ts +3 -2
- package/dist/ui-kit/SlideCheckbox/SlideCheckbox.js +2 -2
- package/dist/ui-kit/SlideCheckbox/SlideCheckbox.js.map +1 -1
- package/dist/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.d.ts +15 -0
- package/dist/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js +19 -0
- package/dist/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js.map +1 -0
- package/lib/common.css +1 -1
- package/lib/components/ApplicationForm/renderSlideCheckboxes.js +1 -1
- package/lib/components/ApplicationForm/renderSlideCheckboxes.js.map +1 -1
- package/lib/components/Blocks.js +2 -0
- package/lib/components/Blocks.js.map +1 -1
- package/lib/components/Filtration/Filtration.d.ts +6 -0
- package/lib/components/Filtration/Filtration.fixture.d.ts +5 -0
- package/lib/components/Filtration/Filtration.js +15 -0
- package/lib/components/Filtration/Filtration.js.map +1 -0
- package/lib/components/Filtration/FiltrationContent.d.ts +78 -0
- package/lib/components/Filtration/FiltrationContent.js +2 -0
- package/lib/components/Filtration/FiltrationContent.js.map +1 -0
- package/lib/components/Filtration/FiltrationInner.d.ts +7 -0
- package/lib/components/Filtration/FiltrationInner.js +21 -0
- package/lib/components/Filtration/FiltrationInner.js.map +1 -0
- package/lib/components/Filtration/checkShouldRenderBlock.d.ts +1 -0
- package/lib/components/Filtration/checkShouldRenderBlock.js +8 -0
- package/lib/components/Filtration/checkShouldRenderBlock.js.map +1 -0
- package/lib/components/Filtration/renderFormItem.d.ts +4 -0
- package/lib/components/Filtration/renderFormItem.js +18 -0
- package/lib/components/Filtration/renderFormItem.js.map +1 -0
- package/lib/hooks/useForm.d.ts +12 -0
- package/lib/hooks/useForm.js +18 -0
- package/lib/hooks/useForm.js.map +1 -0
- package/lib/model/JSXBlock.d.ts +2 -0
- package/lib/ui-kit/ControlProps.d.ts +4 -0
- package/lib/ui-kit/ControlProps.js +2 -0
- package/lib/ui-kit/ControlProps.js.map +1 -0
- package/lib/ui-kit/Foldable/DefaultFoldButton.d.ts +1 -0
- package/lib/ui-kit/Foldable/DefaultFoldButton.js +5 -7
- package/lib/ui-kit/Foldable/DefaultFoldButton.js.map +1 -1
- package/lib/ui-kit/SlideCheckbox/SlideCheckbox.d.ts +3 -2
- package/lib/ui-kit/SlideCheckbox/SlideCheckbox.js +2 -2
- package/lib/ui-kit/SlideCheckbox/SlideCheckbox.js.map +1 -1
- package/lib/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.d.ts +15 -0
- package/lib/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js +17 -0
- package/lib/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js.map +1 -0
- package/mobile/bundle/bundle.umd.js +5 -8
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/Filtration/Filtration.d.ts +6 -0
- package/mobile/bundle/components/Filtration/FiltrationContent.d.ts +78 -0
- package/mobile/bundle/components/Filtration/FiltrationInner.d.ts +7 -0
- package/mobile/bundle/components/Filtration/checkShouldRenderBlock.d.ts +1 -0
- package/mobile/bundle/components/Filtration/renderFormItem.d.ts +4 -0
- package/mobile/bundle/hooks/useForm.d.ts +12 -0
- package/mobile/bundle/model/JSXBlock.d.ts +2 -0
- package/mobile/bundle/ui-kit/ControlProps.d.ts +4 -0
- package/mobile/bundle/ui-kit/Foldable/DefaultFoldButton.d.ts +1 -0
- package/mobile/bundle/ui-kit/SlideCheckbox/SlideCheckbox.d.ts +3 -2
- package/mobile/bundle/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.d.ts +15 -0
- package/mobile/dist/components/ApplicationForm/renderSlideCheckboxes.js +1 -1
- package/mobile/dist/components/ApplicationForm/renderSlideCheckboxes.js.map +1 -1
- package/mobile/dist/components/Filtration/Filtration.d.ts +6 -0
- package/mobile/dist/components/Filtration/Filtration.js +17 -0
- package/mobile/dist/components/Filtration/Filtration.js.map +1 -0
- package/mobile/dist/components/Filtration/FiltrationContent.d.ts +78 -0
- package/mobile/dist/components/Filtration/FiltrationContent.js +2 -0
- package/mobile/dist/components/Filtration/FiltrationContent.js.map +1 -0
- package/mobile/dist/components/Filtration/FiltrationInner.d.ts +7 -0
- package/mobile/dist/components/Filtration/FiltrationInner.js +23 -0
- package/mobile/dist/components/Filtration/FiltrationInner.js.map +1 -0
- package/mobile/dist/components/Filtration/checkShouldRenderBlock.d.ts +1 -0
- package/mobile/dist/components/Filtration/checkShouldRenderBlock.js +11 -0
- package/mobile/dist/components/Filtration/checkShouldRenderBlock.js.map +1 -0
- package/mobile/dist/components/Filtration/renderFormItem.d.ts +4 -0
- package/mobile/dist/components/Filtration/renderFormItem.js +21 -0
- package/mobile/dist/components/Filtration/renderFormItem.js.map +1 -0
- package/mobile/dist/hooks/useForm.d.ts +12 -0
- package/mobile/dist/hooks/useForm.js +21 -0
- package/mobile/dist/hooks/useForm.js.map +1 -0
- package/mobile/dist/model/JSXBlock.d.ts +2 -0
- package/mobile/dist/ui-kit/ControlProps.d.ts +4 -0
- package/mobile/dist/ui-kit/ControlProps.js +2 -0
- package/mobile/dist/ui-kit/ControlProps.js.map +1 -0
- package/mobile/dist/ui-kit/Foldable/DefaultFoldButton.d.ts +1 -0
- package/mobile/dist/ui-kit/Foldable/DefaultFoldButton.js +5 -7
- package/mobile/dist/ui-kit/Foldable/DefaultFoldButton.js.map +1 -1
- package/mobile/dist/ui-kit/SlideCheckbox/SlideCheckbox.d.ts +3 -2
- package/mobile/dist/ui-kit/SlideCheckbox/SlideCheckbox.js +2 -2
- package/mobile/dist/ui-kit/SlideCheckbox/SlideCheckbox.js.map +1 -1
- package/mobile/dist/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.d.ts +15 -0
- package/mobile/dist/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js +19 -0
- package/mobile/dist/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js.map +1 -0
- package/mobile/lib/components/ApplicationForm/renderSlideCheckboxes.js +1 -1
- package/mobile/lib/components/ApplicationForm/renderSlideCheckboxes.js.map +1 -1
- package/mobile/lib/components/Filtration/Filtration.d.ts +6 -0
- package/mobile/lib/components/Filtration/Filtration.js +15 -0
- package/mobile/lib/components/Filtration/Filtration.js.map +1 -0
- package/mobile/lib/components/Filtration/FiltrationContent.d.ts +78 -0
- package/mobile/lib/components/Filtration/FiltrationContent.js +2 -0
- package/mobile/lib/components/Filtration/FiltrationContent.js.map +1 -0
- package/mobile/lib/components/Filtration/FiltrationInner.d.ts +7 -0
- package/mobile/lib/components/Filtration/FiltrationInner.js +21 -0
- package/mobile/lib/components/Filtration/FiltrationInner.js.map +1 -0
- package/mobile/lib/components/Filtration/checkShouldRenderBlock.d.ts +1 -0
- package/mobile/lib/components/Filtration/checkShouldRenderBlock.js +8 -0
- package/mobile/lib/components/Filtration/checkShouldRenderBlock.js.map +1 -0
- package/mobile/lib/components/Filtration/renderFormItem.d.ts +4 -0
- package/mobile/lib/components/Filtration/renderFormItem.js +18 -0
- package/mobile/lib/components/Filtration/renderFormItem.js.map +1 -0
- package/mobile/lib/hooks/useForm.d.ts +12 -0
- package/mobile/lib/hooks/useForm.js +18 -0
- package/mobile/lib/hooks/useForm.js.map +1 -0
- package/mobile/lib/model/JSXBlock.d.ts +2 -0
- package/mobile/lib/ui-kit/ControlProps.d.ts +4 -0
- package/mobile/lib/ui-kit/ControlProps.js +2 -0
- package/mobile/lib/ui-kit/ControlProps.js.map +1 -0
- package/mobile/lib/ui-kit/Foldable/DefaultFoldButton.d.ts +1 -0
- package/mobile/lib/ui-kit/Foldable/DefaultFoldButton.js +5 -7
- package/mobile/lib/ui-kit/Foldable/DefaultFoldButton.js.map +1 -1
- package/mobile/lib/ui-kit/SlideCheckbox/SlideCheckbox.d.ts +3 -2
- package/mobile/lib/ui-kit/SlideCheckbox/SlideCheckbox.js +2 -2
- package/mobile/lib/ui-kit/SlideCheckbox/SlideCheckbox.js.map +1 -1
- package/mobile/lib/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.d.ts +15 -0
- package/mobile/lib/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js +17 -0
- package/mobile/lib/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js.map +1 -0
- package/mobile/src/components/ApplicationForm/renderSlideCheckboxes.tsx +4 -4
- package/mobile/src/components/Filtration/Filtration.example.json +37 -0
- package/mobile/src/components/Filtration/Filtration.tsx +41 -0
- package/mobile/src/components/Filtration/Filtration.ui.json +1 -0
- package/mobile/src/components/Filtration/FiltrationContent.ts +87 -0
- package/mobile/src/components/Filtration/FiltrationInner.tsx +67 -0
- package/mobile/src/components/Filtration/checkShouldRenderBlock.ts +18 -0
- package/mobile/src/components/Filtration/renderFormItem.tsx +36 -0
- package/mobile/src/hooks/useForm.ts +29 -0
- package/mobile/src/model/JSXBlock.ts +2 -0
- package/mobile/src/ui-kit/ControlProps.ts +4 -0
- package/mobile/src/ui-kit/Foldable/DefaultFoldButton.tsx +10 -4
- package/mobile/src/ui-kit/SlideCheckbox/SlideCheckbox.tsx +26 -23
- package/mobile/src/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.tsx +44 -0
- package/package.json +2 -1
- package/src/components/ApplicationForm/renderSlideCheckboxes.tsx +4 -4
- package/src/components/Blocks.ts +2 -0
- package/src/components/Filtration/Filtration.example.json +37 -0
- package/src/components/Filtration/Filtration.fixture.tsx +147 -0
- package/src/components/Filtration/Filtration.tsx +41 -0
- package/src/components/Filtration/Filtration.ui.json +1 -0
- package/src/components/Filtration/FiltrationContent.ts +87 -0
- package/src/components/Filtration/FiltrationInner.tsx +67 -0
- package/src/components/Filtration/checkShouldRenderBlock.ts +18 -0
- package/src/components/Filtration/renderFormItem.tsx +36 -0
- package/src/hooks/useForm.ts +29 -0
- package/src/model/JSXBlock.ts +2 -0
- package/src/ui-kit/ControlProps.ts +4 -0
- package/src/ui-kit/Foldable/DefaultFoldButton.tsx +10 -4
- package/src/ui-kit/SlideCheckbox/SlideCheckbox.fixture.tsx +1 -1
- package/src/ui-kit/SlideCheckbox/SlideCheckbox.tsx +26 -23
- package/src/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.tsx +44 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@redneckz/uni-jsx/jsx-runtime";
|
|
2
|
+
import { SlideCheckboxGroup } from '../../ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.js';
|
|
3
|
+
import { Text } from '../../ui-kit/Text/Text.js';
|
|
4
|
+
export const renderFormItem = (filtrationSchema, register) => (key) => {
|
|
5
|
+
const item = filtrationSchema[key];
|
|
6
|
+
const type = item?.type;
|
|
7
|
+
switch (type) {
|
|
8
|
+
case 'string':
|
|
9
|
+
return renderRadioButtons(key, register)(item);
|
|
10
|
+
default:
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const renderRadioButtons = (key, register) => (item) => {
|
|
15
|
+
const options = item?.enum?.map((e, i) => ({ value: e, title: item?.enumNames?.[i] || '' })) || [];
|
|
16
|
+
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));
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=renderFormItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderFormItem.js","sourceRoot":"","sources":["../../../src/components/Filtration/renderFormItem.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAG9C,MAAM,CAAC,MAAM,cAAc,GACzB,CAAC,gBAAkC,EAAE,QAA+B,EAAE,EAAE,CAAC,CAAC,GAAW,EAAE,EAAE;IACvF,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAoC,CAAC,CAAC;IACpE,MAAM,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC;IAExB,QAAQ,IAAI,EAAE;QACZ,KAAK,QAAQ;YACX,OAAO,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;QACjD;YACE,OAAO,IAAI,CAAC;KACf;AACH,CAAC,CAAC;AAEJ,MAAM,kBAAkB,GACtB,CAAC,GAAW,EAAE,QAA+B,EAAE,EAAE,CAAC,CAAC,IAAiB,EAAE,EAAE;IACtE,MAAM,OAAO,GACX,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAErF,OAAO,CACL,eAAK,IAAI,EAAC,YAAY,aACnB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CACb,cAAK,SAAS,EAAC,MAAM,YACnB,KAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,YAAY,EAAC,KAAK,EAAC,qBAAqB,YAC9D,IAAI,CAAC,KAAK,GACN,GACH,CACP,CAAC,CAAC,CAAC,IAAI,EACR,KAAC,kBAAkB,IAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,KAAM,QAAQ,CAAC,GAAG,CAAC,GAAI,KARhD,GAAG,CASzB,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare type FormElementRegisterer = ReturnType<typeof useForm>['register'];
|
|
2
|
+
export declare const useForm: <FormState extends Record<string, any>>(initialState?: Partial<FormState>) => {
|
|
3
|
+
formState: Partial<FormState>;
|
|
4
|
+
register: <FieldName extends keyof FormState>(fieldName: FieldName) => {
|
|
5
|
+
value?: undefined;
|
|
6
|
+
onChange?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
value: Partial<FormState>[FieldName];
|
|
9
|
+
onChange: Partial<Record<keyof FormState, () => void>>[FieldName];
|
|
10
|
+
};
|
|
11
|
+
resetForm: () => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
export const useForm = (initialState = {}) => {
|
|
3
|
+
const [formState, setFormState] = useState(initialState);
|
|
4
|
+
const handlersMap = useRef({});
|
|
5
|
+
const register = (fieldName) => {
|
|
6
|
+
if (!handlersMap.current) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
const handler = (value) => {
|
|
10
|
+
setFormState((prev) => ({ ...prev, [fieldName]: value }));
|
|
11
|
+
};
|
|
12
|
+
handlersMap.current[fieldName] ||= handler;
|
|
13
|
+
return { value: formState?.[fieldName], onChange: handlersMap.current[fieldName] };
|
|
14
|
+
};
|
|
15
|
+
const resetForm = useCallback(() => setFormState({}), []);
|
|
16
|
+
return { formState, register, resetForm };
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useForm.js","sourceRoot":"","sources":["../../src/hooks/useForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAI5E,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,eAAmC,EAAE,EACrC,EAAE;IACF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAqB,YAAY,CAAC,CAAC;IAE7E,MAAM,WAAW,GAAG,MAAM,CAA+C,EAAE,CAAC,CAAC;IAE7E,MAAM,QAAQ,GAAG,CAAoC,SAAoB,EAAE,EAAE;QAC3E,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;YACxB,OAAO,EAAE,CAAC;SACX;QAED,MAAM,OAAO,GAAG,CAAC,KAA4B,EAAE,EAAE;YAC/C,YAAY,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QAC5D,CAAC,CAAC;QAEF,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,OAAO,CAAC;QAE3C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;IACrF,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAE1D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AAC5C,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { UNIComponent } from '@redneckz/uni-jsx';
|
|
2
|
+
import type { JSONSchema7Definition } from 'json-schema';
|
|
2
3
|
import type { BlockRendererOptions } from '../BlockRenderer/BlockRendererOptions';
|
|
3
4
|
import type { SlotName } from './BlockDecorator';
|
|
4
5
|
import type { BlockVersion } from './BlockVersion';
|
|
@@ -22,5 +23,6 @@ export declare type JSXBlock<BlockProps extends UniBlockProps = UniBlockProps> =
|
|
|
22
23
|
include?: string[];
|
|
23
24
|
exclude?: string[];
|
|
24
25
|
};
|
|
26
|
+
childSchema?: (content: BlockDef['content']) => Record<string, JSONSchema7Definition>;
|
|
25
27
|
slots?: (props: BlockProps) => SlotName[];
|
|
26
28
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ControlProps.js","sourceRoot":"","sources":["../../src/ui-kit/ControlProps.ts"],"names":[],"mappings":""}
|
|
@@ -7,6 +7,7 @@ interface DefaultFoldButtonProps {
|
|
|
7
7
|
label: string;
|
|
8
8
|
icon: IconName;
|
|
9
9
|
dataTheme?: ColorPalette;
|
|
10
|
+
disabled?: boolean;
|
|
10
11
|
onClick?: () => void;
|
|
11
12
|
}
|
|
12
13
|
export declare const DefaultFoldButton: import("@redneckz/uni-jsx").UNIComponent<DefaultFoldButtonProps, any, any>;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@redneckz/uni-jsx/jsx-runtime";
|
|
2
2
|
import { JSX } from '@redneckz/uni-jsx';
|
|
3
|
+
import { style } from '../../utils/style.js';
|
|
3
4
|
import { Img } from '../Img/Img.js';
|
|
4
|
-
export const DefaultFoldButton = JSX(({ className = '', label, icon, dataTheme = '', onClick }) => {
|
|
5
|
+
export const DefaultFoldButton = JSX(({ className = '', label, icon, dataTheme = '', disabled = false, onClick }) => {
|
|
5
6
|
const STATE_STYLE = 'hover:bg-primary-hover focus:border-primary-text active:bg-primary-active outline-none';
|
|
6
7
|
const DIMENSIONS_STYLE = 'flex justify-center w-full px-0 py-5';
|
|
7
|
-
return (_jsxs("button", { className:
|
|
8
|
-
'
|
|
9
|
-
|
|
10
|
-
DIMENSIONS_STYLE,
|
|
11
|
-
className,
|
|
12
|
-
].join(' '), "data-theme": dataTheme, onClick: onClick, children: [_jsx("span", { className: "text-h4 pr-3", children: label }), icon ? (_jsx(Img, { image: {
|
|
8
|
+
return (_jsxs("button", { className: style('border border-transparent bg-primary-main font-sans text-white cursor-pointer', STATE_STYLE, DIMENSIONS_STYLE, disabled
|
|
9
|
+
? 'bg-main-divider text-main-disabled cursor-not-allowed hover:bg-main-divider active:bg-main-divider'
|
|
10
|
+
: '', className), onClick: onClick, disabled: disabled, "data-theme": dataTheme, children: [_jsx("span", { className: "text-h4 pr-3", children: label }), icon ? (_jsx(Img, { image: {
|
|
13
11
|
icon,
|
|
14
12
|
iconVersion: 'white',
|
|
15
13
|
}, className: "flex-shrink-0 my-auto", width: "20", height: "20", asSVG: true })) : null] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultFoldButton.js","sourceRoot":"","sources":["../../../src/ui-kit/Foldable/DefaultFoldButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"DefaultFoldButton.js","sourceRoot":"","sources":["../../../src/ui-kit/Foldable/DefaultFoldButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAYjC,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAClC,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,GAAG,EAAE,EAAE,QAAQ,GAAG,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE;IAC7E,MAAM,WAAW,GACf,wFAAwF,CAAC;IAC3F,MAAM,gBAAgB,GAAG,sCAAsC,CAAC;IAEhE,OAAO,CACL,kBACE,SAAS,EAAE,KAAK,CACd,+EAA+E,EAC/E,WAAW,EACX,gBAAgB,EAChB,QAAQ;YACN,CAAC,CAAC,oGAAoG;YACtG,CAAC,CAAC,EAAE,EACN,SAAS,CACV,EACD,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,gBACN,SAAS,aAErB,eAAM,SAAS,EAAC,cAAc,YAAE,KAAK,GAAQ,EAC5C,IAAI,CAAC,CAAC,CAAC,CACN,KAAC,GAAG,IACF,KAAK,EAAE;oBACL,IAAI;oBACJ,WAAW,EAAE,OAAO;iBACrB,EACD,SAAS,EAAC,uBAAuB,EACjC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,KAAK,SACL,CACH,CAAC,CAAC,CAAC,IAAI,IACD,CACV,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAqB,EAAE,EAAE;IACrF,MAAM,MAAM,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IACxC,MAAM,KAAK,GAAe,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;IAE3D,OAAO,CACL,KAAC,iBAAiB,IAChB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EACjC,OAAO,EAAE,QAAQ,GACjB,CACH,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
interface SlideCheckboxProps {
|
|
2
|
-
|
|
2
|
+
value?: boolean;
|
|
3
3
|
text?: string;
|
|
4
|
-
|
|
4
|
+
type?: 'checkbox' | 'radio';
|
|
5
|
+
onChange?: (value: boolean) => void;
|
|
5
6
|
}
|
|
6
7
|
export declare const SlideCheckbox: import("@redneckz/uni-jsx").UNIComponent<SlideCheckboxProps, any, any>;
|
|
7
8
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@redneckz/uni-jsx/jsx-runtime";
|
|
2
2
|
import { JSX } from '@redneckz/uni-jsx';
|
|
3
|
-
import { Text } from '
|
|
4
|
-
export const SlideCheckbox = JSX(({
|
|
3
|
+
import { Text } from '../Text/Text.js';
|
|
4
|
+
export 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 }) })] })));
|
|
5
5
|
//# sourceMappingURL=SlideCheckbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlideCheckbox.js","sourceRoot":"","sources":["../../../src/ui-kit/SlideCheckbox/SlideCheckbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SlideCheckbox.js","sourceRoot":"","sources":["../../../src/ui-kit/SlideCheckbox/SlideCheckbox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAQpC,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAC9B,CAAC,EAAE,KAAK,GAAG,KAAK,EAAE,IAAI,EAAE,IAAI,GAAG,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CACxD,eACE,IAAI,EAAE,IAAI,kBACI,KAAK,EACnB,SAAS,EAAC,4DAA4D,EACtE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,KAAK,CAAC,aAE3C,cACE,SAAS,EAAE,gEACT,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,iBAC9B,EAAE,YAEF,cACE,SAAS,EAAE,0EACT,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WACzB,EAAE,GACF,GACE,EACN,wBACE,KAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,YAAY,EAAC,KAAK,EAAC,mBAAmB,YAC5D,IAAI,GACA,GACH,IACF,CACP,CACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ControlProps } from '../ControlProps';
|
|
2
|
+
declare type SlideCheckboxGroupItem = {
|
|
3
|
+
value: string;
|
|
4
|
+
title: string;
|
|
5
|
+
};
|
|
6
|
+
interface SlideCheckboxGroupProps extends ControlProps<string> {
|
|
7
|
+
multiple: false;
|
|
8
|
+
items: SlideCheckboxGroupItem[];
|
|
9
|
+
}
|
|
10
|
+
interface MultipleSlideCheckboxGroupProps extends ControlProps<string[]> {
|
|
11
|
+
multiple: true;
|
|
12
|
+
items: SlideCheckboxGroupItem[];
|
|
13
|
+
}
|
|
14
|
+
export declare const SlideCheckboxGroup: import("@redneckz/uni-jsx").UNIComponent<SlideCheckboxGroupProps | MultipleSlideCheckboxGroupProps, any, any>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@redneckz/uni-jsx/jsx-runtime";
|
|
2
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
3
|
+
import { SlideCheckbox } from '../SlideCheckbox/SlideCheckbox.js';
|
|
4
|
+
export const SlideCheckboxGroup = JSX(({ value, onChange, items = [], multiple }) => {
|
|
5
|
+
const handleChange = (newValue) => {
|
|
6
|
+
if (multiple) {
|
|
7
|
+
const hasAlready = value?.includes(newValue);
|
|
8
|
+
onChange &&
|
|
9
|
+
onChange(hasAlready ? value?.filter((v) => v !== newValue) : [...(value || []), newValue]);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
onChange && onChange(value === newValue ? undefined : newValue);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
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)));
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=SlideCheckboxGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlideCheckboxGroup.js","sourceRoot":"","sources":["../../../src/ui-kit/SlideCheckboxGroup/SlideCheckboxGroup.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAiB/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CACnC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC5C,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,EAAE;QACxC,IAAI,QAAQ,EAAE;YACZ,MAAM,UAAU,GAAG,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC7C,QAAQ;gBACN,QAAQ,CACN,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAC,CACjF,CAAC;SACL;aAAM;YACL,QAAQ,IAAI,QAAQ,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;SACjE;IACH,CAAC,CAAC;IAEF,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACzB,KAAC,aAAa,IAEZ,IAAI,EAAE,IAAI,CAAC,KAAK,EAChB,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EACrD,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EACxC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,IAJhC,IAAI,CAAC,KAAK,CAKf,CACH,CAAC,CAAC;AACL,CAAC,CACF,CAAC"}
|
|
@@ -15,14 +15,14 @@ export const renderSlideCheckboxes = ({
|
|
|
15
15
|
}: SlideCheckboxesProps) => (
|
|
16
16
|
<div className="mb-5">
|
|
17
17
|
<SlideCheckbox
|
|
18
|
-
|
|
18
|
+
value={onlineСheckout}
|
|
19
19
|
text="Хочу купить онлайн-кассу"
|
|
20
|
-
|
|
20
|
+
onChange={() => handleChange({ onlineСheckout: !onlineСheckout })}
|
|
21
21
|
/>
|
|
22
22
|
<SlideCheckbox
|
|
23
|
-
|
|
23
|
+
value={posTerminal}
|
|
24
24
|
text="Хочу купить POS-терминал"
|
|
25
|
-
|
|
25
|
+
onChange={() => handleChange({ posTerminal: !posTerminal })}
|
|
26
26
|
/>
|
|
27
27
|
</div>
|
|
28
28
|
);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"content": {
|
|
3
|
+
"filtrationSchema": {
|
|
4
|
+
"propertyType": {
|
|
5
|
+
"title": "Тип недвижимости",
|
|
6
|
+
"type": "string",
|
|
7
|
+
"enum": ["flat", "apartment", "house", "storeRoom", "parkingSpace"],
|
|
8
|
+
"enumNames": ["Квартира", "Апартаменты", "Жилой дом", "Кладовая", "Машино-место"]
|
|
9
|
+
},
|
|
10
|
+
"stage": {
|
|
11
|
+
"title": "Этап строительства",
|
|
12
|
+
"type": "string",
|
|
13
|
+
"enum": ["built", "inProgress"],
|
|
14
|
+
"enumNames": ["Готовое жильё", "Строящиеся"]
|
|
15
|
+
},
|
|
16
|
+
"categories": {
|
|
17
|
+
"title": "Категории",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"enum": ["salaryClient", "IT", "youngFamily", "military", "medicalWorker", "scientist"],
|
|
20
|
+
"enumNames": [
|
|
21
|
+
"Зарплатный клиент",
|
|
22
|
+
"IT-специалист",
|
|
23
|
+
"Молодая семья",
|
|
24
|
+
"Военнослужащий",
|
|
25
|
+
"Медицинский работник",
|
|
26
|
+
"Научный сотрудник"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"extraOptions": {
|
|
30
|
+
"title": "Дополнительно",
|
|
31
|
+
"type": "string",
|
|
32
|
+
"enum": ["preferentialMortgage", "children"],
|
|
33
|
+
"enumNames": ["Льготная ипотека", "Дети"]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { useForm } from '../../hooks/useForm';
|
|
3
|
+
import type { JSXBlock, UniBlockProps } from '../../model/JSXBlock';
|
|
4
|
+
import { BlockWrapper } from '../../ui-kit/BlockWrapper';
|
|
5
|
+
import { Button } from '../../ui-kit/Button/Button';
|
|
6
|
+
import { style } from '../../utils/style';
|
|
7
|
+
import type { FiltrationContent } from './FiltrationContent';
|
|
8
|
+
import { FiltrationInner } from './FiltrationInner';
|
|
9
|
+
import { renderFormItem } from './renderFormItem';
|
|
10
|
+
|
|
11
|
+
interface FiltrationProps extends FiltrationContent, UniBlockProps {}
|
|
12
|
+
|
|
13
|
+
export const Filtration: JSXBlock<FiltrationProps> = JSX<FiltrationProps>(
|
|
14
|
+
({ className, filtrationSchema = {}, resetButton, ...rest }) => {
|
|
15
|
+
const { formState, register, resetForm } = useForm();
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<BlockWrapper className={style('p-9', className)} {...rest}>
|
|
19
|
+
<form className="flex justify-between">
|
|
20
|
+
<div className="flex gap-11">
|
|
21
|
+
{Object.keys(filtrationSchema).map(renderFormItem(filtrationSchema, register))}
|
|
22
|
+
</div>
|
|
23
|
+
{resetButton ? (
|
|
24
|
+
<div>
|
|
25
|
+
<Button
|
|
26
|
+
className="w-72"
|
|
27
|
+
text={resetButton.text}
|
|
28
|
+
version={resetButton.buttonVersion}
|
|
29
|
+
onClick={resetForm}
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
) : null}
|
|
33
|
+
</form>
|
|
34
|
+
<FiltrationInner filtrationState={formState} {...rest} />
|
|
35
|
+
</BlockWrapper>
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
Filtration.childrenTypes = ['ProductTile'];
|
|
41
|
+
Filtration.childSchema = (content?: FiltrationContent) => content?.filtrationSchema || {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { ButtonVersion } from '../../model/ButtonVersion';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @title Заголовок
|
|
5
|
+
*/
|
|
6
|
+
type Title = string;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @title Ключи
|
|
10
|
+
*/
|
|
11
|
+
type Enum = string[];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @title Имена
|
|
15
|
+
*/
|
|
16
|
+
type EnumNames = string[];
|
|
17
|
+
|
|
18
|
+
export type StringEnum = {
|
|
19
|
+
title?: Title;
|
|
20
|
+
/**
|
|
21
|
+
* @default string
|
|
22
|
+
* @hidden
|
|
23
|
+
*/
|
|
24
|
+
type?: 'string';
|
|
25
|
+
enum?: Enum;
|
|
26
|
+
enumNames?: EnumNames;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type StringArray = {
|
|
30
|
+
title?: Title;
|
|
31
|
+
/**
|
|
32
|
+
* @default array
|
|
33
|
+
* @hidden
|
|
34
|
+
*/
|
|
35
|
+
type?: 'array';
|
|
36
|
+
items?: {
|
|
37
|
+
/**
|
|
38
|
+
* @default string
|
|
39
|
+
* @hidden
|
|
40
|
+
*/
|
|
41
|
+
type?: 'string';
|
|
42
|
+
enum?: Enum;
|
|
43
|
+
enumNames?: EnumNames;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// TODO: Make customizable to implement arbitrary filtration blocks
|
|
48
|
+
export type FiltrationSchema = {
|
|
49
|
+
/** @title Тип недвижимости */
|
|
50
|
+
propertyType?: StringEnum;
|
|
51
|
+
/** @title Этап строительства */
|
|
52
|
+
stage?: StringEnum;
|
|
53
|
+
/** @title Категории */
|
|
54
|
+
categories?: StringEnum;
|
|
55
|
+
/** @title Дополнительно */
|
|
56
|
+
extraOptions?: StringEnum;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @title Кнопка сброса
|
|
61
|
+
*/
|
|
62
|
+
export type ResetButton = {
|
|
63
|
+
/**
|
|
64
|
+
* @title Текст кнопки
|
|
65
|
+
*/
|
|
66
|
+
text: string;
|
|
67
|
+
/**
|
|
68
|
+
* @title Цвет кнопки
|
|
69
|
+
*/
|
|
70
|
+
buttonVersion: ButtonVersion;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export interface FiltrationInnerContent {
|
|
74
|
+
/** @title Название кнопки */
|
|
75
|
+
label?: string;
|
|
76
|
+
/** @title Количество отображаемых предметов */
|
|
77
|
+
topItemsCount?: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @title Фильтрация
|
|
82
|
+
*/
|
|
83
|
+
export interface FiltrationContent extends FiltrationInnerContent {
|
|
84
|
+
/** @title Параметры фильтрации */
|
|
85
|
+
filtrationSchema?: FiltrationSchema;
|
|
86
|
+
resetButton?: ResetButton;
|
|
87
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { renderBlocksList } from '../../BlockRenderer/renderBlockList';
|
|
3
|
+
import type { IconName } from '../../icons/IconName';
|
|
4
|
+
import type { UniBlockProps } from '../../model/JSXBlock';
|
|
5
|
+
import { DefaultFoldButton } from '../../ui-kit/Foldable/DefaultFoldButton';
|
|
6
|
+
import { Foldable } from '../../ui-kit/Foldable/Foldable';
|
|
7
|
+
import { FoldableSection } from '../../ui-kit/Foldable/FoldableSection';
|
|
8
|
+
import { style } from '../../utils/style';
|
|
9
|
+
import { ErrorBlock } from '../ErrorBlock/ErrorBlock';
|
|
10
|
+
import { checkShouldRenderBlock } from './checkShouldRenderBlock';
|
|
11
|
+
import type { FiltrationInnerContent } from './FiltrationContent';
|
|
12
|
+
|
|
13
|
+
const ICONS: IconName[] = ['ArrowDownIcon', 'ArrowUpIcon'];
|
|
14
|
+
|
|
15
|
+
const resultsGridStyle = 'grid grid-cols-12 gap-1 border-box';
|
|
16
|
+
|
|
17
|
+
interface FiltrationInnerProps extends FiltrationInnerContent, UniBlockProps {
|
|
18
|
+
filtrationState?: Record<string, any>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const FiltrationInner = JSX<FiltrationInnerProps>(
|
|
22
|
+
({ label = '', filtrationState = {}, topItemsCount = 0, block, ...rest }) => {
|
|
23
|
+
const blocksToRender =
|
|
24
|
+
block?.blocks?.filter((b) => checkShouldRenderBlock(filtrationState, b.content || {})) || [];
|
|
25
|
+
|
|
26
|
+
const [visibleBlocks, hiddenBlocks] =
|
|
27
|
+
topItemsCount > 0
|
|
28
|
+
? [blocksToRender.slice(0, topItemsCount), blocksToRender.slice(topItemsCount)]
|
|
29
|
+
: [blocksToRender, []];
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div>
|
|
33
|
+
<div className={style(blocksToRender.length ? 'hidden' : '')}>
|
|
34
|
+
<ErrorBlock
|
|
35
|
+
error={{ errorContentType: 'Image' }}
|
|
36
|
+
title="Нет подходящей ипотечной программы"
|
|
37
|
+
subtitle="Попробуйте очистить фильтры"
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
<div className={style(blocksToRender.length ? '' : 'hidden')}>
|
|
41
|
+
<div className={resultsGridStyle}>
|
|
42
|
+
{renderBlocksList(visibleBlocks, { ...rest.options, parent: block })}
|
|
43
|
+
</div>
|
|
44
|
+
<Foldable
|
|
45
|
+
renderFoldableSection={({ isUnfolded }) => {
|
|
46
|
+
return (
|
|
47
|
+
<FoldableSection className={resultsGridStyle} isUnfolded={isUnfolded}>
|
|
48
|
+
{renderBlocksList(hiddenBlocks, { ...rest.options, parent: block })}
|
|
49
|
+
</FoldableSection>
|
|
50
|
+
);
|
|
51
|
+
}}
|
|
52
|
+
renderFoldButton={({ isUnfolded, onToggle }) => (
|
|
53
|
+
<DefaultFoldButton
|
|
54
|
+
className="mt-11"
|
|
55
|
+
disabled={topItemsCount > hiddenBlocks.length}
|
|
56
|
+
label={label}
|
|
57
|
+
icon={ICONS[Number(isUnfolded)]}
|
|
58
|
+
dataTheme={rest.options?.page?.colorPalette}
|
|
59
|
+
onClick={onToggle}
|
|
60
|
+
/>
|
|
61
|
+
)}
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
},
|
|
67
|
+
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const isSingularFieldMatch =
|
|
2
|
+
<P extends Partial<Record<string, any>>, T extends P>(key: string, pattern: P) =>
|
|
3
|
+
(target: T) =>
|
|
4
|
+
pattern[key] === undefined || pattern[key] === target[key];
|
|
5
|
+
|
|
6
|
+
const isMultipleFieldMatch =
|
|
7
|
+
<P extends Partial<Record<string, any[]>>, T extends P>(key: string, pattern: P) =>
|
|
8
|
+
(target: T) =>
|
|
9
|
+
pattern[key] === undefined || pattern[key]?.every((_) => target[key]?.includes(_));
|
|
10
|
+
|
|
11
|
+
export const checkShouldRenderBlock = (pattern: Record<string, any>, target: Record<string, any>) =>
|
|
12
|
+
Object.entries(pattern)
|
|
13
|
+
.map(([key, subPattern]) =>
|
|
14
|
+
Array.isArray(subPattern)
|
|
15
|
+
? isMultipleFieldMatch(key, pattern)
|
|
16
|
+
: isSingularFieldMatch(key, pattern),
|
|
17
|
+
)
|
|
18
|
+
.every((predicate) => predicate(target));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { FormElementRegisterer } from '../../hooks/useForm';
|
|
2
|
+
import { SlideCheckboxGroup } from '../../ui-kit/SlideCheckboxGroup/SlideCheckboxGroup';
|
|
3
|
+
import { Text } from '../../ui-kit/Text/Text';
|
|
4
|
+
import type { FiltrationSchema, StringEnum } from './FiltrationContent';
|
|
5
|
+
|
|
6
|
+
export const renderFormItem =
|
|
7
|
+
(filtrationSchema: FiltrationSchema, register: FormElementRegisterer) => (key: string) => {
|
|
8
|
+
const item = filtrationSchema[key as keyof typeof filtrationSchema];
|
|
9
|
+
const type = item?.type;
|
|
10
|
+
|
|
11
|
+
switch (type) {
|
|
12
|
+
case 'string':
|
|
13
|
+
return renderRadioButtons(key, register)(item);
|
|
14
|
+
default:
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const renderRadioButtons =
|
|
20
|
+
(key: string, register: FormElementRegisterer) => (item?: StringEnum) => {
|
|
21
|
+
const options =
|
|
22
|
+
item?.enum?.map((e, i) => ({ value: e, title: item?.enumNames?.[i] || '' })) || [];
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div role="radiogroup" key={key}>
|
|
26
|
+
{item?.title ? (
|
|
27
|
+
<div className="mb-4">
|
|
28
|
+
<Text size="text-m" font="font-light" color="text-secondary-text">
|
|
29
|
+
{item.title}
|
|
30
|
+
</Text>
|
|
31
|
+
</div>
|
|
32
|
+
) : null}
|
|
33
|
+
<SlideCheckboxGroup items={options} multiple={false} {...register(key)} />
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
|
+
|
|
3
|
+
export type FormElementRegisterer = ReturnType<typeof useForm>['register'];
|
|
4
|
+
|
|
5
|
+
export const useForm = <FormState extends Record<string, any>>(
|
|
6
|
+
initialState: Partial<FormState> = {},
|
|
7
|
+
) => {
|
|
8
|
+
const [formState, setFormState] = useState<Partial<FormState>>(initialState);
|
|
9
|
+
|
|
10
|
+
const handlersMap = useRef<Partial<Record<keyof FormState, () => void>>>({});
|
|
11
|
+
|
|
12
|
+
const register = <FieldName extends keyof FormState>(fieldName: FieldName) => {
|
|
13
|
+
if (!handlersMap.current) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const handler = (value?: FormState[FieldName]) => {
|
|
18
|
+
setFormState((prev) => ({ ...prev, [fieldName]: value }));
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
handlersMap.current[fieldName] ||= handler;
|
|
22
|
+
|
|
23
|
+
return { value: formState?.[fieldName], onChange: handlersMap.current[fieldName] };
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const resetForm = useCallback(() => setFormState({}), []);
|
|
27
|
+
|
|
28
|
+
return { formState, register, resetForm };
|
|
29
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { UNIComponent } from '@redneckz/uni-jsx';
|
|
2
|
+
import type { JSONSchema7Definition } from 'json-schema';
|
|
2
3
|
import type { BlockRendererOptions } from '../BlockRenderer/BlockRendererOptions';
|
|
3
4
|
import type { SlotName } from './BlockDecorator';
|
|
4
5
|
import type { BlockVersion } from './BlockVersion';
|
|
@@ -26,5 +27,6 @@ export type JSXBlock<BlockProps extends UniBlockProps = UniBlockProps> = UNIComp
|
|
|
26
27
|
VNode | VNode[]
|
|
27
28
|
> & {
|
|
28
29
|
childrenTypes?: string[] | { include?: string[]; exclude?: string[] };
|
|
30
|
+
childSchema?: (content: BlockDef['content']) => Record<string, JSONSchema7Definition>;
|
|
29
31
|
slots?: (props: BlockProps) => SlotName[];
|
|
30
32
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
2
|
import type { ColorPalette } from '../../model/ContentPageDef';
|
|
3
|
+
import { style } from '../../utils/style';
|
|
3
4
|
import type { IconName } from '../Icon/IconProps';
|
|
4
5
|
import { Img } from '../Img/Img';
|
|
5
6
|
import type { FoldablePartProps } from './FoldablePartProps';
|
|
@@ -9,25 +10,30 @@ interface DefaultFoldButtonProps {
|
|
|
9
10
|
label: string;
|
|
10
11
|
icon: IconName;
|
|
11
12
|
dataTheme?: ColorPalette;
|
|
13
|
+
disabled?: boolean;
|
|
12
14
|
onClick?: () => void;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
export const DefaultFoldButton = JSX<DefaultFoldButtonProps>(
|
|
16
|
-
({ className = '', label, icon, dataTheme = '', onClick }) => {
|
|
18
|
+
({ className = '', label, icon, dataTheme = '', disabled = false, onClick }) => {
|
|
17
19
|
const STATE_STYLE =
|
|
18
20
|
'hover:bg-primary-hover focus:border-primary-text active:bg-primary-active outline-none';
|
|
19
21
|
const DIMENSIONS_STYLE = 'flex justify-center w-full px-0 py-5';
|
|
20
22
|
|
|
21
23
|
return (
|
|
22
24
|
<button
|
|
23
|
-
className={
|
|
25
|
+
className={style(
|
|
24
26
|
'border border-transparent bg-primary-main font-sans text-white cursor-pointer',
|
|
25
27
|
STATE_STYLE,
|
|
26
28
|
DIMENSIONS_STYLE,
|
|
29
|
+
disabled
|
|
30
|
+
? 'bg-main-divider text-main-disabled cursor-not-allowed hover:bg-main-divider active:bg-main-divider'
|
|
31
|
+
: '',
|
|
27
32
|
className,
|
|
28
|
-
|
|
29
|
-
data-theme={dataTheme}
|
|
33
|
+
)}
|
|
30
34
|
onClick={onClick}
|
|
35
|
+
disabled={disabled}
|
|
36
|
+
data-theme={dataTheme}
|
|
31
37
|
>
|
|
32
38
|
<span className="text-h4 pr-3">{label}</span>
|
|
33
39
|
{icon ? (
|