@srcroot/ui 0.0.60 → 0.0.61
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/dist/index.js +7 -0
- package/package.json +1 -1
- package/src/registry/ui/google-analytics.tsx +0 -38
- package/src/registry/ui/google-tag-manager.tsx +0 -64
- package/src/registry/ui/meta-pixel.tsx +0 -46
- package/src/registry/ui/microsoft-clarity.tsx +0 -33
- package/src/registry/ui/tiktok-pixel.tsx +0 -36
package/dist/index.js
CHANGED
|
@@ -884,6 +884,13 @@ var REGISTRY = {
|
|
|
884
884
|
description: "Background patterns",
|
|
885
885
|
category: "Layout",
|
|
886
886
|
dependencies: []
|
|
887
|
+
},
|
|
888
|
+
"theme-switcher": {
|
|
889
|
+
file: "ui/theme-switcher.tsx",
|
|
890
|
+
description: "Theme toggle for dropdowns",
|
|
891
|
+
category: "Navigation",
|
|
892
|
+
dependencies: ["dropdown-menu"],
|
|
893
|
+
registryDependencies: ["next-themes", "react-icons"]
|
|
887
894
|
}
|
|
888
895
|
};
|
|
889
896
|
|
package/package.json
CHANGED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import Script from 'next/script';
|
|
4
|
-
import type { FC } from 'react';
|
|
5
|
-
|
|
6
|
-
interface GoogleAnalyticsProps {
|
|
7
|
-
gaIds: string[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const GoogleAnalytics: FC<GoogleAnalyticsProps> = ({ gaIds }) => {
|
|
11
|
-
if (gaIds.length === 0) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<>
|
|
17
|
-
<Script
|
|
18
|
-
id="ga4-script"
|
|
19
|
-
strategy="afterInteractive"
|
|
20
|
-
src={`https://www.googletagmanager.com/gtag/js?id=${gaIds[0]}`}
|
|
21
|
-
/>
|
|
22
|
-
<Script
|
|
23
|
-
id="ga4-init"
|
|
24
|
-
strategy="afterInteractive"
|
|
25
|
-
dangerouslySetInnerHTML={{
|
|
26
|
-
__html: `
|
|
27
|
-
window.dataLayer = window.dataLayer || [];
|
|
28
|
-
function gtag(){dataLayer.push(arguments);}
|
|
29
|
-
gtag('js', new Date());
|
|
30
|
-
${gaIds.map((id) => `gtag('config', '${id}', { page_path: window.location.pathname });`).join('\n')}
|
|
31
|
-
`,
|
|
32
|
-
}}
|
|
33
|
-
/>
|
|
34
|
-
</>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export default GoogleAnalytics;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import Script from 'next/script';
|
|
4
|
-
import type { FC, ReactNode } from 'react';
|
|
5
|
-
|
|
6
|
-
interface GTMContainer {
|
|
7
|
-
gtmId: string;
|
|
8
|
-
tagServerUrl?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface GoogleTagManagerProps {
|
|
12
|
-
containers: GTMContainer[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const GoogleTagManager: FC<GoogleTagManagerProps> = ({ containers }) => {
|
|
16
|
-
const defaultServer = 'https://www.googletagmanager.com';
|
|
17
|
-
|
|
18
|
-
// Group containers by tagServer to avoid duplicate script loads
|
|
19
|
-
const scriptsMap = containers.reduce((map, container) => {
|
|
20
|
-
const server = container.tagServerUrl || defaultServer;
|
|
21
|
-
if (!map.has(server)) {
|
|
22
|
-
map.set(server, []);
|
|
23
|
-
}
|
|
24
|
-
map.get(server)!.push(container.gtmId);
|
|
25
|
-
return map;
|
|
26
|
-
}, new Map<string, string[]>());
|
|
27
|
-
|
|
28
|
-
const scriptElements: ReactNode[] = Array.from(scriptsMap.entries()).map(([server, ids]) => (
|
|
29
|
-
<Script
|
|
30
|
-
key={server}
|
|
31
|
-
id={`gtm-script-${server}`}
|
|
32
|
-
strategy="afterInteractive"
|
|
33
|
-
dangerouslySetInnerHTML={{
|
|
34
|
-
__html: `
|
|
35
|
-
${ids
|
|
36
|
-
.map(
|
|
37
|
-
id => `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s);j.async=true;j.src="${server}/gtm.js?"+i;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','${id}');`
|
|
38
|
-
)
|
|
39
|
-
.join('')}
|
|
40
|
-
`,
|
|
41
|
-
}}
|
|
42
|
-
/>
|
|
43
|
-
));
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
{scriptElements}
|
|
48
|
-
|
|
49
|
-
<noscript>
|
|
50
|
-
{containers.map(({ gtmId, tagServerUrl = defaultServer }) => (
|
|
51
|
-
<iframe
|
|
52
|
-
key={gtmId}
|
|
53
|
-
src={`${tagServerUrl}/ns.html?id=${gtmId}`}
|
|
54
|
-
height="0"
|
|
55
|
-
width="0"
|
|
56
|
-
style={{ display: 'none', visibility: 'hidden' }}
|
|
57
|
-
/>
|
|
58
|
-
))}
|
|
59
|
-
</noscript>
|
|
60
|
-
</>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export default GoogleTagManager;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import Script from 'next/script';
|
|
4
|
-
import type { FC } from 'react';
|
|
5
|
-
|
|
6
|
-
interface MetaPixelProps {
|
|
7
|
-
pixelIds: string[]; // ← array now
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const MetaPixel: FC<MetaPixelProps> = ({ pixelIds }) => {
|
|
11
|
-
return (
|
|
12
|
-
<>
|
|
13
|
-
<Script
|
|
14
|
-
id="fb-script-multi"
|
|
15
|
-
strategy="afterInteractive"
|
|
16
|
-
dangerouslySetInnerHTML={{
|
|
17
|
-
__html: `
|
|
18
|
-
!function(f,b,e,v,n,t,s)
|
|
19
|
-
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
|
20
|
-
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
|
|
21
|
-
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
|
|
22
|
-
n.queue=[];t=b.createElement(e);t.async=!0;
|
|
23
|
-
t.src=v;s=b.getElementsByTagName(e)[0];
|
|
24
|
-
s.parentNode.insertBefore(t,s)}(window, document,'script',
|
|
25
|
-
'https://connect.facebook.net/en_US/fbevents.js');
|
|
26
|
-
${pixelIds.map(id => `fbq('init', '${id}');`).join('\n')}
|
|
27
|
-
fbq('track', 'PageView');
|
|
28
|
-
`,
|
|
29
|
-
}}
|
|
30
|
-
/>
|
|
31
|
-
|
|
32
|
-
{/* One noscript tag per pixel */}
|
|
33
|
-
{pixelIds.map(id => (
|
|
34
|
-
<noscript key={id}>
|
|
35
|
-
<img
|
|
36
|
-
height="1" width="1" style={{ display: 'none' }}
|
|
37
|
-
src={`https://www.facebook.com/tr?id=${id}&ev=PageView&noscript=1`}
|
|
38
|
-
alt=""
|
|
39
|
-
/>
|
|
40
|
-
</noscript>
|
|
41
|
-
))}
|
|
42
|
-
</>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default MetaPixel;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import Script from 'next/script';
|
|
4
|
-
import type { FC } from 'react';
|
|
5
|
-
|
|
6
|
-
interface MicrosoftClarityProps {
|
|
7
|
-
clarityIds: string[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const MicrosoftClarity: FC<MicrosoftClarityProps> = ({ clarityIds }) => {
|
|
11
|
-
return (
|
|
12
|
-
<>
|
|
13
|
-
{clarityIds.map((id) => (
|
|
14
|
-
<Script
|
|
15
|
-
key={id}
|
|
16
|
-
id={`microsoft-clarity-init-${id}`}
|
|
17
|
-
strategy="afterInteractive"
|
|
18
|
-
dangerouslySetInnerHTML={{
|
|
19
|
-
__html: `
|
|
20
|
-
(function(c,l,a,r,i,t,y){
|
|
21
|
-
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
|
|
22
|
-
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
|
|
23
|
-
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
|
|
24
|
-
})(window, document, "clarity", "script", "${id}");
|
|
25
|
-
`,
|
|
26
|
-
}}
|
|
27
|
-
/>
|
|
28
|
-
))}
|
|
29
|
-
</>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default MicrosoftClarity;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import Script from 'next/script';
|
|
4
|
-
import type { FC } from 'react';
|
|
5
|
-
|
|
6
|
-
interface TikTokPixelProps {
|
|
7
|
-
pixelIds: string[]; // ← array
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const TikTokPixel: FC<TikTokPixelProps> = ({ pixelIds }) => {
|
|
11
|
-
return (
|
|
12
|
-
<Script
|
|
13
|
-
id="tiktok-script-multi"
|
|
14
|
-
strategy="afterInteractive"
|
|
15
|
-
dangerouslySetInnerHTML={{
|
|
16
|
-
__html: `
|
|
17
|
-
!function (w, d, t) {
|
|
18
|
-
w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];
|
|
19
|
-
ttq.methods=["page","track","identify","instances","debug","on","off","once","ready","alias","group","enableCookie","disableCookie","holdConsent","revokeConsent","grantConsent"],
|
|
20
|
-
ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};
|
|
21
|
-
for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);
|
|
22
|
-
ttq.instance=function(t){for(var e=ttq._i[t]||[],n=0;n<ttq.methods.length;n++)ttq.setAndDefer(e,ttq.methods[n]);return e},
|
|
23
|
-
ttq.load=function(e,n){var r="https://analytics.tiktok.com/i18n/pixel/events.js";
|
|
24
|
-
ttq._i=ttq._i||{},ttq._i[e]=[],ttq._i[e]._u=r,ttq._t=ttq._t||{},ttq._t[e]=+new Date,ttq._o=ttq._o||{},ttq._o[e]=n||{};
|
|
25
|
-
var s=document.createElement("script");s.type="text/javascript",s.async=!0,s.src=r+"?sdkid="+e+"&lib="+t;
|
|
26
|
-
var p=document.getElementsByTagName("script")[0];p.parentNode.insertBefore(s,p)};
|
|
27
|
-
${pixelIds.map(id => `ttq.load('${id}');`).join('\n')}
|
|
28
|
-
ttq.page();
|
|
29
|
-
}(window, document, 'ttq');
|
|
30
|
-
`,
|
|
31
|
-
}}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default TikTokPixel;
|