@chaibuilder/sdk 3.2.6 → 3.2.8
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/{apply-binding-DWIWrG2P.cjs → apply-binding-Bn1KC8uC.cjs} +1 -1
- package/dist/{apply-binding-IFVE37dG.js → apply-binding-DLaiD20q.js} +50 -48
- package/dist/{code-editor-CcHrHTi8.cjs → code-editor-cnBzYLxk.cjs} +1 -1
- package/dist/{code-editor-D0sCfrH7.js → code-editor-vpbOSO05.js} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +17 -17
- package/dist/delete-design-token-BjMakV-b.js +40 -0
- package/dist/delete-design-token-Bzxspf8D.cjs +1 -0
- package/dist/design-token-usage-BDArZ38H.js +120 -0
- package/dist/design-token-usage-CCv4XltM.cjs +1 -0
- package/dist/index-CuANr9iH.cjs +160 -0
- package/dist/index-DvdOXKUE.js +18338 -0
- package/dist/manage-design-tokens-DUoMdCBl.js +241 -0
- package/dist/manage-design-tokens-DpC46NAy.cjs +1 -0
- package/dist/mockServiceWorker.js +105 -63
- package/dist/render.cjs +1 -1
- package/dist/render.d.ts +1 -1
- package/dist/render.js +36 -34
- package/dist/{rte-widget-modal-Cmm0pwQI.js → rte-widget-modal-CXbmmhcb.js} +1 -1
- package/dist/{rte-widget-modal-DM4-dPc0.cjs → rte-widget-modal-DDjf0xui.cjs} +1 -1
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +2 -2
- package/package.json +15 -14
- package/dist/index-CnHzCMny.js +0 -13017
- package/dist/index-Dm31eXM7.cjs +0 -154
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsxs as c, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { g as w, a as _, h as f, i as C, j as I } from "./index-DvdOXKUE.js";
|
|
3
|
+
import "clsx";
|
|
4
|
+
import { noop as O } from "lodash-es";
|
|
5
|
+
import "nanoid";
|
|
6
|
+
import "tailwind-merge";
|
|
7
|
+
import "@chaibuilder/runtime";
|
|
8
|
+
import { useMemo as d, useCallback as z } from "react";
|
|
9
|
+
import "jotai";
|
|
10
|
+
import "sonner";
|
|
11
|
+
import { useTranslation as W } from "react-i18next";
|
|
12
|
+
import { b8 as A, av as E, ay as F, ax as M } from "./tooltip-DUosa-uC.js";
|
|
13
|
+
import { ArrowRightIcon as R, FileIcon as $, GlobeIcon as D } from "@radix-ui/react-icons";
|
|
14
|
+
const b = ({ title: s, items: i, emptyLabel: n, onSelect: t, icon: o }) => /* @__PURE__ */ c("div", { className: "space-y-2", children: [
|
|
15
|
+
/* @__PURE__ */ r("p", { className: "text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: s }),
|
|
16
|
+
i.length > 0 ? /* @__PURE__ */ r("div", { className: "space-y-1", children: i.map((a) => /* @__PURE__ */ r(
|
|
17
|
+
"button",
|
|
18
|
+
{
|
|
19
|
+
type: "button",
|
|
20
|
+
onClick: () => t(a.id),
|
|
21
|
+
className: A(
|
|
22
|
+
"group flex w-full items-center justify-between rounded-md border border-transparent bg-muted/40 px-3 py-1 text-left text-xs transition",
|
|
23
|
+
"hover:border-muted-foreground/20 hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1",
|
|
24
|
+
a.isSelected && "border-primary/40 bg-primary/10 text-primary"
|
|
25
|
+
),
|
|
26
|
+
children: /* @__PURE__ */ c("span", { className: "flex items-center space-x-2", children: [
|
|
27
|
+
o && o,
|
|
28
|
+
/* @__PURE__ */ r("span", { className: "truncate", children: a.label })
|
|
29
|
+
] })
|
|
30
|
+
},
|
|
31
|
+
a.id
|
|
32
|
+
)) }) : /* @__PURE__ */ r("div", { className: "rounded border border-dashed border-muted px-3 py-1 text-xs text-muted-foreground", children: n })
|
|
33
|
+
] }), G = "#styles:", X = (s) => {
|
|
34
|
+
const n = [
|
|
35
|
+
typeof s._name == "string" ? s._name : void 0,
|
|
36
|
+
typeof s._type == "string" ? s._type : void 0
|
|
37
|
+
].filter(Boolean).find((t) => t.trim().length > 0);
|
|
38
|
+
return n ? n.length > 40 ? `${n.slice(0, 37)}...` : n : s._id;
|
|
39
|
+
}, Y = (s, i) => {
|
|
40
|
+
const n = `${i}`;
|
|
41
|
+
return s.filter((t) => Object.values(t).some((o) => typeof o != "string" || !o.startsWith(G) ? !1 : o.includes(n))).map((t) => ({
|
|
42
|
+
id: t._id,
|
|
43
|
+
label: X(t)
|
|
44
|
+
}));
|
|
45
|
+
}, ie = ({ tokenId: s, tokenName: i, children: n }) => {
|
|
46
|
+
const { t } = W(), [o] = w(), [a, g] = _(), h = f("pageId"), u = f("siteWideUsage"), y = d(() => Y(o, s), [o, s]), k = d(
|
|
47
|
+
() => y.map((e) => ({
|
|
48
|
+
id: e.id,
|
|
49
|
+
label: e.label,
|
|
50
|
+
isSelected: a.includes(e.id)
|
|
51
|
+
})),
|
|
52
|
+
[y, a]
|
|
53
|
+
), m = d(() => u ? Object.entries(u).reduce(
|
|
54
|
+
(e, [p, l]) => (p === h || !(l != null && l.designTokens) || !Object.keys(l.designTokens).some((P) => typeof P != "string" ? !1 : P === s) || e.push({ id: p, name: l.name || p, isPartial: !!l.isPartial }), e),
|
|
55
|
+
[]
|
|
56
|
+
) : [], [u, i, s, h]), v = d(
|
|
57
|
+
() => m.filter((e) => !e.isPartial).map((e) => ({
|
|
58
|
+
id: e.id,
|
|
59
|
+
label: e.name
|
|
60
|
+
})),
|
|
61
|
+
[m]
|
|
62
|
+
), S = d(
|
|
63
|
+
() => m.filter((e) => e.isPartial).map((e) => ({
|
|
64
|
+
id: e.id,
|
|
65
|
+
label: e.name
|
|
66
|
+
})),
|
|
67
|
+
[m]
|
|
68
|
+
), N = z(
|
|
69
|
+
(e) => {
|
|
70
|
+
g([e]);
|
|
71
|
+
},
|
|
72
|
+
[g]
|
|
73
|
+
), B = f("gotoPage", O), { selectedLang: T, fallbackLang: L } = C(), { savePageAsync: j } = I(), x = async (e) => {
|
|
74
|
+
e && (await j(!0), B({ pageId: e, lang: T || L }));
|
|
75
|
+
};
|
|
76
|
+
return /* @__PURE__ */ c(E, { children: [
|
|
77
|
+
/* @__PURE__ */ r(F, { asChild: !0, children: n }),
|
|
78
|
+
/* @__PURE__ */ c(M, { side: "bottom", align: "end", className: "w-80 p-0", children: [
|
|
79
|
+
/* @__PURE__ */ c("div", { className: "space-y-1 px-4 py-3", children: [
|
|
80
|
+
/* @__PURE__ */ r("p", { className: "text-xs font-semibold", children: i }),
|
|
81
|
+
/* @__PURE__ */ r("p", { className: "text-[11px] text-muted-foreground", children: t("Usage summary for this design token across your site.") })
|
|
82
|
+
] }),
|
|
83
|
+
/* @__PURE__ */ c("div", { className: "no-scrollbar max-h-64 space-y-4 overflow-y-auto px-4 pb-4", children: [
|
|
84
|
+
/* @__PURE__ */ r(
|
|
85
|
+
b,
|
|
86
|
+
{
|
|
87
|
+
title: t("Blocks affected on this page"),
|
|
88
|
+
items: k,
|
|
89
|
+
emptyLabel: t("None"),
|
|
90
|
+
onSelect: N,
|
|
91
|
+
icon: /* @__PURE__ */ r(R, { fontSize: 4 })
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ r(
|
|
95
|
+
b,
|
|
96
|
+
{
|
|
97
|
+
title: t("Blocks affected on other pages"),
|
|
98
|
+
items: v,
|
|
99
|
+
emptyLabel: t("None"),
|
|
100
|
+
onSelect: x,
|
|
101
|
+
icon: /* @__PURE__ */ r($, { fontSize: 8 })
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
/* @__PURE__ */ r(
|
|
105
|
+
b,
|
|
106
|
+
{
|
|
107
|
+
title: t("Blocks affected on partial blocks"),
|
|
108
|
+
items: S,
|
|
109
|
+
emptyLabel: t("None"),
|
|
110
|
+
onSelect: x,
|
|
111
|
+
icon: /* @__PURE__ */ r(D, { fontSize: 8 })
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
] })
|
|
115
|
+
] })
|
|
116
|
+
] });
|
|
117
|
+
};
|
|
118
|
+
export {
|
|
119
|
+
ie as default
|
|
120
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),a=require("./index-CuANr9iH.cjs");require("clsx");const L=require("lodash-es");require("nanoid");require("tailwind-merge");require("@chaibuilder/runtime");const d=require("react");require("jotai");require("sonner");const w=require("react-i18next"),m=require("./tooltip-Ba1-8jmj.cjs"),x=require("@radix-ui/react-icons"),b=({title:r,items:i,emptyLabel:n,onSelect:t,icon:o})=>s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:r}),i.length>0?s.jsx("div",{className:"space-y-1",children:i.map(l=>s.jsx("button",{type:"button",onClick:()=>t(l.id),className:m.cn("group flex w-full items-center justify-between rounded-md border border-transparent bg-muted/40 px-3 py-1 text-left text-xs transition","hover:border-muted-foreground/20 hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1",l.isSelected&&"border-primary/40 bg-primary/10 text-primary"),children:s.jsxs("span",{className:"flex items-center space-x-2",children:[o&&o,s.jsx("span",{className:"truncate",children:l.label})]})},l.id))}):s.jsx("div",{className:"rounded border border-dashed border-muted px-3 py-1 text-xs text-muted-foreground",children:n})]}),M="#styles:",_=r=>{const n=[typeof r._name=="string"?r._name:void 0,typeof r._type=="string"?r._type:void 0].filter(Boolean).find(t=>t.trim().length>0);return n?n.length>40?`${n.slice(0,37)}...`:n:r._id},C=(r,i)=>{const n=`${i}`;return r.filter(t=>Object.values(t).some(o=>typeof o!="string"||!o.startsWith(M)?!1:o.includes(n))).map(t=>({id:t._id,label:_(t)}))},O=({tokenId:r,tokenName:i,children:n})=>{const{t}=w.useTranslation(),[o]=a.useBlocksStore(),[l,g]=a.useSelectedBlockIds(),h=a.useBuilderProp("pageId"),f=a.useBuilderProp("siteWideUsage"),y=d.useMemo(()=>C(o,r),[o,r]),S=d.useMemo(()=>y.map(e=>({id:e.id,label:e.label,isSelected:l.includes(e.id)})),[y,l]),u=d.useMemo(()=>f?Object.entries(f).reduce((e,[p,c])=>(p===h||!(c!=null&&c.designTokens)||!Object.keys(c.designTokens).some(P=>typeof P!="string"?!1:P===r)||e.push({id:p,name:c.name||p,isPartial:!!c.isPartial}),e),[]):[],[f,i,r,h]),k=d.useMemo(()=>u.filter(e=>!e.isPartial).map(e=>({id:e.id,label:e.name})),[u]),v=d.useMemo(()=>u.filter(e=>e.isPartial).map(e=>({id:e.id,label:e.name})),[u]),B=d.useCallback(e=>{g([e])},[g]),N=a.useBuilderProp("gotoPage",L.noop),{selectedLang:q,fallbackLang:T}=a.useLanguages(),{savePageAsync:I}=a.useSavePage(),j=async e=>{e&&(await I(!0),N({pageId:e,lang:q||T}))};return s.jsxs(m.Popover,{children:[s.jsx(m.PopoverTrigger,{asChild:!0,children:n}),s.jsxs(m.PopoverContent,{side:"bottom",align:"end",className:"w-80 p-0",children:[s.jsxs("div",{className:"space-y-1 px-4 py-3",children:[s.jsx("p",{className:"text-xs font-semibold",children:i}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:t("Usage summary for this design token across your site.")})]}),s.jsxs("div",{className:"no-scrollbar max-h-64 space-y-4 overflow-y-auto px-4 pb-4",children:[s.jsx(b,{title:t("Blocks affected on this page"),items:S,emptyLabel:t("None"),onSelect:B,icon:s.jsx(x.ArrowRightIcon,{fontSize:4})}),s.jsx(b,{title:t("Blocks affected on other pages"),items:k,emptyLabel:t("None"),onSelect:j,icon:s.jsx(x.FileIcon,{fontSize:8})}),s.jsx(b,{title:t("Blocks affected on partial blocks"),items:v,emptyLabel:t("None"),onSelect:j,icon:s.jsx(x.GlobeIcon,{fontSize:8})})]})]})]})};exports.default=O;
|