@redneckz/wildless-cms-uni-blocks 0.9.10 → 0.9.11

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 (50) hide show
  1. package/bundle/blocks.schema.json +1 -1
  2. package/bundle/bundle.umd.js +15 -11
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/Filtration/FiltrationContent.d.ts +18 -8
  5. package/dist/components/Filtration/Filtration.js +1 -1
  6. package/dist/components/Filtration/Filtration.js.map +1 -1
  7. package/dist/components/Filtration/FiltrationContent.d.ts +18 -8
  8. package/dist/components/Filtration/FiltrationInner.js +9 -5
  9. package/dist/components/Filtration/FiltrationInner.js.map +1 -1
  10. package/dist/components/Filtration/renderFormItem.js +6 -5
  11. package/dist/components/Filtration/renderFormItem.js.map +1 -1
  12. package/lib/common.css +1 -1
  13. package/lib/components/Filtration/Filtration.js +1 -1
  14. package/lib/components/Filtration/Filtration.js.map +1 -1
  15. package/lib/components/Filtration/FiltrationContent.d.ts +18 -8
  16. package/lib/components/Filtration/FiltrationInner.js +9 -5
  17. package/lib/components/Filtration/FiltrationInner.js.map +1 -1
  18. package/lib/components/Filtration/renderFormItem.js +6 -5
  19. package/lib/components/Filtration/renderFormItem.js.map +1 -1
  20. package/mobile/bundle/bundle.umd.js +1 -1
  21. package/mobile/bundle/bundle.umd.min.js +1 -1
  22. package/mobile/bundle/components/Filtration/FiltrationContent.d.ts +18 -8
  23. package/mobile/dist/components/Filtration/Filtration.js +1 -1
  24. package/mobile/dist/components/Filtration/Filtration.js.map +1 -1
  25. package/mobile/dist/components/Filtration/FiltrationContent.d.ts +18 -8
  26. package/mobile/dist/components/Filtration/FiltrationInner.js +9 -5
  27. package/mobile/dist/components/Filtration/FiltrationInner.js.map +1 -1
  28. package/mobile/dist/components/Filtration/renderFormItem.js +6 -5
  29. package/mobile/dist/components/Filtration/renderFormItem.js.map +1 -1
  30. package/mobile/lib/components/Filtration/Filtration.js +1 -1
  31. package/mobile/lib/components/Filtration/Filtration.js.map +1 -1
  32. package/mobile/lib/components/Filtration/FiltrationContent.d.ts +18 -8
  33. package/mobile/lib/components/Filtration/FiltrationInner.js +9 -5
  34. package/mobile/lib/components/Filtration/FiltrationInner.js.map +1 -1
  35. package/mobile/lib/components/Filtration/renderFormItem.js +6 -5
  36. package/mobile/lib/components/Filtration/renderFormItem.js.map +1 -1
  37. package/mobile/src/components/Filtration/Filtration.example.json +39 -19
  38. package/mobile/src/components/Filtration/Filtration.tsx +3 -8
  39. package/mobile/src/components/Filtration/FiltrationContent.ts +19 -8
  40. package/mobile/src/components/Filtration/FiltrationInner.tsx +31 -12
  41. package/mobile/src/components/Filtration/renderFormItem.tsx +20 -20
  42. package/mobile/src/components/RichTextBlock/RichTextBlock.example.json +1 -1
  43. package/package.json +1 -1
  44. package/src/components/Filtration/Filtration.example.json +39 -19
  45. package/src/components/Filtration/Filtration.fixture.tsx +36 -20
  46. package/src/components/Filtration/Filtration.tsx +3 -8
  47. package/src/components/Filtration/FiltrationContent.ts +19 -8
  48. package/src/components/Filtration/FiltrationInner.tsx +31 -12
  49. package/src/components/Filtration/renderFormItem.tsx +20 -20
  50. package/src/components/RichTextBlock/RichTextBlock.example.json +1 -1
@@ -15,19 +15,14 @@ export const Filtration: JSXBlock<FiltrationProps> = JSX<FiltrationProps>(
15
15
  const { formState, register, resetForm } = useForm();
16
16
 
17
17
  return (
18
- <BlockWrapper className={style('p-9', className)} {...rest}>
19
- <form className="flex justify-between">
18
+ <BlockWrapper className={style(className)} version="transparent" {...rest}>
19
+ <form className="flex justify-between bg-white p-9 mb-1">
20
20
  <div className="flex gap-11">
21
21
  {Object.keys(filtrationSchema).map(renderFormItem(filtrationSchema, register))}
22
22
  </div>
23
23
  {resetButton ? (
24
24
  <div>
25
- <Button
26
- className="w-72"
27
- text={resetButton.text}
28
- version={resetButton.buttonVersion}
29
- onClick={resetForm}
30
- />
25
+ <Button className="w-72" onClick={resetForm} {...resetButton} />
31
26
  </div>
32
27
  ) : null}
33
28
  </form>
@@ -1,4 +1,5 @@
1
1
  import type { ButtonVersion } from '../../model/ButtonVersion';
2
+ import type { DescriptionProps, TitleProps } from '../../model/HeadlineType';
2
3
 
3
4
  /**
4
5
  * @title Заголовок
@@ -33,6 +34,7 @@ export type StringArray = {
33
34
  * @hidden
34
35
  */
35
36
  type?: 'array';
37
+ /** @title */
36
38
  items?: {
37
39
  /**
38
40
  * @default string
@@ -47,13 +49,13 @@ export type StringArray = {
47
49
  // TODO: Make customizable to implement arbitrary filtration blocks
48
50
  export type FiltrationSchema = {
49
51
  /** @title Тип недвижимости */
50
- propertyType?: StringEnum;
52
+ propertyType?: StringArray;
51
53
  /** @title Этап строительства */
52
- stage?: StringEnum;
54
+ stage?: StringArray;
53
55
  /** @title Категории */
54
- categories?: StringEnum;
56
+ categories?: StringArray;
55
57
  /** @title Дополнительно */
56
- extraOptions?: StringEnum;
58
+ extraOptions?: StringArray;
57
59
  };
58
60
 
59
61
  /**
@@ -67,14 +69,24 @@ export type ResetButton = {
67
69
  /**
68
70
  * @title Цвет кнопки
69
71
  */
70
- buttonVersion: ButtonVersion;
72
+ version: ButtonVersion;
71
73
  };
72
74
 
75
+ /**
76
+ * @title Плитка "Не найдено"
77
+ */
78
+ export type NotFound = TitleProps & DescriptionProps;
79
+
73
80
  export interface FiltrationInnerContent {
74
- /** @title Название кнопки */
81
+ /** @title Название сворачивающейся кнопки */
75
82
  label?: string;
76
- /** @title Количество отображаемых предметов */
83
+ /**
84
+ * @title Количество отображаемых предметов
85
+ * @minimum 1
86
+ */
77
87
  topItemsCount?: number;
88
+ resetButton?: ResetButton;
89
+ notFound?: NotFound;
78
90
  }
79
91
 
80
92
  /**
@@ -83,5 +95,4 @@ export interface FiltrationInnerContent {
83
95
  export interface FiltrationContent extends FiltrationInnerContent {
84
96
  /** @title Параметры фильтрации */
85
97
  filtrationSchema?: FiltrationSchema;
86
- resetButton?: ResetButton;
87
98
  }
@@ -5,10 +5,11 @@ import type { UniBlockProps } from '../../model/JSXBlock';
5
5
  import { DefaultFoldButton } from '../../ui-kit/Foldable/DefaultFoldButton';
6
6
  import { Foldable } from '../../ui-kit/Foldable/Foldable';
7
7
  import { FoldableSection } from '../../ui-kit/Foldable/FoldableSection';
8
+ import { Paragraph } from '../../ui-kit/Paragraph/Paragraph';
9
+ import { Text } from '../../ui-kit/Text/Text';
8
10
  import { style } from '../../utils/style';
9
- import { ErrorBlock } from '../ErrorBlock/ErrorBlock';
10
11
  import { checkShouldRenderBlock } from './checkShouldRenderBlock';
11
- import type { FiltrationInnerContent } from './FiltrationContent';
12
+ import type { FiltrationInnerContent, NotFound } from './FiltrationContent';
12
13
 
13
14
  const ICONS: IconName[] = ['ArrowDownIcon', 'ArrowUpIcon'];
14
15
 
@@ -19,7 +20,7 @@ interface FiltrationInnerProps extends FiltrationInnerContent, UniBlockProps {
19
20
  }
20
21
 
21
22
  export const FiltrationInner = JSX<FiltrationInnerProps>(
22
- ({ label = '', filtrationState = {}, topItemsCount = 0, block, ...rest }) => {
23
+ ({ label = '', filtrationState = {}, topItemsCount = 0, block, notFound, ...rest }) => {
23
24
  const blocksToRender =
24
25
  block?.blocks?.filter((b) => checkShouldRenderBlock(filtrationState, b.content || {})) || [];
25
26
 
@@ -30,28 +31,27 @@ export const FiltrationInner = JSX<FiltrationInnerProps>(
30
31
 
31
32
  return (
32
33
  <div>
33
- <div className={style(blocksToRender.length ? 'hidden' : '')}>
34
- <ErrorBlock
35
- error={{ errorContentType: 'Image' }}
36
- title="Нет подходящей ипотечной программы"
37
- subtitle="Попробуйте очистить фильтры"
38
- />
34
+ <div className={style(blocksToRender.length ? 'hidden' : 'block')}>
35
+ {notFound ? renderNotFound(notFound) : null}
39
36
  </div>
40
37
  <div className={style(blocksToRender.length ? '' : 'hidden')}>
41
- <div className={resultsGridStyle}>
38
+ <div className={style('mb-1', resultsGridStyle)}>
42
39
  {renderBlocksList(visibleBlocks, { ...rest.options, parent: block })}
43
40
  </div>
44
41
  <Foldable
45
42
  renderFoldableSection={({ isUnfolded }) => {
46
43
  return (
47
- <FoldableSection className={resultsGridStyle} isUnfolded={isUnfolded}>
44
+ <FoldableSection
45
+ className={style(resultsGridStyle, isUnfolded ? 'mb-1' : '')}
46
+ isUnfolded={isUnfolded}
47
+ >
48
48
  {renderBlocksList(hiddenBlocks, { ...rest.options, parent: block })}
49
49
  </FoldableSection>
50
50
  );
51
51
  }}
52
52
  renderFoldButton={({ isUnfolded, onToggle }) => (
53
53
  <DefaultFoldButton
54
- className={style('mt-11', topItemsCount < 1 ? 'hidden' : '')}
54
+ className={style(topItemsCount < 1 ? 'hidden' : '')}
55
55
  disabled={!hiddenBlocks?.length}
56
56
  label={label}
57
57
  icon={ICONS[Number(isUnfolded)]}
@@ -65,3 +65,22 @@ export const FiltrationInner = JSX<FiltrationInnerProps>(
65
65
  );
66
66
  },
67
67
  );
68
+
69
+ function renderNotFound({ title, description }: NotFound) {
70
+ return (
71
+ <div className="bg-white py-20">
72
+ {title ? (
73
+ <div className="mb-2">
74
+ <Paragraph align="text-center">
75
+ <Text size="text-h4">{title}</Text>
76
+ </Paragraph>
77
+ </div>
78
+ ) : null}
79
+ {description ? (
80
+ <Paragraph size="text-xl" font="font-light" align="text-center">
81
+ {description}
82
+ </Paragraph>
83
+ ) : null}
84
+ </div>
85
+ );
86
+ }
@@ -1,7 +1,7 @@
1
1
  import type { FormElementRegisterer } from '../../hooks/useForm';
2
2
  import { SlideCheckboxGroup } from '../../ui-kit/SlideCheckboxGroup/SlideCheckboxGroup';
3
3
  import { Text } from '../../ui-kit/Text/Text';
4
- import type { FiltrationSchema, StringEnum } from './FiltrationContent';
4
+ import type { FiltrationSchema, StringArray } from './FiltrationContent';
5
5
 
6
6
  export const renderFormItem =
7
7
  (filtrationSchema: FiltrationSchema, register: FormElementRegisterer) => (key: string) => {
@@ -9,28 +9,28 @@ export const renderFormItem =
9
9
  const type = item?.type;
10
10
 
11
11
  switch (type) {
12
- case 'string':
13
- return renderRadioButtons(key, register)(item);
12
+ case 'array':
13
+ return renderCheckboxes(key, register)(item);
14
14
  default:
15
15
  return null;
16
16
  }
17
17
  };
18
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] || '' })) || [];
19
+ const renderCheckboxes = (key: string, register: FormElementRegisterer) => (item?: StringArray) => {
20
+ const options =
21
+ item?.items?.enum?.map((e, i) => ({ value: e, title: item?.items?.enumNames?.[i] || '' })) ||
22
+ [];
23
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
- };
24
+ return (
25
+ <div 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 {...register(key)} />
34
+ </div>
35
+ );
36
+ };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "content": {
3
- "__html": "<p class=\"h1\">Заголовок 1</p>\n<p class=\"h2\">Заголовок 2</p>\n<p class=\"h3\">Заголовок 3</p>\n<p class=\"h4\">Заголовок 4</p>\n<p class=\"h5\">Заголовок 5</p>\n<p class=\"h6\">Заголовок 6</p>\n<p>Параграф, в котором много текста и даже <a href=\"#\">ссылка</a></p>\n<p><strong>Жирный текст</strong>, <em>Наклонный текст</em></p>\n<ul>\n <li>Список с точками</li>\n <li>Список с точками</li>\n</ul>\n<ol>\n <li>Нумерованный список</li>\n <li>Нумерованный список</li>\n</ol>\n"
3
+ "__html": "<h1>Заголовок 1</h1>\n<h2>Заголовок 2</h2>\n<h3>Заголовок 3</h3>\n<h4>Заголовок 4</h4>\n<h5>Заголовок 5</h5>\n<h6>Заголовок 6</h6>\n<p>Параграф, в котором много текста и даже <a href=\"#\">ссылка</a></p>\n<p><strong>Жирный текст</strong>, <em>Наклонный текст</em></p>\n<ul>\n <li>Список с точками</li>\n <li>Список с точками</li>\n</ul>\n<ol>\n <li>Нумерованный список</li>\n <li>Нумерованный список</li>\n</ol>\n"
4
4
  }
5
5
  }