@alfadocs/ui-kit 0.1.5 → 0.1.6

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/README.md CHANGED
@@ -69,6 +69,32 @@ import en from '@alfadocs/ui-kit/locales/en.json';
69
69
  i18n.addResourceBundle('en', 'ui', en);
70
70
  ```
71
71
 
72
+ ## Host integration
73
+
74
+ The kit's dismissable primitives — `Dialog`, `Popover`, `DropdownMenu`,
75
+ `Tooltip`, `Select`, `ContextMenu`, `NavigationMenu`, `AlertDialog` —
76
+ all build on Radix's `@radix-ui/react-dismissable-layer`, which attaches
77
+ a bubble-phase `pointerdown` listener on `document` to detect outside
78
+ clicks. Consuming applications **must not** register a capture-phase
79
+ `document` (or `body`) listener that calls `event.stopPropagation()` on
80
+ `pointerdown` / `mousedown` / `click` — capture-phase consumers run
81
+ BEFORE Radix's detector and starve it, leaving overlays stuck open.
82
+
83
+ ```js
84
+ // Will break every dismissable primitive in the kit
85
+ document.addEventListener('pointerdown', (e) => e.stopPropagation(), true);
86
+ ```
87
+
88
+ If a legacy script must intercept pointer events at `document` level
89
+ (jQuery plugins, Bootstrap modals, in-house global menu handlers, etc.):
90
+
91
+ - Scope the listener to a specific container instead of `document` / `body`.
92
+ - Drop the `useCapture: true` flag — bubble-phase listeners fire AFTER Radix and don't interfere.
93
+ - Drop the `stopPropagation()` call entirely if it isn't load-bearing.
94
+
95
+ Each dismissable component's Storybook page carries a `WithHostInterference`
96
+ story that reproduces the failure mode for diagnosis.
97
+
72
98
  ## Peer dependencies
73
99
 
74
100
  `react`, `react-dom`, `react-i18next`, `i18next`. Tailwind CSS is not
@@ -6,14 +6,14 @@ import { F as se } from "./floating-action-button-Cnw-f6AG.js";
6
6
  import { I as B } from "./icon-button-Wnnde5lc.js";
7
7
  import { S as E } from "./sheet-BhNpLHc9.js";
8
8
  import { X as de } from "./x-CCcI3eJp.js";
9
- import { A as C } from "./avatar-Dcr6XuDQ.js";
9
+ import { A as w } from "./avatar-Dcr6XuDQ.js";
10
10
  import { B as D } from "./button-7mLWcMp_.js";
11
11
  import { C as re } from "./chat-container-BZvQ3_yT.js";
12
12
  import { C as ae } from "./chat-message-ByouZpPP.js";
13
13
  import { C as le } from "./chat-input-DsIrWM4f.js";
14
- import { S as oe } from "./streaming-text-BgjCTVOw.js";
14
+ import { S as ie } from "./streaming-text-BgjCTVOw.js";
15
15
  import { a as q, S as O } from "./suggestion-chip-6AB40rxz.js";
16
- import { T as ie } from "./typing-indicator-CbUBf-Dx.js";
16
+ import { T as oe } from "./typing-indicator-CbUBf-Dx.js";
17
17
  import { P as te } from "./progress-B4Of_pzz.js";
18
18
  import { S as ne } from "./square-CZoGU14v.js";
19
19
  import { c as ce } from "./createLucideIcon-CrFbzy84.js";
@@ -106,8 +106,8 @@ function ve({
106
106
  assistantName: s,
107
107
  avatarSrc: r,
108
108
  greeting: a,
109
- subtitle: i,
110
- suggestions: o,
109
+ subtitle: o,
110
+ suggestions: i,
111
111
  onSuggestion: t
112
112
  }) {
113
113
  const { t: u } = y(), l = "leo-empty-state-heading";
@@ -125,7 +125,7 @@ function ve({
125
125
  ].join(" "),
126
126
  "data-testid": "leo-empty-state",
127
127
  children: [
128
- r ? /* @__PURE__ */ e(C, { name: s, src: r, size: "xl" }) : /* @__PURE__ */ e(j, { size: "xl", label: s }),
128
+ r ? /* @__PURE__ */ e(w, { name: s, src: r, size: "xl" }) : /* @__PURE__ */ e(j, { size: "xl", label: s }),
129
129
  /* @__PURE__ */ c("div", { className: "ds:flex ds:flex-col ds:items-center ds:gap-[var(--spacing-xs)] ds:max-w-[32rem]", children: [
130
130
  /* @__PURE__ */ e(
131
131
  "h2",
@@ -135,14 +135,14 @@ function ve({
135
135
  children: a
136
136
  }
137
137
  ),
138
- /* @__PURE__ */ e("p", { className: "type-body-sm ds:m-0 ds:text-[color:var(--muted-foreground)]", children: i })
138
+ /* @__PURE__ */ e("p", { className: "type-body-sm ds:m-0 ds:text-[color:var(--muted-foreground)]", children: o })
139
139
  ] }),
140
- o && o.length > 0 ? /* @__PURE__ */ e("div", { className: "ds:w-full ds:max-w-[40rem]", children: /* @__PURE__ */ e(
140
+ i && i.length > 0 ? /* @__PURE__ */ e("div", { className: "ds:w-full ds:max-w-[40rem]", children: /* @__PURE__ */ e(
141
141
  q,
142
142
  {
143
143
  label: u("leo.exampleQuestions"),
144
144
  className: "ds:justify-center",
145
- children: o.map((n) => /* @__PURE__ */ e(
145
+ children: i.map((n) => /* @__PURE__ */ e(
146
146
  O,
147
147
  {
148
148
  intent: "suggestion",
@@ -163,23 +163,23 @@ function xe({
163
163
  message: s,
164
164
  assistantName: r,
165
165
  avatarSrc: a,
166
- renderMarkdown: i
166
+ renderMarkdown: o
167
167
  }) {
168
- const { t: o, i18n: t } = y(), u = o("chat.message.role.assistant"), l = U(() => {
168
+ const { t: i, i18n: t } = y(), u = i("chat.message.role.assistant"), l = U(() => {
169
169
  if (!s.timestamp) return null;
170
170
  const m = s.timestamp instanceof Date ? s.timestamp : new Date(s.timestamp);
171
171
  return Number.isNaN(m.getTime()) ? null : new Intl.DateTimeFormat(t.language, {
172
172
  hour: "2-digit",
173
173
  minute: "2-digit"
174
174
  }).format(m);
175
- }, [s.timestamp, t.language]), n = l ? o("chat.message.label", { role: u, time: l }) : o("chat.message.labelNoTime", { role: u });
175
+ }, [s.timestamp, t.language]), n = l ? i("chat.message.label", { role: u, time: l }) : i("chat.message.labelNoTime", { role: u });
176
176
  return /* @__PURE__ */ c(
177
177
  "article",
178
178
  {
179
179
  "aria-label": n,
180
180
  className: "ds:flex ds:w-full ds:items-start ds:flex-row ds:gap-[var(--spacing-sm)]",
181
181
  children: [
182
- a ? /* @__PURE__ */ e(C, { name: r, src: a, size: "sm" }) : /* @__PURE__ */ e(j, { size: "sm", label: r }),
182
+ a ? /* @__PURE__ */ e(w, { name: r, src: a, size: "sm" }) : /* @__PURE__ */ e(j, { size: "sm", label: r }),
183
183
  /* @__PURE__ */ e("div", { className: "ds:flex ds:flex-col ds:items-start", children: /* @__PURE__ */ e(
184
184
  "div",
185
185
  {
@@ -194,11 +194,11 @@ function xe({
194
194
  "ds:rounded-[var(--radius-md)] ds:rounded-es-[var(--radius-sm)]"
195
195
  ].join(" "),
196
196
  children: /* @__PURE__ */ e(
197
- oe,
197
+ ie,
198
198
  {
199
199
  content: s.content,
200
200
  isStreaming: !0,
201
- renderMarkdown: i
201
+ renderMarkdown: o
202
202
  }
203
203
  )
204
204
  }
@@ -211,8 +211,8 @@ function Ne({
211
211
  assistantName: s,
212
212
  avatarSrc: r,
213
213
  onNewConversation: a,
214
- headerEndSlot: i,
215
- density: o
214
+ headerEndSlot: o,
215
+ density: i
216
216
  }) {
217
217
  const { t } = y();
218
218
  return /* @__PURE__ */ c(
@@ -224,21 +224,21 @@ function Ne({
224
224
  "ds:border-b ds:border-[color:var(--border)]",
225
225
  "ds:bg-[var(--background)]",
226
226
  "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]",
227
- o === "compact" ? "ds:pt-[var(--spacing-sm)] ds:pb-[var(--spacing-sm)]" : "ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]"
227
+ i === "compact" ? "ds:pt-[var(--spacing-sm)] ds:pb-[var(--spacing-sm)]" : "ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]"
228
228
  ].join(" "),
229
229
  "data-testid": "leo-header",
230
230
  children: [
231
231
  r ? /* @__PURE__ */ e(
232
- C,
232
+ w,
233
233
  {
234
234
  name: s,
235
235
  src: r,
236
- size: o === "compact" ? "sm" : "md"
236
+ size: i === "compact" ? "sm" : "md"
237
237
  }
238
238
  ) : /* @__PURE__ */ e(
239
239
  j,
240
240
  {
241
- size: o === "compact" ? "sm" : "md",
241
+ size: i === "compact" ? "sm" : "md",
242
242
  label: s
243
243
  }
244
244
  ),
@@ -254,19 +254,19 @@ function Ne({
254
254
  children: t("leo.newConversation")
255
255
  }
256
256
  ) : null,
257
- i
257
+ o
258
258
  ] })
259
259
  ]
260
260
  }
261
261
  );
262
262
  }
263
- const w = L(
263
+ const C = L(
264
264
  ({
265
265
  messages: s,
266
266
  onSend: r,
267
267
  onRetry: a,
268
- onSuggestion: i,
269
- suggestions: o,
268
+ onSuggestion: o,
269
+ suggestions: i,
270
270
  isGenerating: t = !1,
271
271
  onStopGenerating: u,
272
272
  usage: l,
@@ -317,7 +317,7 @@ const w = L(
317
317
  id: "__leo-typing__",
318
318
  node: /* @__PURE__ */ c("div", { className: "ds:flex ds:w-full ds:items-start ds:gap-[var(--spacing-sm)]", children: [
319
319
  d != null && d.src ? /* @__PURE__ */ e(
320
- C,
320
+ w,
321
321
  {
322
322
  name: f,
323
323
  src: d.src,
@@ -334,7 +334,7 @@ const w = L(
334
334
  "ds:bg-muted/40"
335
335
  ].join(" "),
336
336
  children: /* @__PURE__ */ e(
337
- ie,
337
+ oe,
338
338
  {
339
339
  label: p("chat.typing"),
340
340
  density: x
@@ -390,18 +390,18 @@ const w = L(
390
390
  }
391
391
  )
392
392
  ] }) : null,
393
- !R && o && o.length > 0 && !t ? /* @__PURE__ */ e(
393
+ !R && i && i.length > 0 && !t ? /* @__PURE__ */ e(
394
394
  q,
395
395
  {
396
396
  label: p("leo.exampleQuestions"),
397
397
  "data-testid": "leo-followup-suggestions",
398
- children: o.map((N) => /* @__PURE__ */ e(
398
+ children: i.map((N) => /* @__PURE__ */ e(
399
399
  O,
400
400
  {
401
401
  intent: "followup",
402
402
  startIcon: N.icon,
403
403
  keepOnSelect: !0,
404
- onSelect: () => i == null ? void 0 : i(N),
404
+ onSelect: () => o == null ? void 0 : o(N),
405
405
  children: N.label
406
406
  },
407
407
  N.id
@@ -461,8 +461,8 @@ const w = L(
461
461
  avatarSrc: d == null ? void 0 : d.src,
462
462
  greeting: K,
463
463
  subtitle: V,
464
- suggestions: o,
465
- onSuggestion: i
464
+ suggestions: i,
465
+ onSuggestion: o
466
466
  }
467
467
  ),
468
468
  /* @__PURE__ */ e(
@@ -491,7 +491,7 @@ const w = L(
491
491
  );
492
492
  }
493
493
  );
494
- w.displayName = "LeoChatSurface";
494
+ C.displayName = "LeoChatSurface";
495
495
  const ye = L(
496
496
  ({ headerSlot: s, ...r }, a) => /* @__PURE__ */ c(
497
497
  "div",
@@ -524,7 +524,7 @@ const ye = L(
524
524
  "ds:[max-inline-size:48rem]",
525
525
  "ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]"
526
526
  ].join(" "),
527
- children: /* @__PURE__ */ e(w, { ...r })
527
+ children: /* @__PURE__ */ e(C, { ...r })
528
528
  }
529
529
  ) })
530
530
  ]
@@ -540,12 +540,12 @@ const je = L(
540
540
  open: s,
541
541
  onOpenChange: r,
542
542
  position: a = "bottom-end",
543
- unseenCount: i,
544
- assistantName: o,
543
+ unseenCount: o,
544
+ assistantName: i,
545
545
  assistantAvatar: t,
546
546
  ...u
547
547
  }, l) => {
548
- const { t: n } = y(), m = o || n("leo.name"), d = typeof i == "number" && i > 0, h = d ? n("leo.unseenCount", { count: i }) : n("leo.open"), v = /* @__PURE__ */ e(ee.Close, { asChild: !0, children: /* @__PURE__ */ e(
548
+ const { t: n } = y(), m = i || n("leo.name"), d = typeof o == "number" && o > 0, h = d ? n("leo.unseenCount", { count: o }) : n("leo.open"), v = /* @__PURE__ */ e(ee.Close, { asChild: !0, children: /* @__PURE__ */ e(
549
549
  B,
550
550
  {
551
551
  icon: /* @__PURE__ */ e(de, { "aria-hidden": "true" }),
@@ -596,7 +596,7 @@ const je = L(
596
596
  "ds:pointer-events-none ds:select-none",
597
597
  "ds:forced-colors:outline ds:forced-colors:outline-1 ds:forced-colors:outline-[CanvasText]"
598
598
  ].join(" "),
599
- children: ze(i)
599
+ children: ze(o)
600
600
  }
601
601
  ) : null
602
602
  ] })
@@ -613,7 +613,7 @@ const je = L(
613
613
  children: [
614
614
  /* @__PURE__ */ e(E.Title, { className: "ds:sr-only", children: m }),
615
615
  /* @__PURE__ */ e(
616
- w,
616
+ C,
617
617
  {
618
618
  ...u,
619
619
  assistantName: m,
@@ -632,18 +632,18 @@ je.displayName = "LeoPopout";
632
632
  function ke(s) {
633
633
  return s > 99 ? "99+" : String(s);
634
634
  }
635
- const Le = "ds:[inline-size:22rem]", Ce = "ds:[inline-size:3rem]", we = L(
635
+ const Le = "ds:[inline-size:22rem]", we = "ds:[inline-size:3rem]", Ce = L(
636
636
  ({
637
637
  open: s,
638
638
  onOpenChange: r,
639
639
  side: a = "end",
640
- unseenCount: i,
641
- footerSlot: o,
640
+ unseenCount: o,
641
+ footerSlot: i,
642
642
  assistantName: t,
643
643
  assistantAvatar: u,
644
644
  ...l
645
645
  }, n) => {
646
- const { t: m } = y(), d = t || m("leo.name"), h = typeof i == "number" && i > 0, v = a === "end" ? "ds:border-s ds:border-[color:var(--border)]" : "ds:border-e ds:border-[color:var(--border)]", I = h ? m("leo.unseenCount", { count: i }) : m("leo.open");
646
+ const { t: m } = y(), d = t || m("leo.name"), h = typeof o == "number" && o > 0, v = a === "end" ? "ds:shadow-[var(--shadow-chrome-start)]" : "ds:shadow-[var(--shadow-chrome-end)]", I = h ? m("leo.unseenCount", { count: o }) : m("leo.open");
647
647
  if (!s)
648
648
  return /* @__PURE__ */ e(
649
649
  "aside",
@@ -655,7 +655,7 @@ const Le = "ds:[inline-size:22rem]", Ce = "ds:[inline-size:3rem]", we = L(
655
655
  "ds:bg-[var(--background)]",
656
656
  v,
657
657
  "ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]",
658
- Ce
658
+ we
659
659
  ].join(" "),
660
660
  "data-testid": "leo-sidebar-rail",
661
661
  "data-leo-sidebar-state": "collapsed",
@@ -689,7 +689,7 @@ const Le = "ds:[inline-size:22rem]", Ce = "ds:[inline-size:3rem]", we = L(
689
689
  "ds:pointer-events-none ds:select-none",
690
690
  "ds:forced-colors:outline ds:forced-colors:outline-1 ds:forced-colors:outline-[CanvasText]"
691
691
  ].join(" "),
692
- children: ke(i)
692
+ children: ke(o)
693
693
  }
694
694
  ) : null
695
695
  ] })
@@ -723,7 +723,7 @@ const Le = "ds:[inline-size:22rem]", Ce = "ds:[inline-size:3rem]", we = L(
723
723
  "data-leo-sidebar-state": "expanded",
724
724
  children: [
725
725
  /* @__PURE__ */ e("div", { className: "ds:flex ds:min-h-0 ds:flex-1 ds:flex-col", children: /* @__PURE__ */ e(
726
- w,
726
+ C,
727
727
  {
728
728
  ...l,
729
729
  assistantName: d,
@@ -732,12 +732,12 @@ const Le = "ds:[inline-size:22rem]", Ce = "ds:[inline-size:3rem]", we = L(
732
732
  headerEndSlot: x
733
733
  }
734
734
  ) }),
735
- o ? /* @__PURE__ */ e(
735
+ i ? /* @__PURE__ */ e(
736
736
  "div",
737
737
  {
738
738
  "data-testid": "leo-sidebar-footer-slot",
739
739
  className: "ds:shrink-0 ds:border-t ds:border-[color:var(--border)]",
740
- children: o
740
+ children: i
741
741
  }
742
742
  ) : null
743
743
  ]
@@ -745,11 +745,11 @@ const Le = "ds:[inline-size:22rem]", Ce = "ds:[inline-size:3rem]", we = L(
745
745
  );
746
746
  }
747
747
  );
748
- we.displayName = "LeoSidebar";
748
+ Ce.displayName = "LeoSidebar";
749
749
  export {
750
- w as L,
750
+ C as L,
751
751
  ye as a,
752
752
  je as b,
753
- we as c
753
+ Ce as c
754
754
  };
755
- //# sourceMappingURL=leo-sidebar-BzN4pJ7j.js.map
755
+ //# sourceMappingURL=leo-sidebar-Bh3dPDTQ.js.map