@fanvue/ui 3.15.0 → 3.17.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.
Files changed (72) hide show
  1. package/dist/cjs/components/AudioPlayer/AudioPlayer.cjs +16 -89
  2. package/dist/cjs/components/AudioPlayer/AudioPlayer.cjs.map +1 -1
  3. package/dist/cjs/components/AudioRecordButton/AudioRecordButton.cjs +54 -0
  4. package/dist/cjs/components/AudioRecordButton/AudioRecordButton.cjs.map +1 -0
  5. package/dist/cjs/components/AudioUpload/AudioUpload.cjs +5 -5
  6. package/dist/cjs/components/AudioUpload/AudioUpload.cjs.map +1 -1
  7. package/dist/cjs/components/ChatInput/ChatInput.cjs +6 -11
  8. package/dist/cjs/components/ChatInput/ChatInput.cjs.map +1 -1
  9. package/dist/cjs/components/ChatMessage/ChatMessage.cjs +228 -0
  10. package/dist/cjs/components/ChatMessage/ChatMessage.cjs.map +1 -0
  11. package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs +160 -71
  12. package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs.map +1 -1
  13. package/dist/cjs/components/Icons/DenseGridViewIcon.cjs +52 -0
  14. package/dist/cjs/components/Icons/DenseGridViewIcon.cjs.map +1 -0
  15. package/dist/cjs/components/MediaStatusIndicator/MediaStatusIndicator.cjs +66 -0
  16. package/dist/cjs/components/MediaStatusIndicator/MediaStatusIndicator.cjs.map +1 -0
  17. package/dist/cjs/components/Select/Select.cjs +61 -17
  18. package/dist/cjs/components/Select/Select.cjs.map +1 -1
  19. package/dist/cjs/components/SubscribeButton/SubscribeButton.cjs +53 -0
  20. package/dist/cjs/components/SubscribeButton/SubscribeButton.cjs.map +1 -0
  21. package/dist/cjs/components/VoiceNote/VoiceNote.cjs +305 -0
  22. package/dist/cjs/components/VoiceNote/VoiceNote.cjs.map +1 -0
  23. package/dist/cjs/index.cjs +12 -0
  24. package/dist/cjs/index.cjs.map +1 -1
  25. package/dist/cjs/utils/audioWaveform.cjs +76 -0
  26. package/dist/cjs/utils/audioWaveform.cjs.map +1 -0
  27. package/dist/cjs/utils/useAudioPlayback.cjs +123 -0
  28. package/dist/cjs/utils/useAudioPlayback.cjs.map +1 -0
  29. package/dist/cjs/utils/useFittedBarCount.cjs +42 -0
  30. package/dist/cjs/utils/useFittedBarCount.cjs.map +1 -0
  31. package/dist/cjs/utils/useWaveformPeaks.cjs +48 -0
  32. package/dist/cjs/utils/useWaveformPeaks.cjs.map +1 -0
  33. package/dist/cjs/utils/useWaveformSeek.cjs +100 -0
  34. package/dist/cjs/utils/useWaveformSeek.cjs.map +1 -0
  35. package/dist/components/AudioPlayer/AudioPlayer.mjs +7 -80
  36. package/dist/components/AudioPlayer/AudioPlayer.mjs.map +1 -1
  37. package/dist/components/AudioRecordButton/AudioRecordButton.mjs +37 -0
  38. package/dist/components/AudioRecordButton/AudioRecordButton.mjs.map +1 -0
  39. package/dist/components/AudioUpload/AudioUpload.mjs +5 -5
  40. package/dist/components/AudioUpload/AudioUpload.mjs.map +1 -1
  41. package/dist/components/ChatInput/ChatInput.mjs +6 -11
  42. package/dist/components/ChatInput/ChatInput.mjs.map +1 -1
  43. package/dist/components/ChatMessage/ChatMessage.mjs +211 -0
  44. package/dist/components/ChatMessage/ChatMessage.mjs.map +1 -0
  45. package/dist/components/DropdownMenu/DropdownMenu.mjs +161 -72
  46. package/dist/components/DropdownMenu/DropdownMenu.mjs.map +1 -1
  47. package/dist/components/Icons/DenseGridViewIcon.mjs +35 -0
  48. package/dist/components/Icons/DenseGridViewIcon.mjs.map +1 -0
  49. package/dist/components/MediaStatusIndicator/MediaStatusIndicator.mjs +49 -0
  50. package/dist/components/MediaStatusIndicator/MediaStatusIndicator.mjs.map +1 -0
  51. package/dist/components/Select/Select.mjs +61 -17
  52. package/dist/components/Select/Select.mjs.map +1 -1
  53. package/dist/components/SubscribeButton/SubscribeButton.mjs +36 -0
  54. package/dist/components/SubscribeButton/SubscribeButton.mjs.map +1 -0
  55. package/dist/components/VoiceNote/VoiceNote.mjs +288 -0
  56. package/dist/components/VoiceNote/VoiceNote.mjs.map +1 -0
  57. package/dist/index.d.ts +321 -4
  58. package/dist/index.mjs +12 -0
  59. package/dist/index.mjs.map +1 -1
  60. package/dist/styles/base.css +11 -2
  61. package/dist/styles/theme.css +1 -1
  62. package/dist/utils/audioWaveform.mjs +76 -0
  63. package/dist/utils/audioWaveform.mjs.map +1 -0
  64. package/dist/utils/useAudioPlayback.mjs +106 -0
  65. package/dist/utils/useAudioPlayback.mjs.map +1 -0
  66. package/dist/utils/useFittedBarCount.mjs +25 -0
  67. package/dist/utils/useFittedBarCount.mjs.map +1 -0
  68. package/dist/utils/useWaveformPeaks.mjs +31 -0
  69. package/dist/utils/useWaveformPeaks.mjs.map +1 -0
  70. package/dist/utils/useWaveformSeek.mjs +83 -0
  71. package/dist/utils/useWaveformSeek.mjs.map +1 -0
  72. package/package.json +1 -1
@@ -0,0 +1,66 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const jsxRuntime = require("react/jsx-runtime");
5
+ const React = require("react");
6
+ const cn = require("../../utils/cn.cjs");
7
+ const CloseIcon = require("../Icons/CloseIcon.cjs");
8
+ const EyeOffIcon = require("../Icons/EyeOffIcon.cjs");
9
+ const FlagIcon = require("../Icons/FlagIcon.cjs");
10
+ function _interopNamespaceDefault(e) {
11
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
12
+ if (e) {
13
+ for (const k in e) {
14
+ if (k !== "default") {
15
+ const d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: () => e[k]
19
+ });
20
+ }
21
+ }
22
+ }
23
+ n.default = e;
24
+ return Object.freeze(n);
25
+ }
26
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
27
+ const STATUS_CONFIG = {
28
+ default: {
29
+ container: "bg-warning-surface text-warning-content",
30
+ icon: /* @__PURE__ */ jsxRuntime.jsx(FlagIcon.FlagIcon, { size: 16, filled: true }),
31
+ label: "Flagged"
32
+ },
33
+ removed: {
34
+ container: "border border-error-secondary bg-error-negative-content text-content-always-white",
35
+ icon: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon.CloseIcon, { size: 16 }),
36
+ label: "Removed"
37
+ },
38
+ sensitive: {
39
+ container: "bg-buttons-overlay-default text-content-always-white",
40
+ icon: /* @__PURE__ */ jsxRuntime.jsx(EyeOffIcon.EyeOffIcon, { size: 16, filled: true }),
41
+ label: "Sensitive content"
42
+ }
43
+ };
44
+ const MediaStatusIndicator = React__namespace.forwardRef(
45
+ ({ status = "default", label, className, ...props }, ref) => {
46
+ const config = STATUS_CONFIG[status];
47
+ return /* @__PURE__ */ jsxRuntime.jsx(
48
+ "span",
49
+ {
50
+ ref,
51
+ role: "img",
52
+ "aria-label": props["aria-label"] ?? label ?? config.label,
53
+ className: cn.cn(
54
+ "inline-flex items-center justify-center rounded-full p-2 [&>svg]:size-4",
55
+ config.container,
56
+ className
57
+ ),
58
+ ...props,
59
+ children: config.icon
60
+ }
61
+ );
62
+ }
63
+ );
64
+ MediaStatusIndicator.displayName = "MediaStatusIndicator";
65
+ exports.MediaStatusIndicator = MediaStatusIndicator;
66
+ //# sourceMappingURL=MediaStatusIndicator.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaStatusIndicator.cjs","sources":["../../../../src/components/MediaStatusIndicator/MediaStatusIndicator.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { EyeOffIcon } from \"../Icons/EyeOffIcon\";\nimport { FlagIcon } from \"../Icons/FlagIcon\";\n\n/**\n * State represented by the indicator.\n * - `\"default\"`: media flagged / pending review (amber).\n * - `\"removed\"`: media removed for a policy violation (red).\n * - `\"sensitive\"`: sensitive content hidden behind an overlay (dark).\n */\nexport type MediaStatusIndicatorStatus = \"default\" | \"removed\" | \"sensitive\";\n\nexport interface MediaStatusIndicatorProps\n extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"children\"> {\n /** Which media state to represent. @default \"default\" */\n status?: MediaStatusIndicatorStatus;\n /**\n * Accessible label announced by assistive tech. Defaults to a per-status\n * description; pass your own for localisation or extra context.\n */\n label?: string;\n}\n\ntype StatusConfig = { container: string; icon: React.ReactNode; label: string };\n\nconst STATUS_CONFIG: Record<MediaStatusIndicatorStatus, StatusConfig> = {\n default: {\n container: \"bg-warning-surface text-warning-content\",\n icon: <FlagIcon size={16} filled />,\n label: \"Flagged\",\n },\n removed: {\n container: \"border border-error-secondary bg-error-negative-content text-content-always-white\",\n icon: <CloseIcon size={16} />,\n label: \"Removed\",\n },\n sensitive: {\n container: \"bg-buttons-overlay-default text-content-always-white\",\n icon: <EyeOffIcon size={16} filled />,\n label: \"Sensitive content\",\n },\n};\n\n/**\n * A compact circular indicator that surfaces the moderation state of a piece of\n * media — flagged, removed, or sensitive. Typically overlaid on a thumbnail or\n * attachment.\n *\n * Renders as `role=\"img\"` with a descriptive `aria-label`; the inner glyph is\n * decorative.\n *\n * @example\n * ```tsx\n * <MediaStatusIndicator status=\"sensitive\" />\n * <MediaStatusIndicator status=\"removed\" label=\"Removed for violating guidelines\" />\n * ```\n */\nexport const MediaStatusIndicator = React.forwardRef<HTMLSpanElement, MediaStatusIndicatorProps>(\n ({ status = \"default\", label, className, ...props }, ref) => {\n const config = STATUS_CONFIG[status];\n return (\n <span\n ref={ref}\n role=\"img\"\n aria-label={props[\"aria-label\"] ?? label ?? config.label}\n className={cn(\n \"inline-flex items-center justify-center rounded-full p-2 [&>svg]:size-4\",\n config.container,\n className,\n )}\n {...props}\n >\n {config.icon}\n </span>\n );\n },\n);\n\nMediaStatusIndicator.displayName = \"MediaStatusIndicator\";\n"],"names":["jsx","FlagIcon","CloseIcon","EyeOffIcon","React","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,gBAAkE;AAAA,EACtE,SAAS;AAAA,IACP,WAAW;AAAA,IACX,MAAMA,2BAAAA,IAACC,mBAAA,EAAS,MAAM,IAAI,QAAM,MAAC;AAAA,IACjC,OAAO;AAAA,EAAA;AAAA,EAET,SAAS;AAAA,IACP,WAAW;AAAA,IACX,MAAMD,2BAAAA,IAACE,UAAAA,WAAA,EAAU,MAAM,GAAA,CAAI;AAAA,IAC3B,OAAO;AAAA,EAAA;AAAA,EAET,WAAW;AAAA,IACT,WAAW;AAAA,IACX,MAAMF,2BAAAA,IAACG,uBAAA,EAAW,MAAM,IAAI,QAAM,MAAC;AAAA,IACnC,OAAO;AAAA,EAAA;AAEX;AAgBO,MAAM,uBAAuBC,iBAAM;AAAA,EACxC,CAAC,EAAE,SAAS,WAAW,OAAO,WAAW,GAAG,MAAA,GAAS,QAAQ;AAC3D,UAAM,SAAS,cAAc,MAAM;AACnC,WACEJ,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA,MAAK;AAAA,QACL,cAAY,MAAM,YAAY,KAAK,SAAS,OAAO;AAAA,QACnD,WAAWK,GAAAA;AAAAA,UACT;AAAA,UACA,OAAO;AAAA,UACP;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEH,UAAA,OAAO;AAAA,MAAA;AAAA,IAAA;AAAA,EAGd;AACF;AAEA,qBAAqB,cAAc;;"}
@@ -98,7 +98,7 @@ const Select = React__namespace.forwardRef(
98
98
  "aria-describedby": bottomText ? helperTextId : void 0,
99
99
  "aria-invalid": error || void 0,
100
100
  className: cn.cn(
101
- "flex w-full cursor-pointer items-center justify-between rounded-sm border bg-inputs-inputs-primary outline-none motion-safe:transition-colors focus-visible:shadow-focus-ring",
101
+ "flex w-full cursor-pointer items-center justify-between rounded-sm border bg-inputs-inputs-primary outline-none focus-visible:shadow-focus-ring motion-safe:transition-colors",
102
102
  TRIGGER_HEIGHT[size],
103
103
  TRIGGER_PADDING_X[size],
104
104
  TRIGGER_GAP[size],
@@ -173,22 +173,66 @@ const SelectContent = React__namespace.forwardRef(
173
173
  ) })
174
174
  );
175
175
  SelectContent.displayName = "SelectContent";
176
- const SelectItem = React__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
177
- SelectPrimitive__namespace.Item,
178
- {
179
- ref,
180
- className: cn.cn(
181
- "typography-body-default-16px-regular relative flex w-full cursor-pointer select-none items-center gap-2 rounded-xs py-2 pr-2 pl-3 text-content-primary outline-none",
182
- "focus:bg-neutral-alphas-100 data-disabled:pointer-events-none data-disabled:opacity-50",
183
- className
184
- ),
185
- ...props,
186
- children: [
187
- /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children }),
188
- /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemIndicator, { className: "ml-auto flex size-4 shrink-0 items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon.CheckIcon, { className: "size-4 text-content-primary" }) })
189
- ]
190
- }
191
- ));
176
+ const ITEM_SIZE_CLASSES = {
177
+ "40": "min-h-10 py-2 typography-body-default-16px-regular",
178
+ "32": "min-h-8 py-[7px] typography-body-small-14px-regular"
179
+ };
180
+ const ITEM_DESCRIPTION_TYPOGRAPHY = {
181
+ "40": "typography-body-small-14px-regular",
182
+ "32": "typography-description-12px-regular"
183
+ };
184
+ function isRenderableNode(node) {
185
+ return node !== null && node !== void 0 && typeof node !== "boolean";
186
+ }
187
+ const SelectItem = React__namespace.forwardRef(({ className, children, size, leadingIcon, avatar, description, ...props }, ref) => {
188
+ const { size: triggerSize } = React__namespace.useContext(SelectContext);
189
+ const itemSize = size ?? (triggerSize === "32" ? "32" : "40");
190
+ const hasDescription = isRenderableNode(description);
191
+ const hasAvatar = isRenderableNode(avatar);
192
+ const hasLeadingIcon = isRenderableNode(leadingIcon);
193
+ return /* @__PURE__ */ jsxRuntime.jsxs(
194
+ SelectPrimitive__namespace.Item,
195
+ {
196
+ ref,
197
+ className: cn.cn(
198
+ "group relative flex w-full cursor-pointer select-none gap-2 rounded-xs px-3 text-content-primary outline-none",
199
+ hasDescription ? "items-start" : "items-center",
200
+ ITEM_SIZE_CLASSES[itemSize],
201
+ hasAvatar && !hasDescription && itemSize === "32" && "py-1",
202
+ "focus:bg-neutral-alphas-50 data-highlighted:bg-neutral-alphas-50",
203
+ "data-disabled:pointer-events-none data-disabled:text-content-disabled",
204
+ className
205
+ ),
206
+ ...props,
207
+ children: [
208
+ hasAvatar ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0", children: avatar }) : hasLeadingIcon && (hasDescription ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex shrink-0 items-center pt-0.5 [&>svg]:size-4", children: leadingIcon }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex shrink-0 items-center [&>svg]:size-4", children: leadingIcon })),
209
+ hasDescription ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
210
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children }) }),
211
+ /* @__PURE__ */ jsxRuntime.jsx(
212
+ "span",
213
+ {
214
+ className: cn.cn(
215
+ "truncate text-content-secondary group-data-[disabled]:text-content-disabled",
216
+ ITEM_DESCRIPTION_TYPOGRAPHY[itemSize]
217
+ ),
218
+ children: description
219
+ }
220
+ )
221
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate", children: /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.ItemText, { children }) }),
222
+ /* @__PURE__ */ jsxRuntime.jsx(
223
+ SelectPrimitive__namespace.ItemIndicator,
224
+ {
225
+ className: cn.cn(
226
+ "ml-auto flex size-4 shrink-0 items-center justify-center",
227
+ hasDescription && "self-start"
228
+ ),
229
+ children: /* @__PURE__ */ jsxRuntime.jsx(CheckIcon.CheckIcon, { className: "size-4 text-content-primary group-data-[disabled]:text-content-disabled" })
230
+ }
231
+ )
232
+ ]
233
+ }
234
+ );
235
+ });
192
236
  SelectItem.displayName = "SelectItem";
193
237
  const SelectGroup = SelectPrimitive__namespace.Group;
194
238
  SelectGroup.displayName = "SelectGroup";
@@ -1 +1 @@
1
- {"version":3,"file":"Select.cjs","sources":["../../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as SelectPrimitive from \"@radix-ui/react-select\";\nimport * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { FLOATING_CONTENT_COLLISION_PADDING } from \"@/utils/floatingContentCollisionPadding\";\nimport { CheckIcon } from \"../Icons/CheckIcon\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\n\n/** Select field height in pixels. */\nexport type SelectSize = \"48\" | \"40\" | \"32\";\n\ntype SelectContextValue = {\n size: SelectSize;\n error: boolean;\n disabled?: boolean;\n};\n\nconst SelectContext = React.createContext<SelectContextValue>({\n size: \"48\",\n error: false,\n});\n\nconst TRIGGER_HEIGHT: Record<SelectSize, string> = {\n \"48\": \"h-12\",\n \"40\": \"h-10\",\n \"32\": \"h-8\",\n};\n\nconst TRIGGER_PADDING_X: Record<SelectSize, string> = {\n \"48\": \"px-4\",\n \"40\": \"px-4\",\n \"32\": \"px-3\",\n};\n\nconst TRIGGER_GAP: Record<SelectSize, string> = {\n \"48\": \"gap-3\",\n \"40\": \"gap-3\",\n \"32\": \"gap-2\",\n};\n\nconst TRIGGER_TYPOGRAPHY: Record<SelectSize, string> = {\n \"48\": \"typography-body-default-16px-regular\",\n \"40\": \"typography-body-default-16px-regular\",\n \"32\": \"typography-body-small-14px-regular\",\n};\n\nexport interface SelectProps extends Omit<SelectPrimitive.SelectProps, \"dir\"> {\n /** Label text displayed above the trigger. Also used as the accessible name. */\n label?: string;\n /** Accessible name applied directly to the trigger button when no visible `label` is provided. */\n \"aria-label\"?: string;\n /** ID of an external element that labels the trigger button. */\n \"aria-labelledby\"?: string;\n /** Helper text displayed below the trigger. Replaced by `errorMessage` when `error` is `true`. */\n helperText?: string;\n /** Height of the select field in pixels. @default \"48\" */\n size?: SelectSize;\n /** Whether the field is in an error state. @default false */\n error?: boolean;\n /** Error message displayed below the trigger. Shown instead of `helperText` when `error` is `true`. */\n errorMessage?: string;\n /** Placeholder shown when no value is selected. */\n placeholder?: string;\n /** Icon element displayed at the left side of the trigger. */\n leftIcon?: React.ReactNode;\n /** Whether the field stretches to fill its container width. @default false */\n fullWidth?: boolean;\n /** Wraps the `className` of the outermost container div. */\n className?: string;\n /** HTML `id` applied to the trigger button. Auto-generated if omitted. */\n id?: string;\n}\n\n/**\n * A select field with optional label, helper/error text, and an icon slot,\n * built on Radix UI Select for full accessibility and keyboard navigation.\n *\n * Pair with {@link SelectContent} and {@link SelectItem} to provide options.\n *\n * @example\n * ```tsx\n * <Select label=\"Country\" placeholder=\"Select a country\">\n * <SelectContent>\n * <SelectItem value=\"us\">United States</SelectItem>\n * <SelectItem value=\"uk\">United Kingdom</SelectItem>\n * </SelectContent>\n * </Select>\n * ```\n */\nexport const Select = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Trigger>,\n SelectProps\n>(\n (\n {\n label,\n helperText,\n size = \"48\",\n error = false,\n errorMessage,\n placeholder,\n leftIcon,\n fullWidth = false,\n className,\n id,\n disabled,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const triggerId = id ?? generatedId;\n const helperTextId = `${triggerId}-helper`;\n const bottomText = error && errorMessage ? errorMessage : helperText;\n\n return (\n <SelectContext.Provider value={{ size, error, disabled }}>\n <div\n className={cn(\"flex flex-col\", fullWidth && \"w-full\", className)}\n data-disabled={disabled ? \"\" : undefined}\n data-error={error ? \"\" : undefined}\n >\n {label && (\n <label\n htmlFor={triggerId}\n className=\"typography-description-12px-semibold pb-2 text-content-primary\"\n >\n {label}\n </label>\n )}\n\n <SelectPrimitive.Root disabled={disabled} {...props}>\n <SelectPrimitive.Trigger\n ref={ref}\n id={triggerId}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={bottomText ? helperTextId : undefined}\n aria-invalid={error || undefined}\n className={cn(\n \"flex w-full cursor-pointer items-center justify-between rounded-sm border bg-inputs-inputs-primary outline-none motion-safe:transition-colors focus-visible:shadow-focus-ring\",\n TRIGGER_HEIGHT[size],\n TRIGGER_PADDING_X[size],\n TRIGGER_GAP[size],\n TRIGGER_TYPOGRAPHY[size],\n error ? \"border-error-content\" : \"border-border-primary\",\n !disabled &&\n !error &&\n \"hover:border-neutral-alphas-400 data-[state=open]:border-neutral-alphas-400\",\n disabled && \"cursor-not-allowed opacity-50\",\n )}\n >\n <div className=\"flex min-w-0 items-center gap-2\">\n {leftIcon && (\n <span\n className=\"flex size-5 shrink-0 items-center justify-center text-content-secondary\"\n data-testid=\"left-icon\"\n >\n {leftIcon}\n </span>\n )}\n <span className=\"min-w-0 flex-1 truncate text-left text-content-primary [&>[data-placeholder]]:text-content-tertiary\">\n <SelectPrimitive.Value placeholder={placeholder} />\n </span>\n </div>\n\n <SelectPrimitive.Icon asChild>\n <ChevronDownIcon />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n\n {children}\n </SelectPrimitive.Root>\n\n {bottomText && (\n <p\n id={helperTextId}\n className={cn(\n \"typography-description-12px-regular px-2 pt-1 pb-0.5\",\n error ? \"text-error-content\" : \"text-content-secondary\",\n )}\n >\n {bottomText}\n </p>\n )}\n </div>\n </SelectContext.Provider>\n );\n },\n);\n\nSelect.displayName = \"Select\";\n\nexport interface SelectContentProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> {}\n\n/**\n * The dropdown panel rendered inside a portal. Place {@link SelectItem} elements\n * (and optionally {@link SelectGroup} / {@link SelectLabel}) as children.\n */\nexport const SelectContent = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Content>,\n SelectContentProps\n>(\n (\n {\n className,\n children,\n position = \"popper\",\n sideOffset = 4,\n collisionPadding = FLOATING_CONTENT_COLLISION_PADDING,\n style,\n ...props\n },\n ref,\n ) => (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n ref={ref}\n position={position}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n className={cn(\n \"relative w-max min-w-(--radix-select-trigger-width) max-w-(--radix-select-content-available-width) overflow-hidden rounded-sm border border-neutral-alphas-200 bg-background-primary text-content-primary shadow-[0_4px_16px_rgba(0,0,0,0.10)]\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n \"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95\",\n \"data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2\",\n className,\n )}\n {...props}\n >\n <SelectPrimitive.Viewport className=\"max-h-[var(--radix-select-content-available-height)] overflow-y-auto p-1\">\n {children}\n </SelectPrimitive.Viewport>\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n ),\n);\n\nSelectContent.displayName = \"SelectContent\";\n\nexport interface SelectItemProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> {}\n\n/**\n * An individual option inside {@link SelectContent}.\n */\nexport const SelectItem = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Item>,\n SelectItemProps\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n \"typography-body-default-16px-regular relative flex w-full cursor-pointer select-none items-center gap-2 rounded-xs py-2 pr-2 pl-3 text-content-primary outline-none\",\n \"focus:bg-neutral-alphas-100 data-disabled:pointer-events-none data-disabled:opacity-50\",\n className,\n )}\n {...props}\n >\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n <SelectPrimitive.ItemIndicator className=\"ml-auto flex size-4 shrink-0 items-center justify-center\">\n <CheckIcon className=\"size-4 text-content-primary\" />\n </SelectPrimitive.ItemIndicator>\n </SelectPrimitive.Item>\n));\n\nSelectItem.displayName = \"SelectItem\";\n\n/** Props for {@link SelectGroup}. */\nexport type SelectGroupProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Group>;\n\n/**\n * Groups related {@link SelectItem} elements under a {@link SelectLabel}.\n */\nexport const SelectGroup = SelectPrimitive.Group;\nSelectGroup.displayName = \"SelectGroup\";\n\nexport interface SelectLabelProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label> {}\n\n/**\n * A non-interactive label shown above a {@link SelectGroup}.\n */\nexport const SelectLabel = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Label>,\n SelectLabelProps\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn(\n \"typography-description-12px-semibold px-3 py-1.5 text-content-secondary\",\n className,\n )}\n {...props}\n />\n));\n\nSelectLabel.displayName = \"SelectLabel\";\n\nexport interface SelectSeparatorProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator> {}\n\n/** A horizontal rule that visually separates groups in {@link SelectContent}. */\nexport const SelectSeparator = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Separator>,\n SelectSeparatorProps\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn(\"-mx-1 my-1 h-px bg-neutral-alphas-200\", className)}\n {...props}\n />\n));\n\nSelectSeparator.displayName = \"SelectSeparator\";\n"],"names":["React","jsx","jsxs","cn","SelectPrimitive","ChevronDownIcon","FLOATING_CONTENT_COLLISION_PADDING","CheckIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAM,gBAAgBA,iBAAM,cAAkC;AAAA,EAC5D,MAAM;AAAA,EACN,OAAO;AACT,CAAC;AAED,MAAM,iBAA6C;AAAA,EACjD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAE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AM,WAGnC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACG,2BAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAWD,GAAAA,GAAG,yCAAyC,SAAS;AAAA,IAC/D,GAAG;AAAA,EAAA;AACN,CACD;AAED,gBAAgB,cAAc;;;;;;;"}
1
+ {"version":3,"file":"Select.cjs","sources":["../../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as SelectPrimitive from \"@radix-ui/react-select\";\nimport * as React from \"react\";\nimport { cn } from \"@/utils/cn\";\nimport { FLOATING_CONTENT_COLLISION_PADDING } from \"@/utils/floatingContentCollisionPadding\";\nimport { CheckIcon } from \"../Icons/CheckIcon\";\nimport { ChevronDownIcon } from \"../Icons/ChevronDownIcon\";\n\n/** Select field height in pixels. */\nexport type SelectSize = \"48\" | \"40\" | \"32\";\n\ntype SelectContextValue = {\n size: SelectSize;\n error: boolean;\n disabled?: boolean;\n};\n\nconst SelectContext = React.createContext<SelectContextValue>({\n size: \"48\",\n error: false,\n});\n\nconst TRIGGER_HEIGHT: Record<SelectSize, string> = {\n \"48\": \"h-12\",\n \"40\": \"h-10\",\n \"32\": \"h-8\",\n};\n\nconst TRIGGER_PADDING_X: Record<SelectSize, string> = {\n \"48\": \"px-4\",\n \"40\": \"px-4\",\n \"32\": \"px-3\",\n};\n\nconst TRIGGER_GAP: Record<SelectSize, string> = {\n \"48\": \"gap-3\",\n \"40\": \"gap-3\",\n \"32\": \"gap-2\",\n};\n\nconst TRIGGER_TYPOGRAPHY: Record<SelectSize, string> = {\n \"48\": \"typography-body-default-16px-regular\",\n \"40\": \"typography-body-default-16px-regular\",\n \"32\": \"typography-body-small-14px-regular\",\n};\n\nexport interface SelectProps extends Omit<SelectPrimitive.SelectProps, \"dir\"> {\n /** Label text displayed above the trigger. Also used as the accessible name. */\n label?: string;\n /** Accessible name applied directly to the trigger button when no visible `label` is provided. */\n \"aria-label\"?: string;\n /** ID of an external element that labels the trigger button. */\n \"aria-labelledby\"?: string;\n /** Helper text displayed below the trigger. Replaced by `errorMessage` when `error` is `true`. */\n helperText?: string;\n /** Height of the select field in pixels. @default \"48\" */\n size?: SelectSize;\n /** Whether the field is in an error state. @default false */\n error?: boolean;\n /** Error message displayed below the trigger. Shown instead of `helperText` when `error` is `true`. */\n errorMessage?: string;\n /** Placeholder shown when no value is selected. */\n placeholder?: string;\n /** Icon element displayed at the left side of the trigger. */\n leftIcon?: React.ReactNode;\n /** Whether the field stretches to fill its container width. @default false */\n fullWidth?: boolean;\n /** Wraps the `className` of the outermost container div. */\n className?: string;\n /** HTML `id` applied to the trigger button. Auto-generated if omitted. */\n id?: string;\n}\n\n/**\n * A select field with optional label, helper/error text, and an icon slot,\n * built on Radix UI Select for full accessibility and keyboard navigation.\n *\n * Pair with {@link SelectContent} and {@link SelectItem} to provide options.\n *\n * @example\n * ```tsx\n * <Select label=\"Country\" placeholder=\"Select a country\">\n * <SelectContent>\n * <SelectItem value=\"us\">United States</SelectItem>\n * <SelectItem value=\"uk\">United Kingdom</SelectItem>\n * </SelectContent>\n * </Select>\n * ```\n */\nexport const Select = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Trigger>,\n SelectProps\n>(\n (\n {\n label,\n helperText,\n size = \"48\",\n error = false,\n errorMessage,\n placeholder,\n leftIcon,\n fullWidth = false,\n className,\n id,\n disabled,\n children,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const triggerId = id ?? generatedId;\n const helperTextId = `${triggerId}-helper`;\n const bottomText = error && errorMessage ? errorMessage : helperText;\n\n return (\n <SelectContext.Provider value={{ size, error, disabled }}>\n <div\n className={cn(\"flex flex-col\", fullWidth && \"w-full\", className)}\n data-disabled={disabled ? \"\" : undefined}\n data-error={error ? \"\" : undefined}\n >\n {label && (\n <label\n htmlFor={triggerId}\n className=\"typography-description-12px-semibold pb-2 text-content-primary\"\n >\n {label}\n </label>\n )}\n\n <SelectPrimitive.Root disabled={disabled} {...props}>\n <SelectPrimitive.Trigger\n ref={ref}\n id={triggerId}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n aria-describedby={bottomText ? helperTextId : undefined}\n aria-invalid={error || undefined}\n className={cn(\n \"flex w-full cursor-pointer items-center justify-between rounded-sm border bg-inputs-inputs-primary outline-none focus-visible:shadow-focus-ring motion-safe:transition-colors\",\n TRIGGER_HEIGHT[size],\n TRIGGER_PADDING_X[size],\n TRIGGER_GAP[size],\n TRIGGER_TYPOGRAPHY[size],\n error ? \"border-error-content\" : \"border-border-primary\",\n !disabled &&\n !error &&\n \"hover:border-neutral-alphas-400 data-[state=open]:border-neutral-alphas-400\",\n disabled && \"cursor-not-allowed opacity-50\",\n )}\n >\n <div className=\"flex min-w-0 items-center gap-2\">\n {leftIcon && (\n <span\n className=\"flex size-5 shrink-0 items-center justify-center text-content-secondary\"\n data-testid=\"left-icon\"\n >\n {leftIcon}\n </span>\n )}\n <span className=\"min-w-0 flex-1 truncate text-left text-content-primary [&>[data-placeholder]]:text-content-tertiary\">\n <SelectPrimitive.Value placeholder={placeholder} />\n </span>\n </div>\n\n <SelectPrimitive.Icon asChild>\n <ChevronDownIcon />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n\n {children}\n </SelectPrimitive.Root>\n\n {bottomText && (\n <p\n id={helperTextId}\n className={cn(\n \"typography-description-12px-regular px-2 pt-1 pb-0.5\",\n error ? \"text-error-content\" : \"text-content-secondary\",\n )}\n >\n {bottomText}\n </p>\n )}\n </div>\n </SelectContext.Provider>\n );\n },\n);\n\nSelect.displayName = \"Select\";\n\nexport interface SelectContentProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> {}\n\n/**\n * The dropdown panel rendered inside a portal. Place {@link SelectItem} elements\n * (and optionally {@link SelectGroup} / {@link SelectLabel}) as children.\n */\nexport const SelectContent = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Content>,\n SelectContentProps\n>(\n (\n {\n className,\n children,\n position = \"popper\",\n sideOffset = 4,\n collisionPadding = FLOATING_CONTENT_COLLISION_PADDING,\n style,\n ...props\n },\n ref,\n ) => (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Content\n ref={ref}\n position={position}\n sideOffset={sideOffset}\n collisionPadding={collisionPadding}\n style={{ zIndex: \"var(--fanvue-ui-portal-z-index, 50)\", ...style }}\n className={cn(\n \"relative w-max min-w-(--radix-select-trigger-width) max-w-(--radix-select-content-available-width) overflow-hidden rounded-sm border border-neutral-alphas-200 bg-background-primary text-content-primary shadow-[0_4px_16px_rgba(0,0,0,0.10)]\",\n \"data-[state=closed]:animate-out data-[state=open]:animate-in\",\n \"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n \"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95\",\n \"data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2\",\n className,\n )}\n {...props}\n >\n <SelectPrimitive.Viewport className=\"max-h-[var(--radix-select-content-available-height)] overflow-y-auto p-1\">\n {children}\n </SelectPrimitive.Viewport>\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n ),\n);\n\nSelectContent.displayName = \"SelectContent\";\n\n/** Dropdown row height in pixels, matching the V2 Menu Item spec. */\nexport type SelectItemSize = \"40\" | \"32\";\n\nconst ITEM_SIZE_CLASSES: Record<SelectItemSize, string> = {\n \"40\": \"min-h-10 py-2 typography-body-default-16px-regular\",\n \"32\": \"min-h-8 py-[7px] typography-body-small-14px-regular\",\n};\n\nconst ITEM_DESCRIPTION_TYPOGRAPHY: Record<SelectItemSize, string> = {\n \"40\": \"typography-body-small-14px-regular\",\n \"32\": \"typography-description-12px-regular\",\n};\n\nexport interface SelectItemProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> {\n /** Row height. Defaults to the parent {@link Select} size (`48`/`40` → `40`, `32` → `32`). */\n size?: SelectItemSize;\n /** Icon (or other node) rendered before the label. Ignored when {@link SelectItemProps.avatar} is set. */\n leadingIcon?: React.ReactNode;\n /**\n * Leading avatar rendered in place of {@link SelectItemProps.leadingIcon}, for rows\n * representing a person or account. Pass an `Avatar` sized to `24`. Takes precedence over `leadingIcon`.\n */\n avatar?: React.ReactNode;\n /** Optional secondary text rendered on a second line below the label. */\n description?: React.ReactNode;\n}\n\n/**\n * Whether a `ReactNode` will actually render. Excludes `null`/`undefined` and\n * booleans so short-circuit props (e.g. `description={cond && \"…\"}`) don't flip\n * the item into a two-line/avatar layout when they resolve to `false`.\n */\nfunction isRenderableNode(node: React.ReactNode): boolean {\n return node !== null && node !== undefined && typeof node !== \"boolean\";\n}\n\n/**\n * An individual option inside {@link SelectContent}, following the V2 Menu Item spec.\n *\n * Supports a leading icon or avatar, an optional two-line layout via `description`,\n * and the standard hover / selected / disabled states. The selected row is marked\n * with a trailing check indicator.\n *\n * @example\n * ```tsx\n * <SelectItem value=\"jane\" avatar={<Avatar size={24} fallback=\"JD\" />} description=\"Product designer\">\n * Jane Doe\n * </SelectItem>\n * ```\n */\nexport const SelectItem = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Item>,\n SelectItemProps\n>(({ className, children, size, leadingIcon, avatar, description, ...props }, ref) => {\n const { size: triggerSize } = React.useContext(SelectContext);\n const itemSize: SelectItemSize = size ?? (triggerSize === \"32\" ? \"32\" : \"40\");\n const hasDescription = isRenderableNode(description);\n const hasAvatar = isRenderableNode(avatar);\n const hasLeadingIcon = isRenderableNode(leadingIcon);\n\n return (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n \"group relative flex w-full cursor-pointer select-none gap-2 rounded-xs px-3 text-content-primary outline-none\",\n hasDescription ? \"items-start\" : \"items-center\",\n ITEM_SIZE_CLASSES[itemSize],\n hasAvatar && !hasDescription && itemSize === \"32\" && \"py-1\",\n \"focus:bg-neutral-alphas-50 data-highlighted:bg-neutral-alphas-50\",\n \"data-disabled:pointer-events-none data-disabled:text-content-disabled\",\n className,\n )}\n {...props}\n >\n {hasAvatar ? (\n <span className=\"shrink-0\">{avatar}</span>\n ) : (\n hasLeadingIcon &&\n (hasDescription ? (\n <span className=\"flex shrink-0 items-center pt-0.5 [&>svg]:size-4\">{leadingIcon}</span>\n ) : (\n <span className=\"flex shrink-0 items-center [&>svg]:size-4\">{leadingIcon}</span>\n ))\n )}\n\n {hasDescription ? (\n <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n <span className=\"truncate\">\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </span>\n <span\n className={cn(\n \"truncate text-content-secondary group-data-[disabled]:text-content-disabled\",\n ITEM_DESCRIPTION_TYPOGRAPHY[itemSize],\n )}\n >\n {description}\n </span>\n </span>\n ) : (\n <span className=\"min-w-0 flex-1 truncate\">\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </span>\n )}\n\n <SelectPrimitive.ItemIndicator\n className={cn(\n \"ml-auto flex size-4 shrink-0 items-center justify-center\",\n hasDescription && \"self-start\",\n )}\n >\n <CheckIcon className=\"size-4 text-content-primary group-data-[disabled]:text-content-disabled\" />\n </SelectPrimitive.ItemIndicator>\n </SelectPrimitive.Item>\n );\n});\n\nSelectItem.displayName = \"SelectItem\";\n\n/** Props for {@link SelectGroup}. */\nexport type SelectGroupProps = React.ComponentPropsWithoutRef<typeof SelectPrimitive.Group>;\n\n/**\n * Groups related {@link SelectItem} elements under a {@link SelectLabel}.\n */\nexport const SelectGroup = SelectPrimitive.Group;\nSelectGroup.displayName = \"SelectGroup\";\n\nexport interface SelectLabelProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label> {}\n\n/**\n * A non-interactive label shown above a {@link SelectGroup}.\n */\nexport const SelectLabel = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Label>,\n SelectLabelProps\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn(\n \"typography-description-12px-semibold px-3 py-1.5 text-content-secondary\",\n className,\n )}\n {...props}\n />\n));\n\nSelectLabel.displayName = \"SelectLabel\";\n\nexport interface SelectSeparatorProps\n extends React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator> {}\n\n/** A horizontal rule that visually separates groups in {@link SelectContent}. */\nexport const SelectSeparator = React.forwardRef<\n React.ComponentRef<typeof SelectPrimitive.Separator>,\n SelectSeparatorProps\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn(\"-mx-1 my-1 h-px bg-neutral-alphas-200\", className)}\n {...props}\n />\n));\n\nSelectSeparator.displayName = \"SelectSeparator\";\n"],"names":["React","jsx","jsxs","cn","SelectPrimitive","ChevronDownIcon","FLOATING_CONTENT_COLLISION_PADDING","CheckIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAM,gBAAgBA,iBAAM,cAAkC;AAAA,EAC5D,MAAM;AAAA,EACN,OAAO;AACT,CAAC;AAED,MAAM,iBAA6C;AAAA,EACjD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,oBAAgD;AAAA,EACpD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,cAA0C;AAAA,EAC9C,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,qBAAiD;AAAA,EACrD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AA6CO,MAAM,SAASA,iBAAM;AAAA,EAI1B,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,mBAAmB;AAAA,IACnB,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,cAAcA,iBAAM,MAAA;AAC1B,UAAM,YAAY,MAAM;AACxB,UAA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AC,QAAA,EAAK,WAAU,2BACd,yCAACG,2BAAgB,UAAhB,EAA0B,SAAA,CAAS,EAAA,CACtC;AAAA,QAGFH,2BAAAA;AAAAA,UAACG,2BAAgB;AAAA,UAAhB;AAAA,YACC,WAAWD,GAAAA;AAAAA,cACT;AAAA,cACA,kBAAkB;AAAA,YAAA;AAAA,YAGpB,UAAAF,2BAAAA,IAACM,UAAAA,WAAA,EAAU,WAAU,0EAAA,CAA0E;AAAA,UAAA;AAAA,QAAA;AAAA,MACjG;AAAA,IAAA;AAAA,EAAA;AAGN,CAAC;AAED,WAAW,cAAc;AAQlB,MAAM,cAAcH,2BAAgB;AAC3C,YAAY,cAAc;AAQnB,MAAM,cAAcJ,iBAAM,WAG/B,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACG,2BAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAWD,GAAAA;AAAAA,MACT;AAAA,MACA;AAAA,IAAA;AAAA,IAED,GAAG;AAAA,EAAA;AACN,CACD;AAED,YAAY,cAAc;AAMnB,MAAM,kBAAkBH,iBAAM,WAGnC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACG,2BAAgB;AAAA,EAAhB;AAAA,IACC;AAAA,IACA,WAAWD,GAAAA,GAAG,yCAAyC,SAAS;AAAA,IAC/D,GAAG;AAAA,EAAA;AACN,CACD;AAED,gBAAgB,cAAc;;;;;;;"}
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const jsxRuntime = require("react/jsx-runtime");
5
+ const React = require("react");
6
+ const cn = require("../../utils/cn.cjs");
7
+ const Button = require("../Button/Button.cjs");
8
+ function _interopNamespaceDefault(e) {
9
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
10
+ if (e) {
11
+ for (const k in e) {
12
+ if (k !== "default") {
13
+ const d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: () => e[k]
17
+ });
18
+ }
19
+ }
20
+ }
21
+ n.default = e;
22
+ return Object.freeze(n);
23
+ }
24
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
25
+ const OLD_PRICE_TYPOGRAPHY = {
26
+ "48": "typography-body-small-14px-regular",
27
+ "40": "typography-body-small-14px-regular",
28
+ "32": "typography-description-12px-regular"
29
+ };
30
+ function warnMissingAccessibleName(hasTextLabel, ariaLabel) {
31
+ if (process.env.NODE_ENV !== "production" && !hasTextLabel && !ariaLabel) {
32
+ console.warn(
33
+ "SubscribeButton: no accessible name could be derived from a string `children`. Pass an `aria-label` so the action and price are announced."
34
+ );
35
+ }
36
+ }
37
+ const SubscribeButton = React__namespace.forwardRef(
38
+ ({ variant = "primary", size = "48", price, discount, children = "Join now", ...props }, ref) => {
39
+ const labelText = typeof children === "string" ? children : void 0;
40
+ warnMissingAccessibleName(Boolean(labelText?.trim()), props["aria-label"]);
41
+ const accessibleName = props["aria-label"] ?? [labelText, price, discount ? `was ${discount}` : null].filter(Boolean).join(", ");
42
+ return /* @__PURE__ */ jsxRuntime.jsxs(Button.Button, { ref, variant, size, ...props, "aria-label": accessibleName, children: [
43
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 flex-1 truncate text-left", children }),
44
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex shrink-0 items-center gap-2", "aria-hidden": "true", children: [
45
+ discount && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn.cn(OLD_PRICE_TYPOGRAPHY[size], "line-through"), children: discount }),
46
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: price })
47
+ ] })
48
+ ] });
49
+ }
50
+ );
51
+ SubscribeButton.displayName = "SubscribeButton";
52
+ exports.SubscribeButton = SubscribeButton;
53
+ //# sourceMappingURL=SubscribeButton.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubscribeButton.cjs","sources":["../../../../src/components/SubscribeButton/SubscribeButton.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button, type ButtonProps } from \"../Button/Button\";\n\n/** Visual style variant of the subscribe button. Mirrors the V2 Subscribe Button \"Type\" set (`brand` is Figma's \"Upsell\"). */\nexport type SubscribeButtonVariant = \"primary\" | \"secondary\" | \"tertiary\" | \"outline\" | \"brand\";\n\n/** Height of the subscribe button in pixels. */\nexport type SubscribeButtonSize = \"48\" | \"40\" | \"32\";\n\nexport interface SubscribeButtonProps\n extends Omit<\n ButtonProps,\n \"variant\" | \"size\" | \"price\" | \"discount\" | \"leftIcon\" | \"rightIcon\" | \"asChild\"\n > {\n /** Visual style variant. `brand` is the Figma \"Upsell\" (green) type. @default \"primary\" */\n variant?: SubscribeButtonVariant;\n /** Height of the button in pixels. @default \"48\" */\n size?: SubscribeButtonSize;\n /** Current price shown on the trailing side (e.g. `\"$9.99/mo\"`). */\n price: string;\n /** Previous price rendered struck-through before {@link SubscribeButtonProps.price}. */\n discount?: string;\n /** Leading action label. @default \"Join now\" */\n children?: React.ReactNode;\n}\n\nconst OLD_PRICE_TYPOGRAPHY: Record<SubscribeButtonSize, string> = {\n \"48\": \"typography-body-small-14px-regular\",\n \"40\": \"typography-body-small-14px-regular\",\n \"32\": \"typography-description-12px-regular\",\n};\n\nfunction warnMissingAccessibleName(hasTextLabel: boolean, ariaLabel?: string) {\n if (process.env.NODE_ENV !== \"production\" && !hasTextLabel && !ariaLabel) {\n console.warn(\n \"SubscribeButton: no accessible name could be derived from a string `children`. Pass an `aria-label` so the action and price are announced.\",\n );\n }\n}\n\n/**\n * A subscription / purchase button pairing an action label with the current\n * price and an optional struck-through previous price. Built on {@link Button},\n * so it inherits the same variants, sizes, `negative` dark-surface treatment,\n * `fullWidth`, loading, and disabled behaviour.\n *\n * The accessible name defaults to the label plus pricing (e.g. `\"Join now, $9.99,\n * was $19.99\"`); pass `aria-label` to override.\n *\n * @example\n * ```tsx\n * <SubscribeButton price=\"$9.99/mo\" discount=\"$19.99\" variant=\"brand\" fullWidth>\n * Join now\n * </SubscribeButton>\n * ```\n */\nexport const SubscribeButton = React.forwardRef<HTMLButtonElement, SubscribeButtonProps>(\n ({ variant = \"primary\", size = \"48\", price, discount, children = \"Join now\", ...props }, ref) => {\n const labelText = typeof children === \"string\" ? children : undefined;\n warnMissingAccessibleName(Boolean(labelText?.trim()), props[\"aria-label\"]);\n\n const accessibleName =\n props[\"aria-label\"] ??\n [labelText, price, discount ? `was ${discount}` : null].filter(Boolean).join(\", \");\n\n return (\n <Button ref={ref} variant={variant} size={size} {...props} aria-label={accessibleName}>\n <span className=\"min-w-0 flex-1 truncate text-left\">{children}</span>\n <span className=\"flex shrink-0 items-center gap-2\" aria-hidden=\"true\">\n {discount && (\n <span className={cn(OLD_PRICE_TYPOGRAPHY[size], \"line-through\")}>{discount}</span>\n )}\n <span>{price}</span>\n </span>\n </Button>\n );\n },\n);\n\nSubscribeButton.displayName = \"SubscribeButton\";\n"],"names":["React","jsxs","Button","jsx","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,uBAA4D;AAAA,EAChE,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,SAAS,0BAA0B,cAAuB,WAAoB;AAC5E,MAAI,QAAQ,IAAI,aAAa,gBAAgB,CAAC,gBAAgB,CAAC,WAAW;AACxE,YAAQ;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ;AACF;AAkBO,MAAM,kBAAkBA,iBAAM;AAAA,EACnC,CAAC,EAAE,UAAU,WAAW,OAAO,MAAM,OAAO,UAAU,WAAW,YAAY,GAAG,MAAA,GAAS,QAAQ;AAC/F,UAAM,YAAY,OAAO,aAAa,WAAW,WAAW;AAC5D,8BAA0B,QAAQ,WAAW,KAAA,CAAM,GAAG,MAAM,YAAY,CAAC;AAEzE,UAAM,iBACJ,MAAM,YAAY,KAClB,CAAC,WAAW,OAAO,WAAW,OAAO,QAAQ,KAAK,IAAI,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI;AAEnF,WACEC,gCAACC,OAAAA,UAAO,KAAU,SAAkB,MAAa,GAAG,OAAO,cAAY,gBACrE,UAAA;AAAA,MAAAC,2BAAAA,IAAC,QAAA,EAAK,WAAU,qCAAqC,SAAA,CAAS;AAAA,MAC9DF,2BAAAA,KAAC,QAAA,EAAK,WAAU,oCAAmC,eAAY,QAC5D,UAAA;AAAA,QAAA,YACCE,2BAAAA,IAAC,UAAK,WAAWC,GAAAA,GAAG,qBAAqB,IAAI,GAAG,cAAc,GAAI,UAAA,SAAA,CAAS;AAAA,QAE7ED,2BAAAA,IAAC,UAAM,UAAA,MAAA,CAAM;AAAA,MAAA,EAAA,CACf;AAAA,IAAA,GACF;AAAA,EAEJ;AACF;AAEA,gBAAgB,cAAc;;"}
@@ -0,0 +1,305 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const jsxRuntime = require("react/jsx-runtime");
5
+ const React = require("react");
6
+ const audioWaveform = require("../../utils/audioWaveform.cjs");
7
+ const cn = require("../../utils/cn.cjs");
8
+ const useAudioPlayback = require("../../utils/useAudioPlayback.cjs");
9
+ const useFittedBarCount = require("../../utils/useFittedBarCount.cjs");
10
+ const useWaveformPeaks = require("../../utils/useWaveformPeaks.cjs");
11
+ const useWaveformSeek = require("../../utils/useWaveformSeek.cjs");
12
+ const IconButton = require("../IconButton/IconButton.cjs");
13
+ const CloseIcon = require("../Icons/CloseIcon.cjs");
14
+ const PauseIcon = require("../Icons/PauseIcon.cjs");
15
+ const PlayIcon = require("../Icons/PlayIcon.cjs");
16
+ function _interopNamespaceDefault(e) {
17
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
18
+ if (e) {
19
+ for (const k in e) {
20
+ if (k !== "default") {
21
+ const d = Object.getOwnPropertyDescriptor(e, k);
22
+ Object.defineProperty(n, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: () => e[k]
25
+ });
26
+ }
27
+ }
28
+ }
29
+ n.default = e;
30
+ return Object.freeze(n);
31
+ }
32
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
33
+ const DEFAULT_WAVEFORM = [
34
+ 0.15,
35
+ 0.46,
36
+ 0.85,
37
+ 0.23,
38
+ 1,
39
+ 0.85,
40
+ 0.62,
41
+ 0.62,
42
+ 0.62,
43
+ 0.85,
44
+ 0.85,
45
+ 0.62,
46
+ 0.62,
47
+ 1,
48
+ 1,
49
+ 0.62,
50
+ 0.62,
51
+ 0.62,
52
+ 0.23,
53
+ 0.23,
54
+ 0.15,
55
+ 0.46,
56
+ 0.85,
57
+ 0.23,
58
+ 1,
59
+ 0.46,
60
+ 0.85,
61
+ 0.62,
62
+ 0.23,
63
+ 0.23,
64
+ 0.62,
65
+ 0.62,
66
+ 0.85,
67
+ 0.85,
68
+ 0.62,
69
+ 0.62,
70
+ 0.85,
71
+ 1,
72
+ 0.85,
73
+ 1,
74
+ 0.62,
75
+ 0.62,
76
+ 0.62,
77
+ 0.23,
78
+ 0.23,
79
+ 0.62,
80
+ 0.23,
81
+ 0.23,
82
+ 0.23,
83
+ 0.62,
84
+ 0.85,
85
+ 0.62,
86
+ 0.85,
87
+ 1,
88
+ 0.85,
89
+ 0.85,
90
+ 1,
91
+ 0.85,
92
+ 0.23,
93
+ 0.23,
94
+ 0.23,
95
+ 0.46,
96
+ 0.62,
97
+ 0.23,
98
+ 0.23
99
+ ];
100
+ const MIN_BAR_HEIGHT = 4;
101
+ const MAX_BAR_HEIGHT = {
102
+ default: 26,
103
+ small: 16
104
+ };
105
+ const CONTROL_SIZE = {
106
+ default: "48",
107
+ small: "32"
108
+ };
109
+ const BAR_WIDTH_PX = 4;
110
+ const BAR_GAP_PX = 4;
111
+ const DEFAULT_BAR_COUNT = 40;
112
+ function activeBarClass(negative) {
113
+ return negative ? "bg-messages-waveform-listening-negative-active" : "bg-messages-waveform-listening-active";
114
+ }
115
+ function inactiveBarClass(negative) {
116
+ return negative ? "bg-messages-waveform-listening-negative-inactive" : "bg-messages-waveform-listening-inactive";
117
+ }
118
+ function restingBarClass(negative) {
119
+ return negative ? "bg-messages-waveform-listening-negative-default" : "bg-messages-waveform-default";
120
+ }
121
+ function WaveformBars({ bars, variant, size, negative, progress }) {
122
+ const hasProgress = progress !== void 0;
123
+ const activeCount = hasProgress ? Math.round(progress * bars.length) : 0;
124
+ const maxBarHeight = MAX_BAR_HEIGHT[size];
125
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: bars.map((amplitude, index) => {
126
+ const height = variant === "flat" ? MIN_BAR_HEIGHT : Math.max(MIN_BAR_HEIGHT, Math.round(amplitude * maxBarHeight));
127
+ const colorClass = !hasProgress ? restingBarClass(negative) : index < activeCount ? activeBarClass(negative) : inactiveBarClass(negative);
128
+ return /* @__PURE__ */ jsxRuntime.jsx(
129
+ "span",
130
+ {
131
+ className: cn.cn("w-1 shrink-0 rounded-[2px]", colorClass),
132
+ style: { height }
133
+ },
134
+ index
135
+ );
136
+ }) });
137
+ }
138
+ function WaveformMeta({ time, fileName, textColor }) {
139
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
140
+ time && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn.cn("typography-body-small-14px-regular shrink-0", textColor), children: time }),
141
+ fileName && /* @__PURE__ */ jsxRuntime.jsx(
142
+ "span",
143
+ {
144
+ className: cn.cn(
145
+ "typography-body-small-14px-regular min-w-0 max-w-[50%] truncate",
146
+ textColor
147
+ ),
148
+ children: fileName
149
+ }
150
+ )
151
+ ] });
152
+ }
153
+ const VoiceNote = React__namespace.forwardRef(
154
+ ({
155
+ className,
156
+ src,
157
+ duration,
158
+ waveform = DEFAULT_WAVEFORM,
159
+ variant = "default",
160
+ size = "default",
161
+ negative = false,
162
+ progress,
163
+ playing,
164
+ defaultPlaying = false,
165
+ onPlayPause,
166
+ onEnded,
167
+ time,
168
+ fileName,
169
+ showControls = true,
170
+ showTimestamp = true,
171
+ showRemove = false,
172
+ onRemove,
173
+ playButtonLabel,
174
+ removeButtonLabel = "Remove",
175
+ "aria-label": ariaLabel = "Voice note",
176
+ ...props
177
+ }, ref) => {
178
+ const isPlayer = src !== void 0;
179
+ const playback = useAudioPlayback.useAudioPlayback({
180
+ src,
181
+ duration,
182
+ playing,
183
+ defaultPlaying,
184
+ onEnded,
185
+ onPlay: React__namespace.useCallback(() => onPlayPause?.(true), [onPlayPause]),
186
+ onPause: React__namespace.useCallback(() => onPlayPause?.(false), [onPlayPause])
187
+ });
188
+ const decodedPeaks = useWaveformPeaks.useWaveformPeaks(src);
189
+ const [internalPlaying, setInternalPlaying] = React__namespace.useState(defaultPlaying);
190
+ const isControlled = playing !== void 0;
191
+ const trackRef = React__namespace.useRef(null);
192
+ const fittedBarCount = useFittedBarCount.useFittedBarCount(trackRef, {
193
+ barWidthPx: BAR_WIDTH_PX,
194
+ gapPx: BAR_GAP_PX,
195
+ fallback: DEFAULT_BAR_COUNT
196
+ });
197
+ const seekProps = useWaveformSeek.useWaveformSeek({
198
+ trackRef,
199
+ displayDuration: playback.displayDuration,
200
+ currentTime: playback.currentTime,
201
+ seekTo: playback.seekTo,
202
+ setSeeking: playback.setSeeking
203
+ });
204
+ const isPlaying = isPlayer ? playback.isPlaying : playing ?? internalPlaying;
205
+ const handlePlayPause = () => {
206
+ if (isPlayer) {
207
+ playback.toggle();
208
+ return;
209
+ }
210
+ const next = !isPlaying;
211
+ if (!isControlled) setInternalPlaying(next);
212
+ onPlayPause?.(next);
213
+ };
214
+ const bars = audioWaveform.resamplePeaks(isPlayer ? decodedPeaks : waveform, fittedBarCount);
215
+ const progressValue = isPlayer ? playback.progress : progress;
216
+ const textColor = negative ? "text-content-primary-inverted" : "text-content-primary";
217
+ const playerTime = playback.hasStarted ? playback.currentTime : playback.displayDuration;
218
+ const displayTime = isPlayer ? audioWaveform.formatTime(playerTime) : time;
219
+ const controlLabel = playButtonLabel ?? (isPlaying ? "Pause" : "Play");
220
+ const trackAria = isPlayer ? seekProps : { "aria-hidden": true };
221
+ return (
222
+ // biome-ignore lint/a11y/useSemanticElements: <fieldset> would break the public HTMLDivElement ref/props API
223
+ /* @__PURE__ */ jsxRuntime.jsxs(
224
+ "div",
225
+ {
226
+ ref,
227
+ role: "group",
228
+ "aria-label": ariaLabel,
229
+ className: cn.cn("flex items-center gap-3", size === "small" ? "h-8" : "h-12", className),
230
+ ...props,
231
+ children: [
232
+ showControls && /* @__PURE__ */ jsxRuntime.jsx(
233
+ IconButton.IconButton,
234
+ {
235
+ variant: "secondary",
236
+ size: CONTROL_SIZE[size],
237
+ negative,
238
+ icon: isPlaying ? /* @__PURE__ */ jsxRuntime.jsx(PauseIcon.PauseIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(PlayIcon.PlayIcon, {}),
239
+ "aria-label": controlLabel,
240
+ onClick: handlePlayPause
241
+ }
242
+ ),
243
+ /* @__PURE__ */ jsxRuntime.jsx(
244
+ "div",
245
+ {
246
+ ref: trackRef,
247
+ "data-testid": "voice-note-waveform",
248
+ className: cn.cn(
249
+ "flex h-full min-w-0 flex-1 items-center gap-1 overflow-hidden",
250
+ isPlayer && "cursor-pointer touch-none select-none focus-visible:shadow-focus-ring focus-visible:outline-none"
251
+ ),
252
+ ...trackAria,
253
+ children: /* @__PURE__ */ jsxRuntime.jsx(
254
+ WaveformBars,
255
+ {
256
+ bars,
257
+ variant,
258
+ size,
259
+ negative,
260
+ progress: progressValue
261
+ }
262
+ )
263
+ }
264
+ ),
265
+ /* @__PURE__ */ jsxRuntime.jsx(
266
+ WaveformMeta,
267
+ {
268
+ time: showTimestamp ? displayTime : void 0,
269
+ fileName,
270
+ textColor
271
+ }
272
+ ),
273
+ showRemove && /* @__PURE__ */ jsxRuntime.jsx(
274
+ IconButton.IconButton,
275
+ {
276
+ variant: "tertiary",
277
+ size: CONTROL_SIZE[size],
278
+ negative,
279
+ icon: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon.CloseIcon, {}),
280
+ "aria-label": removeButtonLabel,
281
+ onClick: onRemove
282
+ }
283
+ ),
284
+ isPlayer && // biome-ignore lint/a11y/useMediaCaption: a UI voice note / short recording, not narrated content needing captions
285
+ /* @__PURE__ */ jsxRuntime.jsx(
286
+ "audio",
287
+ {
288
+ ref: playback.audioRef,
289
+ src,
290
+ preload: "metadata",
291
+ className: "hidden",
292
+ onLoadedMetadata: playback.audioHandlers.onLoadedMetadata,
293
+ onTimeUpdate: playback.audioHandlers.onTimeUpdate,
294
+ onEnded: playback.audioHandlers.onEnded
295
+ }
296
+ )
297
+ ]
298
+ }
299
+ )
300
+ );
301
+ }
302
+ );
303
+ VoiceNote.displayName = "VoiceNote";
304
+ exports.VoiceNote = VoiceNote;
305
+ //# sourceMappingURL=VoiceNote.cjs.map