@soul-refiner/design-system 0.1.26 → 0.1.27

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,142 @@
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) => {
11
15
  return (
12
- <P {...attributes} {...nodeProps}>
13
- {children}
14
- </P>
16
+ <PlateElement asChild ref={ref} {...props}>
17
+ <>
18
+ <P as="div">{children}</P>
19
+ </>
20
+ </PlateElement>
15
21
  );
16
- };
22
+ });
17
23
 
18
24
  export const createParagraphPlugin = createPluginFactory({
19
25
  key: Elements.ELEMENT_PARAGRAPH,
20
26
  type: Elements.ELEMENT_PARAGRAPH,
21
27
  isElement: true,
22
- component: ParagraphElement,
23
28
  });
24
29
 
25
- const HOneElement = ({
26
- attributes,
27
- nodeProps,
28
- children,
29
- }: PlateRenderElementProps) => {
30
+ export const HOneElement = React.forwardRef<
31
+ React.ElementRef<typeof PlateElement>,
32
+ PlateElementProps
33
+ >(({ children, ...props }: PlateRenderElementProps, ref) => {
30
34
  return (
31
- <H.One {...attributes} {...nodeProps}>
32
- {children}
33
- </H.One>
35
+ <PlateElement asChild ref={ref} {...props}>
36
+ <>
37
+ <H.One>{children}</H.One>
38
+ </>
39
+ </PlateElement>
34
40
  );
35
- };
41
+ });
36
42
 
37
43
  export const createHOnePlugin = createPluginFactory({
38
44
  key: Elements.ELEMENT_H1,
39
45
  type: Elements.ELEMENT_H1,
40
46
  isElement: true,
41
- component: HOneElement,
42
47
  });
43
48
 
44
- const HTwoElement = ({
45
- attributes,
46
- nodeProps,
47
- children,
48
- }: PlateRenderElementProps) => {
49
+ export const HTwoElement = React.forwardRef<
50
+ React.ElementRef<typeof PlateElement>,
51
+ PlateElementProps
52
+ >(({ children, ...props }: PlateRenderElementProps, ref) => {
49
53
  return (
50
- <H.Two {...attributes} {...nodeProps}>
51
- {children}
52
- </H.Two>
54
+ <PlateElement asChild ref={ref} {...props}>
55
+ <>
56
+ <H.Two>{children}</H.Two>
57
+ </>
58
+ </PlateElement>
53
59
  );
54
- };
60
+ });
55
61
 
56
62
  export const createHTwoPlugin = createPluginFactory({
57
63
  key: Elements.ELEMENT_H2,
58
64
  type: Elements.ELEMENT_H2,
59
65
  isElement: true,
60
- component: HTwoElement,
61
66
  });
62
67
 
63
- const HThreeElement = ({
64
- attributes,
65
- nodeProps,
66
- children,
67
- }: PlateRenderElementProps) => {
68
+ export const HThreeElement = React.forwardRef<
69
+ React.ElementRef<typeof PlateElement>,
70
+ PlateElementProps
71
+ >(({ children, ...props }: PlateRenderElementProps, ref) => {
68
72
  return (
69
- <H.Three {...attributes} {...nodeProps}>
70
- {children}
71
- </H.Three>
73
+ <PlateElement asChild ref={ref} {...props}>
74
+ <>
75
+ <H.Three>{children}</H.Three>
76
+ </>
77
+ </PlateElement>
72
78
  );
73
- };
79
+ });
74
80
 
75
81
  export const createHThreePlugin = createPluginFactory({
76
82
  key: Elements.ELEMENT_H3,
77
83
  type: Elements.ELEMENT_H3,
78
84
  isElement: true,
79
- component: HThreeElement,
80
85
  });
81
86
 
82
- const HFourElement = ({
83
- attributes,
84
- nodeProps,
85
- children,
86
- }: PlateRenderElementProps) => {
87
+ export const HFourElement = React.forwardRef<
88
+ React.ElementRef<typeof PlateElement>,
89
+ PlateElementProps
90
+ >(({ children, ...props }: PlateRenderElementProps, ref) => {
87
91
  return (
88
- <H.Four {...attributes} {...nodeProps}>
89
- {children}
90
- </H.Four>
92
+ <PlateElement asChild ref={ref} {...props}>
93
+ <>
94
+ <H.Four>{children}</H.Four>
95
+ </>
96
+ </PlateElement>
91
97
  );
92
- };
98
+ });
93
99
 
94
100
  export const createHFourPlugin = createPluginFactory({
95
101
  key: Elements.ELEMENT_H4,
96
102
  type: Elements.ELEMENT_H4,
97
103
  isElement: true,
98
- component: HFourElement,
99
104
  });
100
105
 
101
- const HFiveElement = ({
102
- attributes,
103
- nodeProps,
104
- children,
105
- }: PlateRenderElementProps) => {
106
+ export const HFiveElement = React.forwardRef<
107
+ React.ElementRef<typeof PlateElement>,
108
+ PlateElementProps
109
+ >(({ children, ...props }: PlateRenderElementProps, ref) => {
106
110
  return (
107
- <H.Five {...attributes} {...nodeProps}>
108
- {children}
109
- </H.Five>
111
+ <PlateElement asChild ref={ref} {...props}>
112
+ <>
113
+ <H.Five>{children}</H.Five>
114
+ </>
115
+ </PlateElement>
110
116
  );
111
- };
117
+ });
112
118
 
113
119
  export const createHFivePlugin = createPluginFactory({
114
120
  key: Elements.ELEMENT_H5,
115
121
  type: Elements.ELEMENT_H5,
116
122
  isElement: true,
117
- component: HFiveElement,
118
123
  });
119
124
 
120
- const HSixElement = ({
121
- attributes,
122
- nodeProps,
123
- children,
124
- }: PlateRenderElementProps) => {
125
+ export const HSixElement = React.forwardRef<
126
+ React.ElementRef<typeof PlateElement>,
127
+ PlateElementProps
128
+ >(({ children, ...props }: PlateRenderElementProps, ref) => {
125
129
  return (
126
- <H.Six {...attributes} {...nodeProps}>
127
- {children}
128
- </H.Six>
130
+ <PlateElement asChild ref={ref} {...props}>
131
+ <>
132
+ <H.Six>{children}</H.Six>
133
+ </>
134
+ </PlateElement>
129
135
  );
130
- };
136
+ });
131
137
 
132
138
  export const createHSixPlugin = createPluginFactory({
133
139
  key: Elements.ELEMENT_H6,
134
140
  type: Elements.ELEMENT_H6,
135
141
  isElement: true,
136
- component: HSixElement,
137
142
  });
@@ -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
  }