@soul-refiner/design-system 0.2.68 → 0.2.70

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.
@@ -30,6 +30,6 @@ export interface FilterTriggerProps {
30
30
  onClick?: (event: React.MouseEvent) => void;
31
31
  open: boolean;
32
32
  type: FilterTriggerTypes;
33
- value: string;
33
+ value?: string;
34
34
  }
35
35
  export { Filter };
@@ -51,7 +51,12 @@ const Filter = ({ closeOnBlur = true, disabled, graphic, label, sx, triggerType,
51
51
  return (React.createElement(Option, { key: option.value, onClick: handleChange, selected: isSelected(option.value), ...option }));
52
52
  });
53
53
  return (React.createElement(Wrapper, { "$sx": sx, tabIndex: 0, ref: wrapperRef, onBlurCapture: handleBlur },
54
- React.createElement(FilterTrigger, { disabled: disabled, graphic: graphic, label: label, onClick: handleOpen, open: open, type: triggerType, value: options.find((option) => isSelected(option.value)).label }),
54
+ React.createElement(FilterTrigger, { disabled: disabled, graphic: graphic, label: label, onClick: handleOpen, open: open, type: triggerType, value: options.find((option) => {
55
+ if (typeof option === 'string' && option === 'break') {
56
+ return false;
57
+ }
58
+ return isSelected(option.value);
59
+ })?.label }),
55
60
  open && React.createElement(Container, { ref: optionsRef }, dropdownOptions)));
56
61
  };
57
62
  const Wrapper = styled.div `
@@ -65,6 +70,18 @@ const Container = styled.div `
65
70
  width: max-content;
66
71
  z-index: 100;
67
72
  outline: none;
73
+ box-shadow: var(--elevation-2);
74
+ background-color: var(--color-white);
75
+ cursor: pointer;
76
+ border-radius: 8px;
77
+
78
+ & > div:first-of-type {
79
+ border-radius: 8px 8px 0px 0px;
80
+ }
81
+
82
+ & > div:last-of-type {
83
+ border-radius: 0px 0px 8px 8px;
84
+ }
68
85
  `;
69
86
  /********************************************************
70
87
  * Triggers
@@ -10,5 +10,7 @@ export { Search } from './search';
10
10
  export type { SearchProps } from './search';
11
11
  export { Select } from './select';
12
12
  export type { SelectProps } from './select';
13
+ export { TextArea } from './text_area';
14
+ export type { TextAreaProps } from './text_area';
13
15
  export { TextInput } from './text_input';
14
16
  export type { TextInputProps } from './text_input';
@@ -4,4 +4,5 @@ export { Filter } from './filter';
4
4
  export { Radio } from './radio';
5
5
  export { Search } from './search';
6
6
  export { Select } from './select';
7
+ export { TextArea } from './text_area';
7
8
  export { TextInput } from './text_input';
@@ -0,0 +1,2 @@
1
+ export { TextArea } from './text_area';
2
+ export type { TextAreaProps } from './text_area';
@@ -0,0 +1 @@
1
+ export { TextArea } from './text_area';
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ export type Props = {
3
+ disabled?: boolean | never;
4
+ successful?: boolean | never;
5
+ warning?: boolean | never;
6
+ bg?: string;
7
+ icon?: React.ReactElement;
8
+ helperText?: string;
9
+ label?: string;
10
+ maxCharacters?: number;
11
+ /**
12
+ * @param minHeight if set, this will make the textarea grow with the text inputted
13
+ * @see resize !! do not use with resize={true} !!
14
+ */
15
+ minHeight?: number;
16
+ minWidth?: number;
17
+ name?: string;
18
+ onChange?: React.ChangeEventHandler<HTMLTextAreaElement>;
19
+ placeholder?: string;
20
+ /**
21
+ * @param resize the user can change the size of the textarea
22
+ * @see resize !! do not use with minHeight !!
23
+ */
24
+ resize?: boolean;
25
+ sx?: string;
26
+ value: string | string[];
27
+ };
28
+ interface DisabledProps extends Props {
29
+ disabled?: true;
30
+ successful?: false | never;
31
+ warning?: false | never;
32
+ }
33
+ interface SuccessfulProps extends Props {
34
+ disabled?: false | never;
35
+ successful?: true;
36
+ warning?: false | never;
37
+ }
38
+ interface WarningProps extends Props {
39
+ disabled?: false | never;
40
+ successful?: false | never;
41
+ warning?: true;
42
+ }
43
+ export type TextAreaProps = DisabledProps | SuccessfulProps | WarningProps;
44
+ export declare const TextArea: ({ bg, disabled, helperText, icon, label, maxCharacters, minHeight, minWidth, name, onChange, placeholder, resize, successful, sx, value, warning, }: TextAreaProps) => React.JSX.Element;
45
+ export {};
@@ -0,0 +1,109 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ import styled from 'styled-components';
4
+ import { Box } from '../../atoms/box/box';
5
+ import { CheckmarkCircle, AlertCircle } from '../../../icons';
6
+ export const TextArea = ({ bg = 'var(--color-blue-10)', disabled, helperText, icon, label, maxCharacters, minHeight, minWidth, name, onChange, placeholder, resize = false, successful, sx, value, warning, }) => {
7
+ const ref = React.useRef(null);
8
+ React.useEffect(() => {
9
+ if (ref.current) {
10
+ ref.current.style.height = `${minHeight}px`;
11
+ const scrollHeight = ref.current.scrollHeight;
12
+ ref.current.style.height = scrollHeight + 'px';
13
+ }
14
+ }, [ref.current, value]);
15
+ return (React.createElement(Label, { "$disabled": disabled, "$sx": sx },
16
+ label,
17
+ React.createElement(InputWrapper, { "$bg": bg, "$minWidth": minWidth, "$successful": successful, "$warning": warning },
18
+ icon,
19
+ React.createElement(TextAreaElement, { disabled: disabled, name: name, onChange: onChange, placeholder: placeholder, ref: ref, value: maxCharacters
20
+ ? value.slice(0, maxCharacters - 1)
21
+ : value, "$resize": resize }),
22
+ successful && React.createElement(CheckmarkCircle, { color: "green-3" }),
23
+ warning && React.createElement(AlertCircle, { color: "red-4" })),
24
+ React.createElement(Box, { "$gap": 16, "$justify": "space-between" },
25
+ helperText && React.createElement(HelperText, null, helperText),
26
+ maxCharacters && (React.createElement(MaxCharactersText, null,
27
+ value.length,
28
+ " / ",
29
+ maxCharacters)))));
30
+ };
31
+ const Label = styled.label `
32
+ width: 100%;
33
+ display: flex;
34
+ gap: 4px;
35
+ flex-flow: column nowrap;
36
+ color: var(--color-grey-2);
37
+ font-family: var(--font-inter);
38
+ font-size: 18px;
39
+ font-weight: 500;
40
+ line-height: 26px;
41
+
42
+ ${({ $disabled }) => $disabled
43
+ ? `
44
+ color: var(--color-grey-7) !important;
45
+ & > * {
46
+ color: var(--color-grey-7) !important;
47
+ }
48
+ & > div:first-of-type {
49
+ background-color: var(--color-grey-9) !important;
50
+ }`
51
+ : ''}
52
+
53
+ ${({ $sx }) => ($sx ? $sx : '')}
54
+ `;
55
+ const InputWrapper = styled.div `
56
+ min-width: ${({ $minWidth }) => ($minWidth ? $minWidth + 'px;' : '')}
57
+ display: flex;
58
+ gap: 8px;
59
+ align-items: center;
60
+ box-sizing: border-box;
61
+ padding: 12px;
62
+ background-color: ${({ $bg }) => $bg};
63
+ border-radius: 8px;
64
+ border: 1px solid transparent;
65
+
66
+ &:hover {
67
+ border-color: var(--color-grey-8);
68
+ }
69
+
70
+ &:focus-within {
71
+ border-color: var(--color-primary-blue-2);
72
+ }
73
+
74
+ ${({ $successful }) => $successful ? 'border-color: var(--color-green-3) !important;' : ''}
75
+ ${({ $warning }) => $warning ? 'border-color: var(--color-red-4) !important;' : ''}
76
+ `;
77
+ const TextAreaElement = styled.textarea `
78
+ padding: 0px;
79
+ flex: 1;
80
+ font-family: var(--font-inter);
81
+ font-size: 16px;
82
+ line-height: 24px;
83
+ color: var(--color-grey-3);
84
+ border: none;
85
+ outline: none;
86
+ border-radius: 8px;
87
+ background-color: transparent;
88
+
89
+ &::placeholder {
90
+ color: var(--color-grey-6);
91
+ }
92
+
93
+ ${({ $resize }) => ($resize ? '' : 'resize: none;')}
94
+ `;
95
+ const HelperText = styled.p `
96
+ color: var(--color-grey-4);
97
+ font-family: var(--font-inter);
98
+ font-size: 14px;
99
+ line-height: 20px;
100
+ `;
101
+ const MaxCharactersText = styled.p `
102
+ text-align: right;
103
+ color: var(--color-grey-6);
104
+ font-family: var(--font-inter);
105
+ font-size: 14px;
106
+ font-style: normal;
107
+ font-weight: 400;
108
+ line-height: 20px;
109
+ `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "0.2.68",
3
+ "version": "0.2.70",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {