@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.
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react");function d(h={}){const{threshold:i=150,interactionTimeout:a=150}=h,o=r.useRef(null),f=r.useRef(!0),u=r.useRef(!1),l=r.useCallback(()=>{const e=o.current;return e?e.scrollHeight-e.clientHeight-e.scrollTop<i:!1},[i]),n=r.useCallback((e=!1)=>{const t=o.current;!t||u.current||t.scrollTo({top:t.scrollHeight,behavior:e?"smooth":"auto"})},[]);return r.useEffect(()=>{const e=o.current;if(!e)return;let t;const s=()=>{u.current=!0,f.current=l(),window.clearTimeout(t),t=window.setTimeout(()=>{u.current=!1},a)};return e.addEventListener("scroll",s,{passive:!0}),()=>{e.removeEventListener("scroll",s),window.clearTimeout(t)}},[l,a]),r.useEffect(()=>{const e=o.current;if(!e)return;const t=new MutationObserver(s=>{s.some(c=>c.type==="childList"||c.type==="characterData"||c.type==="attributes"&&c.attributeName==="style")&&f.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]),{containerRef:o,scrollToBottom:n,isNearBottom:l}}exports.useScrollToBottom=d;
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 u, useCallback as d, useEffect as i } from "react";
3
- function v(m = {}) {
4
- const { threshold: a = 150, interactionTimeout: f = 150 } = m, r = u(null), h = u(!0), s = u(!1), l = d(() => {
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
- !e || s.current || e.scrollTo({
10
- top: e.scrollHeight,
11
- behavior: t ? "smooth" : "auto"
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 i(() => {
15
- const t = r.current;
16
- if (!t) return;
17
- let e;
18
- const n = () => {
19
- s.current = !0, h.current = l(), window.clearTimeout(e), e = window.setTimeout(() => {
20
- s.current = !1;
21
- }, f);
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 t.addEventListener("scroll", n, { passive: !0 }), () => {
24
- t.removeEventListener("scroll", n), window.clearTimeout(e);
23
+ return e.addEventListener("scroll", s, { passive: !0 }), () => {
24
+ e.removeEventListener("scroll", s), window.clearTimeout(t);
25
25
  };
26
- }, [l, f]), i(() => {
27
- const t = r.current;
28
- if (!t) return;
29
- const e = new MutationObserver((n) => {
30
- n.some(
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
- ) && h.current && o(!0);
32
+ ) && i.current && n(!0);
33
33
  });
34
- return e.observe(t, {
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
- }), () => e.disconnect();
42
- }, [o]), i(() => {
43
- r.current && o();
44
- }, [o]), {
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: o,
53
+ scrollToBottom: n,
47
54
  isNearBottom: l
48
55
  };
49
56
  }
50
57
  export {
51
- v as useScrollToBottom
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.111",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;
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.111",
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"),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:`
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
- `}}),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;
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 j, Fragment as z, jsx as c } from "react/jsx-runtime";
3
- import { createColorScheme as A, createCSSVariables as E } from "@inkeep/cxkit-theme";
4
- import { ColorModeProvider as N } from "@inkeep/cxkit-color-mode";
5
- import { useInkeepConfig as P } from "./config-provider.js";
6
- import { merge as R } from "merge-anything";
7
- import { useCustomStyles as _ } from "../atoms/custom-styles.js";
8
- import { useState as q, useRef as B, useEffect as O } from "react";
9
- const Z = ({ children: u }) => {
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),
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
- zIndex: v
15
- }, w = E(k), { customStyles: x, loaded: F } = _(), { sync: e, forcedColorMode: T, ...V } = y ?? {}, [D, a] = q(), H = B(null);
16
- return O(() => {
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
- (L, d) => ({
23
- ...L,
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
- }), H.current = s;
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__ */ j(z, { children: [
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
- x,
54
- F && /* @__PURE__ */ c(
55
- N,
55
+ T,
56
+ V && /* @__PURE__ */ c(
57
+ P,
56
58
  {
57
- forcedColorMode: T ?? D,
58
- ...V,
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
- ...w
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
- Z as ThemeProvider
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.111",
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.111",
71
- "@inkeep/cxkit-theme": "0.5.111",
72
- "@inkeep/cxkit-types": "0.5.111"
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",