@redneckz/wildless-cms-uni-blocks 0.14.982 → 0.14.984

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 (84) hide show
  1. package/bundle/blocks.schema.json +1 -1
  2. package/bundle/bundle.umd.js +21 -18
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/RichTextBlock/RichTextBlock.d.ts +5 -1
  5. package/bundle/components/RichTextBlock/RichTextBlockContent.d.ts +2 -1
  6. package/bundle/utils/getFormatDynamicText.d.ts +2 -0
  7. package/bundle/utils/getQueryParamValue.d.ts +1 -0
  8. package/dist/components/ProductBlock/ProductBlock.js +2 -13
  9. package/dist/components/ProductBlock/ProductBlock.js.map +1 -1
  10. package/dist/components/RichTextBlock/RichTextBlock.d.ts +5 -1
  11. package/dist/components/RichTextBlock/RichTextBlock.js +6 -4
  12. package/dist/components/RichTextBlock/RichTextBlock.js.map +1 -1
  13. package/dist/components/RichTextBlock/RichTextBlockContent.d.ts +2 -1
  14. package/dist/retail/components/Fields/RegionRetailField.js +2 -2
  15. package/dist/retail/components/Fields/RegionRetailField.js.map +1 -1
  16. package/dist/utils/getFormatDynamicText.d.ts +2 -0
  17. package/dist/utils/getFormatDynamicText.js +13 -0
  18. package/dist/utils/getFormatDynamicText.js.map +1 -0
  19. package/dist/utils/getQueryParamValue.d.ts +1 -0
  20. package/dist/utils/getQueryParamValue.js +8 -0
  21. package/dist/utils/getQueryParamValue.js.map +1 -0
  22. package/lib/components/ProductBlock/ProductBlock.js +2 -13
  23. package/lib/components/ProductBlock/ProductBlock.js.map +1 -1
  24. package/lib/components/RichTextBlock/RichTextBlock.d.ts +5 -1
  25. package/lib/components/RichTextBlock/RichTextBlock.fixture.d.ts +1 -0
  26. package/lib/components/RichTextBlock/RichTextBlock.js +6 -4
  27. package/lib/components/RichTextBlock/RichTextBlock.js.map +1 -1
  28. package/lib/components/RichTextBlock/RichTextBlockContent.d.ts +2 -1
  29. package/lib/retail/components/Fields/RegionRetailField.js +2 -2
  30. package/lib/retail/components/Fields/RegionRetailField.js.map +1 -1
  31. package/lib/utils/getFormatDynamicText.d.ts +2 -0
  32. package/lib/utils/getFormatDynamicText.js +10 -0
  33. package/lib/utils/getFormatDynamicText.js.map +1 -0
  34. package/lib/utils/getQueryParamValue.d.ts +1 -0
  35. package/lib/utils/getQueryParamValue.js +5 -0
  36. package/lib/utils/getQueryParamValue.js.map +1 -0
  37. package/mobile/bundle/bundle.umd.js +21 -18
  38. package/mobile/bundle/bundle.umd.min.js +1 -1
  39. package/mobile/bundle/components/RichTextBlock/RichTextBlock.d.ts +5 -1
  40. package/mobile/bundle/components/RichTextBlock/RichTextBlockContent.d.ts +2 -1
  41. package/mobile/bundle/utils/getFormatDynamicText.d.ts +2 -0
  42. package/mobile/bundle/utils/getQueryParamValue.d.ts +1 -0
  43. package/mobile/dist/components/ProductBlock/ProductBlock.js +2 -13
  44. package/mobile/dist/components/ProductBlock/ProductBlock.js.map +1 -1
  45. package/mobile/dist/components/RichTextBlock/RichTextBlock.d.ts +5 -1
  46. package/mobile/dist/components/RichTextBlock/RichTextBlock.js +6 -4
  47. package/mobile/dist/components/RichTextBlock/RichTextBlock.js.map +1 -1
  48. package/mobile/dist/components/RichTextBlock/RichTextBlockContent.d.ts +2 -1
  49. package/mobile/dist/retail/components/Fields/RegionRetailField.js +2 -2
  50. package/mobile/dist/retail/components/Fields/RegionRetailField.js.map +1 -1
  51. package/mobile/dist/utils/getFormatDynamicText.d.ts +2 -0
  52. package/mobile/dist/utils/getFormatDynamicText.js +13 -0
  53. package/mobile/dist/utils/getFormatDynamicText.js.map +1 -0
  54. package/mobile/dist/utils/getQueryParamValue.d.ts +1 -0
  55. package/mobile/dist/utils/getQueryParamValue.js +8 -0
  56. package/mobile/dist/utils/getQueryParamValue.js.map +1 -0
  57. package/mobile/lib/components/ProductBlock/ProductBlock.js +2 -13
  58. package/mobile/lib/components/ProductBlock/ProductBlock.js.map +1 -1
  59. package/mobile/lib/components/RichTextBlock/RichTextBlock.d.ts +5 -1
  60. package/mobile/lib/components/RichTextBlock/RichTextBlock.js +6 -4
  61. package/mobile/lib/components/RichTextBlock/RichTextBlock.js.map +1 -1
  62. package/mobile/lib/components/RichTextBlock/RichTextBlockContent.d.ts +2 -1
  63. package/mobile/lib/retail/components/Fields/RegionRetailField.js +2 -2
  64. package/mobile/lib/retail/components/Fields/RegionRetailField.js.map +1 -1
  65. package/mobile/lib/utils/getFormatDynamicText.d.ts +2 -0
  66. package/mobile/lib/utils/getFormatDynamicText.js +10 -0
  67. package/mobile/lib/utils/getFormatDynamicText.js.map +1 -0
  68. package/mobile/lib/utils/getQueryParamValue.d.ts +1 -0
  69. package/mobile/lib/utils/getQueryParamValue.js +5 -0
  70. package/mobile/lib/utils/getQueryParamValue.js.map +1 -0
  71. package/mobile/src/components/ProductBlock/ProductBlock.tsx +2 -24
  72. package/mobile/src/components/RichTextBlock/RichTextBlock.tsx +19 -5
  73. package/mobile/src/components/RichTextBlock/RichTextBlockContent.ts +2 -1
  74. package/mobile/src/retail/components/Fields/RegionRetailField.tsx +2 -4
  75. package/mobile/src/utils/getFormatDynamicText.ts +18 -0
  76. package/mobile/src/utils/getQueryParamValue.ts +5 -0
  77. package/package.json +1 -1
  78. package/src/components/ProductBlock/ProductBlock.tsx +2 -24
  79. package/src/components/RichTextBlock/RichTextBlock.fixture.tsx +18 -1
  80. package/src/components/RichTextBlock/RichTextBlock.tsx +19 -5
  81. package/src/components/RichTextBlock/RichTextBlockContent.ts +2 -1
  82. package/src/retail/components/Fields/RegionRetailField.tsx +2 -4
  83. package/src/utils/getFormatDynamicText.ts +18 -0
  84. package/src/utils/getQueryParamValue.ts +5 -0
@@ -1,17 +1,31 @@
1
- import { JSX } from '@redneckz/uni-jsx';
1
+ import type { JSONRefObject } from '../../data/JSONRefObject';
2
2
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
3
3
  import { RichText } from '../../ui-kit/RichText/RichText';
4
+ import { UniBlock } from '../../UniBlock/UniBlock';
4
5
  import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
6
+ import { getFormatDynamicText } from '../../utils/getFormatDynamicText';
5
7
  import { type RichTextBlockContent } from './RichTextBlockContent';
6
8
 
7
- interface RichTextBlockProps extends RichTextBlockContent, UniBlockProps {}
9
+ interface RichTextBlockProps extends RichTextBlockContent, UniBlockProps {
10
+ dynamicTextSource?: JSONRefObject & {
11
+ list?: Record<string, string>[];
12
+ };
13
+ }
8
14
 
9
- export const RichTextBlock = JSX<RichTextBlockProps>((props) => {
10
- const { __html, richVersion = '', ...rest } = props;
15
+ export const RichTextBlock = UniBlock<RichTextBlockProps>((props) => {
16
+ const {
17
+ __html,
18
+ dynamicQueryParamText = {},
19
+ dynamicTextSource,
20
+ richVersion = '',
21
+ ...rest
22
+ } = props;
23
+
24
+ const formatText = getFormatDynamicText(dynamicQueryParamText, dynamicTextSource?.list, __html);
11
25
 
12
26
  return (
13
27
  <BlockWrapper defaultPadding="p-0" {...rest}>
14
- <RichText __html={__html} richVersion={richVersion} />
28
+ <RichText __html={formatText} richVersion={richVersion} />
15
29
  </BlockWrapper>
16
30
  );
17
31
  });
@@ -1,7 +1,8 @@
1
+ import { type DynamicTextProps } from '../../model/HeadlineType';
1
2
  import { type RichTextProps } from '../../ui-kit/RichText/RichTextProps';
2
3
  import { type UniBlockContent } from '../../UniBlock/UniBlockProps';
3
4
 
4
5
  /**
5
6
  * @title Форматированный текст
6
7
  */
7
- export type RichTextBlockContent = UniBlockContent & RichTextProps;
8
+ export type RichTextBlockContent = UniBlockContent & RichTextProps & DynamicTextProps;
@@ -60,13 +60,11 @@ export const RegionRetailField = JSX<CustomFieldProps>(({ field, input }) => {
60
60
  handleChangeOffice?.(DEFAULT_BIBLIOLOBUS_VALUES.office);
61
61
  handleChangeRegionHasDelivery?.(checkRegionDeliveryStatus(DEFAULT_BIBLIOLOBUS_VALUES.region));
62
62
  handleChangeMethodObtain?.('office');
63
- }
64
- if (isSalaryCard) {
63
+ } else if (isSalaryCard) {
65
64
  handleChangeRegion?.(DEFAULT_SALARY_CARD_VALUES.region);
66
65
  handleChangeOffice?.(DEFAULT_SALARY_CARD_VALUES.office);
67
66
  handleChangeMethodObtain?.('office');
68
- }
69
- if (regionRetail) {
67
+ } else if (regionRetail) {
70
68
  const regionHasDelivery = checkRegionDeliveryStatus(regionRetail);
71
69
  handleChangeRegionHasDelivery?.(regionHasDelivery);
72
70
  handleChangeMethodObtain?.(regionHasDelivery ? 'courier' : 'office');
@@ -0,0 +1,18 @@
1
+ import type { DynamicText } from '../model/HeadlineType';
2
+ import { getQueryParamValue } from './getQueryParamValue';
3
+ import { saveSessionQuery } from './getSessionQuery';
4
+
5
+ export const getFormatDynamicText = (
6
+ dynamicQueryParamText: DynamicText = {},
7
+ valuesList: Record<string, string>[] = [],
8
+ text = '',
9
+ ) => {
10
+ const { queryParam, value } = dynamicQueryParamText;
11
+ const sessionQuery = saveSessionQuery();
12
+ const utmValue = getQueryParamValue(queryParam ?? 'utm_source', sessionQuery);
13
+ const dynamicValue = valuesList.find(
14
+ (item) => item?.id?.toLowerCase() === utmValue?.toLowerCase(),
15
+ )?.value;
16
+
17
+ return dynamicValue ? text?.replace(String(value), dynamicValue) : text;
18
+ };
@@ -0,0 +1,5 @@
1
+ export const getQueryParamValue = (queryParam: string, queryString: string) => {
2
+ const params = new URLSearchParams(queryString);
3
+
4
+ return params.get(queryParam);
5
+ };