@redneckz/wildless-cms-uni-blocks 0.8.30 → 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/bin/migrateContentUnit.js +2 -5
- package/bin/migration-scripts/0.8.31.js +86 -0
- 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/content-page-repository/transformImgPath.d.ts +8 -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/content-page-repository/transformImg.js +6 -6
- package/dist/content-page-repository/transformImg.js.map +1 -1
- package/dist/content-page-repository/transformImgPath.d.ts +8 -0
- package/{mobile/dist/content-page-repository/transformSrc.js → dist/content-page-repository/transformImgPath.js} +7 -5
- package/dist/content-page-repository/transformImgPath.js.map +1 -0
- package/dist/content-page-repository/transformPicture.js +3 -3
- package/dist/content-page-repository/transformPicture.js.map +1 -1
- 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/content-page-repository/transformImg.js +6 -6
- package/lib/content-page-repository/transformImg.js.map +1 -1
- package/lib/content-page-repository/transformImgPath.d.ts +8 -0
- package/lib/content-page-repository/{transformSrc.js → transformImgPath.js} +5 -3
- package/lib/content-page-repository/transformImgPath.js.map +1 -0
- package/lib/content-page-repository/transformPicture.js +3 -3
- package/lib/content-page-repository/transformPicture.js.map +1 -1
- 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/content-page-repository/transformImgPath.d.ts +8 -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/content-page-repository/transformImg.js +6 -6
- package/mobile/dist/content-page-repository/transformImg.js.map +1 -1
- package/mobile/dist/content-page-repository/transformImgPath.d.ts +8 -0
- package/{dist/content-page-repository/transformSrc.js → mobile/dist/content-page-repository/transformImgPath.js} +7 -5
- package/mobile/dist/content-page-repository/transformImgPath.js.map +1 -0
- package/mobile/dist/content-page-repository/transformPicture.js +3 -3
- package/mobile/dist/content-page-repository/transformPicture.js.map +1 -1
- 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/content-page-repository/transformImg.js +6 -6
- package/mobile/lib/content-page-repository/transformImg.js.map +1 -1
- package/mobile/lib/content-page-repository/transformImgPath.d.ts +8 -0
- package/mobile/lib/content-page-repository/{transformSrc.js → transformImgPath.js} +5 -3
- package/mobile/lib/content-page-repository/transformImgPath.js.map +1 -0
- package/mobile/lib/content-page-repository/transformPicture.js +3 -3
- package/mobile/lib/content-page-repository/transformPicture.js.map +1 -1
- 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/content-page-repository/transformImg.ts +6 -9
- package/mobile/src/content-page-repository/{transformSrc.ts → transformImgPath.ts} +12 -3
- package/mobile/src/content-page-repository/transformPicture.ts +3 -6
- 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/content-page-repository/transformImg.ts +6 -9
- package/src/content-page-repository/{transformSrc.ts → transformImgPath.ts} +12 -3
- package/src/content-page-repository/transformPicture.ts +3 -6
- 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
- package/bundle/content-page-repository/transformSrc.d.ts +0 -3
- package/dist/content-page-repository/transformSrc.d.ts +0 -3
- package/dist/content-page-repository/transformSrc.js.map +0 -1
- package/lib/content-page-repository/transformSrc.d.ts +0 -3
- package/lib/content-page-repository/transformSrc.js.map +0 -1
- package/mobile/bundle/content-page-repository/transformSrc.d.ts +0 -3
- package/mobile/dist/content-page-repository/transformSrc.d.ts +0 -3
- package/mobile/dist/content-page-repository/transformSrc.js.map +0 -1
- package/mobile/lib/content-page-repository/transformSrc.d.ts +0 -3
- package/mobile/lib/content-page-repository/transformSrc.js.map +0 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { BlockRendererOptions } from '../../BlockRenderer/BlockRendererOptions';
|
|
2
|
+
import { Blocks } from '../Blocks';
|
|
3
|
+
import { PRODUCT_TILE } from '../ProductTile/ProductTile.fixture';
|
|
4
|
+
import { Filtration } from './Filtration';
|
|
5
|
+
import type { FiltrationContent } from './FiltrationContent';
|
|
6
|
+
|
|
7
|
+
const PROPERTY_APARTMENT = {
|
|
8
|
+
propertyType: 'apartment',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const PROPERTY_FLAT = {
|
|
12
|
+
propertyType: 'flat',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const PROPERTY_HOUSE = {
|
|
16
|
+
propertyType: 'house',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const STAGE_BUILT = {
|
|
20
|
+
stage: 'built',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const STAGE_IN_PROGRESS = {
|
|
24
|
+
stage: 'inProgress',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const EXTRA_MORTGAGE = {
|
|
28
|
+
extraOptions: 'preferentialMortgage',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const EXTRA_CHILDREN = {
|
|
32
|
+
extraOptions: 'children',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const CATEGORY_IT = {
|
|
36
|
+
categories: 'IT',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const CATEGORY_SALARY = {
|
|
40
|
+
categories: 'salaryClient',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const generateBlock = (...presets: any[]) => ({
|
|
44
|
+
type: 'ProductTile',
|
|
45
|
+
style: ['col-span-6'],
|
|
46
|
+
content: { ...presets.reduce((acc, p) => ({ ...acc, ...p })) },
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const SCHEMA: FiltrationContent['filtrationSchema'] = {
|
|
50
|
+
propertyType: {
|
|
51
|
+
title: 'Тип недвижимости',
|
|
52
|
+
type: 'string',
|
|
53
|
+
enum: ['flat', 'apartment', 'house', 'storeRoom', 'parkingSpace'],
|
|
54
|
+
enumNames: ['Квартира', 'Апартаменты', 'Жилой дом', 'Кладовая', 'Машино-место'],
|
|
55
|
+
},
|
|
56
|
+
stage: {
|
|
57
|
+
title: 'Этап строительства',
|
|
58
|
+
type: 'string',
|
|
59
|
+
enum: ['built', 'inProgress'],
|
|
60
|
+
enumNames: ['Готовое жильё', 'Строящиеся'],
|
|
61
|
+
},
|
|
62
|
+
categories: {
|
|
63
|
+
title: 'Категории',
|
|
64
|
+
type: 'string',
|
|
65
|
+
enum: ['salaryClient', 'IT', 'youngFamily', 'military', 'medicalWorker', 'scientist'],
|
|
66
|
+
enumNames: [
|
|
67
|
+
'Зарплатный клиент',
|
|
68
|
+
'IT-специалист',
|
|
69
|
+
'Молодая семья',
|
|
70
|
+
'Военнослужащий',
|
|
71
|
+
'Медицинский работник',
|
|
72
|
+
'Научный сотрудник',
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
extraOptions: {
|
|
76
|
+
title: 'Дополнительно',
|
|
77
|
+
type: 'string',
|
|
78
|
+
enum: ['preferentialMortgage', 'children'],
|
|
79
|
+
enumNames: ['Льготная ипотека', 'Дети'],
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const options = {
|
|
84
|
+
blocksRegistry: Blocks,
|
|
85
|
+
} as BlockRendererOptions;
|
|
86
|
+
|
|
87
|
+
export default {
|
|
88
|
+
default: (
|
|
89
|
+
<div className="container grid grid-cols-12">
|
|
90
|
+
<Filtration
|
|
91
|
+
className="col-span-12"
|
|
92
|
+
label="Другие ипотечные программы"
|
|
93
|
+
filtrationSchema={SCHEMA}
|
|
94
|
+
topItemsCount={2}
|
|
95
|
+
resetButton={{ text: 'Очистить фильтры', buttonVersion: 'secondary' }}
|
|
96
|
+
block={{
|
|
97
|
+
type: 'Filtration',
|
|
98
|
+
blocks: [
|
|
99
|
+
generateBlock(
|
|
100
|
+
PRODUCT_TILE,
|
|
101
|
+
PROPERTY_APARTMENT,
|
|
102
|
+
STAGE_IN_PROGRESS,
|
|
103
|
+
EXTRA_MORTGAGE,
|
|
104
|
+
CATEGORY_IT,
|
|
105
|
+
),
|
|
106
|
+
generateBlock(
|
|
107
|
+
PRODUCT_TILE,
|
|
108
|
+
PROPERTY_APARTMENT,
|
|
109
|
+
STAGE_BUILT,
|
|
110
|
+
EXTRA_CHILDREN,
|
|
111
|
+
CATEGORY_SALARY,
|
|
112
|
+
),
|
|
113
|
+
generateBlock(
|
|
114
|
+
PRODUCT_TILE,
|
|
115
|
+
PROPERTY_FLAT,
|
|
116
|
+
STAGE_IN_PROGRESS,
|
|
117
|
+
EXTRA_MORTGAGE,
|
|
118
|
+
CATEGORY_SALARY,
|
|
119
|
+
),
|
|
120
|
+
generateBlock(
|
|
121
|
+
PRODUCT_TILE,
|
|
122
|
+
PROPERTY_FLAT,
|
|
123
|
+
STAGE_BUILT,
|
|
124
|
+
EXTRA_MORTGAGE,
|
|
125
|
+
CATEGORY_SALARY,
|
|
126
|
+
),
|
|
127
|
+
generateBlock(
|
|
128
|
+
PRODUCT_TILE,
|
|
129
|
+
PROPERTY_APARTMENT,
|
|
130
|
+
STAGE_BUILT,
|
|
131
|
+
EXTRA_CHILDREN,
|
|
132
|
+
CATEGORY_IT,
|
|
133
|
+
),
|
|
134
|
+
generateBlock(
|
|
135
|
+
PRODUCT_TILE,
|
|
136
|
+
PROPERTY_HOUSE,
|
|
137
|
+
STAGE_BUILT,
|
|
138
|
+
EXTRA_MORTGAGE,
|
|
139
|
+
CATEGORY_SALARY,
|
|
140
|
+
),
|
|
141
|
+
],
|
|
142
|
+
}}
|
|
143
|
+
options={options}
|
|
144
|
+
/>
|
|
145
|
+
</div>
|
|
146
|
+
),
|
|
147
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -7,7 +7,7 @@ import type { ImageSize } from '../model/ImageSize';
|
|
|
7
7
|
import type { ImgAlignment, ImgSource, Picture } from '../model/Picture';
|
|
8
8
|
import { isPictureSizeEmpty } from '../utils/isPictureSizeEmpty';
|
|
9
9
|
import type { TransformationOptions } from './TransformationOptions';
|
|
10
|
-
import {
|
|
10
|
+
import { transformImgPath } from './transformImgPath';
|
|
11
11
|
|
|
12
12
|
const mkdir = util.promisify(fs.mkdir);
|
|
13
13
|
|
|
@@ -59,21 +59,18 @@ export async function transformImg({
|
|
|
59
59
|
chain = chain.toFormat(format, options);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
contentDir,
|
|
65
|
-
`${path.dirname(pagePath)}/${transformedSrc}`,
|
|
66
|
-
)}`;
|
|
62
|
+
const transformedImgPath = transformImgPath(src, { pageDir, contentDir }, transformationOptions);
|
|
63
|
+
const imgPublicPath = path.join(publicDir, transformedImgPath);
|
|
67
64
|
|
|
68
|
-
await mkdir(path.dirname(
|
|
65
|
+
await mkdir(path.dirname(imgPublicPath), { recursive: true });
|
|
69
66
|
|
|
70
67
|
try {
|
|
71
|
-
await chain.toFile(
|
|
68
|
+
await chain.toFile(imgPublicPath);
|
|
72
69
|
} catch (e) {
|
|
73
70
|
console.error(e);
|
|
74
71
|
}
|
|
75
72
|
|
|
76
|
-
return
|
|
73
|
+
return transformedImgPath;
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
function createBackgroundImageChain({ width, height }: ImageSize) {
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import type { ImgSource } from '../model/Picture';
|
|
3
|
-
import type { TransformationOptions } from './TransformationOptions';
|
|
4
3
|
import { isPictureSizeEmpty } from '../utils/isPictureSizeEmpty';
|
|
4
|
+
import type { TransformationOptions } from './TransformationOptions';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
interface DirectoryParams {
|
|
7
|
+
pageDir: string;
|
|
8
|
+
contentDir: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function transformImgPath(
|
|
7
12
|
src: string,
|
|
13
|
+
{ pageDir, contentDir }: DirectoryParams,
|
|
8
14
|
{ format, size }: TransformationOptions & ImgSource,
|
|
9
15
|
): string {
|
|
10
16
|
const noTransform = isPictureSizeEmpty(size) && !format;
|
|
@@ -12,10 +18,13 @@ export function transformSrc(
|
|
|
12
18
|
return src;
|
|
13
19
|
}
|
|
14
20
|
|
|
21
|
+
const imgPath = path.relative(contentDir, path.join(pageDir, src));
|
|
22
|
+
const imgDir = path.dirname(imgPath);
|
|
23
|
+
|
|
15
24
|
const fileName = path.basename(src, path.extname(src));
|
|
16
25
|
const fileSizes = [size?.width, size?.height].filter(Boolean);
|
|
17
26
|
const suffix = fileSizes.length ? `-${fileSizes.join('-')}` : '';
|
|
18
27
|
const ext = format ? String(format) : 'webp';
|
|
19
28
|
|
|
20
|
-
return `${fileName}${suffix}.${ext}
|
|
29
|
+
return path.join(imgDir, `${fileName}${suffix}.${ext}`);
|
|
21
30
|
}
|
|
@@ -19,10 +19,7 @@ export async function transformPicture(
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
const { width, height } = await sharp(
|
|
22
|
-
path.resolve(
|
|
23
|
-
options.publicDir,
|
|
24
|
-
path.relative(options.contentDir, `${path.dirname(pagePath)}/${transformedPicture}`),
|
|
25
|
-
),
|
|
22
|
+
path.resolve(options.publicDir, transformedPicture),
|
|
26
23
|
).metadata();
|
|
27
24
|
|
|
28
25
|
const containerSize = width && height ? { width, height } : undefined;
|
|
@@ -40,10 +37,10 @@ export async function transformPicture(
|
|
|
40
37
|
|
|
41
38
|
return {
|
|
42
39
|
...picture,
|
|
43
|
-
src: transformedPicture,
|
|
40
|
+
src: path.join('/', transformedPicture),
|
|
44
41
|
sources: transformedSources.map((_, i) => ({
|
|
45
42
|
...sources[i],
|
|
46
|
-
src: _,
|
|
43
|
+
src: path.join('/', _),
|
|
47
44
|
size: { width, height },
|
|
48
45
|
})),
|
|
49
46
|
};
|
|
@@ -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
|
+
};
|
package/src/model/JSXBlock.ts
CHANGED
|
@@ -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 ? (
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
-
import { Text } from '
|
|
2
|
+
import { Text } from '../Text/Text';
|
|
3
3
|
|
|
4
4
|
interface SlideCheckboxProps {
|
|
5
|
-
|
|
5
|
+
value?: boolean;
|
|
6
6
|
text?: string;
|
|
7
|
-
|
|
7
|
+
type?: 'checkbox' | 'radio';
|
|
8
|
+
onChange?: (value: boolean) => void;
|
|
8
9
|
}
|
|
9
|
-
export const SlideCheckbox = JSX<SlideCheckboxProps>(
|
|
10
|
-
|
|
11
|
-
role="checkbox"
|
|
12
|
-
aria-checked={checked}
|
|
13
|
-
className="flex justify-start items-center w-full cursor-pointer mb-4"
|
|
14
|
-
onClick={() => onClick && onClick()}
|
|
15
|
-
>
|
|
10
|
+
export const SlideCheckbox = JSX<SlideCheckboxProps>(
|
|
11
|
+
({ value = false, text, type = 'checkbox', onChange }) => (
|
|
16
12
|
<div
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
role={type}
|
|
14
|
+
aria-checked={value}
|
|
15
|
+
className="flex justify-start items-center w-full cursor-pointer mb-4"
|
|
16
|
+
onClick={() => onChange && onChange(!value)}
|
|
20
17
|
>
|
|
21
18
|
<div
|
|
22
|
-
className={`
|
|
23
|
-
|
|
19
|
+
className={`relative flex-shrink-0 duration-300 w-9 h-5 mr-3 rounded-2xl ${
|
|
20
|
+
value ? 'bg-primary-main' : 'bg-main-divider'
|
|
24
21
|
}`}
|
|
25
|
-
|
|
22
|
+
>
|
|
23
|
+
<div
|
|
24
|
+
className={`absolute opacity-80 duration-500 top-0.5 w-4 h-4 bg-white rounded-full ${
|
|
25
|
+
value ? 'left-[50%]' : 'left-[5%]'
|
|
26
|
+
}`}
|
|
27
|
+
/>
|
|
28
|
+
</div>
|
|
29
|
+
<div>
|
|
30
|
+
<Text size="text-m" font="font-light" color="text-primary-text">
|
|
31
|
+
{text}
|
|
32
|
+
</Text>
|
|
33
|
+
</div>
|
|
26
34
|
</div>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
{text}
|
|
30
|
-
</Text>
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
));
|
|
35
|
+
),
|
|
36
|
+
);
|