@soul-refiner/design-system 0.2.44 → 0.2.45

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.
@@ -9,7 +9,7 @@ export interface BoxProps extends BackgroundColor, BorderRadius, Elevation, Flex
9
9
  sx?: string;
10
10
  }
11
11
  export declare const Box: ({ $display, sx, ...args }: BoxProps) => React.JSX.Element;
12
- export declare const Component: import("styled-components").IStyledComponent<"web", "div", BoxProps & {
12
+ export declare const Component: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, BoxProps & {
13
13
  $sx?: string | undefined;
14
- }, never>;
14
+ }>>;
15
15
  export {};
@@ -1,9 +1,7 @@
1
+ /// <reference types="react" />
1
2
  import { Color, Styleable, TextClamp, TypographyStyle, TypographyWeight } from '../../../types';
2
3
  export type TypographyProps = Pick<React.HTMLAttributes<HTMLParagraphElement>, 'children' | 'className' | 'dangerouslySetInnerHTML' | 'id' | 'onBlur' | 'onBlurCapture' | 'onClick' | 'onChange' | 'onCopy' | 'onCut' | 'onKeyDown' | 'onKeyDownCapture' | 'onKeyUp' | 'onKeyUpCapture' | 'onMouseDown' | 'onMouseDownCapture' | 'onMouseEnter' | 'onMouseLeave' | 'onMouseOut' | 'onMouseOver'> & {
3
4
  value?: string;
4
5
  href?: string;
5
6
  } & Color & Styleable & TextClamp & TypographyStyle & TypographyWeight;
6
- export declare const Typography: import("styled-components").IStyledComponent<"web", "p", Pick<import("react").HTMLAttributes<HTMLParagraphElement>, "children" | "onBlur" | "onBlurCapture" | "onClick" | "onChange" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseOut" | "onMouseOver" | "className" | "id" | "dangerouslySetInnerHTML" | "onCopy" | "onCut" | "onKeyDown" | "onKeyDownCapture" | "onKeyUp" | "onKeyUpCapture"> & {
7
- value?: string | undefined;
8
- href?: string | undefined;
9
- } & Color & Styleable & TextClamp & TypographyStyle & TypographyWeight, never>;
7
+ export declare const Typography: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, TypographyProps>>;
@@ -3,6 +3,6 @@ export interface EditorBarProps {
3
3
  handleUploadImage: (files: FileList) => Promise<string>;
4
4
  }
5
5
  export declare const EditorBar: ({ handleUploadImage }: EditorBarProps) => React.JSX.Element;
6
- export declare const MenuButton: import("styled-components").IStyledComponent<"web", "button", {
6
+ export declare const MenuButton: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
7
7
  $active?: boolean | undefined;
8
- }, never>;
8
+ }>>;
@@ -3,6 +3,6 @@ export interface EditorBarProps {
3
3
  handleUploadImage: (files: FileList) => Promise<string>;
4
4
  }
5
5
  export declare const EditorBar: ({ handleUploadImage }: EditorBarProps) => React.JSX.Element;
6
- export declare const MenuButton: import("styled-components").IStyledComponent<"web", "button", {
6
+ export declare const MenuButton: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
7
7
  $active?: boolean | undefined;
8
- }, never>;
8
+ }>>;
@@ -4,12 +4,18 @@ import styled from 'styled-components';
4
4
  import Picker from '@emoji-mart/react';
5
5
  import { Avatar, Box, P, TextInput } from '../../';
6
6
  import { Button } from '../../actions/button';
7
+ import { Portal } from '../portal';
7
8
  import emojis from '../../../emoji/emojis.json';
9
+ import { Styles } from '../../../common';
8
10
  import { ThumbsUp, Comment as CommentIcon } from '../../../icons';
9
11
  import { abbrTimeBeforeDate } from './helpers';
10
- import { Styles } from '../../../common';
11
12
  export const Comment = ({ content, createdDate, hasMoreReplies, id, onComment, onReact, onShowReplies, reactions, replies, userImageUri, userName, userReactions, userProfileUri, }) => {
12
13
  const [showPicker, setShowPicker] = React.useState(false);
14
+ const [pickerTriggerLoc, setPickerTriggerLoc] = React.useState({
15
+ x: 0,
16
+ y: 0,
17
+ });
18
+ const [pickerOrientation, setPickerOrientation] = React.useState('up');
13
19
  const [toggleShowCommentInput, setShowCommentInput] = React.useState(false);
14
20
  const [toggleShowReplies, setShowReplies] = React.useState(false);
15
21
  const [comment, setComment] = React.useState('');
@@ -30,6 +36,8 @@ export const Comment = ({ content, createdDate, hasMoreReplies, id, onComment, o
30
36
  const handlePicker = (event) => {
31
37
  event.stopPropagation();
32
38
  setShowPicker((prev) => !prev);
39
+ setPickerTriggerLoc({ y: event.clientY, x: event.clientX });
40
+ setPickerOrientation(event.clientY > 400 ? 'up' : 'down');
33
41
  };
34
42
  const handlePickerBlur = () => setShowPicker(false);
35
43
  const handleToggleCommentInput = () => setShowCommentInput((prev) => !prev);
@@ -68,8 +76,9 @@ export const Comment = ({ content, createdDate, hasMoreReplies, id, onComment, o
68
76
  React.createElement(P, { "$color": "grey-7" }, "\u2022"),
69
77
  React.createElement(P, { "$color": "grey-4", "$fontSize": 12, "$lineHeight": 24, sx: "flex-shrink: 0;" }, createdTime),
70
78
  React.createElement(Box, { "$display": "flex", "$flow": "row wrap", "$gap": 6, sx: "max-width: calc(100% - 190px); margin-left: auto;" }, reactionElements),
71
- showPicker && (React.createElement(PickerWrapper, null,
72
- React.createElement(Picker, { data: emojis, onEmojiSelect: handleReaction, onClickOutside: handlePickerBlur, maxFrequentRows: 1, navPosition: "none", previewPosition: "none", perLine: 9, theme: "auto" }))))),
79
+ showPicker && (React.createElement(Portal, null,
80
+ React.createElement(PickerWrapper, { "$pickerOrientation": pickerOrientation, "$top": pickerTriggerLoc.y, "$left": pickerTriggerLoc.x },
81
+ React.createElement(Picker, { data: emojis, onEmojiSelect: handleReaction, onClickOutside: handlePickerBlur, maxFrequentRows: 1, navPosition: "none", previewPosition: "none", perLine: 9, theme: "auto" })))))),
73
82
  hasReplies && toggleShowReplies && (React.createElement(RepliesWrapper, null, replyElements)),
74
83
  !toggleShowReplies && !hasMoreReplies && hasReplies && (React.createElement(RepliesWrapper, null,
75
84
  React.createElement(ReplyWrapper, { "$hasLine": false },
@@ -119,6 +128,10 @@ const CommentBox = styled.div `
119
128
  const PickerWrapper = styled.div `
120
129
  position: absolute;
121
130
  z-index: 5;
131
+
132
+ ${({ $pickerOrientation }) => $pickerOrientation === 'up' ? 'transform: translateY(-345px);' : ''}
133
+ top: ${({ $top }) => $top}px;
134
+ left: ${({ $left }) => $left}px;
122
135
  `;
123
136
  const Reaction = styled.div `
124
137
  ${Styles.flex}
@@ -8,5 +8,7 @@ export { Message } from './message';
8
8
  export type { MessageProps } from './message';
9
9
  export { Modal } from './modal';
10
10
  export type { ModalContentProps, ModalProps } from './modal';
11
+ export { Portal } from './portal';
12
+ export type { PortalProps } from './portal';
11
13
  export { Post } from './post';
12
14
  export type { PostProps } from './post';
@@ -3,4 +3,5 @@ export { Comment } from './comment';
3
3
  export { Drawer } from './drawer';
4
4
  export { Message } from './message';
5
5
  export { Modal } from './modal';
6
+ export { Portal } from './portal';
6
7
  export { Post } from './post';
@@ -0,0 +1,2 @@
1
+ export { Portal } from './portal';
2
+ export type { PortalProps } from './portal';
@@ -0,0 +1 @@
1
+ export { Portal } from './portal';
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export interface PortalProps extends React.PropsWithChildren {
3
+ wrapperId?: string;
4
+ }
5
+ export declare const Portal: ({ children, wrapperId, }: PortalProps) => React.ReactPortal | null;
@@ -0,0 +1,26 @@
1
+ 'use client';
2
+ import React from 'react';
3
+ import ReactDOM from 'react-dom';
4
+ export const Portal = ({ children, wrapperId = 'root-portal-wrapper', }) => {
5
+ const [wrapper, setWrapper] = React.useState(null);
6
+ React.useEffect(() => {
7
+ let element = document.getElementById(wrapperId);
8
+ let portalCreated = false;
9
+ if (!element) {
10
+ portalCreated = true;
11
+ element = document.createElement('div');
12
+ element.setAttribute('id', wrapperId);
13
+ document.body.appendChild(element);
14
+ }
15
+ setWrapper(element);
16
+ return () => {
17
+ if (portalCreated && element?.parentNode) {
18
+ element.parentNode.removeChild(element);
19
+ }
20
+ };
21
+ }, [wrapperId]);
22
+ if (!wrapper) {
23
+ return null;
24
+ }
25
+ return ReactDOM.createPortal(children, wrapper);
26
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soul-refiner/design-system",
3
- "version": "0.2.44",
3
+ "version": "0.2.45",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -32,6 +32,7 @@
32
32
  "@storybook/react": "^7.2.1",
33
33
  "@storybook/react-vite": "^7.2.1",
34
34
  "@storybook/testing-library": "^0.2.0",
35
+ "@types/react-dom": "18.2.0",
35
36
  "@types/styled-components": "^5.1.26",
36
37
  "@typescript-eslint/eslint-plugin": "^5.59.5",
37
38
  "@typescript-eslint/parser": "^5.59.5",
@@ -72,5 +73,6 @@
72
73
  "slate-hyperscript": "^0.77.0",
73
74
  "slate-react": "^0.97.1",
74
75
  "styled-components": "^6.0.0-rc.3"
75
- }
76
+ },
77
+ "packageManager": "yarn@3.6.1"
76
78
  }