@sesionario/blocks 1.0.1 → 1.1.1

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
@@ -19,6 +19,21 @@ Peer dependencies (install in the consuming app as needed):
19
19
  - `react-phone-number-input` (PhoneInput — also import its CSS in your app layout)
20
20
  - `hls.js` (optional — VideoPlayer)
21
21
 
22
+ ### Chat UI (`MessageScroller`, `ChatMessageList`, …)
23
+
24
+ Apps that render chat scrollers should define this utility in global CSS (used by `MessageScrollerViewport`):
25
+
26
+ ```css
27
+ .scroll-fade-b {
28
+ mask-image: linear-gradient(
29
+ to bottom,
30
+ #000 0%,
31
+ #000 calc(100% - 1.5rem),
32
+ transparent 100%
33
+ );
34
+ }
35
+ ```
36
+
22
37
  ## Development
23
38
 
24
39
  ```bash
package/dist/index.cjs CHANGED
@@ -20,6 +20,7 @@ var cmdk = require('cmdk');
20
20
  var RPNInput = require('react-phone-number-input');
21
21
  var flags = require('react-phone-number-input/flags');
22
22
  var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
23
+ var messageScroller = require('@shadcn/react/message-scroller');
23
24
 
24
25
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
25
26
 
@@ -4234,9 +4235,400 @@ function VerifiedProfessionalBadge({
4234
4235
  }
4235
4236
  );
4236
4237
  }
4238
+ function MessageGroup({ className, ...props }) {
4239
+ return /* @__PURE__ */ jsxRuntime.jsx(
4240
+ "div",
4241
+ {
4242
+ "data-slot": "message-group",
4243
+ className: cn("flex min-w-0 flex-col gap-2", className),
4244
+ ...props
4245
+ }
4246
+ );
4247
+ }
4248
+ function Message({
4249
+ className,
4250
+ align = "start",
4251
+ ...props
4252
+ }) {
4253
+ return /* @__PURE__ */ jsxRuntime.jsx(
4254
+ "div",
4255
+ {
4256
+ "data-slot": "message",
4257
+ "data-align": align,
4258
+ className: cn(
4259
+ "group/message relative flex w-full min-w-0 gap-2 text-sm data-[align=end]:flex-row-reverse",
4260
+ className
4261
+ ),
4262
+ ...props
4263
+ }
4264
+ );
4265
+ }
4266
+ function MessageAvatar({ className, ...props }) {
4267
+ return /* @__PURE__ */ jsxRuntime.jsx(
4268
+ "div",
4269
+ {
4270
+ "data-slot": "message-avatar",
4271
+ className: cn(
4272
+ "flex w-fit min-w-8 shrink-0 items-center justify-center self-end overflow-hidden rounded-full bg-muted group-has-data-[slot=message-footer]/message:-translate-y-8",
4273
+ className
4274
+ ),
4275
+ ...props
4276
+ }
4277
+ );
4278
+ }
4279
+ function MessageContent({ className, ...props }) {
4280
+ return /* @__PURE__ */ jsxRuntime.jsx(
4281
+ "div",
4282
+ {
4283
+ "data-slot": "message-content",
4284
+ className: cn(
4285
+ "flex w-full min-w-0 flex-col gap-2.5 wrap-break-word group-data-[align=end]/message:*:data-slot:self-end",
4286
+ className
4287
+ ),
4288
+ ...props
4289
+ }
4290
+ );
4291
+ }
4292
+ function MessageHeader({ className, ...props }) {
4293
+ return /* @__PURE__ */ jsxRuntime.jsx(
4294
+ "div",
4295
+ {
4296
+ "data-slot": "message-header",
4297
+ className: cn(
4298
+ "flex max-w-full min-w-0 items-center px-3 text-xs font-medium text-muted-foreground group-has-data-[variant=ghost]/message:px-0",
4299
+ className
4300
+ ),
4301
+ ...props
4302
+ }
4303
+ );
4304
+ }
4305
+ function MessageFooter({ className, ...props }) {
4306
+ return /* @__PURE__ */ jsxRuntime.jsx(
4307
+ "div",
4308
+ {
4309
+ "data-slot": "message-footer",
4310
+ className: cn(
4311
+ "flex max-w-full min-w-0 items-center px-3 text-xs font-medium text-muted-foreground group-has-data-[variant=ghost]/message:px-0 group-data-[align=end]/message:justify-end",
4312
+ className
4313
+ ),
4314
+ ...props
4315
+ }
4316
+ );
4317
+ }
4318
+ function BubbleGroup({ className, ...props }) {
4319
+ return /* @__PURE__ */ jsxRuntime.jsx(
4320
+ "div",
4321
+ {
4322
+ "data-slot": "bubble-group",
4323
+ className: cn("flex min-w-0 flex-col gap-2", className),
4324
+ ...props
4325
+ }
4326
+ );
4327
+ }
4328
+ var bubbleVariants = classVarianceAuthority.cva(
4329
+ "group/bubble relative flex w-fit max-w-[80%] min-w-0 flex-col gap-1 group-data-[align=end]/message:self-end data-[align=end]:self-end data-[variant=ghost]:max-w-full",
4330
+ {
4331
+ variants: {
4332
+ variant: {
4333
+ default: "*:data-[slot=bubble-content]:bg-primary *:data-[slot=bubble-content]:text-primary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-primary/80",
4334
+ secondary: "*:data-[slot=bubble-content]:bg-secondary *:data-[slot=bubble-content]:text-secondary-foreground [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)]",
4335
+ muted: "*:data-[slot=bubble-content]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklch,var(--muted),var(--foreground)_5%)]",
4336
+ tinted: "*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.93_calc(c*0.4)_h)] *:data-[slot=bubble-content]:text-foreground dark:*:data-[slot=bubble-content]:bg-[oklch(from_var(--primary)_0.3_calc(c*0.4)_h)] [&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.88_calc(c*0.5)_h)] dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-[oklch(from_var(--primary)_0.35_calc(c*0.5)_h)]",
4337
+ outline: "*:data-[slot=bubble-content]:border-border *:data-[slot=bubble-content]:bg-background [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-input/30",
4338
+ ghost: "border-none *:data-[slot=bubble-content]:rounded-none *:data-[slot=bubble-content]:bg-transparent *:data-[slot=bubble-content]:p-0 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted [&>[data-slot=bubble-content]:is(button,a):hover]:text-foreground dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-muted/50",
4339
+ destructive: "*:data-[slot=bubble-content]:bg-destructive/10 *:data-[slot=bubble-content]:text-destructive dark:*:data-[slot=bubble-content]:bg-destructive/20 [&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/20 dark:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/30"
4340
+ }
4341
+ },
4342
+ defaultVariants: {
4343
+ variant: "default"
4344
+ }
4345
+ }
4346
+ );
4347
+ function Bubble({
4348
+ variant = "default",
4349
+ align = "start",
4350
+ className,
4351
+ ...props
4352
+ }) {
4353
+ return /* @__PURE__ */ jsxRuntime.jsx(
4354
+ "div",
4355
+ {
4356
+ "data-slot": "bubble",
4357
+ "data-variant": variant,
4358
+ "data-align": align,
4359
+ className: cn(bubbleVariants({ variant }), className),
4360
+ ...props
4361
+ }
4362
+ );
4363
+ }
4364
+ function BubbleContent({
4365
+ asChild = false,
4366
+ className,
4367
+ ...props
4368
+ }) {
4369
+ const Comp = asChild ? reactSlot.Slot : "div";
4370
+ return /* @__PURE__ */ jsxRuntime.jsx(
4371
+ Comp,
4372
+ {
4373
+ "data-slot": "bubble-content",
4374
+ className: cn(
4375
+ "w-fit max-w-full min-w-0 overflow-hidden rounded-xl border border-transparent px-3 py-2 text-sm leading-relaxed wrap-break-word group-data-[align=end]/bubble:self-end [button]:text-left [button,a]:transition-colors [button,a]:outline-none [button,a]:focus-visible:border-ring [button,a]:focus-visible:ring-3 [button,a]:focus-visible:ring-ring/50",
4376
+ className
4377
+ ),
4378
+ ...props
4379
+ }
4380
+ );
4381
+ }
4382
+ var bubbleReactionsVariants = classVarianceAuthority.cva(
4383
+ "absolute z-10 flex w-fit shrink-0 items-center justify-center gap-1 rounded-full bg-muted px-1.5 py-0.5 text-sm ring-3 ring-card has-[button]:p-0",
4384
+ {
4385
+ variants: {
4386
+ side: {
4387
+ top: "top-0 -translate-y-3/4",
4388
+ bottom: "bottom-0 translate-y-3/4"
4389
+ },
4390
+ align: {
4391
+ start: "left-3",
4392
+ end: "right-3"
4393
+ }
4394
+ },
4395
+ defaultVariants: {
4396
+ side: "bottom",
4397
+ align: "end"
4398
+ }
4399
+ }
4400
+ );
4401
+ function BubbleReactions({
4402
+ side = "bottom",
4403
+ align = "end",
4404
+ className,
4405
+ ...props
4406
+ }) {
4407
+ return /* @__PURE__ */ jsxRuntime.jsx(
4408
+ "div",
4409
+ {
4410
+ "data-slot": "bubble-reactions",
4411
+ "data-align": align,
4412
+ "data-side": side,
4413
+ className: cn(bubbleReactionsVariants({ side, align }), className),
4414
+ ...props
4415
+ }
4416
+ );
4417
+ }
4418
+ var markerVariants = classVarianceAuthority.cva(
4419
+ "group/marker relative flex min-h-4 w-full items-center gap-2 text-left text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [a]:underline [a]:underline-offset-3 [a]:hover:text-foreground",
4420
+ {
4421
+ variants: {
4422
+ variant: {
4423
+ default: "",
4424
+ separator: "before:mr-1 before:h-px before:min-w-0 before:flex-1 before:bg-border after:ml-1 after:h-px after:min-w-0 after:flex-1 after:bg-border",
4425
+ border: "border-b border-border pb-2"
4426
+ }
4427
+ }
4428
+ }
4429
+ );
4430
+ function Marker({
4431
+ className,
4432
+ variant = "default",
4433
+ asChild = false,
4434
+ ...props
4435
+ }) {
4436
+ const Comp = asChild ? reactSlot.Slot : "div";
4437
+ return /* @__PURE__ */ jsxRuntime.jsx(
4438
+ Comp,
4439
+ {
4440
+ "data-slot": "marker",
4441
+ "data-variant": variant,
4442
+ className: cn(markerVariants({ variant, className })),
4443
+ ...props
4444
+ }
4445
+ );
4446
+ }
4447
+ function MarkerIcon({ className, ...props }) {
4448
+ return /* @__PURE__ */ jsxRuntime.jsx(
4449
+ "span",
4450
+ {
4451
+ "data-slot": "marker-icon",
4452
+ "aria-hidden": "true",
4453
+ className: cn(
4454
+ "size-4 shrink-0 [&_svg:not([class*='size-'])]:size-4",
4455
+ className
4456
+ ),
4457
+ ...props
4458
+ }
4459
+ );
4460
+ }
4461
+ function MarkerContent({ className, ...props }) {
4462
+ return /* @__PURE__ */ jsxRuntime.jsx(
4463
+ "span",
4464
+ {
4465
+ "data-slot": "marker-content",
4466
+ className: cn(
4467
+ "min-w-0 wrap-break-word group-data-[variant=separator]/marker:flex-none group-data-[variant=separator]/marker:text-center *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
4468
+ className
4469
+ ),
4470
+ ...props
4471
+ }
4472
+ );
4473
+ }
4474
+ function MessageScrollerProvider(props) {
4475
+ return /* @__PURE__ */ jsxRuntime.jsx(messageScroller.MessageScroller.Provider, { ...props });
4476
+ }
4477
+ function MessageScroller({
4478
+ className,
4479
+ ...props
4480
+ }) {
4481
+ return /* @__PURE__ */ jsxRuntime.jsx(
4482
+ messageScroller.MessageScroller.Root,
4483
+ {
4484
+ "data-slot": "message-scroller",
4485
+ className: cn(
4486
+ "group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden",
4487
+ className
4488
+ ),
4489
+ ...props
4490
+ }
4491
+ );
4492
+ }
4493
+ function MessageScrollerViewport({
4494
+ className,
4495
+ ...props
4496
+ }) {
4497
+ return /* @__PURE__ */ jsxRuntime.jsx(
4498
+ messageScroller.MessageScroller.Viewport,
4499
+ {
4500
+ "data-slot": "message-scroller-viewport",
4501
+ className: cn(
4502
+ "size-full min-h-0 min-w-0 scroll-fade-b scrollbar-thin scrollbar-gutter-stable overflow-y-auto overscroll-contain contain-content data-autoscrolling:scrollbar-none",
4503
+ className
4504
+ ),
4505
+ ...props
4506
+ }
4507
+ );
4508
+ }
4509
+ function MessageScrollerContent({
4510
+ className,
4511
+ ...props
4512
+ }) {
4513
+ return /* @__PURE__ */ jsxRuntime.jsx(
4514
+ messageScroller.MessageScroller.Content,
4515
+ {
4516
+ "data-slot": "message-scroller-content",
4517
+ className: cn("flex h-max min-h-full flex-col gap-8", className),
4518
+ ...props
4519
+ }
4520
+ );
4521
+ }
4522
+ function MessageScrollerItem({
4523
+ className,
4524
+ scrollAnchor = false,
4525
+ ...props
4526
+ }) {
4527
+ return /* @__PURE__ */ jsxRuntime.jsx(
4528
+ messageScroller.MessageScroller.Item,
4529
+ {
4530
+ "data-slot": "message-scroller-item",
4531
+ scrollAnchor,
4532
+ className: cn(
4533
+ "min-w-0 shrink-0 [contain-intrinsic-size:auto_10rem] [content-visibility:auto]",
4534
+ className
4535
+ ),
4536
+ ...props
4537
+ }
4538
+ );
4539
+ }
4540
+ function MessageScrollerButton({
4541
+ direction = "end",
4542
+ className,
4543
+ children,
4544
+ render,
4545
+ variant = "secondary",
4546
+ size = "icon",
4547
+ ...props
4548
+ }) {
4549
+ return /* @__PURE__ */ jsxRuntime.jsx(
4550
+ messageScroller.MessageScroller.Button,
4551
+ {
4552
+ "data-slot": "message-scroller-button",
4553
+ "data-direction": direction,
4554
+ "data-variant": variant,
4555
+ "data-size": size,
4556
+ direction,
4557
+ className: cn(
4558
+ "absolute inset-s-1/2 -translate-x-1/2 border-border bg-background text-foreground transition-[translate,scale,opacity] duration-200 hover:bg-muted hover:text-foreground data-[active=false]:pointer-events-none data-[active=false]:scale-95 data-[active=false]:opacity-0 data-[active=false]:duration-400 data-[active=false]:ease-[cubic-bezier(0.7,0,0.84,0)] data-[active=true]:translate-y-0 data-[active=true]:scale-100 data-[active=true]:opacity-100 data-[active=true]:ease-[cubic-bezier(0.23,1,0.32,1)] data-[direction=end]:bottom-4 data-[direction=end]:data-[active=false]:translate-y-full data-[direction=start]:top-4 data-[direction=start]:data-[active=false]:-translate-y-full rtl:translate-x-1/2 data-[direction=start]:[&_svg]:rotate-180",
4559
+ className
4560
+ ),
4561
+ render: render ?? /* @__PURE__ */ jsxRuntime.jsx(Button, { variant, size }),
4562
+ ...props,
4563
+ children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4564
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDownIcon, {}),
4565
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: direction === "end" ? "Ir al final" : "Ir al inicio" })
4566
+ ] })
4567
+ }
4568
+ );
4569
+ }
4570
+ function initials(name) {
4571
+ return name.split(/\s+/).filter(Boolean).slice(0, 2).map((p) => p[0]?.toUpperCase() ?? "").join("");
4572
+ }
4573
+ function ChatMessageList({
4574
+ messages,
4575
+ currentUserId,
4576
+ emptyTitle = "Sin mensajes",
4577
+ emptyDescription = "Escribe para iniciar la conversaci\xF3n."
4578
+ }) {
4579
+ if (messages.length === 0) {
4580
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col items-center justify-center gap-2 p-6 text-center", children: [
4581
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageCircleDashedIcon, { className: "size-8 text-muted-foreground" }),
4582
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: emptyTitle }),
4583
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: emptyDescription })
4584
+ ] });
4585
+ }
4586
+ return /* @__PURE__ */ jsxRuntime.jsx(MessageScrollerProvider, { autoScroll: true, children: /* @__PURE__ */ jsxRuntime.jsxs(MessageScroller, { children: [
4587
+ /* @__PURE__ */ jsxRuntime.jsx(MessageScrollerViewport, { children: /* @__PURE__ */ jsxRuntime.jsx(MessageScrollerContent, { className: "gap-4 p-4", children: messages.map((m) => {
4588
+ const mine = Boolean(currentUserId) && m.senderId === currentUserId;
4589
+ const align = mine ? "end" : "start";
4590
+ return /* @__PURE__ */ jsxRuntime.jsx(MessageScrollerItem, { scrollAnchor: mine, children: m.deleted ? /* @__PURE__ */ jsxRuntime.jsx(Marker, { variant: "separator", children: /* @__PURE__ */ jsxRuntime.jsxs(MarkerContent, { children: [
4591
+ "Mensaje eliminado \xB7 ",
4592
+ m.senderName
4593
+ ] }) }) : /* @__PURE__ */ jsxRuntime.jsxs(Message, { align, children: [
4594
+ !mine ? /* @__PURE__ */ jsxRuntime.jsx(MessageAvatar, { children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex size-8 items-center justify-center rounded-full bg-muted text-xs font-medium text-muted-foreground", children: initials(m.senderName) }) }) : null,
4595
+ /* @__PURE__ */ jsxRuntime.jsxs(MessageContent, { children: [
4596
+ !mine ? /* @__PURE__ */ jsxRuntime.jsx(MessageHeader, { children: m.senderName }) : null,
4597
+ /* @__PURE__ */ jsxRuntime.jsx(
4598
+ Bubble,
4599
+ {
4600
+ variant: mine ? "default" : "muted",
4601
+ align,
4602
+ children: /* @__PURE__ */ jsxRuntime.jsx(BubbleContent, { children: m.body })
4603
+ }
4604
+ ),
4605
+ /* @__PURE__ */ jsxRuntime.jsx(MessageFooter, { children: new Date(m.createdAt).toLocaleString("es-MX") })
4606
+ ] })
4607
+ ] }) }, m.id);
4608
+ }) }) }),
4609
+ /* @__PURE__ */ jsxRuntime.jsx(MessageScrollerButton, {})
4610
+ ] }) });
4611
+ }
4237
4612
 
4613
+ Object.defineProperty(exports, "useMessageScroller", {
4614
+ enumerable: true,
4615
+ get: function () { return messageScroller.useMessageScroller; }
4616
+ });
4617
+ Object.defineProperty(exports, "useMessageScrollerScrollable", {
4618
+ enumerable: true,
4619
+ get: function () { return messageScroller.useMessageScrollerScrollable; }
4620
+ });
4621
+ Object.defineProperty(exports, "useMessageScrollerVisibility", {
4622
+ enumerable: true,
4623
+ get: function () { return messageScroller.useMessageScrollerVisibility; }
4624
+ });
4238
4625
  exports.AvatarEditor = AvatarEditor;
4239
4626
  exports.AvatarEditorDialog = AvatarEditorDialog;
4627
+ exports.Bubble = Bubble;
4628
+ exports.BubbleContent = BubbleContent;
4629
+ exports.BubbleGroup = BubbleGroup;
4630
+ exports.BubbleReactions = BubbleReactions;
4631
+ exports.ChatMessageList = ChatMessageList;
4240
4632
  exports.EmojiPicker = EmojiPicker;
4241
4633
  exports.EmojiPickerPopover = EmojiPickerPopover;
4242
4634
  exports.Empty = Empty;
@@ -4252,6 +4644,21 @@ exports.LanguageSwitcher = LanguageSwitcher;
4252
4644
  exports.LoadingState = LoadingState;
4253
4645
  exports.MEXICO_STATES = MEXICO_STATES;
4254
4646
  exports.MEXICO_STATE_PATHS = MEXICO_STATE_PATHS;
4647
+ exports.Marker = Marker;
4648
+ exports.MarkerContent = MarkerContent;
4649
+ exports.MarkerIcon = MarkerIcon;
4650
+ exports.Message = Message;
4651
+ exports.MessageAvatar = MessageAvatar;
4652
+ exports.MessageContent = MessageContent;
4653
+ exports.MessageFooter = MessageFooter;
4654
+ exports.MessageGroup = MessageGroup;
4655
+ exports.MessageHeader = MessageHeader;
4656
+ exports.MessageScroller = MessageScroller;
4657
+ exports.MessageScrollerButton = MessageScrollerButton;
4658
+ exports.MessageScrollerContent = MessageScrollerContent;
4659
+ exports.MessageScrollerItem = MessageScrollerItem;
4660
+ exports.MessageScrollerProvider = MessageScrollerProvider;
4661
+ exports.MessageScrollerViewport = MessageScrollerViewport;
4255
4662
  exports.MexicoMap = MexicoMap;
4256
4663
  exports.OrgSwitcher = OrgSwitcher;
4257
4664
  exports.PhoneInput = PhoneInput;
@@ -4259,12 +4666,14 @@ exports.SearchCommand = SearchCommand;
4259
4666
  exports.ThemeSwitcher = ThemeSwitcher;
4260
4667
  exports.VerifiedProfessionalBadge = VerifiedProfessionalBadge;
4261
4668
  exports.VideoPlayer = VideoPlayer;
4669
+ exports.bubbleVariants = bubbleVariants;
4262
4670
  exports.cn = cn;
4263
4671
  exports.createLiveHlsConfig = createLiveHlsConfig;
4264
4672
  exports.createVodHlsConfig = createVodHlsConfig;
4265
4673
  exports.defaultLanguages = defaultLanguages;
4266
4674
  exports.describePlaybackError = describePlaybackError;
4267
4675
  exports.fuzzyMatch = fuzzyMatch;
4676
+ exports.markerVariants = markerVariants;
4268
4677
  exports.normalizeEmojiQuery = normalizeEmojiQuery;
4269
4678
  exports.shouldRetryLiveEdge404 = shouldRetryLiveEdge404;
4270
4679
  exports.useDebouncedValue = useDebouncedValue;