@inkeep/cxkit-primitives 0.5.89 → 0.5.91
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/atoms/shadow/context.cjs +1 -2
- package/dist/atoms/shadow/context.js +16 -17
- package/dist/providers/base-events-provider.cjs +1 -1
- package/dist/providers/base-events-provider.js +1 -1
- package/dist/providers/theme-provider.cjs +3 -1
- package/dist/providers/theme-provider.js +43 -32
- package/package.json +4 -4
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),n=require("react"),
|
|
2
|
-
${l}`}}),a,o.jsx("div",{id:"inkeep-widget-root",ref:t=>{t&&x(t)},style:e,children:o.jsx(c.Provider,{value:w,children:s&&r&&i})})]})}const v=e=>d()?e.children:o.jsx(u,{...e});exports.InkeepShadow=v;exports.InkeepShadowProvider=u;exports.ShadowContext=c;exports.useShadow=d;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),n=require("react"),v=require("./root.cjs"),j=require("@radix-ui/react-id"),c=n.createContext(void 0),i=()=>n.useContext(c);function u({wrapperStyles:e={},children:d,customStyles:a,styles:l}){const[s,h]=n.useState(null),[r,x]=n.useState(null),S=n.useMemo(()=>({shadowHost:s,rootElement:r}),[s,r]),w=j.useId(),f=v.default.div;return o.jsxs(f,{id:`inkeep-shadow${w}`,ref:t=>{t&&h(t)},style:e,children:[o.jsx("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`${l}`}}),a,o.jsx("div",{id:"inkeep-widget-root",ref:t=>{t&&x(t)},style:e,children:o.jsx(c.Provider,{value:S,children:s&&r&&d})})]})}const I=e=>i()?e.children:o.jsx(u,{...e});exports.InkeepShadow=I;exports.InkeepShadowProvider=u;exports.ShadowContext=c;exports.useShadow=i;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import
|
|
5
|
-
import { useId as
|
|
6
|
-
const c =
|
|
2
|
+
import { jsxs as f, jsx as o } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as w, useContext as p, useState as i, useMemo as v } from "react";
|
|
4
|
+
import S from "./root.js";
|
|
5
|
+
import { useId as k } from "@radix-ui/react-id";
|
|
6
|
+
const c = w(void 0), y = () => p(c);
|
|
7
7
|
function I({
|
|
8
8
|
wrapperStyles: t = {},
|
|
9
9
|
children: s,
|
|
10
10
|
customStyles: d,
|
|
11
|
-
styles:
|
|
11
|
+
styles: u
|
|
12
12
|
}) {
|
|
13
|
-
const [n,
|
|
14
|
-
return /* @__PURE__ */
|
|
15
|
-
|
|
13
|
+
const [n, l] = i(null), [r, h] = i(null), m = v(() => ({ shadowHost: n, rootElement: r }), [n, r]), x = k(), a = S.div;
|
|
14
|
+
return /* @__PURE__ */ f(
|
|
15
|
+
a,
|
|
16
16
|
{
|
|
17
|
-
id: `inkeep-shadow${
|
|
17
|
+
id: `inkeep-shadow${x}`,
|
|
18
18
|
ref: (e) => {
|
|
19
|
-
e &&
|
|
19
|
+
e && l(e);
|
|
20
20
|
},
|
|
21
21
|
style: t,
|
|
22
22
|
children: [
|
|
@@ -25,8 +25,7 @@ function I({
|
|
|
25
25
|
{
|
|
26
26
|
type: "text/css",
|
|
27
27
|
dangerouslySetInnerHTML: {
|
|
28
|
-
__html:
|
|
29
|
-
${l}`
|
|
28
|
+
__html: `${u}`
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
),
|
|
@@ -36,20 +35,20 @@ function I({
|
|
|
36
35
|
{
|
|
37
36
|
id: "inkeep-widget-root",
|
|
38
37
|
ref: (e) => {
|
|
39
|
-
e &&
|
|
38
|
+
e && h(e);
|
|
40
39
|
},
|
|
41
40
|
style: t,
|
|
42
|
-
children: /* @__PURE__ */ o(c.Provider, { value:
|
|
41
|
+
children: /* @__PURE__ */ o(c.Provider, { value: m, children: n && r && s })
|
|
43
42
|
}
|
|
44
43
|
)
|
|
45
44
|
]
|
|
46
45
|
}
|
|
47
46
|
);
|
|
48
47
|
}
|
|
49
|
-
const E = (t) =>
|
|
48
|
+
const E = (t) => y() ? t.children : /* @__PURE__ */ o(I, { ...t });
|
|
50
49
|
export {
|
|
51
50
|
E as InkeepShadow,
|
|
52
51
|
I as InkeepShadowProvider,
|
|
53
52
|
c as ShadowContext,
|
|
54
|
-
|
|
53
|
+
y as useShadow
|
|
55
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.91",componentType:r,tags:a}),[r,a]),d=!m.optOutAllAnalytics&&g!=="development",P={logEvent:t.useCallback(async n=>{const o={...l,...n.properties,...v},p={eventName:n.eventName,properties:o,userProperties:u},y=["modal_opened","modal_closed"].includes(n.eventName);if(d&&!y){if("conversation"in o&&!o.conversation?.id)return;f.logEvent(p,i,c)}s.onEvent?.(p)},[d,s,i,c,u,l,v])};return B.jsx(E.Provider,{value:P,children:e})},C=()=>{const e=t.useContext(E);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=q;exports.useBaseEvents=C;
|
|
@@ -7,7 +7,7 @@ import { useUser as A } from "./user-provider.js";
|
|
|
7
7
|
const u = B(void 0), $ = ({ children: e }) => {
|
|
8
8
|
const { baseSettings: t, componentType: s } = w(), { apiKey: r, analyticsApiBaseUrl: i, tags: a, privacyPreferences: d, env: E, analyticsProperties: c } = t, { userProperties: v } = A(), p = P(
|
|
9
9
|
() => ({
|
|
10
|
-
widgetLibraryVersion: "0.5.
|
|
10
|
+
widgetLibraryVersion: "0.5.91",
|
|
11
11
|
componentType: s,
|
|
12
12
|
tags: a
|
|
13
13
|
}),
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),m=require("@inkeep/cxkit-theme"),D=require("@inkeep/cxkit-color-mode"),H=require("./config-provider.cjs"),L=require("merge-anything"),z=require("../atoms/custom-styles.cjs"),i=require("react"),E=({children:g})=>{const{baseSettings:y}=H.useInkeepConfig(),{theme:s,primaryBrandColor:h,shadowHost:f,rootElement:b,colorMode:S}=y,{primaryColors:C,varsClassName:M}=s,{disableLoadingDefaultFont:p,fontFamily:v,fontSize:x,zIndex:q}=s,k=m.createColorScheme(C,h),T={colors:L.merge(s.colors,k),fontFamily:v,fontSize:x,zIndex:q},j=m.createCSSVariables(T),{customStyles:I,loaded:w}=z.useCustomStyles(),{sync:e,forcedColorMode:P,...F}=S??{},[R,l]=i.useState(),V=i.useRef(null);return i.useEffect(()=>{if(!e?.target)return;const o=typeof e.target=="string"?document.querySelector(e.target):e.target;if(!o)return;function a(c,r){return r.reduce((A,d)=>({...A,[d]:c.getAttribute(d)}),{})}const n=new MutationObserver(()=>{const c=a(o,e.attributes),r=e.isDarkMode?.(c)?"dark":"light";e.onChange?.(r),l(r)});n.observe(o,{attributes:!0,attributeFilter:e.attributes,childList:!1,subtree:!1}),V.current=n;const u=e.isDarkMode?.(a(o,e?.attributes))?"dark":"light";return e.onChange?.(u),l(u),()=>n.disconnect()},[e]),t.jsxs(t.Fragment,{children:[!p&&t.jsx("style",{type:"text/css",dangerouslySetInnerHTML:{__html:`
|
|
2
|
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;900&display=swap');
|
|
3
|
+
`}}),I,w&&t.jsx(D.ColorModeProvider,{forcedColorMode:P??R,...F,shadowHostId:f?.id,rootId:b?.id,children:t.jsx("div",{className:M,style:{display:"contents",...j},children:g})})]})};exports.ThemeProvider=E;
|
|
@@ -1,59 +1,70 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { createColorScheme as
|
|
2
|
+
import { jsxs as j, Fragment as z, jsx as c } from "react/jsx-runtime";
|
|
3
|
+
import { createColorScheme as A, createCSSVariables as E } from "@inkeep/cxkit-theme";
|
|
4
4
|
import { ColorModeProvider as N } from "@inkeep/cxkit-color-mode";
|
|
5
5
|
import { useInkeepConfig as P } from "./config-provider.js";
|
|
6
6
|
import { merge as R } from "merge-anything";
|
|
7
|
-
import { useCustomStyles as
|
|
8
|
-
import { useState as
|
|
7
|
+
import { useCustomStyles as _ } from "../atoms/custom-styles.js";
|
|
8
|
+
import { useState as q, useRef as B, useEffect as O } from "react";
|
|
9
9
|
const Z = ({ children: u }) => {
|
|
10
|
-
const { baseSettings: m } = P(), { theme: r, primaryBrandColor: f, shadowHost: g, rootElement:
|
|
11
|
-
colors: R(r.colors,
|
|
12
|
-
fontFamily:
|
|
13
|
-
fontSize:
|
|
14
|
-
zIndex:
|
|
15
|
-
},
|
|
10
|
+
const { baseSettings: m } = P(), { theme: r, primaryBrandColor: f, shadowHost: g, rootElement: p, colorMode: y } = m, { primaryColors: h, varsClassName: b } = r, { disableLoadingDefaultFont: C, fontFamily: M, fontSize: S, zIndex: v } = r, I = A(h, f), k = {
|
|
11
|
+
colors: R(r.colors, I),
|
|
12
|
+
fontFamily: M,
|
|
13
|
+
fontSize: S,
|
|
14
|
+
zIndex: v
|
|
15
|
+
}, w = E(k), { customStyles: x, loaded: F } = _(), { sync: e, forcedColorMode: T, ...V } = y ?? {}, [D, a] = q(), H = B(null);
|
|
16
16
|
return O(() => {
|
|
17
17
|
if (!e?.target) return;
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
20
|
-
function i(n,
|
|
21
|
-
return
|
|
22
|
-
(
|
|
23
|
-
...
|
|
24
|
-
[
|
|
18
|
+
const t = typeof e.target == "string" ? document.querySelector(e.target) : e.target;
|
|
19
|
+
if (!t) return;
|
|
20
|
+
function i(n, o) {
|
|
21
|
+
return o.reduce(
|
|
22
|
+
(L, d) => ({
|
|
23
|
+
...L,
|
|
24
|
+
[d]: n.getAttribute(d)
|
|
25
25
|
}),
|
|
26
26
|
{}
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
29
|
const s = new MutationObserver(() => {
|
|
30
|
-
const n = i(
|
|
31
|
-
e.onChange?.(
|
|
30
|
+
const n = i(t, e.attributes), o = e.isDarkMode?.(n) ? "dark" : "light";
|
|
31
|
+
e.onChange?.(o), a(o);
|
|
32
32
|
});
|
|
33
|
-
s.observe(
|
|
33
|
+
s.observe(t, {
|
|
34
34
|
attributes: !0,
|
|
35
35
|
attributeFilter: e.attributes,
|
|
36
36
|
childList: !1,
|
|
37
37
|
subtree: !1
|
|
38
|
-
}),
|
|
39
|
-
const
|
|
40
|
-
return e.onChange?.(
|
|
41
|
-
}, [e]), /* @__PURE__ */
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
}), H.current = s;
|
|
39
|
+
const l = e.isDarkMode?.(i(t, e?.attributes)) ? "dark" : "light";
|
|
40
|
+
return e.onChange?.(l), a(l), () => s.disconnect();
|
|
41
|
+
}, [e]), /* @__PURE__ */ j(z, { children: [
|
|
42
|
+
!C && /* @__PURE__ */ c(
|
|
43
|
+
"style",
|
|
44
|
+
{
|
|
45
|
+
type: "text/css",
|
|
46
|
+
dangerouslySetInnerHTML: {
|
|
47
|
+
__html: `
|
|
48
|
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;900&display=swap');
|
|
49
|
+
`
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
x,
|
|
54
|
+
F && /* @__PURE__ */ c(
|
|
44
55
|
N,
|
|
45
56
|
{
|
|
46
|
-
forcedColorMode:
|
|
47
|
-
...
|
|
57
|
+
forcedColorMode: T ?? D,
|
|
58
|
+
...V,
|
|
48
59
|
shadowHostId: g?.id,
|
|
49
|
-
rootId:
|
|
50
|
-
children: /* @__PURE__ */
|
|
60
|
+
rootId: p?.id,
|
|
61
|
+
children: /* @__PURE__ */ c(
|
|
51
62
|
"div",
|
|
52
63
|
{
|
|
53
|
-
className:
|
|
64
|
+
className: b,
|
|
54
65
|
style: {
|
|
55
66
|
display: "contents",
|
|
56
|
-
...
|
|
67
|
+
...w
|
|
57
68
|
},
|
|
58
69
|
children: u
|
|
59
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/cxkit-primitives",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.91",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Inkeep, Inc. Customer License (IICL) v1.1",
|
|
6
6
|
"homepage": "",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"remark-gfm": "^4.0.1",
|
|
64
64
|
"unist-util-visit": "^5.0.0",
|
|
65
65
|
"use-sync-external-store": "^1.4.0",
|
|
66
|
-
"@inkeep/cxkit-color-mode": "0.5.
|
|
67
|
-
"@inkeep/cxkit-theme": "0.5.
|
|
68
|
-
"@inkeep/cxkit-types": "0.5.
|
|
66
|
+
"@inkeep/cxkit-color-mode": "0.5.91",
|
|
67
|
+
"@inkeep/cxkit-theme": "0.5.91",
|
|
68
|
+
"@inkeep/cxkit-types": "0.5.91"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@biomejs/biome": "1.9.4",
|