@apotech-os/ui-sdk 7.6.0 → 7.7.0

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.cjs CHANGED
@@ -2659,11 +2659,131 @@ function Tooltip2({ label, children, side = "top", className }) {
2659
2659
  )
2660
2660
  ] });
2661
2661
  }
2662
+ var BRAND_LOGO_KEYS = [
2663
+ "anthropic",
2664
+ "bigblue",
2665
+ "cchezvous",
2666
+ "google-ads",
2667
+ "google-drive",
2668
+ "google-search-console",
2669
+ "google-sheets",
2670
+ "gorgias",
2671
+ "hubble",
2672
+ "judgeme",
2673
+ "klaviyo",
2674
+ "meta",
2675
+ "monday",
2676
+ "openai",
2677
+ "openrouter",
2678
+ "pennylane",
2679
+ "pipedrive",
2680
+ "prediko",
2681
+ "ringover",
2682
+ "shopify",
2683
+ "slack"
2684
+ ];
2685
+ var HOSTS = [
2686
+ ["docs.google.com", "google-sheets", "/spreadsheets/"],
2687
+ ["ads.google.com", "google-ads"],
2688
+ ["search.google.com", "google-search-console"],
2689
+ ["drive.google.com", "google-drive"],
2690
+ ["sheets.google.com", "google-sheets"],
2691
+ ["shopify.com", "shopify"],
2692
+ ["myshopify.com", "shopify"],
2693
+ ["facebook.com", "meta"],
2694
+ ["instagram.com", "meta"],
2695
+ ["meta.com", "meta"],
2696
+ ["bigblue.co", "bigblue"],
2697
+ ["cchezvous.fr", "cchezvous"],
2698
+ ["gorgias.com", "gorgias"],
2699
+ ["thehubble.co", "hubble"],
2700
+ ["judge.me", "judgeme"],
2701
+ ["klaviyo.com", "klaviyo"],
2702
+ ["monday.com", "monday"],
2703
+ ["pennylane.com", "pennylane"],
2704
+ ["pipedrive.com", "pipedrive"],
2705
+ ["prediko.io", "prediko"],
2706
+ ["ringover.com", "ringover"],
2707
+ ["slack.com", "slack"],
2708
+ ["anthropic.com", "anthropic"],
2709
+ ["claude.ai", "anthropic"],
2710
+ ["openai.com", "openai"],
2711
+ ["chatgpt.com", "openai"],
2712
+ ["openrouter.ai", "openrouter"]
2713
+ ];
2714
+ function parseHttpUrl(url) {
2715
+ try {
2716
+ const parsed = new URL(/^[a-z][a-z\d+.-]*:/i.test(url) ? url : `https://${url}`);
2717
+ return parsed.protocol === "http:" || parsed.protocol === "https:" ? parsed : null;
2718
+ } catch {
2719
+ return null;
2720
+ }
2721
+ }
2722
+ function brandKeyForUrl(url) {
2723
+ const parsed = parseHttpUrl(url);
2724
+ if (!parsed) return null;
2725
+ for (const [domain, key, pathPrefix] of HOSTS) {
2726
+ const hostMatches = parsed.hostname === domain || parsed.hostname.endsWith(`.${domain}`);
2727
+ if (hostMatches && (!pathPrefix || parsed.pathname.startsWith(pathPrefix))) return key;
2728
+ }
2729
+ return null;
2730
+ }
2731
+ function isBrandLogoKey(key) {
2732
+ return BRAND_LOGO_KEYS.includes(key);
2733
+ }
2734
+ function siteIconUrl(target) {
2735
+ if (target.provider !== void 0) {
2736
+ return isBrandLogoKey(target.provider) ? `/brand-logos/${target.provider}.png` : null;
2737
+ }
2738
+ if (target.href === void 0) return null;
2739
+ const brand = brandKeyForUrl(target.href);
2740
+ if (brand) return `/brand-logos/${brand}.png`;
2741
+ const host = parseHttpUrl(target.href)?.hostname;
2742
+ return host ? `https://www.google.com/s2/favicons?domain=${encodeURIComponent(host)}&sz=64` : null;
2743
+ }
2744
+ function SiteIcon({ className, provider, href }) {
2745
+ const src = siteIconUrl({ provider, href });
2746
+ const [failed, setFailed] = React2__namespace.useState(false);
2747
+ React2__namespace.useEffect(() => setFailed(false), [src]);
2748
+ if (!src || failed) {
2749
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2750
+ "svg",
2751
+ {
2752
+ viewBox: "0 0 24 24",
2753
+ fill: "none",
2754
+ stroke: "currentColor",
2755
+ strokeWidth: 2,
2756
+ strokeLinecap: "round",
2757
+ strokeLinejoin: "round",
2758
+ "aria-hidden": true,
2759
+ className: cn("size-4 shrink-0 text-muted-foreground", className),
2760
+ children: [
2761
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "10" }),
2762
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20" }),
2763
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 12h20" })
2764
+ ]
2765
+ }
2766
+ );
2767
+ }
2768
+ return /* @__PURE__ */ jsxRuntime.jsx(
2769
+ "img",
2770
+ {
2771
+ src,
2772
+ alt: "",
2773
+ "aria-hidden": true,
2774
+ loading: "lazy",
2775
+ referrerPolicy: "no-referrer",
2776
+ onError: () => setFailed(true),
2777
+ className: cn("size-4 shrink-0 rounded-[22%] object-contain", className)
2778
+ }
2779
+ );
2780
+ }
2662
2781
 
2663
2782
  exports.AppApiProvider = AppApiProvider;
2664
2783
  exports.AppContextProvider = AppContextProvider;
2665
2784
  exports.AppInvokeError = AppInvokeError;
2666
2785
  exports.AreaChart = AreaChart;
2786
+ exports.BRAND_LOGO_KEYS = BRAND_LOGO_KEYS;
2667
2787
  exports.Badge = Badge;
2668
2788
  exports.BarChart = BarChart;
2669
2789
  exports.Button = Button;
@@ -2691,6 +2811,7 @@ exports.PERIOD_PRESETS = PERIOD_PRESETS;
2691
2811
  exports.Popover = Popover;
2692
2812
  exports.Select = Select;
2693
2813
  exports.SidePanel = SidePanel;
2814
+ exports.SiteIcon = SiteIcon;
2694
2815
  exports.Spinner = Spinner;
2695
2816
  exports.StackedBarChart = StackedBarChart;
2696
2817
  exports.Switch = Switch;
@@ -2708,6 +2829,7 @@ exports.Textarea = Textarea;
2708
2829
  exports.ToastProvider = ToastProvider;
2709
2830
  exports.Tooltip = Tooltip2;
2710
2831
  exports.badgeVariants = badgeVariants;
2832
+ exports.brandKeyForUrl = brandKeyForUrl;
2711
2833
  exports.buttonVariants = buttonVariants;
2712
2834
  exports.cn = cn;
2713
2835
  exports.comparisonRange = comparisonRange;
@@ -2717,9 +2839,11 @@ exports.downloadCsv = downloadCsv;
2717
2839
  exports.formatCellValue = formatCellValue;
2718
2840
  exports.formatPeriod = formatPeriod;
2719
2841
  exports.formatRange = formatRange;
2842
+ exports.isBrandLogoKey = isBrandLogoKey;
2720
2843
  exports.makePeriod = makePeriod;
2721
2844
  exports.periodFromPreset = periodFromPreset;
2722
2845
  exports.relativeDelta = relativeDelta;
2846
+ exports.siteIconUrl = siteIconUrl;
2723
2847
  exports.toCsv = toCsv;
2724
2848
  exports.useAppApi = useAppApi;
2725
2849
  exports.useAppContext = useAppContext;