@shipfox/react-ui 0.8.0 → 0.9.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/.turbo/turbo-build.log +7 -7
- package/.turbo/turbo-check.log +2 -2
- package/.turbo/turbo-type.log +2 -2
- package/CHANGELOG.md +6 -0
- package/dist/components/alert/alert.d.ts +15 -5
- package/dist/components/alert/alert.d.ts.map +1 -1
- package/dist/components/alert/alert.js +122 -22
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/alert/alert.stories.js +121 -6
- package/dist/components/alert/alert.stories.js.map +1 -1
- package/dist/components/button/button-link.js +1 -1
- package/dist/components/button/button-link.js.map +1 -1
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +4 -1
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button/icon-button.d.ts.map +1 -1
- package/dist/components/button/icon-button.js +4 -1
- package/dist/components/button/icon-button.js.map +1 -1
- package/dist/components/checkbox/checkbox-links.d.ts.map +1 -1
- package/dist/components/checkbox/checkbox-links.js +8 -2
- package/dist/components/checkbox/checkbox-links.js.map +1 -1
- package/dist/components/checkbox/checkbox.stories.js +4 -4
- package/dist/components/checkbox/checkbox.stories.js.map +1 -1
- package/package.json +1 -1
- package/src/components/alert/alert.stories.tsx +103 -2
- package/src/components/alert/alert.tsx +163 -16
- package/src/components/button/button-link.tsx +1 -1
- package/src/components/button/button.tsx +2 -1
- package/src/components/button/icon-button.tsx +2 -1
- package/src/components/checkbox/checkbox-links.tsx +5 -3
- package/src/components/checkbox/checkbox.stories.tsx +20 -4
|
@@ -3,7 +3,7 @@ import { Slot } from '@radix-ui/react-slot';
|
|
|
3
3
|
import { cva } from 'class-variance-authority';
|
|
4
4
|
import { Icon } from '../../components/icon/index.js';
|
|
5
5
|
import { cn } from '../../utils/cn.js';
|
|
6
|
-
export const iconButtonVariants = cva('inline-flex items-center justify-center whitespace-nowrap transition-colors disabled:pointer-events-none shrink-0 outline-none', {
|
|
6
|
+
export const iconButtonVariants = cva('inline-flex items-center justify-center whitespace-nowrap transition-colors cursor-pointer disabled:pointer-events-none shrink-0 outline-none', {
|
|
7
7
|
variants: {
|
|
8
8
|
variant: {
|
|
9
9
|
primary: 'bg-background-button-inverted-default text-tag-neutral-icon shadow-button-inverted hover:bg-background-button-inverted-hover active:bg-background-button-inverted-pressed focus-visible:shadow-button-inverted-focus disabled:bg-background-neutral-disabled disabled:text-foreground-neutral-disabled disabled:shadow-none',
|
|
@@ -55,6 +55,9 @@ export function IconButton({ className, variant, size, radius, muted, asChild =
|
|
|
55
55
|
disabled: disabled || isLoading,
|
|
56
56
|
"aria-busy": isLoading,
|
|
57
57
|
"aria-live": isLoading ? 'polite' : undefined,
|
|
58
|
+
...asChild ? {
|
|
59
|
+
'aria-disabled': disabled || isLoading
|
|
60
|
+
} : {},
|
|
58
61
|
...props,
|
|
59
62
|
children: isLoading ? /*#__PURE__*/ _jsx(Icon, {
|
|
60
63
|
name: "spinner",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/button/icon-button.tsx"],"sourcesContent":["import {Slot} from '@radix-ui/react-slot';\nimport {cva, type VariantProps} from 'class-variance-authority';\nimport {Icon, type IconName} from 'components/icon';\nimport type {ComponentProps} from 'react';\nimport {cn} from 'utils/cn';\n\nexport const iconButtonVariants = cva(\n 'inline-flex items-center justify-center whitespace-nowrap transition-colors disabled:pointer-events-none shrink-0 outline-none',\n {\n variants: {\n variant: {\n primary:\n 'bg-background-button-inverted-default text-tag-neutral-icon shadow-button-inverted hover:bg-background-button-inverted-hover active:bg-background-button-inverted-pressed focus-visible:shadow-button-inverted-focus disabled:bg-background-neutral-disabled disabled:text-foreground-neutral-disabled disabled:shadow-none',\n transparent:\n 'bg-background-button-transparent-default text-tag-neutral-icon hover:bg-background-button-transparent-hover active:bg-background-button-transparent-pressed focus-visible:shadow-button-neutral-focus disabled:text-foreground-neutral-disabled',\n },\n size: {\n '2xs': 'w-20 h-20 text-xs',\n xs: 'w-24 h-24 text-xs',\n sm: 'w-28 h-28 text-sm',\n md: 'w-32 h-32 text-md',\n lg: 'w-36 h-36 text-lg',\n xl: 'w-40 h-40 text-xl',\n },\n radius: {\n rounded: 'rounded-6',\n full: 'rounded-full',\n },\n muted: {\n true: 'opacity-60',\n false: '',\n },\n },\n defaultVariants: {\n variant: 'primary',\n size: 'md',\n radius: 'rounded',\n muted: false,\n },\n },\n);\n\nconst spinnerSizeMap: Record<\n NonNullable<VariantProps<typeof iconButtonVariants>['size']>,\n string\n> = {\n '2xs': 'size-8',\n xs: 'size-10',\n sm: 'size-12',\n md: 'size-14',\n lg: 'size-16',\n xl: 'size-18',\n};\n\nexport function IconButton({\n className,\n variant,\n size,\n radius,\n muted,\n asChild = false,\n children,\n icon,\n isLoading = false,\n disabled,\n ...props\n}: ComponentProps<'button'> &\n VariantProps<typeof iconButtonVariants> & {\n asChild?: boolean;\n icon?: IconName;\n isLoading?: boolean;\n }) {\n const Comp = asChild ? Slot : 'button';\n const spinnerSize = spinnerSizeMap[size ?? 'md'];\n\n return (\n <Comp\n data-slot=\"icon-button\"\n className={cn(iconButtonVariants({variant, size, radius, muted}), className)}\n disabled={disabled || isLoading}\n aria-busy={isLoading}\n aria-live={isLoading ? 'polite' : undefined}\n {...props}\n >\n {isLoading ? (\n <Icon name=\"spinner\" className={spinnerSize} />\n ) : icon ? (\n <Icon name={icon} />\n ) : (\n children\n )}\n </Comp>\n );\n}\n"],"names":["Slot","cva","Icon","cn","iconButtonVariants","variants","variant","primary","transparent","size","xs","sm","md","lg","xl","radius","rounded","full","muted","true","false","defaultVariants","spinnerSizeMap","IconButton","className","asChild","children","icon","isLoading","disabled","props","Comp","spinnerSize","data-slot","aria-busy","aria-live","undefined","name"],"mappings":";AAAA,SAAQA,IAAI,QAAO,uBAAuB;AAC1C,SAAQC,GAAG,QAA0B,2BAA2B;AAChE,SAAQC,IAAI,QAAsB,kBAAkB;AAEpD,SAAQC,EAAE,QAAO,WAAW;AAE5B,OAAO,MAAMC,qBAAqBH,IAChC,
|
|
1
|
+
{"version":3,"sources":["../../../src/components/button/icon-button.tsx"],"sourcesContent":["import {Slot} from '@radix-ui/react-slot';\nimport {cva, type VariantProps} from 'class-variance-authority';\nimport {Icon, type IconName} from 'components/icon';\nimport type {ComponentProps} from 'react';\nimport {cn} from 'utils/cn';\n\nexport const iconButtonVariants = cva(\n 'inline-flex items-center justify-center whitespace-nowrap transition-colors cursor-pointer disabled:pointer-events-none shrink-0 outline-none',\n {\n variants: {\n variant: {\n primary:\n 'bg-background-button-inverted-default text-tag-neutral-icon shadow-button-inverted hover:bg-background-button-inverted-hover active:bg-background-button-inverted-pressed focus-visible:shadow-button-inverted-focus disabled:bg-background-neutral-disabled disabled:text-foreground-neutral-disabled disabled:shadow-none',\n transparent:\n 'bg-background-button-transparent-default text-tag-neutral-icon hover:bg-background-button-transparent-hover active:bg-background-button-transparent-pressed focus-visible:shadow-button-neutral-focus disabled:text-foreground-neutral-disabled',\n },\n size: {\n '2xs': 'w-20 h-20 text-xs',\n xs: 'w-24 h-24 text-xs',\n sm: 'w-28 h-28 text-sm',\n md: 'w-32 h-32 text-md',\n lg: 'w-36 h-36 text-lg',\n xl: 'w-40 h-40 text-xl',\n },\n radius: {\n rounded: 'rounded-6',\n full: 'rounded-full',\n },\n muted: {\n true: 'opacity-60',\n false: '',\n },\n },\n defaultVariants: {\n variant: 'primary',\n size: 'md',\n radius: 'rounded',\n muted: false,\n },\n },\n);\n\nconst spinnerSizeMap: Record<\n NonNullable<VariantProps<typeof iconButtonVariants>['size']>,\n string\n> = {\n '2xs': 'size-8',\n xs: 'size-10',\n sm: 'size-12',\n md: 'size-14',\n lg: 'size-16',\n xl: 'size-18',\n};\n\nexport function IconButton({\n className,\n variant,\n size,\n radius,\n muted,\n asChild = false,\n children,\n icon,\n isLoading = false,\n disabled,\n ...props\n}: ComponentProps<'button'> &\n VariantProps<typeof iconButtonVariants> & {\n asChild?: boolean;\n icon?: IconName;\n isLoading?: boolean;\n }) {\n const Comp = asChild ? Slot : 'button';\n const spinnerSize = spinnerSizeMap[size ?? 'md'];\n\n return (\n <Comp\n data-slot=\"icon-button\"\n className={cn(iconButtonVariants({variant, size, radius, muted}), className)}\n disabled={disabled || isLoading}\n aria-busy={isLoading}\n aria-live={isLoading ? 'polite' : undefined}\n {...(asChild ? {'aria-disabled': disabled || isLoading} : {})}\n {...props}\n >\n {isLoading ? (\n <Icon name=\"spinner\" className={spinnerSize} />\n ) : icon ? (\n <Icon name={icon} />\n ) : (\n children\n )}\n </Comp>\n );\n}\n"],"names":["Slot","cva","Icon","cn","iconButtonVariants","variants","variant","primary","transparent","size","xs","sm","md","lg","xl","radius","rounded","full","muted","true","false","defaultVariants","spinnerSizeMap","IconButton","className","asChild","children","icon","isLoading","disabled","props","Comp","spinnerSize","data-slot","aria-busy","aria-live","undefined","name"],"mappings":";AAAA,SAAQA,IAAI,QAAO,uBAAuB;AAC1C,SAAQC,GAAG,QAA0B,2BAA2B;AAChE,SAAQC,IAAI,QAAsB,kBAAkB;AAEpD,SAAQC,EAAE,QAAO,WAAW;AAE5B,OAAO,MAAMC,qBAAqBH,IAChC,iJACA;IACEI,UAAU;QACRC,SAAS;YACPC,SACE;YACFC,aACE;QACJ;QACAC,MAAM;YACJ,OAAO;YACPC,IAAI;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;QACN;QACAC,QAAQ;YACNC,SAAS;YACTC,MAAM;QACR;QACAC,OAAO;YACLC,MAAM;YACNC,OAAO;QACT;IACF;IACAC,iBAAiB;QACff,SAAS;QACTG,MAAM;QACNM,QAAQ;QACRG,OAAO;IACT;AACF,GACA;AAEF,MAAMI,iBAGF;IACF,OAAO;IACPZ,IAAI;IACJC,IAAI;IACJC,IAAI;IACJC,IAAI;IACJC,IAAI;AACN;AAEA,OAAO,SAASS,WAAW,EACzBC,SAAS,EACTlB,OAAO,EACPG,IAAI,EACJM,MAAM,EACNG,KAAK,EACLO,UAAU,KAAK,EACfC,QAAQ,EACRC,IAAI,EACJC,YAAY,KAAK,EACjBC,QAAQ,EACR,GAAGC,OAMF;IACD,MAAMC,OAAON,UAAUzB,OAAO;IAC9B,MAAMgC,cAAcV,cAAc,CAACb,QAAQ,KAAK;IAEhD,qBACE,KAACsB;QACCE,aAAU;QACVT,WAAWrB,GAAGC,mBAAmB;YAACE;YAASG;YAAMM;YAAQG;QAAK,IAAIM;QAClEK,UAAUA,YAAYD;QACtBM,aAAWN;QACXO,aAAWP,YAAY,WAAWQ;QACjC,GAAIX,UAAU;YAAC,iBAAiBI,YAAYD;QAAS,IAAI,CAAC,CAAC;QAC3D,GAAGE,KAAK;kBAERF,0BACC,KAAC1B;YAAKmC,MAAK;YAAUb,WAAWQ;aAC9BL,qBACF,KAACzB;YAAKmC,MAAMV;aAEZD;;AAIR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox-links.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox/checkbox-links.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkbox-links.d.ts","sourceRoot":"","sources":["../../../src/components/checkbox/checkbox-links.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,SAAS,EAAQ,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAW,KAAK,aAAa,EAAC,MAAM,YAAY,CAAC;AAExD,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG;IAC3D,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAC5B,EAAE,EACF,KAAK,EACL,KAAK,EACL,SAAS,EACT,SAAS,EACT,cAAc,EACd,aAAa,EACb,GAAG,aAAa,EACjB,EAAE,kBAAkB,2CA4DpB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { buttonLinkVariants } from '../../components/button/button-link.js';
|
|
2
3
|
import { Label } from '../../components/label/index.js';
|
|
3
4
|
import { useId } from 'react';
|
|
4
5
|
import { cn } from '../../utils/cn.js';
|
|
@@ -36,13 +37,18 @@ export function CheckboxLinks({ id, label, links, separator, className, labelCla
|
|
|
36
37
|
children: [
|
|
37
38
|
link.href ? /*#__PURE__*/ _jsx("a", {
|
|
38
39
|
href: link.href,
|
|
40
|
+
target: "_blank",
|
|
41
|
+
rel: "noopener noreferrer",
|
|
39
42
|
onClick: link.onClick,
|
|
40
|
-
className: cn('text-sm leading-20 font-medium text-foreground-highlight-interactive', 'hover:text-foreground-highlight-interactive-hover', linkClassName),
|
|
43
|
+
className: cn('text-sm leading-20 font-medium text-foreground-highlight-interactive', 'hover:text-foreground-highlight-interactive-hover transition-colors', linkClassName),
|
|
41
44
|
children: link.label
|
|
42
45
|
}) : /*#__PURE__*/ _jsx("button", {
|
|
43
46
|
type: "button",
|
|
44
47
|
onClick: link.onClick,
|
|
45
|
-
className: cn(
|
|
48
|
+
className: cn(buttonLinkVariants({
|
|
49
|
+
variant: 'interactive',
|
|
50
|
+
size: 'sm'
|
|
51
|
+
}), linkClassName),
|
|
46
52
|
children: link.label
|
|
47
53
|
}),
|
|
48
54
|
index < links.length - 1 && (separator ?? defaultSeparator)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/checkbox/checkbox-links.tsx"],"sourcesContent":["import {Label} from 'components/label';\nimport {type ReactNode, useId} from 'react';\nimport {cn} from 'utils/cn';\nimport {Checkbox, type CheckboxProps} from './checkbox';\n\nexport type CheckboxLink = {\n label: string;\n href?: string;\n onClick?: () => void;\n};\n\nexport type CheckboxLinksProps = Omit<CheckboxProps, 'id'> & {\n id?: string;\n label: string;\n links: CheckboxLink[];\n separator?: ReactNode;\n className?: string;\n labelClassName?: string;\n linkClassName?: string;\n};\n\nexport function CheckboxLinks({\n id,\n label,\n links,\n separator,\n className,\n labelClassName,\n linkClassName,\n ...checkboxProps\n}: CheckboxLinksProps) {\n const generateId = useId();\n const checkboxId = id || generateId;\n const isDisabled = checkboxProps.disabled ?? false;\n const defaultSeparator = (\n <span className=\"size-3 rounded-full bg-foreground-neutral-muted\" aria-hidden=\"true\" />\n );\n\n return (\n <div className={cn('flex gap-10 items-start', className)}>\n <span className=\"p-2\">\n <Checkbox id={checkboxId} {...checkboxProps} />\n </span>\n <div className=\"flex flex-col gap-4 items-start flex-1\">\n <Label\n htmlFor={checkboxId}\n className={cn(\n 'text-sm leading-20 font-medium text-foreground-neutral-base',\n isDisabled && 'cursor-not-allowed opacity-50',\n labelClassName,\n )}\n >\n {label}\n </Label>\n <div className=\"flex gap-6 items-center\">\n {links.map((link, index) => (\n <div key={link.label} className=\"flex gap-6 items-center\">\n {link.href ? (\n <a\n href={link.href}\n onClick={link.onClick}\n className={cn(\n 'text-sm leading-20 font-medium text-foreground-highlight-interactive',\n 'hover:text-foreground-highlight-interactive-hover',\n linkClassName,\n )}\n >\n {link.label}\n </a>\n ) : (\n <button\n type=\"button\"\n onClick={link.onClick}\n className={cn(\n '
|
|
1
|
+
{"version":3,"sources":["../../../src/components/checkbox/checkbox-links.tsx"],"sourcesContent":["import {buttonLinkVariants} from 'components/button/button-link';\nimport {Label} from 'components/label';\nimport {type ReactNode, useId} from 'react';\nimport {cn} from 'utils/cn';\nimport {Checkbox, type CheckboxProps} from './checkbox';\n\nexport type CheckboxLink = {\n label: string;\n href?: string;\n onClick?: () => void;\n};\n\nexport type CheckboxLinksProps = Omit<CheckboxProps, 'id'> & {\n id?: string;\n label: string;\n links: CheckboxLink[];\n separator?: ReactNode;\n className?: string;\n labelClassName?: string;\n linkClassName?: string;\n};\n\nexport function CheckboxLinks({\n id,\n label,\n links,\n separator,\n className,\n labelClassName,\n linkClassName,\n ...checkboxProps\n}: CheckboxLinksProps) {\n const generateId = useId();\n const checkboxId = id || generateId;\n const isDisabled = checkboxProps.disabled ?? false;\n const defaultSeparator = (\n <span className=\"size-3 rounded-full bg-foreground-neutral-muted\" aria-hidden=\"true\" />\n );\n\n return (\n <div className={cn('flex gap-10 items-start', className)}>\n <span className=\"p-2\">\n <Checkbox id={checkboxId} {...checkboxProps} />\n </span>\n <div className=\"flex flex-col gap-4 items-start flex-1\">\n <Label\n htmlFor={checkboxId}\n className={cn(\n 'text-sm leading-20 font-medium text-foreground-neutral-base',\n isDisabled && 'cursor-not-allowed opacity-50',\n labelClassName,\n )}\n >\n {label}\n </Label>\n <div className=\"flex gap-6 items-center\">\n {links.map((link, index) => (\n <div key={link.label} className=\"flex gap-6 items-center\">\n {link.href ? (\n <a\n href={link.href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={link.onClick}\n className={cn(\n 'text-sm leading-20 font-medium text-foreground-highlight-interactive',\n 'hover:text-foreground-highlight-interactive-hover transition-colors',\n linkClassName,\n )}\n >\n {link.label}\n </a>\n ) : (\n <button\n type=\"button\"\n onClick={link.onClick}\n className={cn(\n buttonLinkVariants({variant: 'interactive', size: 'sm'}),\n linkClassName,\n )}\n >\n {link.label}\n </button>\n )}\n {index < links.length - 1 && (separator ?? defaultSeparator)}\n </div>\n ))}\n </div>\n </div>\n </div>\n );\n}\n"],"names":["buttonLinkVariants","Label","useId","cn","Checkbox","CheckboxLinks","id","label","links","separator","className","labelClassName","linkClassName","checkboxProps","generateId","checkboxId","isDisabled","disabled","defaultSeparator","span","aria-hidden","div","htmlFor","map","link","index","href","a","target","rel","onClick","button","type","variant","size","length"],"mappings":";AAAA,SAAQA,kBAAkB,QAAO,gCAAgC;AACjE,SAAQC,KAAK,QAAO,mBAAmB;AACvC,SAAwBC,KAAK,QAAO,QAAQ;AAC5C,SAAQC,EAAE,QAAO,WAAW;AAC5B,SAAQC,QAAQ,QAA2B,aAAa;AAkBxD,OAAO,SAASC,cAAc,EAC5BC,EAAE,EACFC,KAAK,EACLC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,cAAc,EACdC,aAAa,EACb,GAAGC,eACgB;IACnB,MAAMC,aAAaZ;IACnB,MAAMa,aAAaT,MAAMQ;IACzB,MAAME,aAAaH,cAAcI,QAAQ,IAAI;IAC7C,MAAMC,iCACJ,KAACC;QAAKT,WAAU;QAAkDU,eAAY;;IAGhF,qBACE,MAACC;QAAIX,WAAWP,GAAG,2BAA2BO;;0BAC5C,KAACS;gBAAKT,WAAU;0BACd,cAAA,KAACN;oBAASE,IAAIS;oBAAa,GAAGF,aAAa;;;0BAE7C,MAACQ;gBAAIX,WAAU;;kCACb,KAACT;wBACCqB,SAASP;wBACTL,WAAWP,GACT,+DACAa,cAAc,iCACdL;kCAGDJ;;kCAEH,KAACc;wBAAIX,WAAU;kCACZF,MAAMe,GAAG,CAAC,CAACC,MAAMC,sBAChB,MAACJ;gCAAqBX,WAAU;;oCAC7Bc,KAAKE,IAAI,iBACR,KAACC;wCACCD,MAAMF,KAAKE,IAAI;wCACfE,QAAO;wCACPC,KAAI;wCACJC,SAASN,KAAKM,OAAO;wCACrBpB,WAAWP,GACT,wEACA,uEACAS;kDAGDY,KAAKjB,KAAK;uDAGb,KAACwB;wCACCC,MAAK;wCACLF,SAASN,KAAKM,OAAO;wCACrBpB,WAAWP,GACTH,mBAAmB;4CAACiC,SAAS;4CAAeC,MAAM;wCAAI,IACtDtB;kDAGDY,KAAKjB,KAAK;;oCAGdkB,QAAQjB,MAAM2B,MAAM,GAAG,KAAM1B,CAAAA,aAAaS,gBAAe;;+BA3BlDM,KAAKjB,KAAK;;;;;;AAkChC"}
|
|
@@ -534,11 +534,11 @@ export const CheckboxLinksStory = {
|
|
|
534
534
|
links: [
|
|
535
535
|
{
|
|
536
536
|
label: 'Terms of use',
|
|
537
|
-
href: '
|
|
537
|
+
href: 'https://www.shipfox.io/legal/terms-of-service'
|
|
538
538
|
},
|
|
539
539
|
{
|
|
540
540
|
label: 'Privacy Policy',
|
|
541
|
-
|
|
541
|
+
onClick: ()=>window.open('https://www.shipfox.io/legal/privacy-policy', '_blank', 'noopener,noreferrer')
|
|
542
542
|
}
|
|
543
543
|
]
|
|
544
544
|
}),
|
|
@@ -548,11 +548,11 @@ export const CheckboxLinksStory = {
|
|
|
548
548
|
links: [
|
|
549
549
|
{
|
|
550
550
|
label: 'Terms of use',
|
|
551
|
-
href: '
|
|
551
|
+
href: 'https://www.shipfox.io/legal/terms-of-service'
|
|
552
552
|
},
|
|
553
553
|
{
|
|
554
554
|
label: 'Privacy Policy',
|
|
555
|
-
|
|
555
|
+
onClick: ()=>window.open('https://www.shipfox.io/legal/privacy-policy', '_blank', 'noopener,noreferrer')
|
|
556
556
|
}
|
|
557
557
|
],
|
|
558
558
|
checked: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/checkbox/checkbox.stories.tsx"],"sourcesContent":["import type {Meta, StoryObj} from '@storybook/react';\nimport {Code, Header} from 'components/typography';\nimport {Checkbox, CheckboxLabel, CheckboxLinks} from '.';\n\nconst meta = {\n title: 'Components/Checkbox',\n component: Checkbox,\n tags: ['autodocs'],\n argTypes: {\n size: {\n control: 'select',\n options: ['sm', 'md', 'lg'],\n },\n disabled: {control: 'boolean'},\n checked: {control: 'boolean'},\n },\n args: {\n size: 'md',\n disabled: false,\n },\n} satisfies Meta<typeof Checkbox>;\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\n\nexport const Default: Story = {\n render: (args) => (\n <div className=\"flex flex-col gap-32\">\n <div className=\"flex flex-col gap-16\">\n <Header variant=\"h4\">Controlled Checkbox</Header>\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Use the controls below to change the checkbox state\n </Code>\n <Checkbox {...args} />\n </div>\n\n <div className=\"flex flex-col gap-32\">\n <Header variant=\"h4\">All States</Header>\n {(['sm', 'md', 'lg'] as const).map((size) => (\n <div key={size} className=\"flex flex-wrap gap-16\">\n <Header variant=\"h4\">Size: {size}</Header>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Unchecked\n </Code>\n <Checkbox size={size} />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Checked\n </Code>\n <Checkbox size={size} checked />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Indeterminate\n </Code>\n <Checkbox size={size} checked=\"indeterminate\" />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Disabled (Unchecked)\n </Code>\n <Checkbox size={size} disabled />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Disabled (Checked)\n </Code>\n <Checkbox size={size} checked disabled />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Focus\n </Code>\n <Checkbox size={size} className=\"focus\" />\n </div>\n </div>\n ))}\n </div>\n </div>\n ),\n parameters: {\n pseudo: {\n focusVisible: '.focus',\n },\n },\n};\n\nexport const CheckboxLabelStory: StoryObj = {\n render: () => (\n <div className=\"flex flex-col gap-32 pb-64 pt-32 px-32 bg-background-neutral-base\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n CHECKBOX LABEL - WITHOUT BORDER\n </Code>\n <div className=\"flex flex-col gap-16\">\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Default - Unchecked\n </Code>\n <CheckboxLabel\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Hover - Unchecked\n </Code>\n <CheckboxLabel\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n className=\"hover\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Default - Checked\n </Code>\n <CheckboxLabel\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Hover - Checked\n </Code>\n <CheckboxLabel\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked\n className=\"hover\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Default - Indeterminate\n </Code>\n <CheckboxLabel\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked=\"indeterminate\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Disabled - Checked\n </Code>\n <CheckboxLabel\n label=\"Label\"\n checked\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n disabled\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Disabled - Unchecked\n </Code>\n <CheckboxLabel\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n disabled\n />\n </div>\n </div>\n\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle mt-32\">\n CHECKBOX LABEL - WITH BORDER\n </Code>\n <div className=\"flex flex-col gap-16\">\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Default - Unchecked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-default-unchecked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n border\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Hover - Unchecked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-hover-unchecked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n border\n className=\"hover\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Focus - Unchecked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-focus-unchecked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n border\n className=\"focus\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Default - Checked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-default-checked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked\n border\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Hover - Checked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-hover-checked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked\n border\n className=\"hover\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Focus - Checked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-focus-checked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked\n border\n className=\"focus\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Default - Indeterminate\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-default-indeterminate\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked=\"indeterminate\"\n border\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Disabled - Unchecked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-disabled-unchecked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n disabled\n border\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Disabled - Checked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-disabled-checked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked\n disabled\n border\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Disabled - Indeterminate\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-disabled-indeterminate\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked=\"indeterminate\"\n disabled\n border\n />\n </div>\n </div>\n </div>\n ),\n};\n\nCheckboxLabelStory.parameters = {\n pseudo: {\n hover: '.hover',\n focusVisible: '.focus',\n },\n};\n\nexport const CheckboxLinksStory: StoryObj = {\n args: {\n disabled: true,\n },\n\n render: () => (\n <div className=\"flex flex-col gap-32 pb-64 pt-32 px-32 bg-background-neutral-base\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n CHECKBOX LINKS\n </Code>\n <div className=\"flex flex-col gap-16\">\n <CheckboxLinks\n id=\"checkbox-links-default\"\n label=\"Accept policies\"\n links={[\n {label: 'Terms of use', href: '#'},\n {label: 'Privacy Policy', href: '#'},\n ]}\n />\n <CheckboxLinks\n id=\"checkbox-links-checked\"\n label=\"Accept policies\"\n links={[\n {label: 'Terms of use', href: '#'},\n {label: 'Privacy Policy', href: '#'},\n ]}\n checked\n />\n </div>\n </div>\n ),\n};\n"],"names":["Code","Header","Checkbox","CheckboxLabel","CheckboxLinks","meta","title","component","tags","argTypes","size","control","options","disabled","checked","args","Default","render","div","className","variant","map","parameters","pseudo","focusVisible","CheckboxLabelStory","label","optional","showInfoIcon","description","id","border","hover","CheckboxLinksStory","links","href"],"mappings":";AACA,SAAQA,IAAI,EAAEC,MAAM,QAAO,wBAAwB;AACnD,SAAQC,QAAQ,EAAEC,aAAa,EAAEC,aAAa,QAAO,IAAI;AAEzD,MAAMC,OAAO;IACXC,OAAO;IACPC,WAAWL;IACXM,MAAM;QAAC;KAAW;IAClBC,UAAU;QACRC,MAAM;YACJC,SAAS;YACTC,SAAS;gBAAC;gBAAM;gBAAM;aAAK;QAC7B;QACAC,UAAU;YAACF,SAAS;QAAS;QAC7BG,SAAS;YAACH,SAAS;QAAS;IAC9B;IACAI,MAAM;QACJL,MAAM;QACNG,UAAU;IACZ;AACF;AAEA,eAAeR,KAAK;AAIpB,OAAO,MAAMW,UAAiB;IAC5BC,QAAQ,CAACF,qBACP,MAACG;YAAIC,WAAU;;8BACb,MAACD;oBAAIC,WAAU;;sCACb,KAAClB;4BAAOmB,SAAQ;sCAAK;;sCACrB,KAACpB;4BAAKoB,SAAQ;4BAAQD,WAAU;sCAAiC;;sCAGjE,KAACjB;4BAAU,GAAGa,IAAI;;;;8BAGpB,MAACG;oBAAIC,WAAU;;sCACb,KAAClB;4BAAOmB,SAAQ;sCAAK;;wBACnB;4BAAC;4BAAM;4BAAM;yBAAK,CAAWC,GAAG,CAAC,CAACX,qBAClC,MAACQ;gCAAeC,WAAU;;kDACxB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oCAACR,OAAO;oCAAgBS,MAAM;gCAAG;gCACjC;oCAACT,OAAO;oCAAkBS,MAAM;gCAAG;6BACpC;4BACDrB,OAAO;;;;;;AAKjB,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/checkbox/checkbox.stories.tsx"],"sourcesContent":["import type {Meta, StoryObj} from '@storybook/react';\nimport {Code, Header} from 'components/typography';\nimport {Checkbox, CheckboxLabel, CheckboxLinks} from '.';\n\nconst meta = {\n title: 'Components/Checkbox',\n component: Checkbox,\n tags: ['autodocs'],\n argTypes: {\n size: {\n control: 'select',\n options: ['sm', 'md', 'lg'],\n },\n disabled: {control: 'boolean'},\n checked: {control: 'boolean'},\n },\n args: {\n size: 'md',\n disabled: false,\n },\n} satisfies Meta<typeof Checkbox>;\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\n\nexport const Default: Story = {\n render: (args) => (\n <div className=\"flex flex-col gap-32\">\n <div className=\"flex flex-col gap-16\">\n <Header variant=\"h4\">Controlled Checkbox</Header>\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Use the controls below to change the checkbox state\n </Code>\n <Checkbox {...args} />\n </div>\n\n <div className=\"flex flex-col gap-32\">\n <Header variant=\"h4\">All States</Header>\n {(['sm', 'md', 'lg'] as const).map((size) => (\n <div key={size} className=\"flex flex-wrap gap-16\">\n <Header variant=\"h4\">Size: {size}</Header>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Unchecked\n </Code>\n <Checkbox size={size} />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Checked\n </Code>\n <Checkbox size={size} checked />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Indeterminate\n </Code>\n <Checkbox size={size} checked=\"indeterminate\" />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Disabled (Unchecked)\n </Code>\n <Checkbox size={size} disabled />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Disabled (Checked)\n </Code>\n <Checkbox size={size} checked disabled />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Focus\n </Code>\n <Checkbox size={size} className=\"focus\" />\n </div>\n </div>\n ))}\n </div>\n </div>\n ),\n parameters: {\n pseudo: {\n focusVisible: '.focus',\n },\n },\n};\n\nexport const CheckboxLabelStory: StoryObj = {\n render: () => (\n <div className=\"flex flex-col gap-32 pb-64 pt-32 px-32 bg-background-neutral-base\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n CHECKBOX LABEL - WITHOUT BORDER\n </Code>\n <div className=\"flex flex-col gap-16\">\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Default - Unchecked\n </Code>\n <CheckboxLabel\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Hover - Unchecked\n </Code>\n <CheckboxLabel\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n className=\"hover\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Default - Checked\n </Code>\n <CheckboxLabel\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Hover - Checked\n </Code>\n <CheckboxLabel\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked\n className=\"hover\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Default - Indeterminate\n </Code>\n <CheckboxLabel\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked=\"indeterminate\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Disabled - Checked\n </Code>\n <CheckboxLabel\n label=\"Label\"\n checked\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n disabled\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Disabled - Unchecked\n </Code>\n <CheckboxLabel\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n disabled\n />\n </div>\n </div>\n\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle mt-32\">\n CHECKBOX LABEL - WITH BORDER\n </Code>\n <div className=\"flex flex-col gap-16\">\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Default - Unchecked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-default-unchecked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n border\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Hover - Unchecked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-hover-unchecked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n border\n className=\"hover\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Focus - Unchecked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-focus-unchecked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n border\n className=\"focus\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Default - Checked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-default-checked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked\n border\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Hover - Checked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-hover-checked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked\n border\n className=\"hover\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Focus - Checked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-focus-checked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked\n border\n className=\"focus\"\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Default - Indeterminate\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-default-indeterminate\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked=\"indeterminate\"\n border\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Disabled - Unchecked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-disabled-unchecked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n disabled\n border\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Disabled - Checked\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-disabled-checked\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked\n disabled\n border\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle text-xs\">\n Disabled - Indeterminate\n </Code>\n <CheckboxLabel\n id=\"checkbox-border-disabled-indeterminate\"\n label=\"Label\"\n optional\n showInfoIcon\n description=\"The quick brown fox jumps over a lazy dog.\"\n checked=\"indeterminate\"\n disabled\n border\n />\n </div>\n </div>\n </div>\n ),\n};\n\nCheckboxLabelStory.parameters = {\n pseudo: {\n hover: '.hover',\n focusVisible: '.focus',\n },\n};\n\nexport const CheckboxLinksStory: StoryObj = {\n args: {\n disabled: true,\n },\n\n render: () => (\n <div className=\"flex flex-col gap-32 pb-64 pt-32 px-32 bg-background-neutral-base\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n CHECKBOX LINKS\n </Code>\n <div className=\"flex flex-col gap-16\">\n <CheckboxLinks\n id=\"checkbox-links-default\"\n label=\"Accept policies\"\n links={[\n {label: 'Terms of use', href: 'https://www.shipfox.io/legal/terms-of-service'},\n {\n label: 'Privacy Policy',\n onClick: () =>\n window.open(\n 'https://www.shipfox.io/legal/privacy-policy',\n '_blank',\n 'noopener,noreferrer',\n ),\n },\n ]}\n />\n <CheckboxLinks\n id=\"checkbox-links-checked\"\n label=\"Accept policies\"\n links={[\n {label: 'Terms of use', href: 'https://www.shipfox.io/legal/terms-of-service'},\n {\n label: 'Privacy Policy',\n onClick: () =>\n window.open(\n 'https://www.shipfox.io/legal/privacy-policy',\n '_blank',\n 'noopener,noreferrer',\n ),\n },\n ]}\n checked\n />\n </div>\n </div>\n ),\n};\n"],"names":["Code","Header","Checkbox","CheckboxLabel","CheckboxLinks","meta","title","component","tags","argTypes","size","control","options","disabled","checked","args","Default","render","div","className","variant","map","parameters","pseudo","focusVisible","CheckboxLabelStory","label","optional","showInfoIcon","description","id","border","hover","CheckboxLinksStory","links","href","onClick","window","open"],"mappings":";A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NC,QAAQ;oCACRC,YAAY;oCACZC,aAAY;oCACZf,OAAO;oCACPD,QAAQ;oCACRkB,MAAM;;;;sCAGV,MAACb;4BAAIC,WAAU;;8CACb,KAACnB;oCAAKoB,SAAQ;oCAAQD,WAAU;8CAAyC;;8CAGzE,KAAChB;oCACC2B,IAAG;oCACHJ,OAAM;oCACNC,QAAQ;oCACRC,YAAY;oCACZC,aAAY;oCACZf,SAAQ;oCACRD,QAAQ;oCACRkB,MAAM;;;;;;;;AAMlB,EAAE;AAEFN,mBAAmBH,UAAU,GAAG;IAC9BC,QAAQ;QACNS,OAAO;QACPR,cAAc;IAChB;AACF;AAEA,OAAO,MAAMS,qBAA+B;IAC1ClB,MAAM;QACJF,UAAU;IACZ;IAEAI,QAAQ,kBACN,MAACC;YAAIC,WAAU;;8BACb,KAACnB;oBAAKoB,SAAQ;oBAAQD,WAAU;8BAAiC;;8BAGjE,MAACD;oBAAIC,WAAU;;sCACb,KAACf;4BACC0B,IAAG;4BACHJ,OAAM;4BACNQ,OAAO;gCACL;oCAACR,OAAO;oCAAgBS,MAAM;gCAA+C;gCAC7E;oCACET,OAAO;oCACPU,SAAS,IACPC,OAAOC,IAAI,CACT,+CACA,UACA;gCAEN;6BACD;;sCAEH,KAAClC;4BACC0B,IAAG;4BACHJ,OAAM;4BACNQ,OAAO;gCACL;oCAACR,OAAO;oCAAgBS,MAAM;gCAA+C;gCAC7E;oCACET,OAAO;oCACPU,SAAS,IACPC,OAAOC,IAAI,CACT,+CACA,UACA;gCAEN;6BACD;4BACDxB,OAAO;;;;;;AAKjB,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import {zodResolver} from '@hookform/resolvers/zod';
|
|
1
2
|
import type {Meta, StoryObj} from '@storybook/react';
|
|
3
|
+
import {Button} from 'components/button';
|
|
4
|
+
import {Form, FormControl, FormField, FormItem, FormLabel, FormMessage} from 'components/form';
|
|
5
|
+
import {Input} from 'components/input';
|
|
2
6
|
import {Header} from 'components/typography';
|
|
7
|
+
import {useState} from 'react';
|
|
8
|
+
import {useForm} from 'react-hook-form';
|
|
9
|
+
import {z} from 'zod';
|
|
3
10
|
import {
|
|
4
11
|
Alert,
|
|
5
12
|
AlertAction,
|
|
@@ -43,12 +50,106 @@ export const Default: Story = {
|
|
|
43
50
|
<AlertAction>View</AlertAction>
|
|
44
51
|
</AlertActions>
|
|
45
52
|
</AlertContent>
|
|
46
|
-
<AlertClose
|
|
53
|
+
<AlertClose />
|
|
47
54
|
</Alert>
|
|
48
55
|
);
|
|
49
56
|
},
|
|
50
57
|
};
|
|
51
58
|
|
|
59
|
+
const validationFormSchema = z.object({
|
|
60
|
+
email: z.string().email('Please enter a valid email address'),
|
|
61
|
+
password: z.string().min(8, 'Password must be at least 8 characters'),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
type ValidationFormValues = z.infer<typeof validationFormSchema>;
|
|
65
|
+
|
|
66
|
+
function ErrorValidationToasterExample() {
|
|
67
|
+
const [showError, setShowError] = useState(false);
|
|
68
|
+
const form = useForm<ValidationFormValues>({
|
|
69
|
+
resolver: zodResolver(validationFormSchema),
|
|
70
|
+
defaultValues: {
|
|
71
|
+
email: '',
|
|
72
|
+
password: '',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
function onSubmit(data: ValidationFormValues) {
|
|
77
|
+
// biome-ignore lint/suspicious/noConsole: <we need to log the data for the story>
|
|
78
|
+
console.log('Form submitted:', data);
|
|
79
|
+
setShowError(false);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function onError() {
|
|
83
|
+
setShowError(true);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const errors = form.formState.errors;
|
|
87
|
+
const errorCount = Object.keys(errors).length;
|
|
88
|
+
const errorMessage =
|
|
89
|
+
errorCount > 0
|
|
90
|
+
? `Please fix ${errorCount} error${errorCount > 1 ? 's' : ''} before submitting.`
|
|
91
|
+
: '';
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<div className="flex flex-col gap-16 w-full max-w-md">
|
|
95
|
+
{errorCount > 0 && (
|
|
96
|
+
<Alert variant="error" open={showError} autoClose={5000} onOpenChange={setShowError}>
|
|
97
|
+
<AlertContent>
|
|
98
|
+
<AlertTitle>Validation Error</AlertTitle>
|
|
99
|
+
<AlertDescription>{errorMessage}</AlertDescription>
|
|
100
|
+
<AlertActions>
|
|
101
|
+
<AlertAction
|
|
102
|
+
onClick={() => {
|
|
103
|
+
form.clearErrors();
|
|
104
|
+
setShowError(false);
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
Dismiss
|
|
108
|
+
</AlertAction>
|
|
109
|
+
</AlertActions>
|
|
110
|
+
</AlertContent>
|
|
111
|
+
<AlertClose />
|
|
112
|
+
</Alert>
|
|
113
|
+
)}
|
|
114
|
+
<Form {...form}>
|
|
115
|
+
<form onSubmit={form.handleSubmit(onSubmit, onError)} className="space-y-8">
|
|
116
|
+
<FormField
|
|
117
|
+
control={form.control}
|
|
118
|
+
name="email"
|
|
119
|
+
render={({field}) => (
|
|
120
|
+
<FormItem>
|
|
121
|
+
<FormLabel>Email</FormLabel>
|
|
122
|
+
<FormControl>
|
|
123
|
+
<Input type="email" placeholder="email@example.com" {...field} />
|
|
124
|
+
</FormControl>
|
|
125
|
+
<FormMessage />
|
|
126
|
+
</FormItem>
|
|
127
|
+
)}
|
|
128
|
+
/>
|
|
129
|
+
<FormField
|
|
130
|
+
control={form.control}
|
|
131
|
+
name="password"
|
|
132
|
+
render={({field}) => (
|
|
133
|
+
<FormItem>
|
|
134
|
+
<FormLabel>Password</FormLabel>
|
|
135
|
+
<FormControl>
|
|
136
|
+
<Input type="password" placeholder="Enter password" {...field} />
|
|
137
|
+
</FormControl>
|
|
138
|
+
<FormMessage />
|
|
139
|
+
</FormItem>
|
|
140
|
+
)}
|
|
141
|
+
/>
|
|
142
|
+
<Button type="submit">Submit</Button>
|
|
143
|
+
</form>
|
|
144
|
+
</Form>
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export const WithFormValidation: Story = {
|
|
150
|
+
render: () => <ErrorValidationToasterExample />,
|
|
151
|
+
};
|
|
152
|
+
|
|
52
153
|
export const DesignMock: Story = {
|
|
53
154
|
render: () => {
|
|
54
155
|
return (
|
|
@@ -67,7 +168,7 @@ export const DesignMock: Story = {
|
|
|
67
168
|
<AlertAction>View</AlertAction>
|
|
68
169
|
</AlertActions>
|
|
69
170
|
</AlertContent>
|
|
70
|
-
<AlertClose
|
|
171
|
+
<AlertClose />
|
|
71
172
|
</Alert>
|
|
72
173
|
))}
|
|
73
174
|
</div>
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import {cva, type VariantProps} from 'class-variance-authority';
|
|
2
2
|
import {Icon} from 'components/icon';
|
|
3
|
-
import type
|
|
3
|
+
import {AnimatePresence, motion, type Transition} from 'framer-motion';
|
|
4
|
+
import {
|
|
5
|
+
type ComponentProps,
|
|
6
|
+
createContext,
|
|
7
|
+
type MouseEvent,
|
|
8
|
+
useCallback,
|
|
9
|
+
useContext,
|
|
10
|
+
useEffect,
|
|
11
|
+
useRef,
|
|
12
|
+
useState,
|
|
13
|
+
} from 'react';
|
|
4
14
|
import {cn} from 'utils/cn';
|
|
5
15
|
|
|
6
16
|
const alertVariants = cva(
|
|
@@ -51,21 +61,137 @@ const closeIconVariants = cva('w-16 h-16', {
|
|
|
51
61
|
},
|
|
52
62
|
});
|
|
53
63
|
|
|
54
|
-
|
|
64
|
+
const alertDefaultTransition: Transition = {
|
|
65
|
+
duration: 0.2,
|
|
66
|
+
ease: 'easeInOut',
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
type AlertContextValue = {
|
|
70
|
+
isOpen: boolean;
|
|
71
|
+
onClose: () => void;
|
|
72
|
+
variant: VariantProps<typeof alertVariants>['variant'];
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const AlertContext = createContext<AlertContextValue | null>(null);
|
|
76
|
+
|
|
77
|
+
function useAlertContext() {
|
|
78
|
+
const context = useContext(AlertContext);
|
|
79
|
+
if (!context) {
|
|
80
|
+
throw new Error('Alert components must be used within an Alert component');
|
|
81
|
+
}
|
|
82
|
+
return context;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
type AlertProps = ComponentProps<'div'> &
|
|
86
|
+
VariantProps<typeof alertVariants> & {
|
|
87
|
+
open?: boolean;
|
|
88
|
+
defaultOpen?: boolean;
|
|
89
|
+
onOpenChange?: (open: boolean) => void;
|
|
90
|
+
animated?: boolean;
|
|
91
|
+
transition?: Transition;
|
|
92
|
+
autoClose?: number;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
function Alert({
|
|
96
|
+
className,
|
|
97
|
+
variant = 'default',
|
|
98
|
+
children,
|
|
99
|
+
open: controlledOpen,
|
|
100
|
+
defaultOpen = true,
|
|
101
|
+
onOpenChange,
|
|
102
|
+
animated = true,
|
|
103
|
+
transition = alertDefaultTransition,
|
|
104
|
+
autoClose,
|
|
105
|
+
...props
|
|
106
|
+
}: AlertProps) {
|
|
107
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
108
|
+
const isOpen = controlledOpen !== undefined ? controlledOpen : internalOpen;
|
|
109
|
+
|
|
110
|
+
const handleClose = useCallback(() => {
|
|
111
|
+
if (controlledOpen === undefined) {
|
|
112
|
+
setInternalOpen(false);
|
|
113
|
+
}
|
|
114
|
+
onOpenChange?.(false);
|
|
115
|
+
}, [controlledOpen, onOpenChange]);
|
|
116
|
+
|
|
117
|
+
const handleCloseRef = useRef(handleClose);
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
handleCloseRef.current = handleClose;
|
|
120
|
+
}, [handleClose]);
|
|
121
|
+
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (autoClose && isOpen && autoClose > 0) {
|
|
124
|
+
const timeoutId = setTimeout(() => {
|
|
125
|
+
handleCloseRef.current();
|
|
126
|
+
}, autoClose);
|
|
127
|
+
|
|
128
|
+
return () => {
|
|
129
|
+
clearTimeout(timeoutId);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}, [autoClose, isOpen]);
|
|
133
|
+
|
|
134
|
+
const contextValue: AlertContextValue = {
|
|
135
|
+
isOpen,
|
|
136
|
+
onClose: handleClose,
|
|
137
|
+
variant,
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
if (!animated) {
|
|
141
|
+
if (!isOpen) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<AlertContext.Provider value={contextValue}>
|
|
147
|
+
<div className="w-full flex items-start gap-4">
|
|
148
|
+
<div
|
|
149
|
+
data-slot="alert-line"
|
|
150
|
+
className={cn(alertLineVariants({variant}))}
|
|
151
|
+
aria-hidden="true"
|
|
152
|
+
/>
|
|
153
|
+
<div
|
|
154
|
+
data-slot="alert"
|
|
155
|
+
role="alert"
|
|
156
|
+
className={cn(alertVariants({variant}), className)}
|
|
157
|
+
{...props}
|
|
158
|
+
>
|
|
159
|
+
{children}
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</AlertContext.Provider>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
55
165
|
|
|
56
|
-
function Alert({className, variant, children, ...props}: AlertProps) {
|
|
57
166
|
return (
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
167
|
+
<AnimatePresence>
|
|
168
|
+
{isOpen && (
|
|
169
|
+
<motion.div
|
|
170
|
+
key="alert"
|
|
171
|
+
className="w-full flex items-start gap-4"
|
|
172
|
+
initial={{opacity: 0}}
|
|
173
|
+
animate={{opacity: 1}}
|
|
174
|
+
exit={{opacity: 0}}
|
|
175
|
+
transition={transition}
|
|
176
|
+
>
|
|
177
|
+
<AlertContext.Provider value={contextValue}>
|
|
178
|
+
<div
|
|
179
|
+
data-slot="alert-line"
|
|
180
|
+
className={cn(alertLineVariants({variant}))}
|
|
181
|
+
aria-hidden="true"
|
|
182
|
+
/>
|
|
183
|
+
<div
|
|
184
|
+
data-slot="alert"
|
|
185
|
+
role="alert"
|
|
186
|
+
className={cn(alertVariants({variant}), className)}
|
|
187
|
+
{...props}
|
|
188
|
+
>
|
|
189
|
+
{children}
|
|
190
|
+
</div>
|
|
191
|
+
</AlertContext.Provider>
|
|
192
|
+
</motion.div>
|
|
193
|
+
)}
|
|
194
|
+
</AnimatePresence>
|
|
69
195
|
);
|
|
70
196
|
}
|
|
71
197
|
|
|
@@ -122,9 +248,18 @@ function AlertAction({className, ...props}: ComponentProps<'button'>) {
|
|
|
122
248
|
|
|
123
249
|
function AlertClose({
|
|
124
250
|
className,
|
|
125
|
-
variant
|
|
251
|
+
variant: variantProp,
|
|
252
|
+
onClick,
|
|
126
253
|
...props
|
|
127
254
|
}: ComponentProps<'button'> & VariantProps<typeof closeIconVariants>) {
|
|
255
|
+
const {onClose, variant: contextVariant} = useAlertContext();
|
|
256
|
+
const variant = variantProp ?? contextVariant ?? 'default';
|
|
257
|
+
|
|
258
|
+
const handleClick = (e: MouseEvent<HTMLButtonElement>) => {
|
|
259
|
+
onClose();
|
|
260
|
+
onClick?.(e);
|
|
261
|
+
};
|
|
262
|
+
|
|
128
263
|
return (
|
|
129
264
|
<button
|
|
130
265
|
data-slot="alert-close"
|
|
@@ -134,6 +269,7 @@ function AlertClose({
|
|
|
134
269
|
className,
|
|
135
270
|
)}
|
|
136
271
|
aria-label="Close"
|
|
272
|
+
onClick={handleClick}
|
|
137
273
|
{...props}
|
|
138
274
|
>
|
|
139
275
|
<Icon name="close" className={cn(closeIconVariants({variant}))} />
|
|
@@ -141,4 +277,15 @@ function AlertClose({
|
|
|
141
277
|
);
|
|
142
278
|
}
|
|
143
279
|
|
|
144
|
-
export {
|
|
280
|
+
export {
|
|
281
|
+
Alert,
|
|
282
|
+
AlertContent,
|
|
283
|
+
AlertTitle,
|
|
284
|
+
AlertDescription,
|
|
285
|
+
AlertActions,
|
|
286
|
+
AlertAction,
|
|
287
|
+
AlertClose,
|
|
288
|
+
alertDefaultTransition,
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export type {AlertProps};
|
|
@@ -5,7 +5,7 @@ import type {ComponentProps} from 'react';
|
|
|
5
5
|
import {cn} from 'utils/cn';
|
|
6
6
|
|
|
7
7
|
export const buttonLinkVariants = cva(
|
|
8
|
-
'inline-flex items-center justify-center gap-4 whitespace-nowrap transition-colors disabled:pointer-events-none outline-none font-medium',
|
|
8
|
+
'inline-flex items-center justify-center gap-4 whitespace-nowrap transition-colors cursor-pointer disabled:pointer-events-none outline-none font-medium',
|
|
9
9
|
{
|
|
10
10
|
variants: {
|
|
11
11
|
variant: {
|
|
@@ -5,7 +5,7 @@ import type {ComponentProps} from 'react';
|
|
|
5
5
|
import {cn} from 'utils/cn';
|
|
6
6
|
|
|
7
7
|
export const buttonVariants = cva(
|
|
8
|
-
'rounded-6 inline-flex items-center justify-center whitespace-nowrap transition-colors disabled:pointer-events-none shrink-0 outline-none',
|
|
8
|
+
'rounded-6 inline-flex items-center justify-center whitespace-nowrap transition-colors cursor-pointer disabled:pointer-events-none shrink-0 outline-none',
|
|
9
9
|
{
|
|
10
10
|
variants: {
|
|
11
11
|
variant: {
|
|
@@ -76,6 +76,7 @@ export function Button({
|
|
|
76
76
|
disabled={disabled || isLoading}
|
|
77
77
|
aria-busy={isLoading}
|
|
78
78
|
aria-live={isLoading ? 'polite' : undefined}
|
|
79
|
+
{...(asChild ? {'aria-disabled': disabled || isLoading} : {})}
|
|
79
80
|
{...props}
|
|
80
81
|
>
|
|
81
82
|
{isLoading ? (
|
|
@@ -5,7 +5,7 @@ import type {ComponentProps} from 'react';
|
|
|
5
5
|
import {cn} from 'utils/cn';
|
|
6
6
|
|
|
7
7
|
export const iconButtonVariants = cva(
|
|
8
|
-
'inline-flex items-center justify-center whitespace-nowrap transition-colors disabled:pointer-events-none shrink-0 outline-none',
|
|
8
|
+
'inline-flex items-center justify-center whitespace-nowrap transition-colors cursor-pointer disabled:pointer-events-none shrink-0 outline-none',
|
|
9
9
|
{
|
|
10
10
|
variants: {
|
|
11
11
|
variant: {
|
|
@@ -80,6 +80,7 @@ export function IconButton({
|
|
|
80
80
|
disabled={disabled || isLoading}
|
|
81
81
|
aria-busy={isLoading}
|
|
82
82
|
aria-live={isLoading ? 'polite' : undefined}
|
|
83
|
+
{...(asChild ? {'aria-disabled': disabled || isLoading} : {})}
|
|
83
84
|
{...props}
|
|
84
85
|
>
|
|
85
86
|
{isLoading ? (
|