@taiv/ui 1.9.0 → 1.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.
Files changed (43) hide show
  1. package/dist/components/Info/Badge/Badge.d.ts +10 -8
  2. package/dist/components/Info/Badge/Badge.d.ts.map +1 -1
  3. package/dist/components/Info/Badge/Badge.js +23 -45
  4. package/dist/components/Info/Badge/Badge.stories.d.ts +15 -0
  5. package/dist/components/Info/Badge/Badge.stories.d.ts.map +1 -0
  6. package/dist/components/Info/Badge/Badge.stories.js +92 -0
  7. package/dist/components/Info/Badge/sizes.d.ts +34 -0
  8. package/dist/components/Info/Badge/sizes.d.ts.map +1 -0
  9. package/dist/components/Info/Badge/sizes.js +24 -0
  10. package/dist/components/Info/Badge/variants.d.ts +6 -0
  11. package/dist/components/Info/Badge/variants.d.ts.map +1 -0
  12. package/dist/components/Info/Badge/variants.js +22 -0
  13. package/dist/components/Info/Modals/FormModal/FormModal.d.ts +16 -0
  14. package/dist/components/Info/Modals/FormModal/FormModal.d.ts.map +1 -0
  15. package/dist/components/Info/Modals/FormModal/FormModal.js +59 -0
  16. package/dist/components/Info/Modals/FormModal/FormModal.stories.d.ts +14 -0
  17. package/dist/components/Info/Modals/FormModal/FormModal.stories.d.ts.map +1 -0
  18. package/dist/components/Info/Modals/FormModal/FormModal.stories.js +187 -0
  19. package/dist/components/Inputs/Buttons/Button/Button.d.ts +2 -2
  20. package/dist/components/Inputs/Buttons/Button/Button.d.ts.map +1 -1
  21. package/dist/components/Inputs/Buttons/Button/Button.js +3 -4
  22. package/dist/components/Inputs/Buttons/IconButton/IconButton.d.ts +2 -2
  23. package/dist/components/Inputs/Buttons/IconButton/IconButton.d.ts.map +1 -1
  24. package/dist/components/Inputs/Buttons/IconButton/IconButton.js +23 -4
  25. package/dist/components/Inputs/Buttons/shared/variants.d.ts +76 -188
  26. package/dist/components/Inputs/Buttons/shared/variants.d.ts.map +1 -1
  27. package/dist/components/Inputs/Buttons/shared/variants.js +49 -88
  28. package/dist/components/Layout/Table/Table.d.ts +3 -1
  29. package/dist/components/Layout/Table/Table.d.ts.map +1 -1
  30. package/dist/components/Layout/Table/Table.js +3 -3
  31. package/dist/components/Layout/Table/Table.stories.d.ts +3 -0
  32. package/dist/components/Layout/Table/Table.stories.d.ts.map +1 -1
  33. package/dist/components/Layout/Table/Table.stories.js +60 -1
  34. package/dist/components/index.d.ts +1 -0
  35. package/dist/components/index.d.ts.map +1 -1
  36. package/dist/components/index.js +1 -0
  37. package/dist/hooks/useConfirmationModal.d.ts +1 -1
  38. package/dist/hooks/useConfirmationModal.d.ts.map +1 -1
  39. package/dist/hooks/useConfirmationModal.js +3 -1
  40. package/dist/hooks/useInfoModal.d.ts +1 -1
  41. package/dist/hooks/useInfoModal.d.ts.map +1 -1
  42. package/dist/hooks/useInfoModal.js +3 -1
  43. package/package.json +2 -3
@@ -1,11 +1,13 @@
1
+ import React from 'react';
1
2
  import { BadgeProps as MantineBadgeProps } from '@mantine/core';
2
- import { colors } from '../../../constants/colors';
3
- interface BadgeProps extends Omit<MantineBadgeProps, 'color'> {
4
- size?: 'sm' | 'md' | 'lg';
5
- color?: keyof typeof colors;
6
- variant?: 'outline' | 'filled' | 'gradient';
3
+ import type { BadgeSize } from './sizes';
4
+ import type { BadgeColor, BadgeVariant } from './variants';
5
+ interface BadgeProps extends Omit<MantineBadgeProps, 'color' | 'leftSection'> {
6
+ size?: BadgeSize;
7
+ color?: BadgeColor;
8
+ variant?: BadgeVariant;
9
+ leftIcon?: React.ReactElement;
7
10
  }
8
- declare const Badge: ({ styles, color, variant, size, ...props }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
9
- export { Badge };
10
- export type { BadgeProps };
11
+ declare const Badge: ({ styles, color, variant, size, leftIcon, ...props }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
12
+ export { Badge, type BadgeProps };
11
13
  //# sourceMappingURL=Badge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../../src/components/Info/Badge/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyB,UAAU,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGvF,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEnD,UAAU,UAAW,SAAQ,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC;IAC3D,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,OAAO,MAAM,CAAC;IAC5B,OAAO,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;CAC7C;AAED,QAAA,MAAM,KAAK,GAAI,4CAA2E,UAAU,4CA8DnG,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,YAAY,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../../src/components/Info/Badge/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAyB,UAAU,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAKvF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE3D,UAAU,UAAW,SAAQ,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,aAAa,CAAC;IAC3E,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;CAC/B;AAED,QAAA,MAAM,KAAK,GAAI,sDAAqF,UAAU,4CAoC7G,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,CAAC"}
@@ -1,54 +1,21 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
2
3
  import { Badge as MantineBadge } from '@mantine/core';
3
- import { fontBase, inputFontSize } from '../../../constants/font';
4
- import { colors } from '../../../constants/colors';
5
- const Badge = ({ styles, color = 'primary', variant = 'outline', size = 'md', ...props }) => {
6
- const sizes = {
7
- sm: {
8
- mantineSize: 'md',
9
- padding: '0.4rem 0.8rem',
10
- height: '1.5rem',
11
- fontSize: inputFontSize['sm'],
12
- },
13
- md: {
14
- mantineSize: 'lg',
15
- padding: '0.4rem 0.8rem',
16
- height: '2.5rem',
17
- fontSize: inputFontSize['md'],
18
- },
19
- lg: {
20
- mantineSize: 'xl',
21
- padding: '0.4rem 0.8rem',
22
- height: '3rem',
23
- fontSize: inputFontSize['lg'],
24
- },
25
- };
26
- const variants = {
27
- outline: {
28
- border: `1.5px solid ${colors[color][200]}`,
29
- color: colors[color][200],
30
- backgroundColor: 'transparent',
31
- borderRadius: '8px',
32
- padding: '0.4rem 0.8rem',
33
- },
34
- filled: {
35
- backgroundColor: colors[color][50],
36
- color: colors[color][200],
37
- },
38
- gradient: {
39
- background: `linear-gradient(to right, ${colors[color][50]}, ${colors[color][200]})`,
40
- color: 'white',
41
- borderRadius: '16px',
42
- padding: '0.4rem 0.8rem',
43
- },
44
- };
45
- const selectedSize = sizes[size];
46
- const selectedVariant = variants[variant];
4
+ import { fontBase } from '../../../constants/font';
5
+ import { badgeSizes } from './sizes';
6
+ import { getVariantStyles } from './variants';
7
+ const Badge = ({ styles, color = 'primary', variant = 'outline', size = 'md', leftIcon, ...props }) => {
8
+ const selectedSize = badgeSizes[size];
9
+ const variantStyles = getVariantStyles(color);
10
+ const selectedVariant = variantStyles[variant];
47
11
  const style = {
48
12
  root: {
49
13
  padding: selectedSize.padding,
50
14
  height: selectedSize.height,
51
15
  cursor: 'default',
16
+ display: 'flex',
17
+ alignItems: 'center',
18
+ justifyContent: 'center',
52
19
  ...selectedVariant,
53
20
  },
54
21
  inner: {
@@ -57,8 +24,19 @@ const Badge = ({ styles, color = 'primary', variant = 'outline', size = 'md', ..
57
24
  textTransform: 'none',
58
25
  cursor: 'default',
59
26
  },
27
+ leftSection: {
28
+ display: 'flex',
29
+ alignItems: 'center',
30
+ justifyContent: 'center',
31
+ },
32
+ rightSection: {
33
+ display: 'flex',
34
+ alignItems: 'center',
35
+ justifyContent: 'center',
36
+ },
60
37
  ...styles,
61
38
  };
62
- return _jsx(MantineBadge, { size: selectedSize.mantineSize, styles: style, ...props });
39
+ const badgeIcon = leftIcon ? React.cloneElement(leftIcon, { size: selectedSize.iconSize, color: selectedVariant.color }) : leftIcon;
40
+ return _jsx(MantineBadge, { size: selectedSize.mantineSize, styles: style, leftSection: badgeIcon, ...props });
63
41
  };
64
42
  export { Badge };
@@ -0,0 +1,15 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import type { BadgeProps } from './Badge';
3
+ type LeftIconChoice = 'none' | 'IconCheck' | 'IconCircleFilled';
4
+ type BadgeStoryArgs = Omit<BadgeProps, 'leftIcon'> & {
5
+ leftIcon?: LeftIconChoice;
6
+ };
7
+ declare const meta: Meta<BadgeStoryArgs>;
8
+ export default meta;
9
+ type Story = StoryObj<BadgeStoryArgs>;
10
+ export declare const Default: Story;
11
+ export declare const Variants: Story;
12
+ export declare const Colors: Story;
13
+ export declare const Sizes: Story;
14
+ export declare const WithLeftIcon: Story;
15
+ //# sourceMappingURL=Badge.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Badge.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/Info/Badge/Badge.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C,KAAK,cAAc,GAAG,MAAM,GAAG,WAAW,GAAG,kBAAkB,CAAC;AAEhE,KAAK,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG;IACnD,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,cAAc,CAwD9B,CAAC;AAQF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;AAEtC,eAAO,MAAM,OAAO,EAAE,KAYrB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAQtB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAUpB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAQnB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAsC1B,CAAC"}
@@ -0,0 +1,92 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { IconCheck, IconCircleFilled } from '@tabler/icons-react';
3
+ import { Badge } from './Badge';
4
+ import { Group } from '../../Layout/Group/Group';
5
+ import { Stack } from '../../Layout/Stack/Stack';
6
+ const meta = {
7
+ title: 'Components/Info/Badge',
8
+ component: Badge,
9
+ parameters: {
10
+ layout: 'centered',
11
+ docs: {
12
+ description: {
13
+ component: 'A customizable badge built on Mantine Badge. Supports sizes (sm, md, lg), design system colors, and outline, filled, or gradient variants.',
14
+ },
15
+ },
16
+ },
17
+ argTypes: {
18
+ variant: {
19
+ control: { type: 'select' },
20
+ options: ['outline', 'filled', 'gradient'],
21
+ description: 'Visual style of the badge',
22
+ table: {
23
+ type: { summary: "'outline' | 'filled' | 'gradient'" },
24
+ defaultValue: { summary: "'outline'" },
25
+ },
26
+ },
27
+ size: {
28
+ control: { type: 'select' },
29
+ options: ['sm', 'md', 'lg'],
30
+ description: 'Badge size (height and font size)',
31
+ table: {
32
+ type: { summary: "'sm' | 'md' | 'lg'" },
33
+ defaultValue: { summary: "'md'" },
34
+ },
35
+ },
36
+ color: {
37
+ control: { type: 'select' },
38
+ options: ['primary', 'success', 'warning', 'error', 'neutral', 'white'],
39
+ description: 'Design system color',
40
+ table: {
41
+ type: { summary: 'keyof typeof colors' },
42
+ defaultValue: { summary: "'primary'" },
43
+ },
44
+ },
45
+ children: {
46
+ control: { type: 'text' },
47
+ description: 'Badge label or content',
48
+ table: {
49
+ type: { summary: 'ReactNode' },
50
+ },
51
+ },
52
+ leftIcon: {
53
+ control: { type: 'select' },
54
+ options: ['none', 'IconCheck', 'IconCircleFilled'],
55
+ description: 'Icon shown to the left of the label',
56
+ table: {
57
+ type: { summary: "'IconCheck' | 'IconCircleFilled' | 'etc'" },
58
+ },
59
+ },
60
+ },
61
+ };
62
+ const leftIconMap = {
63
+ none: undefined,
64
+ IconCheck: _jsx(IconCheck, {}),
65
+ IconCircleFilled: _jsx(IconCircleFilled, {}),
66
+ };
67
+ export default meta;
68
+ export const Default = {
69
+ args: {
70
+ children: 'Badge',
71
+ variant: 'outline',
72
+ size: 'md',
73
+ color: 'primary',
74
+ leftIcon: 'none',
75
+ },
76
+ render: (args) => {
77
+ const { leftIcon = 'none', ...badgeProps } = args;
78
+ return _jsx(Badge, { ...badgeProps, leftIcon: leftIconMap[leftIcon] });
79
+ },
80
+ };
81
+ export const Variants = {
82
+ render: () => (_jsxs(Group, { gap: "1.6rem", children: [_jsx(Badge, { variant: "outline", color: "primary", children: "Outline" }), _jsx(Badge, { variant: "filled", color: "primary", children: "Filled" }), _jsx(Badge, { variant: "gradient", color: "primary", children: "Gradient" })] })),
83
+ };
84
+ export const Colors = {
85
+ render: () => (_jsxs(Group, { gap: "1.6rem", style: { flexWrap: 'wrap' }, children: [_jsx(Badge, { variant: "outline", color: "primary", children: "Primary" }), _jsx(Badge, { variant: "outline", color: "success", children: "Success" }), _jsx(Badge, { variant: "outline", color: "warning", children: "Warning" }), _jsx(Badge, { variant: "outline", color: "error", children: "Error" }), _jsx(Badge, { variant: "outline", color: "neutral", children: "Neutral" })] })),
86
+ };
87
+ export const Sizes = {
88
+ render: () => (_jsxs(Group, { gap: "1.6rem", align: "flex-end", children: [_jsx(Badge, { size: "sm", color: "primary", children: "Small" }), _jsx(Badge, { size: "md", color: "primary", children: "Medium" }), _jsx(Badge, { size: "lg", color: "primary", children: "Large" })] })),
89
+ };
90
+ export const WithLeftIcon = {
91
+ render: () => (_jsxs(Stack, { gap: "1.6rem", children: [_jsxs(Group, { gap: "1.6rem", children: [_jsx(Badge, { size: "sm", leftIcon: _jsx(IconCheck, {}), color: "success", children: "Completed" }), _jsx(Badge, { size: "sm", variant: "filled", leftIcon: _jsx(IconCircleFilled, {}), color: "success", children: "Online" }), _jsx(Badge, { size: "sm", variant: "gradient", leftIcon: _jsx(IconCheck, {}), color: "success", children: "In Progress" })] }), _jsxs(Group, { gap: "1.6rem", children: [_jsx(Badge, { leftIcon: _jsx(IconCheck, {}), color: "success", children: "Completed" }), _jsx(Badge, { variant: "filled", leftIcon: _jsx(IconCircleFilled, {}), color: "success", children: "Online" }), _jsx(Badge, { variant: "gradient", leftIcon: _jsx(IconCheck, {}), color: "success", children: "In Progress" })] }), _jsxs(Group, { gap: "1.6rem", children: [_jsx(Badge, { size: "lg", leftIcon: _jsx(IconCheck, {}), color: "success", children: "Completed" }), _jsx(Badge, { size: "lg", variant: "filled", leftIcon: _jsx(IconCircleFilled, {}), color: "success", children: "Online" }), _jsx(Badge, { size: "lg", variant: "gradient", leftIcon: _jsx(IconCheck, {}), color: "success", children: "In Progress" })] })] })),
92
+ };
@@ -0,0 +1,34 @@
1
+ export declare const badgeSizes: {
2
+ sm: {
3
+ mantineSize: string;
4
+ padding: string;
5
+ height: string;
6
+ fontSize: {
7
+ fontSize: string;
8
+ lineHeight: string;
9
+ };
10
+ iconSize: number;
11
+ };
12
+ md: {
13
+ mantineSize: string;
14
+ padding: string;
15
+ height: string;
16
+ fontSize: {
17
+ fontSize: string;
18
+ lineHeight: string;
19
+ };
20
+ iconSize: number;
21
+ };
22
+ lg: {
23
+ mantineSize: string;
24
+ padding: string;
25
+ height: string;
26
+ fontSize: {
27
+ fontSize: string;
28
+ lineHeight: string;
29
+ };
30
+ iconSize: number;
31
+ };
32
+ };
33
+ export type BadgeSize = keyof typeof badgeSizes;
34
+ //# sourceMappingURL=sizes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sizes.d.ts","sourceRoot":"","sources":["../../../../src/components/Info/Badge/sizes.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBtB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,UAAU,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { inputFontSize } from '../../../constants/font';
2
+ export const badgeSizes = {
3
+ sm: {
4
+ mantineSize: 'md',
5
+ padding: '0.4rem 0.8rem',
6
+ height: '1.5rem',
7
+ fontSize: inputFontSize['sm'],
8
+ iconSize: 10,
9
+ },
10
+ md: {
11
+ mantineSize: 'lg',
12
+ padding: '0.4rem 0.8rem',
13
+ height: '2.5rem',
14
+ fontSize: inputFontSize['md'],
15
+ iconSize: 14,
16
+ },
17
+ lg: {
18
+ mantineSize: 'xl',
19
+ padding: '0.4rem 0.8rem',
20
+ height: '3rem',
21
+ fontSize: inputFontSize['lg'],
22
+ iconSize: 16,
23
+ },
24
+ };
@@ -0,0 +1,6 @@
1
+ import type { CSSObject } from '@mantine/styles';
2
+ import { colors } from '../../../constants/colors';
3
+ export type BadgeVariant = 'outline' | 'filled' | 'gradient';
4
+ export type BadgeColor = keyof typeof colors;
5
+ export declare function getVariantStyles(color: BadgeColor): Record<BadgeVariant, CSSObject>;
6
+ //# sourceMappingURL=variants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/components/Info/Badge/variants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEnD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE7D,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,MAAM,CAAC;AAE7C,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAoBnF"}
@@ -0,0 +1,22 @@
1
+ import { colors } from '../../../constants/colors';
2
+ export function getVariantStyles(color) {
3
+ return {
4
+ outline: {
5
+ border: `1.5px solid ${colors[color][200]}`,
6
+ color: colors[color][200],
7
+ backgroundColor: 'transparent',
8
+ borderRadius: '8px',
9
+ padding: '0.4rem 0.8rem',
10
+ },
11
+ filled: {
12
+ backgroundColor: colors[color][50],
13
+ color: colors[color][200],
14
+ },
15
+ gradient: {
16
+ background: `linear-gradient(to right, ${colors[color][50]}, ${colors[color][200]})`,
17
+ color: 'white',
18
+ borderRadius: '16px',
19
+ padding: '0.4rem 0.8rem',
20
+ },
21
+ };
22
+ }
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import { modalVariants } from "../variants";
3
+ export interface FormModalProps {
4
+ opened: boolean;
5
+ onClose: () => void;
6
+ icon?: React.ReactElement;
7
+ children?: React.ReactNode;
8
+ size?: string | number;
9
+ modalVariant?: keyof typeof modalVariants;
10
+ onCancel?: () => void;
11
+ onConfirm?: () => void;
12
+ cancelLabel?: string;
13
+ confirmLabel?: string;
14
+ }
15
+ export declare const FormModal: ({ opened, onClose, icon, children, size, modalVariant, onCancel, onConfirm, cancelLabel, confirmLabel, }: FormModalProps) => import("react/jsx-runtime").JSX.Element;
16
+ //# sourceMappingURL=FormModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormModal.d.ts","sourceRoot":"","sources":["../../../../../src/components/Info/Modals/FormModal/FormModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,OAAO,aAAa,CAAC;IAC1C,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,SAAS,GAAI,0GAWvB,cAAc,4CA+FhB,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from "react";
3
+ import { Modal as MantineModal } from "@mantine/core";
4
+ import { neutral } from "../../../../constants/colors";
5
+ import { Stack } from "../../../Layout/Stack/Stack";
6
+ import { Center } from "../../../Layout/Center/Center";
7
+ import { modalVariants } from "../variants";
8
+ import { Group } from "../../../Layout/Group/Group";
9
+ import { Button } from "../../../Inputs/Buttons/Button/Button";
10
+ export const FormModal = ({ opened, onClose, icon, children, size = "40rem", modalVariant = "info", onCancel, onConfirm, cancelLabel, confirmLabel, }) => {
11
+ const selectedVariant = modalVariants[modalVariant];
12
+ const iconContainer = {
13
+ width: "4.2rem",
14
+ height: "4.2rem",
15
+ borderRadius: "50%",
16
+ backgroundColor: selectedVariant.iconBackgroundColor,
17
+ border: `2px solid ${selectedVariant.iconColor}`,
18
+ };
19
+ const coloredIcon = icon && React.cloneElement(icon, { color: icon.props.color || selectedVariant.iconColor });
20
+ const modalIcon = coloredIcon || (_jsx("i", { className: selectedVariant.icon, style: { color: selectedVariant.iconColor, fontSize: "2rem" } }));
21
+ return (_jsx(MantineModal, { opened: opened, onClose: onClose, centered: true, radius: "16px", overlayProps: {
22
+ opacity: 0,
23
+ blur: 4,
24
+ }, size: size, transitionProps: {
25
+ transition: "pop",
26
+ duration: 200,
27
+ }, closeButtonProps: {
28
+ style: {
29
+ borderRadius: "16px",
30
+ backgroundColor: neutral[50],
31
+ width: "1.8rem",
32
+ height: "1.8rem",
33
+ },
34
+ }, styles: {
35
+ content: {
36
+ borderRadius: "8px",
37
+ border: `1px solid ${neutral[50]}`,
38
+ boxShadow: "0px 0px 19px 0px #00000040",
39
+ },
40
+ header: {
41
+ padding: "0.8rem",
42
+ },
43
+ close: {
44
+ borderRadius: "16px",
45
+ backgroundColor: neutral[50],
46
+ width: "1.8rem",
47
+ height: "1.8rem",
48
+ "&:hover": {
49
+ backgroundColor: neutral[50],
50
+ },
51
+ "&:active": {
52
+ transform: "none",
53
+ },
54
+ },
55
+ body: {
56
+ padding: "0 3.2rem 1.6rem 3.2rem",
57
+ },
58
+ }, children: _jsx(Center, { h: "100%", w: "100%", children: _jsxs(Stack, { gap: "2rem", h: "100%", w: "100%", align: "center", children: [_jsxs(Stack, { gap: "1.5rem", align: "center", children: [_jsx(Center, { style: iconContainer, children: modalIcon }), children && (_jsx(Stack, { gap: "0.25rem", align: "center", children: children }))] }), _jsx(Center, { h: "100%", w: "100%", children: _jsxs(Group, { gap: "1rem", align: "center", children: [_jsx(Button, { onClick: onCancel, variant: "secondary", children: cancelLabel || selectedVariant.cancelLabel }), _jsx(Button, { onClick: onConfirm, variant: selectedVariant.buttonVariant, children: confirmLabel || selectedVariant.confirmLabel })] }) })] }) }) }));
59
+ };
@@ -0,0 +1,14 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite";
2
+ import { FormModal } from "./FormModal";
3
+ declare const meta: Meta<typeof FormModal>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof FormModal>;
6
+ export declare const Default: Story;
7
+ export declare const WithCustomIcon: Story;
8
+ export declare const WithCustomIconColor: Story;
9
+ export declare const WithTextInput: Story;
10
+ export declare const Variants: Story;
11
+ export declare const Sizes: Story;
12
+ export declare const CustomLabels: Story;
13
+ export declare const CompleteExample: Story;
14
+ //# sourceMappingURL=FormModal.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormModal.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Info/Modals/FormModal/FormModal.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAYxC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,SAAS,CAiFhC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,SAAS,CAAC,CAAC;AAExC,eAAO,MAAM,OAAO,EAAE,KAyDrB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAuB5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAuBjC,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAwB3B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAuCtB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAyCnB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAwB1B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAwC7B,CAAC"}
@@ -0,0 +1,187 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { FormModal } from "./FormModal";
4
+ import { Button } from "../../../Inputs/Buttons/Button/Button";
5
+ import { primary, red } from "../../../../constants/colors";
6
+ import { IconFlask, IconShoppingCart } from "@tabler/icons-react";
7
+ import { TextInput } from "../../../Inputs/TextInputs/TextInput/TextInput";
8
+ import { NumberInput } from "../../../Inputs/TextInputs/NumberInput/NumberInput";
9
+ import { Stack } from "../../../Layout/Stack/Stack";
10
+ import { Title } from "../../../Typography/Title/Title";
11
+ import { Group } from "../../../Layout/Group/Group";
12
+ import { Center } from "../../../Layout/Center/Center";
13
+ import { modalVariants } from "../variants";
14
+ const meta = {
15
+ title: "Components/Info/Modals/FormModal",
16
+ component: FormModal,
17
+ argTypes: {
18
+ opened: {
19
+ control: false,
20
+ description: "Whether the modal is open.",
21
+ table: {
22
+ type: { summary: "boolean" },
23
+ },
24
+ },
25
+ onClose: {
26
+ control: false,
27
+ description: "Called when the modal is closed (e.g. overlay click, close button).",
28
+ table: {
29
+ type: { summary: "() => void" },
30
+ },
31
+ },
32
+ icon: {
33
+ control: false,
34
+ description: "Custom icon to display above the content. If not provided, the default variant icon is used.",
35
+ table: {
36
+ type: { summary: "ReactNode" },
37
+ },
38
+ },
39
+ children: {
40
+ control: false,
41
+ description: "Modal body content (messages, forms, inputs, etc.).",
42
+ table: {
43
+ type: { summary: "ReactNode" },
44
+ },
45
+ },
46
+ size: {
47
+ control: { type: "text" },
48
+ description: "Modal size (CSS value or number in px).",
49
+ table: {
50
+ type: { summary: "string | number" },
51
+ defaultValue: { summary: "'40rem'" },
52
+ },
53
+ },
54
+ modalVariant: {
55
+ control: { type: "select" },
56
+ options: Object.keys(modalVariants),
57
+ description: "Visual variant (provides default icon, button style, and labels).",
58
+ table: {
59
+ type: {
60
+ summary: "'confirm' | 'info' | 'success' | 'error' | 'warning' | 'cancel'",
61
+ },
62
+ defaultValue: { summary: "'info'" },
63
+ },
64
+ },
65
+ onCancel: {
66
+ control: false,
67
+ description: "Handler for the cancel button click.",
68
+ table: {
69
+ type: { summary: "() => void" },
70
+ },
71
+ },
72
+ onConfirm: {
73
+ control: false,
74
+ description: "Handler for the confirm button click.",
75
+ table: {
76
+ type: { summary: "() => void" },
77
+ },
78
+ },
79
+ cancelLabel: {
80
+ control: { type: "text" },
81
+ description: "Override cancel button label. Omit to use variant default.",
82
+ table: { type: { summary: "string" } },
83
+ },
84
+ confirmLabel: {
85
+ control: { type: "text" },
86
+ description: "Override confirm button label. Omit to use variant default.",
87
+ table: { type: { summary: "string" } },
88
+ },
89
+ },
90
+ };
91
+ export default meta;
92
+ export const Default = {
93
+ args: {
94
+ modalVariant: "info",
95
+ size: "40rem",
96
+ cancelLabel: "",
97
+ confirmLabel: "",
98
+ },
99
+ render: (args) => {
100
+ const [opened, setOpened] = useState(false);
101
+ return (_jsxs(_Fragment, { children: [_jsx(Center, { children: _jsx(Button, { onClick: () => setOpened(true), children: "Open FormModal" }) }), _jsx(FormModal, { ...args, opened: opened, onClose: () => setOpened(false), onCancel: () => setOpened(false), onConfirm: () => setOpened(false), children: _jsx(Title, { variant: "cardSubheader", align: "center", children: "Example message." }) })] }));
102
+ },
103
+ parameters: {
104
+ docs: {
105
+ source: {
106
+ code: `const [opened, setOpened] = useState(false);
107
+
108
+ return (
109
+ <>
110
+ <Center>
111
+ <Button onClick={() => setOpened(true)}>Open FormModal</Button>
112
+ </Center>
113
+ <FormModal
114
+ opened={opened}
115
+ onClose={() => setOpened(false)}
116
+ onCancel={() => setOpened(false)}
117
+ onConfirm={() => setOpened(false)}
118
+ modalVariant='info'
119
+ size='40rem'
120
+ children={
121
+ <Title variant="cardSubheader" align="center">
122
+ Example message.
123
+ </Title>
124
+ }
125
+ />
126
+ </>
127
+ );`,
128
+ },
129
+ },
130
+ },
131
+ };
132
+ export const WithCustomIcon = {
133
+ render: () => {
134
+ const [opened, setOpened] = useState(false);
135
+ return (_jsxs(_Fragment, { children: [_jsx(Center, { children: _jsx(Button, { onClick: () => setOpened(true), children: "Open FormModal" }) }), _jsx(FormModal, { opened: opened, onClose: () => setOpened(false), onCancel: () => setOpened(false), onConfirm: () => setOpened(false), icon: _jsx(IconFlask, { color: primary[200] }), children: _jsx(Title, { variant: "cardSubheader", align: "center", children: "Example message." }) })] }));
136
+ },
137
+ };
138
+ export const WithCustomIconColor = {
139
+ render: () => {
140
+ const [opened, setOpened] = useState(false);
141
+ return (_jsxs(_Fragment, { children: [_jsx(Center, { children: _jsx(Button, { onClick: () => setOpened(true), children: "Open FormModal" }) }), _jsx(FormModal, { opened: opened, onClose: () => setOpened(false), onCancel: () => setOpened(false), onConfirm: () => setOpened(false), icon: _jsx(IconFlask, { color: red[200] }), children: _jsx(Title, { variant: "cardSubheader", align: "center", children: "Example message." }) })] }));
142
+ },
143
+ };
144
+ export const WithTextInput = {
145
+ render: () => {
146
+ const [opened, setOpened] = useState(false);
147
+ return (_jsxs(_Fragment, { children: [_jsx(Center, { children: _jsx(Button, { onClick: () => setOpened(true), children: "Open FormModal" }) }), _jsx(FormModal, { children: _jsx(TextInput, { label: "Full Name", placeholder: "Enter your full name", onChange: () => { } }), opened: opened, onClose: () => setOpened(false), onCancel: () => setOpened(false), onConfirm: () => setOpened(false) })] }));
148
+ },
149
+ };
150
+ export const Variants = {
151
+ render: () => {
152
+ const [opened, setOpened] = useState(false);
153
+ const [variant, setVariant] = useState("info");
154
+ return (_jsxs(_Fragment, { children: [_jsx(Center, { children: _jsx(Group, { gap: "1rem", children: Object.keys(modalVariants).map((v) => (_jsx(Button, { onClick: () => {
155
+ setVariant(v);
156
+ setOpened(true);
157
+ }, children: v }, v))) }) }), _jsx(FormModal, { opened: opened, onClose: () => setOpened(false), onCancel: () => setOpened(false), onConfirm: () => setOpened(false), modalVariant: variant, children: _jsx(Title, { variant: "cardSubheader", align: "center", children: modalVariants[variant].message }) })] }));
158
+ },
159
+ };
160
+ export const Sizes = {
161
+ render: () => {
162
+ const [opened, setOpened] = useState(false);
163
+ const [size, setSize] = useState("40rem");
164
+ const sizes = [
165
+ { label: "30rem", value: "30rem" },
166
+ { label: "40rem (Default)", value: "40rem" },
167
+ { label: "60rem", value: "60rem" },
168
+ ];
169
+ return (_jsxs(_Fragment, { children: [_jsx(Center, { children: _jsx(Group, { gap: "1rem", children: sizes.map(({ label, value }) => (_jsx(Button, { onClick: () => {
170
+ setSize(value);
171
+ setOpened(true);
172
+ }, children: label }, value))) }) }), _jsx(FormModal, { opened: opened, onClose: () => setOpened(false), onCancel: () => setOpened(false), onConfirm: () => setOpened(false), size: size, children: _jsxs(Title, { variant: "cardSubheader", align: "center", children: ["Modal size: ", size] }) })] }));
173
+ },
174
+ };
175
+ export const CustomLabels = {
176
+ render: () => {
177
+ const [opened, setOpened] = useState(false);
178
+ return (_jsxs(_Fragment, { children: [_jsx(Center, { children: _jsx(Button, { onClick: () => setOpened(true), children: "Open FormModal" }) }), _jsx(FormModal, { opened: opened, onClose: () => setOpened(false), onCancel: () => setOpened(false), onConfirm: () => setOpened(false), cancelLabel: "No, go back", confirmLabel: "Yes, continue", children: _jsx(Title, { variant: "cardSubheader", align: "center", children: "Custom cancel and confirm button labels." }) })] }));
179
+ },
180
+ };
181
+ export const CompleteExample = {
182
+ render: () => {
183
+ const [opened, setOpened] = useState(false);
184
+ const [quantity, setQuantity] = useState(1);
185
+ return (_jsxs(_Fragment, { children: [_jsx(Center, { children: _jsx(Button, { onClick: () => setOpened(true), children: "Add to Cart" }) }), _jsx(FormModal, { opened: opened, onClose: () => setOpened(false), onCancel: () => setOpened(false), onConfirm: () => setOpened(false), modalVariant: "confirm", icon: _jsx(IconShoppingCart, { color: primary[200] }), cancelLabel: "Cancel", confirmLabel: "Add to Cart", children: _jsxs(Stack, { gap: "1rem", align: "center", children: [_jsx(Title, { variant: "cardHeader", align: "center", children: "Add Item to Cart" }), _jsx(Title, { variant: "cardSubheader", align: "center", children: "Select the quantity you would like to add." }), _jsx(NumberInput, { label: "Quantity", value: quantity, onChange: (val) => setQuantity(val !== null && val !== void 0 ? val : 1), min: 1, max: 99, step: 1 })] }) })] }));
186
+ },
187
+ };
@@ -1,10 +1,10 @@
1
1
  import { ButtonProps as MantineButtonProps } from '@mantine/core';
2
2
  import { componentSizes } from './sizes';
3
- import { buttonVariants } from '../shared/variants';
3
+ import { componentVariants } from '../shared/variants';
4
4
  export interface ButtonProps extends MantineButtonProps {
5
5
  onClick?: () => void;
6
6
  size?: keyof typeof componentSizes;
7
- variant?: keyof typeof buttonVariants;
7
+ variant?: keyof typeof componentVariants;
8
8
  fullWidth?: boolean;
9
9
  toggled?: boolean;
10
10
  shadow?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../src/components/Inputs/Buttons/Button/Button.tsx"],"names":[],"mappings":"AACA,OAAO,EAA2B,WAAW,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE3F,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,WAAY,SAAQ,kBAAkB;IACrD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,OAAO,cAAc,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,OAAO,cAAc,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,MAAM,GAAI,0EAAqH,WAAW,4CAmCtJ,CAAC"}
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../src/components/Inputs/Buttons/Button/Button.tsx"],"names":[],"mappings":"AACA,OAAO,EAA2B,WAAW,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE3F,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,WAAY,SAAQ,kBAAkB;IACrD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,OAAO,cAAc,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,OAAO,iBAAiB,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,eAAO,MAAM,MAAM,GAAI,0EAAqH,WAAW,4CAkCtJ,CAAC"}