@beydesign/storybook 0.0.47 → 0.0.48

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.
@@ -3,9 +3,9 @@ import { useState } from 'react';
3
3
  import { Box } from '@mui/material';
4
4
  import { Typography, TypographySize, TypographyWeight } from '../Typography';
5
5
  import { HintBubble, HintBubbleSize } from '../UI';
6
- export const TextArea = ({ label, value, onChange, placeholder, hintText, errorText, disabled, maxLength = 256, showMaxLengthIndicator = false, numberOfRows = 5, style, hintBubbleProps, hintBubbleText, required, }) => {
6
+ export const TextArea = ({ label, value, onChange, placeholder, hintText, errorText, disabled, maxLength = 256, showMaxLengthIndicator = false, numberOfRows = 5, style, hintBubbleProps, hintBubbleText, required, labelTrailingElement, }) => {
7
7
  const [focused, setFocused] = useState(false);
8
- return (_jsx(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)', sx: style, children: _jsxs(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', minWidth: '260px', children: [label && (_jsx(Typography, { text: label, size: TypographySize.HeadingXS, weight: TypographyWeight.SemiBold, required: required })), hintBubbleText && (_jsx(HintBubble, { text: hintBubbleText, size: HintBubbleSize.sm, ...hintBubbleProps })), _jsx(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', bgcolor: 'var(--colors-light-background-bg-component)', border: `1px solid ${errorText
8
+ return (_jsx(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)', sx: style, children: _jsxs(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', minWidth: '260px', children: [label && (_jsx(Typography, { text: label, size: TypographySize.HeadingXS, weight: TypographyWeight.SemiBold, required: required, trailingElement: labelTrailingElement })), hintBubbleText && (_jsx(HintBubble, { text: hintBubbleText, size: HintBubbleSize.sm, ...hintBubbleProps })), _jsx(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', bgcolor: 'var(--colors-light-background-bg-component)', border: `1px solid ${errorText
9
9
  ? 'var(--colors-light-border-border-error)'
10
10
  : focused
11
11
  ? 'var(--colors-light-border-border-component-active)'
@@ -132,6 +132,15 @@ declare const meta: {
132
132
  };
133
133
  };
134
134
  };
135
+ labelTrailingElement: {
136
+ control: "object";
137
+ description: string;
138
+ table: {
139
+ type: {
140
+ summary: string;
141
+ };
142
+ };
143
+ };
135
144
  };
136
145
  };
137
146
  export default meta;
@@ -104,6 +104,13 @@ const meta = {
104
104
  type: { summary: 'object' },
105
105
  },
106
106
  },
107
+ labelTrailingElement: {
108
+ control: 'object',
109
+ description: 'The trailing element of the label',
110
+ table: {
111
+ type: { summary: 'ReactNode' },
112
+ },
113
+ },
107
114
  },
108
115
  };
109
116
  export default meta;
@@ -3,9 +3,9 @@ import { useState } from 'react';
3
3
  import { Box } from '@mui/material';
4
4
  import { Typography, TypographySize, TypographyWeight } from '../Typography';
5
5
  import { HintBubble, HintBubbleSize } from '../UI';
6
- export const TextInput = ({ label, value, onChange, placeholder, hintText, errorText, disabled, trailingText, style, hintBubbleText, hintBubbleProps, required, }) => {
6
+ export const TextInput = ({ label, value, onChange, placeholder, hintText, errorText, disabled, trailingText, style, hintBubbleText, hintBubbleProps, required, labelTrailingElement, }) => {
7
7
  const [focused, setFocused] = useState(false);
8
- return (_jsx(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)', sx: style, children: _jsxs(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', minWidth: '260px', children: [label && (_jsx(Typography, { text: label, size: TypographySize.HeadingXS, weight: TypographyWeight.SemiBold, required: required })), hintBubbleText && (_jsx(HintBubble, { text: hintBubbleText, size: HintBubbleSize.sm, ...hintBubbleProps })), _jsxs(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', bgcolor: 'var(--colors-light-background-bg-component)', border: errorText
8
+ return (_jsx(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)', sx: style, children: _jsxs(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', minWidth: '260px', children: [label && (_jsx(Typography, { text: label, size: TypographySize.HeadingXS, weight: TypographyWeight.SemiBold, required: required, trailingElement: labelTrailingElement })), hintBubbleText && (_jsx(HintBubble, { text: hintBubbleText, size: HintBubbleSize.sm, ...hintBubbleProps })), _jsxs(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', bgcolor: 'var(--colors-light-background-bg-component)', border: errorText
9
9
  ? 'none'
10
10
  : '1px solid var(--colors-light-border-border-component)', overflow: 'hidden', borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', children: [_jsx(Box, { display: 'flex', flexDirection: 'row', padding: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', width: '100%', borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs) 0 0 var(--spacing-tokens-size-in-px-spacing-spacing-xs)', border: `${errorText
11
11
  ? '1px solid var(--colors-light-border-border-error)'
@@ -114,6 +114,15 @@ declare const meta: {
114
114
  };
115
115
  };
116
116
  };
117
+ labelTrailingElement: {
118
+ control: "object";
119
+ description: string;
120
+ table: {
121
+ type: {
122
+ summary: string;
123
+ };
124
+ };
125
+ };
117
126
  };
118
127
  };
119
128
  export default meta;
@@ -90,6 +90,13 @@ const meta = {
90
90
  type: { summary: 'object' },
91
91
  },
92
92
  },
93
+ labelTrailingElement: {
94
+ control: 'object',
95
+ description: 'The trailing element of the label',
96
+ table: {
97
+ type: { summary: 'ReactNode' },
98
+ },
99
+ },
93
100
  },
94
101
  };
95
102
  export default meta;
@@ -32,6 +32,8 @@ export type TextAreaProps = {
32
32
  style?: SxProps<Theme>;
33
33
  /** Whether the text area is required */
34
34
  required?: boolean;
35
+ /** Text area label trailing element */
36
+ labelTrailingElement?: React.ReactNode;
35
37
  };
36
38
  /**
37
39
  * Text input component props
@@ -61,6 +63,8 @@ export type TextInputProps = {
61
63
  style?: SxProps<Theme>;
62
64
  /** Whether the text input is required */
63
65
  required?: boolean;
66
+ /** Text input label trailing element */
67
+ labelTrailingElement?: React.ReactNode;
64
68
  };
65
69
  /**
66
70
  * Toggle position variants
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { TypographySize, TypographyWeight } from './types';
3
- export const Typography = ({ text, color, size = TypographySize.HeadingL, weight = TypographyWeight.Bold, className, required = false, style, }) => {
3
+ import { Box } from '@mui/material';
4
+ export const Typography = ({ text, color, size = TypographySize.HeadingL, weight = TypographyWeight.Bold, className, required = false, style, trailingElement = null, }) => {
4
5
  const getTypographySizeToken = () => {
5
6
  let sizeLc = size?.toLowerCase() || '';
6
7
  if (sizeLc.includes('heading')) {
@@ -29,26 +30,33 @@ export const Typography = ({ text, color, size = TypographySize.HeadingL, weight
29
30
  const paragraphIndent = `var(--global-${sizeToken}-${weightToken}-paragraph-indent)`;
30
31
  const paragraphSpacing = `var(--global-${sizeToken}-${weightToken}-paragraph-spacing)`;
31
32
  const textDecoration = `var(--global-${sizeToken}-${weightToken}-text-decoration)`;
33
+ const requiredColor = 'var(--colors-light-text-text-error)';
32
34
  const getTextTransform = () => {
33
35
  const computedValue = getComputedStyle(document.documentElement)
34
36
  .getPropertyValue(`--global-${sizeToken}-${weightToken}-text-case`)
35
37
  .trim();
36
38
  return (computedValue === 'uppercase' ? 'uppercase' : 'none');
37
39
  };
38
- return (_jsxs("span", { className: className, style: {
39
- display: 'flex',
40
- alignItems: 'center',
41
- fontSize: fontSize,
42
- fontWeight: fontWeight,
43
- fontFamily: fontFamily + ', sans-serif',
44
- lineHeight: lineHeight + 'px',
45
- letterSpacing: letterSpacing,
46
- textIndent: paragraphIndent,
47
- marginBottom: paragraphSpacing,
48
- textTransform: getTextTransform(),
49
- textDecoration: textDecoration,
50
- color: color || 'var(--global-text-text-title)',
51
- gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)',
52
- ...style,
53
- }, children: [text, required && (_jsx("span", { style: { color: 'var(--colors-light-text-text-error)' }, children: "*" }))] }));
40
+ const Label = () => {
41
+ return (_jsxs("span", { className: className, style: {
42
+ display: 'flex',
43
+ alignItems: 'center',
44
+ gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)',
45
+ fontSize: fontSize,
46
+ fontWeight: fontWeight,
47
+ fontFamily: fontFamily + ', sans-serif',
48
+ lineHeight: lineHeight + 'px',
49
+ letterSpacing: letterSpacing,
50
+ textIndent: paragraphIndent,
51
+ marginBottom: paragraphSpacing,
52
+ textTransform: getTextTransform(),
53
+ textDecoration: textDecoration,
54
+ color: color || 'var(--global-text-text-title)',
55
+ ...style,
56
+ }, children: [text, required && _jsx("span", { style: { color: requiredColor }, children: "*" })] }));
57
+ };
58
+ if (!trailingElement) {
59
+ return _jsx(Label, {});
60
+ }
61
+ return (_jsxs(Box, { display: "flex", flexDirection: "row", alignItems: "center", justifyContent: "flex-start", gap: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)", children: [_jsx(Label, {}), trailingElement] }));
54
62
  };
@@ -1,5 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  import { Typography } from './Typography';
2
3
  import { TypographySize, TypographyWeight } from './types';
4
+ import { Info } from '@phosphor-icons/react';
3
5
  const meta = {
4
6
  title: 'Design System/Components/Typography/Typography',
5
7
  component: Typography,
@@ -65,6 +67,12 @@ const meta = {
65
67
  type: { summary: 'string' },
66
68
  },
67
69
  },
70
+ trailingElement: {
71
+ description: 'Trailing element of the typography',
72
+ table: {
73
+ type: { summary: 'ReactNode' },
74
+ },
75
+ },
68
76
  },
69
77
  };
70
78
  export default meta;
@@ -73,6 +81,8 @@ export const HeadingXLBold = {
73
81
  text: 'Typography',
74
82
  size: TypographySize.HeadingXL,
75
83
  weight: TypographyWeight.Bold,
84
+ trailingElement: _jsx(Info, { size: 24 }),
85
+ required: true,
76
86
  },
77
87
  };
78
88
  export const HeadingXLSemiBold = {
@@ -41,4 +41,6 @@ export interface TypographyProps {
41
41
  style?: React.CSSProperties;
42
42
  /** Whether the typography is required */
43
43
  required?: boolean;
44
+ /** Whether the typography has a trailing element */
45
+ trailingElement?: React.ReactNode;
44
46
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beydesign/storybook",
3
3
  "private": false,
4
- "version": "0.0.47",
4
+ "version": "0.0.48",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",