@apotech-os/ui-sdk 7.5.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 +138 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -1
- package/dist/index.d.ts +64 -1
- package/dist/index.js +133 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -50,6 +50,19 @@ function useAppContext() {
|
|
|
50
50
|
if (!ctx) throw new Error("useAppContext must be used inside an app page mounted by the shell");
|
|
51
51
|
return ctx;
|
|
52
52
|
}
|
|
53
|
+
function useAppPageHref() {
|
|
54
|
+
const { appSlug, basePath } = useAppContext();
|
|
55
|
+
const base = basePath ?? `/espace/${appSlug}`;
|
|
56
|
+
return (pagePath, query) => {
|
|
57
|
+
const params = query instanceof URLSearchParams ? query : new URLSearchParams(
|
|
58
|
+
Object.entries(query ?? {}).flatMap(
|
|
59
|
+
([key, value]) => value === null || value === void 0 ? [] : [[key, String(value)]]
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
const search = params.toString();
|
|
63
|
+
return `${base}/${pagePath}${search ? `?${search}` : ""}`;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
53
66
|
var AppInvokeError = class extends Error {
|
|
54
67
|
constructor(status, message, code, invocationId) {
|
|
55
68
|
super(message);
|
|
@@ -2646,11 +2659,131 @@ function Tooltip2({ label, children, side = "top", className }) {
|
|
|
2646
2659
|
)
|
|
2647
2660
|
] });
|
|
2648
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
|
+
}
|
|
2649
2781
|
|
|
2650
2782
|
exports.AppApiProvider = AppApiProvider;
|
|
2651
2783
|
exports.AppContextProvider = AppContextProvider;
|
|
2652
2784
|
exports.AppInvokeError = AppInvokeError;
|
|
2653
2785
|
exports.AreaChart = AreaChart;
|
|
2786
|
+
exports.BRAND_LOGO_KEYS = BRAND_LOGO_KEYS;
|
|
2654
2787
|
exports.Badge = Badge;
|
|
2655
2788
|
exports.BarChart = BarChart;
|
|
2656
2789
|
exports.Button = Button;
|
|
@@ -2678,6 +2811,7 @@ exports.PERIOD_PRESETS = PERIOD_PRESETS;
|
|
|
2678
2811
|
exports.Popover = Popover;
|
|
2679
2812
|
exports.Select = Select;
|
|
2680
2813
|
exports.SidePanel = SidePanel;
|
|
2814
|
+
exports.SiteIcon = SiteIcon;
|
|
2681
2815
|
exports.Spinner = Spinner;
|
|
2682
2816
|
exports.StackedBarChart = StackedBarChart;
|
|
2683
2817
|
exports.Switch = Switch;
|
|
@@ -2695,6 +2829,7 @@ exports.Textarea = Textarea;
|
|
|
2695
2829
|
exports.ToastProvider = ToastProvider;
|
|
2696
2830
|
exports.Tooltip = Tooltip2;
|
|
2697
2831
|
exports.badgeVariants = badgeVariants;
|
|
2832
|
+
exports.brandKeyForUrl = brandKeyForUrl;
|
|
2698
2833
|
exports.buttonVariants = buttonVariants;
|
|
2699
2834
|
exports.cn = cn;
|
|
2700
2835
|
exports.comparisonRange = comparisonRange;
|
|
@@ -2704,12 +2839,15 @@ exports.downloadCsv = downloadCsv;
|
|
|
2704
2839
|
exports.formatCellValue = formatCellValue;
|
|
2705
2840
|
exports.formatPeriod = formatPeriod;
|
|
2706
2841
|
exports.formatRange = formatRange;
|
|
2842
|
+
exports.isBrandLogoKey = isBrandLogoKey;
|
|
2707
2843
|
exports.makePeriod = makePeriod;
|
|
2708
2844
|
exports.periodFromPreset = periodFromPreset;
|
|
2709
2845
|
exports.relativeDelta = relativeDelta;
|
|
2846
|
+
exports.siteIconUrl = siteIconUrl;
|
|
2710
2847
|
exports.toCsv = toCsv;
|
|
2711
2848
|
exports.useAppApi = useAppApi;
|
|
2712
2849
|
exports.useAppContext = useAppContext;
|
|
2850
|
+
exports.useAppPageHref = useAppPageHref;
|
|
2713
2851
|
exports.useAppRun = useAppRun;
|
|
2714
2852
|
exports.useAppRuns = useAppRuns;
|
|
2715
2853
|
exports.useAppSettings = useAppSettings;
|