@redneckz/wildless-cms-uni-blocks 0.13.0 → 0.13.2
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/bundle/bundle.umd.js +33 -22
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/model/HeadlineType.d.ts +1 -1
- package/bundle/ui-kit/TabsControl/TabItemInner.d.ts +6 -0
- package/dist/components/Blocks.mobile.js +17 -13
- package/dist/components/Blocks.mobile.js.map +1 -1
- package/dist/components/MortgageFiltration/MortgageFiltration.js +5 -5
- package/dist/components/MortgageFiltration/MortgageFiltration.js.map +1 -1
- package/dist/components/Tabs/Tabs.js +6 -6
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/model/HeadlineType.d.ts +1 -1
- package/dist/ui-kit/BaseFiltration/checkShouldRenderBlock.js +2 -4
- package/dist/ui-kit/BaseFiltration/checkShouldRenderBlock.js.map +1 -1
- package/dist/ui-kit/TabsControl/TabItem.js +15 -29
- package/dist/ui-kit/TabsControl/TabItem.js.map +1 -1
- package/dist/ui-kit/TabsControl/TabItemInner.d.ts +6 -0
- package/dist/ui-kit/TabsControl/TabItemInner.js +33 -0
- package/dist/ui-kit/TabsControl/TabItemInner.js.map +1 -0
- package/lib/components/Blocks.mobile.js +17 -13
- package/lib/components/Blocks.mobile.js.map +1 -1
- package/lib/components/MortgageFiltration/MortgageFiltration.js +5 -5
- package/lib/components/MortgageFiltration/MortgageFiltration.js.map +1 -1
- package/lib/components/Tabs/Tabs.js +6 -6
- package/lib/components/Tabs/Tabs.js.map +1 -1
- package/lib/model/HeadlineType.d.ts +1 -1
- package/lib/ui-kit/BaseFiltration/checkShouldRenderBlock.js +2 -4
- package/lib/ui-kit/BaseFiltration/checkShouldRenderBlock.js.map +1 -1
- package/lib/ui-kit/TabsControl/TabItem.js +15 -29
- package/lib/ui-kit/TabsControl/TabItem.js.map +1 -1
- package/lib/ui-kit/TabsControl/TabItemInner.d.ts +6 -0
- package/lib/ui-kit/TabsControl/TabItemInner.js +31 -0
- package/lib/ui-kit/TabsControl/TabItemInner.js.map +1 -0
- package/mobile/bundle/bundle.umd.js +98 -79
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/model/HeadlineType.d.ts +1 -1
- package/mobile/bundle/ui-kit/TabsControl/TabItemInner.d.ts +6 -0
- package/mobile/dist/components/Blocks.js +17 -13
- package/mobile/dist/components/Blocks.js.map +1 -1
- package/mobile/dist/components/MortgageFiltration/MortgageFiltration.js +5 -5
- package/mobile/dist/components/MortgageFiltration/MortgageFiltration.js.map +1 -1
- package/mobile/dist/components/Tabs/Tabs.js +6 -6
- package/mobile/dist/components/Tabs/Tabs.js.map +1 -1
- package/mobile/dist/model/HeadlineType.d.ts +1 -1
- package/mobile/dist/ui-kit/BaseFiltration/checkShouldRenderBlock.js +2 -4
- package/mobile/dist/ui-kit/BaseFiltration/checkShouldRenderBlock.js.map +1 -1
- package/mobile/dist/ui-kit/TabsControl/TabItem.js +15 -29
- package/mobile/dist/ui-kit/TabsControl/TabItem.js.map +1 -1
- package/mobile/dist/ui-kit/TabsControl/TabItemInner.d.ts +6 -0
- package/mobile/dist/ui-kit/TabsControl/TabItemInner.js +33 -0
- package/mobile/dist/ui-kit/TabsControl/TabItemInner.js.map +1 -0
- package/mobile/lib/components/Blocks.js +17 -13
- package/mobile/lib/components/Blocks.js.map +1 -1
- package/mobile/lib/components/MortgageFiltration/MortgageFiltration.js +5 -5
- package/mobile/lib/components/MortgageFiltration/MortgageFiltration.js.map +1 -1
- package/mobile/lib/components/Tabs/Tabs.js +6 -6
- package/mobile/lib/components/Tabs/Tabs.js.map +1 -1
- package/mobile/lib/model/HeadlineType.d.ts +1 -1
- package/mobile/lib/ui-kit/BaseFiltration/checkShouldRenderBlock.js +2 -4
- package/mobile/lib/ui-kit/BaseFiltration/checkShouldRenderBlock.js.map +1 -1
- package/mobile/lib/ui-kit/TabsControl/TabItem.js +15 -29
- package/mobile/lib/ui-kit/TabsControl/TabItem.js.map +1 -1
- package/mobile/lib/ui-kit/TabsControl/TabItemInner.d.ts +6 -0
- package/mobile/lib/ui-kit/TabsControl/TabItemInner.js +31 -0
- package/mobile/lib/ui-kit/TabsControl/TabItemInner.js.map +1 -0
- package/mobile/src/components/Blocks.ts +17 -13
- package/mobile/src/components/MortgageFiltration/MortgageFiltration.tsx +6 -6
- package/mobile/src/components/Tabs/Tabs.tsx +12 -9
- package/mobile/src/model/HeadlineType.ts +1 -1
- package/mobile/src/ui-kit/BaseFiltration/checkShouldRenderBlock.ts +2 -4
- package/mobile/src/ui-kit/TabsControl/TabItem.tsx +18 -57
- package/mobile/src/ui-kit/TabsControl/TabItemInner.tsx +69 -0
- package/package.json +1 -1
- package/src/components/Blocks.mobile.ts +17 -13
- package/src/components/MortgageFiltration/MortgageFiltration.tsx +6 -6
- package/src/components/Tabs/Tabs.tsx +12 -9
- package/src/model/HeadlineType.ts +1 -1
- package/src/ui-kit/BaseFiltration/checkShouldRenderBlock.ts +2 -4
- package/src/ui-kit/TabsControl/TabItem.tsx +18 -57
- package/src/ui-kit/TabsControl/TabItemInner.tsx +69 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
|
|
2
3
|
import { useLink } from '../../hooks/useLink';
|
|
3
4
|
import type { LinkProps } from '../../model/LinkProps';
|
|
4
|
-
import {
|
|
5
|
-
import { Text } from '../Text/Text';
|
|
5
|
+
import { TabItemInner } from './TabItemInner';
|
|
6
6
|
import type { TabsControlProps } from './TabsControlProps';
|
|
7
7
|
|
|
8
8
|
export type TabItemBase = LinkProps;
|
|
@@ -16,66 +16,27 @@ export interface TabItemProps {
|
|
|
16
16
|
type?: TabType;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
rounded: 'px-lg rounded-md',
|
|
23
|
-
};
|
|
19
|
+
export const TabItem = JSX<TabItemProps>((props) =>
|
|
20
|
+
props?.item?.href ? <LinkTabItem {...props} /> : <ButtonTabItem {...props} />,
|
|
21
|
+
);
|
|
24
22
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const activeTabTextStyleMap: Record<TabType, string> = {
|
|
28
|
-
default: 'text-black sm:text-white',
|
|
29
|
-
underlined: 'text-primary-main border-b-2',
|
|
30
|
-
rounded: 'text-white',
|
|
31
|
-
};
|
|
23
|
+
const LinkTabItem = JSX<TabItemProps>((props) => {
|
|
24
|
+
const link = useLink();
|
|
32
25
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
rounded: 'bg-transparent',
|
|
37
|
-
};
|
|
26
|
+
const handleClick = useCallback(() => {
|
|
27
|
+
props.onClick && props.onClick(props.item || {});
|
|
28
|
+
}, [props.onClick, props.item]);
|
|
38
29
|
|
|
39
|
-
const
|
|
40
|
-
default: 'sm:bg-primary-main',
|
|
41
|
-
underlined: 'bg-white',
|
|
42
|
-
rounded: 'bg-primary-main',
|
|
43
|
-
};
|
|
30
|
+
const { onClick, ...item } = link({ ...props.item, onClick: handleClick });
|
|
44
31
|
|
|
45
|
-
|
|
46
|
-
|
|
32
|
+
return <TabItemInner {...props} tag="a" item={item} onClick={onClick} />;
|
|
33
|
+
});
|
|
47
34
|
|
|
48
|
-
|
|
35
|
+
// TODO: Update handlerDecorator (support buttons?)
|
|
36
|
+
const ButtonTabItem = JSX<TabItemProps>(({ item = {}, onClick, ...rest }) => {
|
|
37
|
+
const handleClick = useCallback(() => {
|
|
49
38
|
onClick && onClick(item);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const { text, ...linkProps } = link({ ...item, onClick: handleClick });
|
|
53
|
-
|
|
54
|
-
const Tag = item.href ? 'a' : 'div';
|
|
39
|
+
}, [onClick, item]);
|
|
55
40
|
|
|
56
|
-
return
|
|
57
|
-
<Tag
|
|
58
|
-
className={style(
|
|
59
|
-
'h-12',
|
|
60
|
-
'block flex-1',
|
|
61
|
-
'cursor-pointer',
|
|
62
|
-
tabPaddingStyleMap[type],
|
|
63
|
-
isActive ? activeTabBgStyleMap[type] : tabBgStyleMap[type],
|
|
64
|
-
)}
|
|
65
|
-
role="tab"
|
|
66
|
-
aria-selected={isActive}
|
|
67
|
-
{...linkProps}
|
|
68
|
-
>
|
|
69
|
-
<div
|
|
70
|
-
className={style(
|
|
71
|
-
'h-full',
|
|
72
|
-
'flex justify-center items-center',
|
|
73
|
-
'text-center whitespace-nowrap',
|
|
74
|
-
isActive ? activeTabTextStyleMap[type] : tabTextStyle,
|
|
75
|
-
)}
|
|
76
|
-
>
|
|
77
|
-
<Text size="text-m">{text}</Text>
|
|
78
|
-
</div>
|
|
79
|
-
</Tag>
|
|
80
|
-
);
|
|
41
|
+
return <TabItemInner item={item} onClick={handleClick} {...rest} />;
|
|
81
42
|
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { JSX } from '@redneckz/uni-jsx';
|
|
2
|
+
import { style } from '../../utils/style';
|
|
3
|
+
import { Text } from '../Text/Text';
|
|
4
|
+
import type { TabItemProps, TabType } from './TabItem';
|
|
5
|
+
|
|
6
|
+
const tabPaddingStyleMap: Record<TabType, string> = {
|
|
7
|
+
default: 'px-xs',
|
|
8
|
+
underlined: 'px-m',
|
|
9
|
+
rounded: 'px-lg rounded-md',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const tabTextStyle = 'text-secondary-text hover:text-primary-main';
|
|
13
|
+
|
|
14
|
+
const activeTabTextStyleMap: Record<TabType, string> = {
|
|
15
|
+
default: 'text-black sm:text-white',
|
|
16
|
+
underlined: 'text-primary-main border-b-2',
|
|
17
|
+
rounded: 'text-white',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const tabBgStyleMap: Record<TabType, string> = {
|
|
21
|
+
default: 'bg-white',
|
|
22
|
+
underlined: 'bg-white',
|
|
23
|
+
rounded: 'bg-transparent',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const activeTabBgStyleMap: Record<TabType, string> = {
|
|
27
|
+
default: 'sm:bg-primary-main',
|
|
28
|
+
underlined: 'bg-white',
|
|
29
|
+
rounded: 'bg-primary-main',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
interface TabItemInnerProps extends TabItemProps {
|
|
33
|
+
tag?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const TabItemInner = JSX<TabItemInnerProps>(
|
|
37
|
+
({ tag = 'div', item = {}, isActive, type = 'default', onClick }) => {
|
|
38
|
+
const Tag: any = tag;
|
|
39
|
+
|
|
40
|
+
const { text, ...link } = item;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Tag
|
|
44
|
+
className={style(
|
|
45
|
+
'h-12',
|
|
46
|
+
'block flex-1',
|
|
47
|
+
'cursor-pointer',
|
|
48
|
+
tabPaddingStyleMap[type],
|
|
49
|
+
isActive ? activeTabBgStyleMap[type] : tabBgStyleMap[type],
|
|
50
|
+
)}
|
|
51
|
+
role="tab"
|
|
52
|
+
aria-selected={isActive}
|
|
53
|
+
onClick={onClick}
|
|
54
|
+
{...link}
|
|
55
|
+
>
|
|
56
|
+
<div
|
|
57
|
+
className={style(
|
|
58
|
+
'h-full',
|
|
59
|
+
'flex justify-center items-center',
|
|
60
|
+
'text-center whitespace-nowrap',
|
|
61
|
+
isActive ? activeTabTextStyleMap[type] : tabTextStyle,
|
|
62
|
+
)}
|
|
63
|
+
>
|
|
64
|
+
<Text size="text-m">{text}</Text>
|
|
65
|
+
</div>
|
|
66
|
+
</Tag>
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
);
|