@fanvue/ui 3.30.0 → 3.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/AiButton/AiButton.cjs +8 -6
- package/dist/cjs/components/AiButton/AiButton.cjs.map +1 -1
- package/dist/cjs/components/ChatInput/ChatInput.cjs +6 -5
- package/dist/cjs/components/ChatInput/ChatInput.cjs.map +1 -1
- package/dist/cjs/components/DropdownMenu/DropdownMenuHeader.cjs +190 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuHeader.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs +213 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuItem.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderGroup.cjs +438 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderGroup.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs +197 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuReorderItem.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs +221 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuRoot.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs +128 -0
- package/dist/cjs/components/DropdownMenu/DropdownMenuSelectionItems.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/context.cjs +26 -0
- package/dist/cjs/components/DropdownMenu/context.cjs.map +1 -0
- package/dist/cjs/components/DropdownMenu/reorderShared.cjs +38 -0
- package/dist/cjs/components/DropdownMenu/reorderShared.cjs.map +1 -0
- package/dist/cjs/components/SwitchButton/SwitchButton.cjs +97 -0
- package/dist/cjs/components/SwitchButton/SwitchButton.cjs.map +1 -0
- package/dist/cjs/index.cjs +21 -12
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/AiButton/AiButton.mjs +8 -6
- package/dist/components/AiButton/AiButton.mjs.map +1 -1
- package/dist/components/ChatInput/ChatInput.mjs +2 -1
- package/dist/components/ChatInput/ChatInput.mjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenuHeader.mjs +173 -0
- package/dist/components/DropdownMenu/DropdownMenuHeader.mjs.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs +195 -0
- package/dist/components/DropdownMenu/DropdownMenuItem.mjs.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenuReorderGroup.mjs +421 -0
- package/dist/components/DropdownMenu/DropdownMenuReorderGroup.mjs.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs +180 -0
- package/dist/components/DropdownMenu/DropdownMenuReorderItem.mjs.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs +203 -0
- package/dist/components/DropdownMenu/DropdownMenuRoot.mjs.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs +110 -0
- package/dist/components/DropdownMenu/DropdownMenuSelectionItems.mjs.map +1 -0
- package/dist/components/DropdownMenu/context.mjs +9 -0
- package/dist/components/DropdownMenu/context.mjs.map +1 -0
- package/dist/components/DropdownMenu/reorderShared.mjs +21 -0
- package/dist/components/DropdownMenu/reorderShared.mjs.map +1 -0
- package/dist/components/SwitchButton/SwitchButton.mjs +80 -0
- package/dist/components/SwitchButton/SwitchButton.mjs.map +1 -0
- package/dist/index.d.ts +223 -1
- package/dist/index.mjs +10 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs +0 -598
- package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs.map +0 -1
- package/dist/components/DropdownMenu/DropdownMenu.mjs +0 -580
- package/dist/components/DropdownMenu/DropdownMenu.mjs.map +0 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { cn } from "../../utils/cn.mjs";
|
|
6
|
+
import { AddIcon } from "../Icons/AddIcon.mjs";
|
|
7
|
+
import { AIIcon } from "../Icons/AIIcon.mjs";
|
|
8
|
+
const sizeVariants = {
|
|
9
|
+
"24": "h-6 px-2 py-1 typography-description-12px-semibold",
|
|
10
|
+
"32": "h-8 px-3 py-[7px] typography-body-small-14px-semibold",
|
|
11
|
+
"40": "h-10 px-4 py-2 typography-body-default-16px-semibold"
|
|
12
|
+
};
|
|
13
|
+
const ICON_SLOT_CLASSES = "flex size-4 shrink-0 items-center justify-center";
|
|
14
|
+
const AI_PRESSED_FILL = "relative bg-buttons-ai-default before:pointer-events-none before:absolute before:inset-0 before:rounded-full before:p-px before:[background:linear-gradient(90deg,var(--color-buttons-ai-stroke-end)_0%,var(--color-buttons-ai-stroke-start)_50%,var(--color-buttons-ai-stroke-end)_100%)] before:[mask:linear-gradient(#000_0_0)_content-box_exclude,linear-gradient(#000_0_0)]";
|
|
15
|
+
const SwitchButton = React.forwardRef(
|
|
16
|
+
({
|
|
17
|
+
label,
|
|
18
|
+
size = "32",
|
|
19
|
+
variant = "default",
|
|
20
|
+
pressed: pressedProp,
|
|
21
|
+
defaultPressed = false,
|
|
22
|
+
onPressedChange,
|
|
23
|
+
showLeftIcon = false,
|
|
24
|
+
showRightIcon = false,
|
|
25
|
+
leftIcon,
|
|
26
|
+
rightIcon,
|
|
27
|
+
type = "button",
|
|
28
|
+
className,
|
|
29
|
+
disabled = false,
|
|
30
|
+
onClick,
|
|
31
|
+
...props
|
|
32
|
+
}, ref) => {
|
|
33
|
+
const [pressed = false, setPressed] = useControllableState({
|
|
34
|
+
prop: pressedProp,
|
|
35
|
+
defaultProp: defaultPressed,
|
|
36
|
+
onChange: onPressedChange
|
|
37
|
+
});
|
|
38
|
+
const isAi = variant === "ai";
|
|
39
|
+
const leading = isAi ? /* @__PURE__ */ jsx(AIIcon, { size: 16, filled: true }) : showLeftIcon ? leftIcon ?? /* @__PURE__ */ jsx(AddIcon, { size: 16 }) : void 0;
|
|
40
|
+
const trailing = !isAi && showRightIcon ? rightIcon ?? /* @__PURE__ */ jsx(AddIcon, { size: 16 }) : void 0;
|
|
41
|
+
return /* @__PURE__ */ jsxs(
|
|
42
|
+
"button",
|
|
43
|
+
{
|
|
44
|
+
ref,
|
|
45
|
+
type,
|
|
46
|
+
disabled,
|
|
47
|
+
"aria-pressed": pressed,
|
|
48
|
+
"data-state": pressed ? "on" : "off",
|
|
49
|
+
onClick: (event) => {
|
|
50
|
+
onClick?.(event);
|
|
51
|
+
if (event.defaultPrevented) return;
|
|
52
|
+
setPressed(!pressed);
|
|
53
|
+
},
|
|
54
|
+
className: cn(
|
|
55
|
+
"inline-flex w-fit shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-full",
|
|
56
|
+
"motion-safe:transition-colors motion-safe:duration-150",
|
|
57
|
+
"focus-visible:shadow-focus-ring focus-visible:outline-none",
|
|
58
|
+
sizeVariants[size],
|
|
59
|
+
!disabled && "cursor-pointer",
|
|
60
|
+
!disabled && !pressed && "text-content-primary hover:bg-buttons-switch-hover",
|
|
61
|
+
!disabled && pressed && !isAi && "bg-buttons-switch-active text-content-primary-inverted shadow-sm",
|
|
62
|
+
!disabled && pressed && isAi && `text-content-primary shadow-sm ${AI_PRESSED_FILL}`,
|
|
63
|
+
disabled && "cursor-not-allowed text-content-disabled",
|
|
64
|
+
className
|
|
65
|
+
),
|
|
66
|
+
...props,
|
|
67
|
+
children: [
|
|
68
|
+
leading && /* @__PURE__ */ jsx("span", { className: ICON_SLOT_CLASSES, "aria-hidden": "true", children: leading }),
|
|
69
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: label }),
|
|
70
|
+
trailing && /* @__PURE__ */ jsx("span", { className: ICON_SLOT_CLASSES, "aria-hidden": "true", children: trailing })
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
SwitchButton.displayName = "SwitchButton";
|
|
77
|
+
export {
|
|
78
|
+
SwitchButton
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=SwitchButton.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwitchButton.mjs","sources":["../../../src/components/SwitchButton/SwitchButton.tsx"],"sourcesContent":["import { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { AddIcon } from \"../Icons/AddIcon\";\nimport { AIIcon } from \"../Icons/AIIcon\";\n\n/** Height of the button in pixels. Matches {@link Button}'s scale. */\nexport type SwitchButtonSize = \"24\" | \"32\" | \"40\";\n\n/** Visual treatment of the button. */\nexport type SwitchButtonVariant = \"default\" | \"ai\";\n\n/** Padding and label typography per size, from `Spacing/Global` xs/sm/md. */\nconst sizeVariants: Record<SwitchButtonSize, string> = {\n \"24\": \"h-6 px-2 py-1 typography-description-12px-semibold\",\n \"32\": \"h-8 px-3 py-[7px] typography-body-small-14px-semibold\",\n \"40\": \"h-10 px-4 py-2 typography-body-default-16px-semibold\",\n};\n\n/** Glyphs are a flat 16px at every size, per the design. */\nconst ICON_SLOT_CLASSES = \"flex size-4 shrink-0 items-center justify-center\";\n\n/**\n * Pressed `\"ai\"` treatment, matching Figma node `16800:9469`: the translucent\n * `Buttons/AI/Default` fill, plus a 1px stroke whose three-stop gradient runs\n * `Stroke-End → Stroke-Start → Stroke-End` horizontally.\n *\n * The stroke is a masked overlay rather than a border because Figma draws it with\n * `strokeAlign: INSIDE` — a real border would add 2px to the hug width and push\n * every size past its Figma dimensions.\n *\n * Written as one literal string because Tailwind scans source text — composing it\n * from parts stops the utilities being generated at all.\n */\nconst AI_PRESSED_FILL =\n \"relative bg-buttons-ai-default before:pointer-events-none before:absolute before:inset-0 before:rounded-full before:p-px before:[background:linear-gradient(90deg,var(--color-buttons-ai-stroke-end)_0%,var(--color-buttons-ai-stroke-start)_50%,var(--color-buttons-ai-stroke-end)_100%)] before:[mask:linear-gradient(#000_0_0)_content-box_exclude,linear-gradient(#000_0_0)]\";\n\ninterface SwitchButtonBaseProps\n extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"type\" | \"children\"> {\n /** Visible text label, which is also the accessible name. */\n label: string;\n /** Height of the button in pixels. @default \"32\" */\n size?: SwitchButtonSize;\n /** On/off state for controlled usage. Pair with `onPressedChange`. */\n pressed?: boolean;\n /** Initial on/off state for uncontrolled usage. @default false */\n defaultPressed?: boolean;\n /** Fired with the next state each time the button flips. */\n onPressedChange?: (pressed: boolean) => void;\n /** Native button behaviour. @default \"button\" */\n type?: \"button\" | \"submit\" | \"reset\";\n}\n\n/**\n * Props for the `\"default\"` variant, the only one with icon slots. The two are\n * independent: pass either, neither, or both.\n */\nexport interface SwitchButtonDefaultProps extends SwitchButtonBaseProps {\n /** Visual treatment. @default \"default\" */\n variant?: \"default\";\n /** Show an icon before the label. @default false */\n showLeftIcon?: boolean;\n /** Show an icon after the label. @default false */\n showRightIcon?: boolean;\n /** Icon rendered before the label when `showLeftIcon` is set. @default `<AddIcon size={16} />` */\n leftIcon?: React.ReactNode;\n /** Icon rendered after the label when `showRightIcon` is set. @default `<AddIcon size={16} />` */\n rightIcon?: React.ReactNode;\n}\n\n/**\n * Props for the `\"ai\"` variant. Its leading sparkle is fixed and it has no\n * trailing slot, so neither icon prop is available here.\n */\nexport interface SwitchButtonAiProps extends SwitchButtonBaseProps {\n /** Visual treatment. */\n variant: \"ai\";\n /** Unavailable on `\"ai\"` — the leading sparkle is always shown and cannot be swapped. */\n showLeftIcon?: never;\n /** Unavailable on `\"ai\"` — this variant has no trailing icon slot. */\n showRightIcon?: never;\n /** Unavailable on `\"ai\"` — the leading sparkle is fixed. */\n leftIcon?: never;\n /** Unavailable on `\"ai\"` — this variant has no trailing icon slot. */\n rightIcon?: never;\n}\n\n/**\n * Props for {@link SwitchButton}. A discriminated union on `variant`, so the icon\n * slots only type-check on the `\"default\"` variant.\n */\nexport type SwitchButtonProps = SwitchButtonDefaultProps | SwitchButtonAiProps;\n\n/**\n * A labelled pill that switches one feature or mode on and off, for settings\n * panels, filter bars and tool options. Unlike {@link Switch} it names the thing\n * it controls, which suits contexts where the action needs spelling out.\n *\n * Rendered as a `<button>` carrying `aria-pressed` — the ARIA toggle-button\n * pattern — so it flips on click and on Enter or Space, and exposes\n * `data-state=\"on\" | \"off\"` for styling. Supports controlled (`pressed`) and\n * uncontrolled (`defaultPressed`) usage. The visible `label` is the accessible\n * name, so no `aria-label` is needed.\n *\n * For two or three mutually exclusive options, reach for {@link SegmentedControl}\n * instead: this button is independently on or off, not a choice between options.\n *\n * @example\n * ```tsx\n * <SwitchButton label=\"Hide sold out\" pressed={hidden} onPressedChange={setHidden} />\n * ```\n *\n * @example Independent icon flags, available on the default variant only\n * ```tsx\n * <SwitchButton size=\"40\" label=\"Add filter\" showLeftIcon showRightIcon />\n * ```\n *\n * @example The AI variant, whose sparkle is fixed\n * ```tsx\n * <SwitchButton variant=\"ai\" label=\"Smart replies\" defaultPressed />\n * ```\n */\nexport const SwitchButton = React.forwardRef<HTMLButtonElement, SwitchButtonProps>(\n (\n {\n label,\n size = \"32\",\n variant = \"default\",\n pressed: pressedProp,\n defaultPressed = false,\n onPressedChange,\n showLeftIcon = false,\n showRightIcon = false,\n leftIcon,\n rightIcon,\n type = \"button\",\n className,\n disabled = false,\n onClick,\n ...props\n },\n ref,\n ) => {\n const [pressed = false, setPressed] = useControllableState({\n prop: pressedProp,\n defaultProp: defaultPressed,\n onChange: onPressedChange,\n });\n\n const isAi = variant === \"ai\";\n const leading = isAi ? (\n <AIIcon size={16} filled />\n ) : showLeftIcon ? (\n (leftIcon ?? <AddIcon size={16} />)\n ) : undefined;\n const trailing = !isAi && showRightIcon ? (rightIcon ?? <AddIcon size={16} />) : undefined;\n\n return (\n <button\n ref={ref}\n type={type}\n disabled={disabled}\n aria-pressed={pressed}\n data-state={pressed ? \"on\" : \"off\"}\n onClick={(event) => {\n onClick?.(event);\n // A consumer cancelling the event, typically to stop a `type=\"submit\"`\n // button submitting, means the interaction did not happen, so the state\n // must not flip either.\n if (event.defaultPrevented) return;\n setPressed(!pressed);\n }}\n className={cn(\n \"inline-flex w-fit shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-full\",\n \"motion-safe:transition-colors motion-safe:duration-150\",\n \"focus-visible:shadow-focus-ring focus-visible:outline-none\",\n sizeVariants[size],\n !disabled && \"cursor-pointer\",\n !disabled && !pressed && \"text-content-primary hover:bg-buttons-switch-hover\",\n !disabled &&\n pressed &&\n !isAi &&\n \"bg-buttons-switch-active text-content-primary-inverted shadow-sm\",\n !disabled && pressed && isAi && `text-content-primary shadow-sm ${AI_PRESSED_FILL}`,\n disabled && \"cursor-not-allowed text-content-disabled\",\n className,\n )}\n {...props}\n >\n {leading && (\n <span className={ICON_SLOT_CLASSES} aria-hidden=\"true\">\n {leading}\n </span>\n )}\n <span className=\"min-w-0 truncate\">{label}</span>\n {trailing && (\n <span className={ICON_SLOT_CLASSES} aria-hidden=\"true\">\n {trailing}\n </span>\n )}\n </button>\n );\n },\n);\n\nSwitchButton.displayName = \"SwitchButton\";\n"],"names":[],"mappings":";;;;;;;AAaA,MAAM,eAAiD;AAAA,EACrD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAGA,MAAM,oBAAoB;AAc1B,MAAM,kBACJ;AAuFK,MAAM,eAAe,MAAM;AAAA,EAChC,CACE;AAAA,IACE;AAAA,IACA,OAAO;AAAA,IACP,UAAU;AAAA,IACV,SAAS;AAAA,IACT,iBAAiB;AAAA,IACjB;AAAA,IACA,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,WAAW;AAAA,IACX;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,CAAC,UAAU,OAAO,UAAU,IAAI,qBAAqB;AAAA,MACzD,MAAM;AAAA,MACN,aAAa;AAAA,MACb,UAAU;AAAA,IAAA,CACX;AAED,UAAM,OAAO,YAAY;AACzB,UAAM,UAAU,OACd,oBAAC,QAAA,EAAO,MAAM,IAAI,QAAM,KAAA,CAAC,IACvB,eACD,YAAY,oBAAC,SAAA,EAAQ,MAAM,IAAI,IAC9B;AACJ,UAAM,WAAW,CAAC,QAAQ,gBAAiB,aAAa,oBAAC,SAAA,EAAQ,MAAM,GAAA,CAAI,IAAM;AAEjF,WACE;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA,gBAAc;AAAA,QACd,cAAY,UAAU,OAAO;AAAA,QAC7B,SAAS,CAAC,UAAU;AAClB,oBAAU,KAAK;AAIf,cAAI,MAAM,iBAAkB;AAC5B,qBAAW,CAAC,OAAO;AAAA,QACrB;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,UACA,aAAa,IAAI;AAAA,UACjB,CAAC,YAAY;AAAA,UACb,CAAC,YAAY,CAAC,WAAW;AAAA,UACzB,CAAC,YACC,WACA,CAAC,QACD;AAAA,UACF,CAAC,YAAY,WAAW,QAAQ,kCAAkC,eAAe;AAAA,UACjF,YAAY;AAAA,UACZ;AAAA,QAAA;AAAA,QAED,GAAG;AAAA,QAEH,UAAA;AAAA,UAAA,+BACE,QAAA,EAAK,WAAW,mBAAmB,eAAY,QAC7C,UAAA,SACH;AAAA,UAEF,oBAAC,QAAA,EAAK,WAAU,oBAAoB,UAAA,OAAM;AAAA,UACzC,YACC,oBAAC,QAAA,EAAK,WAAW,mBAAmB,eAAY,QAC7C,UAAA,SAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,aAAa,cAAc;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -153,6 +153,10 @@ export declare type AI2IconProps = BaseIconProps;
|
|
|
153
153
|
* Honours `prefers-reduced-motion`: the shimmer and flicker are dropped and the
|
|
154
154
|
* label renders in its settled state.
|
|
155
155
|
*
|
|
156
|
+
* Set `idleShimmer={false}` when several `AiButton`s sit side by side, so an
|
|
157
|
+
* idle one sits still and the shimmer reads as "this one is genuinely busy"
|
|
158
|
+
* rather than "any of these could be clicked".
|
|
159
|
+
*
|
|
156
160
|
* @example
|
|
157
161
|
* ```tsx
|
|
158
162
|
* <AiButton label="Analyse" activeLabel="Analysing" active={isPending} onClick={run} />
|
|
@@ -168,6 +172,12 @@ export declare interface AiButtonProps extends Omit<React_2.ButtonHTMLAttributes
|
|
|
168
172
|
activeLabel?: string;
|
|
169
173
|
/** Swap to {@link activeLabel} and keep the shimmer running. @default false */
|
|
170
174
|
active?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Shimmer and flicker while enabled and idle, inviting a click. Turn off when
|
|
177
|
+
* several `AiButton`s sit side by side, so an idle one sits still and only the
|
|
178
|
+
* `active` one reads as busy. @default true
|
|
179
|
+
*/
|
|
180
|
+
idleShimmer?: boolean;
|
|
171
181
|
/** @default "32" */
|
|
172
182
|
size?: AiButtonSize;
|
|
173
183
|
/** Replace the leading AI glyph. */
|
|
@@ -2851,12 +2861,30 @@ export declare interface DropdownMenuHeaderProps extends React_2.HTMLAttributes<
|
|
|
2851
2861
|
title?: string;
|
|
2852
2862
|
/** Configuration for the embedded search input when `type="search"`. */
|
|
2853
2863
|
searchProps?: DropdownMenuHeaderSearchProps;
|
|
2864
|
+
/**
|
|
2865
|
+
* Action elements rendered at the end of the header row, before the close
|
|
2866
|
+
* button — e.g. icon buttons for search/add, or a primary "Done" button that
|
|
2867
|
+
* commits a {@link DropdownMenuReorderGroup} reorder. An action that should
|
|
2868
|
+
* close the menu needs the menu's `open` state controlled (only the built-in
|
|
2869
|
+
* close button can dismiss an uncontrolled menu).
|
|
2870
|
+
*/
|
|
2871
|
+
actions?: React_2.ReactNode;
|
|
2854
2872
|
/** Whether to render the close icon button on the right. @default true */
|
|
2855
2873
|
showClose?: boolean;
|
|
2856
2874
|
/** Fires when the close icon button is activated. */
|
|
2857
2875
|
onClose?: () => void;
|
|
2858
2876
|
/** Accessible label for the close button. @default "Close menu" */
|
|
2859
2877
|
closeLabel?: string;
|
|
2878
|
+
/**
|
|
2879
|
+
* Fires when the back icon button at the start of the row is activated.
|
|
2880
|
+
* Rendering it lets a menu step back from a sub-view — a `type="search"`
|
|
2881
|
+
* header returning to its title, for instance — without closing the menu.
|
|
2882
|
+
*/
|
|
2883
|
+
onBack?: () => void;
|
|
2884
|
+
/** Whether to render the back icon button. @default `onBack !== undefined` */
|
|
2885
|
+
showBack?: boolean;
|
|
2886
|
+
/** Accessible label for the back button. @default "Back" */
|
|
2887
|
+
backLabel?: string;
|
|
2860
2888
|
}
|
|
2861
2889
|
|
|
2862
2890
|
/** Search-input configuration for {@link DropdownMenuHeader} when `type="search"`. */
|
|
@@ -3012,6 +3040,108 @@ export declare interface DropdownMenuRadioItemProps extends React_2.ComponentPro
|
|
|
3012
3040
|
/** Height preset for a {@link DropdownMenuRadioItem}. */
|
|
3013
3041
|
export declare type DropdownMenuRadioItemSize = "40";
|
|
3014
3042
|
|
|
3043
|
+
/** Describes a completed reorder: which item moved and where. */
|
|
3044
|
+
export declare interface DropdownMenuReorderDetail {
|
|
3045
|
+
/** `value` of the item that moved. */
|
|
3046
|
+
value: string;
|
|
3047
|
+
/** Plain-text name of the item that moved (see `DropdownMenuReorderItem.label`). */
|
|
3048
|
+
label: string;
|
|
3049
|
+
/** Index the item moved from. */
|
|
3050
|
+
from: number;
|
|
3051
|
+
/** Index the item now occupies. */
|
|
3052
|
+
to: number;
|
|
3053
|
+
/** Number of items in the group. */
|
|
3054
|
+
total: number;
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
/**
|
|
3058
|
+
* A drag-to-reorder list of {@link DropdownMenuReorderItem} rows within a
|
|
3059
|
+
* dropdown menu — the "Reorganise" mode of `V2 Menu Dropdown`. Rows are
|
|
3060
|
+
* dragged with the pointer (from anywhere on the row with a mouse, from the
|
|
3061
|
+
* drag handle on touch) or moved with ArrowUp/ArrowDown on the focused
|
|
3062
|
+
* handle. Works in both the `"menu"` and `"sheet"` variants — for a long
|
|
3063
|
+
* list in a sheet, give the scrolling ancestor `overflow-y-auto` (the sheet
|
|
3064
|
+
* only caps its height) so edge auto-scroll has something to scroll.
|
|
3065
|
+
*
|
|
3066
|
+
* Inside a `"menu"`, Tab cycles through the handles and any header actions
|
|
3067
|
+
* (Radix menus otherwise swallow Tab), and the first handle takes focus when
|
|
3068
|
+
* the menu opens straight into the group.
|
|
3069
|
+
*
|
|
3070
|
+
* Pair with a {@link DropdownMenuHeader} whose `actions` contains a commit
|
|
3071
|
+
* button to exit the reorder mode.
|
|
3072
|
+
*
|
|
3073
|
+
* @example
|
|
3074
|
+
* ```tsx
|
|
3075
|
+
* <DropdownMenuReorderGroup
|
|
3076
|
+
* values={folders.map((folder) => folder.id)}
|
|
3077
|
+
* onReorder={(_, { value, to }) => moveFolder(value, to)}
|
|
3078
|
+
* aria-label="Reorder folders"
|
|
3079
|
+
* >
|
|
3080
|
+
* {folders.map((folder) => (
|
|
3081
|
+
* <DropdownMenuReorderItem key={folder.id} value={folder.id} label={folder.name}>
|
|
3082
|
+
* {folder.name}
|
|
3083
|
+
* </DropdownMenuReorderItem>
|
|
3084
|
+
* ))}
|
|
3085
|
+
* </DropdownMenuReorderGroup>
|
|
3086
|
+
* ```
|
|
3087
|
+
*/
|
|
3088
|
+
export declare const DropdownMenuReorderGroup: React_2.ForwardRefExoticComponent<DropdownMenuReorderGroupProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
3089
|
+
|
|
3090
|
+
/** Props for the {@link DropdownMenuReorderGroup} component. */
|
|
3091
|
+
export declare interface DropdownMenuReorderGroupProps extends Omit<React_2.HTMLAttributes<HTMLDivElement>, "onChange"> {
|
|
3092
|
+
/**
|
|
3093
|
+
* Item values in their current order. Must contain one entry per
|
|
3094
|
+
* {@link DropdownMenuReorderItem} child, in the same order the children are
|
|
3095
|
+
* rendered.
|
|
3096
|
+
*/
|
|
3097
|
+
values: string[];
|
|
3098
|
+
/**
|
|
3099
|
+
* Fires after a drop or a keyboard move completes with the new order, plus
|
|
3100
|
+
* which item moved and from/to where — enough to call a move-to-position
|
|
3101
|
+
* API without diffing the arrays.
|
|
3102
|
+
*/
|
|
3103
|
+
onReorder: (values: string[], detail: DropdownMenuReorderDetail) => void;
|
|
3104
|
+
/**
|
|
3105
|
+
* Builds the text announced to screen readers after a move. Override to
|
|
3106
|
+
* localise it.
|
|
3107
|
+
* @default ({ label, to, total }) => `${label} moved to position ${to + 1} of ${total}`
|
|
3108
|
+
*/
|
|
3109
|
+
getAnnouncement?: (detail: DropdownMenuReorderDetail) => string;
|
|
3110
|
+
/**
|
|
3111
|
+
* Screen-reader instructions attached to every drag handle. Override to
|
|
3112
|
+
* localise them.
|
|
3113
|
+
* @default "Press the up and down arrow keys to move this item."
|
|
3114
|
+
*/
|
|
3115
|
+
instructions?: string;
|
|
3116
|
+
}
|
|
3117
|
+
|
|
3118
|
+
/**
|
|
3119
|
+
* A draggable row within a {@link DropdownMenuReorderGroup}. Shows the drag
|
|
3120
|
+
* handle grip, dims in place while its floating copy follows the pointer, and
|
|
3121
|
+
* supports ArrowUp/ArrowDown reordering when the handle has focus.
|
|
3122
|
+
*/
|
|
3123
|
+
export declare const DropdownMenuReorderItem: React_2.ForwardRefExoticComponent<DropdownMenuReorderItemProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
3124
|
+
|
|
3125
|
+
/** Props for the {@link DropdownMenuReorderItem} component. */
|
|
3126
|
+
export declare interface DropdownMenuReorderItemProps extends React_2.HTMLAttributes<HTMLDivElement> {
|
|
3127
|
+
/** Value identifying this item within the parent group's `values`. */
|
|
3128
|
+
value: string;
|
|
3129
|
+
/**
|
|
3130
|
+
* Plain-text name used in the group's screen-reader announcements and
|
|
3131
|
+
* reported in `onReorder`'s detail. Defaults to `children` when that is a
|
|
3132
|
+
* string or number, then to `value` — so pass it whenever `value` is an id.
|
|
3133
|
+
*/
|
|
3134
|
+
label?: string;
|
|
3135
|
+
/** Icon (or other node) rendered between the drag handle and the label. */
|
|
3136
|
+
leadingIcon?: React_2.ReactNode;
|
|
3137
|
+
/** Content rendered at the end of the row, e.g. an item count. */
|
|
3138
|
+
trailing?: React_2.ReactNode;
|
|
3139
|
+
/** Accessible label for the drag handle button. @default "Reorder" */
|
|
3140
|
+
dragHandleLabel?: string;
|
|
3141
|
+
/** Disables dragging and keyboard reordering for this item. @default false */
|
|
3142
|
+
disabled?: boolean;
|
|
3143
|
+
}
|
|
3144
|
+
|
|
3015
3145
|
/** Visual separator between groups of items. */
|
|
3016
3146
|
export declare const DropdownMenuSeparator: React_2.ForwardRefExoticComponent<DropdownMenuSeparatorProps & React_2.RefAttributes<HTMLDivElement>>;
|
|
3017
3147
|
|
|
@@ -3040,7 +3170,7 @@ export declare type DropdownMenuTriggerProps = React_2.ComponentPropsWithoutRef<
|
|
|
3040
3170
|
* The viewport decision belongs to the consumer (it owns the breakpoint
|
|
3041
3171
|
* source of truth), so pass e.g. `variant={isDesktop ? "menu" : "sheet"}`.
|
|
3042
3172
|
*/
|
|
3043
|
-
declare type DropdownMenuVariant = "menu" | "sheet";
|
|
3173
|
+
export declare type DropdownMenuVariant = "menu" | "sheet";
|
|
3044
3174
|
|
|
3045
3175
|
/**
|
|
3046
3176
|
* Edit icon. Renders at sizes 16, 24, or 32 px with outlined and filled variants.
|
|
@@ -5574,6 +5704,98 @@ export declare type SupportIconProps = BaseIconProps;
|
|
|
5574
5704
|
*/
|
|
5575
5705
|
export declare const Switch: React_2.ForwardRefExoticComponent<SwitchProps & React_2.RefAttributes<HTMLButtonElement>>;
|
|
5576
5706
|
|
|
5707
|
+
/**
|
|
5708
|
+
* A labelled pill that switches one feature or mode on and off, for settings
|
|
5709
|
+
* panels, filter bars and tool options. Unlike {@link Switch} it names the thing
|
|
5710
|
+
* it controls, which suits contexts where the action needs spelling out.
|
|
5711
|
+
*
|
|
5712
|
+
* Rendered as a `<button>` carrying `aria-pressed` — the ARIA toggle-button
|
|
5713
|
+
* pattern — so it flips on click and on Enter or Space, and exposes
|
|
5714
|
+
* `data-state="on" | "off"` for styling. Supports controlled (`pressed`) and
|
|
5715
|
+
* uncontrolled (`defaultPressed`) usage. The visible `label` is the accessible
|
|
5716
|
+
* name, so no `aria-label` is needed.
|
|
5717
|
+
*
|
|
5718
|
+
* For two or three mutually exclusive options, reach for {@link SegmentedControl}
|
|
5719
|
+
* instead: this button is independently on or off, not a choice between options.
|
|
5720
|
+
*
|
|
5721
|
+
* @example
|
|
5722
|
+
* ```tsx
|
|
5723
|
+
* <SwitchButton label="Hide sold out" pressed={hidden} onPressedChange={setHidden} />
|
|
5724
|
+
* ```
|
|
5725
|
+
*
|
|
5726
|
+
* @example Independent icon flags, available on the default variant only
|
|
5727
|
+
* ```tsx
|
|
5728
|
+
* <SwitchButton size="40" label="Add filter" showLeftIcon showRightIcon />
|
|
5729
|
+
* ```
|
|
5730
|
+
*
|
|
5731
|
+
* @example The AI variant, whose sparkle is fixed
|
|
5732
|
+
* ```tsx
|
|
5733
|
+
* <SwitchButton variant="ai" label="Smart replies" defaultPressed />
|
|
5734
|
+
* ```
|
|
5735
|
+
*/
|
|
5736
|
+
export declare const SwitchButton: React_2.ForwardRefExoticComponent<SwitchButtonProps & React_2.RefAttributes<HTMLButtonElement>>;
|
|
5737
|
+
|
|
5738
|
+
/**
|
|
5739
|
+
* Props for the `"ai"` variant. Its leading sparkle is fixed and it has no
|
|
5740
|
+
* trailing slot, so neither icon prop is available here.
|
|
5741
|
+
*/
|
|
5742
|
+
export declare interface SwitchButtonAiProps extends SwitchButtonBaseProps {
|
|
5743
|
+
/** Visual treatment. */
|
|
5744
|
+
variant: "ai";
|
|
5745
|
+
/** Unavailable on `"ai"` — the leading sparkle is always shown and cannot be swapped. */
|
|
5746
|
+
showLeftIcon?: never;
|
|
5747
|
+
/** Unavailable on `"ai"` — this variant has no trailing icon slot. */
|
|
5748
|
+
showRightIcon?: never;
|
|
5749
|
+
/** Unavailable on `"ai"` — the leading sparkle is fixed. */
|
|
5750
|
+
leftIcon?: never;
|
|
5751
|
+
/** Unavailable on `"ai"` — this variant has no trailing icon slot. */
|
|
5752
|
+
rightIcon?: never;
|
|
5753
|
+
}
|
|
5754
|
+
|
|
5755
|
+
declare interface SwitchButtonBaseProps extends Omit<React_2.ButtonHTMLAttributes<HTMLButtonElement>, "type" | "children"> {
|
|
5756
|
+
/** Visible text label, which is also the accessible name. */
|
|
5757
|
+
label: string;
|
|
5758
|
+
/** Height of the button in pixels. @default "32" */
|
|
5759
|
+
size?: SwitchButtonSize;
|
|
5760
|
+
/** On/off state for controlled usage. Pair with `onPressedChange`. */
|
|
5761
|
+
pressed?: boolean;
|
|
5762
|
+
/** Initial on/off state for uncontrolled usage. @default false */
|
|
5763
|
+
defaultPressed?: boolean;
|
|
5764
|
+
/** Fired with the next state each time the button flips. */
|
|
5765
|
+
onPressedChange?: (pressed: boolean) => void;
|
|
5766
|
+
/** Native button behaviour. @default "button" */
|
|
5767
|
+
type?: "button" | "submit" | "reset";
|
|
5768
|
+
}
|
|
5769
|
+
|
|
5770
|
+
/**
|
|
5771
|
+
* Props for the `"default"` variant, the only one with icon slots. The two are
|
|
5772
|
+
* independent: pass either, neither, or both.
|
|
5773
|
+
*/
|
|
5774
|
+
export declare interface SwitchButtonDefaultProps extends SwitchButtonBaseProps {
|
|
5775
|
+
/** Visual treatment. @default "default" */
|
|
5776
|
+
variant?: "default";
|
|
5777
|
+
/** Show an icon before the label. @default false */
|
|
5778
|
+
showLeftIcon?: boolean;
|
|
5779
|
+
/** Show an icon after the label. @default false */
|
|
5780
|
+
showRightIcon?: boolean;
|
|
5781
|
+
/** Icon rendered before the label when `showLeftIcon` is set. @default `<AddIcon size={16} />` */
|
|
5782
|
+
leftIcon?: React_2.ReactNode;
|
|
5783
|
+
/** Icon rendered after the label when `showRightIcon` is set. @default `<AddIcon size={16} />` */
|
|
5784
|
+
rightIcon?: React_2.ReactNode;
|
|
5785
|
+
}
|
|
5786
|
+
|
|
5787
|
+
/**
|
|
5788
|
+
* Props for {@link SwitchButton}. A discriminated union on `variant`, so the icon
|
|
5789
|
+
* slots only type-check on the `"default"` variant.
|
|
5790
|
+
*/
|
|
5791
|
+
export declare type SwitchButtonProps = SwitchButtonDefaultProps | SwitchButtonAiProps;
|
|
5792
|
+
|
|
5793
|
+
/** Height of the button in pixels. Matches {@link Button}'s scale. */
|
|
5794
|
+
export declare type SwitchButtonSize = "24" | "32" | "40";
|
|
5795
|
+
|
|
5796
|
+
/** Visual treatment of the button. */
|
|
5797
|
+
export declare type SwitchButtonVariant = "default" | "ai";
|
|
5798
|
+
|
|
5577
5799
|
/**
|
|
5578
5800
|
* A labelled switch field with optional helper text and info tooltip. Composes
|
|
5579
5801
|
* the {@link Switch} component with a `<label>` and description.
|
package/dist/index.mjs
CHANGED
|
@@ -38,7 +38,6 @@ import { Demographics } from "./components/Demographics/Demographics.mjs";
|
|
|
38
38
|
import { Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogTitle, DialogTrigger } from "./components/Dialog/Dialog.mjs";
|
|
39
39
|
import { Divider } from "./components/Divider/Divider.mjs";
|
|
40
40
|
import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerTitle, DrawerTrigger } from "./components/Drawer/Drawer.mjs";
|
|
41
|
-
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuHeader, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger } from "./components/DropdownMenu/DropdownMenu.mjs";
|
|
42
41
|
import { EmptyState } from "./components/EmptyState/EmptyState.mjs";
|
|
43
42
|
import { FanFollowerCount } from "./components/FanFollowerCount/FanFollowerCount.mjs";
|
|
44
43
|
import { FloatingActionButton } from "./components/FloatingActionButton/FloatingActionButton.mjs";
|
|
@@ -247,6 +246,7 @@ import { Stepper } from "./components/Stepper/Stepper.mjs";
|
|
|
247
246
|
import { StepperStep } from "./components/Stepper/StepperStep.mjs";
|
|
248
247
|
import { SubscribeButton } from "./components/SubscribeButton/SubscribeButton.mjs";
|
|
249
248
|
import { Switch } from "./components/Switch/Switch.mjs";
|
|
249
|
+
import { SwitchButton } from "./components/SwitchButton/SwitchButton.mjs";
|
|
250
250
|
import { SwitchField } from "./components/SwitchField/SwitchField.mjs";
|
|
251
251
|
import { SwitchToggle } from "./components/SwitchToggle/SwitchToggle.mjs";
|
|
252
252
|
import { Table, TableBody, TableCard, TableCell, TableCellContent, TableCellGroup, TableFooter, TableHead, TableHeader, TableLineClamp, TableMediaThumbnail, TablePillProgressLayout, TableProgressTrack, TableRow, TableRowsPerPageSelect, TableScrollArea, TableSortLabel, TableStackedText, TableStatusDot, TableToolbar } from "./components/Table/Table.mjs";
|
|
@@ -271,6 +271,12 @@ import { cn } from "./utils/cn.mjs";
|
|
|
271
271
|
import { getInitials } from "./utils/getInitials.mjs";
|
|
272
272
|
import { useFittedBarCount } from "./utils/useFittedBarCount.mjs";
|
|
273
273
|
import { useSuppressClickAfterDrag } from "./utils/useSuppressClickAfterDrag.mjs";
|
|
274
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuTrigger } from "./components/DropdownMenu/DropdownMenuRoot.mjs";
|
|
275
|
+
import { DropdownMenuCheckboxItem, DropdownMenuRadioGroup, DropdownMenuRadioItem } from "./components/DropdownMenu/DropdownMenuSelectionItems.mjs";
|
|
276
|
+
import { DropdownMenuHeader } from "./components/DropdownMenu/DropdownMenuHeader.mjs";
|
|
277
|
+
import { DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator } from "./components/DropdownMenu/DropdownMenuItem.mjs";
|
|
278
|
+
import { DropdownMenuReorderGroup } from "./components/DropdownMenu/DropdownMenuReorderGroup.mjs";
|
|
279
|
+
import { DropdownMenuReorderItem } from "./components/DropdownMenu/DropdownMenuReorderItem.mjs";
|
|
274
280
|
export {
|
|
275
281
|
AI2Icon,
|
|
276
282
|
AICallIcon,
|
|
@@ -402,6 +408,8 @@ export {
|
|
|
402
408
|
DropdownMenuLabel,
|
|
403
409
|
DropdownMenuRadioGroup,
|
|
404
410
|
DropdownMenuRadioItem,
|
|
411
|
+
DropdownMenuReorderGroup,
|
|
412
|
+
DropdownMenuReorderItem,
|
|
405
413
|
DropdownMenuSeparator,
|
|
406
414
|
DropdownMenuTrigger,
|
|
407
415
|
EditIcon,
|
|
@@ -533,6 +541,7 @@ export {
|
|
|
533
541
|
Support2Icon,
|
|
534
542
|
SupportIcon,
|
|
535
543
|
Switch,
|
|
544
|
+
SwitchButton,
|
|
536
545
|
SwitchField,
|
|
537
546
|
SwitchToggle,
|
|
538
547
|
Table,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fanvue/ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.32.0",
|
|
4
4
|
"description": "React component library built with Tailwind CSS for Fanvue ecosystem",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org",
|
|
@@ -196,7 +196,8 @@
|
|
|
196
196
|
"lodash-es": ">=4.18.0",
|
|
197
197
|
"minimatch": ">=10.2.3",
|
|
198
198
|
"ajv": ">=8.18.0",
|
|
199
|
-
"fast-uri": ">=4.1.
|
|
199
|
+
"fast-uri": ">=4.1.3",
|
|
200
|
+
"browserslist": ">=4.28.7",
|
|
200
201
|
"brace-expansion": ">=5.0.9",
|
|
201
202
|
"yaml": ">=2.8.3",
|
|
202
203
|
"postcss": ">=8.5.23",
|