@shipfox/react-ui 0.7.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.
Files changed (68) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/.turbo/turbo-check.log +3 -3
  3. package/.turbo/turbo-type.log +2 -2
  4. package/CHANGELOG.md +13 -0
  5. package/dist/components/alert/alert.d.ts +15 -5
  6. package/dist/components/alert/alert.d.ts.map +1 -1
  7. package/dist/components/alert/alert.js +122 -22
  8. package/dist/components/alert/alert.js.map +1 -1
  9. package/dist/components/alert/alert.stories.js +121 -6
  10. package/dist/components/alert/alert.stories.js.map +1 -1
  11. package/dist/components/button/button-link.js +1 -1
  12. package/dist/components/button/button-link.js.map +1 -1
  13. package/dist/components/button/button.d.ts +2 -1
  14. package/dist/components/button/button.d.ts.map +1 -1
  15. package/dist/components/button/button.js +21 -3
  16. package/dist/components/button/button.js.map +1 -1
  17. package/dist/components/button/button.stories.js +25 -0
  18. package/dist/components/button/button.stories.js.map +1 -1
  19. package/dist/components/button/icon-button.d.ts +2 -1
  20. package/dist/components/button/icon-button.d.ts.map +1 -1
  21. package/dist/components/button/icon-button.js +21 -3
  22. package/dist/components/button/icon-button.js.map +1 -1
  23. package/dist/components/button/icon-button.stories.js +90 -0
  24. package/dist/components/button/icon-button.stories.js.map +1 -1
  25. package/dist/components/checkbox/checkbox-links.d.ts.map +1 -1
  26. package/dist/components/checkbox/checkbox-links.js +8 -2
  27. package/dist/components/checkbox/checkbox-links.js.map +1 -1
  28. package/dist/components/checkbox/checkbox.stories.js +4 -4
  29. package/dist/components/checkbox/checkbox.stories.js.map +1 -1
  30. package/dist/components/form/form.d.ts +11 -0
  31. package/dist/components/form/form.d.ts.map +1 -0
  32. package/dist/components/form/form.js +106 -0
  33. package/dist/components/form/form.js.map +1 -0
  34. package/dist/components/form/form.stories.js +582 -0
  35. package/dist/components/form/form.stories.js.map +1 -0
  36. package/dist/components/form/index.d.ts +2 -0
  37. package/dist/components/form/index.d.ts.map +1 -0
  38. package/dist/components/form/index.js +3 -0
  39. package/dist/components/form/index.js.map +1 -0
  40. package/dist/components/icon/custom/spinner.d.ts +1 -1
  41. package/dist/components/icon/custom/spinner.d.ts.map +1 -1
  42. package/dist/components/icon/custom/spinner.js +84 -30
  43. package/dist/components/icon/custom/spinner.js.map +1 -1
  44. package/dist/components/icon/icon.d.ts +19 -18
  45. package/dist/components/icon/icon.d.ts.map +1 -1
  46. package/dist/components/icon/icon.js +17 -17
  47. package/dist/components/icon/icon.js.map +1 -1
  48. package/dist/components/index.d.ts +1 -0
  49. package/dist/components/index.d.ts.map +1 -1
  50. package/dist/components/index.js +1 -0
  51. package/dist/components/index.js.map +1 -1
  52. package/dist/styles.css +1 -1
  53. package/package.json +3 -1
  54. package/src/components/alert/alert.stories.tsx +103 -2
  55. package/src/components/alert/alert.tsx +163 -16
  56. package/src/components/button/button-link.tsx +1 -1
  57. package/src/components/button/button.stories.tsx +18 -0
  58. package/src/components/button/button.tsx +29 -3
  59. package/src/components/button/icon-button.stories.tsx +46 -0
  60. package/src/components/button/icon-button.tsx +28 -2
  61. package/src/components/checkbox/checkbox-links.tsx +5 -3
  62. package/src/components/checkbox/checkbox.stories.tsx +20 -4
  63. package/src/components/form/form.stories.tsx +500 -0
  64. package/src/components/form/form.tsx +154 -0
  65. package/src/components/form/index.ts +1 -0
  66. package/src/components/icon/custom/spinner.tsx +64 -18
  67. package/src/components/icon/icon.tsx +18 -18
  68. package/src/components/index.ts +1 -0
@@ -1,19 +1,19 @@
1
-  WARN  Issue while reading "/runnertmp/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
1
+  WARN  Issue while reading "/runner/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
2
2
 
3
- > @shipfox/react-ui@0.7.0 build /runnertmp/_work/tooling/tooling/libs/react/ui
3
+ > @shipfox/react-ui@0.9.0 build /runner/_work/tooling/tooling/libs/react/ui
4
4
  > swc && pnpm run build:css
5
5
 
6
- Successfully compiled: 116 files with swc (406.75ms)
7
-  WARN  Issue while reading "/runnertmp/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
6
+ Successfully compiled: 119 files with swc (333.36ms)
7
+  WARN  Issue while reading "/runner/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
8
8
 
9
- > @shipfox/react-ui@0.7.0 build:css /runnertmp/_work/tooling/tooling/libs/react/ui
9
+ > @shipfox/react-ui@0.9.0 build:css /runner/_work/tooling/tooling/libs/react/ui
10
10
  > vite build --config vite.css.config.ts && rm -f dist/css-entry.js dist/css-entry.js.map
11
11
 
12
- vite v7.2.2 building client environment for production...
12
+ vite v7.2.4 building client environment for production...
13
13
  transforming...
14
14
  ✓ 2 modules transformed.
15
15
  rendering chunks...
16
16
  computing gzip size...
17
- dist/styles.css 84.62 kB │ gzip: 13.44 kB
17
+ dist/styles.css 85.04 kB │ gzip: 13.51 kB
18
18
  dist/css-entry.js  0.00 kB │ gzip: 0.02 kB
19
- ✓ built in 745ms
19
+ ✓ built in 505ms
@@ -1,6 +1,6 @@
1
-  WARN  Issue while reading "/runnertmp/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
1
+  WARN  Issue while reading "/runner/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
2
2
 
3
- > @shipfox/react-ui@0.7.0 check /runnertmp/_work/tooling/tooling/libs/react/ui
3
+ > @shipfox/react-ui@0.9.0 check /runner/_work/tooling/tooling/libs/react/ui
4
4
  > biome-check --fix
5
5
 
6
- Checked 135 files in 240ms. No fixes applied.
6
+ Checked 138 files in 244ms. No fixes applied.
@@ -1,5 +1,5 @@
1
-  WARN  Issue while reading "/runnertmp/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
1
+  WARN  Issue while reading "/runner/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
2
2
 
3
- > @shipfox/react-ui@0.7.0 type /runnertmp/_work/tooling/tooling/libs/react/ui
3
+ > @shipfox/react-ui@0.9.0 type /runner/_work/tooling/tooling/libs/react/ui
4
4
  > tsc-emit
5
5
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @shipfox/react-ui
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 00b8126: Enhance Alert, Buttons, Checkbox components
8
+
9
+ ## 0.8.0
10
+
11
+ ### Minor Changes
12
+
13
+ - f3dd22c: Add Form components
14
+ - 5e4a493: Update Spinner icon and Button loading state
15
+
3
16
  ## 0.7.0
4
17
 
5
18
  ### Minor Changes
@@ -1,18 +1,28 @@
1
1
  import { type VariantProps } from 'class-variance-authority';
2
- import type { ComponentProps } from 'react';
2
+ import { type Transition } from 'framer-motion';
3
+ import { type ComponentProps } from 'react';
3
4
  declare const alertVariants: (props?: ({
4
5
  variant?: "info" | "default" | "success" | "warning" | "error" | null | undefined;
5
6
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
7
  declare const closeIconVariants: (props?: ({
7
8
  variant?: "info" | "default" | "success" | "warning" | "error" | null | undefined;
8
9
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
9
- type AlertProps = ComponentProps<'div'> & VariantProps<typeof alertVariants>;
10
- declare function Alert({ className, variant, children, ...props }: AlertProps): import("react/jsx-runtime").JSX.Element;
10
+ declare const alertDefaultTransition: Transition;
11
+ type AlertProps = ComponentProps<'div'> & VariantProps<typeof alertVariants> & {
12
+ open?: boolean;
13
+ defaultOpen?: boolean;
14
+ onOpenChange?: (open: boolean) => void;
15
+ animated?: boolean;
16
+ transition?: Transition;
17
+ autoClose?: number;
18
+ };
19
+ declare function Alert({ className, variant, children, open: controlledOpen, defaultOpen, onOpenChange, animated, transition, autoClose, ...props }: AlertProps): import("react/jsx-runtime").JSX.Element | null;
11
20
  declare function AlertContent({ className, ...props }: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
12
21
  declare function AlertTitle({ className, ...props }: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
13
22
  declare function AlertDescription({ className, ...props }: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
14
23
  declare function AlertActions({ className, ...props }: ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
15
24
  declare function AlertAction({ className, ...props }: ComponentProps<'button'>): import("react/jsx-runtime").JSX.Element;
16
- declare function AlertClose({ className, variant, ...props }: ComponentProps<'button'> & VariantProps<typeof closeIconVariants>): import("react/jsx-runtime").JSX.Element;
17
- export { Alert, AlertContent, AlertTitle, AlertDescription, AlertActions, AlertAction, AlertClose };
25
+ declare function AlertClose({ className, variant: variantProp, onClick, ...props }: ComponentProps<'button'> & VariantProps<typeof closeIconVariants>): import("react/jsx-runtime").JSX.Element;
26
+ export { Alert, AlertContent, AlertTitle, AlertDescription, AlertActions, AlertAction, AlertClose, alertDefaultTransition, };
27
+ export type { AlertProps };
18
28
  //# sourceMappingURL=alert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../../src/components/alert/alert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,OAAO,CAAC;AAG1C,QAAA,MAAM,aAAa;;8EAgBlB,CAAC;AAiBF,QAAA,MAAM,iBAAiB;;8EAarB,CAAC;AAEH,KAAK,UAAU,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC,OAAO,aAAa,CAAC,CAAC;AAE7E,iBAAS,KAAK,CAAC,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAC,EAAE,UAAU,2CAclE;AAED,iBAAS,YAAY,CAAC,EAAC,SAAS,EAAE,GAAG,KAA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
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cva } from 'class-variance-authority';
3
3
  import { Icon } from '../../components/icon/index.js';
4
+ import { AnimatePresence, motion } from 'framer-motion';
5
+ import { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react';
4
6
  import { cn } from '../../utils/cn.js';
5
7
  const alertVariants = cva('relative w-full rounded-l-4 rounded-r-8 px-16 py-12 text-sm flex gap-12 items-start border', {
6
8
  variants: {
@@ -44,27 +46,118 @@ const closeIconVariants = cva('w-16 h-16', {
44
46
  variant: 'default'
45
47
  }
46
48
  });
47
- function Alert({ className, variant, children, ...props }) {
48
- return /*#__PURE__*/ _jsxs("div", {
49
- className: "w-full flex items-start gap-4",
50
- children: [
51
- /*#__PURE__*/ _jsx("div", {
52
- "data-slot": "alert-line",
53
- className: cn(alertLineVariants({
54
- variant
55
- })),
56
- "aria-hidden": "true"
57
- }),
58
- /*#__PURE__*/ _jsx("div", {
59
- "data-slot": "alert",
60
- role: "alert",
61
- className: cn(alertVariants({
62
- variant
63
- }), className),
64
- ...props,
65
- children: children
49
+ const alertDefaultTransition = {
50
+ duration: 0.2,
51
+ ease: 'easeInOut'
52
+ };
53
+ const AlertContext = /*#__PURE__*/ createContext(null);
54
+ function useAlertContext() {
55
+ const context = useContext(AlertContext);
56
+ if (!context) {
57
+ throw new Error('Alert components must be used within an Alert component');
58
+ }
59
+ return context;
60
+ }
61
+ function Alert({ className, variant = 'default', children, open: controlledOpen, defaultOpen = true, onOpenChange, animated = true, transition = alertDefaultTransition, autoClose, ...props }) {
62
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
63
+ const isOpen = controlledOpen !== undefined ? controlledOpen : internalOpen;
64
+ const handleClose = useCallback(()=>{
65
+ if (controlledOpen === undefined) {
66
+ setInternalOpen(false);
67
+ }
68
+ onOpenChange?.(false);
69
+ }, [
70
+ controlledOpen,
71
+ onOpenChange
72
+ ]);
73
+ const handleCloseRef = useRef(handleClose);
74
+ useEffect(()=>{
75
+ handleCloseRef.current = handleClose;
76
+ }, [
77
+ handleClose
78
+ ]);
79
+ useEffect(()=>{
80
+ if (autoClose && isOpen && autoClose > 0) {
81
+ const timeoutId = setTimeout(()=>{
82
+ handleCloseRef.current();
83
+ }, autoClose);
84
+ return ()=>{
85
+ clearTimeout(timeoutId);
86
+ };
87
+ }
88
+ }, [
89
+ autoClose,
90
+ isOpen
91
+ ]);
92
+ const contextValue = {
93
+ isOpen,
94
+ onClose: handleClose,
95
+ variant
96
+ };
97
+ if (!animated) {
98
+ if (!isOpen) {
99
+ return null;
100
+ }
101
+ return /*#__PURE__*/ _jsx(AlertContext.Provider, {
102
+ value: contextValue,
103
+ children: /*#__PURE__*/ _jsxs("div", {
104
+ className: "w-full flex items-start gap-4",
105
+ children: [
106
+ /*#__PURE__*/ _jsx("div", {
107
+ "data-slot": "alert-line",
108
+ className: cn(alertLineVariants({
109
+ variant
110
+ })),
111
+ "aria-hidden": "true"
112
+ }),
113
+ /*#__PURE__*/ _jsx("div", {
114
+ "data-slot": "alert",
115
+ role: "alert",
116
+ className: cn(alertVariants({
117
+ variant
118
+ }), className),
119
+ ...props,
120
+ children: children
121
+ })
122
+ ]
123
+ })
124
+ });
125
+ }
126
+ return /*#__PURE__*/ _jsx(AnimatePresence, {
127
+ children: isOpen && /*#__PURE__*/ _jsx(motion.div, {
128
+ className: "w-full flex items-start gap-4",
129
+ initial: {
130
+ opacity: 0
131
+ },
132
+ animate: {
133
+ opacity: 1
134
+ },
135
+ exit: {
136
+ opacity: 0
137
+ },
138
+ transition: transition,
139
+ children: /*#__PURE__*/ _jsxs(AlertContext.Provider, {
140
+ value: contextValue,
141
+ children: [
142
+ /*#__PURE__*/ _jsx("div", {
143
+ "data-slot": "alert-line",
144
+ className: cn(alertLineVariants({
145
+ variant
146
+ })),
147
+ "aria-hidden": "true"
148
+ }),
149
+ /*#__PURE__*/ _jsx("div", {
150
+ "data-slot": "alert",
151
+ role: "alert",
152
+ className: cn(alertVariants({
153
+ variant
154
+ }), className),
155
+ ...props,
156
+ children: children
157
+ })
158
+ ]
66
159
  })
67
- ]
160
+ }, "alert")
68
161
  });
69
162
  }
70
163
  function AlertContent({ className, ...props }) {
@@ -103,12 +196,19 @@ function AlertAction({ className, ...props }) {
103
196
  ...props
104
197
  });
105
198
  }
106
- function AlertClose({ className, variant = 'default', ...props }) {
199
+ function AlertClose({ className, variant: variantProp, onClick, ...props }) {
200
+ const { onClose, variant: contextVariant } = useAlertContext();
201
+ const variant = variantProp ?? contextVariant ?? 'default';
202
+ const handleClick = (e)=>{
203
+ onClose();
204
+ onClick?.(e);
205
+ };
107
206
  return /*#__PURE__*/ _jsx("button", {
108
207
  "data-slot": "alert-close",
109
208
  type: "button",
110
209
  className: cn('absolute cursor-pointer top-12 right-12 rounded-4 p-4 bg-transparent border-none text-foreground-neutral-muted hover:text-foreground-neutral-base hover:bg-background-components-hover transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-background-accent-blue-base focus-visible:ring-offset-2', className),
111
210
  "aria-label": "Close",
211
+ onClick: handleClick,
112
212
  ...props,
113
213
  children: /*#__PURE__*/ _jsx(Icon, {
114
214
  name: "close",
@@ -118,6 +218,6 @@ function AlertClose({ className, variant = 'default', ...props }) {
118
218
  })
119
219
  });
120
220
  }
121
- export { Alert, AlertContent, AlertTitle, AlertDescription, AlertActions, AlertAction, AlertClose };
221
+ export { Alert, AlertContent, AlertTitle, AlertDescription, AlertActions, AlertAction, AlertClose, alertDefaultTransition };
122
222
 
123
223
  //# sourceMappingURL=alert.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/alert/alert.tsx"],"sourcesContent":["import {cva, type VariantProps} from 'class-variance-authority';\nimport {Icon} from 'components/icon';\nimport type {ComponentProps} from 'react';\nimport {cn} from 'utils/cn';\n\nconst alertVariants = cva(\n 'relative w-full rounded-l-4 rounded-r-8 px-16 py-12 text-sm flex gap-12 items-start border',\n {\n variants: {\n variant: {\n default: 'bg-tag-neutral-bg text-foreground-neutral-base border-tag-neutral-border',\n info: 'bg-tag-blue-bg text-foreground-neutral-base border-tag-blue-border',\n success: 'bg-tag-success-bg text-foreground-neutral-base border-tag-success-border',\n warning: 'bg-tag-warning-bg text-foreground-neutral-base border-tag-warning-border',\n error: 'bg-tag-error-bg text-foreground-neutral-base border-tag-error-border',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n },\n);\n\nconst alertLineVariants = cva('w-4 self-stretch rounded-full', {\n variants: {\n variant: {\n default: 'bg-tag-neutral-icon',\n info: 'bg-tag-blue-icon',\n success: 'bg-tag-success-icon',\n warning: 'bg-tag-warning-icon',\n error: 'bg-tag-error-icon',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n});\n\nconst closeIconVariants = cva('w-16 h-16', {\n variants: {\n variant: {\n default: 'text-tag-neutral-icon',\n info: 'text-tag-blue-icon',\n success: 'text-tag-success-icon',\n warning: 'text-tag-warning-icon',\n error: 'text-tag-error-icon',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n});\n\ntype AlertProps = ComponentProps<'div'> & VariantProps<typeof alertVariants>;\n\nfunction Alert({className, variant, children, ...props}: AlertProps) {\n return (\n <div className=\"w-full flex items-start gap-4\">\n <div data-slot=\"alert-line\" className={cn(alertLineVariants({variant}))} aria-hidden=\"true\" />\n <div\n data-slot=\"alert\"\n role=\"alert\"\n className={cn(alertVariants({variant}), className)}\n {...props}\n >\n {children}\n </div>\n </div>\n );\n}\n\nfunction AlertContent({className, ...props}: ComponentProps<'div'>) {\n return <div data-slot=\"alert-content\" className={cn('flex-1 min-w-0', className)} {...props} />;\n}\n\nfunction AlertTitle({className, ...props}: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-title\"\n className={cn('font-medium text-sm leading-20 text-foreground-neutral-base mb-4', className)}\n {...props}\n />\n );\n}\n\nfunction AlertDescription({className, ...props}: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-description\"\n className={cn(\n 'text-xs leading-20 text-foreground-neutral-base [&_p]:leading-relaxed',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AlertActions({className, ...props}: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-actions\"\n className={cn('flex items-center gap-8 mt-8', className)}\n {...props}\n />\n );\n}\n\nfunction AlertAction({className, ...props}: ComponentProps<'button'>) {\n return (\n <button\n data-slot=\"alert-action\"\n type=\"button\"\n className={cn(\n 'bg-transparent border-none p-0 cursor-pointer text-xs font-medium leading-20 text-foreground-neutral-base hover:text-foreground-neutral-subtle transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-background-accent-blue-base focus-visible:ring-offset-2',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AlertClose({\n className,\n variant = 'default',\n ...props\n}: ComponentProps<'button'> & VariantProps<typeof closeIconVariants>) {\n return (\n <button\n data-slot=\"alert-close\"\n type=\"button\"\n className={cn(\n 'absolute cursor-pointer top-12 right-12 rounded-4 p-4 bg-transparent border-none text-foreground-neutral-muted hover:text-foreground-neutral-base hover:bg-background-components-hover transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-background-accent-blue-base focus-visible:ring-offset-2',\n className,\n )}\n aria-label=\"Close\"\n {...props}\n >\n <Icon name=\"close\" className={cn(closeIconVariants({variant}))} />\n </button>\n );\n}\n\nexport {Alert, AlertContent, AlertTitle, AlertDescription, AlertActions, AlertAction, AlertClose};\n"],"names":["cva","Icon","cn","alertVariants","variants","variant","default","info","success","warning","error","defaultVariants","alertLineVariants","closeIconVariants","Alert","className","children","props","div","data-slot","aria-hidden","role","AlertContent","AlertTitle","AlertDescription","AlertActions","AlertAction","button","type","AlertClose","aria-label","name"],"mappings":";AAAA,SAAQA,GAAG,QAA0B,2BAA2B;AAChE,SAAQC,IAAI,QAAO,kBAAkB;AAErC,SAAQC,EAAE,QAAO,WAAW;AAE5B,MAAMC,gBAAgBH,IACpB,8FACA;IACEI,UAAU;QACRC,SAAS;YACPC,SAAS;YACTC,MAAM;YACNC,SAA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U;QACVJ,WAAWb,GAAG,gCAAgCa;QAC7C,GAAGE,KAAK;;AAGf;AAEA,SAASS,YAAY,EAACX,SAAS,EAAE,GAAGE,OAAgC;IAClE,qBACE,KAACU;QACCR,aAAU;QACVS,MAAK;QACLb,WAAWb,GACT,8RACAa;QAED,GAAGE,KAAK;;AAGf;AAEA,SAASY,WAAW,EAClBd,SAAS,EACTV,UAAU,SAAS,EACnB,GAAGY,OAC+D;IAClE,qBACE,KAACU;QACCR,aAAU;QACVS,MAAK;QACLb,WAAWb,GACT,sUACAa;QAEFe,cAAW;QACV,GAAGb,KAAK;kBAET,cAAA,KAAChB;YAAK8B,MAAK;YAAQhB,WAAWb,GAAGW,kBAAkB;gBAACR;YAAO;;;AAGjE;AAEA,SAAQS,KAAK,EAAEQ,YAAY,EAAEC,UAAU,EAAEC,gBAAgB,EAAEC,YAAY,EAAEC,WAAW,EAAEG,UAAU,GAAE"}
1
+ {"version":3,"sources":["../../../src/components/alert/alert.tsx"],"sourcesContent":["import {cva, type VariantProps} from 'class-variance-authority';\nimport {Icon} from 'components/icon';\nimport {AnimatePresence, motion, type Transition} from 'framer-motion';\nimport {\n type ComponentProps,\n createContext,\n type MouseEvent,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport {cn} from 'utils/cn';\n\nconst alertVariants = cva(\n 'relative w-full rounded-l-4 rounded-r-8 px-16 py-12 text-sm flex gap-12 items-start border',\n {\n variants: {\n variant: {\n default: 'bg-tag-neutral-bg text-foreground-neutral-base border-tag-neutral-border',\n info: 'bg-tag-blue-bg text-foreground-neutral-base border-tag-blue-border',\n success: 'bg-tag-success-bg text-foreground-neutral-base border-tag-success-border',\n warning: 'bg-tag-warning-bg text-foreground-neutral-base border-tag-warning-border',\n error: 'bg-tag-error-bg text-foreground-neutral-base border-tag-error-border',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n },\n);\n\nconst alertLineVariants = cva('w-4 self-stretch rounded-full', {\n variants: {\n variant: {\n default: 'bg-tag-neutral-icon',\n info: 'bg-tag-blue-icon',\n success: 'bg-tag-success-icon',\n warning: 'bg-tag-warning-icon',\n error: 'bg-tag-error-icon',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n});\n\nconst closeIconVariants = cva('w-16 h-16', {\n variants: {\n variant: {\n default: 'text-tag-neutral-icon',\n info: 'text-tag-blue-icon',\n success: 'text-tag-success-icon',\n warning: 'text-tag-warning-icon',\n error: 'text-tag-error-icon',\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n});\n\nconst alertDefaultTransition: Transition = {\n duration: 0.2,\n ease: 'easeInOut',\n};\n\ntype AlertContextValue = {\n isOpen: boolean;\n onClose: () => void;\n variant: VariantProps<typeof alertVariants>['variant'];\n};\n\nconst AlertContext = createContext<AlertContextValue | null>(null);\n\nfunction useAlertContext() {\n const context = useContext(AlertContext);\n if (!context) {\n throw new Error('Alert components must be used within an Alert component');\n }\n return context;\n}\n\ntype AlertProps = ComponentProps<'div'> &\n VariantProps<typeof alertVariants> & {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n animated?: boolean;\n transition?: Transition;\n autoClose?: number;\n };\n\nfunction Alert({\n className,\n variant = 'default',\n children,\n open: controlledOpen,\n defaultOpen = true,\n onOpenChange,\n animated = true,\n transition = alertDefaultTransition,\n autoClose,\n ...props\n}: AlertProps) {\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const isOpen = controlledOpen !== undefined ? controlledOpen : internalOpen;\n\n const handleClose = useCallback(() => {\n if (controlledOpen === undefined) {\n setInternalOpen(false);\n }\n onOpenChange?.(false);\n }, [controlledOpen, onOpenChange]);\n\n const handleCloseRef = useRef(handleClose);\n useEffect(() => {\n handleCloseRef.current = handleClose;\n }, [handleClose]);\n\n useEffect(() => {\n if (autoClose && isOpen && autoClose > 0) {\n const timeoutId = setTimeout(() => {\n handleCloseRef.current();\n }, autoClose);\n\n return () => {\n clearTimeout(timeoutId);\n };\n }\n }, [autoClose, isOpen]);\n\n const contextValue: AlertContextValue = {\n isOpen,\n onClose: handleClose,\n variant,\n };\n\n if (!animated) {\n if (!isOpen) {\n return null;\n }\n\n return (\n <AlertContext.Provider value={contextValue}>\n <div className=\"w-full flex items-start gap-4\">\n <div\n data-slot=\"alert-line\"\n className={cn(alertLineVariants({variant}))}\n aria-hidden=\"true\"\n />\n <div\n data-slot=\"alert\"\n role=\"alert\"\n className={cn(alertVariants({variant}), className)}\n {...props}\n >\n {children}\n </div>\n </div>\n </AlertContext.Provider>\n );\n }\n\n return (\n <AnimatePresence>\n {isOpen && (\n <motion.div\n key=\"alert\"\n className=\"w-full flex items-start gap-4\"\n initial={{opacity: 0}}\n animate={{opacity: 1}}\n exit={{opacity: 0}}\n transition={transition}\n >\n <AlertContext.Provider value={contextValue}>\n <div\n data-slot=\"alert-line\"\n className={cn(alertLineVariants({variant}))}\n aria-hidden=\"true\"\n />\n <div\n data-slot=\"alert\"\n role=\"alert\"\n className={cn(alertVariants({variant}), className)}\n {...props}\n >\n {children}\n </div>\n </AlertContext.Provider>\n </motion.div>\n )}\n </AnimatePresence>\n );\n}\n\nfunction AlertContent({className, ...props}: ComponentProps<'div'>) {\n return <div data-slot=\"alert-content\" className={cn('flex-1 min-w-0', className)} {...props} />;\n}\n\nfunction AlertTitle({className, ...props}: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-title\"\n className={cn('font-medium text-sm leading-20 text-foreground-neutral-base mb-4', className)}\n {...props}\n />\n );\n}\n\nfunction AlertDescription({className, ...props}: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-description\"\n className={cn(\n 'text-xs leading-20 text-foreground-neutral-base [&_p]:leading-relaxed',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AlertActions({className, ...props}: ComponentProps<'div'>) {\n return (\n <div\n data-slot=\"alert-actions\"\n className={cn('flex items-center gap-8 mt-8', className)}\n {...props}\n />\n );\n}\n\nfunction AlertAction({className, ...props}: ComponentProps<'button'>) {\n return (\n <button\n data-slot=\"alert-action\"\n type=\"button\"\n className={cn(\n 'bg-transparent border-none p-0 cursor-pointer text-xs font-medium leading-20 text-foreground-neutral-base hover:text-foreground-neutral-subtle transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-background-accent-blue-base focus-visible:ring-offset-2',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AlertClose({\n className,\n variant: variantProp,\n onClick,\n ...props\n}: ComponentProps<'button'> & VariantProps<typeof closeIconVariants>) {\n const {onClose, variant: contextVariant} = useAlertContext();\n const variant = variantProp ?? contextVariant ?? 'default';\n\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n onClose();\n onClick?.(e);\n };\n\n return (\n <button\n data-slot=\"alert-close\"\n type=\"button\"\n className={cn(\n 'absolute cursor-pointer top-12 right-12 rounded-4 p-4 bg-transparent border-none text-foreground-neutral-muted hover:text-foreground-neutral-base hover:bg-background-components-hover transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-background-accent-blue-base focus-visible:ring-offset-2',\n className,\n )}\n aria-label=\"Close\"\n onClick={handleClick}\n {...props}\n >\n <Icon name=\"close\" className={cn(closeIconVariants({variant}))} />\n </button>\n );\n}\n\nexport {\n Alert,\n AlertContent,\n AlertTitle,\n AlertDescription,\n AlertActions,\n AlertAction,\n AlertClose,\n alertDefaultTransition,\n};\n\nexport type {AlertProps};\n"],"names":["cva","Icon","AnimatePresence","motion","createContext","useCallback","useContext","useEffect","useRef","useState","cn","alertVariants","variants","variant","default","info","success","warning","error","defaultVariants","alertLineVariants","closeIconVariants","alertDefaultTransition","duration","ease","AlertContext","useAlertContext","context","Error","Alert","className","children","open","controlledOpen","defaultOpen","onOpenChange","animated","transition","autoClose","props","internalOpen","setInternalOpen","isOpen","undefined","handleClose","handleCloseRef","current","timeoutId","setTimeout","clearTimeout","contextValue","onClose","Provider","value","div","data-slot","aria-hidden","role","initial","opacity","animate","exit","AlertContent","AlertTitle","AlertDescription","AlertActions","AlertAction","button","type","AlertClose","variantProp","onClick","contextVariant","handleClick","e","aria-label","name"],"mappings":";AAAA,SAAQA,GAAG,QAA0B,2BAA2B;AAChE,SAAQC,IAAI,QAAO,kBAAkB;AACrC,SAAQC,eAAe,EAAEC,MAAM,QAAwB,gBAAgB;AACvE,SAEEC,aAAa,EAEbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,QAAQ;AACf,SAAQC,EAAE,QAAO,WAAW;AAE5B,MAAMC,gBAAgBX,IACpB,8FACA;IACEY,UAAU;QACRC,SAAS;YACPC,SAAS;YACTC,MAAM;YACNC,SAAS;YACTC,SAAS;YACTC,OAAO;QACT;IACF;IACAC,iBAAiB;QACfN,SAAS;IACX;AACF;AAGF,MAAMO,oBAAoBpB,IAAI,iCAAiC;IAC7DY,UAAU;QACRC,SAAS;YACPC,SAAS;YACTC,MAAM;YACNC,SAAS;YACTC,SAAS;YACTC,OAAO;QACT;IACF;IACAC,iBAAiB;QACfN,SAAS;IACX;AACF;AAEA,MAAMQ,oBAAoBrB,IAAI,aAAa;IACzCY,UAAU;QACRC,SAAS;YACPC,SAAS;YACTC,MAAM;YACNC,SAAS;YACTC,SAAS;YACTC,OAAO;QACT;IACF;IACAC,iBAAiB;QACfN,SAAS;IACX;AACF;AAEA,MAAMS,yBAAqC;IACzCC,UAAU;IACVC,MAAM;AACR;AAQA,MAAMC,6BAAerB,cAAwC;AAE7D,SAASsB;IACP,MAAMC,UAAUrB,WAAWmB;IAC3B,IAAI,CAACE,SAAS;QACZ,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOD;AACT;AAYA,SAASE,MAAM,EACbC,SAAS,EACTjB,UAAU,SAAS,EACnBkB,QAAQ,EACRC,MAAMC,cAAc,EACpBC,cAAc,IAAI,EAClBC,YAAY,EACZC,WAAW,IAAI,EACfC,aAAaf,sBAAsB,EACnCgB,SAAS,EACT,GAAGC,OACQ;IACX,MAAM,CAACC,cAAcC,gBAAgB,GAAGhC,SAASyB;IACjD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AAK2E,MAAK;YAAQ9C,WAAWpB,GAAGW,kBAAkB;gBAACR;YAAO;;;AAGjE;AAEA,SACEgB,KAAK,EACLiC,YAAY,EACZC,UAAU,EACVC,gBAAgB,EAChBC,YAAY,EACZC,WAAW,EACXG,UAAU,EACV/C,sBAAsB,GACtB"}
@@ -1,5 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { zodResolver } from '@hookform/resolvers/zod';
3
+ import { Button } from '../../components/button/index.js';
4
+ import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '../../components/form/index.js';
5
+ import { Input } from '../../components/input/index.js';
2
6
  import { Header } from '../../components/typography/index.js';
7
+ import { useState } from 'react';
8
+ import { useForm } from 'react-hook-form';
9
+ import { z } from 'zod';
3
10
  import { Alert, AlertAction, AlertActions, AlertClose, AlertContent, AlertDescription, AlertTitle } from './alert.js';
4
11
  const meta = {
5
12
  title: 'Components/Alert',
@@ -56,13 +63,123 @@ export const Default = {
56
63
  })
57
64
  ]
58
65
  }),
59
- /*#__PURE__*/ _jsx(AlertClose, {
60
- variant: args.variant
61
- })
66
+ /*#__PURE__*/ _jsx(AlertClose, {})
62
67
  ]
63
68
  });
64
69
  }
65
70
  };
71
+ const validationFormSchema = z.object({
72
+ email: z.string().email('Please enter a valid email address'),
73
+ password: z.string().min(8, 'Password must be at least 8 characters')
74
+ });
75
+ function ErrorValidationToasterExample() {
76
+ const [showError, setShowError] = useState(false);
77
+ const form = useForm({
78
+ resolver: zodResolver(validationFormSchema),
79
+ defaultValues: {
80
+ email: '',
81
+ password: ''
82
+ }
83
+ });
84
+ function onSubmit(data) {
85
+ // biome-ignore lint/suspicious/noConsole: <we need to log the data for the story>
86
+ console.log('Form submitted:', data);
87
+ setShowError(false);
88
+ }
89
+ function onError() {
90
+ setShowError(true);
91
+ }
92
+ const errors = form.formState.errors;
93
+ const errorCount = Object.keys(errors).length;
94
+ const errorMessage = errorCount > 0 ? `Please fix ${errorCount} error${errorCount > 1 ? 's' : ''} before submitting.` : '';
95
+ return /*#__PURE__*/ _jsxs("div", {
96
+ className: "flex flex-col gap-16 w-full max-w-md",
97
+ children: [
98
+ errorCount > 0 && /*#__PURE__*/ _jsxs(Alert, {
99
+ variant: "error",
100
+ open: showError,
101
+ autoClose: 5000,
102
+ onOpenChange: setShowError,
103
+ children: [
104
+ /*#__PURE__*/ _jsxs(AlertContent, {
105
+ children: [
106
+ /*#__PURE__*/ _jsx(AlertTitle, {
107
+ children: "Validation Error"
108
+ }),
109
+ /*#__PURE__*/ _jsx(AlertDescription, {
110
+ children: errorMessage
111
+ }),
112
+ /*#__PURE__*/ _jsx(AlertActions, {
113
+ children: /*#__PURE__*/ _jsx(AlertAction, {
114
+ onClick: ()=>{
115
+ form.clearErrors();
116
+ setShowError(false);
117
+ },
118
+ children: "Dismiss"
119
+ })
120
+ })
121
+ ]
122
+ }),
123
+ /*#__PURE__*/ _jsx(AlertClose, {})
124
+ ]
125
+ }),
126
+ /*#__PURE__*/ _jsx(Form, {
127
+ ...form,
128
+ children: /*#__PURE__*/ _jsxs("form", {
129
+ onSubmit: form.handleSubmit(onSubmit, onError),
130
+ className: "space-y-8",
131
+ children: [
132
+ /*#__PURE__*/ _jsx(FormField, {
133
+ control: form.control,
134
+ name: "email",
135
+ render: ({ field })=>/*#__PURE__*/ _jsxs(FormItem, {
136
+ children: [
137
+ /*#__PURE__*/ _jsx(FormLabel, {
138
+ children: "Email"
139
+ }),
140
+ /*#__PURE__*/ _jsx(FormControl, {
141
+ children: /*#__PURE__*/ _jsx(Input, {
142
+ type: "email",
143
+ placeholder: "email@example.com",
144
+ ...field
145
+ })
146
+ }),
147
+ /*#__PURE__*/ _jsx(FormMessage, {})
148
+ ]
149
+ })
150
+ }),
151
+ /*#__PURE__*/ _jsx(FormField, {
152
+ control: form.control,
153
+ name: "password",
154
+ render: ({ field })=>/*#__PURE__*/ _jsxs(FormItem, {
155
+ children: [
156
+ /*#__PURE__*/ _jsx(FormLabel, {
157
+ children: "Password"
158
+ }),
159
+ /*#__PURE__*/ _jsx(FormControl, {
160
+ children: /*#__PURE__*/ _jsx(Input, {
161
+ type: "password",
162
+ placeholder: "Enter password",
163
+ ...field
164
+ })
165
+ }),
166
+ /*#__PURE__*/ _jsx(FormMessage, {})
167
+ ]
168
+ })
169
+ }),
170
+ /*#__PURE__*/ _jsx(Button, {
171
+ type: "submit",
172
+ children: "Submit"
173
+ })
174
+ ]
175
+ })
176
+ })
177
+ ]
178
+ });
179
+ }
180
+ export const WithFormValidation = {
181
+ render: ()=>/*#__PURE__*/ _jsx(ErrorValidationToasterExample, {})
182
+ };
66
183
  export const DesignMock = {
67
184
  render: ()=>{
68
185
  return /*#__PURE__*/ _jsxs("div", {
@@ -98,9 +215,7 @@ export const DesignMock = {
98
215
  })
99
216
  ]
100
217
  }),
101
- /*#__PURE__*/ _jsx(AlertClose, {
102
- variant: variant
103
- })
218
+ /*#__PURE__*/ _jsx(AlertClose, {})
104
219
  ]
105
220
  }, variant))
106
221
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/alert/alert.stories.tsx"],"sourcesContent":["import type {Meta, StoryObj} from '@storybook/react';\nimport {Header} from 'components/typography';\nimport {\n Alert,\n AlertAction,\n AlertActions,\n AlertClose,\n AlertContent,\n AlertDescription,\n AlertTitle,\n} from './alert';\n\nconst meta = {\n title: 'Components/Alert',\n component: Alert,\n tags: ['autodocs'],\n argTypes: {\n variant: {\n control: 'select',\n options: ['default', 'info', 'success', 'warning', 'error'],\n },\n },\n args: {\n variant: 'default',\n },\n} satisfies Meta<typeof Alert>;\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\n\nconst variants = ['default', 'info', 'success', 'warning', 'error'] as const;\n\nexport const Default: Story = {\n render: (args) => {\n return (\n <Alert {...args}>\n <AlertContent>\n <AlertTitle>Title</AlertTitle>\n <AlertDescription>Description</AlertDescription>\n <AlertActions>\n <AlertAction>Download</AlertAction>\n <AlertAction>View</AlertAction>\n </AlertActions>\n </AlertContent>\n <AlertClose variant={args.variant} />\n </Alert>\n );\n },\n};\n\nexport const DesignMock: Story = {\n render: () => {\n return (\n <div className=\"flex flex-col gap-32 pb-64 pt-32 px-32 bg-background-neutral-base\">\n <Header variant=\"h3\" className=\"text-foreground-neutral-subtle\">\n ALERTS\n </Header>\n <div className=\"flex flex-col gap-16\">\n {variants.map((variant) => (\n <Alert key={variant} variant={variant}>\n <AlertContent>\n <AlertTitle>Title</AlertTitle>\n <AlertDescription>Description</AlertDescription>\n <AlertActions>\n <AlertAction>Download</AlertAction>\n <AlertAction>View</AlertAction>\n </AlertActions>\n </AlertContent>\n <AlertClose variant={variant} />\n </Alert>\n ))}\n </div>\n </div>\n );\n },\n};\n"],"names":["Header","Alert","AlertAction","AlertActions","AlertClose","AlertContent","AlertDescription","AlertTitle","meta","title","component","tags","argTypes","variant","control","options","args","variants","Default","render","DesignMock","div","className","map"],"mappings":";AACA,SAAQA,MAAM,QAAO,wBAAwB;AAC7C,SACEC,KAAK,EACLC,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,YAAY,EACZC,gBAAgB,EAChBC,UAAU,QACL,UAAU;AAEjB,MAAMC,OAAO;IACXC,OAAO;IACPC,WAAWT;IACXU,MAAM;QAAC;KAAW;IAClBC,UAAU;QACRC,SAAS;YACPC,SAAS;YACTC,SAAS;gBAAC;gBAAW;gBAAQ;gBAAW;gBAAW;aAAQ;QAC7D;IACF;IACAC,MAAM;QACJH,SAAS;IACX;AACF;AAEA,eAAeL,KAAK;AAIpB,MAAMS,WAAW;IAAC;IAAW;IAAQ;IAAW;IAAW;CAAQ;AAEnE,OAAO,MAAMC,UAAiB;IAC5BC,QAAQ,CAACH;QACP,qBACE,MAACf;YAAO,GAAGe,IAAI;;8BACb,MAACX;;sCACC,KAACE;sCAAW;;sCACZ,KAACD;sCAAiB;;sCAClB,MAACH;;8CACC,KAACD;8CAAY;;8CACb,KAACA;8CAAY;;;;;;8BAGjB,KAACE;oBAAWS,SAASG,KAAKH,OAAO;;;;IAGvC;AACF,EAAE;AAEF,OAAO,MAAMO,aAAoB;IAC/BD,QAAQ;QACN,qBACE,MAACE;YAAIC,WAAU;;8BACb,KAACtB;oBAAOa,SAAQ;oBAAKS,WAAU;8BAAiC;;8BAGhE,KAACD;oBAAIC,WAAU;8BACZL,SAASM,GAAG,CAAC,CAACV,wBACb,MAACZ;4BAAoBY,SAASA;;8CAC5B,MAACR;;sDACC,KAACE;sDAAW;;sDACZ,KAACD;sDAAiB;;sDAClB,MAACH;;8DACC,KAACD;8DAAY;;8DACb,KAACA;8DAAY;;;;;;8CAGjB,KAACE;oCAAWS,SAASA;;;2BATXA;;;;IAetB;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../src/components/alert/alert.stories.tsx"],"sourcesContent":["import {zodResolver} from '@hookform/resolvers/zod';\nimport type {Meta, StoryObj} from '@storybook/react';\nimport {Button} from 'components/button';\nimport {Form, FormControl, FormField, FormItem, FormLabel, FormMessage} from 'components/form';\nimport {Input} from 'components/input';\nimport {Header} from 'components/typography';\nimport {useState} from 'react';\nimport {useForm} from 'react-hook-form';\nimport {z} from 'zod';\nimport {\n Alert,\n AlertAction,\n AlertActions,\n AlertClose,\n AlertContent,\n AlertDescription,\n AlertTitle,\n} from './alert';\n\nconst meta = {\n title: 'Components/Alert',\n component: Alert,\n tags: ['autodocs'],\n argTypes: {\n variant: {\n control: 'select',\n options: ['default', 'info', 'success', 'warning', 'error'],\n },\n },\n args: {\n variant: 'default',\n },\n} satisfies Meta<typeof Alert>;\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\n\nconst variants = ['default', 'info', 'success', 'warning', 'error'] as const;\n\nexport const Default: Story = {\n render: (args) => {\n return (\n <Alert {...args}>\n <AlertContent>\n <AlertTitle>Title</AlertTitle>\n <AlertDescription>Description</AlertDescription>\n <AlertActions>\n <AlertAction>Download</AlertAction>\n <AlertAction>View</AlertAction>\n </AlertActions>\n </AlertContent>\n <AlertClose />\n </Alert>\n );\n },\n};\n\nconst validationFormSchema = z.object({\n email: z.string().email('Please enter a valid email address'),\n password: z.string().min(8, 'Password must be at least 8 characters'),\n});\n\ntype ValidationFormValues = z.infer<typeof validationFormSchema>;\n\nfunction ErrorValidationToasterExample() {\n const [showError, setShowError] = useState(false);\n const form = useForm<ValidationFormValues>({\n resolver: zodResolver(validationFormSchema),\n defaultValues: {\n email: '',\n password: '',\n },\n });\n\n function onSubmit(data: ValidationFormValues) {\n // biome-ignore lint/suspicious/noConsole: <we need to log the data for the story>\n console.log('Form submitted:', data);\n setShowError(false);\n }\n\n function onError() {\n setShowError(true);\n }\n\n const errors = form.formState.errors;\n const errorCount = Object.keys(errors).length;\n const errorMessage =\n errorCount > 0\n ? `Please fix ${errorCount} error${errorCount > 1 ? 's' : ''} before submitting.`\n : '';\n\n return (\n <div className=\"flex flex-col gap-16 w-full max-w-md\">\n {errorCount > 0 && (\n <Alert variant=\"error\" open={showError} autoClose={5000} onOpenChange={setShowError}>\n <AlertContent>\n <AlertTitle>Validation Error</AlertTitle>\n <AlertDescription>{errorMessage}</AlertDescription>\n <AlertActions>\n <AlertAction\n onClick={() => {\n form.clearErrors();\n setShowError(false);\n }}\n >\n Dismiss\n </AlertAction>\n </AlertActions>\n </AlertContent>\n <AlertClose />\n </Alert>\n )}\n <Form {...form}>\n <form onSubmit={form.handleSubmit(onSubmit, onError)} className=\"space-y-8\">\n <FormField\n control={form.control}\n name=\"email\"\n render={({field}) => (\n <FormItem>\n <FormLabel>Email</FormLabel>\n <FormControl>\n <Input type=\"email\" placeholder=\"email@example.com\" {...field} />\n </FormControl>\n <FormMessage />\n </FormItem>\n )}\n />\n <FormField\n control={form.control}\n name=\"password\"\n render={({field}) => (\n <FormItem>\n <FormLabel>Password</FormLabel>\n <FormControl>\n <Input type=\"password\" placeholder=\"Enter password\" {...field} />\n </FormControl>\n <FormMessage />\n </FormItem>\n )}\n />\n <Button type=\"submit\">Submit</Button>\n </form>\n </Form>\n </div>\n );\n}\n\nexport const WithFormValidation: Story = {\n render: () => <ErrorValidationToasterExample />,\n};\n\nexport const DesignMock: Story = {\n render: () => {\n return (\n <div className=\"flex flex-col gap-32 pb-64 pt-32 px-32 bg-background-neutral-base\">\n <Header variant=\"h3\" className=\"text-foreground-neutral-subtle\">\n ALERTS\n </Header>\n <div className=\"flex flex-col gap-16\">\n {variants.map((variant) => (\n <Alert key={variant} variant={variant}>\n <AlertContent>\n <AlertTitle>Title</AlertTitle>\n <AlertDescription>Description</AlertDescription>\n <AlertActions>\n <AlertAction>Download</AlertAction>\n <AlertAction>View</AlertAction>\n </AlertActions>\n </AlertContent>\n <AlertClose />\n </Alert>\n ))}\n </div>\n </div>\n );\n },\n};\n"],"names":["zodResolver","Button","Form","FormControl","FormField","FormItem","FormLabel","FormMessage","Input","Header","useState","useForm","z","Alert","AlertAction","AlertActions","AlertClose","AlertContent","AlertDescription","AlertTitle","meta","title","component","tags","argTypes","variant","control","options","args","variants","Default","render","validationFormSchema","object","email","string","password","min","ErrorValidationToasterExample","showError","setShowError","form","resolver","defaultValues","onSubmit","data","console","log","onError","errors","formState","errorCount","Object","keys","length","errorMessage","div","className","open","autoClose","onOpenChange","onClick","clearErrors","handleSubmit","name","field","type","placeholder","WithFormValidation","DesignMock","map"],"mappings":";AAAA,SAAQA,WAAW,QAAO,0BAA0B;AAEpD,SAAQC,MAAM,QAAO,oBAAoB;AACzC,SAAQC,IAAI,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,WAAW,QAAO,kBAAkB;AAC/F,SAAQC,KAAK,QAAO,mBAAmB;AACvC,SAAQC,MAAM,QAAO,wBAAwB;AAC7C,SAAQC,QAAQ,QAAO,QAAQ;AAC/B,SAAQC,OAAO,QAAO,kBAAkB;AACxC,SAAQC,CAAC,QAAO,MAAM;AACtB,SACEC,KAAK,EACLC,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,YAAY,EACZC,gBAAgB,EAChBC,UAAU,QACL,UAAU;AAE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sDACZ,KAACD;sDAAiB;;sDAClB,MAACH;;8DACC,KAACD;8DAAY;;8DACb,KAACA;8DAAY;;;;;;8CAGjB,KAACE;;2BATSS;;;;IAetB;AACF,EAAE"}
@@ -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 buttonLinkVariants = cva('inline-flex items-center justify-center gap-4 whitespace-nowrap transition-colors disabled:pointer-events-none outline-none font-medium', {
6
+ export const buttonLinkVariants = cva('inline-flex items-center justify-center gap-4 whitespace-nowrap transition-colors cursor-pointer disabled:pointer-events-none outline-none font-medium', {
7
7
  variants: {
8
8
  variant: {
9
9
  base: 'text-foreground-neutral-base hover:text-foreground-neutral-base focus-visible:text-foreground-neutral-base disabled:text-foreground-neutral-disabled',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/button/button-link.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 buttonLinkVariants = cva(\n 'inline-flex items-center justify-center gap-4 whitespace-nowrap transition-colors disabled:pointer-events-none outline-none font-medium',\n {\n variants: {\n variant: {\n base: 'text-foreground-neutral-base hover:text-foreground-neutral-base focus-visible:text-foreground-neutral-base disabled:text-foreground-neutral-disabled',\n interactive:\n 'text-foreground-highlight-interactive hover:text-foreground-highlight-interactive-hover focus-visible:text-foreground-highlight-interactive disabled:text-foreground-neutral-disabled',\n muted:\n 'text-foreground-neutral-muted hover:text-foreground-neutral-base focus-visible:text-foreground-neutral-base disabled:text-foreground-neutral-disabled',\n subtle:\n 'text-foreground-neutral-subtle hover:text-foreground-neutral-base focus-visible:text-foreground-neutral-base disabled:text-foreground-neutral-disabled',\n },\n size: {\n xs: 'text-xs',\n sm: 'text-sm',\n md: 'text-md',\n xl: 'text-xl',\n },\n underline: {\n true: 'underline decoration-solid [text-underline-position:from-font]',\n false: '',\n },\n },\n defaultVariants: {\n variant: 'base',\n size: 'sm',\n underline: false,\n },\n },\n);\n\nconst iconSizeMap = {\n xs: 14,\n sm: 14,\n md: 16,\n xl: 20,\n} as const;\n\nexport function ButtonLink({\n className,\n variant,\n size = 'sm',\n underline,\n asChild = false,\n children,\n iconLeft,\n iconRight,\n ...props\n}: ComponentProps<'a'> &\n VariantProps<typeof buttonLinkVariants> & {\n asChild?: boolean;\n iconLeft?: IconName;\n iconRight?: IconName;\n }) {\n const Comp = asChild ? Slot : 'a';\n const iconSize = iconSizeMap[size as keyof typeof iconSizeMap];\n\n return (\n <Comp\n data-slot=\"button-link\"\n className={cn(buttonLinkVariants({variant, size, underline, className}))}\n {...props}\n >\n {iconLeft && <Icon name={iconLeft} size={iconSize} />}\n {children}\n {iconRight && <Icon name={iconRight} size={iconSize} />}\n </Comp>\n );\n}\n"],"names":["Slot","cva","Icon","cn","buttonLinkVariants","variants","variant","base","interactive","muted","subtle","size","xs","sm","md","xl","underline","true","false","defaultVariants","iconSizeMap","ButtonLink","className","asChild","children","iconLeft","iconRight","props","Comp","iconSize","data-slot","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,2IACA;IACEI,UAAU;QACRC,SAAS;YACPC,MAAM;YACNC,aACE;YACFC,OACE;YACFC,QACE;QACJ;QACAC,MAAM;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;QACN;QACAC,WAAW;YACTC,MAAM;YACNC,OAAO;QACT;IACF;IACAC,iBAAiB;QACfb,SAAS;QACTK,MAAM;QACNK,WAAW;IACb;AACF,GACA;AAEF,MAAMI,cAAc;IAClBR,IAAI;IACJC,IAAI;IACJC,IAAI;IACJC,IAAI;AACN;AAEA,OAAO,SAASM,WAAW,EACzBC,SAAS,EACThB,OAAO,EACPK,OAAO,IAAI,EACXK,SAAS,EACTO,UAAU,KAAK,EACfC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACT,GAAGC,OAMF;IACD,MAAMC,OAAOL,UAAUvB,OAAO;IAC9B,MAAM6B,WAAWT,WAAW,CAACT,KAAiC;IAE9D,qBACE,MAACiB;QACCE,aAAU;QACVR,WAAWnB,GAAGC,mBAAmB;YAACE;YAASK;YAAMK;YAAWM;QAAS;QACpE,GAAGK,KAAK;;YAERF,0BAAY,KAACvB;gBAAK6B,MAAMN;gBAAUd,MAAMkB;;YACxCL;YACAE,2BAAa,KAACxB;gBAAK6B,MAAML;gBAAWf,MAAMkB;;;;AAGjD"}
1
+ {"version":3,"sources":["../../../src/components/button/button-link.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 buttonLinkVariants = cva(\n 'inline-flex items-center justify-center gap-4 whitespace-nowrap transition-colors cursor-pointer disabled:pointer-events-none outline-none font-medium',\n {\n variants: {\n variant: {\n base: 'text-foreground-neutral-base hover:text-foreground-neutral-base focus-visible:text-foreground-neutral-base disabled:text-foreground-neutral-disabled',\n interactive:\n 'text-foreground-highlight-interactive hover:text-foreground-highlight-interactive-hover focus-visible:text-foreground-highlight-interactive disabled:text-foreground-neutral-disabled',\n muted:\n 'text-foreground-neutral-muted hover:text-foreground-neutral-base focus-visible:text-foreground-neutral-base disabled:text-foreground-neutral-disabled',\n subtle:\n 'text-foreground-neutral-subtle hover:text-foreground-neutral-base focus-visible:text-foreground-neutral-base disabled:text-foreground-neutral-disabled',\n },\n size: {\n xs: 'text-xs',\n sm: 'text-sm',\n md: 'text-md',\n xl: 'text-xl',\n },\n underline: {\n true: 'underline decoration-solid [text-underline-position:from-font]',\n false: '',\n },\n },\n defaultVariants: {\n variant: 'base',\n size: 'sm',\n underline: false,\n },\n },\n);\n\nconst iconSizeMap = {\n xs: 14,\n sm: 14,\n md: 16,\n xl: 20,\n} as const;\n\nexport function ButtonLink({\n className,\n variant,\n size = 'sm',\n underline,\n asChild = false,\n children,\n iconLeft,\n iconRight,\n ...props\n}: ComponentProps<'a'> &\n VariantProps<typeof buttonLinkVariants> & {\n asChild?: boolean;\n iconLeft?: IconName;\n iconRight?: IconName;\n }) {\n const Comp = asChild ? Slot : 'a';\n const iconSize = iconSizeMap[size as keyof typeof iconSizeMap];\n\n return (\n <Comp\n data-slot=\"button-link\"\n className={cn(buttonLinkVariants({variant, size, underline, className}))}\n {...props}\n >\n {iconLeft && <Icon name={iconLeft} size={iconSize} />}\n {children}\n {iconRight && <Icon name={iconRight} size={iconSize} />}\n </Comp>\n );\n}\n"],"names":["Slot","cva","Icon","cn","buttonLinkVariants","variants","variant","base","interactive","muted","subtle","size","xs","sm","md","xl","underline","true","false","defaultVariants","iconSizeMap","ButtonLink","className","asChild","children","iconLeft","iconRight","props","Comp","iconSize","data-slot","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,0JACA;IACEI,UAAU;QACRC,SAAS;YACPC,MAAM;YACNC,aACE;YACFC,OACE;YACFC,QACE;QACJ;QACAC,MAAM;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;QACN;QACAC,WAAW;YACTC,MAAM;YACNC,OAAO;QACT;IACF;IACAC,iBAAiB;QACfb,SAAS;QACTK,MAAM;QACNK,WAAW;IACb;AACF,GACA;AAEF,MAAMI,cAAc;IAClBR,IAAI;IACJC,IAAI;IACJC,IAAI;IACJC,IAAI;AACN;AAEA,OAAO,SAASM,WAAW,EACzBC,SAAS,EACThB,OAAO,EACPK,OAAO,IAAI,EACXK,SAAS,EACTO,UAAU,KAAK,EACfC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACT,GAAGC,OAMF;IACD,MAAMC,OAAOL,UAAUvB,OAAO;IAC9B,MAAM6B,WAAWT,WAAW,CAACT,KAAiC;IAE9D,qBACE,MAACiB;QACCE,aAAU;QACVR,WAAWnB,GAAGC,mBAAmB;YAACE;YAASK;YAAMK;YAAWM;QAAS;QACpE,GAAGK,KAAK;;YAERF,0BAAY,KAACvB;gBAAK6B,MAAMN;gBAAUd,MAAMkB;;YACxCL;YACAE,2BAAa,KAACxB;gBAAK6B,MAAML;gBAAWf,MAAMkB;;;;AAGjD"}
@@ -5,9 +5,10 @@ export declare const buttonVariants: (props?: ({
5
5
  variant?: "transparent" | "success" | "primary" | "secondary" | "danger" | "transparentMuted" | null | undefined;
6
6
  size?: "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
7
7
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
- export declare function Button({ className, variant, size, asChild, children, iconLeft, iconRight, ...props }: ComponentProps<'button'> & VariantProps<typeof buttonVariants> & {
8
+ export declare function Button({ className, variant, size, asChild, children, iconLeft, iconRight, isLoading, disabled, ...props }: ComponentProps<'button'> & VariantProps<typeof buttonVariants> & {
9
9
  asChild?: boolean;
10
10
  iconLeft?: IconName;
11
11
  iconRight?: IconName;
12
+ isLoading?: boolean;
12
13
  }): import("react/jsx-runtime").JSX.Element;
13
14
  //# sourceMappingURL=button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/button/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,cAAc;;;8EAgC1B,CAAC;AAEF,wBAAgB,MAAM,CAAC,EACrB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAe,EACf,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,QAAQ,CAAC,GACzB,YAAY,CAAC,OAAO,cAAc,CAAC,GAAG;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,CAAC;CACtB,2CAUF"}
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/button/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,cAAc;;;8EAgC1B,CAAC;AAWF,wBAAgB,MAAM,CAAC,EACrB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAe,EACf,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAiB,EACjB,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,QAAQ,CAAC,GACzB,YAAY,CAAC,OAAO,cAAc,CAAC,GAAG;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,2CAwBF"}
@@ -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 buttonVariants = cva('rounded-6 inline-flex items-center justify-center whitespace-nowrap transition-colors disabled:pointer-events-none shrink-0 outline-none', {
6
+ export const buttonVariants = cva('rounded-6 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-foreground-contrast-primary 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',
@@ -27,8 +27,17 @@ export const buttonVariants = cva('rounded-6 inline-flex items-center justify-ce
27
27
  size: 'md'
28
28
  }
29
29
  });
30
- export function Button({ className, variant, size, asChild = false, children, iconLeft, iconRight, ...props }) {
30
+ const spinnerSizeMap = {
31
+ '2xs': 'size-10',
32
+ xs: 'size-10',
33
+ sm: 'size-12',
34
+ md: 'size-14',
35
+ lg: 'size-16',
36
+ xl: 'size-18'
37
+ };
38
+ export function Button({ className, variant, size, asChild = false, children, iconLeft, iconRight, isLoading = false, disabled, ...props }) {
31
39
  const Comp = asChild ? Slot : 'button';
40
+ const spinnerSize = spinnerSizeMap[size ?? 'md'];
32
41
  return /*#__PURE__*/ _jsxs(Comp, {
33
42
  "data-slot": "button",
34
43
  className: cn(buttonVariants({
@@ -36,9 +45,18 @@ export function Button({ className, variant, size, asChild = false, children, ic
36
45
  size,
37
46
  className
38
47
  })),
48
+ disabled: disabled || isLoading,
49
+ "aria-busy": isLoading,
50
+ "aria-live": isLoading ? 'polite' : undefined,
51
+ ...asChild ? {
52
+ 'aria-disabled': disabled || isLoading
53
+ } : {},
39
54
  ...props,
40
55
  children: [
41
- iconLeft && /*#__PURE__*/ _jsx(Icon, {
56
+ isLoading ? /*#__PURE__*/ _jsx(Icon, {
57
+ name: "spinner",
58
+ className: spinnerSize
59
+ }) : iconLeft && /*#__PURE__*/ _jsx(Icon, {
42
60
  name: iconLeft
43
61
  }),
44
62
  children,