@fanvue/ui 1.1.0 → 1.2.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/README.md +5 -1
- package/dist/cjs/components/Alert/Alert.cjs +19 -3
- package/dist/cjs/components/Alert/Alert.cjs.map +1 -1
- package/dist/cjs/components/Button/Button.cjs +2 -2
- package/dist/cjs/components/Button/Button.cjs.map +1 -1
- package/dist/cjs/components/Checkbox/Checkbox.cjs +7 -0
- package/dist/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
- package/dist/cjs/components/Chip/Chip.cjs +1 -1
- package/dist/cjs/components/Chip/Chip.cjs.map +1 -1
- package/dist/cjs/components/DatePicker/DatePicker.cjs +1 -1
- package/dist/cjs/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/cjs/components/IconButton/IconButton.cjs +23 -19
- package/dist/cjs/components/IconButton/IconButton.cjs.map +1 -1
- package/dist/cjs/components/Icons/EyeIcon.cjs +63 -0
- package/dist/cjs/components/Icons/EyeIcon.cjs.map +1 -0
- package/dist/cjs/components/Pagination/Pagination.cjs +11 -5
- package/dist/cjs/components/Pagination/Pagination.cjs.map +1 -1
- package/dist/cjs/components/Snackbar/Snackbar.cjs +12 -5
- package/dist/cjs/components/Snackbar/Snackbar.cjs.map +1 -1
- package/dist/cjs/components/SwitchField/SwitchField.cjs +6 -4
- package/dist/cjs/components/SwitchField/SwitchField.cjs.map +1 -1
- package/dist/cjs/components/Tabs/TabsTrigger.cjs +1 -0
- package/dist/cjs/components/Tabs/TabsTrigger.cjs.map +1 -1
- package/dist/cjs/components/TextField/TextField.cjs +164 -0
- package/dist/cjs/components/TextField/TextField.cjs.map +1 -0
- package/dist/cjs/components/Toast/Toast.cjs +4 -3
- package/dist/cjs/components/Toast/Toast.cjs.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.cjs +50 -0
- package/dist/cjs/components/Tooltip/Tooltip.cjs.map +1 -0
- package/dist/cjs/index.cjs +9 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/components/Alert/Alert.mjs +19 -3
- package/dist/components/Alert/Alert.mjs.map +1 -1
- package/dist/components/Button/Button.mjs +2 -2
- package/dist/components/Button/Button.mjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.mjs +7 -0
- package/dist/components/Checkbox/Checkbox.mjs.map +1 -1
- package/dist/components/Chip/Chip.mjs +1 -1
- package/dist/components/Chip/Chip.mjs.map +1 -1
- package/dist/components/DatePicker/DatePicker.mjs +1 -1
- package/dist/components/DatePicker/DatePicker.mjs.map +1 -1
- package/dist/components/IconButton/IconButton.mjs +23 -19
- package/dist/components/IconButton/IconButton.mjs.map +1 -1
- package/dist/components/Icons/EyeIcon.mjs +46 -0
- package/dist/components/Icons/EyeIcon.mjs.map +1 -0
- package/dist/components/Pagination/Pagination.mjs +11 -5
- package/dist/components/Pagination/Pagination.mjs.map +1 -1
- package/dist/components/Snackbar/Snackbar.mjs +12 -5
- package/dist/components/Snackbar/Snackbar.mjs.map +1 -1
- package/dist/components/SwitchField/SwitchField.mjs +6 -4
- package/dist/components/SwitchField/SwitchField.mjs.map +1 -1
- package/dist/components/Tabs/TabsTrigger.mjs +1 -0
- package/dist/components/Tabs/TabsTrigger.mjs.map +1 -1
- package/dist/components/TextField/TextField.mjs +147 -0
- package/dist/components/TextField/TextField.mjs.map +1 -0
- package/dist/components/Toast/Toast.mjs +4 -3
- package/dist/components/Toast/Toast.mjs.map +1 -1
- package/dist/components/Tooltip/Tooltip.mjs +32 -0
- package/dist/components/Tooltip/Tooltip.mjs.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.mjs +9 -0
- package/dist/index.mjs.map +1 -1
- package/dist/styles/theme.css +21 -21
- package/package.json +3 -2
|
@@ -5,6 +5,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
5
5
|
const React = require("react");
|
|
6
6
|
const cn = require("../../utils/cn.cjs");
|
|
7
7
|
const Button = require("../Button/Button.cjs");
|
|
8
|
+
const IconButton = require("../IconButton/IconButton.cjs");
|
|
8
9
|
const CrossIcon = require("../Icons/CrossIcon.cjs");
|
|
9
10
|
function _interopNamespaceDefault(e) {
|
|
10
11
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -23,16 +24,20 @@ function _interopNamespaceDefault(e) {
|
|
|
23
24
|
return Object.freeze(n);
|
|
24
25
|
}
|
|
25
26
|
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
26
|
-
function CloseButton({
|
|
27
|
+
function CloseButton({
|
|
28
|
+
onClose,
|
|
29
|
+
className,
|
|
30
|
+
closeLabel = "Close snackbar"
|
|
31
|
+
}) {
|
|
27
32
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
28
|
-
|
|
33
|
+
IconButton.IconButton,
|
|
29
34
|
{
|
|
30
35
|
variant: "tertiary",
|
|
31
36
|
size: "24",
|
|
32
37
|
onClick: onClose,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(CrossIcon.CrossIcon, {}),
|
|
39
|
+
className: cn.cn("shrink-0", className),
|
|
40
|
+
"aria-label": closeLabel
|
|
36
41
|
}
|
|
37
42
|
);
|
|
38
43
|
}
|
|
@@ -137,6 +142,7 @@ const Snackbar = React__namespace.forwardRef(
|
|
|
137
142
|
secondarySlot,
|
|
138
143
|
closable = false,
|
|
139
144
|
onClose,
|
|
145
|
+
closeLabel,
|
|
140
146
|
children,
|
|
141
147
|
...props
|
|
142
148
|
}, ref) => {
|
|
@@ -201,6 +207,7 @@ const Snackbar = React__namespace.forwardRef(
|
|
|
201
207
|
CloseButton,
|
|
202
208
|
{
|
|
203
209
|
onClose,
|
|
210
|
+
closeLabel,
|
|
204
211
|
className: variant === "welcome" ? "absolute top-2 right-2" : void 0
|
|
205
212
|
}
|
|
206
213
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Snackbar.cjs","sources":["../../../../src/components/Snackbar/Snackbar.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button } from \"../Button/Button\";\nimport { CrossIcon } from \"../Icons/CrossIcon\";\n\nexport type SnackbarVariant = \"default\" | \"vipEarn\" | \"welcome\";\n\nexport interface SnackbarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n /** Snackbar layout variant */\n variant?: SnackbarVariant;\n /** Left icon element */\n icon?: React.ReactNode;\n /** Title text */\n title?: React.ReactNode;\n /** Description text */\n description?: React.ReactNode;\n /** Whether to show the actions section */\n showActions?: boolean;\n /** Primary CTA label (renders a default Button) */\n primaryLabel?: string;\n /** Primary CTA click handler (used with primaryLabel) */\n primaryOnClick?: () => void;\n /** Custom element to render as primary CTA (overrides primaryLabel/primaryOnClick) */\n primarySlot?: React.ReactNode;\n /** Secondary CTA label (renders a default Button) */\n secondaryLabel?: string;\n /** Secondary CTA click handler (used with secondaryLabel) */\n secondaryOnClick?: () => void;\n /** Custom element to render as secondary CTA (overrides secondaryLabel/secondaryOnClick) */\n secondarySlot?: React.ReactNode;\n /** Show close button */\n closable?: boolean;\n /** Close button click handler */\n onClose?: () => void;\n}\n\nfunction CloseButton({ onClose, className }: { onClose?: () => void; className?: string }) {\n return (\n <Button\n variant=\"tertiary\"\n size=\"24\"\n onClick={onClose}\n className={cn(\"h-auto shrink-0\", className)}\n aria-label=\"Close snackbar\"\n >\n <CrossIcon />\n </Button>\n );\n}\n\n/**\n * Resolves a CTA slot. If a custom slot is provided it takes precedence,\n * otherwise a default Button is rendered from label + onClick.\n */\nfunction resolveCtaSlot(\n slot: React.ReactNode | undefined,\n label: string | undefined,\n onClick: (() => void) | undefined,\n buttonProps: React.ComponentProps<typeof Button>,\n): React.ReactNode | null {\n if (slot) return slot;\n if (label) {\n return (\n <Button onClick={onClick} {...buttonProps}>\n {label}\n </Button>\n );\n }\n return null;\n}\n\nfunction VipEarnContent({\n icon,\n title,\n description,\n showActions,\n primarySlot,\n primaryLabel,\n primaryOnClick,\n}: Pick<\n SnackbarProps,\n | \"icon\"\n | \"title\"\n | \"description\"\n | \"showActions\"\n | \"primarySlot\"\n | \"primaryLabel\"\n | \"primaryOnClick\"\n>) {\n const primary = resolveCtaSlot(primarySlot, primaryLabel, primaryOnClick, {\n variant: \"text\",\n size: \"24\",\n });\n\n return (\n <>\n {icon && (\n <span className=\"flex shrink-0\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n <div className=\"flex min-w-0 flex-1 flex-col gap-4\">\n <div className=\"flex flex-col\">\n {title && <p className=\"typography-body-1-semibold text-body-100 leading-6\">{title}</p>}\n {description && <p className=\"typography-body-2-regular text-body-200\">{description}</p>}\n </div>\n {showActions && primary && <div className=\"self-start\">{primary}</div>}\n </div>\n </>\n );\n}\n\nfunction WelcomeContent({\n title,\n description,\n showActions,\n primarySlot,\n primaryLabel,\n primaryOnClick,\n secondarySlot,\n secondaryLabel,\n secondaryOnClick,\n}: Pick<\n SnackbarProps,\n | \"title\"\n | \"description\"\n | \"showActions\"\n | \"primarySlot\"\n | \"primaryLabel\"\n | \"primaryOnClick\"\n | \"secondarySlot\"\n | \"secondaryLabel\"\n | \"secondaryOnClick\"\n>) {\n const primary = resolveCtaSlot(primarySlot, primaryLabel, primaryOnClick, {\n variant: \"primary\",\n });\n const secondary = resolveCtaSlot(secondarySlot, secondaryLabel, secondaryOnClick, {\n variant: \"secondary\",\n });\n\n return (\n <>\n <div className=\"flex flex-col items-center gap-2 px-8 text-center text-body-100\">\n {title && <p className=\"typography-heading-4 text-body-100\">{title}</p>}\n {description && <p className=\"typography-body-2-regular text-body-200\">{description}</p>}\n </div>\n {showActions && (primary || secondary) && (\n <div className=\"flex w-full flex-col gap-4 px-8 sm:flex-row sm:*:flex-1\">\n {secondary}\n {primary}\n </div>\n )}\n </>\n );\n}\n\nfunction DefaultContent({\n children,\n showActions,\n primarySlot,\n primaryLabel,\n primaryOnClick,\n secondarySlot,\n secondaryLabel,\n secondaryOnClick,\n}: Pick<\n SnackbarProps,\n | \"children\"\n | \"showActions\"\n | \"primarySlot\"\n | \"primaryLabel\"\n | \"primaryOnClick\"\n | \"secondarySlot\"\n | \"secondaryLabel\"\n | \"secondaryOnClick\"\n>) {\n const primary = resolveCtaSlot(primarySlot, primaryLabel, primaryOnClick, {\n variant: \"primary\",\n size: \"40\",\n });\n const secondary = resolveCtaSlot(secondarySlot, secondaryLabel, secondaryOnClick, {\n variant: \"tertiary\",\n size: \"40\",\n });\n\n return (\n <>\n <div className=\"typography-body-1-medium flex min-w-0 flex-1 items-center self-stretch text-body-100\">\n {children}\n </div>\n {showActions && (primary || secondary) && (\n <div className=\"flex shrink-0 items-start gap-2\">\n {primary}\n {secondary}\n </div>\n )}\n </>\n );\n}\n\nexport const Snackbar = React.forwardRef<HTMLDivElement, SnackbarProps>(\n (\n {\n className,\n variant = \"default\",\n icon,\n title,\n description,\n showActions = true,\n primaryLabel,\n primaryOnClick,\n primarySlot,\n secondaryLabel,\n secondaryOnClick,\n secondarySlot,\n closable = false,\n onClose,\n children,\n ...props\n },\n ref,\n ) => {\n return (\n /* biome-ignore lint/a11y/useSemanticElements: output cannot contain div children; browsers would break the wrapper. */\n <div\n ref={ref}\n role=\"status\"\n data-testid=\"snackbar\"\n className={cn(\n \"flex gap-4 rounded-2xl\",\n (variant === \"default\" || variant === \"vipEarn\") &&\n \"border border-neutral-50 bg-background-200 p-4 backdrop-blur-md\",\n variant === \"default\" && \"flex-wrap items-start\",\n variant === \"vipEarn\" && \"items-start\",\n variant === \"welcome\" &&\n \"relative flex-col items-center bg-background-inverse-solid py-6\",\n className,\n )}\n {...props}\n >\n {variant === \"vipEarn\" && (\n <VipEarnContent\n icon={icon}\n title={title}\n description={description}\n showActions={showActions}\n primarySlot={primarySlot}\n primaryLabel={primaryLabel}\n primaryOnClick={primaryOnClick}\n />\n )}\n {variant === \"welcome\" && (\n <WelcomeContent\n title={title}\n description={description}\n showActions={showActions}\n primarySlot={primarySlot}\n primaryLabel={primaryLabel}\n primaryOnClick={primaryOnClick}\n secondarySlot={secondarySlot}\n secondaryLabel={secondaryLabel}\n secondaryOnClick={secondaryOnClick}\n />\n )}\n {variant === \"default\" && (\n <DefaultContent\n showActions={showActions}\n primarySlot={primarySlot}\n primaryLabel={primaryLabel}\n primaryOnClick={primaryOnClick}\n secondarySlot={secondarySlot}\n secondaryLabel={secondaryLabel}\n secondaryOnClick={secondaryOnClick}\n >\n {children}\n </DefaultContent>\n )}\n {closable && (\n <CloseButton\n onClose={onClose}\n className={variant === \"welcome\" ? \"absolute top-2 right-2\" : undefined}\n />\n )}\n </div>\n );\n },\n);\n\nSnackbar.displayName = \"Snackbar\";\n"],"names":["jsx","Button","cn","CrossIcon","jsxs","Fragment","React"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAS,YAAY,EAAE,SAAS,aAA2D;AACzF,SACEA,2BAAAA;AAAAA,IAACC,OAAAA;AAAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,SAAS;AAAA,MACT,WAAWC,GAAAA,GAAG,mBAAmB,SAAS;AAAA,MAC1C,cAAW;AAAA,MAEX,yCAACC,UAAAA,WAAA,CAAA,CAAU;AAAA,IAAA;AAAA,EAAA;AAGjB;AAMA,SAAS,eACP,MACA,OACA,SACA,aACwB;AACxB,MAAI,KAAM,QAAO;AACjB,MAAI,OAAO;AACT,WACEH,2BAAAA,IAACC,OAAAA,QAAA,EAAO,SAAmB,GAAG,aAC3B,UAAA,OACH;AAAA,EAEJ;AACA,SAAO;AACT;AAEA,SAAS,eAAe;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GASG;AACD,QAAM,UAAU,eAAe,aAAa,cAAc,gBAAgB;AAAA,IACxE,SAAS;AAAA,IACT,MAAM;AAAA,EAAA,CACP;AAED,SACEG,2BAAAA,KAAAC,qBAAA,EACG,UAAA;AAAA,IAAA,uC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AAA;AAAA,YAAA;AAAA,YAGH,YAAY,aACXA,2BAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,cAAA;AAAA,YAAA;AAAA,YAGH,YAAY,aACXA,2BAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,gBAEC;AAAA,cAAA;AAAA,YAAA;AAAA,YAGJ,YACCA,2BAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC;AAAA,gBACA,WAAW,YAAY,YAAY,2BAA2B;AAAA,cAAA;AAAA,YAAA;AAAA,UAChE;AAAA,QAAA;AAAA,MAAA;AAAA;AAAA,EAIR;AACF;AAEA,SAAS,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"Snackbar.cjs","sources":["../../../../src/components/Snackbar/Snackbar.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button } from \"../Button/Button\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CrossIcon } from \"../Icons/CrossIcon\";\n\nexport type SnackbarVariant = \"default\" | \"vipEarn\" | \"welcome\";\n\nexport interface SnackbarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n /** Snackbar layout variant */\n variant?: SnackbarVariant;\n /** Left icon element */\n icon?: React.ReactNode;\n /** Title text */\n title?: React.ReactNode;\n /** Description text */\n description?: React.ReactNode;\n /** Whether to show the actions section */\n showActions?: boolean;\n /** Primary CTA label (renders a default Button) */\n primaryLabel?: string;\n /** Primary CTA click handler (used with primaryLabel) */\n primaryOnClick?: () => void;\n /** Custom element to render as primary CTA (overrides primaryLabel/primaryOnClick) */\n primarySlot?: React.ReactNode;\n /** Secondary CTA label (renders a default Button) */\n secondaryLabel?: string;\n /** Secondary CTA click handler (used with secondaryLabel) */\n secondaryOnClick?: () => void;\n /** Custom element to render as secondary CTA (overrides secondaryLabel/secondaryOnClick) */\n secondarySlot?: React.ReactNode;\n /** Show close button */\n closable?: boolean;\n /** Close button click handler */\n onClose?: () => void;\n /** Accessible label for the close button. @default \"Close snackbar\" */\n closeLabel?: string;\n}\n\nfunction CloseButton({\n onClose,\n className,\n closeLabel = \"Close snackbar\",\n}: {\n onClose?: () => void;\n className?: string;\n closeLabel?: string;\n}) {\n return (\n <IconButton\n variant=\"tertiary\"\n size=\"24\"\n onClick={onClose}\n icon={<CrossIcon />}\n className={cn(\"shrink-0\", className)}\n aria-label={closeLabel}\n />\n );\n}\n\n/**\n * Resolves a CTA slot. If a custom slot is provided it takes precedence,\n * otherwise a default Button is rendered from label + onClick.\n */\nfunction resolveCtaSlot(\n slot: React.ReactNode | undefined,\n label: string | undefined,\n onClick: (() => void) | undefined,\n buttonProps: React.ComponentProps<typeof Button>,\n): React.ReactNode | null {\n if (slot) return slot;\n if (label) {\n return (\n <Button onClick={onClick} {...buttonProps}>\n {label}\n </Button>\n );\n }\n return null;\n}\n\nfunction VipEarnContent({\n icon,\n title,\n description,\n showActions,\n primarySlot,\n primaryLabel,\n primaryOnClick,\n}: Pick<\n SnackbarProps,\n | \"icon\"\n | \"title\"\n | \"description\"\n | \"showActions\"\n | \"primarySlot\"\n | \"primaryLabel\"\n | \"primaryOnClick\"\n>) {\n const primary = resolveCtaSlot(primarySlot, primaryLabel, primaryOnClick, {\n variant: \"text\",\n size: \"24\",\n });\n\n return (\n <>\n {icon && (\n <span className=\"flex shrink-0\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n <div className=\"flex min-w-0 flex-1 flex-col gap-4\">\n <div className=\"flex flex-col\">\n {title && <p className=\"typography-body-1-semibold text-body-100 leading-6\">{title}</p>}\n {description && <p className=\"typography-body-2-regular text-body-200\">{description}</p>}\n </div>\n {showActions && primary && <div className=\"self-start\">{primary}</div>}\n </div>\n </>\n );\n}\n\nfunction WelcomeContent({\n title,\n description,\n showActions,\n primarySlot,\n primaryLabel,\n primaryOnClick,\n secondarySlot,\n secondaryLabel,\n secondaryOnClick,\n}: Pick<\n SnackbarProps,\n | \"title\"\n | \"description\"\n | \"showActions\"\n | \"primarySlot\"\n | \"primaryLabel\"\n | \"primaryOnClick\"\n | \"secondarySlot\"\n | \"secondaryLabel\"\n | \"secondaryOnClick\"\n>) {\n const primary = resolveCtaSlot(primarySlot, primaryLabel, primaryOnClick, {\n variant: \"primary\",\n });\n const secondary = resolveCtaSlot(secondarySlot, secondaryLabel, secondaryOnClick, {\n variant: \"secondary\",\n });\n\n return (\n <>\n <div className=\"flex flex-col items-center gap-2 px-8 text-center text-body-100\">\n {title && <p className=\"typography-heading-4 text-body-100\">{title}</p>}\n {description && <p className=\"typography-body-2-regular text-body-200\">{description}</p>}\n </div>\n {showActions && (primary || secondary) && (\n <div className=\"flex w-full flex-col gap-4 px-8 sm:flex-row sm:*:flex-1\">\n {secondary}\n {primary}\n </div>\n )}\n </>\n );\n}\n\nfunction DefaultContent({\n children,\n showActions,\n primarySlot,\n primaryLabel,\n primaryOnClick,\n secondarySlot,\n secondaryLabel,\n secondaryOnClick,\n}: Pick<\n SnackbarProps,\n | \"children\"\n | \"showActions\"\n | \"primarySlot\"\n | \"primaryLabel\"\n | \"primaryOnClick\"\n | \"secondarySlot\"\n | \"secondaryLabel\"\n | \"secondaryOnClick\"\n>) {\n const primary = resolveCtaSlot(primarySlot, primaryLabel, primaryOnClick, {\n variant: \"primary\",\n size: \"40\",\n });\n const secondary = resolveCtaSlot(secondarySlot, secondaryLabel, secondaryOnClick, {\n variant: \"tertiary\",\n size: \"40\",\n });\n\n return (\n <>\n <div className=\"typography-body-1-medium flex min-w-0 flex-1 items-center self-stretch text-body-100\">\n {children}\n </div>\n {showActions && (primary || secondary) && (\n <div className=\"flex shrink-0 items-start gap-2\">\n {primary}\n {secondary}\n </div>\n )}\n </>\n );\n}\n\nexport const Snackbar = React.forwardRef<HTMLDivElement, SnackbarProps>(\n (\n {\n className,\n variant = \"default\",\n icon,\n title,\n description,\n showActions = true,\n primaryLabel,\n primaryOnClick,\n primarySlot,\n secondaryLabel,\n secondaryOnClick,\n secondarySlot,\n closable = false,\n onClose,\n closeLabel,\n children,\n ...props\n },\n ref,\n ) => {\n return (\n /* biome-ignore lint/a11y/useSemanticElements: output cannot contain div children; browsers would break the wrapper. */\n <div\n ref={ref}\n role=\"status\"\n data-testid=\"snackbar\"\n className={cn(\n \"flex gap-4 rounded-2xl\",\n (variant === \"default\" || variant === \"vipEarn\") &&\n \"border border-neutral-50 bg-background-200 p-4 backdrop-blur-md\",\n variant === \"default\" && \"flex-wrap items-start\",\n variant === \"vipEarn\" && \"items-start\",\n variant === \"welcome\" &&\n \"relative flex-col items-center bg-background-inverse-solid py-6\",\n className,\n )}\n {...props}\n >\n {variant === \"vipEarn\" && (\n <VipEarnContent\n icon={icon}\n title={title}\n description={description}\n showActions={showActions}\n primarySlot={primarySlot}\n primaryLabel={primaryLabel}\n primaryOnClick={primaryOnClick}\n />\n )}\n {variant === \"welcome\" && (\n <WelcomeContent\n title={title}\n description={description}\n showActions={showActions}\n primarySlot={primarySlot}\n primaryLabel={primaryLabel}\n primaryOnClick={primaryOnClick}\n secondarySlot={secondarySlot}\n secondaryLabel={secondaryLabel}\n secondaryOnClick={secondaryOnClick}\n />\n )}\n {variant === \"default\" && (\n <DefaultContent\n showActions={showActions}\n primarySlot={primarySlot}\n primaryLabel={primaryLabel}\n primaryOnClick={primaryOnClick}\n secondarySlot={secondarySlot}\n secondaryLabel={secondaryLabel}\n secondaryOnClick={secondaryOnClick}\n >\n {children}\n </DefaultContent>\n )}\n {closable && (\n <CloseButton\n onClose={onClose}\n closeLabel={closeLabel}\n className={variant === \"welcome\" ? \"absolute top-2 right-2\" : undefined}\n />\n )}\n </div>\n );\n },\n);\n\nSnackbar.displayName = \"Snackbar\";\n"],"names":["jsx","IconButton","CrossIcon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;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC;AAAA,gBACA;AAAA,gBACA,WAAW,YAAY,YAAY,2BAA2B;AAAA,cAAA;AAAA,YAAA;AAAA,UAChE;AAAA,QAAA;AAAA,MAAA;AAAA;AAAA,EAIR;AACF;AAEA,SAAS,cAAc;;"}
|
|
@@ -6,6 +6,7 @@ const React = require("react");
|
|
|
6
6
|
const cn = require("../../utils/cn.cjs");
|
|
7
7
|
const InfoCircleIcon = require("../Icons/InfoCircleIcon.cjs");
|
|
8
8
|
const Switch = require("../Switch/Switch.cjs");
|
|
9
|
+
const Tooltip = require("../Tooltip/Tooltip.cjs");
|
|
9
10
|
function _interopNamespaceDefault(e) {
|
|
10
11
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
11
12
|
if (e) {
|
|
@@ -31,6 +32,7 @@ const SwitchField = React__namespace.forwardRef(
|
|
|
31
32
|
label,
|
|
32
33
|
helperText,
|
|
33
34
|
infoText,
|
|
35
|
+
infoLabel = "More information",
|
|
34
36
|
disabled,
|
|
35
37
|
id: propId,
|
|
36
38
|
...props
|
|
@@ -70,10 +72,10 @@ const SwitchField = React__namespace.forwardRef(
|
|
|
70
72
|
children: label
|
|
71
73
|
}
|
|
72
74
|
),
|
|
73
|
-
infoText && /* @__PURE__ */ jsxRuntime.
|
|
74
|
-
/* @__PURE__ */ jsxRuntime.jsx(InfoCircleIcon.InfoCircleIcon, { className: "size-5 text-body-200" }),
|
|
75
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
76
|
-
] })
|
|
75
|
+
infoText && /* @__PURE__ */ jsxRuntime.jsx(Tooltip.TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip.Tooltip, { children: [
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tooltip.TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "aria-label": infoLabel, className: "flex shrink-0 pt-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(InfoCircleIcon.InfoCircleIcon, { "aria-hidden": "true", className: "size-5 text-body-200" }) }) }),
|
|
77
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tooltip.TooltipContent, { side: "bottom", children: infoText })
|
|
78
|
+
] }) })
|
|
77
79
|
] }),
|
|
78
80
|
helperText && /* @__PURE__ */ jsxRuntime.jsx(
|
|
79
81
|
"span",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwitchField.cjs","sources":["../../../../src/components/SwitchField/SwitchField.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { InfoCircleIcon } from \"../Icons/InfoCircleIcon\";\nimport { Switch, type SwitchSize } from \"../Switch/Switch\";\n\nexport type SwitchFieldOrientation = \"right\" | \"left\";\n\nexport interface SwitchFieldProps\n extends Omit<React.ComponentPropsWithoutRef<typeof Switch>, \"size\" | \"className\"> {\n /** Position of the switch relative to the label */\n orientation?: SwitchFieldOrientation;\n /** Size variant of the switch and text */\n size?: SwitchSize;\n /** Label text displayed next to the switch */\n label?: string;\n /** Helper text displayed below the label */\n helperText?: string;\n /** Info tooltip text displayed on hover of the info icon */\n infoText?: string;\n /** Additional className for the wrapper */\n className?: string;\n}\n\nexport const SwitchField = React.forwardRef<React.ComponentRef<typeof Switch>, SwitchFieldProps>(\n (\n {\n className,\n orientation = \"right\",\n size = \"default\",\n label,\n helperText,\n infoText,\n disabled,\n id: propId,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const id = propId ?? generatedId;\n const helperTextId = helperText ? `${id}-helper` : undefined;\n\n const switchElement = (\n <Switch\n ref={ref}\n id={id}\n size={size}\n disabled={disabled}\n aria-describedby={helperTextId}\n {...props}\n />\n );\n\n const labelContent = (label || helperText) && (\n <div\n className={cn(\n \"flex min-w-0 flex-1 flex-col items-start\",\n size === \"default\" ? \"gap-1\" : \"gap-0.5\",\n )}\n >\n {label && (\n <div className=\"flex items-center gap-1\">\n <label\n htmlFor={id}\n className={cn(\n \"cursor-pointer select-none text-body-100\",\n disabled && \"cursor-not-allowed text-disabled-100\",\n size === \"default\" ? \"typography-body-1-semibold\" : \"typography-body-2-semibold\",\n )}\n >\n {label}\n </label>\n {infoText && (\n <
|
|
1
|
+
{"version":3,"file":"SwitchField.cjs","sources":["../../../../src/components/SwitchField/SwitchField.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { InfoCircleIcon } from \"../Icons/InfoCircleIcon\";\nimport { Switch, type SwitchSize } from \"../Switch/Switch\";\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from \"../Tooltip/Tooltip\";\n\nexport type SwitchFieldOrientation = \"right\" | \"left\";\n\nexport interface SwitchFieldProps\n extends Omit<React.ComponentPropsWithoutRef<typeof Switch>, \"size\" | \"className\"> {\n /** Position of the switch relative to the label */\n orientation?: SwitchFieldOrientation;\n /** Size variant of the switch and text */\n size?: SwitchSize;\n /** Label text displayed next to the switch */\n label?: string;\n /** Helper text displayed below the label */\n helperText?: string;\n /** Info tooltip text displayed on hover of the info icon */\n infoText?: string;\n /** Accessible label for the info tooltip trigger button. Override for i18n.\n * @default \"More information\"\n */\n infoLabel?: string;\n /** Additional className for the wrapper */\n className?: string;\n}\n\nexport const SwitchField = React.forwardRef<React.ComponentRef<typeof Switch>, SwitchFieldProps>(\n (\n {\n className,\n orientation = \"right\",\n size = \"default\",\n label,\n helperText,\n infoText,\n infoLabel = \"More information\",\n disabled,\n id: propId,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const id = propId ?? generatedId;\n const helperTextId = helperText ? `${id}-helper` : undefined;\n\n const switchElement = (\n <Switch\n ref={ref}\n id={id}\n size={size}\n disabled={disabled}\n aria-describedby={helperTextId}\n {...props}\n />\n );\n\n const labelContent = (label || helperText) && (\n <div\n className={cn(\n \"flex min-w-0 flex-1 flex-col items-start\",\n size === \"default\" ? \"gap-1\" : \"gap-0.5\",\n )}\n >\n {label && (\n <div className=\"flex items-center gap-1\">\n <label\n htmlFor={id}\n className={cn(\n \"cursor-pointer select-none text-body-100\",\n disabled && \"cursor-not-allowed text-disabled-100\",\n size === \"default\" ? \"typography-body-1-semibold\" : \"typography-body-2-semibold\",\n )}\n >\n {label}\n </label>\n {infoText && (\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger asChild>\n <button type=\"button\" aria-label={infoLabel} className=\"flex shrink-0 pt-0.5\">\n <InfoCircleIcon aria-hidden=\"true\" className=\"size-5 text-body-200\" />\n </button>\n </TooltipTrigger>\n <TooltipContent side=\"bottom\">{infoText}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n )}\n </div>\n )}\n {helperText && (\n <span\n id={helperTextId}\n className={cn(\n \"text-body-200\", // !TODO https://linear.app/fanvue/issue/ENG-7301/swap-out-typography-tailwind-utility-classes\n disabled && \"text-disabled-100\",\n size === \"default\" ? \"typography-body-2-regular\" : \"typography-caption-regular\",\n )}\n >\n {helperText}\n </span>\n )}\n </div>\n );\n\n return (\n <div className={cn(\"flex items-start gap-2\", disabled && \"cursor-not-allowed\", className)}>\n {orientation === \"left\" && switchElement}\n {labelContent}\n {orientation === \"right\" && switchElement}\n </div>\n );\n },\n);\n\nSwitchField.displayName = \"SwitchField\";\n"],"names":["React","jsx","Switch","jsxs","cn","TooltipProvider","Tooltip","TooltipTrigger","InfoCircleIcon","TooltipContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,cAAcA,iBAAM;AAAA,EAC/B,CACE;AAAA,IACE;AAAA,IACA,cAAc;AAAA,IACd,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA,IAAI;AAAA,IACJ,GAAG;AAAA,EAAA,GAEL,QACG;AACH,UAAM,cAAcA,iBAAM,MAAA;AAC1B,UAAM,KAAK,UAAU;AACrB,UAAM,eAAe,aAAa,GAAG,EAAE,YAAY;AAEnD,UAAM,gBACJC,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AAA,IAAA;AAKN,WACED,gCAAC,SAAI,WAAWC,GAAAA,GAAG,0BAA0B,YAAY,sBAAsB,SAAS,GACrF,UAAA;AAAA,MAAA,gBAAgB,UAAU;AAAA,MAC1B;AAAA,MACA,gBAAgB,WAAW;AAAA,IAAA,GAC9B;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;;"}
|
|
@@ -31,6 +31,7 @@ const TabsTrigger = React__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
31
31
|
"inline-flex items-center justify-center",
|
|
32
32
|
"rounded-xs border-transparent",
|
|
33
33
|
"typography-body-1-semibold cursor-pointer text-body-100",
|
|
34
|
+
"motion-safe:transition-[color,border-color] motion-safe:duration-150 motion-safe:ease-in-out",
|
|
34
35
|
"data-[orientation=horizontal]:border-b-4 data-[orientation=horizontal]:px-3 data-[orientation=horizontal]:pb-4",
|
|
35
36
|
"data-[orientation=vertical]:justify-start data-[orientation=vertical]:border-r-4 data-[orientation=vertical]:px-4 data-[orientation=vertical]:py-3",
|
|
36
37
|
"data-[state=active]:border-brand-green-500",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabsTrigger.cjs","sources":["../../../../src/components/Tabs/TabsTrigger.tsx"],"sourcesContent":["import * as TabsPrimitive from \"@radix-ui/react-tabs\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\nexport type TabsTriggerProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>;\n\nexport const TabsTrigger = React.forwardRef<\n React.ComponentRef<typeof TabsPrimitive.Trigger>,\n TabsTriggerProps\n>(({ className, ...props }, ref) => (\n <TabsPrimitive.Trigger\n ref={ref}\n className={cn(\n \"inline-flex items-center justify-center\",\n \"rounded-xs border-transparent\",\n \"typography-body-1-semibold cursor-pointer text-body-100\",\n \"data-[orientation=horizontal]:border-b-4 data-[orientation=horizontal]:px-3 data-[orientation=horizontal]:pb-4\",\n \"data-[orientation=vertical]:justify-start data-[orientation=vertical]:border-r-4 data-[orientation=vertical]:px-4 data-[orientation=vertical]:py-3\",\n \"data-[state=active]:border-brand-green-500\",\n \"data-[state=active]:hover:text-hover-100\",\n \"data-[state=inactive]:hover:text-hover-200\",\n \"data-disabled:pointer-events-none\",\n \"data-disabled:data-[state=active]:text-disabled-100\",\n \"data-disabled:data-[state=inactive]:text-disabled-400\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-purple-500 focus-visible:ring-offset-2 focus-visible:ring-offset-background-inverse-solid\",\n className,\n )}\n {...props}\n />\n));\n\nTabsTrigger.displayName = \"TabsTrigger\";\n"],"names":["React","jsx","TabsPrimitive","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMO,MAAM,cAAcA,iBAAM,WAG/B,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACC,yBAAc;AAAA,EAAd;AAAA,IACC;AAAA,IACA,WAAWC,GAAAA;AAAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,IAED,GAAG;AAAA,EAAA;AACN,CACD;AAED,YAAY,cAAc;;"}
|
|
1
|
+
{"version":3,"file":"TabsTrigger.cjs","sources":["../../../../src/components/Tabs/TabsTrigger.tsx"],"sourcesContent":["import * as TabsPrimitive from \"@radix-ui/react-tabs\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\nexport type TabsTriggerProps = React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>;\n\nexport const TabsTrigger = React.forwardRef<\n React.ComponentRef<typeof TabsPrimitive.Trigger>,\n TabsTriggerProps\n>(({ className, ...props }, ref) => (\n <TabsPrimitive.Trigger\n ref={ref}\n className={cn(\n \"inline-flex items-center justify-center\",\n \"rounded-xs border-transparent\",\n \"typography-body-1-semibold cursor-pointer text-body-100\",\n \"motion-safe:transition-[color,border-color] motion-safe:duration-150 motion-safe:ease-in-out\",\n \"data-[orientation=horizontal]:border-b-4 data-[orientation=horizontal]:px-3 data-[orientation=horizontal]:pb-4\",\n \"data-[orientation=vertical]:justify-start data-[orientation=vertical]:border-r-4 data-[orientation=vertical]:px-4 data-[orientation=vertical]:py-3\",\n \"data-[state=active]:border-brand-green-500\",\n \"data-[state=active]:hover:text-hover-100\",\n \"data-[state=inactive]:hover:text-hover-200\",\n \"data-disabled:pointer-events-none\",\n \"data-disabled:data-[state=active]:text-disabled-100\",\n \"data-disabled:data-[state=inactive]:text-disabled-400\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-purple-500 focus-visible:ring-offset-2 focus-visible:ring-offset-background-inverse-solid\",\n className,\n )}\n {...props}\n />\n));\n\nTabsTrigger.displayName = \"TabsTrigger\";\n"],"names":["React","jsx","TabsPrimitive","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMO,MAAM,cAAcA,iBAAM,WAG/B,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACC,yBAAc;AAAA,EAAd;AAAA,IACC;AAAA,IACA,WAAWC,GAAAA;AAAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,IAED,GAAG;AAAA,EAAA;AACN,CACD;AAED,YAAY,cAAc;;"}
|
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
|
+
if (e) {
|
|
10
|
+
for (const k in e) {
|
|
11
|
+
if (k !== "default") {
|
|
12
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: () => e[k]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
24
|
+
const CONTAINER_HEIGHT = {
|
|
25
|
+
"48": "h-12",
|
|
26
|
+
"40": "h-10",
|
|
27
|
+
"32": "h-8"
|
|
28
|
+
};
|
|
29
|
+
const INPUT_SIZE_CLASSES = {
|
|
30
|
+
"48": "py-3 typography-body-1-regular",
|
|
31
|
+
"40": "py-2 typography-body-1-regular",
|
|
32
|
+
"32": "py-2 typography-body-2-regular"
|
|
33
|
+
};
|
|
34
|
+
const PADDING_LEFT = {
|
|
35
|
+
"48": ["pl-4", "pl-11"],
|
|
36
|
+
"40": ["pl-4", "pl-11"],
|
|
37
|
+
"32": ["pl-3", "pl-10"]
|
|
38
|
+
};
|
|
39
|
+
const PADDING_RIGHT = {
|
|
40
|
+
"48": ["pr-4", "pr-11"],
|
|
41
|
+
"40": ["pr-4", "pr-11"],
|
|
42
|
+
"32": ["pr-3", "pr-10"]
|
|
43
|
+
};
|
|
44
|
+
const ICON_LEFT = {
|
|
45
|
+
"48": "left-4",
|
|
46
|
+
"40": "left-4",
|
|
47
|
+
"32": "left-3"
|
|
48
|
+
};
|
|
49
|
+
const ICON_RIGHT = {
|
|
50
|
+
"48": "right-4",
|
|
51
|
+
"40": "right-4",
|
|
52
|
+
"32": "right-3"
|
|
53
|
+
};
|
|
54
|
+
function getContainerClassName(size, error, disabled) {
|
|
55
|
+
return cn.cn(
|
|
56
|
+
"relative rounded-xl border bg-neutral-100 has-focus-visible:shadow-focus-ring has-focus-visible:outline-none motion-safe:transition-colors",
|
|
57
|
+
error ? "border-error-500" : "border-transparent",
|
|
58
|
+
!disabled && !error && "hover:border-neutral-400",
|
|
59
|
+
CONTAINER_HEIGHT[size],
|
|
60
|
+
disabled && "opacity-50"
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
function getInputClassName(size, hasLeftIcon, hasRightIcon) {
|
|
64
|
+
return cn.cn(
|
|
65
|
+
"h-full w-full rounded-xl bg-transparent text-body-100 placeholder:text-body-200 placeholder:opacity-40 focus:outline-none disabled:cursor-not-allowed",
|
|
66
|
+
INPUT_SIZE_CLASSES[size],
|
|
67
|
+
PADDING_LEFT[size][hasLeftIcon ? 1 : 0],
|
|
68
|
+
PADDING_RIGHT[size][hasRightIcon ? 1 : 0]
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
const ICON_BASE = "pointer-events-none absolute top-1/2 flex size-5 -translate-y-1/2 items-center justify-center text-body-200";
|
|
72
|
+
function TextFieldIcon({
|
|
73
|
+
children,
|
|
74
|
+
size,
|
|
75
|
+
side
|
|
76
|
+
}) {
|
|
77
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn.cn(ICON_BASE, side === "left" ? ICON_LEFT[size] : ICON_RIGHT[size]), children });
|
|
78
|
+
}
|
|
79
|
+
function TextFieldHelperText({
|
|
80
|
+
id,
|
|
81
|
+
error,
|
|
82
|
+
children
|
|
83
|
+
}) {
|
|
84
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
85
|
+
"p",
|
|
86
|
+
{
|
|
87
|
+
id,
|
|
88
|
+
className: cn.cn(
|
|
89
|
+
"typography-caption-regular px-2 pt-1 pb-0.5",
|
|
90
|
+
error ? "text-error-500" : "text-body-200"
|
|
91
|
+
),
|
|
92
|
+
children
|
|
93
|
+
}
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
function warnMissingAccessibleName(label, ariaLabel, ariaLabelledBy) {
|
|
97
|
+
if (process.env.NODE_ENV !== "production") {
|
|
98
|
+
if (!label && !ariaLabel && !ariaLabelledBy) {
|
|
99
|
+
console.warn(
|
|
100
|
+
"TextField: no accessible name provided. Pass a `label`, `aria-label`, or `aria-labelledby` prop."
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const TextField = React__namespace.forwardRef(
|
|
106
|
+
({
|
|
107
|
+
label,
|
|
108
|
+
helperText,
|
|
109
|
+
size = "48",
|
|
110
|
+
error = false,
|
|
111
|
+
errorMessage,
|
|
112
|
+
leftIcon,
|
|
113
|
+
rightIcon,
|
|
114
|
+
className,
|
|
115
|
+
id,
|
|
116
|
+
disabled,
|
|
117
|
+
fullWidth = false,
|
|
118
|
+
...props
|
|
119
|
+
}, ref) => {
|
|
120
|
+
const generatedId = React__namespace.useId();
|
|
121
|
+
const inputId = id || generatedId;
|
|
122
|
+
const helperTextId = `${inputId}-helper`;
|
|
123
|
+
const bottomText = error && errorMessage ? errorMessage : helperText;
|
|
124
|
+
warnMissingAccessibleName(label, props["aria-label"], props["aria-labelledby"]);
|
|
125
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
126
|
+
"div",
|
|
127
|
+
{
|
|
128
|
+
className: cn.cn("flex flex-col", fullWidth && "w-full", className),
|
|
129
|
+
"data-disabled": disabled ? "" : void 0,
|
|
130
|
+
"data-error": error ? "" : void 0,
|
|
131
|
+
children: [
|
|
132
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(
|
|
133
|
+
"label",
|
|
134
|
+
{
|
|
135
|
+
htmlFor: inputId,
|
|
136
|
+
className: "typography-caption-semibold px-1 pt-1 pb-2 text-body-100",
|
|
137
|
+
children: label
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: getContainerClassName(size, error, disabled), children: [
|
|
141
|
+
leftIcon && /* @__PURE__ */ jsxRuntime.jsx(TextFieldIcon, { size, side: "left", children: leftIcon }),
|
|
142
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
143
|
+
"input",
|
|
144
|
+
{
|
|
145
|
+
ref,
|
|
146
|
+
id: inputId,
|
|
147
|
+
disabled,
|
|
148
|
+
"aria-describedby": bottomText ? helperTextId : void 0,
|
|
149
|
+
"aria-invalid": error || void 0,
|
|
150
|
+
className: getInputClassName(size, !!leftIcon, !!rightIcon),
|
|
151
|
+
...props
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
rightIcon && /* @__PURE__ */ jsxRuntime.jsx(TextFieldIcon, { size, side: "right", children: rightIcon })
|
|
155
|
+
] }),
|
|
156
|
+
bottomText && /* @__PURE__ */ jsxRuntime.jsx(TextFieldHelperText, { id: helperTextId, error, children: bottomText })
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
TextField.displayName = "TextField";
|
|
163
|
+
exports.TextField = TextField;
|
|
164
|
+
//# sourceMappingURL=TextField.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.cjs","sources":["../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\nexport type TextFieldSize = \"48\" | \"40\" | \"32\";\n\nexport interface TextFieldProps\n extends Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\" | \"prefix\"> {\n /** Label text displayed above the input */\n label?: string;\n /** Helper text displayed below the input */\n helperText?: string;\n /** Size variant of the text field */\n size?: TextFieldSize;\n /** Error state of the text field */\n error?: boolean;\n /** Error message displayed below the input. Overrides helper text when error is true. */\n errorMessage?: string;\n /** Icon displayed on the left side of the input */\n leftIcon?: React.ReactNode;\n /** Icon displayed on the right side of the input */\n rightIcon?: React.ReactNode;\n /** Whether the text field should take the full width of its container */\n fullWidth?: boolean;\n}\n\nconst CONTAINER_HEIGHT: Record<TextFieldSize, string> = {\n \"48\": \"h-12\",\n \"40\": \"h-10\",\n \"32\": \"h-8\",\n};\n\nconst INPUT_SIZE_CLASSES: Record<TextFieldSize, string> = {\n \"48\": \"py-3 typography-body-1-regular\",\n \"40\": \"py-2 typography-body-1-regular\",\n \"32\": \"py-2 typography-body-2-regular\",\n};\n\nconst PADDING_LEFT: Record<TextFieldSize, [base: string, withIcon: string]> = {\n \"48\": [\"pl-4\", \"pl-11\"],\n \"40\": [\"pl-4\", \"pl-11\"],\n \"32\": [\"pl-3\", \"pl-10\"],\n};\n\nconst PADDING_RIGHT: Record<TextFieldSize, [base: string, withIcon: string]> = {\n \"48\": [\"pr-4\", \"pr-11\"],\n \"40\": [\"pr-4\", \"pr-11\"],\n \"32\": [\"pr-3\", \"pr-10\"],\n};\n\nconst ICON_LEFT: Record<TextFieldSize, string> = {\n \"48\": \"left-4\",\n \"40\": \"left-4\",\n \"32\": \"left-3\",\n};\n\nconst ICON_RIGHT: Record<TextFieldSize, string> = {\n \"48\": \"right-4\",\n \"40\": \"right-4\",\n \"32\": \"right-3\",\n};\n\nfunction getContainerClassName(size: TextFieldSize, error: boolean, disabled?: boolean) {\n return cn(\n \"relative rounded-xl border bg-neutral-100 has-focus-visible:shadow-focus-ring has-focus-visible:outline-none motion-safe:transition-colors\",\n error ? \"border-error-500\" : \"border-transparent\",\n !disabled && !error && \"hover:border-neutral-400\",\n CONTAINER_HEIGHT[size],\n disabled && \"opacity-50\",\n );\n}\n\nfunction getInputClassName(size: TextFieldSize, hasLeftIcon: boolean, hasRightIcon: boolean) {\n return cn(\n \"h-full w-full rounded-xl bg-transparent text-body-100 placeholder:text-body-200 placeholder:opacity-40 focus:outline-none disabled:cursor-not-allowed\",\n INPUT_SIZE_CLASSES[size],\n PADDING_LEFT[size][hasLeftIcon ? 1 : 0],\n PADDING_RIGHT[size][hasRightIcon ? 1 : 0],\n );\n}\n\nconst ICON_BASE =\n \"pointer-events-none absolute top-1/2 flex size-5 -translate-y-1/2 items-center justify-center text-body-200\";\n\nfunction TextFieldIcon({\n children,\n size,\n side,\n}: {\n children: React.ReactNode;\n size: TextFieldSize;\n side: \"left\" | \"right\";\n}) {\n return (\n <div className={cn(ICON_BASE, side === \"left\" ? ICON_LEFT[size] : ICON_RIGHT[size])}>\n {children}\n </div>\n );\n}\n\nfunction TextFieldHelperText({\n id,\n error,\n children,\n}: {\n id: string;\n error: boolean;\n children: React.ReactNode;\n}) {\n return (\n <p\n id={id}\n className={cn(\n \"typography-caption-regular px-2 pt-1 pb-0.5\",\n error ? \"text-error-500\" : \"text-body-200\",\n )}\n >\n {children}\n </p>\n );\n}\n\nfunction warnMissingAccessibleName(label?: string, ariaLabel?: string, ariaLabelledBy?: string) {\n if (process.env.NODE_ENV !== \"production\") {\n if (!label && !ariaLabel && !ariaLabelledBy) {\n console.warn(\n \"TextField: no accessible name provided. Pass a `label`, `aria-label`, or `aria-labelledby` prop.\",\n );\n }\n }\n}\n\nexport const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(\n (\n {\n label,\n helperText,\n size = \"48\",\n error = false,\n errorMessage,\n leftIcon,\n rightIcon,\n className,\n id,\n disabled,\n fullWidth = false,\n ...props\n },\n ref,\n ) => {\n const generatedId = React.useId();\n const inputId = id || generatedId;\n const helperTextId = `${inputId}-helper`;\n const bottomText = error && errorMessage ? errorMessage : helperText;\n\n warnMissingAccessibleName(label, props[\"aria-label\"], props[\"aria-labelledby\"]);\n\n return (\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={inputId}\n className=\"typography-caption-semibold px-1 pt-1 pb-2 text-body-100\"\n >\n {label}\n </label>\n )}\n\n <div className={getContainerClassName(size, error, disabled)}>\n {leftIcon && (\n <TextFieldIcon size={size} side=\"left\">\n {leftIcon}\n </TextFieldIcon>\n )}\n\n <input\n ref={ref}\n id={inputId}\n disabled={disabled}\n aria-describedby={bottomText ? helperTextId : undefined}\n aria-invalid={error || undefined}\n className={getInputClassName(size, !!leftIcon, !!rightIcon)}\n {...props}\n />\n\n {rightIcon && (\n <TextFieldIcon size={size} side=\"right\">\n {rightIcon}\n </TextFieldIcon>\n )}\n </div>\n\n {bottomText && (\n <TextFieldHelperText id={helperTextId} error={error}>\n {bottomText}\n </TextFieldHelperText>\n )}\n </div>\n );\n },\n);\n\nTextField.displayName = \"TextField\";\n"],"names":["cn","jsx","React","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,mBAAkD;AAAA,EACtD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,qBAAoD;AAAA,EACxD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,eAAwE;AAAA,EAC5E,MAAM,CAAC,QAAQ,OAAO;AAAA,EACtB,MAAM,CAAC,QAAQ,OAAO;AAAA,EACtB,MAAM,CAAC,QAAQ,OAAO;AACxB;AAEA,MAAM,gBAAyE;AAAA,EAC7E,MAAM,CAAC,QAAQ,OAAO;AAAA,EACtB,MAAM,CAAC,QAAQ,OAAO;AAAA,EACtB,MAAM,CAAC,QAAQ,OAAO;AACxB;AAEA,MAAM,YAA2C;AAAA,EAC/C,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,MAAM,aAA4C;AAAA,EAChD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AACR;AAEA,SAAS,sBAAsB,MAAqB,OAAgB,UAAoB;AACtF,SAAOA,GAAAA;AAAAA,IACL;AAAA,IACA,QAAQ,qBAAqB;AAAA,IAC7B,CAAC,YAAY,CAAC,SAAS;AAAA,IACvB,iBAAiB,IAAI;AAAA,IACrB,YAAY;AAAA,EAAA;AAEhB;AAEA,SAAS,kBAAkB,MAAqB,aAAsB,cAAuB;AAC3F,SAAOA,GAAAA;AAAAA,IACL;AAAA,IACA,mB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;AAAA,QACC,WAAWH,GAAAA,GAAG,iBAAiB,aAAa,UAAU,SAAS;AAAA,QAC/D,iBAAe,WAAW,KAAK;AAAA,QAC/B,cAAY,QAAQ,KAAK;AAAA,QAExB,UAAA;AAAA,UAAA,SACCC,2BAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,SAAS;AAAA,cACT,WAAU;AAAA,cAET,UAAA;AAAA,YAAA;AAAA,UAAA;AAAA,0CAIJ,OAAA,EAAI,WAAW,sBAAsB,MAAM,OAAO,QAAQ,GACxD,UAAA;AAAA,YAAA,YACCA,2BAAAA,IAAC,eAAA,EAAc,MAAY,MAAK,QAC7B,UAAA,UACH;AAAA,YAGFA,2BAAAA;AAAAA,cAAC;AAAA,cAAA;AAAA,gBACC;AAAA,gBACA,IAAI;AAAA,gBACJ;AAAA,gBACA,oBAAkB,aAAa,eAAe;AAAA,gBAC9C,gBAAc,SAAS;AAAA,gBACvB,WAAW,kBAAkB,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,SAAS;AAAA,gBACzD,GAAG;AAAA,cAAA;AAAA,YAAA;AAAA,YAGL,aACCA,2BAAAA,IAAC,eAAA,EAAc,MAAY,MAAK,SAC7B,UAAA,UAAA,CACH;AAAA,UAAA,GAEJ;AAAA,UAEC,cACCA,2BAAAA,IAAC,qBAAA,EAAoB,IAAI,cAAc,OACpC,UAAA,WAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEA,UAAU,cAAc;;"}
|
|
@@ -37,7 +37,7 @@ const ToastViewport = React__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
37
37
|
{
|
|
38
38
|
ref,
|
|
39
39
|
className: cn.cn(
|
|
40
|
-
"fixed
|
|
40
|
+
"fixed right-0 bottom-0 z-100 flex max-h-screen w-full flex-col-reverse gap-3 p-4 md:max-w-[420px]",
|
|
41
41
|
className
|
|
42
42
|
),
|
|
43
43
|
...props
|
|
@@ -65,6 +65,7 @@ const Toast = React__namespace.forwardRef(
|
|
|
65
65
|
actionLabel,
|
|
66
66
|
onActionClick,
|
|
67
67
|
showClose = true,
|
|
68
|
+
closeLabel = "Close notification",
|
|
68
69
|
avatarSrc,
|
|
69
70
|
avatarAlt,
|
|
70
71
|
avatarFallback,
|
|
@@ -82,7 +83,7 @@ const Toast = React__namespace.forwardRef(
|
|
|
82
83
|
// Dark mode
|
|
83
84
|
"dark:border-opacity-100",
|
|
84
85
|
// Animation
|
|
85
|
-
"data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-bottom-full data-[
|
|
86
|
+
"data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-bottom-full data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[state=closed]:animate-out data-[state=open]:animate-in data-[swipe=end]:animate-out data-[swipe=move]:transition-none",
|
|
86
87
|
// Manual CSS overrides
|
|
87
88
|
className
|
|
88
89
|
),
|
|
@@ -110,7 +111,7 @@ const Toast = React__namespace.forwardRef(
|
|
|
110
111
|
IconButton.IconButton,
|
|
111
112
|
{
|
|
112
113
|
icon: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon.CloseIcon, {}),
|
|
113
|
-
"aria-label":
|
|
114
|
+
"aria-label": closeLabel,
|
|
114
115
|
className: "absolute top-2 right-2 text-body-300",
|
|
115
116
|
variant: "tertiary",
|
|
116
117
|
size: "24"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.cjs","sources":["../../../../src/components/Toast/Toast.tsx"],"sourcesContent":["import * as ToastPrimitive from \"@radix-ui/react-toast\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Avatar } from \"../Avatar/Avatar\";\nimport { Button } from \"../Button/Button\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { ErrorIcon } from \"../Icons/ErrorIcon\";\nimport { InfoIcon } from \"../Icons/InfoIcon\";\nimport { SuccessIcon } from \"../Icons/SuccessIcon\";\nimport { WarningIcon } from \"../Icons/WarningIcon\";\n\nexport type ToastVariant = \"info\" | \"warning\" | \"success\" | \"error\" | \"messageToast\";\n\n// Override \"title\" prop to allow React.ReactNode instead of string | undefined\nexport interface ToastProps\n extends Omit<Omit<React.ComponentPropsWithoutRef<typeof ToastPrimitive.Root>, \"type\">, \"title\"> {\n /** Variant of the toast */\n variant?: ToastVariant;\n /** Toast title */\n title?: string;\n /** Toast description/message */\n description?: React.ReactNode;\n /** Action button label */\n actionLabel?: string;\n /** Action button click handler */\n onActionClick?: () => void;\n /** Show close button */\n showClose?: boolean;\n /** Avatar image source */\n avatarSrc?: string;\n /** Avatar alt text */\n avatarAlt?: string;\n /** Avatar fallback text */\n avatarFallback?: string;\n}\n\nexport interface ToastProviderProps extends ToastPrimitive.ToastProviderProps {}\nexport interface ToastViewportProps\n extends React.ComponentPropsWithoutRef<typeof ToastPrimitive.Viewport> {}\n\nexport const ToastProvider: React.FC<ToastProviderProps> = ToastPrimitive.Provider;\n\nexport const ToastViewport = React.forwardRef<\n React.ElementRef<typeof ToastPrimitive.Viewport>,\n ToastViewportProps\n>(({ className, ...props }, ref) => (\n <ToastPrimitive.Viewport\n ref={ref}\n className={cn(\n \"fixed
|
|
1
|
+
{"version":3,"file":"Toast.cjs","sources":["../../../../src/components/Toast/Toast.tsx"],"sourcesContent":["import * as ToastPrimitive from \"@radix-ui/react-toast\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Avatar } from \"../Avatar/Avatar\";\nimport { Button } from \"../Button/Button\";\nimport { IconButton } from \"../IconButton/IconButton\";\nimport { CloseIcon } from \"../Icons/CloseIcon\";\nimport { ErrorIcon } from \"../Icons/ErrorIcon\";\nimport { InfoIcon } from \"../Icons/InfoIcon\";\nimport { SuccessIcon } from \"../Icons/SuccessIcon\";\nimport { WarningIcon } from \"../Icons/WarningIcon\";\n\nexport type ToastVariant = \"info\" | \"warning\" | \"success\" | \"error\" | \"messageToast\";\n\n// Override \"title\" prop to allow React.ReactNode instead of string | undefined\nexport interface ToastProps\n extends Omit<Omit<React.ComponentPropsWithoutRef<typeof ToastPrimitive.Root>, \"type\">, \"title\"> {\n /** Variant of the toast */\n variant?: ToastVariant;\n /** Toast title */\n title?: string;\n /** Toast description/message */\n description?: React.ReactNode;\n /** Action button label */\n actionLabel?: string;\n /** Action button click handler */\n onActionClick?: () => void;\n /** Show close button */\n showClose?: boolean;\n /** Accessible label for the close button. @default \"Close notification\" */\n closeLabel?: string;\n /** Avatar image source */\n avatarSrc?: string;\n /** Avatar alt text */\n avatarAlt?: string;\n /** Avatar fallback text */\n avatarFallback?: string;\n}\n\nexport interface ToastProviderProps extends ToastPrimitive.ToastProviderProps {}\nexport interface ToastViewportProps\n extends React.ComponentPropsWithoutRef<typeof ToastPrimitive.Viewport> {}\n\nexport const ToastProvider: React.FC<ToastProviderProps> = ToastPrimitive.Provider;\n\nexport const ToastViewport = React.forwardRef<\n React.ElementRef<typeof ToastPrimitive.Viewport>,\n ToastViewportProps\n>(({ className, ...props }, ref) => (\n <ToastPrimitive.Viewport\n ref={ref}\n className={cn(\n \"fixed right-0 bottom-0 z-100 flex max-h-screen w-full flex-col-reverse gap-3 p-4 md:max-w-[420px]\",\n className,\n )}\n {...props}\n />\n));\n\nToastViewport.displayName = \"ToastViewport\";\n\nconst VariantIcon = ({ variant }: { variant: ToastVariant }) => {\n switch (variant) {\n case \"info\":\n return <InfoIcon className=\"size-5 text-info-500\" />;\n case \"warning\":\n return <WarningIcon className=\"size-5 text-warning-500\" />;\n case \"success\":\n return <SuccessIcon className=\"size-5 text-success-500\" />;\n case \"error\":\n return <ErrorIcon className=\"size-5 text-error-500\" />;\n }\n};\n\nexport const Toast = React.forwardRef<React.ComponentRef<typeof ToastPrimitive.Root>, ToastProps>(\n (\n {\n className,\n variant = \"info\",\n title,\n description,\n actionLabel,\n onActionClick,\n showClose = true,\n closeLabel = \"Close notification\",\n avatarSrc,\n avatarAlt,\n avatarFallback,\n children,\n ...props\n },\n ref,\n ) => {\n return (\n <ToastPrimitive.Root\n ref={ref}\n data-testid=\"toast\"\n className={cn(\n // Base styles\n \"group pointer-events-auto relative flex w-full flex-col items-start gap-3 overflow-hidden rounded-lg border-none bg-background-solid p-4 text-background-inverse-solid shadow-lg transition-all\",\n // Dark mode\n \"dark:border-opacity-100\",\n // Animation\n \"data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-bottom-full data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[state=closed]:animate-out data-[state=open]:animate-in data-[swipe=end]:animate-out data-[swipe=move]:transition-none\",\n // Manual CSS overrides\n className,\n )}\n {...props}\n >\n <div className=\"flex w-full items-center gap-3\">\n <div className=\"self-start\">\n {variant === \"messageToast\" ? (\n avatarSrc && <Avatar src={avatarSrc} alt={avatarAlt} fallback={avatarFallback} />\n ) : (\n <VariantIcon variant={variant} />\n )}\n </div>\n <div className=\"flex flex-1 flex-col items-start\">\n {title && (\n <ToastPrimitive.Title className=\"typography-body-2-semibold\">\n {title}\n </ToastPrimitive.Title>\n )}\n {description && (\n <ToastPrimitive.Description className=\"typography-body-2-regular mt-1 opacity-90\">\n {description}\n </ToastPrimitive.Description>\n )}\n {children}\n {onActionClick && (\n <Button\n variant=\"secondary\"\n // These styles are basically inverted from the selected theme\n className=\"mt-4 border-body-400 text-body-400\"\n size=\"32\"\n onClick={onActionClick}\n >\n {actionLabel ?? \"Action\"}\n </Button>\n )}\n </div>\n </div>\n {showClose && (\n <ToastPrimitive.Close asChild>\n <IconButton\n icon={<CloseIcon />}\n aria-label={closeLabel}\n // same as the button above\n className=\"absolute top-2 right-2 text-body-300\"\n variant=\"tertiary\"\n size=\"24\"\n />\n </ToastPrimitive.Close>\n )}\n </ToastPrimitive.Root>\n );\n },\n);\n\nToast.displayName = \"Toast\";\n"],"names":["ToastPrimitive","React","jsx","cn","InfoIcon","WarningIcon","SuccessIcon","ErrorIcon","jsxs","Avatar","Button","IconButton","CloseIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CO,MAAM,gBAA8CA,0BAAe;AAEnE,MAAM,gBAAgBC,iBAAM,WAGjC,CAAC,EAAE,WAAW,GAAG,MAAA,GAAS,QAC1BC,2BAAAA;AAAAA,EAACF,0BAAe;AAAA,EAAf;AAAA,IACC;AAAA,IACA,WAAWG,GAAAA;AAAAA,MACT;AAAA,MACA;AAAA,IAAA;AAAA,IAED,GAAG;AAAA,EAAA;AACN,CACD;AAED,cAAc,cAAc;AAE5B,MAAM,cAAc,CAAC,EAAE,cAAyC;AAC9D,UAAQ,SAAA;AAAA,IACN,KAAK;AACH,aAAOD,2BAAAA,IAACE,SAAAA,UAAA,EAAS,WAAU,uBAAA,CAAuB;AAAA,IACpD,KAAK;AACH,aAAOF,2BAAAA,IAACG,YAAAA,aAAA,EAAY,WAAU,0BAAA,CAA0B;AAAA,IAC1D,KAAK;AACH,aAAOH,2BAAAA,IAACI,YAAAA,aAAA,EAAY,WAAU,0BAAA,CAA0B;AAAA,IAC1D,KAAK;AACH,aAAOJ,2BAAAA,IAACK,UAAAA,WAAA,EAAU,WAAU,wBAAA,CAAwB;AAAA,EAAA;AAE1D;AAEO,MAAM,QAAQN,iBAAM;AAAA,EACzB,CACE;AAAA,IACE;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,GAEL,QACG;AACH,WACEO,2BAAAA;AAAAA,MAACR,0BAAe;AAAA,MAAf;AAAA,QACC;AAAA,QACA,eAAY;AAAA,QACZ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ty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const TooltipPrimitive = require("@radix-ui/react-tooltip");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const cn = require("../../utils/cn.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 TooltipPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(TooltipPrimitive);
|
|
25
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
26
|
+
const TooltipProvider = TooltipPrimitive__namespace.Provider;
|
|
27
|
+
const Tooltip = TooltipPrimitive__namespace.Root;
|
|
28
|
+
const TooltipTrigger = TooltipPrimitive__namespace.Trigger;
|
|
29
|
+
const TooltipContent = React__namespace.forwardRef(({ className, showArrow = true, sideOffset = 8, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
30
|
+
TooltipPrimitive__namespace.Content,
|
|
31
|
+
{
|
|
32
|
+
ref,
|
|
33
|
+
sideOffset,
|
|
34
|
+
className: cn.cn(
|
|
35
|
+
"typography-body-2-regular max-w-xs overflow-hidden rounded-3xl bg-background-solid p-4 text-background-inverse-solid shadow-[0_2px_4px_rgba(17,24,39,0.08)]",
|
|
36
|
+
className
|
|
37
|
+
),
|
|
38
|
+
...props,
|
|
39
|
+
children: [
|
|
40
|
+
children,
|
|
41
|
+
showArrow && /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Arrow, { className: "fill-background-solid", width: 12, height: 6 })
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
) }));
|
|
45
|
+
TooltipContent.displayName = "TooltipContent";
|
|
46
|
+
exports.Tooltip = Tooltip;
|
|
47
|
+
exports.TooltipContent = TooltipContent;
|
|
48
|
+
exports.TooltipProvider = TooltipProvider;
|
|
49
|
+
exports.TooltipTrigger = TooltipTrigger;
|
|
50
|
+
//# sourceMappingURL=Tooltip.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.cjs","sources":["../../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["/**\n * !TODO: This is a temporary component to fix a bug in the <Switch />, this needs rebuilding once design is ready https://linear.app/fanvue/issue/ENG-7226/component-library-tooltip-component\n */\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\nimport * as React from \"react\";\nimport { cn } from \"../../utils/cn\";\n\nexport type TooltipProviderProps = React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Provider>;\n\nexport const TooltipProvider = TooltipPrimitive.Provider;\n\nexport type TooltipProps = React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Root>;\n\nexport const Tooltip = TooltipPrimitive.Root;\n\nexport type TooltipTriggerProps = React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Trigger>;\n\nexport const TooltipTrigger = TooltipPrimitive.Trigger;\n\nexport interface TooltipContentProps\n extends React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> {\n /** Whether to show the arrow pointer */\n showArrow?: boolean;\n}\n\nexport const TooltipContent = React.forwardRef<\n React.ComponentRef<typeof TooltipPrimitive.Content>,\n TooltipContentProps\n>(({ className, showArrow = true, sideOffset = 8, children, ...props }, ref) => (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n ref={ref}\n sideOffset={sideOffset}\n className={cn(\n \"typography-body-2-regular max-w-xs overflow-hidden rounded-3xl bg-background-solid p-4 text-background-inverse-solid shadow-[0_2px_4px_rgba(17,24,39,0.08)]\",\n className,\n )}\n {...props}\n >\n {children}\n {showArrow && (\n <TooltipPrimitive.Arrow className=\"fill-background-solid\" width={12} height={6} />\n )}\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n));\n\nTooltipContent.displayName = \"TooltipContent\";\n"],"names":["TooltipPrimitive","React","jsx","jsxs","cn"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AASO,MAAM,kBAAkBA,4BAAiB;AAIzC,MAAM,UAAUA,4BAAiB;AAIjC,MAAM,iBAAiBA,4BAAiB;AAQxC,MAAM,iBAAiBC,iBAAM,WAGlC,CAAC,EAAE,WAAW,YAAY,MAAM,aAAa,GAAG,UAAU,GAAG,MAAA,GAAS,QACtEC,2BAAAA,IAACF,4BAAiB,QAAjB,EACC,UAAAG,2BAAAA;AAAAA,EAACH,4BAAiB;AAAA,EAAjB;AAAA,IACC;AAAA,IACA;AAAA,IACA,WAAWI,GAAAA;AAAAA,MACT;AAAA,MACA;AAAA,IAAA;AAAA,IAED,GAAG;AAAA,IAEH,UAAA;AAAA,MAAA;AAAA,MACA,aACCF,2BAAAA,IAACF,4BAAiB,OAAjB,EAAuB,WAAU,yBAAwB,OAAO,IAAI,QAAQ,EAAA,CAAG;AAAA,IAAA;AAAA,EAAA;AAEpF,GACF,CACD;AAED,eAAe,cAAc;;;;;"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ const CrossIcon = require("./components/Icons/CrossIcon.cjs");
|
|
|
22
22
|
const CrownIcon = require("./components/Icons/CrownIcon.cjs");
|
|
23
23
|
const ErrorCircleIcon = require("./components/Icons/ErrorCircleIcon.cjs");
|
|
24
24
|
const ErrorIcon = require("./components/Icons/ErrorIcon.cjs");
|
|
25
|
+
const EyeIcon = require("./components/Icons/EyeIcon.cjs");
|
|
25
26
|
const FireIcon = require("./components/Icons/FireIcon.cjs");
|
|
26
27
|
const HomeIcon = require("./components/Icons/HomeIcon.cjs");
|
|
27
28
|
const InfoCircleIcon = require("./components/Icons/InfoCircleIcon.cjs");
|
|
@@ -50,7 +51,9 @@ const Tabs = require("./components/Tabs/Tabs.cjs");
|
|
|
50
51
|
const TabsContent = require("./components/Tabs/TabsContent.cjs");
|
|
51
52
|
const TabsList = require("./components/Tabs/TabsList.cjs");
|
|
52
53
|
const TabsTrigger = require("./components/Tabs/TabsTrigger.cjs");
|
|
54
|
+
const TextField = require("./components/TextField/TextField.cjs");
|
|
53
55
|
const Toast = require("./components/Toast/Toast.cjs");
|
|
56
|
+
const Tooltip = require("./components/Tooltip/Tooltip.cjs");
|
|
54
57
|
const cn = require("./utils/cn.cjs");
|
|
55
58
|
exports.Alert = Alert.Alert;
|
|
56
59
|
exports.Avatar = Avatar.Avatar;
|
|
@@ -76,6 +79,7 @@ exports.CrossIcon = CrossIcon.CrossIcon;
|
|
|
76
79
|
exports.CrownIcon = CrownIcon.CrownIcon;
|
|
77
80
|
exports.ErrorCircleIcon = ErrorCircleIcon.ErrorCircleIcon;
|
|
78
81
|
exports.ErrorIcon = ErrorIcon.ErrorIcon;
|
|
82
|
+
exports.EyeIcon = EyeIcon.EyeIcon;
|
|
79
83
|
exports.FireIcon = FireIcon.FireIcon;
|
|
80
84
|
exports.HomeIcon = HomeIcon.HomeIcon;
|
|
81
85
|
exports.InfoCircleIcon = InfoCircleIcon.InfoCircleIcon;
|
|
@@ -104,8 +108,13 @@ exports.Tabs = Tabs.Tabs;
|
|
|
104
108
|
exports.TabsContent = TabsContent.TabsContent;
|
|
105
109
|
exports.TabsList = TabsList.TabsList;
|
|
106
110
|
exports.TabsTrigger = TabsTrigger.TabsTrigger;
|
|
111
|
+
exports.TextField = TextField.TextField;
|
|
107
112
|
exports.Toast = Toast.Toast;
|
|
108
113
|
exports.ToastProvider = Toast.ToastProvider;
|
|
109
114
|
exports.ToastViewport = Toast.ToastViewport;
|
|
115
|
+
exports.Tooltip = Tooltip.Tooltip;
|
|
116
|
+
exports.TooltipContent = Tooltip.TooltipContent;
|
|
117
|
+
exports.TooltipProvider = Tooltip.TooltipProvider;
|
|
118
|
+
exports.TooltipTrigger = Tooltip.TooltipTrigger;
|
|
110
119
|
exports.cn = cn.cn;
|
|
111
120
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -4,8 +4,24 @@ import * as React from "react";
|
|
|
4
4
|
import { cn } from "../../utils/cn.mjs";
|
|
5
5
|
import { Button } from "../Button/Button.mjs";
|
|
6
6
|
import { CrossIcon } from "../Icons/CrossIcon.mjs";
|
|
7
|
+
const CLOSE_BUTTON_CLASSES = {
|
|
8
|
+
info: "hover:bg-info-500/10 text-info-500 motion-safe:transition-colors motion-safe:duration-150",
|
|
9
|
+
success: "hover:bg-success-500/10 text-success-500 motion-safe:transition-colors motion-safe:duration-150",
|
|
10
|
+
warning: "hover:bg-warning-500/10 text-warning-500 motion-safe:transition-colors motion-safe:duration-150",
|
|
11
|
+
error: "hover:bg-error-500/10 text-error-500 motion-safe:transition-colors motion-safe:duration-150"
|
|
12
|
+
};
|
|
7
13
|
const Alert = React.forwardRef(
|
|
8
|
-
({
|
|
14
|
+
({
|
|
15
|
+
className,
|
|
16
|
+
variant = "info",
|
|
17
|
+
title,
|
|
18
|
+
icon,
|
|
19
|
+
closable = false,
|
|
20
|
+
onClose,
|
|
21
|
+
closeLabel = "Close alert",
|
|
22
|
+
children,
|
|
23
|
+
...props
|
|
24
|
+
}, ref) => {
|
|
9
25
|
return /* @__PURE__ */ jsxs(
|
|
10
26
|
"div",
|
|
11
27
|
{
|
|
@@ -38,8 +54,8 @@ const Alert = React.forwardRef(
|
|
|
38
54
|
variant: "tertiary",
|
|
39
55
|
size: "24",
|
|
40
56
|
onClick: onClose,
|
|
41
|
-
className: "self-start",
|
|
42
|
-
"aria-label":
|
|
57
|
+
className: cn("self-start", CLOSE_BUTTON_CLASSES[variant]),
|
|
58
|
+
"aria-label": closeLabel,
|
|
43
59
|
children: /* @__PURE__ */ jsx(CrossIcon, {})
|
|
44
60
|
}
|
|
45
61
|
)
|