@djangocfg/widget-assistant 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/package.json +7 -7
  2. package/src/i18n/index.ts +11 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/widget-assistant",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A site assistant on top of @djangocfg/widget-chat: the SSE wire and session layer, a persistent host, docked column, floating button and sheet, dictation, Help and 17 built-in locales",
5
5
  "keywords": [
6
6
  "chat",
@@ -44,19 +44,19 @@
44
44
  "test": "vitest run"
45
45
  },
46
46
  "dependencies": {
47
- "@djangocfg/widget-chat": "^0.1.14",
47
+ "@djangocfg/widget-chat": "^0.1.16",
48
48
  "zustand": "^5.0.14"
49
49
  },
50
50
  "peerDependencies": {
51
- "@djangocfg/i18n": "^2.1.585",
52
- "@djangocfg/ui-core": "^2.1.585",
51
+ "@djangocfg/i18n": "^2.1.586",
52
+ "@djangocfg/ui-core": "^2.1.586",
53
53
  "lucide-react": "^0.545.0",
54
54
  "react": "^19.0.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@djangocfg/i18n": "^2.1.585",
58
- "@djangocfg/typescript-config": "^2.1.585",
59
- "@djangocfg/ui-core": "^2.1.585",
57
+ "@djangocfg/i18n": "^2.1.586",
58
+ "@djangocfg/typescript-config": "^2.1.586",
59
+ "@djangocfg/ui-core": "^2.1.586",
60
60
  "@storybook/react-vite": "^10.5.0",
61
61
  "@types/node": "^25.9.5",
62
62
  "@types/react": "19.2.15",
package/src/i18n/index.ts CHANGED
@@ -1,6 +1,4 @@
1
- import { useMemo } from 'react';
2
-
3
- import { useLocaleOptional } from '@djangocfg/i18n';
1
+ import { createCopy, type Locale } from '@djangocfg/i18n/copy';
4
2
 
5
3
  import { ar } from './locales/ar';
6
4
  import { da } from './locales/da';
@@ -23,14 +21,16 @@ import type { AssistantCopy } from './types';
23
21
 
24
22
  export type { AssistantCopy } from './types';
25
23
 
26
- /** Every bundled dictionary, keyed by the language code the app reports; the same seventeen languages as the framework widget. */
27
- export const ASSISTANT_DICTIONARIES: Readonly<Record<string, AssistantCopy>> = { ar, da, de, en, es, fr, it, ja, ko, nl, no, pl, 'pt-BR': ptBR, ru, sv, tr, zh };
24
+ /** Every bundled dictionary, typed complete over the shared `Locale` union. */
25
+ export const ASSISTANT_DICTIONARIES: Readonly<Record<Locale, AssistantCopy>> = {
26
+ en, ru, ko, ja, de, fr, zh, it, es, nl, ar, tr, pl, sv, no, da,
27
+ 'pt-BR': ptBR,
28
+ };
29
+
30
+ const kit = createCopy(ASSISTANT_DICTIONARIES);
28
31
 
29
32
  /**
30
- * The assistant's own words for the active language (English for one not yet translated). The host passes no strings: the language comes from the framework's
31
- * locale provider, the one the widget's built-in composer copy already follows. With no provider (a story, a test) it is English.
33
+ * The assistant's own words for the active language: the `locale` prop, else the
34
+ * `@djangocfg/i18n` provider, else English. The host passes no strings.
32
35
  */
33
- export function useAssistantCopy(): AssistantCopy {
34
- const locale = useLocaleOptional();
35
- return useMemo(() => (locale ? ASSISTANT_DICTIONARIES[locale] ?? en : en), [locale]);
36
- }
36
+ export const useAssistantCopy = kit.useCopy;