@fanvue/ui 2.13.0 → 2.14.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.
Files changed (42) hide show
  1. package/dist/cjs/components/ChatInput/ChatInput.cjs +75 -27
  2. package/dist/cjs/components/ChatInput/ChatInput.cjs.map +1 -1
  3. package/dist/cjs/components/CreatorCard/CreatorCard.cjs +81 -0
  4. package/dist/cjs/components/CreatorCard/CreatorCard.cjs.map +1 -0
  5. package/dist/cjs/components/CreatorCover/CreatorCover.cjs +83 -0
  6. package/dist/cjs/components/CreatorCover/CreatorCover.cjs.map +1 -0
  7. package/dist/cjs/components/CreatorTile/CreatorTile.cjs +64 -0
  8. package/dist/cjs/components/CreatorTile/CreatorTile.cjs.map +1 -0
  9. package/dist/cjs/components/CyclingText/CyclingText.cjs +137 -0
  10. package/dist/cjs/components/CyclingText/CyclingText.cjs.map +1 -0
  11. package/dist/cjs/components/CyclingText/useCyclingCycle.cjs +212 -0
  12. package/dist/cjs/components/CyclingText/useCyclingCycle.cjs.map +1 -0
  13. package/dist/cjs/components/CyclingText/useCyclingTextTrackWidth.cjs +55 -0
  14. package/dist/cjs/components/CyclingText/useCyclingTextTrackWidth.cjs.map +1 -0
  15. package/dist/cjs/components/CyclingText/usePageVisibility.cjs +38 -0
  16. package/dist/cjs/components/CyclingText/usePageVisibility.cjs.map +1 -0
  17. package/dist/cjs/components/CyclingText/usePrefersReducedMotion.cjs +39 -0
  18. package/dist/cjs/components/CyclingText/usePrefersReducedMotion.cjs.map +1 -0
  19. package/dist/cjs/index.cjs +8 -0
  20. package/dist/cjs/index.cjs.map +1 -1
  21. package/dist/components/ChatInput/ChatInput.mjs +75 -27
  22. package/dist/components/ChatInput/ChatInput.mjs.map +1 -1
  23. package/dist/components/CreatorCard/CreatorCard.mjs +64 -0
  24. package/dist/components/CreatorCard/CreatorCard.mjs.map +1 -0
  25. package/dist/components/CreatorCover/CreatorCover.mjs +66 -0
  26. package/dist/components/CreatorCover/CreatorCover.mjs.map +1 -0
  27. package/dist/components/CreatorTile/CreatorTile.mjs +47 -0
  28. package/dist/components/CreatorTile/CreatorTile.mjs.map +1 -0
  29. package/dist/components/CyclingText/CyclingText.mjs +120 -0
  30. package/dist/components/CyclingText/CyclingText.mjs.map +1 -0
  31. package/dist/components/CyclingText/useCyclingCycle.mjs +195 -0
  32. package/dist/components/CyclingText/useCyclingCycle.mjs.map +1 -0
  33. package/dist/components/CyclingText/useCyclingTextTrackWidth.mjs +38 -0
  34. package/dist/components/CyclingText/useCyclingTextTrackWidth.mjs.map +1 -0
  35. package/dist/components/CyclingText/usePageVisibility.mjs +21 -0
  36. package/dist/components/CyclingText/usePageVisibility.mjs.map +1 -0
  37. package/dist/components/CyclingText/usePrefersReducedMotion.mjs +22 -0
  38. package/dist/components/CyclingText/usePrefersReducedMotion.mjs.map +1 -0
  39. package/dist/index.d.ts +223 -0
  40. package/dist/index.mjs +8 -0
  41. package/dist/index.mjs.map +1 -1
  42. package/package.json +1 -1
@@ -6,11 +6,40 @@ import { IconButton } from "../IconButton/IconButton.mjs";
6
6
  import { AddIcon } from "../Icons/AddIcon.mjs";
7
7
  import { ArrowUpIcon } from "../Icons/ArrowUpIcon.mjs";
8
8
  import { ChevronDownIcon } from "../Icons/ChevronDownIcon.mjs";
9
+ import { CloseIcon } from "../Icons/CloseIcon.mjs";
9
10
  const LINE_HEIGHT = 18;
10
11
  const TEXTAREA_PY = 12;
11
12
  function calculateHeight(rows) {
12
13
  return LINE_HEIGHT * rows + TEXTAREA_PY * 2;
13
14
  }
15
+ function ChatInputDefaultAttachmentThumbnails({
16
+ attachments,
17
+ onAttachmentRemove,
18
+ disabled = false
19
+ }) {
20
+ return attachments.map((item) => /* @__PURE__ */ jsxs(
21
+ "div",
22
+ {
23
+ className: "relative size-16 shrink-0 overflow-hidden rounded-sm border border-neutral-200 bg-bg-secondary",
24
+ children: [
25
+ /* @__PURE__ */ jsx("img", { src: item.src, alt: "", className: "size-full object-cover" }),
26
+ /* @__PURE__ */ jsx(
27
+ IconButton,
28
+ {
29
+ variant: "tertiary",
30
+ size: "24",
31
+ "aria-label": item.ariaLabel ? `Remove ${item.ariaLabel}` : "Remove attachment",
32
+ icon: /* @__PURE__ */ jsx(CloseIcon, { className: "!size-3" }),
33
+ disabled: disabled || !onAttachmentRemove,
34
+ onClick: () => onAttachmentRemove?.(item.id),
35
+ className: "absolute top-0.5 right-0.5 size-5 bg-neutral-900/40 p-1 text-white hover:bg-neutral-900/55"
36
+ }
37
+ )
38
+ ]
39
+ },
40
+ item.id
41
+ ));
42
+ }
14
43
  const ChatInput = React.forwardRef(
15
44
  ({
16
45
  className,
@@ -35,6 +64,9 @@ const ChatInput = React.forwardRef(
35
64
  selectOptions,
36
65
  selectValue,
37
66
  onSelectChange,
67
+ attachments,
68
+ onAttachmentRemove,
69
+ attachmentPreviews,
38
70
  style,
39
71
  ...textareaProps
40
72
  }, ref) => {
@@ -89,6 +121,18 @@ const ChatInput = React.forwardRef(
89
121
  };
90
122
  const minHeight = calculateHeight(minRows);
91
123
  const maxHeight = calculateHeight(maxRows);
124
+ const useCustomAttachmentPreviews = attachmentPreviews !== void 0;
125
+ const customAttachmentStrip = useCustomAttachmentPreviews ? attachmentPreviews : null;
126
+ const defaultAttachmentStrip = !useCustomAttachmentPreviews && !!attachments?.length ? /* @__PURE__ */ jsx(
127
+ ChatInputDefaultAttachmentThumbnails,
128
+ {
129
+ attachments: attachments ?? [],
130
+ disabled,
131
+ onAttachmentRemove
132
+ }
133
+ ) : null;
134
+ const resolvedAttachmentStrip = customAttachmentStrip ?? defaultAttachmentStrip;
135
+ const hasAttachmentStrip = resolvedAttachmentStrip != null;
92
136
  const selectedOption = selectOptions?.find((o) => o.value === selectValue) ?? selectOptions?.[0];
93
137
  const resolvedToolbarRight = toolbarRight ?? (selectOptions && selectOptions.length > 0 ? /* @__PURE__ */ jsx(
94
138
  InlineSelect,
@@ -105,39 +149,43 @@ const ChatInput = React.forwardRef(
105
149
  {
106
150
  className: cn(
107
151
  "relative flex flex-col gap-6 rounded-lg border border-border-primary bg-surface-primary",
108
- "has-focus-visible:border-neutral-alphas-400 has-focus-visible:outline-none",
152
+ "has-focus-visible:outline-none",
109
153
  "motion-safe:transition-colors",
110
154
  disabled && "opacity-50",
111
155
  className
112
156
  ),
113
157
  children: [
114
- /* @__PURE__ */ jsx(
115
- "textarea",
116
- {
117
- ...textareaProps,
118
- ref: mergedRef,
119
- value: isControlled ? value : internalValue,
120
- placeholder,
121
- maxLength,
122
- disabled,
123
- "aria-label": ariaLabel ?? placeholder,
124
- onChange: handleChange,
125
- onKeyDown: handleKeyDown,
126
- rows: minRows,
127
- className: cn(
128
- "w-full resize-none bg-transparent px-4 pt-4",
129
- "typography-regular-body-md text-content-primary",
130
- "placeholder:text-content-tertiary",
131
- "focus:outline-none disabled:cursor-not-allowed",
132
- "overflow-y-auto"
133
- ),
134
- style: {
135
- minHeight: `${minHeight}px`,
136
- maxHeight: `${maxHeight}px`,
137
- ...style
158
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
159
+ hasAttachmentStrip ? /* @__PURE__ */ jsx("div", { className: "flex gap-2 overflow-x-auto px-4 pt-4 pb-2 [scrollbar-width:thin]", children: resolvedAttachmentStrip }) : null,
160
+ /* @__PURE__ */ jsx(
161
+ "textarea",
162
+ {
163
+ ...textareaProps,
164
+ ref: mergedRef,
165
+ value: isControlled ? value : internalValue,
166
+ placeholder,
167
+ maxLength,
168
+ disabled,
169
+ "aria-label": ariaLabel ?? placeholder,
170
+ onChange: handleChange,
171
+ onKeyDown: handleKeyDown,
172
+ rows: minRows,
173
+ className: cn(
174
+ "w-full resize-none bg-transparent px-4",
175
+ hasAttachmentStrip ? "pt-0" : "pt-4",
176
+ "typography-regular-body-md text-content-primary",
177
+ "placeholder:text-content-tertiary",
178
+ "focus:outline-none disabled:cursor-not-allowed",
179
+ "overflow-y-auto"
180
+ ),
181
+ style: {
182
+ minHeight: `${minHeight}px`,
183
+ maxHeight: `${maxHeight}px`,
184
+ ...style
185
+ }
138
186
  }
139
- }
140
- ),
187
+ )
188
+ ] }),
141
189
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 px-4 pb-4", children: [
142
190
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", children: showFileButton && /* @__PURE__ */ jsx(
143
191
  IconButton,
@@ -1 +1 @@
1
- {"version":3,"file":"ChatInput.mjs","sources":["../../../src/components/ChatInput/ChatInput.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { AddIcon } from \"../Icons/AddIcon\";\nimport { ArrowUpIcon } from \"../Icons/ArrowUpIcon\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\n\n/** A single option for the inline model/dropdown selector. */\nexport interface ChatInputSelectOption {\n /** Unique value for this option. */\n value: string;\n /** Display label. */\n label: string;\n /** Optional icon rendered to the left of the label. */\n icon?: React.ReactNode;\n}\n\n/**\n * Props for {@link ChatInput}. Standard textarea HTML attributes are forwarded to the inner\n * `<textarea>` except `className` (applied to the outer container), `rows` (use `minRows`), and\n * `onSubmit` (replaced by the chat message submit callback).\n */\nexport interface ChatInputProps\n extends Omit<\n React.TextareaHTMLAttributes<HTMLTextAreaElement>,\n \"className\" | \"rows\" | \"onSubmit\"\n > {\n /** Minimum number of visible rows. @default 1 */\n minRows?: number;\n /** Maximum number of visible rows before scrolling. @default 6 */\n maxRows?: number;\n /** Whether a submission is in progress (disables submit, shows visual feedback). @default false */\n loading?: boolean;\n /**\n * Callback fired when the user submits (clicks the send button or presses Enter without Shift).\n * Receives the current trimmed text value.\n */\n onSubmit?: (value: string) => void;\n /**\n * When `true`, renders an \"attach file\" button in the bottom-left toolbar.\n * @default false\n */\n showFileButton?: boolean;\n /** Callback fired when the attach-file button is clicked. Only relevant when `showFileButton` is `true`. */\n onFileClick?: () => void;\n /** Accessible label for the attach-file button. @default \"Attach file\" */\n fileButtonAriaLabel?: string;\n /** Accessible label for the submit button. @default \"Send message\" */\n submitAriaLabel?: string;\n /** Icon element for the submit button. @default `<ArrowUpIcon />` */\n submitIcon?: React.ReactNode;\n /**\n * Optional content rendered in the bottom-right toolbar, to the left of the submit button.\n * When provided, takes precedence over the built-in `selectOptions` dropdown.\n */\n toolbarRight?: React.ReactNode;\n /**\n * Options for the built-in inline dropdown selector (e.g. model picker).\n * Ignored when `toolbarRight` is provided.\n */\n selectOptions?: ChatInputSelectOption[];\n /** Currently selected value for the built-in dropdown. Should match one of `selectOptions[].value`. */\n selectValue?: string;\n /** Callback fired when the user picks a different dropdown option. */\n onSelectChange?: (value: string) => void;\n /** Additional className applied to the outermost container. */\n className?: string;\n}\n\nconst LINE_HEIGHT = 18;\nconst TEXTAREA_PY = 12;\n\nfunction calculateHeight(rows: number): number {\n return LINE_HEIGHT * rows + TEXTAREA_PY * 2;\n}\n\n/**\n * A chat-style multi-line input with an integrated toolbar containing an\n * optional file-attach button, optional right-side controls (e.g. a model\n * selector), and a submit button — all inside a single bordered container.\n *\n * Designed to behave like modern AI chat inputs: auto-grows with content,\n * submits on Enter (Shift+Enter for newlines), and keeps controls inline.\n *\n * @example\n * ```tsx\n * <ChatInput\n * placeholder=\"Type a message...\"\n * onSubmit={(text) => send(text)}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <ChatInput\n * placeholder=\"Ask the agent...\"\n * showFileButton\n * onFileClick={() => openFilePicker()}\n * selectOptions={[\n * { value: \"fanvue-ai\", label: \"Fanvue AI\", icon: <AIIcon className=\"size-4\" /> },\n * { value: \"example\", label: \"Example\", icon: <BulbIcon className=\"size-4\" /> },\n * ]}\n * selectValue=\"fanvue-ai\"\n * onSelectChange={(v) => setModel(v)}\n * onSubmit={(text) => send(text)}\n * />\n * ```\n */\nexport const ChatInput = React.forwardRef<HTMLTextAreaElement, ChatInputProps>(\n (\n {\n className,\n minRows = 1,\n maxRows = 6,\n disabled = false,\n loading = false,\n value,\n defaultValue,\n placeholder,\n maxLength,\n \"aria-label\": ariaLabel,\n onChange,\n onKeyDown,\n onSubmit,\n showFileButton = false,\n onFileClick,\n fileButtonAriaLabel = \"Attach file\",\n submitAriaLabel = \"Send message\",\n submitIcon,\n toolbarRight,\n selectOptions,\n selectValue,\n onSelectChange,\n style,\n ...textareaProps\n },\n ref,\n ) => {\n const internalRef = React.useRef<HTMLTextAreaElement>(null);\n const [internalValue, setInternalValue] = React.useState(defaultValue ?? \"\");\n const resolvedValue = value !== undefined ? value : internalValue;\n const isControlled = value !== undefined;\n\n const mergedRef = React.useCallback(\n (node: HTMLTextAreaElement | null) => {\n (internalRef as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n }\n },\n [ref],\n );\n\n const adjustHeight = React.useCallback(() => {\n const textarea = internalRef.current;\n if (!textarea) return;\n\n const minHeight = calculateHeight(minRows);\n const maxHeight = calculateHeight(maxRows);\n\n textarea.style.height = `${minHeight}px`;\n const desired = Math.min(Math.max(textarea.scrollHeight, minHeight), maxHeight);\n textarea.style.height = `${desired}px`;\n }, [minRows, maxRows]);\n\n React.useEffect(() => {\n adjustHeight();\n }, [resolvedValue, adjustHeight]);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (!isControlled) {\n setInternalValue(e.target.value);\n }\n onChange?.(e);\n };\n\n const canSubmit = !!String(resolvedValue).trim() && !disabled && !loading;\n\n const handleSubmit = () => {\n const text = String(resolvedValue).trim();\n if (!text || !canSubmit) return;\n onSubmit?.(text);\n if (!isControlled) {\n setInternalValue(\"\");\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n onKeyDown?.(e);\n };\n\n const minHeight = calculateHeight(minRows);\n const maxHeight = calculateHeight(maxRows);\n\n const selectedOption =\n selectOptions?.find((o) => o.value === selectValue) ?? selectOptions?.[0];\n const resolvedToolbarRight =\n toolbarRight ??\n (selectOptions && selectOptions.length > 0 ? (\n <InlineSelect\n options={selectOptions}\n value={selectValue}\n onChange={onSelectChange}\n disabled={disabled}\n selectedOption={selectedOption}\n />\n ) : null);\n\n return (\n <div\n className={cn(\n \"relative flex flex-col gap-6 rounded-lg border border-border-primary bg-surface-primary\",\n \"has-focus-visible:border-neutral-alphas-400 has-focus-visible:outline-none\",\n \"motion-safe:transition-colors\",\n disabled && \"opacity-50\",\n className,\n )}\n >\n <textarea\n {...textareaProps}\n ref={mergedRef}\n value={isControlled ? value : internalValue}\n placeholder={placeholder}\n maxLength={maxLength}\n disabled={disabled}\n aria-label={ariaLabel ?? placeholder}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n rows={minRows}\n className={cn(\n \"w-full resize-none bg-transparent px-4 pt-4\",\n \"typography-regular-body-md text-content-primary\",\n \"placeholder:text-content-tertiary\",\n \"focus:outline-none disabled:cursor-not-allowed\",\n \"overflow-y-auto\",\n )}\n style={{\n minHeight: `${minHeight}px`,\n maxHeight: `${maxHeight}px`,\n ...style,\n }}\n />\n\n <div className=\"flex items-center justify-between gap-2 px-4 pb-4\">\n <div className=\"flex items-center gap-1\">\n {showFileButton && (\n <IconButton\n variant=\"tertiary\"\n size=\"32\"\n icon={<AddIcon />}\n aria-label={fileButtonAriaLabel}\n onClick={onFileClick}\n disabled={disabled}\n className=\"sm:border sm:border-border-primary max-sm:-ml-2\"\n />\n )}\n </div>\n\n <div className=\"flex items-center gap-1\">\n {resolvedToolbarRight}\n <IconButton\n variant=\"primary\"\n size=\"32\"\n icon={submitIcon ?? <ArrowUpIcon />}\n aria-label={submitAriaLabel}\n onClick={handleSubmit}\n disabled={!canSubmit}\n className=\"disabled:bg-surface-secondary disabled:opacity-100 disabled:text-icons-primary\"\n />\n </div>\n </div>\n </div>\n );\n },\n);\n\nChatInput.displayName = \"ChatInput\";\n\ninterface InlineSelectProps {\n options: ChatInputSelectOption[];\n value?: string;\n onChange?: (value: string) => void;\n disabled?: boolean;\n selectedOption?: ChatInputSelectOption;\n}\n\nfunction InlineSelect({ options, value, onChange, disabled, selectedOption }: InlineSelectProps) {\n const [open, setOpen] = React.useState(false);\n const containerRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n if (!open) return;\n const handleClick = (e: MouseEvent) => {\n if (containerRef.current && !containerRef.current.contains(e.target as Node)) {\n setOpen(false);\n }\n };\n document.addEventListener(\"mousedown\", handleClick);\n return () => document.removeEventListener(\"mousedown\", handleClick);\n }, [open]);\n\n React.useEffect(() => {\n if (!open) return;\n const handleKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") setOpen(false);\n };\n document.addEventListener(\"keydown\", handleKey);\n return () => document.removeEventListener(\"keydown\", handleKey);\n }, [open]);\n\n return (\n <div ref={containerRef} className=\"relative\">\n <button\n type=\"button\"\n role=\"combobox\"\n aria-expanded={open}\n aria-haspopup=\"listbox\"\n aria-label=\"Select model\"\n disabled={disabled}\n onClick={() => setOpen((prev) => !prev)}\n className={cn(\n \"typography-semibold-body-sm text-content-primary\",\n \"flex items-center gap-1 rounded-md px-2 py-2\",\n \"hover:bg-neutral-alphas-50 focus-visible:shadow-focus-ring focus-visible:outline-none\",\n \"disabled:cursor-not-allowed disabled:opacity-50\",\n \"motion-safe:transition-colors\",\n )}\n >\n {selectedOption?.icon && (\n <span className=\"flex shrink-0 items-center [&>svg]:size-4\">{selectedOption.icon}</span>\n )}\n {selectedOption?.label ?? options[0]?.label ?? \"Select\"}\n <ChevronDownIcon\n className={cn(\"size-4 motion-safe:transition-transform\", open && \"rotate-180\")}\n />\n </button>\n\n {open && (\n <div\n role=\"listbox\"\n className={cn(\n \"absolute right-0 bottom-full z-10 mb-1 min-w-[140px]\",\n \"overflow-hidden rounded-xs border border-border-primary bg-surface-primary p-1 shadow-lg\",\n )}\n >\n {options.map((option) => (\n <div\n key={option.value}\n role=\"option\"\n tabIndex={0}\n aria-selected={option.value === value}\n className={cn(\n \"typography-regular-body-md flex cursor-pointer items-center gap-2 rounded-xs px-3 py-1.5\",\n \"text-content-primary hover:bg-neutral-alphas-50\",\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n option.value === value && \"bg-neutral-alphas-50\",\n )}\n onClick={() => {\n onChange?.(option.value);\n setOpen(false);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n onChange?.(option.value);\n setOpen(false);\n }\n }}\n >\n {option.icon && (\n <span className=\"flex shrink-0 items-center [&>svg]:size-4\">{option.icon}</span>\n )}\n {option.label}\n </div>\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"names":["minHeight","maxHeight"],"mappings":";;;;;;;;AAqEA,MAAM,cAAc;AACpB,MAAM,cAAc;AAEpB,SAAS,gBAAgB,MAAsB;AAC7C,SAAO,cAAc,OAAO,cAAc;AAC5C;AAkCO,MAAM,YAAY,MAAM;AAAA,EAC7B,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA,sBAAsB;AAAA,IACtB,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,cAAc,MAAM,OAA4B,IAAI;AAC1D,UAAM,CAAC,eAAe,gBAAgB,IAAI,MAAM,SAAS,gBAAgB,EAAE;AAC3E,UAAM,gBAAgB,UAAU,SAAY,QAAQ;AACpD,UAAM,eAAe,UAAU;AAE/B,UAAM,YAAY,MAAM;AAAA,MACtB,CAAC,SAAqC;AACnC,oBAAmE,UAAU;AAC9E,YA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,UACT;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,QAGD,UAAA;AAAA,UAAA,gBAAgB,QACf,oBAAC,QAAA,EAAK,WAAU,6CAA6C,yBAAe,MAAK;AAAA,UAElF,gBAAgB,SAAS,QAAQ,CAAC,GAAG,SAAS;AAAA,UAC/C;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,GAAG,2CAA2C,QAAQ,YAAY;AAAA,YAAA;AAAA,UAAA;AAAA,QAC/E;AAAA,MAAA;AAAA,IAAA;AAAA,IAGD,QACC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QAAA;AAAA,QAGD,UAAA,QAAQ,IAAI,CAAC,WACZ;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,MAAK;AAAA,YACL,UAAU;AAAA,YACV,iBAAe,OAAO,UAAU;AAAA,YAChC,WAAW;AAAA,cACT;AAAA,cACA;AAAA,cACA;AAAA,cACA,OAAO,UAAU,SAAS;AAAA,YAAA;AAAA,YAE5B,SAAS,MAAM;AACb,yBAAW,OAAO,KAAK;AACvB,sBAAQ,KAAK;AAAA,YACf;AAAA,YACA,WAAW,CAAC,MAAM;AAChB,kBAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;AACtC,kBAAE,eAAA;AACF,2BAAW,OAAO,KAAK;AACvB,wBAAQ,KAAK;AAAA,cACf;AAAA,YACF;AAAA,YAEC,UAAA;AAAA,cAAA,OAAO,QACN,oBAAC,QAAA,EAAK,WAAU,6CAA6C,iBAAO,MAAK;AAAA,cAE1E,OAAO;AAAA,YAAA;AAAA,UAAA;AAAA,UAzBH,OAAO;AAAA,QAAA,CA2Bf;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"ChatInput.mjs","sources":["../../../src/components/ChatInput/ChatInput.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { AddIcon } from \"../Icons/AddIcon\";\nimport { ArrowUpIcon } from \"../Icons/ArrowUpIcon\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\n\n/** A single image thumbnail in the built-in attachment strip. */\nexport interface ChatInputAttachmentItem {\n /** Stable id passed to {@link ChatInputProps.onAttachmentRemove} and used as React `key`. */\n id: string;\n /** Image URL for the thumbnail. */\n src: string;\n /** Optional value passed to the remove control `aria-label`. */\n ariaLabel?: string;\n}\n\n/** A single option for the inline model/dropdown selector. */\nexport interface ChatInputSelectOption {\n /** Unique value for this option. */\n value: string;\n /** Display label. */\n label: string;\n /** Optional icon rendered to the left of the label. */\n icon?: React.ReactNode;\n}\n\n/**\n * Props for {@link ChatInput}. Standard textarea HTML attributes are forwarded to the inner\n * `<textarea>` except `className` (applied to the outer container), `rows` (use `minRows`), and\n * `onSubmit` (replaced by the chat message submit callback).\n */\nexport interface ChatInputProps\n extends Omit<\n React.TextareaHTMLAttributes<HTMLTextAreaElement>,\n \"className\" | \"rows\" | \"onSubmit\"\n > {\n /** Minimum number of visible rows. @default 1 */\n minRows?: number;\n /** Maximum number of visible rows before scrolling. @default 6 */\n maxRows?: number;\n /** Whether a submission is in progress (disables submit, shows visual feedback). @default false */\n loading?: boolean;\n /**\n * Callback fired when the user submits (clicks the send button or presses Enter without Shift).\n * Receives the current trimmed text value.\n */\n onSubmit?: (value: string) => void;\n /**\n * When `true`, renders an \"attach file\" button in the bottom-left toolbar.\n * @default false\n */\n showFileButton?: boolean;\n /** Callback fired when the attach-file button is clicked. Only relevant when `showFileButton` is `true`. */\n onFileClick?: () => void;\n /** Accessible label for the attach-file button. @default \"Attach file\" */\n fileButtonAriaLabel?: string;\n /** Accessible label for the submit button. @default \"Send message\" */\n submitAriaLabel?: string;\n /** Icon element for the submit button. @default `<ArrowUpIcon />` */\n submitIcon?: React.ReactNode;\n /**\n * Optional content rendered in the bottom-right toolbar, to the left of the submit button.\n * When provided, takes precedence over the built-in `selectOptions` dropdown.\n */\n toolbarRight?: React.ReactNode;\n /**\n * Options for the built-in inline dropdown selector (e.g. model picker).\n * Ignored when `toolbarRight` is provided.\n */\n selectOptions?: ChatInputSelectOption[];\n /** Currently selected value for the built-in dropdown. Should match one of `selectOptions[].value`. */\n selectValue?: string;\n /** Callback fired when the user picks a different dropdown option. */\n onSelectChange?: (value: string) => void;\n /**\n * Image attachments shown in the built-in thumbnail strip. Ignored when {@link ChatInputProps.attachmentPreviews}\n * is provided (including `null`).\n */\n attachments?: ChatInputAttachmentItem[];\n /**\n * Called when the user removes a built-in thumbnail. The remove button is disabled when this is\n * omitted or the input is {@link ChatInputProps.disabled}.\n */\n onAttachmentRemove?: (id: string) => void;\n /**\n * Replaces the built-in attachment strip entirely. When set to any value other than `undefined`\n * (including `null` or `[]`), {@link ChatInputProps.attachments} is ignored.\n */\n attachmentPreviews?: React.ReactNode;\n /** Additional className applied to the outermost container. */\n className?: string;\n}\n\nconst LINE_HEIGHT = 18;\nconst TEXTAREA_PY = 12;\n\nfunction calculateHeight(rows: number): number {\n return LINE_HEIGHT * rows + TEXTAREA_PY * 2;\n}\n\ninterface ChatInputDefaultAttachmentThumbnailsProps {\n attachments: ChatInputAttachmentItem[];\n onAttachmentRemove?: (id: string) => void;\n disabled?: boolean;\n}\n\nfunction ChatInputDefaultAttachmentThumbnails({\n attachments,\n onAttachmentRemove,\n disabled = false,\n}: ChatInputDefaultAttachmentThumbnailsProps) {\n return attachments.map((item) => (\n <div\n key={item.id}\n className=\"relative size-16 shrink-0 overflow-hidden rounded-sm border border-neutral-200 bg-bg-secondary\"\n >\n <img src={item.src} alt=\"\" className=\"size-full object-cover\" />\n <IconButton\n variant=\"tertiary\"\n size=\"24\"\n aria-label={item.ariaLabel ? `Remove ${item.ariaLabel}` : \"Remove attachment\"}\n icon={<CloseIcon className=\"!size-3\" />}\n disabled={disabled || !onAttachmentRemove}\n onClick={() => onAttachmentRemove?.(item.id)}\n className=\"absolute top-0.5 right-0.5 size-5 bg-neutral-900/40 p-1 text-white hover:bg-neutral-900/55\"\n />\n </div>\n ));\n}\n\n/**\n * A chat-style multi-line input with an integrated toolbar containing an\n * optional file-attach button, optional right-side controls (e.g. a model\n * selector), and a submit button — all inside a single bordered container.\n *\n * Designed to behave like modern AI chat inputs: auto-grows with content,\n * submits on Enter (Shift+Enter for newlines), and keeps controls inline.\n *\n * @example\n * ```tsx\n * <ChatInput\n * placeholder=\"Type a message...\"\n * onSubmit={(text) => send(text)}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <ChatInput\n * placeholder=\"Ask the agent...\"\n * showFileButton\n * onFileClick={() => openFilePicker()}\n * selectOptions={[\n * { value: \"fanvue-ai\", label: \"Fanvue AI\", icon: <AIIcon className=\"size-4\" /> },\n * { value: \"example\", label: \"Example\", icon: <BulbIcon className=\"size-4\" /> },\n * ]}\n * selectValue=\"fanvue-ai\"\n * onSelectChange={(v) => setModel(v)}\n * onSubmit={(text) => send(text)}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <ChatInput\n * showFileButton\n * onFileClick={() => openPicker()}\n * attachments={files}\n * onAttachmentRemove={(id) => setFiles((prev) => prev.filter((f) => f.id !== id))}\n * />\n * ```\n *\n * @example\n * ```tsx\n * <ChatInput\n * showFileButton\n * onFileClick={() => openPicker()}\n * attachmentPreviews={<CustomVideoStrip items={items} />}\n * />\n * ```\n */\nexport const ChatInput = React.forwardRef<HTMLTextAreaElement, ChatInputProps>(\n (\n {\n className,\n minRows = 1,\n maxRows = 6,\n disabled = false,\n loading = false,\n value,\n defaultValue,\n placeholder,\n maxLength,\n \"aria-label\": ariaLabel,\n onChange,\n onKeyDown,\n onSubmit,\n showFileButton = false,\n onFileClick,\n fileButtonAriaLabel = \"Attach file\",\n submitAriaLabel = \"Send message\",\n submitIcon,\n toolbarRight,\n selectOptions,\n selectValue,\n onSelectChange,\n attachments,\n onAttachmentRemove,\n attachmentPreviews,\n style,\n ...textareaProps\n },\n ref,\n ) => {\n const internalRef = React.useRef<HTMLTextAreaElement>(null);\n const [internalValue, setInternalValue] = React.useState(defaultValue ?? \"\");\n const resolvedValue = value !== undefined ? value : internalValue;\n const isControlled = value !== undefined;\n\n const mergedRef = React.useCallback(\n (node: HTMLTextAreaElement | null) => {\n (internalRef as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n (ref as React.MutableRefObject<HTMLTextAreaElement | null>).current = node;\n }\n },\n [ref],\n );\n\n const adjustHeight = React.useCallback(() => {\n const textarea = internalRef.current;\n if (!textarea) return;\n\n const minHeight = calculateHeight(minRows);\n const maxHeight = calculateHeight(maxRows);\n\n textarea.style.height = `${minHeight}px`;\n const desired = Math.min(Math.max(textarea.scrollHeight, minHeight), maxHeight);\n textarea.style.height = `${desired}px`;\n }, [minRows, maxRows]);\n\n React.useEffect(() => {\n adjustHeight();\n }, [resolvedValue, adjustHeight]);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n if (!isControlled) {\n setInternalValue(e.target.value);\n }\n onChange?.(e);\n };\n\n const canSubmit = !!String(resolvedValue).trim() && !disabled && !loading;\n\n const handleSubmit = () => {\n const text = String(resolvedValue).trim();\n if (!text || !canSubmit) return;\n onSubmit?.(text);\n if (!isControlled) {\n setInternalValue(\"\");\n }\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n handleSubmit();\n }\n onKeyDown?.(e);\n };\n\n const minHeight = calculateHeight(minRows);\n const maxHeight = calculateHeight(maxRows);\n\n const useCustomAttachmentPreviews = attachmentPreviews !== undefined;\n const customAttachmentStrip = useCustomAttachmentPreviews ? attachmentPreviews : null;\n const defaultAttachmentStrip =\n !useCustomAttachmentPreviews && !!attachments?.length ? (\n <ChatInputDefaultAttachmentThumbnails\n attachments={attachments ?? []}\n disabled={disabled}\n onAttachmentRemove={onAttachmentRemove}\n />\n ) : null;\n const resolvedAttachmentStrip = customAttachmentStrip ?? defaultAttachmentStrip;\n const hasAttachmentStrip = resolvedAttachmentStrip != null;\n\n const selectedOption =\n selectOptions?.find((o) => o.value === selectValue) ?? selectOptions?.[0];\n const resolvedToolbarRight =\n toolbarRight ??\n (selectOptions && selectOptions.length > 0 ? (\n <InlineSelect\n options={selectOptions}\n value={selectValue}\n onChange={onSelectChange}\n disabled={disabled}\n selectedOption={selectedOption}\n />\n ) : null);\n\n return (\n <div\n className={cn(\n \"relative flex flex-col gap-6 rounded-lg border border-border-primary bg-surface-primary\",\n \"has-focus-visible:outline-none\",\n \"motion-safe:transition-colors\",\n disabled && \"opacity-50\",\n className,\n )}\n >\n <div className=\"flex flex-col\">\n {hasAttachmentStrip ? (\n <div className=\"flex gap-2 overflow-x-auto px-4 pt-4 pb-2 [scrollbar-width:thin]\">\n {resolvedAttachmentStrip}\n </div>\n ) : null}\n <textarea\n {...textareaProps}\n ref={mergedRef}\n value={isControlled ? value : internalValue}\n placeholder={placeholder}\n maxLength={maxLength}\n disabled={disabled}\n aria-label={ariaLabel ?? placeholder}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n rows={minRows}\n className={cn(\n \"w-full resize-none bg-transparent px-4\",\n hasAttachmentStrip ? \"pt-0\" : \"pt-4\",\n \"typography-regular-body-md text-content-primary\",\n \"placeholder:text-content-tertiary\",\n \"focus:outline-none disabled:cursor-not-allowed\",\n \"overflow-y-auto\",\n )}\n style={{\n minHeight: `${minHeight}px`,\n maxHeight: `${maxHeight}px`,\n ...style,\n }}\n />\n </div>\n\n <div className=\"flex items-center justify-between gap-2 px-4 pb-4\">\n <div className=\"flex items-center gap-1\">\n {showFileButton && (\n <IconButton\n variant=\"tertiary\"\n size=\"32\"\n icon={<AddIcon />}\n aria-label={fileButtonAriaLabel}\n onClick={onFileClick}\n disabled={disabled}\n className=\"sm:border sm:border-border-primary max-sm:-ml-2\"\n />\n )}\n </div>\n\n <div className=\"flex items-center gap-1\">\n {resolvedToolbarRight}\n <IconButton\n variant=\"primary\"\n size=\"32\"\n icon={submitIcon ?? <ArrowUpIcon />}\n aria-label={submitAriaLabel}\n onClick={handleSubmit}\n disabled={!canSubmit}\n className=\"disabled:bg-surface-secondary disabled:opacity-100 disabled:text-icons-primary\"\n />\n </div>\n </div>\n </div>\n );\n },\n);\n\nChatInput.displayName = \"ChatInput\";\n\ninterface InlineSelectProps {\n options: ChatInputSelectOption[];\n value?: string;\n onChange?: (value: string) => void;\n disabled?: boolean;\n selectedOption?: ChatInputSelectOption;\n}\n\nfunction InlineSelect({ options, value, onChange, disabled, selectedOption }: InlineSelectProps) {\n const [open, setOpen] = React.useState(false);\n const containerRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n if (!open) return;\n const handleClick = (e: MouseEvent) => {\n if (containerRef.current && !containerRef.current.contains(e.target as Node)) {\n setOpen(false);\n }\n };\n document.addEventListener(\"mousedown\", handleClick);\n return () => document.removeEventListener(\"mousedown\", handleClick);\n }, [open]);\n\n React.useEffect(() => {\n if (!open) return;\n const handleKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") setOpen(false);\n };\n document.addEventListener(\"keydown\", handleKey);\n return () => document.removeEventListener(\"keydown\", handleKey);\n }, [open]);\n\n return (\n <div ref={containerRef} className=\"relative\">\n <button\n type=\"button\"\n role=\"combobox\"\n aria-expanded={open}\n aria-haspopup=\"listbox\"\n aria-label=\"Select model\"\n disabled={disabled}\n onClick={() => setOpen((prev) => !prev)}\n className={cn(\n \"typography-semibold-body-sm text-content-primary\",\n \"flex items-center gap-1 rounded-md px-2 py-2\",\n \"hover:bg-neutral-alphas-50 focus-visible:shadow-focus-ring focus-visible:outline-none\",\n \"disabled:cursor-not-allowed disabled:opacity-50\",\n \"motion-safe:transition-colors\",\n )}\n >\n {selectedOption?.icon && (\n <span className=\"flex shrink-0 items-center [&>svg]:size-4\">{selectedOption.icon}</span>\n )}\n {selectedOption?.label ?? options[0]?.label ?? \"Select\"}\n <ChevronDownIcon\n className={cn(\"size-4 motion-safe:transition-transform\", open && \"rotate-180\")}\n />\n </button>\n\n {open && (\n <div\n role=\"listbox\"\n className={cn(\n \"absolute right-0 bottom-full z-10 mb-1 min-w-[140px]\",\n \"overflow-hidden rounded-xs border border-border-primary bg-surface-primary p-1 shadow-lg\",\n )}\n >\n {options.map((option) => (\n <div\n key={option.value}\n role=\"option\"\n tabIndex={0}\n aria-selected={option.value === value}\n className={cn(\n \"typography-regular-body-md flex cursor-pointer items-center gap-2 rounded-xs px-3 py-1.5\",\n \"text-content-primary hover:bg-neutral-alphas-50\",\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n option.value === value && \"bg-neutral-alphas-50\",\n )}\n onClick={() => {\n onChange?.(option.value);\n setOpen(false);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n onChange?.(option.value);\n setOpen(false);\n }\n }}\n >\n {option.icon && (\n <span className=\"flex shrink-0 items-center [&>svg]:size-4\">{option.icon}</span>\n )}\n {option.label}\n </div>\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"names":["minHeight","maxHeight"],"mappings":";;;;;;;;;AA+FA,MAAM,cAAc;AACpB,MAAM,cAAc;AAEpB,SAAS,gBAAgB,MAAsB;AAC7C,SAAO,cAAc,OAAO,cAAc;AAC5C;AAQA,SAAS,qCAAqC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA,WAAW;AACb,GAA8C;AAC5C,SAAO,YAAY,IAAI,CAAC,SACtB;AAAA,IAAC;AAAA,IAAA;AAAA,MAEC,WAAU;AAAA,MAEV,UAAA;AAAA,QAAA,oBAAC,SAAI,KAAK,KAAK,KAAK,KAAI,IAAG,WAAU,0BAAyB;AAAA,QAC9D;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,cAAY,K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A;AAAA,UAzBH,OAAO;AAAA,QAAA,CA2Bf;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GAEJ;AAEJ;"}
@@ -0,0 +1,64 @@
1
+ "use client";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../../utils/cn.mjs";
5
+ import { Avatar } from "../Avatar/Avatar.mjs";
6
+ const CreatorCard = React.forwardRef(
7
+ ({ className, imageSrc, imageAlt = "", name, description, avatar, actions, ...props }, ref) => {
8
+ return /* @__PURE__ */ jsxs(
9
+ "div",
10
+ {
11
+ ref,
12
+ className: cn(
13
+ "relative isolate flex aspect-290/450 max-w-full flex-col justify-end overflow-hidden bg-bg-primary",
14
+ className
15
+ ),
16
+ ...props,
17
+ children: [
18
+ /* @__PURE__ */ jsx(
19
+ "img",
20
+ {
21
+ src: imageSrc,
22
+ alt: imageAlt,
23
+ loading: "lazy",
24
+ className: "absolute inset-0 size-full object-cover"
25
+ }
26
+ ),
27
+ /* @__PURE__ */ jsx(
28
+ "div",
29
+ {
30
+ className: cn(
31
+ "pointer-events-none absolute inset-x-0 bottom-0 bg-linear-to-t from-bg-primary via-bg-primary/90 to-transparent",
32
+ actions ? "h-3/5" : "h-1/3"
33
+ )
34
+ }
35
+ ),
36
+ /* @__PURE__ */ jsxs("div", { className: "relative flex flex-col gap-4 p-4", children: [
37
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
38
+ /* @__PURE__ */ jsx(
39
+ Avatar,
40
+ {
41
+ size: 48,
42
+ src: avatar?.src,
43
+ alt: avatar?.alt ?? name,
44
+ fallback: avatar?.fallback,
45
+ ...avatar
46
+ }
47
+ ),
48
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
49
+ /* @__PURE__ */ jsx("p", { className: "typography-bold-heading-sm truncate text-content-primary", children: name }),
50
+ description && /* @__PURE__ */ jsx("p", { className: "typography-semibold-body-sm truncate text-content-secondary dark:text-brand-primary-default", children: description })
51
+ ] })
52
+ ] }),
53
+ actions && /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: actions })
54
+ ] })
55
+ ]
56
+ }
57
+ );
58
+ }
59
+ );
60
+ CreatorCard.displayName = "CreatorCard";
61
+ export {
62
+ CreatorCard
63
+ };
64
+ //# sourceMappingURL=CreatorCard.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreatorCard.mjs","sources":["../../../src/components/CreatorCard/CreatorCard.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Avatar } from \"../Avatar/Avatar\";\n\nexport interface CreatorCardProps extends React.HTMLAttributes<HTMLDivElement> {\n /** URL of the background media (image or video poster). */\n imageSrc: string;\n /** Alt text for the background image. @default \"\" */\n imageAlt?: string;\n /** Creator display name shown as the heading. */\n name: string;\n /** Optional secondary line shown below the name (e.g. role or tagline). */\n description?: string;\n /** Avatar props forwarded to the inner {@link Avatar}. */\n avatar?: React.ComponentPropsWithoutRef<typeof Avatar>;\n /**\n * Action buttons rendered at the bottom of the card. Pass zero, one, or two\n * `Button` elements to render variants with no, one, or two CTAs.\n */\n actions?: React.ReactNode;\n}\n\n/**\n * A portrait media card highlighting a creator with avatar, name, optional\n * tagline, and up to two stacked action buttons over a background image.\n *\n * Pass zero, one, or two {@link Button} elements via `actions` to render the\n * no-button, single-button, or two-button variants.\n *\n * @example\n * ```tsx\n * <CreatorCard\n * imageSrc=\"/creator.jpg\"\n * name=\"Jane Doe\"\n * description=\"MODEL & PODCASTER\"\n * avatar={{ src: \"/avatar.jpg\", alt: \"Jane Doe\", fallback: \"JD\" }}\n * actions={\n * <>\n * <Button variant=\"brand\" fullWidth>Join for free for 3 days</Button>\n * <Button variant=\"primary\" fullWidth>Follow for Free</Button>\n * </>\n * }\n * />\n * ```\n */\nexport const CreatorCard = React.forwardRef<HTMLDivElement, CreatorCardProps>(\n ({ className, imageSrc, imageAlt = \"\", name, description, avatar, actions, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn(\n \"relative isolate flex aspect-290/450 max-w-full flex-col justify-end overflow-hidden bg-bg-primary\",\n className,\n )}\n {...props}\n >\n <img\n src={imageSrc}\n alt={imageAlt}\n loading=\"lazy\"\n className=\"absolute inset-0 size-full object-cover\"\n />\n <div\n className={cn(\n \"pointer-events-none absolute inset-x-0 bottom-0 bg-linear-to-t from-bg-primary via-bg-primary/90 to-transparent\",\n actions ? \"h-3/5\" : \"h-1/3\",\n )}\n />\n <div className=\"relative flex flex-col gap-4 p-4\">\n <div className=\"flex items-center gap-4\">\n <Avatar\n size={48}\n src={avatar?.src}\n alt={avatar?.alt ?? name}\n fallback={avatar?.fallback}\n {...avatar}\n />\n <div className=\"min-w-0 flex-1\">\n <p className=\"typography-bold-heading-sm truncate text-content-primary\">{name}</p>\n {description && (\n <p className=\"typography-semibold-body-sm truncate text-content-secondary dark:text-brand-primary-default\">\n {description}\n </p>\n )}\n </div>\n </div>\n {actions && <div className=\"flex flex-col gap-2\">{actions}</div>}\n </div>\n </div>\n );\n },\n);\n\nCreatorCard.displayName = \"CreatorCard\";\n"],"names":[],"mappings":";;;;;AA6CO,MAAM,cAAc,MAAM;AAAA,EAC/B,CAAC,EAAE,WAAW,UAAU,WAAW,IAAI,MAAM,aAAa,QAAQ,SAAS,GAAG,MAAA,GAAS,QAAQ;AAC7F,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEJ,UAAA;AAAA,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK;AAAA,cACL,KAAK;AAAA,cACL,SAAQ;AAAA,cACR,WAAU;AAAA,YAAA;AAAA,UAAA;AAAA,UAEZ;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACA,UAAU,UAAU;AAAA,cAAA;AAAA,YACtB;AAAA,UAAA;AAAA,UAEF,qBAAC,OAAA,EAAI,WAAU,oCACb,UAAA;AAAA,YAAA,qBAAC,OAAA,EAAI,WAAU,2BACb,UAAA;AAAA,cAAA;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,MAAM;AAAA,kBACN,KAAK,QAAQ;AAAA,kBACb,KAAK,QAAQ,OAAO;AAAA,kBACpB,UAAU,QAAQ;AAAA,kBACjB,GAAG;AAAA,gBAAA;AAAA,cAAA;AAAA,cAEN,qBAAC,OAAA,EAAI,WAAU,kBACb,UAAA;AAAA,gBAAA,oBAAC,KAAA,EAAE,WAAU,4DAA4D,UAAA,MAAK;AAAA,gBAC7E,eACC,oBAAC,KAAA,EAAE,WAAU,+FACV,UAAA,YAAA,CACH;AAAA,cAAA,EAAA,CAEJ;AAAA,YAAA,GACF;AAAA,YACC,WAAW,oBAAC,OAAA,EAAI,WAAU,uBAAuB,UAAA,QAAA,CAAQ;AAAA,UAAA,EAAA,CAC5D;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,YAAY,cAAc;"}
@@ -0,0 +1,66 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../../utils/cn.mjs";
5
+ import { Pill } from "../Pill/Pill.mjs";
6
+ function isNonEmptyString(value) {
7
+ return typeof value === "string" && value.length > 0;
8
+ }
9
+ const CreatorCover = React.forwardRef(
10
+ ({ className, imageSrc, imageAlt = "", backgroundSrc, name, tagline, tag, action, ...props }, ref) => {
11
+ const headingId = React.useId();
12
+ const renderedTag = isNonEmptyString(tag) ? /* @__PURE__ */ jsx(Pill, { variant: "brand", children: tag }) : tag;
13
+ return /* @__PURE__ */ jsxs(
14
+ "section",
15
+ {
16
+ ref,
17
+ "aria-labelledby": headingId,
18
+ "data-testid": "creator-cover",
19
+ className: cn(
20
+ "relative isolate w-full overflow-hidden bg-white dark:bg-bg-primary",
21
+ className
22
+ ),
23
+ ...props,
24
+ children: [
25
+ /* @__PURE__ */ jsxs("div", { className: "absolute inset-0 -z-10", children: [
26
+ /* @__PURE__ */ jsx(
27
+ "img",
28
+ {
29
+ src: backgroundSrc ?? imageSrc,
30
+ alt: "",
31
+ loading: "lazy",
32
+ className: "size-full scale-110 object-cover blur-3xl"
33
+ }
34
+ ),
35
+ /* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-linear-to-b from-white/30 to-white/15 dark:from-bg-primary/30 dark:to-bg-primary/15" }),
36
+ /* @__PURE__ */ jsx("div", { className: "absolute inset-x-0 bottom-0 h-1/3 bg-linear-to-b from-transparent to-white dark:to-bg-primary" })
37
+ ] }),
38
+ /* @__PURE__ */ jsxs("div", { className: cn("mx-auto flex max-w-90 flex-col items-center gap-4 px-4 pt-17 pb-16"), children: [
39
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
40
+ /* @__PURE__ */ jsx(
41
+ "img",
42
+ {
43
+ src: imageSrc,
44
+ alt: imageAlt,
45
+ loading: "lazy",
46
+ className: "block h-55 w-37.5 rounded-lg object-cover"
47
+ }
48
+ ),
49
+ renderedTag ? /* @__PURE__ */ jsx("div", { className: "absolute bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2", children: renderedTag }) : null
50
+ ] }),
51
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-1 pt-4 text-center", children: [
52
+ /* @__PURE__ */ jsx("h2", { id: headingId, className: "typography-bold-heading-md m-0 text-white", children: name }),
53
+ tagline ? /* @__PURE__ */ jsx("p", { className: "typography-semibold-badge m-0 text-brand-primary-default uppercase", children: tagline }) : null
54
+ ] }),
55
+ action ? /* @__PURE__ */ jsx("div", { className: "w-full pt-2", children: action }) : null
56
+ ] })
57
+ ]
58
+ }
59
+ );
60
+ }
61
+ );
62
+ CreatorCover.displayName = "CreatorCover";
63
+ export {
64
+ CreatorCover
65
+ };
66
+ //# sourceMappingURL=CreatorCover.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreatorCover.mjs","sources":["../../../src/components/CreatorCover/CreatorCover.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Pill } from \"../Pill/Pill\";\n\n/** Slot that accepts a string (rendered as default styling) or a node for full control. */\nexport type CreatorCoverSlot = string | React.ReactNode;\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value.length > 0;\n}\n\nexport interface CreatorCoverProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n /** URL of the creator image displayed in the centre card. Also used as the blurred backdrop unless `backgroundSrc` is provided. */\n imageSrc: string;\n /** Alt text for the centre cover image. @default \"\" */\n imageAlt?: string;\n /** Override URL used for the blurred background image. @default `imageSrc` */\n backgroundSrc?: string;\n /** Creator's name, rendered as the heading. */\n name: string;\n /** Smaller subtitle below the name (e.g. \"GLOBAL POPSTAR\"). Rendered uppercase in the brand colour. */\n tagline?: string;\n /**\n * Status label rendered as a pill overlapping the bottom of the cover image (e.g. \"New Joiner\").\n * Strings render with default green pill styling; pass a node for custom markup.\n */\n tag?: CreatorCoverSlot;\n /**\n * Primary call to action displayed below the title.\n */\n action?: React.ReactNode;\n /** When `true`, fades the bottom of the component to transparent and increases bottom padding to 64px. @default false */\n fadeBottom?: boolean;\n}\n\n/**\n * A creator profile hero with a stylised blurred backdrop, central cover image,\n * status pill, name, tagline, and primary call to action.\n *\n * @example\n * ```tsx\n * <CreatorCover\n * imageSrc=\"/creator.jpg\"\n * imageAlt=\"Jane Doe\"\n * name=\"JANE DOE\"\n * tagline=\"GLOBAL POPSTAR\"\n * tag=\"New Joiner\"\n * action={<Button variant=\"primary\" size=\"48\" fullWidth>Join for free for 7 days</Button>}\n * />\n * ```\n */\nexport const CreatorCover = React.forwardRef<HTMLElement, CreatorCoverProps>(\n (\n { className, imageSrc, imageAlt = \"\", backgroundSrc, name, tagline, tag, action, ...props },\n ref,\n ) => {\n const headingId = React.useId();\n\n const renderedTag = isNonEmptyString(tag) ? <Pill variant=\"brand\">{tag}</Pill> : tag;\n\n return (\n <section\n ref={ref}\n aria-labelledby={headingId}\n data-testid=\"creator-cover\"\n className={cn(\n \"relative isolate w-full overflow-hidden bg-white dark:bg-bg-primary\",\n className,\n )}\n {...props}\n >\n <div className=\"absolute inset-0 -z-10\">\n <img\n src={backgroundSrc ?? imageSrc}\n alt=\"\"\n loading=\"lazy\"\n className=\"size-full scale-110 object-cover blur-3xl\"\n />\n <div className=\"absolute inset-0 bg-linear-to-b from-white/30 to-white/15 dark:from-bg-primary/30 dark:to-bg-primary/15\" />\n <div className=\"absolute inset-x-0 bottom-0 h-1/3 bg-linear-to-b from-transparent to-white dark:to-bg-primary\" />\n </div>\n <div className={cn(\"mx-auto flex max-w-90 flex-col items-center gap-4 px-4 pt-17 pb-16\")}>\n <div className=\"relative\">\n <img\n src={imageSrc}\n alt={imageAlt}\n loading=\"lazy\"\n className=\"block h-55 w-37.5 rounded-lg object-cover\"\n />\n {renderedTag ? (\n <div className=\"absolute bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2\">\n {renderedTag}\n </div>\n ) : null}\n </div>\n <div className=\"flex flex-col items-center gap-1 pt-4 text-center\">\n <h2 id={headingId} className=\"typography-bold-heading-md m-0 text-white\">\n {name}\n </h2>\n {tagline ? (\n <p className=\"typography-semibold-badge m-0 text-brand-primary-default uppercase\">\n {tagline}\n </p>\n ) : null}\n </div>\n {action ? <div className=\"w-full pt-2\">{action}</div> : null}\n </div>\n </section>\n );\n },\n);\n\nCreatorCover.displayName = \"CreatorCover\";\n"],"names":[],"mappings":";;;;;AAOA,SAAS,iBAAiB,OAAiC;AACzD,SAAO,OAAO,UAAU,YAAY,MAAM,SAAS;AACrD;AA0CO,MAAM,eAAe,MAAM;AAAA,EAChC,CACE,EAAE,WAAW,UAAU,WAAW,IAAI,eAAe,MAAM,SAAS,KAAK,QAAQ,GAAG,MAAA,GACpF,QACG;AACH,UAAM,YAAY,MAAM,MAAA;AAExB,UAAM,cAAc,iBAAiB,GAAG,wBAAK,MAAA,EAAK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";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../../utils/cn.mjs";
5
+ const ASPECT_RATIO_CLASSES = {
6
+ tall: "aspect-1/2",
7
+ medium: "aspect-2/3",
8
+ short: "aspect-4/5"
9
+ };
10
+ const CreatorTile = React.forwardRef(
11
+ ({ className, imageSrc, imageAlt = "", name, tagline, aspectRatio = "medium", ...props }, ref) => {
12
+ const aspectClass = ASPECT_RATIO_CLASSES[aspectRatio];
13
+ return /* @__PURE__ */ jsxs(
14
+ "div",
15
+ {
16
+ ref,
17
+ className: cn(
18
+ "relative isolate flex w-full flex-col justify-end overflow-hidden",
19
+ aspectClass,
20
+ className
21
+ ),
22
+ ...props,
23
+ children: [
24
+ /* @__PURE__ */ jsx(
25
+ "img",
26
+ {
27
+ src: imageSrc,
28
+ alt: imageAlt,
29
+ loading: "lazy",
30
+ className: "absolute inset-0 -z-10 h-full w-full object-cover"
31
+ }
32
+ ),
33
+ /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-0 -z-10 bg-linear-to-b from-64% from-transparent to-black/40" }),
34
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1 px-6 pb-6", children: [
35
+ /* @__PURE__ */ jsx("p", { className: "m-0 font-black text-4xl text-white leading-none tracking-tight", children: name }),
36
+ tagline ? /* @__PURE__ */ jsx("p", { className: "m-0 font-bold text-[9px] text-brand-primary-default uppercase leading-none", children: tagline }) : null
37
+ ] })
38
+ ]
39
+ }
40
+ );
41
+ }
42
+ );
43
+ CreatorTile.displayName = "CreatorTile";
44
+ export {
45
+ CreatorTile
46
+ };
47
+ //# sourceMappingURL=CreatorTile.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreatorTile.mjs","sources":["../../../src/components/CreatorTile/CreatorTile.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/** Width-to-height ratio preset for the tile. */\nexport type CreatorTileAspectRatio = \"tall\" | \"medium\" | \"short\";\n\nconst ASPECT_RATIO_CLASSES: Record<CreatorTileAspectRatio, string> = {\n tall: \"aspect-1/2\",\n medium: \"aspect-2/3\",\n short: \"aspect-4/5\",\n};\n\nexport interface CreatorTileProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Source URL of the creator's image. Rendered as the tile background. */\n imageSrc: string;\n /** Alt text for the creator image. Use an empty string for purely decorative imagery. */\n imageAlt?: string;\n /** Creator name shown as the prominent overlay heading. */\n name: React.ReactNode;\n /** Short tagline shown under the name in the brand accent color. */\n tagline?: React.ReactNode;\n /**\n * Width-to-height ratio preset.\n *\n * - `tall` – 1:2 narrow portrait\n * - `medium` – 2:3 classic poster (default)\n * - `short` – 4:5 closer to square\n *\n * @default \"medium\"\n */\n aspectRatio?: CreatorTileAspectRatio;\n}\n\n/**\n * A visual highlight tile showcasing a creator with an overlaid name and tagline.\n *\n * The tile renders a full-bleed image with a bottom gradient that ensures the\n * overlaid text remains legible regardless of the underlying photography.\n *\n * @example\n * ```tsx\n * <CreatorTile\n * imageSrc=\"https://example.com/creator.jpg\"\n * imageAlt=\"Portrait of Jane Doe\"\n * name=\"JANE DOE\"\n * tagline=\"GLOBAL MUSIC ICON\"\n * />\n * ```\n */\nexport const CreatorTile = React.forwardRef<HTMLDivElement, CreatorTileProps>(\n (\n { className, imageSrc, imageAlt = \"\", name, tagline, aspectRatio = \"medium\", ...props },\n ref,\n ) => {\n const aspectClass = ASPECT_RATIO_CLASSES[aspectRatio];\n\n return (\n <div\n ref={ref}\n className={cn(\n \"relative isolate flex w-full flex-col justify-end overflow-hidden\",\n aspectClass,\n className,\n )}\n {...props}\n >\n <img\n src={imageSrc}\n alt={imageAlt}\n loading=\"lazy\"\n className=\"absolute inset-0 -z-10 h-full w-full object-cover\"\n />\n <div className=\"pointer-events-none absolute inset-0 -z-10 bg-linear-to-b from-64% from-transparent to-black/40\" />\n <div className=\"flex flex-col gap-1 px-6 pb-6\">\n <p className=\"m-0 font-black text-4xl text-white leading-none tracking-tight\">{name}</p>\n {tagline ? (\n <p className=\"m-0 font-bold text-[9px] text-brand-primary-default uppercase leading-none\">\n {tagline}\n </p>\n ) : null}\n </div>\n </div>\n );\n },\n);\n\nCreatorTile.displayName = \"CreatorTile\";\n"],"names":[],"mappings":";;;;AAMA,MAAM,uBAA+D;AAAA,EACnE,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO;AACT;AAuCO,MAAM,cAAc,MAAM;AAAA,EAC/B,CACE,EAAE,WAAW,UAAU,WAAW,IAAI,MAAM,SAAS,cAAc,UAAU,GAAG,MAAA,GAChF,QACG;AACH,UAAM,cAAc,qBAAqB,WAAW;AAEpD,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEJ,UAAA;AAAA,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,KAAK;AAAA,cACL,KAAK;AAAA,cACL,SAAQ;AAAA,cACR,WAAU;AAAA,YAAA;AAAA,UAAA;AAAA,UAEZ,oBAAC,OAAA,EAAI,WAAU,kGAAA,CAAkG;AAAA,UACjH,qBAAC,OAAA,EAAI,WAAU,iCACb,UAAA;AAAA,YAAA,oBAAC,KAAA,EAAE,WAAU,kEAAkE,UAAA,MAAK;AAAA,YACnF,UACC,oBAAC,KAAA,EAAE,WAAU,8EACV,mBACH,IACE;AAAA,UAAA,EAAA,CACN;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,YAAY,cAAc;"}
@@ -0,0 +1,120 @@
1
+ "use client";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { cn } from "../../utils/cn.mjs";
5
+ import { useCyclingCycle } from "./useCyclingCycle.mjs";
6
+ import { useCyclingTextTrackWidth } from "./useCyclingTextTrackWidth.mjs";
7
+ import { usePageVisibility } from "./usePageVisibility.mjs";
8
+ import { usePrefersReducedMotion } from "./usePrefersReducedMotion.mjs";
9
+ const DEFAULT_INTERVAL_MS = 2100;
10
+ const DEFAULT_TRANSITION_MS = 200;
11
+ const SLIDE_OFFSET_PX = 18;
12
+ const CyclingText = React.forwardRef(
13
+ ({
14
+ items,
15
+ intervalMs = DEFAULT_INTERVAL_MS,
16
+ transitionMs = DEFAULT_TRANSITION_MS,
17
+ direction = "up",
18
+ paused = false,
19
+ sizing = "longest",
20
+ className,
21
+ labelClassName,
22
+ announceChanges = false,
23
+ ...rest
24
+ }, ref) => {
25
+ const docVisible = usePageVisibility();
26
+ const reducedMotion = usePrefersReducedMotion();
27
+ const { sizingLabelRef, trackWidth } = useCyclingTextTrackWidth();
28
+ const { cycle, currentLabel, incomingLabel, sizingLabel, onOutgoingTransitionEnd } = useCyclingCycle(items, sizing, intervalMs, paused, docVisible, transitionMs);
29
+ const itemCount = items.length;
30
+ const outgoingMotionStyle = React.useMemo(() => {
31
+ const durMs = reducedMotion ? 0 : transitionMs;
32
+ const exiting = cycle.transitioning;
33
+ const yExit = direction === "up" ? -SLIDE_OFFSET_PX : SLIDE_OFFSET_PX;
34
+ return {
35
+ opacity: exiting ? 0 : 1,
36
+ transform: exiting ? `translate3d(0, ${yExit}px, 0)` : "translate3d(0, 0, 0)",
37
+ transition: exiting && durMs > 0 ? `opacity ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1), transform ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1)` : "none"
38
+ };
39
+ }, [cycle.transitioning, direction, transitionMs, reducedMotion]);
40
+ const incomingMotionStyle = React.useMemo(() => {
41
+ const durMs = reducedMotion ? 0 : transitionMs;
42
+ const entered = cycle.incomingEntered;
43
+ const yEnter = direction === "up" ? SLIDE_OFFSET_PX : -SLIDE_OFFSET_PX;
44
+ return {
45
+ opacity: entered ? 1 : 0,
46
+ transform: entered ? "translate3d(0, 0, 0)" : `translate3d(0, ${yEnter}px, 0)`,
47
+ transition: durMs > 0 ? `opacity ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1), transform ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1)` : "none"
48
+ };
49
+ }, [cycle.incomingEntered, direction, transitionMs, reducedMotion]);
50
+ if (itemCount === 0) {
51
+ return null;
52
+ }
53
+ const wrapperStyle = {
54
+ ...trackWidth !== null ? { width: `${trackWidth}px` } : {}
55
+ // paddingTop: SLIDE_OFFSET_PX,
56
+ };
57
+ const showIncoming = incomingLabel !== null && cycle.transitioning;
58
+ return /* @__PURE__ */ jsxs(
59
+ "span",
60
+ {
61
+ ref,
62
+ "data-testid": "cycling-text",
63
+ "data-paused": paused ? "true" : void 0,
64
+ className: cn(
65
+ "relative inline-flex items-center overflow-hidden align-middle leading-[inherit]",
66
+ "motion-safe:transition-[width] motion-safe:duration-300 motion-safe:ease-out",
67
+ className
68
+ ),
69
+ style: wrapperStyle,
70
+ ...rest,
71
+ children: [
72
+ /* @__PURE__ */ jsx(
73
+ "span",
74
+ {
75
+ ref: sizingLabelRef,
76
+ "aria-hidden": "true",
77
+ className: "pointer-events-none invisible inline-block select-none whitespace-nowrap leading-[inherit]",
78
+ children: sizingLabel
79
+ }
80
+ ),
81
+ /* @__PURE__ */ jsx(
82
+ "span",
83
+ {
84
+ "data-layer": "current",
85
+ "aria-live": announceChanges ? "polite" : void 0,
86
+ "aria-atomic": announceChanges ? true : void 0,
87
+ "data-state": cycle.transitioning ? "exit" : "idle",
88
+ onTransitionEnd: onOutgoingTransitionEnd,
89
+ className: cn(
90
+ "absolute inset-0 flex items-center whitespace-nowrap leading-[inherit]",
91
+ labelClassName
92
+ ),
93
+ style: outgoingMotionStyle,
94
+ children: currentLabel
95
+ }
96
+ ),
97
+ showIncoming ? /* @__PURE__ */ jsx(
98
+ "span",
99
+ {
100
+ "aria-hidden": "true",
101
+ "data-layer": "incoming",
102
+ "data-state": cycle.incomingEntered ? "idle" : "enter",
103
+ className: cn(
104
+ "absolute inset-0 flex items-center whitespace-nowrap leading-[inherit]",
105
+ labelClassName
106
+ ),
107
+ style: incomingMotionStyle,
108
+ children: incomingLabel
109
+ }
110
+ ) : null
111
+ ]
112
+ }
113
+ );
114
+ }
115
+ );
116
+ CyclingText.displayName = "CyclingText";
117
+ export {
118
+ CyclingText
119
+ };
120
+ //# sourceMappingURL=CyclingText.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CyclingText.mjs","sources":["../../../src/components/CyclingText/CyclingText.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useCyclingCycle } from \"./useCyclingCycle\";\nimport { useCyclingTextTrackWidth } from \"./useCyclingTextTrackWidth\";\nimport { usePageVisibility } from \"./usePageVisibility\";\nimport { usePrefersReducedMotion } from \"./usePrefersReducedMotion\";\n\nconst DEFAULT_INTERVAL_MS = 2100;\nconst DEFAULT_TRANSITION_MS = 200;\n\nconst SLIDE_OFFSET_PX = 18;\n\n/** How the wrapper should be sized to accommodate variable-length items. */\nexport type CyclingTextSizing = \"longest\" | \"current\";\n\nexport interface CyclingTextProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /** Strings to cycle through, in order. Cycles back to the first after the last. */\n items: readonly string[];\n /**\n * Milliseconds to wait after the previous transition finishes before starting the next one.\n * @default 2100\n */\n intervalMs?: number;\n /** Slide and cross-fade duration in milliseconds. @default 200 */\n transitionMs?: number;\n /** Direction the outgoing item slides. @default \"up\" */\n direction?: \"up\" | \"down\";\n /** When true, freezes on the current item — no further cycling until cleared. @default false */\n paused?: boolean;\n /**\n * How the wrapper sizes itself horizontally.\n * - `longest` reserves space for the longest item — no width jitter as items cycle.\n * - `current` shrinks/grows with each item, animating width between cycles.\n * @default \"longest\"\n */\n sizing?: CyclingTextSizing;\n /**\n * When `true`, updates are exposed to assistive technologies via `aria-live=\"polite\"`.\n * Leave `false` for decorative or frequently changing copy so screen readers are not interrupted on every cycle.\n * @default false\n */\n announceChanges?: boolean;\n /**\n * Class applied to each visible label span (current + incoming). Use this for\n * effects that have to sit on the text element itself, e.g. `background-clip: text`.\n */\n labelClassName?: string;\n}\n\n/**\n * Cycles through a list of strings with a slide-in/slide-out animation. Lives\n * inline so it can sit inside divs, spans, buttons, or as a fake placeholder\n * overlay.\n *\n * @example\n * ```tsx\n * <CyclingText items={[\"Thinking\", \"Reading messages\", \"Drafting reply\"]} />\n * ```\n */\nexport const CyclingText = React.forwardRef<HTMLSpanElement, CyclingTextProps>(\n (\n {\n items,\n intervalMs = DEFAULT_INTERVAL_MS,\n transitionMs = DEFAULT_TRANSITION_MS,\n direction = \"up\",\n paused = false,\n sizing = \"longest\",\n className,\n labelClassName,\n announceChanges = false,\n ...rest\n },\n ref,\n ) => {\n const docVisible = usePageVisibility();\n const reducedMotion = usePrefersReducedMotion();\n const { sizingLabelRef, trackWidth } = useCyclingTextTrackWidth();\n const { cycle, currentLabel, incomingLabel, sizingLabel, onOutgoingTransitionEnd } =\n useCyclingCycle(items, sizing, intervalMs, paused, docVisible, transitionMs);\n\n const itemCount = items.length;\n\n const outgoingMotionStyle = React.useMemo((): React.CSSProperties => {\n const durMs = reducedMotion ? 0 : transitionMs;\n const exiting = cycle.transitioning;\n const yExit = direction === \"up\" ? -SLIDE_OFFSET_PX : SLIDE_OFFSET_PX;\n return {\n opacity: exiting ? 0 : 1,\n transform: exiting ? `translate3d(0, ${yExit}px, 0)` : \"translate3d(0, 0, 0)\",\n transition:\n exiting && durMs > 0\n ? `opacity ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1), transform ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1)`\n : \"none\",\n };\n }, [cycle.transitioning, direction, transitionMs, reducedMotion]);\n\n const incomingMotionStyle = React.useMemo((): React.CSSProperties => {\n const durMs = reducedMotion ? 0 : transitionMs;\n const entered = cycle.incomingEntered;\n const yEnter = direction === \"up\" ? SLIDE_OFFSET_PX : -SLIDE_OFFSET_PX;\n return {\n opacity: entered ? 1 : 0,\n transform: entered ? \"translate3d(0, 0, 0)\" : `translate3d(0, ${yEnter}px, 0)`,\n transition:\n durMs > 0\n ? `opacity ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1), transform ${durMs}ms cubic-bezier(0.4, 0, 0.2, 1)`\n : \"none\",\n };\n }, [cycle.incomingEntered, direction, transitionMs, reducedMotion]);\n\n if (itemCount === 0) {\n return null;\n }\n\n const wrapperStyle = {\n ...(trackWidth !== null ? { width: `${trackWidth}px` } : {}),\n // paddingTop: SLIDE_OFFSET_PX,\n } as React.CSSProperties;\n\n const showIncoming = incomingLabel !== null && cycle.transitioning;\n\n return (\n <span\n ref={ref}\n data-testid=\"cycling-text\"\n data-paused={paused ? \"true\" : undefined}\n className={cn(\n \"relative inline-flex items-center overflow-hidden align-middle leading-[inherit]\",\n \"motion-safe:transition-[width] motion-safe:duration-300 motion-safe:ease-out\",\n className,\n )}\n style={wrapperStyle}\n {...rest}\n >\n <span\n ref={sizingLabelRef}\n aria-hidden=\"true\"\n className=\"pointer-events-none invisible inline-block select-none whitespace-nowrap leading-[inherit]\"\n >\n {sizingLabel}\n </span>\n\n <span\n data-layer=\"current\"\n aria-live={announceChanges ? \"polite\" : undefined}\n aria-atomic={announceChanges ? true : undefined}\n data-state={cycle.transitioning ? \"exit\" : \"idle\"}\n onTransitionEnd={onOutgoingTransitionEnd}\n className={cn(\n \"absolute inset-0 flex items-center whitespace-nowrap leading-[inherit]\",\n labelClassName,\n )}\n style={outgoingMotionStyle}\n >\n {currentLabel}\n </span>\n\n {showIncoming ? (\n <span\n aria-hidden=\"true\"\n data-layer=\"incoming\"\n data-state={cycle.incomingEntered ? \"idle\" : \"enter\"}\n className={cn(\n \"absolute inset-0 flex items-center whitespace-nowrap leading-[inherit]\",\n labelClassName,\n )}\n style={incomingMotionStyle}\n >\n {incomingLabel}\n </span>\n ) : null}\n </span>\n );\n },\n);\n\nCyclingText.displayName = \"CyclingText\";\n"],"names":[],"mappings":";;;;;;;;AAOA,MAAM,sBAAsB;AAC5B,MAAM,wBAAwB;AAE9B,MAAM,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