@shipfox/react-ui 0.8.0 → 0.10.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 +3 -3
- package/.turbo/turbo-type.log +2 -2
- package/CHANGELOG.md +12 -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/dist/components/icon/icon.d.ts +3 -17
- package/dist/components/icon/icon.d.ts.map +1 -1
- package/dist/components/icon/icon.js +21 -13
- package/dist/components/icon/icon.js.map +1 -1
- package/dist/components/icon/remixicon-registry.d.ts +5 -0
- package/dist/components/icon/remixicon-registry.d.ts.map +1 -0
- package/dist/components/icon/remixicon-registry.js +14 -0
- package/dist/components/icon/remixicon-registry.js.map +1 -0
- 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
- package/src/components/icon/icon.tsx +23 -13
- package/src/components/icon/remixicon-registry.ts +24 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../../src/components/button/icon-button.tsx"],"names":[],"mappings":"AACA,OAAO,EAAM,KAAK,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAO,KAAK,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,OAAO,CAAC;AAG1C,eAAO,MAAM,kBAAkB;;;;;8EAkC9B,CAAC;AAcF,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,MAAM,EACN,KAAK,EACL,OAAe,EACf,QAAQ,EACR,IAAI,EACJ,SAAiB,EACjB,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,QAAQ,CAAC,GACzB,YAAY,CAAC,OAAO,kBAAkB,CAAC,GAAG;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,
|
|
1
|
+
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../../src/components/button/icon-button.tsx"],"names":[],"mappings":"AACA,OAAO,EAAM,KAAK,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAO,KAAK,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,OAAO,CAAC;AAG1C,eAAO,MAAM,kBAAkB;;;;;8EAkC9B,CAAC;AAcF,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,MAAM,EACN,KAAK,EACL,OAAe,EACf,QAAQ,EACR,IAAI,EACJ,SAAiB,EACjB,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,QAAQ,CAAC,GACzB,YAAY,CAAC,OAAO,kBAAkB,CAAC,GAAG;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,2CAuBF"}
|
|
@@ -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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AAO;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;gCAAG;gCACjC;oCAACT,OAAO;oCAAkBS,MAAM;gCAAG;6BACpC;;sCAEH,KAAC/B;4BACC0B,IAAG;4BACHJ,OAAM;4BACNQ,OAAO;gCACL;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":";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,MAAClB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AM;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"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { RemixiconComponentType } from '@remixicon/react';
|
|
2
|
-
import { RiGoogleFill } from '@remixicon/react';
|
|
3
2
|
import type { ComponentProps } from 'react';
|
|
4
3
|
import { BadgeIcon, CheckCircleSolidIcon, CircleDottedLineIcon, ComponentFillIcon, ComponentLineIcon, EllipseMiniSolidIcon, InfoTooltipFillIcon, ResizeIcon, ShipfoxLogo, SlackLogo, SpinnerIcon, StripeLogo, ThunderIcon, XCircleSolidIcon } from './custom';
|
|
5
|
-
declare const
|
|
6
|
-
readonly google: RemixiconComponentType;
|
|
7
|
-
readonly microsoft: RemixiconComponentType;
|
|
8
|
-
readonly github: RemixiconComponentType;
|
|
4
|
+
declare const customIconsMap: {
|
|
9
5
|
readonly shipfox: typeof ShipfoxLogo;
|
|
10
6
|
readonly slack: typeof SlackLogo;
|
|
11
7
|
readonly stripe: typeof StripeLogo;
|
|
@@ -20,21 +16,11 @@ declare const iconsMap: {
|
|
|
20
16
|
readonly spinner: typeof SpinnerIcon;
|
|
21
17
|
readonly thunder: typeof ThunderIcon;
|
|
22
18
|
readonly xCircleSolid: typeof XCircleSolidIcon;
|
|
23
|
-
readonly addLine: RemixiconComponentType;
|
|
24
|
-
readonly bookOpen: RemixiconComponentType;
|
|
25
|
-
readonly check: RemixiconComponentType;
|
|
26
|
-
readonly chevronRight: RemixiconComponentType;
|
|
27
|
-
readonly close: RemixiconComponentType;
|
|
28
|
-
readonly copy: RemixiconComponentType;
|
|
29
|
-
readonly homeSmile: RemixiconComponentType;
|
|
30
|
-
readonly imageAdd: RemixiconComponentType;
|
|
31
|
-
readonly info: RemixiconComponentType;
|
|
32
|
-
readonly money: RemixiconComponentType;
|
|
33
|
-
readonly subtractLine: RemixiconComponentType;
|
|
34
19
|
};
|
|
20
|
+
declare const iconsMap: Record<string, RemixiconComponentType> & typeof customIconsMap;
|
|
35
21
|
export type IconName = keyof typeof iconsMap;
|
|
36
22
|
export declare const iconNames: IconName[];
|
|
37
|
-
type BaseIconProps = ComponentProps<
|
|
23
|
+
type BaseIconProps = ComponentProps<RemixiconComponentType>;
|
|
38
24
|
type IconProps = {
|
|
39
25
|
name: IconName;
|
|
40
26
|
} & Omit<BaseIconProps, 'name'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/components/icon/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/components/icon/icon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AAiB7D,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,OAAO,CAAC;AAC1C,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,EACV,WAAW,EACX,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAoBlB,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;CAeuC,CAAC;AAE5D,QAAA,MAAM,QAAQ,EAIT,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,GAAG,OAAO,cAAc,CAAC;AAEpE,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,QAAQ,CAAC;AAC7C,eAAO,MAAM,SAAS,EAA4B,QAAQ,EAAE,CAAC;AAE7D,KAAK,aAAa,GAAG,cAAc,CAAC,sBAAsB,CAAC,CAAC;AAC5D,KAAK,SAAS,GAAG;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AAEhE,wBAAgB,IAAI,CAAC,EAAC,IAAI,EAAE,GAAG,KAAK,EAAC,EAAE,SAAS,2CAG/C"}
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { RiAddLine, RiArrowRightSLine, RiBookOpenFill, RiCheckLine, RiCloseLine, RiFileCopyLine, RiGithubFill, RiGoogleFill, RiHomeSmileFill, RiImageAddFill, RiInformationFill, RiMicrosoftFill, RiMoneyDollarCircleLine, RiSubtractLine } from '@remixicon/react';
|
|
3
3
|
import { BadgeIcon, CheckCircleSolidIcon, CircleDottedLineIcon, ComponentFillIcon, ComponentLineIcon, EllipseMiniSolidIcon, InfoTooltipFillIcon, ResizeIcon, ShipfoxLogo, SlackLogo, SpinnerIcon, StripeLogo, ThunderIcon, XCircleSolidIcon } from './custom/index.js';
|
|
4
|
-
|
|
4
|
+
import { remixiconMap } from './remixicon-registry.js';
|
|
5
|
+
const commonRemixicons = {
|
|
6
|
+
addLine: RiAddLine,
|
|
7
|
+
close: RiCloseLine,
|
|
8
|
+
check: RiCheckLine,
|
|
9
|
+
copy: RiFileCopyLine,
|
|
10
|
+
info: RiInformationFill,
|
|
11
|
+
imageAdd: RiImageAddFill,
|
|
12
|
+
chevronRight: RiArrowRightSLine,
|
|
13
|
+
homeSmile: RiHomeSmileFill,
|
|
14
|
+
money: RiMoneyDollarCircleLine,
|
|
5
15
|
google: RiGoogleFill,
|
|
6
16
|
microsoft: RiMicrosoftFill,
|
|
7
17
|
github: RiGithubFill,
|
|
18
|
+
subtractLine: RiSubtractLine,
|
|
19
|
+
bookOpen: RiBookOpenFill
|
|
20
|
+
};
|
|
21
|
+
const customIconsMap = {
|
|
8
22
|
shipfox: ShipfoxLogo,
|
|
9
23
|
slack: SlackLogo,
|
|
10
24
|
stripe: StripeLogo,
|
|
@@ -18,18 +32,12 @@ const iconsMap = {
|
|
|
18
32
|
resize: ResizeIcon,
|
|
19
33
|
spinner: SpinnerIcon,
|
|
20
34
|
thunder: ThunderIcon,
|
|
21
|
-
xCircleSolid: XCircleSolidIcon
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
copy: RiFileCopyLine,
|
|
28
|
-
homeSmile: RiHomeSmileFill,
|
|
29
|
-
imageAdd: RiImageAddFill,
|
|
30
|
-
info: RiInformationFill,
|
|
31
|
-
money: RiMoneyDollarCircleLine,
|
|
32
|
-
subtractLine: RiSubtractLine
|
|
35
|
+
xCircleSolid: XCircleSolidIcon
|
|
36
|
+
};
|
|
37
|
+
const iconsMap = {
|
|
38
|
+
...remixiconMap,
|
|
39
|
+
...commonRemixicons,
|
|
40
|
+
...customIconsMap
|
|
33
41
|
};
|
|
34
42
|
export const iconNames = Object.keys(iconsMap);
|
|
35
43
|
export function Icon({ name, ...props }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/icon/icon.tsx"],"sourcesContent":["import type {RemixiconComponentType} from '@remixicon/react';\nimport {\n RiAddLine,\n RiArrowRightSLine,\n RiBookOpenFill,\n RiCheckLine,\n RiCloseLine,\n RiFileCopyLine,\n RiGithubFill,\n RiGoogleFill,\n RiHomeSmileFill,\n RiImageAddFill,\n RiInformationFill,\n RiMicrosoftFill,\n RiMoneyDollarCircleLine,\n RiSubtractLine,\n} from '@remixicon/react';\nimport type {ComponentProps} from 'react';\nimport {\n BadgeIcon,\n CheckCircleSolidIcon,\n CircleDottedLineIcon,\n ComponentFillIcon,\n ComponentLineIcon,\n EllipseMiniSolidIcon,\n InfoTooltipFillIcon,\n ResizeIcon,\n ShipfoxLogo,\n SlackLogo,\n SpinnerIcon,\n StripeLogo,\n ThunderIcon,\n XCircleSolidIcon,\n} from './custom';\n\nconst
|
|
1
|
+
{"version":3,"sources":["../../../src/components/icon/icon.tsx"],"sourcesContent":["import type {RemixiconComponentType} from '@remixicon/react';\nimport {\n RiAddLine,\n RiArrowRightSLine,\n RiBookOpenFill,\n RiCheckLine,\n RiCloseLine,\n RiFileCopyLine,\n RiGithubFill,\n RiGoogleFill,\n RiHomeSmileFill,\n RiImageAddFill,\n RiInformationFill,\n RiMicrosoftFill,\n RiMoneyDollarCircleLine,\n RiSubtractLine,\n} from '@remixicon/react';\nimport type {ComponentProps} from 'react';\nimport {\n BadgeIcon,\n CheckCircleSolidIcon,\n CircleDottedLineIcon,\n ComponentFillIcon,\n ComponentLineIcon,\n EllipseMiniSolidIcon,\n InfoTooltipFillIcon,\n ResizeIcon,\n ShipfoxLogo,\n SlackLogo,\n SpinnerIcon,\n StripeLogo,\n ThunderIcon,\n XCircleSolidIcon,\n} from './custom';\nimport {remixiconMap} from './remixicon-registry';\n\nconst commonRemixicons = {\n addLine: RiAddLine,\n close: RiCloseLine,\n check: RiCheckLine,\n copy: RiFileCopyLine,\n info: RiInformationFill,\n imageAdd: RiImageAddFill,\n chevronRight: RiArrowRightSLine,\n homeSmile: RiHomeSmileFill,\n money: RiMoneyDollarCircleLine,\n google: RiGoogleFill,\n microsoft: RiMicrosoftFill,\n github: RiGithubFill,\n subtractLine: RiSubtractLine,\n bookOpen: RiBookOpenFill,\n} as const satisfies Record<string, RemixiconComponentType>;\n\nconst customIconsMap = {\n shipfox: ShipfoxLogo,\n slack: SlackLogo,\n stripe: StripeLogo,\n badge: BadgeIcon,\n checkCircleSolid: CheckCircleSolidIcon,\n circleDottedLine: CircleDottedLineIcon,\n componentFill: ComponentFillIcon,\n componentLine: ComponentLineIcon,\n ellipseMiniSolid: EllipseMiniSolidIcon,\n infoTooltipFill: InfoTooltipFillIcon,\n resize: ResizeIcon,\n spinner: SpinnerIcon,\n thunder: ThunderIcon,\n xCircleSolid: XCircleSolidIcon,\n} as const satisfies Record<string, RemixiconComponentType>;\n\nconst iconsMap = {\n ...remixiconMap,\n ...commonRemixicons,\n ...customIconsMap,\n} as Record<string, RemixiconComponentType> & typeof customIconsMap;\n\nexport type IconName = keyof typeof iconsMap;\nexport const iconNames = Object.keys(iconsMap) as IconName[];\n\ntype BaseIconProps = ComponentProps<RemixiconComponentType>;\ntype IconProps = {name: IconName} & Omit<BaseIconProps, 'name'>;\n\nexport function Icon({name, ...props}: IconProps) {\n const IconComponent = iconsMap[name];\n return <IconComponent {...props} />;\n}\n"],"names":["RiAddLine","RiArrowRightSLine","RiBookOpenFill","RiCheckLine","RiCloseLine","RiFileCopyLine","RiGithubFill","RiGoogleFill","RiHomeSmileFill","RiImageAddFill","RiInformationFill","RiMicrosoftFill","RiMoneyDollarCircleLine","RiSubtractLine","BadgeIcon","CheckCircleSolidIcon","CircleDottedLineIcon","ComponentFillIcon","ComponentLineIcon","EllipseMiniSolidIcon","InfoTooltipFillIcon","ResizeIcon","ShipfoxLogo","SlackLogo","SpinnerIcon","StripeLogo","ThunderIcon","XCircleSolidIcon","remixiconMap","commonRemixicons","addLine","close","check","copy","info","imageAdd","chevronRight","homeSmile","money","google","microsoft","github","subtractLine","bookOpen","customIconsMap","shipfox","slack","stripe","badge","checkCircleSolid","circleDottedLine","componentFill","componentLine","ellipseMiniSolid","infoTooltipFill","resize","spinner","thunder","xCircleSolid","iconsMap","iconNames","Object","keys","Icon","name","props","IconComponent"],"mappings":";AACA,SACEA,SAAS,EACTC,iBAAiB,EACjBC,cAAc,EACdC,WAAW,EACXC,WAAW,EACXC,cAAc,EACdC,YAAY,EACZC,YAAY,EACZC,eAAe,EACfC,cAAc,EACdC,iBAAiB,EACjBC,eAAe,EACfC,uBAAuB,EACvBC,cAAc,QACT,mBAAmB;AAE1B,SACEC,SAAS,EACTC,oBAAoB,EACpBC,oBAAoB,EACpBC,iBAAiB,EACjBC,iBAAiB,EACjBC,oBAAoB,EACpBC,mBAAmB,EACnBC,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,WAAW,EACXC,UAAU,EACVC,WAAW,EACXC,gBAAgB,QACX,WAAW;AAClB,SAAQC,YAAY,QAAO,uBAAuB;AAElD,MAAMC,mBAAmB;IACvBC,SAAS9B;IACT+B,OAAO3B;IACP4B,OAAO7B;IACP8B,MAAM5B;IACN6B,MAAMxB;IACNyB,UAAU1B;IACV2B,cAAcnC;IACdoC,WAAW7B;IACX8B,OAAO1B;IACP2B,QAAQhC;IACRiC,WAAW7B;IACX8B,QAAQnC;IACRoC,cAAc7B;IACd8B,UAAUzC;AACZ;AAEA,MAAM0C,iBAAiB;IACrBC,SAASvB;IACTwB,OAAOvB;IACPwB,QAAQtB;IACRuB,OAAOlC;IACPmC,kBAAkBlC;IAClBmC,kBAAkBlC;IAClBmC,eAAelC;IACfmC,eAAelC;IACfmC,kBAAkBlC;IAClBmC,iBAAiBlC;IACjBmC,QAAQlC;IACRmC,SAAShC;IACTiC,SAAS/B;IACTgC,cAAc/B;AAChB;AAEA,MAAMgC,WAAW;IACf,GAAG/B,YAAY;IACf,GAAGC,gBAAgB;IACnB,GAAGe,cAAc;AACnB;AAGA,OAAO,MAAMgB,YAAYC,OAAOC,IAAI,CAACH,UAAwB;AAK7D,OAAO,SAASI,KAAK,EAACC,IAAI,EAAE,GAAGC,OAAiB;IAC9C,MAAMC,gBAAgBP,QAAQ,CAACK,KAAK;IACpC,qBAAO,KAACE;QAAe,GAAGD,KAAK;;AACjC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RemixiconComponentType } from '@remixicon/react';
|
|
2
|
+
export declare const remixiconMap: Record<string, RemixiconComponentType>;
|
|
3
|
+
export type RemixIconName = keyof typeof remixiconMap;
|
|
4
|
+
export declare const remixiconNames: RemixIconName[];
|
|
5
|
+
//# sourceMappingURL=remixicon-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remixicon-registry.d.ts","sourceRoot":"","sources":["../../../src/components/icon/remixicon-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AAiB7D,eAAO,MAAM,YAAY,EAA8C,MAAM,CAC3E,MAAM,EACN,sBAAsB,CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,YAAY,CAAC;AACtD,eAAO,MAAM,cAAc,EAAgC,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as RemixIcons from '@remixicon/react';
|
|
2
|
+
const remixiconEntries = Object.entries(RemixIcons).filter(([key, value])=>key.startsWith('Ri') && typeof value === 'function');
|
|
3
|
+
function iconNameToKey(iconName) {
|
|
4
|
+
const withoutPrefix = iconName.slice(2);
|
|
5
|
+
return withoutPrefix.charAt(0).toLowerCase() + withoutPrefix.slice(1);
|
|
6
|
+
}
|
|
7
|
+
const remixiconMapEntries = remixiconEntries.map(([name, component])=>[
|
|
8
|
+
iconNameToKey(name),
|
|
9
|
+
component
|
|
10
|
+
]);
|
|
11
|
+
export const remixiconMap = Object.fromEntries(remixiconMapEntries);
|
|
12
|
+
export const remixiconNames = Object.keys(remixiconMap);
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=remixicon-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/icon/remixicon-registry.ts"],"sourcesContent":["import type {RemixiconComponentType} from '@remixicon/react';\nimport * as RemixIcons from '@remixicon/react';\n\nconst remixiconEntries = Object.entries(RemixIcons).filter(\n ([key, value]) => key.startsWith('Ri') && typeof value === 'function',\n) as Array<[string, RemixiconComponentType]>;\n\nfunction iconNameToKey(iconName: string): string {\n const withoutPrefix = iconName.slice(2);\n return withoutPrefix.charAt(0).toLowerCase() + withoutPrefix.slice(1);\n}\n\nconst remixiconMapEntries = remixiconEntries.map(([name, component]) => [\n iconNameToKey(name),\n component,\n]) as Array<[string, RemixiconComponentType]>;\n\nexport const remixiconMap = Object.fromEntries(remixiconMapEntries) as Record<\n string,\n RemixiconComponentType\n>;\n\nexport type RemixIconName = keyof typeof remixiconMap;\nexport const remixiconNames = Object.keys(remixiconMap) as RemixIconName[];\n"],"names":["RemixIcons","remixiconEntries","Object","entries","filter","key","value","startsWith","iconNameToKey","iconName","withoutPrefix","slice","charAt","toLowerCase","remixiconMapEntries","map","name","component","remixiconMap","fromEntries","remixiconNames","keys"],"mappings":"AACA,YAAYA,gBAAgB,mBAAmB;AAE/C,MAAMC,mBAAmBC,OAAOC,OAAO,CAACH,YAAYI,MAAM,CACxD,CAAC,CAACC,KAAKC,MAAM,GAAKD,IAAIE,UAAU,CAAC,SAAS,OAAOD,UAAU;AAG7D,SAASE,cAAcC,QAAgB;IACrC,MAAMC,gBAAgBD,SAASE,KAAK,CAAC;IACrC,OAAOD,cAAcE,MAAM,CAAC,GAAGC,WAAW,KAAKH,cAAcC,KAAK,CAAC;AACrE;AAEA,MAAMG,sBAAsBb,iBAAiBc,GAAG,CAAC,CAAC,CAACC,MAAMC,UAAU,GAAK;QACtET,cAAcQ;QACdC;KACD;AAED,OAAO,MAAMC,eAAehB,OAAOiB,WAAW,CAACL,qBAG7C;AAGF,OAAO,MAAMM,iBAAiBlB,OAAOmB,IAAI,CAACH,cAAiC"}
|
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>
|