@soul-refiner/design-system 0.2.19 → 0.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/editor/navbar/alignment_dropdown.js +5 -1
- package/dist/components/editor/simple_editor/navbar.js +1 -2
- package/dist/components/feedback/chip/chip.js +1 -1
- package/dist/components/input/text_input/text_input.d.ts +4 -2
- package/dist/components/input/text_input/text_input.js +52 -2
- package/package.json +1 -1
|
@@ -2,7 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { setAlign } from '@udecode/plate';
|
|
3
3
|
import { useAlignDropdownMenu, useAlignDropdownMenuState, } from '@udecode/plate-alignment';
|
|
4
4
|
import { Dropdown } from '../../';
|
|
5
|
-
import {
|
|
5
|
+
import { AlignCenter } from '../../../icons/text/align_center';
|
|
6
|
+
import { AlignJustified } from '../../../icons/text/align_justified';
|
|
7
|
+
import { AlignLeft } from '../../../icons/text/align_left';
|
|
8
|
+
import { AlignRight } from '../../../icons/text/align_right';
|
|
9
|
+
import { PlayerListPlay } from '../../../icons';
|
|
6
10
|
import { MenuButton } from './navbar';
|
|
7
11
|
const items = [
|
|
8
12
|
{
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import { insertImage, useLinkToolbarButton, useLinkToolbarButtonState, useListToolbarButton, useListToolbarButtonState, useMarkToolbarButton, useMarkToolbarButtonState, usePlateEditorRef,
|
|
3
|
+
import { insertImage, useLinkToolbarButton, useLinkToolbarButtonState, useListToolbarButton, useListToolbarButtonState, useMarkToolbarButton, useMarkToolbarButtonState, usePlateEditorRef, } from '@udecode/plate';
|
|
4
4
|
import { Tooltip } from '../../';
|
|
5
5
|
import { Bold, Image, Italic, Link, ListOrdered, ListUnordered, Redo, Underline, Undo, } from '../../../icons';
|
|
6
6
|
import { ELEMENT_OL, ELEMENT_UL, MARK_BOLD, MARK_ITALIC, MARK_UNDERLINE, } from '../constants';
|
|
7
7
|
export const EditorBar = ({ handleUploadImage }) => {
|
|
8
8
|
const editorRef = usePlateEditorRef('main');
|
|
9
|
-
const stateEditor = usePlateEditorState();
|
|
10
9
|
const imageRef = React.useRef(null);
|
|
11
10
|
const boldState = useMarkToolbarButtonState({ nodeType: MARK_BOLD });
|
|
12
11
|
const { props: { pressed: currBold, onClick: handleBold }, } = useMarkToolbarButton(boldState);
|
|
@@ -56,7 +56,7 @@ export const Chip = ({ children, color, dot, onDismiss, size }) => {
|
|
|
56
56
|
return (React.createElement(Component, { "$bgColor": bgColor, "$size": size, "$textColor": textColor },
|
|
57
57
|
dot && React.createElement(Dot, { "$secondaryColor": dotColor }),
|
|
58
58
|
children,
|
|
59
|
-
onDismiss && React.createElement(Close, { size: 16 })));
|
|
59
|
+
onDismiss && React.createElement(Close, { size: 16, onClick: onDismiss })));
|
|
60
60
|
};
|
|
61
61
|
const Component = styled.div `
|
|
62
62
|
display: flex;
|
|
@@ -9,11 +9,13 @@ export type Props = {
|
|
|
9
9
|
helperText?: string;
|
|
10
10
|
label?: string;
|
|
11
11
|
maxCharacters?: number;
|
|
12
|
+
multiple?: boolean;
|
|
12
13
|
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
14
|
+
onMultipleChange?: (values: string[]) => void;
|
|
13
15
|
placeholder?: string;
|
|
14
16
|
size?: TextInputSize;
|
|
15
17
|
sx?: string;
|
|
16
|
-
value: string;
|
|
18
|
+
value: string | string[];
|
|
17
19
|
};
|
|
18
20
|
interface DisabledProps extends Props {
|
|
19
21
|
disabled?: true;
|
|
@@ -31,5 +33,5 @@ interface WarningProps extends Props {
|
|
|
31
33
|
warning?: true;
|
|
32
34
|
}
|
|
33
35
|
export type TextInputProps = DisabledProps | SuccessfulProps | WarningProps;
|
|
34
|
-
export declare const TextInput: ({ bg, disabled, helperText, icon, label, maxCharacters, onChange, placeholder, size, successful, sx, value, warning, }: TextInputProps) => React.JSX.Element;
|
|
36
|
+
export declare const TextInput: ({ bg, disabled, helperText, icon, label, maxCharacters, multiple, onChange, onMultipleChange, placeholder, size, successful, sx, value, warning, }: TextInputProps) => React.JSX.Element;
|
|
35
37
|
export {};
|
|
@@ -1,13 +1,57 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
+
import { Chip } from '../../feedback/chip/chip';
|
|
4
5
|
import { CheckmarkCircle, AlertCircle } from '../../../icons';
|
|
5
|
-
export const TextInput = ({ bg = 'var(--color-blue-10)', disabled, helperText, icon, label, maxCharacters, onChange, placeholder, size = 'large', successful, sx, value, warning, }) => {
|
|
6
|
+
export const TextInput = ({ bg = 'var(--color-blue-10)', disabled, helperText, icon, label, maxCharacters, multiple, onChange, onMultipleChange, placeholder, size = 'large', successful, sx, value, warning, }) => {
|
|
7
|
+
const id = React.useId();
|
|
8
|
+
const isMultiple = multiple;
|
|
9
|
+
const [multipleValueToAdd, setMultipleValueToAdd] = React.useState('');
|
|
10
|
+
/**
|
|
11
|
+
* @todo make multiple wrapper a form
|
|
12
|
+
* on enter set multiple change and clear local value
|
|
13
|
+
* use local value to be text box
|
|
14
|
+
* have text box be flex shrink competing with chips
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
const handleMultipleValueToAdd = (event) => {
|
|
18
|
+
setMultipleValueToAdd(event.target.value);
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* when there is no text in the input,
|
|
22
|
+
* pop the previous multiple value out
|
|
23
|
+
*/
|
|
24
|
+
const handleMultipleValueDelete = (event) => {
|
|
25
|
+
if (value.length &&
|
|
26
|
+
onMultipleChange &&
|
|
27
|
+
!multipleValueToAdd &&
|
|
28
|
+
(event.key === 'Delete' || event.key === 'Backspace')) {
|
|
29
|
+
onMultipleChange(value.slice(0, value.length - 1));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const handleMultipleAdd = (event) => {
|
|
33
|
+
event.stopPropagation();
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
const alreadyHasValue = value.includes(multipleValueToAdd);
|
|
36
|
+
if (onMultipleChange && !alreadyHasValue) {
|
|
37
|
+
onMultipleChange([...value, multipleValueToAdd]);
|
|
38
|
+
}
|
|
39
|
+
setMultipleValueToAdd('');
|
|
40
|
+
};
|
|
41
|
+
const handleMultipleItemRemoval = (removalItem) => {
|
|
42
|
+
onMultipleChange &&
|
|
43
|
+
onMultipleChange(value.filter((item) => item !== removalItem));
|
|
44
|
+
};
|
|
6
45
|
return (React.createElement(Label, { "$disabled": disabled, "$size": size, "$sx": sx },
|
|
7
46
|
label,
|
|
8
47
|
React.createElement(InputWrapper, { "$bg": bg, "$size": size, "$successful": successful, "$warning": warning },
|
|
9
48
|
icon,
|
|
10
|
-
React.createElement(
|
|
49
|
+
isMultiple && (React.createElement(MultipleInputWrapper, { onSubmit: handleMultipleAdd },
|
|
50
|
+
value.filter(Boolean).map((item, index) => (React.createElement(Chip, { key: id + item + index, color: "blue", size: "small", onDismiss: () => handleMultipleItemRemoval(item) }, item))),
|
|
51
|
+
React.createElement(Input, { onChange: handleMultipleValueToAdd, onKeyDown: handleMultipleValueDelete, value: multipleValueToAdd, "$size": size }))),
|
|
52
|
+
!isMultiple && (React.createElement(Input, { disabled: disabled, onChange: onChange, placeholder: placeholder, value: maxCharacters
|
|
53
|
+
? value.slice(0, maxCharacters - 1)
|
|
54
|
+
: value, "$size": size })),
|
|
11
55
|
maxCharacters && (React.createElement(MaxCharactersText, { "$size": size },
|
|
12
56
|
value.length,
|
|
13
57
|
" / ",
|
|
@@ -67,6 +111,7 @@ const Input = styled.input `
|
|
|
67
111
|
font-family: Inter;
|
|
68
112
|
font-size: ${({ $size }) => ($size === 'small' ? 14 : 16)}px;
|
|
69
113
|
line-height: ${({ $size }) => ($size === 'small' ? 20 : 24)}px;
|
|
114
|
+
color: var(--color-grey-3);
|
|
70
115
|
border: none;
|
|
71
116
|
outline: none;
|
|
72
117
|
border-radius: 8px;
|
|
@@ -90,3 +135,8 @@ const MaxCharactersText = styled.span `
|
|
|
90
135
|
font-weight: 400;
|
|
91
136
|
line-height: 20px;
|
|
92
137
|
`;
|
|
138
|
+
const MultipleInputWrapper = styled.form `
|
|
139
|
+
display: flex;
|
|
140
|
+
flex-flow: row wrap;
|
|
141
|
+
gap: 8px 16px;
|
|
142
|
+
`;
|