@doyourjob/gravity-ui-page-constructor 5.31.28 → 5.31.30

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.
@@ -9,12 +9,12 @@ const components_1 = require("../../components");
9
9
  const utils_1 = require("../../utils");
10
10
  const b = (0, utils_1.block)('marquee-links-block');
11
11
  const MarqueeLinksBlock = ({ title, description, textAlign = 'left', speed = 10, items, }) => {
12
- const renderItem = (0, react_1.useCallback)((item) => {
12
+ const renderItem = (0, react_1.useCallback)((item, index) => {
13
13
  if (item.url) {
14
- return (react_1.default.createElement(uikit_1.Link, { key: item.src, href: item.url, extraProps: { tabIndex: -1 } },
14
+ return (react_1.default.createElement(uikit_1.Link, { key: item.src + index, href: item.url, extraProps: { tabIndex: -1 } },
15
15
  react_1.default.createElement(components_1.Image, { src: item.src, alt: "" })));
16
16
  }
17
- return react_1.default.createElement(components_1.Image, { src: item.src, key: item.src, alt: "" });
17
+ return react_1.default.createElement(components_1.Image, { src: item.src + index, key: item.src, alt: "" });
18
18
  }, []);
19
19
  if (!items.length)
20
20
  return null;
@@ -1,3 +1,3 @@
1
1
  import { RelevantPostsBlockProps } from '../../models';
2
- export declare const RelevantPosts: ({ title, description, date, tags, services, pinnedPost, }: RelevantPostsBlockProps) => JSX.Element;
2
+ export declare const RelevantPosts: ({ title, description, date, dateStart, dateEnd, tags, services, pinnedPost, }: RelevantPostsBlockProps) => JSX.Element;
3
3
  export default RelevantPosts;
@@ -14,7 +14,7 @@ const colSizes = {
14
14
  lg: 2,
15
15
  sm: 1,
16
16
  };
17
- const RelevantPosts = ({ title, description, date, tags, services, pinnedPost, }) => {
17
+ const RelevantPosts = ({ title, description, date, dateStart, dateEnd, tags, services, pinnedPost, }) => {
18
18
  const [now, setNow] = react_1.default.useState(null);
19
19
  const { posts } = (0, react_1.useContext)(relevantPostsContext_1.RelevantPostsContext);
20
20
  (0, react_1.useEffect)(() => {
@@ -27,27 +27,34 @@ const RelevantPosts = ({ title, description, date, tags, services, pinnedPost, }
27
27
  var _a, _b;
28
28
  const itemDate = new Date(item.dateTime);
29
29
  let isDateMatch = true;
30
- if (date === 'today') {
31
- const startOfToday = new Date(now);
32
- startOfToday.setHours(0, 0, 0, 0);
33
- const endOfToday = new Date(now);
34
- endOfToday.setHours(23, 59, 59, 999);
35
- isDateMatch = itemDate >= startOfToday && itemDate <= endOfToday;
36
- }
37
- else if (date === 'week') {
38
- const weekAgo = new Date(now);
39
- weekAgo.setDate(now.getDate() - 7);
40
- isDateMatch = itemDate >= weekAgo && itemDate <= now;
41
- }
42
- else if (date === 'month') {
43
- const monthAgo = new Date(now);
44
- monthAgo.setMonth(now.getMonth() - 1);
45
- isDateMatch = itemDate >= monthAgo && itemDate <= now;
46
- }
47
- else if (typeof date === 'object' && (date.start || date.end)) {
48
- const startDate = date.start ? new Date(date.start) : new Date('1970-01-01');
49
- const endDate = date.end ? new Date(date.end) : now;
50
- isDateMatch = itemDate >= startDate && itemDate <= endDate;
30
+ switch (date) {
31
+ case 'today': {
32
+ const startOfToday = new Date(now);
33
+ startOfToday.setHours(0, 0, 0, 0);
34
+ const endOfToday = new Date(now);
35
+ endOfToday.setHours(23, 59, 59, 999);
36
+ isDateMatch = itemDate >= startOfToday && itemDate <= endOfToday;
37
+ break;
38
+ }
39
+ case 'week': {
40
+ const weekAgo = new Date(now);
41
+ weekAgo.setDate(now.getDate() - 7);
42
+ isDateMatch = itemDate >= weekAgo && itemDate <= now;
43
+ break;
44
+ }
45
+ case 'month': {
46
+ const monthAgo = new Date(now);
47
+ monthAgo.setMonth(now.getMonth() - 1);
48
+ isDateMatch = itemDate >= monthAgo && itemDate <= now;
49
+ break;
50
+ }
51
+ default: {
52
+ if (dateStart || dateEnd) {
53
+ const startDate = dateStart ? new Date(dateStart) : new Date('1970-01-01');
54
+ const endDate = dateEnd ? new Date(dateEnd) : now;
55
+ isDateMatch = itemDate >= startDate && itemDate <= endDate;
56
+ }
57
+ }
51
58
  }
52
59
  // Фильтрация по тегам
53
60
  const isTagMatch = !tags || tags.length === 0 || ((_a = item.tags) === null || _a === void 0 ? void 0 : _a.some((tag) => tags.includes(tag.slug)));
@@ -57,7 +64,7 @@ const RelevantPosts = ({ title, description, date, tags, services, pinnedPost, }
57
64
  ((_b = item.services) === null || _b === void 0 ? void 0 : _b.some((s) => services.includes(s)));
58
65
  return isDateMatch && isTagMatch && isServiceMatch;
59
66
  });
60
- }, [now, posts, date, tags, services]);
67
+ }, [now, posts, date, tags, services, dateStart, dateEnd]);
61
68
  const [findedPinnedPost, restPosts] = (0, react_1.useMemo)(() => {
62
69
  if (!pinnedPost || filteredPosts.length === 0)
63
70
  return [undefined, filteredPosts];
@@ -4,28 +4,14 @@ export declare const RelevantPostsBlock: {
4
4
  required: never[];
5
5
  properties: {
6
6
  date: {
7
- oneOf: ({
8
- type: string;
9
- enum: string[];
10
- additionalProperties?: undefined;
11
- required?: undefined;
12
- properties?: undefined;
13
- optionName?: undefined;
14
- } | {
15
- type: string;
16
- additionalProperties: boolean;
17
- required: never[];
18
- properties: {
19
- start: {
20
- type: string;
21
- };
22
- end: {
23
- type: string;
24
- };
25
- };
26
- optionName: string;
27
- enum?: undefined;
28
- })[];
7
+ type: string;
8
+ enum: string[];
9
+ };
10
+ dateStart: {
11
+ type: string;
12
+ };
13
+ dateEnd: {
14
+ type: string;
29
15
  };
30
16
  tags: {
31
17
  type: string;
@@ -7,26 +7,12 @@ exports.RelevantPostsBlock = {
7
7
  additionalProperties: false,
8
8
  required: [],
9
9
  properties: Object.assign(Object.assign(Object.assign({}, common_1.BaseProps), common_1.BlockHeaderProps), { date: {
10
- oneOf: [
11
- {
12
- type: 'string',
13
- enum: ['today', 'week', 'month'],
14
- },
15
- {
16
- type: 'object',
17
- additionalProperties: false,
18
- required: [],
19
- properties: {
20
- start: {
21
- type: 'string',
22
- },
23
- end: {
24
- type: 'string',
25
- },
26
- },
27
- optionName: 'options',
28
- },
29
- ],
10
+ type: 'string',
11
+ enum: ['today', 'week', 'month'],
12
+ }, dateStart: {
13
+ type: 'string',
14
+ }, dateEnd: {
15
+ type: 'string',
30
16
  }, tags: {
31
17
  type: 'array',
32
18
  items: {
@@ -22,7 +22,7 @@ export declare const blockMap: {
22
22
  "solutions-block": () => JSX.Element;
23
23
  "events-feed-block": ({ image, title }: import("./models").EventsFeedBlockProps) => JSX.Element;
24
24
  "blog-feed-block": ({ image, title }: import("./models").BlogFeedBlockProps) => JSX.Element;
25
- "relevant-posts-block": ({ title, description, date, tags, services, pinnedPost, }: import("./models").RelevantPostsBlockProps) => JSX.Element;
25
+ "relevant-posts-block": ({ title, description, date, dateStart, dateEnd, tags, services, pinnedPost, }: import("./models").RelevantPostsBlockProps) => JSX.Element;
26
26
  "press-releases-block": ({ title }: import("./models").PressReleasesBlockProps) => JSX.Element;
27
27
  "highlight-table-block": (props: import("./models").HighlightTableBlockProps) => JSX.Element;
28
28
  "link-table-block": ({ title, items }: import("./models").LinkTableBlockProps) => JSX.Element;
@@ -311,10 +311,9 @@ export interface BlogFeedBlockProps {
311
311
  export interface RelevantPostsBlockProps {
312
312
  title?: TitleItemProps | string;
313
313
  description?: string;
314
- date?: {
315
- start?: string;
316
- end?: string;
317
- } | 'today' | 'week' | 'month';
314
+ date?: 'today' | 'week' | 'month';
315
+ dateStart?: string;
316
+ dateEnd?: string;
318
317
  tags?: string[];
319
318
  services?: string[];
320
319
  pinnedPost?: boolean;
@@ -6,12 +6,12 @@ import { block } from '../../utils';
6
6
  import './MarqueeLinks.css';
7
7
  const b = block('marquee-links-block');
8
8
  export const MarqueeLinksBlock = ({ title, description, textAlign = 'left', speed = 10, items, }) => {
9
- const renderItem = useCallback((item) => {
9
+ const renderItem = useCallback((item, index) => {
10
10
  if (item.url) {
11
- return (React.createElement(Link, { key: item.src, href: item.url, extraProps: { tabIndex: -1 } },
11
+ return (React.createElement(Link, { key: item.src + index, href: item.url, extraProps: { tabIndex: -1 } },
12
12
  React.createElement(Image, { src: item.src, alt: "" })));
13
13
  }
14
- return React.createElement(Image, { src: item.src, key: item.src, alt: "" });
14
+ return React.createElement(Image, { src: item.src + index, key: item.src, alt: "" });
15
15
  }, []);
16
16
  if (!items.length)
17
17
  return null;
@@ -1,4 +1,4 @@
1
1
  import { RelevantPostsBlockProps } from '../../models';
2
2
  import './RelevantPosts.css';
3
- export declare const RelevantPosts: ({ title, description, date, tags, services, pinnedPost, }: RelevantPostsBlockProps) => JSX.Element;
3
+ export declare const RelevantPosts: ({ title, description, date, dateStart, dateEnd, tags, services, pinnedPost, }: RelevantPostsBlockProps) => JSX.Element;
4
4
  export default RelevantPosts;
@@ -11,7 +11,7 @@ const colSizes = {
11
11
  lg: 2,
12
12
  sm: 1,
13
13
  };
14
- export const RelevantPosts = ({ title, description, date, tags, services, pinnedPost, }) => {
14
+ export const RelevantPosts = ({ title, description, date, dateStart, dateEnd, tags, services, pinnedPost, }) => {
15
15
  const [now, setNow] = React.useState(null);
16
16
  const { posts } = useContext(RelevantPostsContext);
17
17
  useEffect(() => {
@@ -24,27 +24,34 @@ export const RelevantPosts = ({ title, description, date, tags, services, pinned
24
24
  var _a, _b;
25
25
  const itemDate = new Date(item.dateTime);
26
26
  let isDateMatch = true;
27
- if (date === 'today') {
28
- const startOfToday = new Date(now);
29
- startOfToday.setHours(0, 0, 0, 0);
30
- const endOfToday = new Date(now);
31
- endOfToday.setHours(23, 59, 59, 999);
32
- isDateMatch = itemDate >= startOfToday && itemDate <= endOfToday;
33
- }
34
- else if (date === 'week') {
35
- const weekAgo = new Date(now);
36
- weekAgo.setDate(now.getDate() - 7);
37
- isDateMatch = itemDate >= weekAgo && itemDate <= now;
38
- }
39
- else if (date === 'month') {
40
- const monthAgo = new Date(now);
41
- monthAgo.setMonth(now.getMonth() - 1);
42
- isDateMatch = itemDate >= monthAgo && itemDate <= now;
43
- }
44
- else if (typeof date === 'object' && (date.start || date.end)) {
45
- const startDate = date.start ? new Date(date.start) : new Date('1970-01-01');
46
- const endDate = date.end ? new Date(date.end) : now;
47
- isDateMatch = itemDate >= startDate && itemDate <= endDate;
27
+ switch (date) {
28
+ case 'today': {
29
+ const startOfToday = new Date(now);
30
+ startOfToday.setHours(0, 0, 0, 0);
31
+ const endOfToday = new Date(now);
32
+ endOfToday.setHours(23, 59, 59, 999);
33
+ isDateMatch = itemDate >= startOfToday && itemDate <= endOfToday;
34
+ break;
35
+ }
36
+ case 'week': {
37
+ const weekAgo = new Date(now);
38
+ weekAgo.setDate(now.getDate() - 7);
39
+ isDateMatch = itemDate >= weekAgo && itemDate <= now;
40
+ break;
41
+ }
42
+ case 'month': {
43
+ const monthAgo = new Date(now);
44
+ monthAgo.setMonth(now.getMonth() - 1);
45
+ isDateMatch = itemDate >= monthAgo && itemDate <= now;
46
+ break;
47
+ }
48
+ default: {
49
+ if (dateStart || dateEnd) {
50
+ const startDate = dateStart ? new Date(dateStart) : new Date('1970-01-01');
51
+ const endDate = dateEnd ? new Date(dateEnd) : now;
52
+ isDateMatch = itemDate >= startDate && itemDate <= endDate;
53
+ }
54
+ }
48
55
  }
49
56
  // Фильтрация по тегам
50
57
  const isTagMatch = !tags || tags.length === 0 || ((_a = item.tags) === null || _a === void 0 ? void 0 : _a.some((tag) => tags.includes(tag.slug)));
@@ -54,7 +61,7 @@ export const RelevantPosts = ({ title, description, date, tags, services, pinned
54
61
  ((_b = item.services) === null || _b === void 0 ? void 0 : _b.some((s) => services.includes(s)));
55
62
  return isDateMatch && isTagMatch && isServiceMatch;
56
63
  });
57
- }, [now, posts, date, tags, services]);
64
+ }, [now, posts, date, tags, services, dateStart, dateEnd]);
58
65
  const [findedPinnedPost, restPosts] = useMemo(() => {
59
66
  if (!pinnedPost || filteredPosts.length === 0)
60
67
  return [undefined, filteredPosts];
@@ -4,28 +4,14 @@ export declare const RelevantPostsBlock: {
4
4
  required: never[];
5
5
  properties: {
6
6
  date: {
7
- oneOf: ({
8
- type: string;
9
- enum: string[];
10
- additionalProperties?: undefined;
11
- required?: undefined;
12
- properties?: undefined;
13
- optionName?: undefined;
14
- } | {
15
- type: string;
16
- additionalProperties: boolean;
17
- required: never[];
18
- properties: {
19
- start: {
20
- type: string;
21
- };
22
- end: {
23
- type: string;
24
- };
25
- };
26
- optionName: string;
27
- enum?: undefined;
28
- })[];
7
+ type: string;
8
+ enum: string[];
9
+ };
10
+ dateStart: {
11
+ type: string;
12
+ };
13
+ dateEnd: {
14
+ type: string;
29
15
  };
30
16
  tags: {
31
17
  type: string;
@@ -4,26 +4,12 @@ export const RelevantPostsBlock = {
4
4
  additionalProperties: false,
5
5
  required: [],
6
6
  properties: Object.assign(Object.assign(Object.assign({}, BaseProps), BlockHeaderProps), { date: {
7
- oneOf: [
8
- {
9
- type: 'string',
10
- enum: ['today', 'week', 'month'],
11
- },
12
- {
13
- type: 'object',
14
- additionalProperties: false,
15
- required: [],
16
- properties: {
17
- start: {
18
- type: 'string',
19
- },
20
- end: {
21
- type: 'string',
22
- },
23
- },
24
- optionName: 'options',
25
- },
26
- ],
7
+ type: 'string',
8
+ enum: ['today', 'week', 'month'],
9
+ }, dateStart: {
10
+ type: 'string',
11
+ }, dateEnd: {
12
+ type: 'string',
27
13
  }, tags: {
28
14
  type: 'array',
29
15
  items: {
@@ -22,7 +22,7 @@ export declare const blockMap: {
22
22
  "solutions-block": () => JSX.Element;
23
23
  "events-feed-block": ({ image, title }: import("./models").EventsFeedBlockProps) => JSX.Element;
24
24
  "blog-feed-block": ({ image, title }: import("./models").BlogFeedBlockProps) => JSX.Element;
25
- "relevant-posts-block": ({ title, description, date, tags, services, pinnedPost, }: import("./models").RelevantPostsBlockProps) => JSX.Element;
25
+ "relevant-posts-block": ({ title, description, date, dateStart, dateEnd, tags, services, pinnedPost, }: import("./models").RelevantPostsBlockProps) => JSX.Element;
26
26
  "press-releases-block": ({ title }: import("./models").PressReleasesBlockProps) => JSX.Element;
27
27
  "highlight-table-block": (props: import("./models").HighlightTableBlockProps) => JSX.Element;
28
28
  "link-table-block": ({ title, items }: import("./models").LinkTableBlockProps) => JSX.Element;
@@ -311,10 +311,9 @@ export interface BlogFeedBlockProps {
311
311
  export interface RelevantPostsBlockProps {
312
312
  title?: TitleItemProps | string;
313
313
  description?: string;
314
- date?: {
315
- start?: string;
316
- end?: string;
317
- } | 'today' | 'week' | 'month';
314
+ date?: 'today' | 'week' | 'month';
315
+ dateStart?: string;
316
+ dateEnd?: string;
318
317
  tags?: string[];
319
318
  services?: string[];
320
319
  pinnedPost?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doyourjob/gravity-ui-page-constructor",
3
- "version": "5.31.28",
3
+ "version": "5.31.30",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {