@inkeep/cxkit-primitives 0.5.111 → 0.5.113
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/hooks/use-scroll-to-bottom.cjs +1 -1
- package/dist/hooks/use-scroll-to-bottom.js +39 -32
- package/dist/index.d.cts +48 -0
- package/dist/index.d.ts +48 -0
- package/dist/providers/base-events-provider.cjs +1 -1
- package/dist/providers/base-events-provider.js +1 -1
- package/dist/providers/theme-provider.cjs +2 -2
- package/dist/providers/theme-provider.js +26 -24
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react");function
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react");function b(h={}){const{threshold:a=150,interactionTimeout:f=150}=h,o=r.useRef(null),l=r.useRef(!0),s=r.useRef(!1),i=r.useCallback(()=>{const e=o.current;return e?e.scrollHeight-e.clientHeight-e.scrollTop<a:!1},[a]),n=r.useCallback((e=!1)=>{const t=o.current;!t||s.current||t.scrollTo({top:t.scrollHeight,behavior:e?"smooth":"auto"})},[]);return r.useEffect(()=>{const e=o.current;if(!e)return;let t;const c=()=>{s.current=!0,l.current=i(),window.clearTimeout(t),t=window.setTimeout(()=>{s.current=!1},f)};return e.addEventListener("scroll",c,{passive:!0}),()=>{e.removeEventListener("scroll",c),window.clearTimeout(t)}},[i,f]),r.useEffect(()=>{const e=o.current;if(!e)return;const t=new MutationObserver(c=>{c.some(u=>u.type==="childList"||u.type==="characterData"||u.type==="attributes"&&u.attributeName==="style")&&l.current&&n(!0)});return t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"],characterData:!0}),()=>t.disconnect()},[n]),r.useEffect(()=>{o.current&&n()},[n]),r.useEffect(()=>{const e=o.current;if(!e)return;const t=new ResizeObserver(()=>{l.current&&(s.current=!1,n(!1))});return t.observe(e),()=>t.disconnect()},[n]),{containerRef:o,scrollToBottom:n,isNearBottom:i}}exports.useScrollToBottom=b;
|
|
@@ -1,52 +1,59 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRef as
|
|
3
|
-
function
|
|
4
|
-
const { threshold:
|
|
5
|
-
const t = r.current;
|
|
6
|
-
return t ? t.scrollHeight - t.clientHeight - t.scrollTop < a : !1;
|
|
7
|
-
}, [a]), o = d((t = !1) => {
|
|
2
|
+
import { useRef as a, useCallback as d, useEffect as u } from "react";
|
|
3
|
+
function T(b = {}) {
|
|
4
|
+
const { threshold: f = 150, interactionTimeout: h = 150 } = b, r = a(null), i = a(!0), o = a(!1), l = d(() => {
|
|
8
5
|
const e = r.current;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
return e ? e.scrollHeight - e.clientHeight - e.scrollTop < f : !1;
|
|
7
|
+
}, [f]), n = d((e = !1) => {
|
|
8
|
+
const t = r.current;
|
|
9
|
+
!t || o.current || t.scrollTo({
|
|
10
|
+
top: t.scrollHeight,
|
|
11
|
+
behavior: e ? "smooth" : "auto"
|
|
12
12
|
});
|
|
13
13
|
}, []);
|
|
14
|
-
return
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
17
|
-
let
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
14
|
+
return u(() => {
|
|
15
|
+
const e = r.current;
|
|
16
|
+
if (!e) return;
|
|
17
|
+
let t;
|
|
18
|
+
const s = () => {
|
|
19
|
+
o.current = !0, i.current = l(), window.clearTimeout(t), t = window.setTimeout(() => {
|
|
20
|
+
o.current = !1;
|
|
21
|
+
}, h);
|
|
22
22
|
};
|
|
23
|
-
return
|
|
24
|
-
|
|
23
|
+
return e.addEventListener("scroll", s, { passive: !0 }), () => {
|
|
24
|
+
e.removeEventListener("scroll", s), window.clearTimeout(t);
|
|
25
25
|
};
|
|
26
|
-
}, [l,
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
29
|
-
const
|
|
30
|
-
|
|
26
|
+
}, [l, h]), u(() => {
|
|
27
|
+
const e = r.current;
|
|
28
|
+
if (!e) return;
|
|
29
|
+
const t = new MutationObserver((s) => {
|
|
30
|
+
s.some(
|
|
31
31
|
(c) => c.type === "childList" || c.type === "characterData" || c.type === "attributes" && c.attributeName === "style"
|
|
32
|
-
) &&
|
|
32
|
+
) && i.current && n(!0);
|
|
33
33
|
});
|
|
34
|
-
return
|
|
34
|
+
return t.observe(e, {
|
|
35
35
|
childList: !0,
|
|
36
36
|
subtree: !0,
|
|
37
37
|
attributes: !0,
|
|
38
38
|
attributeFilter: ["style"],
|
|
39
39
|
// Only watch style changes
|
|
40
40
|
characterData: !0
|
|
41
|
-
}), () =>
|
|
42
|
-
}, [
|
|
43
|
-
r.current &&
|
|
44
|
-
}, [
|
|
41
|
+
}), () => t.disconnect();
|
|
42
|
+
}, [n]), u(() => {
|
|
43
|
+
r.current && n();
|
|
44
|
+
}, [n]), u(() => {
|
|
45
|
+
const e = r.current;
|
|
46
|
+
if (!e) return;
|
|
47
|
+
const t = new ResizeObserver(() => {
|
|
48
|
+
i.current && (o.current = !1, n(!1));
|
|
49
|
+
});
|
|
50
|
+
return t.observe(e), () => t.disconnect();
|
|
51
|
+
}, [n]), {
|
|
45
52
|
containerRef: r,
|
|
46
|
-
scrollToBottom:
|
|
53
|
+
scrollToBottom: n,
|
|
47
54
|
isNearBottom: l
|
|
48
55
|
};
|
|
49
56
|
}
|
|
50
57
|
export {
|
|
51
|
-
|
|
58
|
+
T as useScrollToBottom
|
|
52
59
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1400,6 +1400,54 @@ declare const defaultInkeepBaseSettings: {
|
|
|
1400
1400
|
'8xl': string;
|
|
1401
1401
|
'9xl': string;
|
|
1402
1402
|
};
|
|
1403
|
+
spacing: {
|
|
1404
|
+
0: string;
|
|
1405
|
+
px: string;
|
|
1406
|
+
0.5: string;
|
|
1407
|
+
1: string;
|
|
1408
|
+
1.5: string;
|
|
1409
|
+
2: string;
|
|
1410
|
+
2.5: string;
|
|
1411
|
+
3: string;
|
|
1412
|
+
3.5: string;
|
|
1413
|
+
4: string;
|
|
1414
|
+
5: string;
|
|
1415
|
+
6: string;
|
|
1416
|
+
7: string;
|
|
1417
|
+
8: string;
|
|
1418
|
+
9: string;
|
|
1419
|
+
10: string;
|
|
1420
|
+
11: string;
|
|
1421
|
+
12: string;
|
|
1422
|
+
14: string;
|
|
1423
|
+
16: string;
|
|
1424
|
+
20: string;
|
|
1425
|
+
24: string;
|
|
1426
|
+
28: string;
|
|
1427
|
+
32: string;
|
|
1428
|
+
36: string;
|
|
1429
|
+
40: string;
|
|
1430
|
+
44: string;
|
|
1431
|
+
48: string;
|
|
1432
|
+
52: string;
|
|
1433
|
+
56: string;
|
|
1434
|
+
60: string;
|
|
1435
|
+
64: string;
|
|
1436
|
+
72: string;
|
|
1437
|
+
80: string;
|
|
1438
|
+
96: string;
|
|
1439
|
+
};
|
|
1440
|
+
borderRadius: {
|
|
1441
|
+
none: string;
|
|
1442
|
+
sm: string;
|
|
1443
|
+
DEFAULT: string;
|
|
1444
|
+
md: string;
|
|
1445
|
+
lg: string;
|
|
1446
|
+
xl: string;
|
|
1447
|
+
'2xl': string;
|
|
1448
|
+
'3xl': string;
|
|
1449
|
+
full: string;
|
|
1450
|
+
};
|
|
1403
1451
|
zIndex: {
|
|
1404
1452
|
hide: number;
|
|
1405
1453
|
auto: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1400,6 +1400,54 @@ declare const defaultInkeepBaseSettings: {
|
|
|
1400
1400
|
'8xl': string;
|
|
1401
1401
|
'9xl': string;
|
|
1402
1402
|
};
|
|
1403
|
+
spacing: {
|
|
1404
|
+
0: string;
|
|
1405
|
+
px: string;
|
|
1406
|
+
0.5: string;
|
|
1407
|
+
1: string;
|
|
1408
|
+
1.5: string;
|
|
1409
|
+
2: string;
|
|
1410
|
+
2.5: string;
|
|
1411
|
+
3: string;
|
|
1412
|
+
3.5: string;
|
|
1413
|
+
4: string;
|
|
1414
|
+
5: string;
|
|
1415
|
+
6: string;
|
|
1416
|
+
7: string;
|
|
1417
|
+
8: string;
|
|
1418
|
+
9: string;
|
|
1419
|
+
10: string;
|
|
1420
|
+
11: string;
|
|
1421
|
+
12: string;
|
|
1422
|
+
14: string;
|
|
1423
|
+
16: string;
|
|
1424
|
+
20: string;
|
|
1425
|
+
24: string;
|
|
1426
|
+
28: string;
|
|
1427
|
+
32: string;
|
|
1428
|
+
36: string;
|
|
1429
|
+
40: string;
|
|
1430
|
+
44: string;
|
|
1431
|
+
48: string;
|
|
1432
|
+
52: string;
|
|
1433
|
+
56: string;
|
|
1434
|
+
60: string;
|
|
1435
|
+
64: string;
|
|
1436
|
+
72: string;
|
|
1437
|
+
80: string;
|
|
1438
|
+
96: string;
|
|
1439
|
+
};
|
|
1440
|
+
borderRadius: {
|
|
1441
|
+
none: string;
|
|
1442
|
+
sm: string;
|
|
1443
|
+
DEFAULT: string;
|
|
1444
|
+
md: string;
|
|
1445
|
+
lg: string;
|
|
1446
|
+
xl: string;
|
|
1447
|
+
'2xl': string;
|
|
1448
|
+
'3xl': string;
|
|
1449
|
+
full: string;
|
|
1450
|
+
};
|
|
1403
1451
|
zIndex: {
|
|
1404
1452
|
hide: number;
|
|
1405
1453
|
auto: string;
|
|
@@ -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.113",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.113",
|
|
11
11
|
componentType: s,
|
|
12
12
|
tags: a
|
|
13
13
|
}),
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),m=require("@inkeep/cxkit-theme"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),m=require("@inkeep/cxkit-theme"),L=require("@inkeep/cxkit-color-mode"),z=require("./config-provider.cjs"),E=require("merge-anything"),N=require("../atoms/custom-styles.cjs"),i=require("react"),O=({children:g})=>{const{baseSettings:y}=z.useInkeepConfig(),{theme:s,primaryBrandColor:h,shadowHost:f,rootElement:b,colorMode:S}=y,{primaryColors:C,varsClassName:M}=s,{disableLoadingDefaultFont:p,fontFamily:v,fontSize:x,spacing:q,borderRadius:k,zIndex:T}=s,j=m.createColorScheme(C,h),I={colors:E.merge(s.colors,j),fontFamily:v,fontSize:x,spacing:q,borderRadius:k,zIndex:T},w=m.createCSSVariables(I),{customStyles:P,loaded:R}=N.useCustomStyles(),{sync:e,forcedColorMode:F,...V}=S??{},[A,l]=i.useState(),D=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((H,d)=>({...H,[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}),D.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
2
|
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;900&display=swap');
|
|
3
|
-
`}}),
|
|
3
|
+
`}}),P,R&&t.jsx(L.ColorModeProvider,{forcedColorMode:F??A,...V,shadowHostId:f?.id,rootId:b?.id,children:t.jsx("div",{className:M,style:{display:"contents",...w},children:g})})]})};exports.ThemeProvider=O;
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { createColorScheme as
|
|
4
|
-
import { ColorModeProvider as
|
|
5
|
-
import { useInkeepConfig as
|
|
6
|
-
import { merge as
|
|
7
|
-
import { useCustomStyles as
|
|
8
|
-
import { useState as
|
|
9
|
-
const
|
|
10
|
-
const { baseSettings: m } =
|
|
11
|
-
colors:
|
|
2
|
+
import { jsxs as z, Fragment as A, jsx as c } from "react/jsx-runtime";
|
|
3
|
+
import { createColorScheme as E, createCSSVariables as N } from "@inkeep/cxkit-theme";
|
|
4
|
+
import { ColorModeProvider as P } from "@inkeep/cxkit-color-mode";
|
|
5
|
+
import { useInkeepConfig as _ } from "./config-provider.js";
|
|
6
|
+
import { merge as q } from "merge-anything";
|
|
7
|
+
import { useCustomStyles as B } from "../atoms/custom-styles.js";
|
|
8
|
+
import { useState as O, useRef as G, useEffect as J } from "react";
|
|
9
|
+
const ee = ({ children: u }) => {
|
|
10
|
+
const { baseSettings: m } = _(), { theme: r, primaryBrandColor: f, shadowHost: g, rootElement: p, colorMode: y } = m, { primaryColors: h, varsClassName: b } = r, { disableLoadingDefaultFont: C, fontFamily: M, fontSize: S, spacing: v, borderRadius: I, zIndex: k } = r, w = E(h, f), x = {
|
|
11
|
+
colors: q(r.colors, w),
|
|
12
12
|
fontFamily: M,
|
|
13
13
|
fontSize: S,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
spacing: v,
|
|
15
|
+
borderRadius: I,
|
|
16
|
+
zIndex: k
|
|
17
|
+
}, F = N(x), { customStyles: T, loaded: V } = B(), { sync: e, forcedColorMode: D, ...H } = y ?? {}, [L, a] = O(), R = G(null);
|
|
18
|
+
return J(() => {
|
|
17
19
|
if (!e?.target) return;
|
|
18
20
|
const t = typeof e.target == "string" ? document.querySelector(e.target) : e.target;
|
|
19
21
|
if (!t) return;
|
|
20
22
|
function i(n, o) {
|
|
21
23
|
return o.reduce(
|
|
22
|
-
(
|
|
23
|
-
...
|
|
24
|
+
(j, d) => ({
|
|
25
|
+
...j,
|
|
24
26
|
[d]: n.getAttribute(d)
|
|
25
27
|
}),
|
|
26
28
|
{}
|
|
@@ -35,10 +37,10 @@ const Z = ({ children: u }) => {
|
|
|
35
37
|
attributeFilter: e.attributes,
|
|
36
38
|
childList: !1,
|
|
37
39
|
subtree: !1
|
|
38
|
-
}),
|
|
40
|
+
}), R.current = s;
|
|
39
41
|
const l = e.isDarkMode?.(i(t, e?.attributes)) ? "dark" : "light";
|
|
40
42
|
return e.onChange?.(l), a(l), () => s.disconnect();
|
|
41
|
-
}, [e]), /* @__PURE__ */
|
|
43
|
+
}, [e]), /* @__PURE__ */ z(A, { children: [
|
|
42
44
|
!C && /* @__PURE__ */ c(
|
|
43
45
|
"style",
|
|
44
46
|
{
|
|
@@ -50,12 +52,12 @@ const Z = ({ children: u }) => {
|
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
T,
|
|
56
|
+
V && /* @__PURE__ */ c(
|
|
57
|
+
P,
|
|
56
58
|
{
|
|
57
|
-
forcedColorMode:
|
|
58
|
-
...
|
|
59
|
+
forcedColorMode: D ?? L,
|
|
60
|
+
...H,
|
|
59
61
|
shadowHostId: g?.id,
|
|
60
62
|
rootId: p?.id,
|
|
61
63
|
children: /* @__PURE__ */ c(
|
|
@@ -64,7 +66,7 @@ const Z = ({ children: u }) => {
|
|
|
64
66
|
className: b,
|
|
65
67
|
style: {
|
|
66
68
|
display: "contents",
|
|
67
|
-
...
|
|
69
|
+
...F
|
|
68
70
|
},
|
|
69
71
|
children: u
|
|
70
72
|
}
|
|
@@ -74,5 +76,5 @@ const Z = ({ children: u }) => {
|
|
|
74
76
|
] });
|
|
75
77
|
};
|
|
76
78
|
export {
|
|
77
|
-
|
|
79
|
+
ee as ThemeProvider
|
|
78
80
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/cxkit-primitives",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.113",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Inkeep, Inc. Customer License (IICL) v1.1",
|
|
6
6
|
"homepage": "",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"remark-gfm": "^4.0.1",
|
|
68
68
|
"unist-util-visit": "^5.0.0",
|
|
69
69
|
"use-sync-external-store": "^1.4.0",
|
|
70
|
-
"@inkeep/cxkit-color-mode": "^0.5.
|
|
71
|
-
"@inkeep/cxkit-theme": "0.5.
|
|
72
|
-
"@inkeep/cxkit-types": "0.5.
|
|
70
|
+
"@inkeep/cxkit-color-mode": "^0.5.113",
|
|
71
|
+
"@inkeep/cxkit-theme": "0.5.113",
|
|
72
|
+
"@inkeep/cxkit-types": "0.5.113"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@biomejs/biome": "1.9.4",
|