@redneckz/wildless-cms-uni-blocks 0.14.481 → 0.14.482

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 (59) hide show
  1. package/bin/migration-scripts/0.14.471.js +18 -5
  2. package/bin/migration-scripts/0.14.478.js +86 -0
  3. package/bundle/bundle.umd.js +12 -9
  4. package/bundle/bundle.umd.min.js +1 -1
  5. package/bundle/components/TabsLayout/renderTabsLayout.d.ts +2 -1
  6. package/bundle/ui-kit/TabsControl/TabItem.d.ts +1 -0
  7. package/dist/components/TabsLayout/TabsLayout.js +8 -6
  8. package/dist/components/TabsLayout/TabsLayout.js.map +1 -1
  9. package/dist/components/TabsLayout/renderTabsLayout.d.ts +2 -1
  10. package/dist/components/TabsLayout/renderTabsLayout.js +2 -1
  11. package/dist/components/TabsLayout/renderTabsLayout.js.map +1 -1
  12. package/dist/ui-kit/TabsControl/TabItem.d.ts +1 -0
  13. package/dist/ui-kit/TabsControl/TabItem.js.map +1 -1
  14. package/dist/ui-kit/TabsControl/TabItemInner.js +2 -1
  15. package/dist/ui-kit/TabsControl/TabItemInner.js.map +1 -1
  16. package/lib/common.css +1 -1
  17. package/lib/components/TabsLayout/TabsLayout.fixture.d.ts +1 -0
  18. package/lib/components/TabsLayout/TabsLayout.js +8 -6
  19. package/lib/components/TabsLayout/TabsLayout.js.map +1 -1
  20. package/lib/components/TabsLayout/renderTabsLayout.d.ts +2 -1
  21. package/lib/components/TabsLayout/renderTabsLayout.js +2 -1
  22. package/lib/components/TabsLayout/renderTabsLayout.js.map +1 -1
  23. package/lib/ui-kit/TabsControl/TabItem.d.ts +1 -0
  24. package/lib/ui-kit/TabsControl/TabItem.js.map +1 -1
  25. package/lib/ui-kit/TabsControl/TabItemInner.js +2 -1
  26. package/lib/ui-kit/TabsControl/TabItemInner.js.map +1 -1
  27. package/mobile/bundle/bundle.umd.js +12 -9
  28. package/mobile/bundle/bundle.umd.min.js +1 -1
  29. package/mobile/bundle/components/TabsLayout/renderTabsLayout.d.ts +2 -1
  30. package/mobile/bundle/ui-kit/TabsControl/TabItem.d.ts +1 -0
  31. package/mobile/dist/components/TabsLayout/TabsLayout.js +8 -6
  32. package/mobile/dist/components/TabsLayout/TabsLayout.js.map +1 -1
  33. package/mobile/dist/components/TabsLayout/renderTabsLayout.d.ts +2 -1
  34. package/mobile/dist/components/TabsLayout/renderTabsLayout.js +2 -1
  35. package/mobile/dist/components/TabsLayout/renderTabsLayout.js.map +1 -1
  36. package/mobile/dist/ui-kit/TabsControl/TabItem.d.ts +1 -0
  37. package/mobile/dist/ui-kit/TabsControl/TabItem.js.map +1 -1
  38. package/mobile/dist/ui-kit/TabsControl/TabItemInner.js +2 -1
  39. package/mobile/dist/ui-kit/TabsControl/TabItemInner.js.map +1 -1
  40. package/mobile/lib/common.css +1 -1
  41. package/mobile/lib/components/TabsLayout/TabsLayout.js +8 -6
  42. package/mobile/lib/components/TabsLayout/TabsLayout.js.map +1 -1
  43. package/mobile/lib/components/TabsLayout/renderTabsLayout.d.ts +2 -1
  44. package/mobile/lib/components/TabsLayout/renderTabsLayout.js +2 -1
  45. package/mobile/lib/components/TabsLayout/renderTabsLayout.js.map +1 -1
  46. package/mobile/lib/ui-kit/TabsControl/TabItem.d.ts +1 -0
  47. package/mobile/lib/ui-kit/TabsControl/TabItem.js.map +1 -1
  48. package/mobile/lib/ui-kit/TabsControl/TabItemInner.js +2 -1
  49. package/mobile/lib/ui-kit/TabsControl/TabItemInner.js.map +1 -1
  50. package/mobile/src/components/TabsLayout/TabsLayout.tsx +11 -8
  51. package/mobile/src/components/TabsLayout/renderTabsLayout.tsx +8 -2
  52. package/mobile/src/ui-kit/TabsControl/TabItem.tsx +1 -0
  53. package/mobile/src/ui-kit/TabsControl/TabItemInner.tsx +2 -1
  54. package/package.json +1 -1
  55. package/src/components/TabsLayout/TabsLayout.fixture.tsx +21 -0
  56. package/src/components/TabsLayout/TabsLayout.tsx +11 -8
  57. package/src/components/TabsLayout/renderTabsLayout.tsx +8 -2
  58. package/src/ui-kit/TabsControl/TabItem.tsx +1 -0
  59. package/src/ui-kit/TabsControl/TabItemInner.tsx +2 -1
@@ -1,4 +1,4 @@
1
- import { deleteProp, renameProp, traversePageBlocks } from '../utils.js';
1
+ import { deleteEmptyProps, deleteProp, renameProp, traversePageBlocks } from '../utils.js';
2
2
 
3
3
  export const description = 'v0.14.471';
4
4
 
@@ -7,14 +7,21 @@ export default traversePageBlocks(adjustTabs, adjustTabsLayout);
7
7
  function adjustTabs(block) {
8
8
  const isLayout = block?.type === 'VerticalLayout' || block?.type === 'HorizontalLayout';
9
9
  const findTab = block?.blocks?.find((_) => _?.type === 'Tabs') ?? [];
10
+ const tabs = findTab?.content?.tabs;
10
11
  const layoutBlocks = block?.blocks;
11
- if (!isLayout || !block?.blocks?.length || !findTab?.content?.tabs?.length) {
12
+
13
+ if (
14
+ !isLayout ||
15
+ !block?.blocks?.length ||
16
+ !tabs?.length ||
17
+ tabs?.filter((_) => _?.type === 'group')?.length !== tabs?.length
18
+ ) {
12
19
  return;
13
20
  }
21
+
14
22
  const tabContent = findTab.content;
15
- const tabs = findTab.content.tabs;
16
23
  const slots = tabs.map((tab) => {
17
- const slotBlock = layoutBlocks.find((_) => _?.labels?.[0] === tab?.ref);
24
+ const slotBlock = layoutBlocks.filter((_) => _?.labels?.includes(tab?.ref));
18
25
  const title = tab?.title;
19
26
  if (slotBlock) {
20
27
  block.blocks = block.blocks.filter((_) => _ !== slotBlock);
@@ -24,7 +31,10 @@ function adjustTabs(block) {
24
31
  return [title, title && slotBlock];
25
32
  });
26
33
 
27
- findTab.slots = slots.reduce((res, [key, val]) => ({ ...res, [key]: [val] }), {});
34
+ findTab.slots = slots.reduce((res, [key, val]) => ({ ...res, [key]: val }), {});
35
+ block.blocks = block.blocks.filter(
36
+ (_) => !slots?.some(([, slotBlocks]) => slotBlocks?.some((slotBlock) => slotBlock === _)),
37
+ );
28
38
 
29
39
  if (!findTab?.labels?.length) {
30
40
  deleteProp(findTab, 'labels');
@@ -64,4 +74,7 @@ function adjustTabsLayout(block) {
64
74
  if (block?.labels?.length === 0) {
65
75
  deleteProp(block, 'labels');
66
76
  }
77
+ if (!Object.keys(block.slots).length) {
78
+ deleteProp(block, 'slots');
79
+ }
67
80
  }
@@ -0,0 +1,86 @@
1
+ import { deleteEmptyProps, deleteProp, renameProp, traversePageBlocks } from '../utils.js';
2
+
3
+ export const description = 'v0.14.478';
4
+
5
+ export default traversePageBlocks(adjustTabs, adjustTabsLayout);
6
+
7
+ function adjustTabs(block, parent) {
8
+ const parentBlocks = parent?.blocks;
9
+ const findTab = parentBlocks?.find((_) => _?.type === 'Tabs') ?? [];
10
+ const tabs = findTab?.content?.tabs;
11
+
12
+ if (
13
+ !parent ||
14
+ !parentBlocks?.length ||
15
+ !tabs?.length ||
16
+ tabs?.filter((_) => _?.type === 'link')?.length !== tabs?.length
17
+ ) {
18
+ return;
19
+ }
20
+
21
+ const tabContent = findTab.content;
22
+ const slots = tabs.map((tab) => {
23
+ const slotBlocks = parentBlocks.filter((_) => _?.labels?.includes(tab?.ref));
24
+ const title = tab?.title;
25
+
26
+ return [title, title && slotBlocks];
27
+ });
28
+
29
+ findTab.slots = slots.reduce((res, [key, val]) => ({ ...res, [key]: val }), {});
30
+
31
+ parent.blocks = parent.blocks.filter(
32
+ (_) => !slots?.some(([, slotBlocks]) => slotBlocks?.some((slotBlock) => slotBlock === _)),
33
+ );
34
+
35
+ if (!findTab?.labels?.length) {
36
+ deleteProp(findTab, 'labels');
37
+ }
38
+ deleteProp(tabContent, 'showCounter');
39
+ renameProp(findTab.content, 'tabsMode', 'tabsType');
40
+ findTab.type = 'TabsLayout';
41
+ tabContent.tabsType = tabsTypeMap?.[tabContent?.tabsType] ?? 'default';
42
+ tabContent.version = 'transparent';
43
+
44
+ findTab.content.tabs = findTab.content.tabs.map((_) => {
45
+ renameProp(_, 'title', 'text');
46
+ deleteProp(_, 'ref');
47
+ if (_?.type === 'group' && !_?.tabName) {
48
+ _.tabName = _.text;
49
+ }
50
+
51
+ return _;
52
+ });
53
+ }
54
+
55
+ const tabsTypeMap = {
56
+ wideScreen: 'default',
57
+ scrollable: 'underlined',
58
+ };
59
+
60
+ function adjustTabsLayout(block) {
61
+ if (!block || block?.type !== 'TabsLayout' || !block?.slots) {
62
+ return;
63
+ }
64
+
65
+ block.slots = Object.fromEntries(
66
+ Object.entries(block.slots)
67
+ .filter(([, val]) => val?.length)
68
+ .map(([key, val]) => [
69
+ key,
70
+ val.map((_) => {
71
+ deleteProp(_, 'labels');
72
+
73
+ return _;
74
+ }),
75
+ ]),
76
+ );
77
+ if (block?.style?.length === 0) {
78
+ deleteProp(block, 'style');
79
+ }
80
+ if (block?.labels?.length === 0) {
81
+ deleteProp(block, 'labels');
82
+ }
83
+ if (!Object.keys(block.slots).length) {
84
+ deleteProp(block, 'slots');
85
+ }
86
+ }
@@ -5050,7 +5050,8 @@
5050
5050
  };
5051
5051
  const TabItemInner = JSX(({ tag = 'div', item = {}, isActive = false, type = 'default', onClick }) => {
5052
5052
  const Tag = tag;
5053
- const { text, description, icon, count, ...link } = item;
5053
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5054
+ const { text, description, icon, count, tabName, ...link } = item;
5054
5055
  return (jsx(Tag, { className: style('h-12', 'block flex-1', 'cursor-pointer', tabPaddingStyleMap[type], isActive ? activeTabBgStyleMap[type] : tabBgStyleMap[type]), role: "tablist", onClick: onClick, ...link, children: jsxs("div", { className: style('h-full', 'flex justify-center items-center', 'text-center whitespace-nowrap', isActive ? activeTabTextStyleMap[type] : tabTextStyle), children: [renderTabItemInner({
5055
5056
  text,
5056
5057
  description,
@@ -6057,20 +6058,20 @@
6057
6058
  component: 'm-auto',
6058
6059
  },
6059
6060
  };
6060
- const renderTabsLayout = ({ tabsType = 'animated', ...props }) => tabsType ? (jsx("div", { className: tabsStyle[tabsType].wrapper, children: jsx(ScrollableTabsControl, { className: tabsStyle[tabsType].component, tabsType: tabsType, ...props }) })) : null;
6061
+ const renderTabsLayout = ({ className = '', tabsType = 'animated', ...props }) => tabsType ? (jsx("div", { className: style(tabsStyle[tabsType].wrapper, className), children: jsx(ScrollableTabsControl, { className: tabsStyle[tabsType].component, tabsType: tabsType, ...props }) })) : null;
6061
6062
 
6062
6063
  const TabsLayout = UniBlock(
6063
6064
  // eslint-disable-next-line max-lines-per-function
6064
6065
  ({ className = '', tabs = [], block, tabsType, showCounter = false, isSticky, ...rest }) => {
6065
6066
  const id = block?.__id ? `tabs-${block.__id}` : 'tabs';
6066
6067
  const router = useRouter();
6067
- const groupTab = tabs.filter((_) => _.type === 'group');
6068
+ const isEveryLink = tabs.every((_) => _?.type === 'link');
6068
6069
  const tabsCounted = showCounter
6069
- ? groupTab.map((_) => ({
6070
+ ? tabs.map((_) => ({
6070
6071
  ..._,
6071
- count: block?.slots?.[_?.tabName ?? '']?.length ?? 0,
6072
+ count: _?.type === 'group' ? block?.slots?.[_?.tabName ?? '']?.length ?? 0 : 0,
6072
6073
  }))
6073
- : groupTab;
6074
+ : tabs;
6074
6075
  const { isReady } = router;
6075
6076
  const [activeTabIndex, setActiveTabIndex] = useState(getInitSelectedIndex(tabsCounted, getUrlParams(id)));
6076
6077
  const activeItem = tabsCounted[activeTabIndex];
@@ -6101,8 +6102,9 @@
6101
6102
  updateUrlSearchTabParam(_, index);
6102
6103
  }
6103
6104
  }, [tabsCounted]);
6104
- return (jsxs(BlockWrapper, { className: style(isSticky ? 'sticky top-1 z-20' : '', className), defaultPadding: "p-0", block: block, ...rest, children: [renderTabsLayout({
6105
- items: tabsCounted,
6105
+ return (jsxs(BlockWrapper, { className: style(isEveryLink ? getStickyStyle(isSticky) : '', className), defaultPadding: "p-0", block: block, ...rest, children: [renderTabsLayout({
6106
+ className: isEveryLink ? '' : getStickyStyle(isSticky),
6107
+ items: tabsCounted?.length ? tabsCounted : tabs,
6106
6108
  activeItem,
6107
6109
  tabsType,
6108
6110
  onChange: handleChange,
@@ -6115,6 +6117,7 @@
6115
6117
  }, {
6116
6118
  slots: ({ tabs }) => (tabs?.filter((_) => _.type === 'group')).map(getSlotName) || [],
6117
6119
  });
6120
+ const getStickyStyle = (isSticky = false) => (isSticky ? 'sticky top-1 z-20 pb-1' : '');
6118
6121
  const getSlotName = (tab, index) => tab?.tabName || `Слот №${index}`;
6119
6122
  const getInitSelectedIndex = (tabs, paramsId) => paramsId
6120
6123
  ? Number(paramsId)
@@ -6550,7 +6553,7 @@
6550
6553
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
6551
6554
  });
6552
6555
 
6553
- const packageVersion = "0.14.480";
6556
+ const packageVersion = "0.14.481";
6554
6557
 
6555
6558
  exports.Blocks = Blocks;
6556
6559
  exports.ContentPage = ContentPage;