@vaneui/ui 0.0.3 → 0.0.5

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 (32) hide show
  1. package/dist/components/complex/index.d.ts +1 -0
  2. package/dist/components/complex/index.js +135 -0
  3. package/dist/components/complex/index.js.map +1 -0
  4. package/dist/components/complex/sharer.d.ts +2 -2
  5. package/dist/components/ui/badge.d.ts +1 -1
  6. package/dist/components/ui/button.d.ts +1 -1
  7. package/dist/components/ui/chip.d.ts +1 -1
  8. package/dist/components/ui/divider.d.ts +1 -1
  9. package/dist/components/ui/layout.d.ts +1 -1
  10. package/dist/components/ui/settings.d.ts +1 -1
  11. package/dist/components/ui/typography.d.ts +1 -1
  12. package/dist/components/{ui/utils.d.ts → utils/componentBuilder.d.ts} +2 -2
  13. package/dist/index.esm.js.map +1 -1
  14. package/dist/index.js.map +1 -1
  15. package/package.json +9 -31
  16. package/rollup.config.mjs +40 -17
  17. package/src/components/complex/index.ts +1 -0
  18. package/src/components/complex/sharer.tsx +1 -5
  19. package/src/components/ui/badge.tsx +2 -2
  20. package/src/components/ui/button.tsx +2 -2
  21. package/src/components/ui/chip.tsx +2 -2
  22. package/src/components/ui/divider.tsx +2 -2
  23. package/src/components/ui/layout.tsx +2 -2
  24. package/src/components/ui/settings.ts +1 -1
  25. package/src/components/ui/typography.tsx +2 -2
  26. package/src/components/{ui/utils.tsx → utils/componentBuilder.tsx} +3 -3
  27. package/tsconfig.complex.json +11 -0
  28. package/tsconfig.json +1 -1
  29. /package/dist/components/ui/{commonValues.d.ts → props/commonValues.d.ts} +0 -0
  30. /package/dist/components/ui/{props.d.ts → props/props.d.ts} +0 -0
  31. /package/src/components/ui/{commonValues.ts → props/commonValues.ts} +0 -0
  32. /package/src/components/ui/{props.ts → props/props.ts} +0 -0
@@ -0,0 +1 @@
1
+ export { SocialShare } from "./sharer";
@@ -0,0 +1,135 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ const buildQueryString = (params) => {
4
+ const validKeys = Object.keys(params).filter(key => params[key] !== undefined && params[key] !== '');
5
+ return validKeys.length > 0
6
+ ? '?' +
7
+ validKeys
8
+ .map(key => `${key}=${encodeURIComponent(String(params[key]))}`)
9
+ .join('&')
10
+ : '';
11
+ };
12
+ const SocialShare = ({ url = window.location.href, text = '', width = 600, height = 480, isLink = false, isBlank = true, platforms, containerComponent, buttonComponent, buttonComponents, facebookProps = {}, twitterProps = {}, emailProps = {}, whatsappProps = {}, }) => {
13
+ const shareConfigs = {
14
+ fb: {
15
+ shareUrl: 'https://www.facebook.com/sharer/sharer.php',
16
+ getParams: () => ({
17
+ u: url,
18
+ hashtag: facebookProps.hashtag
19
+ ? facebookProps.hashtag.startsWith('#')
20
+ ? facebookProps.hashtag
21
+ : `#${facebookProps.hashtag}`
22
+ : '',
23
+ quote: text,
24
+ }),
25
+ },
26
+ li: {
27
+ shareUrl: 'https://www.linkedin.com/shareArticle',
28
+ getParams: () => ({
29
+ url,
30
+ }),
31
+ },
32
+ x: {
33
+ shareUrl: 'https://x.com/intent/tweet',
34
+ getParams: () => ({
35
+ text,
36
+ url,
37
+ hashtags: twitterProps.hashtags,
38
+ via: twitterProps.via,
39
+ related: twitterProps.related,
40
+ in_reply_to: twitterProps.inReplyTo,
41
+ }),
42
+ },
43
+ th: {
44
+ shareUrl: 'https://threads.net/intent/post',
45
+ getParams: () => ({
46
+ text: `${text} ${url}`,
47
+ }),
48
+ },
49
+ em: {
50
+ shareUrl: 'mailto:' + (emailProps.to || ''),
51
+ getParams: () => ({
52
+ subject: emailProps.title,
53
+ body: `${text}\n${url}`,
54
+ }),
55
+ },
56
+ wa: {
57
+ shareUrl: whatsappProps.web
58
+ ? 'https://web.whatsapp.com/send'
59
+ : 'https://wa.me/',
60
+ getParams: () => ({
61
+ phone: whatsappProps.to,
62
+ text: `${text} ${url}`,
63
+ }),
64
+ },
65
+ tg: {
66
+ shareUrl: 'https://t.me/share',
67
+ getParams: () => ({
68
+ text,
69
+ url,
70
+ }),
71
+ },
72
+ re: {
73
+ shareUrl: 'https://www.reddit.com/submit',
74
+ getParams: () => ({
75
+ url,
76
+ title: text,
77
+ }),
78
+ },
79
+ };
80
+ const platformLabels = {
81
+ fb: 'Facebook',
82
+ li: 'LinkedIn',
83
+ x: 'X',
84
+ th: 'Threads',
85
+ em: 'Email',
86
+ wa: 'WhatsApp',
87
+ tg: 'Telegram',
88
+ re: 'Reddit',
89
+ };
90
+ const buildShareUrl = (config) => {
91
+ const params = config.getParams();
92
+ const queryString = buildQueryString(params);
93
+ return config.shareUrl + queryString;
94
+ };
95
+ const openShareWindow = (shareUrl) => {
96
+ if (isLink) {
97
+ if (isBlank) {
98
+ window.open(shareUrl, '_blank');
99
+ }
100
+ else {
101
+ window.location.href = shareUrl;
102
+ }
103
+ }
104
+ else {
105
+ const left = window.innerWidth / 2 - width / 2 + window.screenX;
106
+ const top = window.innerHeight / 2 - height / 2 + window.screenY;
107
+ const popParams = `scrollbars=no, width=${width}, height=${height}, top=${top}, left=${left}`;
108
+ const newWindow = window.open(shareUrl, '', popParams);
109
+ if (newWindow) {
110
+ newWindow.focus();
111
+ }
112
+ }
113
+ };
114
+ const handleShare = (key) => {
115
+ const config = shareConfigs[key];
116
+ if (!config)
117
+ return;
118
+ const shareUrl = buildShareUrl(config);
119
+ openShareWindow(shareUrl);
120
+ };
121
+ // Use the provided container component or default to 'div'
122
+ const Container = containerComponent || 'div';
123
+ // Default button component to use if no platform-specific component is provided
124
+ const DefaultButton = buttonComponent || 'button';
125
+ const platformsToShow = platforms || Object.keys(shareConfigs);
126
+ return (jsx(Container, { children: platformsToShow.map(key => {
127
+ // Use a specific button component if defined for the key
128
+ const Button = (buttonComponents && buttonComponents[key]) || DefaultButton;
129
+ const label = platformLabels[key] || key;
130
+ return (jsx(Button, { onClick: () => handleShare(key), title: `Share on ${label}`, children: label }, key));
131
+ }) }));
132
+ };
133
+
134
+ export { SocialShare };
135
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -35,5 +35,5 @@ interface SocialShareProps extends SocialShareCommonProps {
35
35
  emailProps?: EmailShareProps;
36
36
  whatsappProps?: WhatsAppShareProps;
37
37
  }
38
- declare const SocialShare: React.FC<SocialShareProps>;
39
- export default SocialShare;
38
+ export declare const SocialShare: React.FC<SocialShareProps>;
39
+ export {};
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- import { TypographyComponentProps } from "./props";
2
+ import { TypographyComponentProps } from "./props/props";
3
3
  export declare const Badge: React.FC<TypographyComponentProps>;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- import { TypographyComponentProps } from "./props";
2
+ import { TypographyComponentProps } from "./props/props";
3
3
  export declare const Button: React.FC<TypographyComponentProps>;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- import { TypographyComponentProps } from "./props";
2
+ import { TypographyComponentProps } from "./props/props";
3
3
  export declare const Chip: React.FC<TypographyComponentProps>;
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
- import { BaseComponentProps } from "./props";
2
+ import { BaseComponentProps } from "./props/props";
3
3
  export declare const Divider: React.FC<BaseComponentProps>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { GridProps, LayoutComponentProps, ColProps, RowProps } from "./props";
2
+ import { GridProps, LayoutComponentProps, ColProps, RowProps } from "./props/props";
3
3
  export declare const Section: React.FC<LayoutComponentProps>;
4
4
  export declare const Container: React.FC<LayoutComponentProps>;
5
5
  export declare const Col: React.FC<ColProps>;
@@ -1,4 +1,4 @@
1
- import { CommonAppearanceProps, FontFamilyProps, FontStyleProps, FontWeightProps, TextAppearanceProps, TextDecorationProps, TextTransformProps } from "./props";
1
+ import { CommonAppearanceProps, FontFamilyProps, FontStyleProps, FontWeightProps, TextAppearanceProps, TextDecorationProps, TextTransformProps } from "./props/props";
2
2
  export type CommonAppearanceSettings = {
3
3
  [key in keyof CommonAppearanceProps]: boolean;
4
4
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { TypographyComponentProps } from "./props";
2
+ import { TypographyComponentProps } from "./props/props";
3
3
  export declare const PageTitle: React.FC<TypographyComponentProps>;
4
4
  export declare const SectionTitle: React.FC<TypographyComponentProps>;
5
5
  export declare const Title: React.FC<TypographyComponentProps>;
@@ -1,5 +1,5 @@
1
- import { BaseComponentProps, BreakpointProps, CenteredProps, CommonAppearanceProps, FontFamilyProps, FontStyleProps, FontWeightProps, GapProps, HideProps, PositionProps, ReverseProps, TextAppearanceProps, TextDecorationProps, TextTransformProps, SizeProps } from "./props";
2
- import { CommonAppearanceSettings, FontFamilySettings, FontStyleSettings, FontWeightSettings, TextAppearanceSettings, TextDecorationSettings, TextTransformSettings, TypographySettings } from "./settings";
1
+ import { BaseComponentProps, BreakpointProps, CenteredProps, CommonAppearanceProps, FontFamilyProps, FontStyleProps, FontWeightProps, GapProps, HideProps, PositionProps, ReverseProps, TextAppearanceProps, TextDecorationProps, TextTransformProps, SizeProps } from "../ui/props/props";
2
+ import { CommonAppearanceSettings, FontFamilySettings, FontStyleSettings, FontWeightSettings, TextAppearanceSettings, TextDecorationSettings, TextTransformSettings, TypographySettings } from "../ui/settings";
3
3
  export declare function componentBuilder(baseProps: BaseComponentProps, defaultTag: string, baseClasses?: string): {
4
4
  withBooleanProps: <T extends Record<string, string>>(propMap: Record<keyof T, string>, fallbackKey?: keyof T, settings?: {
5
5
  [key: string]: boolean;