@devalok/shilp-sutra 0.55.1 → 0.57.0
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/BREAKING.json +13 -0
- package/MIGRATION.md +163 -0
- package/README.md +16 -1
- package/dist/_chunks/badge-group.js +92 -78
- package/dist/_chunks/badge-group.js.map +1 -1
- package/dist/_chunks/chat.js +91 -75
- package/dist/_chunks/chat.js.map +1 -1
- package/dist/_chunks/document-preview.js +1 -1
- package/dist/_chunks/document-preview.js.map +1 -1
- package/dist/_chunks/emoji-suggestion.js +32 -30
- package/dist/_chunks/emoji-suggestion.js.map +1 -1
- package/dist/_chunks/mention-suggestion.js +36 -35
- package/dist/_chunks/mention-suggestion.js.map +1 -1
- package/dist/_chunks/oauth-button.js +1 -1
- package/dist/_chunks/oauth-button.js.map +1 -1
- package/dist/_chunks/primitives-internal.js +437 -537
- package/dist/_chunks/primitives-internal.js.map +1 -1
- package/dist/_chunks/success.js +2 -2
- package/dist/_chunks/success.js.map +1 -1
- package/dist/_chunks/tree-view.js +1 -1
- package/dist/_chunks/tree-view.js.map +1 -1
- package/dist/_chunks/use-calendar.js +4 -4
- package/dist/_chunks/use-calendar.js.map +1 -1
- package/dist/ai/blocks/text.js +1 -1
- package/dist/ai/blocks/text.js.map +1 -1
- package/dist/ai/command-bar.js +9 -9
- package/dist/ai/command-bar.js.map +1 -1
- package/dist/ai/conversation.js +2 -2
- package/dist/ai/conversation.js.map +1 -1
- package/dist/composed/activity-feed.js +1 -1
- package/dist/composed/activity-feed.js.map +1 -1
- package/dist/composed/avatar-group.d.ts +7 -2
- package/dist/composed/avatar-group.d.ts.map +1 -1
- package/dist/composed/avatar-group.js +3 -3
- package/dist/composed/avatar-group.js.map +1 -1
- package/dist/composed/command-palette.js +7 -7
- package/dist/composed/command-palette.js.map +1 -1
- package/dist/composed/content-card.js +20 -20
- package/dist/composed/content-card.js.map +1 -1
- package/dist/composed/date-picker/index.js +4 -4
- package/dist/composed/date-picker/index.js.map +1 -1
- package/dist/composed/diff.d.ts +23 -2
- package/dist/composed/diff.d.ts.map +1 -1
- package/dist/composed/diff.js +341 -260
- package/dist/composed/diff.js.map +1 -1
- package/dist/composed/emoji-picker.js +3 -3
- package/dist/composed/emoji-picker.js.map +1 -1
- package/dist/composed/error-boundary.js +2 -2
- package/dist/composed/error-boundary.js.map +1 -1
- package/dist/composed/extensions/emoji-node.js +8 -7
- package/dist/composed/extensions/emoji-node.js.map +1 -1
- package/dist/composed/file-preview.js +1 -1
- package/dist/composed/file-preview.js.map +1 -1
- package/dist/composed/filter-bar.js +1 -1
- package/dist/composed/filter-bar.js.map +1 -1
- package/dist/composed/inline-edit.js +1 -1
- package/dist/composed/inline-edit.js.map +1 -1
- package/dist/composed/loading-skeleton.js +3 -3
- package/dist/composed/loading-skeleton.js.map +1 -1
- package/dist/composed/master-detail.js +1 -1
- package/dist/composed/master-detail.js.map +1 -1
- package/dist/composed/member-picker.js +1 -1
- package/dist/composed/member-picker.js.map +1 -1
- package/dist/composed/multi-select-popover.js +1 -1
- package/dist/composed/multi-select-popover.js.map +1 -1
- package/dist/composed/page-skeletons.js +4 -4
- package/dist/composed/page-skeletons.js.map +1 -1
- package/dist/composed/responsive-modal.js +1 -1
- package/dist/composed/responsive-modal.js.map +1 -1
- package/dist/composed/rich-chat-input.js +549 -540
- package/dist/composed/rich-chat-input.js.map +1 -1
- package/dist/composed/rich-text-editor.js +206 -198
- package/dist/composed/rich-text-editor.js.map +1 -1
- package/dist/composed/schedule-view.js +5 -5
- package/dist/composed/schedule-view.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +4 -3
- package/dist/hooks/use-container-size.d.ts +18 -0
- package/dist/hooks/use-container-size.d.ts.map +1 -0
- package/dist/hooks/use-container-size.js +28 -0
- package/dist/hooks/use-container-size.js.map +1 -0
- package/dist/shell/app-shell.d.ts +101 -0
- package/dist/shell/app-shell.d.ts.map +1 -0
- package/dist/shell/app-shell.js +76 -0
- package/dist/shell/app-shell.js.map +1 -0
- package/dist/shell/bottom-navbar.js +2 -2
- package/dist/shell/bottom-navbar.js.map +1 -1
- package/dist/shell/index.d.ts +1 -0
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +6 -5
- package/dist/shell/notification-center.js +4 -4
- package/dist/shell/notification-center.js.map +1 -1
- package/dist/shell/notification-preferences.js +1 -1
- package/dist/shell/notification-preferences.js.map +1 -1
- package/dist/shell/top-bar.js +7 -7
- package/dist/shell/top-bar.js.map +1 -1
- package/dist/tokens/generate-scale.d.ts +49 -0
- package/dist/tokens/generate-scale.d.ts.map +1 -1
- package/dist/tokens/primitives.css +29 -26
- package/dist/tokens/semantic.css +98 -39
- package/dist/tokens/variants.css +1 -1
- package/dist/ui/accordion.js +1 -1
- package/dist/ui/accordion.js.map +1 -1
- package/dist/ui/alert-dialog.js +1 -1
- package/dist/ui/alert-dialog.js.map +1 -1
- package/dist/ui/alert.d.ts.map +1 -1
- package/dist/ui/alert.js +36 -36
- package/dist/ui/alert.js.map +1 -1
- package/dist/ui/avatar.js +44 -44
- package/dist/ui/avatar.js.map +1 -1
- package/dist/ui/badge-indicator.js +1 -1
- package/dist/ui/badge-indicator.js.map +1 -1
- package/dist/ui/badge.d.ts +47 -33
- package/dist/ui/badge.d.ts.map +1 -1
- package/dist/ui/banner.js +26 -26
- package/dist/ui/banner.js.map +1 -1
- package/dist/ui/button.js +35 -35
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/card.js +42 -42
- package/dist/ui/card.js.map +1 -1
- package/dist/ui/chat/date-separator.d.ts +8 -1
- package/dist/ui/chat/date-separator.d.ts.map +1 -1
- package/dist/ui/checkbox.js +1 -1
- package/dist/ui/checkbox.js.map +1 -1
- package/dist/ui/code.js +2 -2
- package/dist/ui/code.js.map +1 -1
- package/dist/ui/color-input.js +3 -3
- package/dist/ui/color-input.js.map +1 -1
- package/dist/ui/combobox.js +139 -139
- package/dist/ui/combobox.js.map +1 -1
- package/dist/ui/context-menu.js +4 -4
- package/dist/ui/context-menu.js.map +1 -1
- package/dist/ui/data-table-body.d.ts +3 -1
- package/dist/ui/data-table-body.d.ts.map +1 -1
- package/dist/ui/data-table-body.js +93 -92
- package/dist/ui/data-table-body.js.map +1 -1
- package/dist/ui/data-table-bulk-actions.d.ts +7 -1
- package/dist/ui/data-table-bulk-actions.d.ts.map +1 -1
- package/dist/ui/data-table-bulk-actions.js +14 -8
- package/dist/ui/data-table-bulk-actions.js.map +1 -1
- package/dist/ui/data-table-card.d.ts.map +1 -1
- package/dist/ui/data-table-card.js +66 -47
- package/dist/ui/data-table-card.js.map +1 -1
- package/dist/ui/data-table-context.d.ts +4 -0
- package/dist/ui/data-table-context.d.ts.map +1 -1
- package/dist/ui/data-table-context.js.map +1 -1
- package/dist/ui/data-table-header.d.ts.map +1 -1
- package/dist/ui/data-table-header.js +18 -15
- package/dist/ui/data-table-header.js.map +1 -1
- package/dist/ui/data-table-pagination.js +3 -3
- package/dist/ui/data-table-pagination.js.map +1 -1
- package/dist/ui/data-table-toolbar.d.ts +11 -1
- package/dist/ui/data-table-toolbar.d.ts.map +1 -1
- package/dist/ui/data-table-toolbar.js +7 -7
- package/dist/ui/data-table-toolbar.js.map +1 -1
- package/dist/ui/data-table.d.ts +52 -5
- package/dist/ui/data-table.d.ts.map +1 -1
- package/dist/ui/data-table.js +181 -169
- package/dist/ui/data-table.js.map +1 -1
- package/dist/ui/dialog.js +1 -1
- package/dist/ui/dialog.js.map +1 -1
- package/dist/ui/dot.js +13 -13
- package/dist/ui/dot.js.map +1 -1
- package/dist/ui/dropdown-menu.js +4 -4
- package/dist/ui/dropdown-menu.js.map +1 -1
- package/dist/ui/file-upload.js +3 -3
- package/dist/ui/file-upload.js.map +1 -1
- package/dist/ui/input-otp.js +1 -1
- package/dist/ui/input-otp.js.map +1 -1
- package/dist/ui/input.js +30 -30
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/lib/utils.js +2 -1
- package/dist/ui/lib/utils.js.map +1 -1
- package/dist/ui/menubar.js +5 -5
- package/dist/ui/menubar.js.map +1 -1
- package/dist/ui/navigation-menu.js +1 -1
- package/dist/ui/navigation-menu.js.map +1 -1
- package/dist/ui/number-input.js +36 -36
- package/dist/ui/number-input.js.map +1 -1
- package/dist/ui/pagination.js +1 -1
- package/dist/ui/pagination.js.map +1 -1
- package/dist/ui/progress-ring.js +2 -2
- package/dist/ui/progress-ring.js.map +1 -1
- package/dist/ui/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +66 -62
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/radio.js +1 -1
- package/dist/ui/radio.js.map +1 -1
- package/dist/ui/select.js +61 -61
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/sheet.js +47 -47
- package/dist/ui/sheet.js.map +1 -1
- package/dist/ui/sidebar.js +132 -132
- package/dist/ui/sidebar.js.map +1 -1
- package/dist/ui/skeleton.js +39 -39
- package/dist/ui/slider.js +18 -18
- package/dist/ui/slider.js.map +1 -1
- package/dist/ui/split-button.js +3 -3
- package/dist/ui/split-button.js.map +1 -1
- package/dist/ui/stat-card.js +1 -1
- package/dist/ui/stat-card.js.map +1 -1
- package/dist/ui/stepper.js +2 -2
- package/dist/ui/stepper.js.map +1 -1
- package/dist/ui/surface.d.ts.map +1 -1
- package/dist/ui/surface.js +11 -11
- package/dist/ui/surface.js.map +1 -1
- package/dist/ui/switch.js +1 -1
- package/dist/ui/switch.js.map +1 -1
- package/dist/ui/table.js +1 -1
- package/dist/ui/table.js.map +1 -1
- package/dist/ui/tabs.d.ts.map +1 -1
- package/dist/ui/tabs.js +48 -48
- package/dist/ui/tabs.js.map +1 -1
- package/dist/ui/text.js +8 -8
- package/dist/ui/textarea.js +17 -17
- package/dist/ui/textarea.js.map +1 -1
- package/dist/ui/toast.js +1 -1
- package/dist/ui/toast.js.map +1 -1
- package/dist/ui/toggle.js +15 -15
- package/dist/ui/toggle.js.map +1 -1
- package/docs/components/composed/avatar-group.md +4 -4
- package/docs/components/composed/diff.md +10 -2
- package/docs/components/composed/schedule-view.md +1 -1
- package/docs/components/shell/app-shell.md +132 -0
- package/docs/components/ui/avatar.md +1 -1
- package/docs/components/ui/button.md +1 -1
- package/docs/components/ui/chat.md +7 -1
- package/docs/components/ui/color-swatch.md +1 -1
- package/docs/components/ui/data-table-toolbar.md +6 -2
- package/docs/components/ui/data-table.md +41 -7
- package/docs/components/ui/dot.md +1 -1
- package/docs/components/ui/progress.md +1 -0
- package/docs/components/ui/surface.md +3 -3
- package/docs/components/ui/table.md +2 -2
- package/docs/recipes/install-astro.md +3 -2
- package/docs/recipes/install-next-app-router.md +3 -2
- package/docs/recipes/install-remix.md +3 -2
- package/docs/recipes/install-tanstack-start.md +3 -2
- package/docs/recipes/install-vite.md +3 -2
- package/docs/recipes/troubleshoot.md +26 -5
- package/llms.txt +2 -1
- package/make-kit/Guidelines.md +2 -2
- package/make-kit/components/button.md +1 -1
- package/make-kit/components/card.md +6 -6
- package/make-kit/components/surface.md +4 -4
- package/make-kit/foundations/color.md +4 -4
- package/make-kit/foundations/dark-mode.md +1 -1
- package/make-kit/foundations/radius.md +1 -1
- package/make-kit/foundations/surfaces.md +9 -9
- package/mcp-manifest.json +373 -34
- package/package.json +43 -13
- package/skill/SKILL.md +12 -6
- package/skill/references/components.md +2 -1
- package/skill/references/setup-astro.md +3 -2
- package/skill/references/setup-next-app-router.md +3 -2
- package/skill/references/setup-remix.md +3 -2
- package/skill/references/setup-tanstack-start.md +3 -2
- package/skill/references/setup-vite.md +3 -2
- package/skill/references/troubleshoot.md +26 -5
- package/dist/_chunks/tiptap.js +0 -18809
- package/dist/_chunks/tiptap.js.map +0 -1
- package/dist/_chunks/vendor-utils.js +0 -1766
- package/dist/_chunks/vendor-utils.js.map +0 -1
- package/dist/primitives/react-toast.d.ts +0 -120
- package/dist/ui/charts/_internal/scales.d.ts +0 -5
- package/dist/ui/charts/_internal/scales.d.ts.map +0 -1
- package/dist/ui/lib/slot.d.ts +0 -8
- package/dist/ui/lib/slot.d.ts.map +0 -1
- package/scripts/welcome.mjs +0 -312
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge-group.js","names":[],"sources":["../../src/ui/badge.tsx","../../src/ui/badge-group.tsx"],"sourcesContent":["'use client'\n\nimport { Slot } from '@primitives/react-slot'\nimport { IconCheck, IconX } from '@tabler/icons-react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { AnimatePresence, motion } from 'framer-motion'\nimport * as React from 'react'\n\nimport { Dot } from './dot'\nimport { Icon } from './icon'\nimport type { IconInput } from './lib/icon-input'\nimport { durations,springs } from './lib/motion'\nimport { normalizeIcon } from './lib/normalize-icon'\nimport { cn } from './lib/utils'\n\n// ── Color map — single source of truth for all badge color × variant combos ──\nconst colorMap = {\n default: { bg: 'bg-surface-raised-hover', fg: 'text-surface-fg-muted', border: 'border-surface-border-strong', solid: 'bg-neutral-5', solidFg: 'text-surface-fg' },\n accent: { bg: 'bg-accent-3', fg: 'text-accent-11', border: 'border-accent-7', solid: 'bg-accent-9', solidFg: 'text-accent-fg' },\n error: { bg: 'bg-error-3', fg: 'text-error-11', border: 'border-error-7', solid: 'bg-error-9', solidFg: 'text-error-fg' },\n success: { bg: 'bg-success-3', fg: 'text-success-11', border: 'border-success-7', solid: 'bg-success-9', solidFg: 'text-success-fg' },\n warning: { bg: 'bg-warning-3', fg: 'text-warning-11', border: 'border-warning-7', solid: 'bg-warning-9', solidFg: 'text-warning-fg' },\n info: { bg: 'bg-info-3', fg: 'text-info-11', border: 'border-info-7', solid: 'bg-info-9', solidFg: 'text-info-fg' },\n neutral: { bg: 'bg-surface-raised-hover', fg: 'text-surface-fg-muted', border: 'border-surface-border-strong', solid: 'bg-neutral-5', solidFg: 'text-surface-fg' },\n teal: { bg: 'bg-category-teal-3', fg: 'text-category-teal-11', border: 'border-category-teal-7', solid: 'bg-category-teal-9', solidFg: 'text-white' },\n amber: { bg: 'bg-category-amber-3', fg: 'text-category-amber-11', border: 'border-category-amber-7', solid: 'bg-category-amber-9', solidFg: 'text-white' },\n slate: { bg: 'bg-category-slate-3', fg: 'text-category-slate-11', border: 'border-category-slate-7', solid: 'bg-category-slate-9', solidFg: 'text-white' },\n indigo: { bg: 'bg-category-indigo-3', fg: 'text-category-indigo-11', border: 'border-category-indigo-7', solid: 'bg-category-indigo-9', solidFg: 'text-white' },\n cyan: { bg: 'bg-category-cyan-3', fg: 'text-category-cyan-11', border: 'border-category-cyan-7', solid: 'bg-category-cyan-9', solidFg: 'text-white' },\n orange: { bg: 'bg-category-orange-3', fg: 'text-category-orange-11', border: 'border-category-orange-7', solid: 'bg-category-orange-9', solidFg: 'text-white' },\n emerald: { bg: 'bg-category-emerald-3', fg: 'text-category-emerald-11', border: 'border-category-emerald-7', solid: 'bg-category-emerald-9', solidFg: 'text-white' },\n} as const\n\ntype BadgeColor = keyof typeof colorMap | 'custom'\n\n/** Derive color classes for a given variant + color pair */\nfunction getColorClasses(variant: 'subtle' | 'solid' | 'outline' | 'soft', color: BadgeColor): string {\n if (color === 'custom') return ''\n const c = colorMap[color]\n switch (variant) {\n case 'subtle': return cn(c.bg, c.fg, c.border)\n case 'solid': return cn(c.solid, c.solidFg, 'border-transparent')\n case 'outline': return cn('bg-transparent', c.fg, c.border)\n case 'soft': return cn(c.bg, c.fg, 'border-transparent')\n }\n}\n\nconst badgeVariants = cva(\n 'relative inline-flex items-center rounded-pill font-sans font-medium overflow-hidden isolate transition-[color,background-color,border-color,padding] duration-fast-02 ease-productive-standard select-none [&>span:not([data-grain])]:relative [&>span:not([data-grain])]:z-[2]',\n {\n variants: {\n variant: {\n subtle: 'border',\n solid: 'border border-transparent',\n outline: 'border',\n soft: 'border border-transparent',\n },\n size: {\n xs: 'h-4 px-ds-02b text-body-xs gap-ds-02',\n sm: 'h-5 px-ds-03 text-body-xs gap-ds-02',\n md: 'h-6 px-2.5 text-body-xs gap-ds-02b', /* px-2.5=10px — no exact DS token */\n lg: 'h-7 px-ds-04 text-body-sm gap-ds-02b',\n },\n },\n defaultVariants: {\n variant: 'subtle',\n size: 'md',\n },\n },\n)\n\n/** Icon sizing per badge size */\nconst iconSizeMap: Record<string, string> = {\n xs: '[&>svg]:h-2.5 [&>svg]:w-2.5',\n sm: '[&>svg]:h-3 [&>svg]:w-3',\n md: '[&>svg]:h-3 [&>svg]:w-3',\n lg: '[&>svg]:h-3.5 [&>svg]:w-3.5',\n}\n\n/** Reduced left padding when leading content (icon/dot/selected) is present */\nconst paddingLeftWithIcon: Record<string, string> = {\n xs: 'pl-ds-02',\n sm: 'pl-ds-02b',\n md: 'pl-ds-03',\n lg: 'pl-2.5', /* 10px — no exact DS token */\n}\n\n/** Reduced right padding when trailing content (dismiss/endIcon) is present */\nconst paddingRightWithTrailing: Record<string, string> = {\n xs: 'pr-ds-01',\n sm: 'pr-ds-02',\n md: 'pr-ds-02',\n lg: 'pr-ds-02b',\n}\n\n/**\n * Badge — a compact inline label with a two-axis variant system.\n *\n * **Two axes:**\n * - `variant` controls **visual style**: `\"subtle\"` | `\"solid\"` | `\"outline\"` | `\"soft\"`\n * - `color` controls **semantic intent/category**: 16 built-in colors + `\"custom\"` (CSS variable)\n *\n * **Interactive:** Pass `onClick` to make it a button. Pass `selected` for toggle state.\n * **Dismissible:** Pass `onDismiss` to show a dismiss button.\n * **Custom colors:** Set `color=\"custom\"` and CSS variable `--badge-color` on a parent or via `style`.\n * For light custom colors on solid variant, set `--badge-fg-color` to a dark value.\n *\n * @example\n * <Badge color=\"success\">Active</Badge>\n *\n * @example\n * <Badge variant=\"solid\" size=\"sm\" dot>3 new</Badge>\n *\n * @example\n * <Badge color=\"custom\" style={{ '--badge-color': '#8b5cf6' } as React.CSSProperties}>\n * Custom\n * </Badge>\n */\ninterface BadgeProps\n extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>,\n VariantProps<typeof badgeVariants> {\n /** Semantic intent or category color. Use `\"custom\"` with `--badge-color` CSS variable. */\n color?: BadgeColor\n asChild?: boolean\n startIcon?: IconInput\n endIcon?: IconInput\n dot?: boolean\n /** Pulse the status dot (opt-in; static by default). @default false */\n dotPulse?: boolean\n onDismiss?: () => void\n selected?: boolean\n disabled?: boolean\n maxWidth?: number\n /**\n * Truncate children with ellipsis when they overflow the badge width.\n * Use with a fixed width (e.g. `className=\"w-20\"`) or `maxWidth` for\n * constrained pill badges. Always adds a title tooltip on the full text.\n */\n truncate?: boolean\n circle?: boolean\n}\n\nconst Badge = React.forwardRef<HTMLElement, BadgeProps>(\n (\n {\n className,\n variant,\n color,\n size,\n asChild,\n startIcon,\n endIcon,\n dot,\n dotPulse,\n onDismiss,\n onClick,\n selected,\n disabled,\n maxWidth,\n truncate,\n circle,\n children,\n style,\n ...props\n },\n ref,\n ) => {\n const resolvedVariant = variant ?? 'subtle'\n const resolvedColor = color ?? 'default'\n const resolvedSize = size ?? 'md'\n\n // When both onClick + onDismiss, use div with role=\"button\" to avoid nested <button>\n const Comp = asChild\n ? Slot\n : onClick && onDismiss\n ? 'div'\n : onClick\n ? 'button'\n : 'span'\n\n // Custom color inline styles via CSS variable\n const customStyles =\n resolvedColor === 'custom'\n ? {\n ...(resolvedVariant === 'subtle' && {\n backgroundColor: 'color-mix(in oklch, var(--badge-color) 15%, transparent)',\n color: 'var(--badge-color)',\n borderColor: 'color-mix(in oklch, var(--badge-color) 40%, transparent)',\n }),\n ...(resolvedVariant === 'solid' && {\n backgroundColor: 'var(--badge-color)',\n color: 'var(--badge-fg-color, white)',\n borderColor: 'transparent',\n }),\n ...(resolvedVariant === 'outline' && {\n backgroundColor: 'transparent',\n color: 'var(--badge-color)',\n borderColor: 'color-mix(in oklch, var(--badge-color) 50%, transparent)',\n }),\n ...(resolvedVariant === 'soft' && {\n backgroundColor: 'color-mix(in oklch, var(--badge-color) 12%, transparent)',\n color: 'var(--badge-color)',\n borderColor: 'transparent',\n }),\n }\n : undefined\n\n // Keyboard handler for div[role=\"button\"] (onClick + onDismiss case)\n const handleKeyDown =\n onClick && onDismiss\n ? (e: React.KeyboardEvent<HTMLElement>) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n if (!disabled) onClick(e as unknown as React.MouseEvent<HTMLElement>)\n }\n props.onKeyDown?.(e)\n }\n : props.onKeyDown\n\n const hasLeading = !!(dot || startIcon || (onClick && selected && !startIcon && !dot))\n const hasTrailing = !!(onDismiss || endIcon)\n\n return (\n <Comp\n ref={ref as React.Ref<never>}\n className={cn(\n badgeVariants({ variant: resolvedVariant, size: resolvedSize }),\n getColorClasses(resolvedVariant, resolvedColor),\n hasLeading && paddingLeftWithIcon[resolvedSize],\n hasTrailing && paddingRightWithTrailing[resolvedSize],\n onClick &&\n 'cursor-pointer hover:brightness-[0.97] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-1 transition-[color,background-color,border-color,transform,filter] duration-moderate-01 ease-productive-exit hover:duration-fast-02 hover:ease-productive-entrance active:scale-[0.95] active:brightness-[0.92] active:duration-[0ms]',\n selected && 'ring-1 ring-current/20 transition-shadow duration-fast-02',\n disabled && 'opacity-action-disabled pointer-events-none saturate-[0.3]',\n circle && 'justify-center px-0 aspect-square',\n className,\n )}\n style={{ ...style, ...customStyles, ...(maxWidth ? { maxWidth } : undefined) }}\n onClick={disabled ? undefined : (onClick as React.MouseEventHandler<HTMLElement>)}\n onKeyDown={handleKeyDown}\n {...(Comp === 'button' && { type: 'button' as const })}\n {...(Comp === 'button' && disabled ? { disabled: true } : {})}\n {...(Comp === 'div' && onClick ? { role: 'button' as const, tabIndex: 0 } : {})}\n {...props}\n >\n {/* Dot indicator — animated entrance, uses the shared <Dot> (current colour + pulse) */}\n <AnimatePresence>\n {dot && (\n <motion.span\n key=\"dot\"\n initial={{ scale: 0 }}\n animate={{ scale: 1 }}\n exit={{ scale: 0 }}\n transition={springs.snappy}\n className=\"inline-flex shrink-0\"\n >\n <Dot color=\"current\" size=\"sm\" pulse={dotPulse} />\n </motion.span>\n )}\n </AnimatePresence>\n\n {/* Selected check icon — always mounted for interactive badges */}\n {onClick && !startIcon && !dot && (\n <motion.span\n initial={false}\n animate={selected\n ? { opacity: 1, scale: 1, width: 'auto', marginRight: 0 }\n : { opacity: 0, scale: 0.5, width: 0, marginRight: -4 }\n }\n transition={{ type: 'tween', duration: durations.moderate01, ease: [0.2, 0, 0.38, 0.9] }} /* ease-productive-standard */\n className=\"inline-flex shrink-0 overflow-hidden\"\n aria-hidden={!selected}\n >\n <Icon icon={IconCheck} size=\"xs\" />\n </motion.span>\n )}\n\n {/* Start icon */}\n {startIcon && (\n <span className={cn('shrink-0', iconSizeMap[resolvedSize])}>{normalizeIcon(startIcon)}</span>\n )}\n\n {/* Children — with optional truncation */}\n {truncate || maxWidth ? (\n <span\n className=\"truncate\"\n title={typeof children === 'string' ? children : undefined}\n >\n {children}\n </span>\n ) : (\n children\n )}\n\n {/* End icon */}\n {endIcon && (\n <span className={cn('shrink-0', iconSizeMap[resolvedSize])}>{normalizeIcon(endIcon)}</span>\n )}\n\n {/* Dismiss button */}\n {onDismiss && (\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation()\n onDismiss()\n }}\n className={cn(\n 'shrink-0 rounded-pill text-current/60 hover:text-current hover:bg-current/10 transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-accent-9',\n resolvedSize === 'xs'\n ? 'p-0 -mr-0.5 min-w-ds-05 min-h-ds-05'\n : 'p-px',\n )}\n aria-label={\n `Remove ${typeof children === 'string' ? children : ''}`.trim() || 'Remove'\n }\n >\n <Icon icon={IconX} size=\"xs\" />\n </button>\n )}\n </Comp>\n )\n },\n)\nBadge.displayName = 'Badge'\n\nimport { BadgeGroup } from './badge-group'\nimport { BadgeIndicator } from './badge-indicator'\n\nconst BadgeCompound = Object.assign(Badge, {\n Indicator: BadgeIndicator,\n Group: BadgeGroup,\n})\n\nexport { BadgeCompound as Badge, type BadgeColor,type BadgeProps, badgeVariants }\n","'use client'\n\nimport * as React from 'react'\n\nimport { Badge, type BadgeProps } from './badge'\nimport { cn } from './lib/utils'\n\nconst GAP_CLASSES = {\n tight: 'gap-1',\n default: 'gap-1.5',\n loose: 'gap-2',\n} as const\n\nexport interface BadgeGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n max?: number\n gap?: keyof typeof GAP_CLASSES\n size?: BadgeProps['size']\n onOverflowClick?: () => void\n children: React.ReactNode\n}\n\nexport const BadgeGroup = React.forwardRef<HTMLDivElement, BadgeGroupProps>(function BadgeGroup(\n { max, gap = 'default', size, onOverflowClick, className, children, ...rest },\n ref,\n) {\n const childArray = React.Children.toArray(children)\n const total = childArray.length\n const hasOverflow = max !== undefined && total > max\n const visible = hasOverflow ? childArray.slice(0, max) : childArray\n const overflowCount = hasOverflow ? total - max! : 0\n\n return (\n <div\n ref={ref}\n className={cn('flex flex-wrap items-center', GAP_CLASSES[gap], className)}\n {...rest}\n >\n {visible}\n {hasOverflow && (\n // With onClick, Badge renders a real, keyboard-reachable <button>; add a\n // label since \"+N\" alone isn't descriptive to a screen reader.\n <Badge\n variant=\"outline\"\n color=\"neutral\"\n size={size ?? 'sm'}\n onClick={onOverflowClick}\n aria-label={onOverflowClick ? `Show ${overflowCount} more` : undefined}\n >\n +{overflowCount}\n </Badge>\n )}\n </div>\n )\n})\n\nBadgeGroup.displayName = 'BadgeGroup'\n"],"mappings":";;;;;;;;;;;;;AAgBA,IAAM,IAAW;CACf,SAAS;EAAE,IAAI;EAA2B,IAAI;EAAyB,QAAQ;EAAgC,OAAO;EAAgB,SAAS;CAAkB;CACjK,QAAS;EAAE,IAAI;EAAgB,IAAI;EAAmB,QAAQ;EAAoB,OAAO;EAAgB,SAAS;CAAiB;CACnI,OAAS;EAAE,IAAI;EAAgB,IAAI;EAAmB,QAAQ;EAAoB,OAAO;EAAgB,SAAS;CAAgB;CAClI,SAAS;EAAE,IAAI;EAAgB,IAAI;EAAmB,QAAQ;EAAoB,OAAO;EAAgB,SAAS;CAAkB;CACpI,SAAS;EAA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version":3,"file":"badge-group.js","names":[],"sources":["../../src/ui/badge.tsx","../../src/ui/badge-group.tsx"],"sourcesContent":["'use client'\n\nimport { Slot } from '@primitives/react-slot'\nimport { IconCheck, IconX } from '@tabler/icons-react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { AnimatePresence, motion } from 'framer-motion'\nimport * as React from 'react'\n\nimport { Dot } from './dot'\nimport { Icon } from './icon'\nimport type { IconInput } from './lib/icon-input'\nimport { durations,springs } from './lib/motion'\nimport { normalizeIcon } from './lib/normalize-icon'\nimport { cn } from './lib/utils'\n\n// ── Color map — single source of truth for all badge color × variant combos ──\nconst colorMap = {\n default: { bg: 'bg-surface-panel-hover', softBg: 'bg-surface-panel-hover', fg: 'text-surface-fg-muted', border: 'border-surface-border-strong', solid: 'bg-neutral-5', solidFg: 'text-surface-fg' },\n accent: { bg: 'bg-accent-2', softBg: 'bg-accent-3', fg: 'text-accent-11', border: 'border-accent-4', solid: 'bg-accent-9', solidFg: 'text-accent-fg' },\n error: { bg: 'bg-error-2', softBg: 'bg-error-3', fg: 'text-error-11', border: 'border-error-4', solid: 'bg-error-9', solidFg: 'text-error-fg' },\n success: { bg: 'bg-success-2', softBg: 'bg-success-3', fg: 'text-success-11', border: 'border-success-4', solid: 'bg-success-9', solidFg: 'text-success-fg' },\n warning: { bg: 'bg-warning-2', softBg: 'bg-warning-3', fg: 'text-warning-11', border: 'border-warning-4', solid: 'bg-warning-9', solidFg: 'text-warning-fg' },\n info: { bg: 'bg-info-2', softBg: 'bg-info-3', fg: 'text-info-11', border: 'border-info-4', solid: 'bg-info-9', solidFg: 'text-info-fg' },\n neutral: { bg: 'bg-surface-panel-hover', softBg: 'bg-surface-panel-hover', fg: 'text-surface-fg-muted', border: 'border-surface-border-strong', solid: 'bg-neutral-5', solidFg: 'text-surface-fg' },\n teal: { bg: 'bg-category-teal-2', softBg: 'bg-category-teal-3', fg: 'text-category-teal-11', border: 'border-category-teal-4', solid: 'bg-category-teal-9', solidFg: 'text-category-fg' },\n amber: { bg: 'bg-category-amber-2', softBg: 'bg-category-amber-3', fg: 'text-category-amber-11', border: 'border-category-amber-4', solid: 'bg-category-amber-9', solidFg: 'text-category-fg' },\n slate: { bg: 'bg-category-slate-2', softBg: 'bg-category-slate-3', fg: 'text-category-slate-11', border: 'border-category-slate-4', solid: 'bg-category-slate-9', solidFg: 'text-category-fg' },\n indigo: { bg: 'bg-category-indigo-2', softBg: 'bg-category-indigo-3', fg: 'text-category-indigo-11', border: 'border-category-indigo-4', solid: 'bg-category-indigo-9', solidFg: 'text-category-fg' },\n cyan: { bg: 'bg-category-cyan-2', softBg: 'bg-category-cyan-3', fg: 'text-category-cyan-11', border: 'border-category-cyan-4', solid: 'bg-category-cyan-9', solidFg: 'text-category-fg' },\n orange: { bg: 'bg-category-orange-2', softBg: 'bg-category-orange-3', fg: 'text-category-orange-11', border: 'border-category-orange-4', solid: 'bg-category-orange-9', solidFg: 'text-category-fg' },\n emerald: { bg: 'bg-category-emerald-2', softBg: 'bg-category-emerald-3', fg: 'text-category-emerald-11', border: 'border-category-emerald-4', solid: 'bg-category-emerald-9', solidFg: 'text-category-fg' },\n} as const\n\ntype BadgeColor = keyof typeof colorMap | 'custom'\n\n/** Derive color classes for a given variant + color pair */\nfunction getColorClasses(variant: 'subtle' | 'solid' | 'outline' | 'soft', color: BadgeColor): string {\n if (color === 'custom') return ''\n const c = colorMap[color]\n switch (variant) {\n case 'subtle': return cn(c.bg, c.fg, c.border)\n case 'solid': return cn(c.solid, c.solidFg, 'border-transparent')\n case 'outline': return cn('bg-transparent', c.fg, c.border)\n // soft keeps the original step-3 fill. subtle moved to step 2; soft did not,\n // so the two cannot share one key (design call, Yogin/Goutham 2026-08-24).\n case 'soft': return cn(c.softBg, c.fg, 'border-transparent')\n }\n}\n\nconst badgeVariants = cva(\n 'relative inline-flex items-center rounded-pill font-sans font-medium overflow-hidden isolate transition-[color,background-color,border-color,padding] duration-fast-02 ease-productive-standard select-none [&>span:not([data-grain])]:relative [&>span:not([data-grain])]:z-[2]',\n {\n variants: {\n variant: {\n subtle: 'border',\n solid: 'border border-transparent',\n outline: 'border',\n soft: 'border border-transparent',\n },\n size: {\n xs: 'h-4 px-ds-02b text-body-xs gap-ds-02',\n sm: 'h-5 px-ds-03 text-body-xs gap-ds-02',\n md: 'h-6 px-2.5 text-body-xs gap-ds-02b', /* px-2.5=10px — no exact DS token */\n lg: 'h-7 px-ds-04 text-body-sm gap-ds-02b',\n },\n },\n defaultVariants: {\n variant: 'subtle',\n size: 'md',\n },\n },\n)\n\n/** Icon sizing per badge size */\nconst iconSizeMap: Record<string, string> = {\n xs: '[&>svg]:h-2.5 [&>svg]:w-2.5',\n sm: '[&>svg]:h-3 [&>svg]:w-3',\n md: '[&>svg]:h-3 [&>svg]:w-3',\n lg: '[&>svg]:h-3.5 [&>svg]:w-3.5',\n}\n\n/** Reduced left padding when leading content (icon/dot/selected) is present */\nconst paddingLeftWithIcon: Record<string, string> = {\n xs: 'pl-ds-02',\n sm: 'pl-ds-02b',\n md: 'pl-ds-03',\n lg: 'pl-2.5', /* 10px — no exact DS token */\n}\n\n/** Reduced right padding when trailing content (dismiss/endIcon) is present */\nconst paddingRightWithTrailing: Record<string, string> = {\n xs: 'pr-ds-01',\n sm: 'pr-ds-02',\n md: 'pr-ds-02',\n lg: 'pr-ds-02b',\n}\n\n/**\n * Badge — a compact inline label with a two-axis variant system.\n *\n * **Two axes:**\n * - `variant` controls **visual style**: `\"subtle\"` | `\"solid\"` | `\"outline\"` | `\"soft\"`\n * - `color` controls **semantic intent/category**: 16 built-in colors + `\"custom\"` (CSS variable)\n *\n * **Interactive:** Pass `onClick` to make it a button. Pass `selected` for toggle state.\n * **Dismissible:** Pass `onDismiss` to show a dismiss button.\n * **Custom colors:** Set `color=\"custom\"` and CSS variable `--badge-color` on a parent or via `style`.\n * For light custom colors on solid variant, set `--badge-fg-color` to a dark value.\n *\n * @example\n * <Badge color=\"success\">Active</Badge>\n *\n * @example\n * <Badge variant=\"solid\" size=\"sm\" dot>3 new</Badge>\n *\n * @example\n * <Badge color=\"custom\" style={{ '--badge-color': '#8b5cf6' } as React.CSSProperties}>\n * Custom\n * </Badge>\n */\ninterface BadgeProps\n extends Omit<React.HTMLAttributes<HTMLElement>, 'color'>,\n VariantProps<typeof badgeVariants> {\n /** Semantic intent or category color. Use `\"custom\"` with `--badge-color` CSS variable. */\n color?: BadgeColor\n asChild?: boolean\n startIcon?: IconInput\n endIcon?: IconInput\n dot?: boolean\n /** Pulse the status dot (opt-in; static by default). @default false */\n dotPulse?: boolean\n onDismiss?: () => void\n selected?: boolean\n disabled?: boolean\n maxWidth?: number\n /**\n * Truncate children with ellipsis when they overflow the badge width.\n * Use with a fixed width (e.g. `className=\"w-20\"`) or `maxWidth` for\n * constrained pill badges. Always adds a title tooltip on the full text.\n */\n truncate?: boolean\n circle?: boolean\n}\n\nconst Badge = React.forwardRef<HTMLElement, BadgeProps>(\n (\n {\n className,\n variant,\n color,\n size,\n asChild,\n startIcon,\n endIcon,\n dot,\n dotPulse,\n onDismiss,\n onClick,\n selected,\n disabled,\n maxWidth,\n truncate,\n circle,\n children,\n style,\n ...props\n },\n ref,\n ) => {\n const resolvedVariant = variant ?? 'subtle'\n const resolvedColor = color ?? 'default'\n const resolvedSize = size ?? 'md'\n\n // When both onClick + onDismiss, use div with role=\"button\" to avoid nested <button>\n const Comp = asChild\n ? Slot\n : onClick && onDismiss\n ? 'div'\n : onClick\n ? 'button'\n : 'span'\n\n // Custom color inline styles via CSS variable\n const customStyles =\n resolvedColor === 'custom'\n ? {\n ...(resolvedVariant === 'subtle' && {\n backgroundColor: 'color-mix(in oklch, var(--badge-color) 15%, transparent)',\n color: 'var(--badge-color)',\n borderColor: 'color-mix(in oklch, var(--badge-color) 40%, transparent)',\n }),\n ...(resolvedVariant === 'solid' && {\n backgroundColor: 'var(--badge-color)',\n color: 'var(--badge-fg-color, white)',\n borderColor: 'transparent',\n }),\n ...(resolvedVariant === 'outline' && {\n backgroundColor: 'transparent',\n color: 'var(--badge-color)',\n borderColor: 'color-mix(in oklch, var(--badge-color) 50%, transparent)',\n }),\n ...(resolvedVariant === 'soft' && {\n backgroundColor: 'color-mix(in oklch, var(--badge-color) 12%, transparent)',\n color: 'var(--badge-color)',\n borderColor: 'transparent',\n }),\n }\n : undefined\n\n // Keyboard handler for div[role=\"button\"] (onClick + onDismiss case)\n const handleKeyDown =\n onClick && onDismiss\n ? (e: React.KeyboardEvent<HTMLElement>) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n if (!disabled) onClick(e as unknown as React.MouseEvent<HTMLElement>)\n }\n props.onKeyDown?.(e)\n }\n : props.onKeyDown\n\n const hasLeading = !!(dot || startIcon || (onClick && selected && !startIcon && !dot))\n const hasTrailing = !!(onDismiss || endIcon)\n\n return (\n <Comp\n ref={ref as React.Ref<never>}\n className={cn(\n badgeVariants({ variant: resolvedVariant, size: resolvedSize }),\n getColorClasses(resolvedVariant, resolvedColor),\n hasLeading && paddingLeftWithIcon[resolvedSize],\n hasTrailing && paddingRightWithTrailing[resolvedSize],\n onClick &&\n 'cursor-pointer hover:brightness-[0.97] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9 focus-visible:ring-offset-1 transition-[color,background-color,border-color,transform,filter] duration-moderate-01 ease-productive-exit hover:duration-fast-02 hover:ease-productive-entrance active:scale-[0.95] active:brightness-[0.92] active:duration-[0ms]',\n selected && 'ring-1 ring-current/20 transition-shadow duration-fast-02',\n disabled && 'opacity-action-disabled pointer-events-none saturate-[0.3]',\n circle && 'justify-center px-0 aspect-square',\n className,\n )}\n style={{ ...style, ...customStyles, ...(maxWidth ? { maxWidth } : undefined) }}\n onClick={disabled ? undefined : (onClick as React.MouseEventHandler<HTMLElement>)}\n onKeyDown={handleKeyDown}\n {...(Comp === 'button' && { type: 'button' as const })}\n {...(Comp === 'button' && disabled ? { disabled: true } : {})}\n {...(Comp === 'div' && onClick ? { role: 'button' as const, tabIndex: 0 } : {})}\n {...props}\n >\n {/* Dot indicator — animated entrance, uses the shared <Dot> (current colour + pulse) */}\n <AnimatePresence>\n {dot && (\n <motion.span\n key=\"dot\"\n initial={{ scale: 0 }}\n animate={{ scale: 1 }}\n exit={{ scale: 0 }}\n transition={springs.snappy}\n className=\"inline-flex shrink-0\"\n >\n <Dot color=\"current\" size=\"sm\" pulse={dotPulse} />\n </motion.span>\n )}\n </AnimatePresence>\n\n {/* Selected check icon — always mounted for interactive badges */}\n {onClick && !startIcon && !dot && (\n <motion.span\n initial={false}\n animate={selected\n ? { opacity: 1, scale: 1, width: 'auto', marginRight: 0 }\n : { opacity: 0, scale: 0.5, width: 0, marginRight: -4 }\n }\n transition={{ type: 'tween', duration: durations.moderate01, ease: [0.2, 0, 0.38, 0.9] }} /* ease-productive-standard */\n className=\"inline-flex shrink-0 overflow-hidden\"\n aria-hidden={!selected}\n >\n <Icon icon={IconCheck} size=\"xs\" />\n </motion.span>\n )}\n\n {/* Start icon */}\n {startIcon && (\n <span className={cn('shrink-0', iconSizeMap[resolvedSize])}>{normalizeIcon(startIcon)}</span>\n )}\n\n {/* Children — with optional truncation */}\n {truncate || maxWidth ? (\n <span\n className=\"truncate\"\n title={typeof children === 'string' ? children : undefined}\n >\n {children}\n </span>\n ) : (\n children\n )}\n\n {/* End icon */}\n {endIcon && (\n <span className={cn('shrink-0', iconSizeMap[resolvedSize])}>{normalizeIcon(endIcon)}</span>\n )}\n\n {/* Dismiss button */}\n {onDismiss && (\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation()\n onDismiss()\n }}\n className={cn(\n 'shrink-0 rounded-pill text-current/60 hover:text-current hover:bg-current/10 transition-colors focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-accent-9',\n resolvedSize === 'xs'\n ? 'p-0 -mr-0.5 min-w-ds-05 min-h-ds-05'\n : 'p-px',\n )}\n aria-label={\n `Remove ${typeof children === 'string' ? children : ''}`.trim() || 'Remove'\n }\n >\n <Icon icon={IconX} size=\"xs\" />\n </button>\n )}\n </Comp>\n )\n },\n)\nBadge.displayName = 'Badge'\n\nimport { BadgeGroup } from './badge-group'\nimport { BadgeIndicator } from './badge-indicator'\n\nconst BadgeCompound = Object.assign(Badge, {\n Indicator: BadgeIndicator,\n Group: BadgeGroup,\n})\n\nexport { BadgeCompound as Badge, type BadgeColor,type BadgeProps, badgeVariants }\n","'use client'\n\nimport * as React from 'react'\n\nimport { Badge, type BadgeProps } from './badge'\nimport { cn } from './lib/utils'\n\nconst GAP_CLASSES = {\n tight: 'gap-1',\n default: 'gap-1.5',\n loose: 'gap-2',\n} as const\n\nexport interface BadgeGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n max?: number\n gap?: keyof typeof GAP_CLASSES\n size?: BadgeProps['size']\n onOverflowClick?: () => void\n children: React.ReactNode\n}\n\nexport const BadgeGroup = React.forwardRef<HTMLDivElement, BadgeGroupProps>(function BadgeGroup(\n { max, gap = 'default', size, onOverflowClick, className, children, ...rest },\n ref,\n) {\n const childArray = React.Children.toArray(children)\n const total = childArray.length\n const hasOverflow = max !== undefined && total > max\n const visible = hasOverflow ? childArray.slice(0, max) : childArray\n const overflowCount = hasOverflow ? total - max! : 0\n\n return (\n <div\n ref={ref}\n className={cn('flex flex-wrap items-center', GAP_CLASSES[gap], className)}\n {...rest}\n >\n {visible}\n {hasOverflow && (\n // With onClick, Badge renders a real, keyboard-reachable <button>; add a\n // label since \"+N\" alone isn't descriptive to a screen reader.\n <Badge\n variant=\"outline\"\n color=\"neutral\"\n size={size ?? 'sm'}\n onClick={onOverflowClick}\n aria-label={onOverflowClick ? `Show ${overflowCount} more` : undefined}\n >\n +{overflowCount}\n </Badge>\n )}\n </div>\n )\n})\n\nBadgeGroup.displayName = 'BadgeGroup'\n"],"mappings":";;;;;;;;;;;;;AAgBA,IAAM,IAAW;CACf,SAAS;EAAE,IAAI;EAA0B,QAAQ;EAA0B,IAAI;EAAyB,QAAQ;EAAgC,OAAO;EAAgB,SAAS;CAAkB;CAClM,QAA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Aa,EAAM,SAAS,QAAQ,CAAQ,GAC5C,IAAQ,EAAW,QACnB,IAAc,MAAQ,KAAA,KAAa,IAAQ,GAC3C,IAAU,IAAc,EAAW,MAAM,GAAG,CAAG,IAAI,GACnD,IAAgB,IAAc,IAAQ,IAAO;CAEnD,OACE,kBAAC,OAAD;EACO;EACL,WAAW,EAAG,+BAA+B,EAAY,IAAM,CAAS;EACxE,GAAI;YAHN,CAKG,GACA,KAGC,kBAAC,GAAD;GACE,SAAQ;GACR,OAAM;GACN,MAAM,KAAQ;GACd,SAAS;GACT,cAAY,IAAkB,QAAQ,EAAc,SAAS,KAAA;aAL/D,CAMC,KACG,CACG;IAEN;;AAET,CAAC;AAED,EAAW,cAAc"}
|
package/dist/_chunks/chat.js
CHANGED
|
@@ -15,39 +15,55 @@ import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
|
15
15
|
import { IconAlertCircle as b, IconSend as x, IconSquare as S, IconTrash as C } from "@tabler/icons-react";
|
|
16
16
|
import { AnimatePresence as w, motion as T } from "framer-motion";
|
|
17
17
|
//#region src/ui/chat/date-separator.tsx
|
|
18
|
-
function E(e) {
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
function E(e, t) {
|
|
19
|
+
let n = new Intl.DateTimeFormat("en-US", {
|
|
20
|
+
timeZone: t,
|
|
21
|
+
year: "numeric",
|
|
22
|
+
month: "2-digit",
|
|
23
|
+
day: "2-digit"
|
|
24
|
+
}).formatToParts(e), r = (e) => Number(n.find((t) => t.type === e)?.value);
|
|
25
|
+
return {
|
|
26
|
+
year: r("year"),
|
|
27
|
+
month: r("month"),
|
|
28
|
+
day: r("day")
|
|
29
|
+
};
|
|
24
30
|
}
|
|
25
|
-
function D(
|
|
26
|
-
let r =
|
|
31
|
+
function D(e, t, n) {
|
|
32
|
+
let r = E(/* @__PURE__ */ new Date(), n), i = E(e, n), a = Date.UTC(r.year, r.month - 1, r.day), o = Date.UTC(i.year, i.month - 1, i.day), s = Math.round((a - o) / (1e3 * 60 * 60 * 24));
|
|
33
|
+
if (s === 0) return "Today";
|
|
34
|
+
if (s === 1) return "Yesterday";
|
|
35
|
+
let c = e.toLocaleString(t, {
|
|
36
|
+
month: "short",
|
|
37
|
+
timeZone: n
|
|
38
|
+
});
|
|
39
|
+
return i.year === r.year ? `${c} ${i.day}` : `${c} ${i.day}, ${i.year}`;
|
|
40
|
+
}
|
|
41
|
+
function O({ date: e, format: t, className: n, locale: r = "en-US", timeZone: a }) {
|
|
42
|
+
let o = typeof e == "string" ? new Date(e) : e, s = t ? t(o) : D(o, r, a);
|
|
27
43
|
return /* @__PURE__ */ y("div", {
|
|
28
44
|
className: i("flex items-center gap-ds-03 py-ds-03", n),
|
|
29
45
|
children: [
|
|
30
46
|
/* @__PURE__ */ v("div", { className: "flex-1 border-t border-surface-border-subtle" }),
|
|
31
47
|
/* @__PURE__ */ v("span", {
|
|
32
|
-
className: "text-label-xs font-medium text-surface-fg-subtle
|
|
33
|
-
children:
|
|
48
|
+
className: "text-label-xs font-medium text-surface-fg-subtle uppercase tracking-wider",
|
|
49
|
+
children: s
|
|
34
50
|
}),
|
|
35
51
|
/* @__PURE__ */ v("div", { className: "flex-1 border-t border-surface-border-subtle" })
|
|
36
52
|
]
|
|
37
53
|
});
|
|
38
54
|
}
|
|
39
|
-
|
|
55
|
+
O.displayName = "DateSeparator";
|
|
40
56
|
//#endregion
|
|
41
57
|
//#region src/ui/chat/message.tsx
|
|
42
|
-
var
|
|
58
|
+
var k = _.createContext({
|
|
43
59
|
variant: "flat",
|
|
44
60
|
placement: "start",
|
|
45
61
|
grouped: !1
|
|
46
62
|
});
|
|
47
|
-
function
|
|
48
|
-
return _.useContext(
|
|
63
|
+
function A() {
|
|
64
|
+
return _.useContext(k);
|
|
49
65
|
}
|
|
50
|
-
var
|
|
66
|
+
var j = _.forwardRef(({ children: e, variant: r = "flat", placement: a = "start", highlight: s, grouped: c = !1, deleted: l = !1, deletedText: u = "This message was deleted", className: d, ...f }, p) => {
|
|
51
67
|
let m = _.useMemo(() => ({
|
|
52
68
|
variant: r,
|
|
53
69
|
placement: a,
|
|
@@ -67,13 +83,13 @@ var A = _.forwardRef(({ children: e, variant: r = "flat", placement: a = "start"
|
|
|
67
83
|
y: 0
|
|
68
84
|
},
|
|
69
85
|
transition: n.snappy,
|
|
70
|
-
className: i("flex items-center gap-ds-02 py-ds-02 text-caption text-surface-fg-subtle
|
|
86
|
+
className: i("flex items-center gap-ds-02 py-ds-02 text-caption text-surface-fg-subtle italic", d),
|
|
71
87
|
...t(f),
|
|
72
88
|
children: [/* @__PURE__ */ v(o, {
|
|
73
89
|
icon: C,
|
|
74
90
|
size: "xs"
|
|
75
91
|
}), u]
|
|
76
|
-
}) : r === "bubble" ? /* @__PURE__ */ v(
|
|
92
|
+
}) : r === "bubble" ? /* @__PURE__ */ v(k.Provider, {
|
|
77
93
|
value: m,
|
|
78
94
|
children: /* @__PURE__ */ v(T.div, {
|
|
79
95
|
ref: p,
|
|
@@ -87,11 +103,11 @@ var A = _.forwardRef(({ children: e, variant: r = "flat", placement: a = "start"
|
|
|
87
103
|
className: i("group/message relative flex", a === "end" ? "justify-end" : "justify-start", g, s === "internal" && "bg-warning-2/50 rounded-control-inner", d),
|
|
88
104
|
...t(f),
|
|
89
105
|
children: /* @__PURE__ */ v("div", {
|
|
90
|
-
className: i("max-w-[85%] rounded-bubble px-ds-04 py-ds-03", a === "end" ? "bg-accent-3 text-surface-fg" : "bg-surface-
|
|
106
|
+
className: i("max-w-[85%] rounded-bubble px-ds-04 py-ds-03", a === "end" ? "bg-accent-3 text-surface-fg" : "bg-surface-panel text-surface-fg"),
|
|
91
107
|
children: e
|
|
92
108
|
})
|
|
93
109
|
})
|
|
94
|
-
}) : /* @__PURE__ */ v(
|
|
110
|
+
}) : /* @__PURE__ */ v(k.Provider, {
|
|
95
111
|
value: m,
|
|
96
112
|
children: /* @__PURE__ */ v(T.div, {
|
|
97
113
|
ref: p,
|
|
@@ -108,14 +124,14 @@ var A = _.forwardRef(({ children: e, variant: r = "flat", placement: a = "start"
|
|
|
108
124
|
})
|
|
109
125
|
});
|
|
110
126
|
});
|
|
111
|
-
|
|
112
|
-
function
|
|
113
|
-
let { grouped: d } =
|
|
127
|
+
j.displayName = "Message";
|
|
128
|
+
function M({ src: t, fallback: n, icon: r, size: a = "md", children: o }) {
|
|
129
|
+
let { grouped: d } = A(), f = a === "sm" ? "w-5" : "w-6";
|
|
114
130
|
return d ? /* @__PURE__ */ v("div", { className: i(f, a === "sm" ? "h-5" : "h-6", "shrink-0") }) : o ? /* @__PURE__ */ v("div", {
|
|
115
131
|
className: i(f, "shrink-0 flex items-start"),
|
|
116
132
|
children: o
|
|
117
133
|
}) : r ? /* @__PURE__ */ v("div", {
|
|
118
|
-
className: i(f, a === "sm" ? "h-5" : "h-6", "shrink-0 flex items-center justify-center rounded-pill bg-surface-
|
|
134
|
+
className: i(f, a === "sm" ? "h-5" : "h-6", "shrink-0 flex items-center justify-center rounded-pill bg-surface-panel-hover"),
|
|
119
135
|
children: /* @__PURE__ */ v(e, {
|
|
120
136
|
size: a === "sm" ? "xs" : "sm",
|
|
121
137
|
children: u(r)
|
|
@@ -131,23 +147,23 @@ function j({ src: t, fallback: n, icon: r, size: a = "md", children: o }) {
|
|
|
131
147
|
})
|
|
132
148
|
});
|
|
133
149
|
}
|
|
134
|
-
|
|
135
|
-
function
|
|
150
|
+
M.displayName = "Message.Avatar";
|
|
151
|
+
function N({ children: e, className: t, ...n }) {
|
|
136
152
|
return /* @__PURE__ */ v("div", {
|
|
137
153
|
className: i("min-w-0 flex-1 flex flex-col gap-ds-02", t),
|
|
138
154
|
...n,
|
|
139
155
|
children: e
|
|
140
156
|
});
|
|
141
157
|
}
|
|
142
|
-
|
|
143
|
-
function
|
|
158
|
+
N.displayName = "Message.Content";
|
|
159
|
+
function P(e) {
|
|
144
160
|
return e.toLocaleTimeString("en-US", {
|
|
145
161
|
hour: "numeric",
|
|
146
162
|
minute: "2-digit"
|
|
147
163
|
});
|
|
148
164
|
}
|
|
149
|
-
function
|
|
150
|
-
let { grouped: a } =
|
|
165
|
+
function F({ name: e, badge: t, timestamp: n, formattedTimestamp: r, timestampFormat: i = P }) {
|
|
166
|
+
let { grouped: a } = A();
|
|
151
167
|
if (a) return null;
|
|
152
168
|
let o = r ?? (n ? i(n) : void 0);
|
|
153
169
|
return /* @__PURE__ */ y("div", {
|
|
@@ -159,22 +175,22 @@ function P({ name: e, badge: t, timestamp: n, formattedTimestamp: r, timestampFo
|
|
|
159
175
|
}),
|
|
160
176
|
t,
|
|
161
177
|
o && /* @__PURE__ */ v("span", {
|
|
162
|
-
className: "text-body-sm text-surface-fg-subtle
|
|
178
|
+
className: "text-body-sm text-surface-fg-subtle",
|
|
163
179
|
children: o
|
|
164
180
|
})
|
|
165
181
|
]
|
|
166
182
|
});
|
|
167
183
|
}
|
|
168
|
-
|
|
169
|
-
function
|
|
184
|
+
F.displayName = "Message.Author";
|
|
185
|
+
function I({ children: e, className: t, ...n }) {
|
|
170
186
|
return /* @__PURE__ */ v("div", {
|
|
171
187
|
className: i("text-body-md leading-relaxed text-surface-fg whitespace-pre-wrap", t),
|
|
172
188
|
...n,
|
|
173
189
|
children: e
|
|
174
190
|
});
|
|
175
191
|
}
|
|
176
|
-
|
|
177
|
-
function
|
|
192
|
+
I.displayName = "Message.Body";
|
|
193
|
+
function L({ content: e, onSave: t, onCancel: n, canEdit: r = !1, renderContent: a }) {
|
|
178
194
|
let [o, s] = _.useState(!1), [c, l] = _.useState(e), u = _.useRef(null);
|
|
179
195
|
_.useEffect(() => {
|
|
180
196
|
o && u.current && (u.current.focus(), u.current.select());
|
|
@@ -201,14 +217,14 @@ function I({ content: e, onSave: t, onCancel: n, canEdit: r = !1, renderContent:
|
|
|
201
217
|
onChange: (e) => l(e.target.value),
|
|
202
218
|
onKeyDown: h,
|
|
203
219
|
onBlur: p,
|
|
204
|
-
className: "resize-none rounded-control-inner bg-surface-
|
|
220
|
+
className: "resize-none rounded-control-inner bg-surface-panel-hover px-ds-02 py-ds-01 text-body-md leading-relaxed",
|
|
205
221
|
rows: 2
|
|
206
222
|
}), /* @__PURE__ */ v("div", {
|
|
207
|
-
className: "mt-ds-01 text-caption text-surface-fg-subtle
|
|
223
|
+
className: "mt-ds-01 text-caption text-surface-fg-subtle",
|
|
208
224
|
children: "Enter to save · Escape to cancel"
|
|
209
225
|
})]
|
|
210
226
|
}) : /* @__PURE__ */ v("div", {
|
|
211
|
-
className: i("text-body-md leading-relaxed text-surface-fg whitespace-pre-wrap", r && "cursor-pointer hover:bg-surface-
|
|
227
|
+
className: i("text-body-md leading-relaxed text-surface-fg whitespace-pre-wrap", r && "cursor-pointer hover:bg-surface-panel-hover rounded-control-inner transition-colors"),
|
|
212
228
|
onClick: d,
|
|
213
229
|
role: r ? "button" : void 0,
|
|
214
230
|
tabIndex: r ? 0 : void 0,
|
|
@@ -218,36 +234,36 @@ function I({ content: e, onSave: t, onCancel: n, canEdit: r = !1, renderContent:
|
|
|
218
234
|
children: a ? a(e) : e
|
|
219
235
|
});
|
|
220
236
|
}
|
|
221
|
-
|
|
222
|
-
function
|
|
237
|
+
L.displayName = "Message.EditableBody";
|
|
238
|
+
function R({ reactions: e, onReact: t }) {
|
|
223
239
|
return e.length === 0 ? null : /* @__PURE__ */ v("div", {
|
|
224
240
|
className: "flex flex-wrap gap-ds-02 mt-ds-03",
|
|
225
241
|
children: e.map((e) => /* @__PURE__ */ y("button", {
|
|
226
242
|
type: "button",
|
|
227
243
|
onClick: () => t(e.emoji),
|
|
228
244
|
"aria-label": `${e.emoji} ${e.count} reaction${e.count === 1 ? "" : "s"}${e.reacted ? ", you reacted" : ""}`,
|
|
229
|
-
className: i("inline-flex items-center gap-ds-01 rounded-pill px-ds-02 py-ds-01 text-body-xs transition-colors", e.reacted ? "bg-accent-3 ring-1 ring-accent-6" : "bg-surface-
|
|
245
|
+
className: i("inline-flex items-center gap-ds-01 rounded-pill px-ds-02 py-ds-01 text-body-xs transition-colors", e.reacted ? "bg-accent-3 ring-1 ring-accent-6" : "bg-surface-panel-hover hover:bg-surface-panel-active"),
|
|
230
246
|
children: [/* @__PURE__ */ v("span", { children: e.emoji }), /* @__PURE__ */ v("span", { children: e.count })]
|
|
231
247
|
}, e.emoji))
|
|
232
248
|
});
|
|
233
249
|
}
|
|
234
|
-
|
|
235
|
-
function
|
|
250
|
+
R.displayName = "Message.Reactions";
|
|
251
|
+
function z({ children: e, delay: t = 100 }) {
|
|
236
252
|
return /* @__PURE__ */ v("div", {
|
|
237
|
-
className: i("absolute -top-2 right-0 z-10", "flex items-center gap-ds-01 rounded-control bg-surface-
|
|
253
|
+
className: i("absolute -top-2 right-0 z-10", "flex items-center gap-ds-01 rounded-control bg-surface-panel px-ds-01 py-ds-01 shadow-raised", "opacity-0 group-hover/message:opacity-100 group-focus-within/message:opacity-100 transition-opacity duration-150"),
|
|
238
254
|
style: { transitionDelay: `${t}ms` },
|
|
239
255
|
children: e
|
|
240
256
|
});
|
|
241
257
|
}
|
|
242
|
-
|
|
243
|
-
function
|
|
258
|
+
z.displayName = "Message.Actions";
|
|
259
|
+
function B({ icon: t, label: n, onClick: r, variant: a = "default" }) {
|
|
244
260
|
return /* @__PURE__ */ y(p, { children: [/* @__PURE__ */ v(h, {
|
|
245
261
|
asChild: !0,
|
|
246
262
|
children: /* @__PURE__ */ v("button", {
|
|
247
263
|
type: "button",
|
|
248
264
|
onClick: r,
|
|
249
265
|
"aria-label": n,
|
|
250
|
-
className: i("p-ds-02 rounded-control-inner transition-colors", a === "default" && "text-surface-fg-subtle hover:text-surface-fg hover:bg-surface-
|
|
266
|
+
className: i("p-ds-02 rounded-control-inner transition-colors", a === "default" && "text-surface-fg-subtle hover:text-surface-fg hover:bg-surface-panel-hover", a === "danger" && "text-surface-fg-subtle hover:text-error-11 hover:bg-surface-panel-hover"),
|
|
251
267
|
children: /* @__PURE__ */ v(e, {
|
|
252
268
|
size: "xs",
|
|
253
269
|
children: u(t)
|
|
@@ -255,17 +271,17 @@ function z({ icon: t, label: n, onClick: r, variant: a = "default" }) {
|
|
|
255
271
|
})
|
|
256
272
|
}), /* @__PURE__ */ v(m, { children: n })] });
|
|
257
273
|
}
|
|
258
|
-
|
|
259
|
-
var
|
|
260
|
-
Avatar:
|
|
261
|
-
Content:
|
|
262
|
-
Author:
|
|
263
|
-
Body:
|
|
264
|
-
EditableBody:
|
|
265
|
-
Reactions:
|
|
266
|
-
Actions:
|
|
267
|
-
Action:
|
|
268
|
-
}),
|
|
274
|
+
B.displayName = "Message.Action";
|
|
275
|
+
var V = Object.assign(j, {
|
|
276
|
+
Avatar: M,
|
|
277
|
+
Content: N,
|
|
278
|
+
Author: F,
|
|
279
|
+
Body: I,
|
|
280
|
+
EditableBody: L,
|
|
281
|
+
Reactions: R,
|
|
282
|
+
Actions: z,
|
|
283
|
+
Action: B
|
|
284
|
+
}), H = _.forwardRef(({ onSubmit: e, placeholder: t = "Type a message...", disabled: n = !1, isStreaming: r = !1, onCancel: a, leadingSlot: s, trailingSlot: c, disclaimer: l, sendIcon: u, className: f, ...p }, m) => {
|
|
269
285
|
let [h, g] = _.useState(""), b = _.useRef(null), C = _.useCallback(() => {
|
|
270
286
|
let e = b.current;
|
|
271
287
|
e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, 160)}px`);
|
|
@@ -298,7 +314,7 @@ var B = Object.assign(A, {
|
|
|
298
314
|
"aria-label": t || "Type a message",
|
|
299
315
|
disabled: n,
|
|
300
316
|
rows: 1,
|
|
301
|
-
className: "flex-1 resize-none bg-transparent px-ds-02 py-ds-01 text-body-sm text-surface-fg placeholder:text-surface-fg-
|
|
317
|
+
className: "flex-1 resize-none bg-transparent px-ds-02 py-ds-01 text-body-sm text-surface-fg placeholder:text-surface-fg-muted focus:outline-hidden disabled:opacity-50",
|
|
302
318
|
style: { maxHeight: 160 }
|
|
303
319
|
}),
|
|
304
320
|
r ? /* @__PURE__ */ v(d, {
|
|
@@ -325,15 +341,15 @@ var B = Object.assign(A, {
|
|
|
325
341
|
c
|
|
326
342
|
]
|
|
327
343
|
}), l && /* @__PURE__ */ v("p", {
|
|
328
|
-
className: "mt-ds-02 text-center text-caption text-surface-fg-subtle
|
|
344
|
+
className: "mt-ds-02 text-center text-caption text-surface-fg-subtle",
|
|
329
345
|
children: l
|
|
330
346
|
})]
|
|
331
347
|
});
|
|
332
348
|
});
|
|
333
|
-
|
|
349
|
+
H.displayName = "MessageInput";
|
|
334
350
|
//#endregion
|
|
335
351
|
//#region src/ui/chat/message-list.tsx
|
|
336
|
-
var
|
|
352
|
+
var U = _.forwardRef(({ children: e, autoScroll: t = !0, newMessageCount: n = 0, onScrollToBottom: o, onLoadMore: s, loadingMore: c = !1, emptySlot: l, scrollToBottomSlot: u, headerSlot: d, className: f, ...p }, m) => {
|
|
337
353
|
let h = _.useRef(null), g = _.useRef(!0), [b, x] = _.useState(!0), S = _.useRef(!1), C = _.useRef(0), E = _.Children.count(e) === 0 && !c, D = _.useCallback(() => {
|
|
338
354
|
let e = h.current;
|
|
339
355
|
if (!e) return;
|
|
@@ -411,16 +427,16 @@ var H = _.forwardRef(({ children: e, autoScroll: t = !0, newMessageCount: n = 0,
|
|
|
411
427
|
]
|
|
412
428
|
});
|
|
413
429
|
});
|
|
414
|
-
|
|
430
|
+
U.displayName = "MessageList";
|
|
415
431
|
//#endregion
|
|
416
432
|
//#region src/ui/chat/system-message.tsx
|
|
417
|
-
function
|
|
433
|
+
function W(e) {
|
|
418
434
|
return new Date(e).toLocaleTimeString("en-US", {
|
|
419
435
|
hour: "numeric",
|
|
420
436
|
minute: "2-digit"
|
|
421
437
|
});
|
|
422
438
|
}
|
|
423
|
-
var
|
|
439
|
+
var G = _.forwardRef(({ icon: t, timestamp: n, variant: r = "event", children: a, className: s, ...c }, l) => r === "alert" ? /* @__PURE__ */ v("div", {
|
|
424
440
|
ref: l,
|
|
425
441
|
role: "alert",
|
|
426
442
|
className: i("flex justify-center", s),
|
|
@@ -438,13 +454,13 @@ var W = _.forwardRef(({ icon: t, timestamp: n, variant: r = "event", children: a
|
|
|
438
454
|
}),
|
|
439
455
|
n && /* @__PURE__ */ v("span", {
|
|
440
456
|
className: "text-body-sm text-error-11/60",
|
|
441
|
-
children:
|
|
457
|
+
children: W(n)
|
|
442
458
|
})
|
|
443
459
|
]
|
|
444
460
|
})
|
|
445
461
|
}) : /* @__PURE__ */ y("div", {
|
|
446
462
|
ref: l,
|
|
447
|
-
className: i("flex items-center gap-ds-02 rounded-control-inner bg-surface-
|
|
463
|
+
className: i("flex items-center gap-ds-02 rounded-control-inner bg-surface-panel-hover/30 px-ds-02 py-ds-01 -mx-ds-02 text-body-sm text-surface-fg-subtle", s),
|
|
448
464
|
...c,
|
|
449
465
|
children: [
|
|
450
466
|
/* @__PURE__ */ v(e, {
|
|
@@ -455,16 +471,16 @@ var W = _.forwardRef(({ icon: t, timestamp: n, variant: r = "event", children: a
|
|
|
455
471
|
className: "flex-1",
|
|
456
472
|
children: a
|
|
457
473
|
}),
|
|
458
|
-
n && /* @__PURE__ */ v("span", { children:
|
|
474
|
+
n && /* @__PURE__ */ v("span", { children: W(n) })
|
|
459
475
|
]
|
|
460
476
|
}));
|
|
461
|
-
|
|
477
|
+
G.displayName = "SystemMessage";
|
|
462
478
|
//#endregion
|
|
463
479
|
//#region src/ui/chat/typing-indicator.tsx
|
|
464
|
-
function
|
|
480
|
+
function K(e) {
|
|
465
481
|
return e.length === 1 ? `${e[0].name} is typing...` : e.length === 2 ? `${e[0].name} and ${e[1].name} are typing...` : "Several people are typing...";
|
|
466
482
|
}
|
|
467
|
-
function
|
|
483
|
+
function q({ users: e, className: t }) {
|
|
468
484
|
return /* @__PURE__ */ v("div", {
|
|
469
485
|
className: i("min-h-ds-06 px-ds-05", t),
|
|
470
486
|
role: "status",
|
|
@@ -493,14 +509,14 @@ function K({ users: e, className: t }) {
|
|
|
493
509
|
delay: e * .15
|
|
494
510
|
}
|
|
495
511
|
}, e))
|
|
496
|
-
}), /* @__PURE__ */ v("span", { children:
|
|
512
|
+
}), /* @__PURE__ */ v("span", { children: K(e) })]
|
|
497
513
|
}) })
|
|
498
514
|
});
|
|
499
515
|
}
|
|
500
|
-
|
|
516
|
+
q.displayName = "TypingIndicator";
|
|
501
517
|
//#endregion
|
|
502
518
|
//#region src/ui/chat/unread-separator.tsx
|
|
503
|
-
function
|
|
519
|
+
function J({ label: e = "NEW", count: t, className: n }) {
|
|
504
520
|
return /* @__PURE__ */ y("div", {
|
|
505
521
|
className: i("relative flex items-center py-ds-02", n),
|
|
506
522
|
children: [
|
|
@@ -513,6 +529,6 @@ function q({ label: e = "NEW", count: t, className: n }) {
|
|
|
513
529
|
]
|
|
514
530
|
});
|
|
515
531
|
}
|
|
516
|
-
|
|
532
|
+
J.displayName = "UnreadSeparator";
|
|
517
533
|
//#endregion
|
|
518
|
-
export {
|
|
534
|
+
export { O as DateSeparator, V as Message, H as MessageInput, U as MessageList, G as SystemMessage, q as TypingIndicator, J as UnreadSeparator, A as useMessageContext };
|