@soul-refiner/design-system 0.1.26 → 0.1.28

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.
@@ -1,137 +1,151 @@
1
1
  import React from 'react';
2
- import { PlateRenderElementProps, createPluginFactory } from '@udecode/plate';
2
+ import {
3
+ createPluginFactory,
4
+ PlateElement,
5
+ PlateElementProps,
6
+ PlateRenderElementProps,
7
+ } from '@udecode/plate';
3
8
  import { H, P } from 'components';
4
9
  import * as Elements from '../constants';
5
10
 
6
- const ParagraphElement = ({
7
- attributes,
8
- nodeProps,
9
- children,
10
- }: PlateRenderElementProps) => {
11
+ export const ParagraphElement = React.forwardRef<
12
+ React.ElementRef<typeof PlateElement>,
13
+ PlateElementProps
14
+ >(({ children, ...props }: PlateRenderElementProps, ref) => {
15
+ const textAlign = (props as any)?.style?.textAlign;
11
16
  return (
12
- <P {...attributes} {...nodeProps}>
13
- {children}
14
- </P>
17
+ <PlateElement asChild ref={ref} {...props}>
18
+ <>
19
+ <P as="div" $textAlign={textAlign}>
20
+ {children}
21
+ </P>
22
+ </>
23
+ </PlateElement>
15
24
  );
16
- };
25
+ });
17
26
 
18
27
  export const createParagraphPlugin = createPluginFactory({
19
28
  key: Elements.ELEMENT_PARAGRAPH,
20
29
  type: Elements.ELEMENT_PARAGRAPH,
21
30
  isElement: true,
22
- component: ParagraphElement,
23
31
  });
24
32
 
25
- const HOneElement = ({
26
- attributes,
27
- nodeProps,
28
- children,
29
- }: PlateRenderElementProps) => {
33
+ export const HOneElement = React.forwardRef<
34
+ React.ElementRef<typeof PlateElement>,
35
+ PlateElementProps
36
+ >(({ children, ...props }: PlateRenderElementProps, ref) => {
37
+ const textAlign = (props as any)?.style?.textAlign;
30
38
  return (
31
- <H.One {...attributes} {...nodeProps}>
32
- {children}
33
- </H.One>
39
+ <PlateElement asChild ref={ref} {...props}>
40
+ <>
41
+ <H.One $textAlign={textAlign}>{children}</H.One>
42
+ </>
43
+ </PlateElement>
34
44
  );
35
- };
45
+ });
36
46
 
37
47
  export const createHOnePlugin = createPluginFactory({
38
48
  key: Elements.ELEMENT_H1,
39
49
  type: Elements.ELEMENT_H1,
40
50
  isElement: true,
41
- component: HOneElement,
42
51
  });
43
52
 
44
- const HTwoElement = ({
45
- attributes,
46
- nodeProps,
47
- children,
48
- }: PlateRenderElementProps) => {
53
+ export const HTwoElement = React.forwardRef<
54
+ React.ElementRef<typeof PlateElement>,
55
+ PlateElementProps
56
+ >(({ children, ...props }: PlateRenderElementProps, ref) => {
57
+ const textAlign = (props as any)?.style?.textAlign;
49
58
  return (
50
- <H.Two {...attributes} {...nodeProps}>
51
- {children}
52
- </H.Two>
59
+ <PlateElement asChild ref={ref} {...props}>
60
+ <>
61
+ <H.Two $textAlign={textAlign}>{children}</H.Two>
62
+ </>
63
+ </PlateElement>
53
64
  );
54
- };
65
+ });
55
66
 
56
67
  export const createHTwoPlugin = createPluginFactory({
57
68
  key: Elements.ELEMENT_H2,
58
69
  type: Elements.ELEMENT_H2,
59
70
  isElement: true,
60
- component: HTwoElement,
61
71
  });
62
72
 
63
- const HThreeElement = ({
64
- attributes,
65
- nodeProps,
66
- children,
67
- }: PlateRenderElementProps) => {
73
+ export const HThreeElement = React.forwardRef<
74
+ React.ElementRef<typeof PlateElement>,
75
+ PlateElementProps
76
+ >(({ children, ...props }: PlateRenderElementProps, ref) => {
77
+ const textAlign = (props as any)?.style?.textAlign;
68
78
  return (
69
- <H.Three {...attributes} {...nodeProps}>
70
- {children}
71
- </H.Three>
79
+ <PlateElement asChild ref={ref} {...props}>
80
+ <>
81
+ <H.Three $textAlign={textAlign}>{children}</H.Three>
82
+ </>
83
+ </PlateElement>
72
84
  );
73
- };
85
+ });
74
86
 
75
87
  export const createHThreePlugin = createPluginFactory({
76
88
  key: Elements.ELEMENT_H3,
77
89
  type: Elements.ELEMENT_H3,
78
90
  isElement: true,
79
- component: HThreeElement,
80
91
  });
81
92
 
82
- const HFourElement = ({
83
- attributes,
84
- nodeProps,
85
- children,
86
- }: PlateRenderElementProps) => {
93
+ export const HFourElement = React.forwardRef<
94
+ React.ElementRef<typeof PlateElement>,
95
+ PlateElementProps
96
+ >(({ children, ...props }: PlateRenderElementProps, ref) => {
97
+ const textAlign = (props as any)?.style?.textAlign;
87
98
  return (
88
- <H.Four {...attributes} {...nodeProps}>
89
- {children}
90
- </H.Four>
99
+ <PlateElement asChild ref={ref} {...props}>
100
+ <>
101
+ <H.Four $textAlign={textAlign}>{children}</H.Four>
102
+ </>
103
+ </PlateElement>
91
104
  );
92
- };
105
+ });
93
106
 
94
107
  export const createHFourPlugin = createPluginFactory({
95
108
  key: Elements.ELEMENT_H4,
96
109
  type: Elements.ELEMENT_H4,
97
110
  isElement: true,
98
- component: HFourElement,
99
111
  });
100
112
 
101
- const HFiveElement = ({
102
- attributes,
103
- nodeProps,
104
- children,
105
- }: PlateRenderElementProps) => {
113
+ export const HFiveElement = React.forwardRef<
114
+ React.ElementRef<typeof PlateElement>,
115
+ PlateElementProps
116
+ >(({ children, ...props }: PlateRenderElementProps, ref) => {
117
+ const textAlign = (props as any)?.style?.textAlign;
106
118
  return (
107
- <H.Five {...attributes} {...nodeProps}>
108
- {children}
109
- </H.Five>
119
+ <PlateElement asChild ref={ref} {...props}>
120
+ <>
121
+ <H.Five $textAlign={textAlign}>{children}</H.Five>
122
+ </>
123
+ </PlateElement>
110
124
  );
111
- };
125
+ });
112
126
 
113
127
  export const createHFivePlugin = createPluginFactory({
114
128
  key: Elements.ELEMENT_H5,
115
129
  type: Elements.ELEMENT_H5,
116
130
  isElement: true,
117
- component: HFiveElement,
118
131
  });
119
132
 
120
- const HSixElement = ({
121
- attributes,
122
- nodeProps,
123
- children,
124
- }: PlateRenderElementProps) => {
133
+ export const HSixElement = React.forwardRef<
134
+ React.ElementRef<typeof PlateElement>,
135
+ PlateElementProps
136
+ >(({ children, ...props }: PlateRenderElementProps, ref) => {
137
+ const textAlign = (props as any)?.style?.textAlign;
125
138
  return (
126
- <H.Six {...attributes} {...nodeProps}>
127
- {children}
128
- </H.Six>
139
+ <PlateElement asChild ref={ref} {...props}>
140
+ <>
141
+ <H.Six $textAlign={textAlign}>{children}</H.Six>
142
+ </>
143
+ </PlateElement>
129
144
  );
130
- };
145
+ });
131
146
 
132
147
  export const createHSixPlugin = createPluginFactory({
133
148
  key: Elements.ELEMENT_H6,
134
149
  type: Elements.ELEMENT_H6,
135
150
  isElement: true,
136
- component: HSixElement,
137
151
  });
@@ -18,7 +18,7 @@ export interface RadioProps extends NativeProps {
18
18
  checked: boolean;
19
19
  disabled?: boolean;
20
20
  label?: string;
21
- onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
21
+ onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
22
22
  name?: string;
23
23
  reversed?: boolean;
24
24
  sx?: string;
@@ -37,7 +37,7 @@ const Radio = ({
37
37
  }: RadioProps) => {
38
38
  const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
39
39
  event.stopPropagation();
40
- onChange(event);
40
+ onChange && onChange(event);
41
41
  };
42
42
 
43
43
  return (
@@ -47,6 +47,7 @@ Modal.Trigger = ModalTrigger;
47
47
 
48
48
  const ModalDismiss = ({
49
49
  children: child,
50
+
50
51
  setClosed,
51
52
  }: {
52
53
  children: React.ReactElement;
@@ -73,6 +74,7 @@ export interface ModalContentProps extends React.PropsWithChildren {
73
74
  footer?: React.ReactElement;
74
75
  header?: React.ReactElement;
75
76
  setClosed?: () => void;
77
+ sx?: string;
76
78
  }
77
79
 
78
80
  const ModalContent = ({
@@ -81,6 +83,7 @@ const ModalContent = ({
81
83
  footer,
82
84
  header,
83
85
  setClosed,
86
+ sx,
84
87
  ...props
85
88
  }: ModalContentProps) => {
86
89
  const [open, setOpen] = React.useContext(ModalContext);
@@ -96,7 +99,7 @@ const ModalContent = ({
96
99
  $open={open}
97
100
  onClick={handleOutsideClick}
98
101
  >
99
- <Content {...props}>
102
+ <Content {...props} $sx={sx}>
100
103
  {header && (
101
104
  <div className="header">
102
105
  <div>{header}</div>
@@ -144,7 +147,7 @@ const Wrapper = styled.div<{
144
147
  overflow: hidden;
145
148
  `;
146
149
 
147
- const Content = styled.div`
150
+ const Content = styled.div<{ $sx?: string }>`
148
151
  position: absolute;
149
152
  z-index: 101;
150
153
  background-color: var(--color-white);
@@ -169,4 +172,5 @@ const Content = styled.div`
169
172
  position: relative;
170
173
  padding-top: 16px;
171
174
  }
175
+ ${({ $sx }) => ($sx ? $sx : '')}
172
176
  `;
@@ -7,7 +7,7 @@ export const AlignJustified = (props: IconProps) => {
7
7
  <path
8
8
  fillRule="evenodd"
9
9
  clipRule="evenodd"
10
- d="M14.6673 4.66671V3.33337H1.33398V4.66671H14.6673ZM12.6673 6.00004V7.33337H3.33398V6.00004H12.6673ZM14.6673 10V8.66671H1.33398V10H14.6673ZM12.6673 12.6667V11.3334H3.33398V12.6667H12.6673Z"
10
+ d="M14.6673 4.66671V3.33337H1.33398V4.66671H14.6673ZM14.6673 6.00004V7.33337H1.33398V6.00004H14.6673ZM14.6673 10V8.66671H1.33398V10H14.6673ZM14.6673 12.6667V11.3334H1.33398V12.6667H14.6673Z"
11
11
  />
12
12
  </Icon>
13
13
  );
package/tsconfig.json CHANGED
@@ -22,6 +22,6 @@
22
22
  "types/*": ["./src/types/*"]
23
23
  }
24
24
  },
25
- "include": ["src/**/*.tsx", "src/**/*.ts", "src/icons/home.tsx"],
25
+ "include": ["src/**/*.tsx", "src/**/*.ts"],
26
26
  "exclude": ["node_modules"]
27
27
  }