@xbrain-swe/nova-chat-widget 0.1.2 → 0.1.4

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.d.cts CHANGED
@@ -43,6 +43,10 @@ type FactValue = unknown | (() => unknown);
43
43
  type XbNovaTheme = {
44
44
  accentFrom: string;
45
45
  accentTo: string;
46
+ /** 위젯의 라이트/다크. `"system"`(기본)은 브라우저·OS 설정을 따른다 — 호스트 사이트가 다크
47
+ * 모드를 지원하지 않는데 사용자 OS만 다크이면 사이트는 밝은데 위젯만 어두워진다. 그런 사이트는
48
+ * `"light"`로 고정하고, 사이트 자체 테마를 가진 호스트는 그 값을 넘기면 된다. */
49
+ colorScheme: "light" | "dark" | "system";
46
50
  };
47
51
 
48
52
  declare function XbNovaProvider({ apiKey, botId, appId, screen, apiBaseUrl, clientActions, theme, children, }: {
package/dist/index.d.ts CHANGED
@@ -43,6 +43,10 @@ type FactValue = unknown | (() => unknown);
43
43
  type XbNovaTheme = {
44
44
  accentFrom: string;
45
45
  accentTo: string;
46
+ /** 위젯의 라이트/다크. `"system"`(기본)은 브라우저·OS 설정을 따른다 — 호스트 사이트가 다크
47
+ * 모드를 지원하지 않는데 사용자 OS만 다크이면 사이트는 밝은데 위젯만 어두워진다. 그런 사이트는
48
+ * `"light"`로 고정하고, 사이트 자체 테마를 가진 호스트는 그 값을 넘기면 된다. */
49
+ colorScheme: "light" | "dark" | "system";
46
50
  };
47
51
 
48
52
  declare function XbNovaProvider({ apiKey, botId, appId, screen, apiBaseUrl, clientActions, theme, children, }: {
package/dist/index.js CHANGED
@@ -11,7 +11,8 @@ import { createContext, useContext, useMemo, useRef } from "react";
11
11
  import { jsx } from "react/jsx-runtime";
12
12
  var DEFAULT_THEME = {
13
13
  accentFrom: "#4f46e5",
14
- accentTo: "#7c3aed"
14
+ accentTo: "#7c3aed",
15
+ colorScheme: "system"
15
16
  };
16
17
  var InternalContext = createContext(null);
17
18
  function useXbNovaInternal() {
@@ -921,10 +922,25 @@ function loadCss() {
921
922
  }
922
923
  return cssPromise;
923
924
  }
925
+ function useResolvedScheme(scheme) {
926
+ const [systemDark, setSystemDark] = useState2(false);
927
+ useEffect6(() => {
928
+ if (scheme !== "system") return;
929
+ const mq = window.matchMedia("(prefers-color-scheme: dark)");
930
+ setSystemDark(mq.matches);
931
+ const onChange = (e) => setSystemDark(e.matches);
932
+ mq.addEventListener("change", onChange);
933
+ return () => mq.removeEventListener("change", onChange);
934
+ }, [scheme]);
935
+ if (scheme === "system") return systemDark ? "dark" : "light";
936
+ return scheme;
937
+ }
924
938
  function XbNovaShadowRoot({
925
939
  children,
926
940
  style
927
941
  }) {
942
+ const { theme } = useXbNovaInternal();
943
+ const scheme = useResolvedScheme(theme.colorScheme);
928
944
  const hostRef = useRef6(null);
929
945
  const [mountNode, setMountNode] = useState2(null);
930
946
  const [portalTarget, setPortalTarget] = useState2(null);
@@ -946,6 +962,11 @@ function XbNovaShadowRoot({
946
962
  shadow.appendChild(mount);
947
963
  setMountNode(mount);
948
964
  }, [portalTarget]);
965
+ useEffect6(() => {
966
+ if (!mountNode) return;
967
+ mountNode.dataset.xbnovaScheme = scheme;
968
+ mountNode.style.colorScheme = scheme;
969
+ }, [mountNode, scheme]);
949
970
  if (!portalTarget) return null;
950
971
  return createPortal(
951
972
  /* @__PURE__ */ jsx5("div", { ref: hostRef, style, children: mountNode ? createPortal(children, mountNode) : null }),
@@ -1715,7 +1736,7 @@ function XbNovaChat({
1715
1736
  onChange: (e) => setInput(e.target.value),
1716
1737
  placeholder: "\uC774 \uCC28\uC5D0 \uB300\uD574 \uBB34\uC5C7\uC774\uB4E0 \uBB3C\uC5B4\uBCF4\uC138\uC694",
1717
1738
  disabled: busy,
1718
- className: "xbnova-input-accent flex-1 rounded-full border border-neutral-300 px-3.5 py-2 text-sm outline-none disabled:opacity-50 dark:border-neutral-600 dark:bg-neutral-800"
1739
+ className: "xbnova-input-accent flex-1 rounded-full border border-neutral-300 bg-white px-3.5 py-2 text-sm text-neutral-900 placeholder:text-neutral-400 outline-none disabled:opacity-50 dark:border-neutral-600 dark:bg-neutral-800 dark:text-neutral-100 dark:placeholder:text-neutral-500"
1719
1740
  }
1720
1741
  ),
1721
1742
  /* @__PURE__ */ jsx7(