@pushwoosh/dumb-components 1.1.1 → 1.1.3

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,5 +1,6 @@
1
1
  import styled from 'styled-components';
2
+ import { Color, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
2
3
  export const EmojiPickerStyled = styled.div.withConfig({
3
4
  displayName: "EmojiPickerStyled",
4
5
  componentId: "sc-1bxjwgk-0"
5
- })(["min-width:352px;"]);
6
+ })(["min-width:352px;em-emoji-picker{border:1px solid ", ";--border-radius:", ";--shadow:", ";background-color:", ";--rgb-background:", ";}"], Color.FORM, ShapeRadius.CONTROL, Shadow.REGULAR, Color.FROZEN, Color.FROZEN);
@@ -0,0 +1,3 @@
1
+ import { type Placement } from '@floating-ui/react-dom';
2
+ import { type ArrowDirection } from './RichMessageEditor.types';
3
+ export declare function placementToDirection(placement: Placement): ArrowDirection;
@@ -0,0 +1,12 @@
1
+ export function placementToDirection(placement) {
2
+ if (placement.startsWith('left')) {
3
+ return 'right';
4
+ }
5
+ if (placement.startsWith('right')) {
6
+ return 'left';
7
+ }
8
+ if (placement.startsWith('top')) {
9
+ return 'bottom';
10
+ }
11
+ return 'top';
12
+ }
@@ -1,13 +1,15 @@
1
- import { autoPlacement, offset, useFloating } from '@floating-ui/react-dom';
1
+ import { arrow, autoPlacement, offset, useFloating } from '@floating-ui/react-dom';
2
2
  import { isEqual } from 'es-toolkit';
3
- import React, { useEffect, useState } from 'react';
3
+ import React, { useEffect, useRef, useState } from 'react';
4
4
  import { Transforms } from 'slate';
5
5
  import { Collapse, elementAddListener, Horizontal, usePersistentFunction } from '@pushwoosh/kit-helpers';
6
6
  import { FieldBox } from '../FieldBox';
7
+ import ArrowIcon from './assets/arrow.svg';
7
8
  import EmojiIcon from './assets/EmojiIcon.svg';
8
9
  import PersonalizationIcon from './assets/PersonalizationIcon.svg';
9
10
  import { EmojiPicker } from './EmojiPicker';
10
- import { DropArea, ImSpan } from './RichMessageEditor.styled';
11
+ import { placementToDirection } from './RichMessageEditor.helpers';
12
+ import { Arrow, DropArea, DropContent, ImSpan } from './RichMessageEditor.styled';
11
13
  import { getDcByPath } from './slate/helpers';
12
14
  import { SlateEditable, SlateEditor } from './slate/SlateEditor';
13
15
  export const RichMessageEditor = ({
@@ -23,14 +25,19 @@ export const RichMessageEditor = ({
23
25
  }) => {
24
26
  const [showDrop, setShowDrop] = useState();
25
27
  const [isFocused, setIsFocused] = useState(false);
28
+ const arrowRef = useRef(null);
26
29
  const {
27
30
  refs,
28
31
  floatingStyles,
29
- update
32
+ update,
33
+ middlewareData,
34
+ placement
30
35
  } = useFloating({
31
36
  strategy: 'fixed',
32
37
  middleware: [offset(8), autoPlacement({
33
38
  allowedPlacements: ['right', 'right-start', 'right-end', 'left', 'left-start', 'left-end']
39
+ }), arrow({
40
+ element: arrowRef
34
41
  })]
35
42
  });
36
43
  const onSelectionChange = selection => {
@@ -82,7 +89,7 @@ export const RichMessageEditor = ({
82
89
  }, ({
83
90
  editor
84
91
  }) => {
85
- var _getDcByPath;
92
+ var _getDcByPath, _middlewareData$arrow, _middlewareData$arrow2;
86
93
  return React.createElement(FieldBox, {
87
94
  title: title,
88
95
  boxRef: refs.setReference,
@@ -118,7 +125,7 @@ export const RichMessageEditor = ({
118
125
  style: floatingStyles,
119
126
  ref: refs.setFloating,
120
127
  key: showDrop.type
121
- }, showDrop.type === 'personalization' && (renderDynamicContent === null || renderDynamicContent === void 0 ? void 0 : renderDynamicContent({
128
+ }, showDrop.type === 'personalization' && React.createElement(DropContent, null, renderDynamicContent === null || renderDynamicContent === void 0 ? void 0 : renderDynamicContent({
122
129
  dc: showDrop.path ? (_getDcByPath = getDcByPath(editor.children, showDrop.path)) === null || _getDcByPath === void 0 ? void 0 : _getDcByPath.dc : undefined,
123
130
  onChange: newDC => {
124
131
  if (showDrop.path) {
@@ -134,6 +141,13 @@ export const RichMessageEditor = ({
134
141
  update
135
142
  })), showDrop.type === 'emoji' && React.createElement(EmojiPicker, {
136
143
  onEmojiSelect: s => editor.insertText(s)
137
- })));
144
+ }), React.createElement(Arrow, {
145
+ "$direction": placementToDirection(placement),
146
+ ref: arrowRef,
147
+ style: {
148
+ left: (_middlewareData$arrow = middlewareData.arrow) === null || _middlewareData$arrow === void 0 ? void 0 : _middlewareData$arrow.x,
149
+ top: (_middlewareData$arrow2 = middlewareData.arrow) === null || _middlewareData$arrow2 === void 0 ? void 0 : _middlewareData$arrow2.y
150
+ }
151
+ }, React.createElement(ArrowIcon, null))));
138
152
  });
139
153
  };
@@ -1,2 +1,64 @@
1
+ import { type ArrowDirection } from './RichMessageEditor.types';
1
2
  export declare const ImSpan: import("styled-components").StyledComponent<"span", any, {}, never>;
2
3
  export declare const DropArea: import("styled-components").StyledComponent<"div", any, {}, never>;
4
+ export declare const DropContent: import("styled-components").StyledComponent<"div", any, {}, never>;
5
+ export declare const Arrow: import("styled-components").StyledComponent<"div", any, {
6
+ $alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
7
+ $alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
8
+ $bgColor?: string | undefined;
9
+ $border?: string | ({
10
+ top?: string | undefined;
11
+ right?: string | undefined;
12
+ bottom?: string | undefined;
13
+ left?: string | undefined;
14
+ } | {
15
+ horizontal: string;
16
+ top?: string | undefined;
17
+ bottom?: string | undefined;
18
+ } | {
19
+ vertical: string;
20
+ right?: string | undefined;
21
+ left?: string | undefined;
22
+ }) | undefined;
23
+ $borderRadius?: (string | number) | undefined;
24
+ $boxShadow?: string | undefined;
25
+ $gap?: (string | number) | undefined;
26
+ $gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
27
+ $justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
28
+ $justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
29
+ $margin?: (string | number) | ({
30
+ top?: (string | number) | undefined;
31
+ right?: (string | number) | undefined;
32
+ bottom?: (string | number) | undefined;
33
+ left?: (string | number) | undefined;
34
+ } | {
35
+ horizontal: string | number;
36
+ top?: (string | number) | undefined;
37
+ bottom?: (string | number) | undefined;
38
+ } | {
39
+ vertical: string | number;
40
+ right?: (string | number) | undefined;
41
+ left?: (string | number) | undefined;
42
+ }) | undefined;
43
+ $padding?: (string | number) | ({
44
+ top?: (string | number) | undefined;
45
+ right?: (string | number) | undefined;
46
+ bottom?: (string | number) | undefined;
47
+ left?: (string | number) | undefined;
48
+ } | {
49
+ horizontal: string | number;
50
+ top?: (string | number) | undefined;
51
+ bottom?: (string | number) | undefined;
52
+ } | {
53
+ vertical: string | number;
54
+ right?: (string | number) | undefined;
55
+ left?: (string | number) | undefined;
56
+ }) | undefined;
57
+ $placeItems?: "end" | "start" | "center" | "stretch" | undefined;
58
+ } & {
59
+ $gridAutoFlow: string;
60
+ } & {
61
+ $placeItems: string;
62
+ } & {
63
+ $direction: ArrowDirection;
64
+ }, "$gridAutoFlow" | "$placeItems">;
@@ -1,5 +1,6 @@
1
1
  import styled from 'styled-components';
2
- import { Color } from '@pushwoosh/kit-constants';
2
+ import { Color, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
3
+ import { Horizontal } from '@pushwoosh/kit-helpers';
3
4
  export const ImSpan = styled.span.withConfig({
4
5
  displayName: "ImSpan",
5
6
  componentId: "sc-kdvgj9-0"
@@ -7,4 +8,24 @@ export const ImSpan = styled.span.withConfig({
7
8
  export const DropArea = styled.div.withConfig({
8
9
  displayName: "DropArea",
9
10
  componentId: "sc-kdvgj9-1"
10
- })(["z-index:1000;"]);
11
+ })(["z-index:1000;"]);
12
+ export const DropContent = styled.div.withConfig({
13
+ displayName: "DropContent",
14
+ componentId: "sc-kdvgj9-2"
15
+ })(["border:1px solid ", ";border-radius:", ";box-shadow:", ";background-color:", ";"], Color.FORM, ShapeRadius.CONTROL, Shadow.REGULAR, Color.FROZEN);
16
+ const transforms = {
17
+ left: 'scaleX(-1)',
18
+ right: 'scaleX(1)',
19
+ top: 'rotate(-90deg)',
20
+ bottom: 'rotate(90deg)'
21
+ };
22
+ export const Arrow = styled(Horizontal).attrs({
23
+ $placeItems: 'center'
24
+ }).withConfig({
25
+ displayName: "Arrow",
26
+ componentId: "sc-kdvgj9-3"
27
+ })(["position:absolute;width:20px;height:20px;transform:", " translateX(11px);", ":0;"], ({
28
+ $direction
29
+ }) => transforms[$direction], ({
30
+ $direction
31
+ }) => $direction);
@@ -24,3 +24,4 @@ export type RichMessageEditorProps = {
24
24
  onBlur?: () => void;
25
25
  renderDynamicContent?: (props: RenderDynamicContentProps) => ReactNode;
26
26
  };
27
+ export type ArrowDirection = 'top' | 'bottom' | 'left' | 'right';
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="10" height="20" fill="none"><mask id="a" fill="#fff"><path fill-rule="evenodd" d="M0 2a2 2 0 0 1 4 0v1.26a2 2 0 0 0 .598 1.426L8.55 8.574a2 2 0 0 1 0 2.852l-3.953 3.888A2 2 0 0 0 4 16.74V18a2 2 0 1 1-4 0z" clip-rule="evenodd"/></mask><path fill="#F7F9FA" fill-rule="evenodd" d="M0 2a2 2 0 0 1 4 0v1.26a2 2 0 0 0 .598 1.426L8.55 8.574a2 2 0 0 1 0 2.852l-3.953 3.888A2 2 0 0 0 4 16.74V18a2 2 0 1 1-4 0z" clip-rule="evenodd"/><path fill="#DCE1E5" d="m4.598 15.314.7.713zM3 3.26V2h2v1.26zm4.85 6.027L3.896 5.4 5.3 3.973 9.252 7.86zm-3.954 5.314 3.954-3.888 1.402 1.426L5.3 16.027zM3 18v-1.26h2V18zM1 2v16h-2V2zm1 19a3 3 0 0 1-3-3h2a1 1 0 0 0 1 1zm3-3a3 3 0 0 1-3 3v-2a1 1 0 0 0 1-1zm.299-1.973A1 1 0 0 0 5 16.74H3a3 3 0 0 1 .896-2.138L5.3 16.026zm3.953-8.166a3 3 0 0 1 0 4.278L7.85 10.713a1 1 0 0 0 0-1.426zM5 3.26a1 1 0 0 0 .299.713L3.896 5.399A3 3 0 0 1 3 3.259zM2 1a1 1 0 0 0-1 1h-2a3 3 0 0 1 3-3zm0-2a3 3 0 0 1 3 3H3a1 1 0 0 0-1-1z" mask="url(#a)"/><path stroke="#F7F9FA" stroke-width="3" d="M1.5 0v20"/></svg>
@@ -67,7 +67,8 @@ export function DataTable(props) {
67
67
  ...acc,
68
68
  [key]: context.params[key]
69
69
  }), {
70
- page: 1
70
+ page: 1,
71
+ search: ''
71
72
  }));
72
73
  }
73
74
  }, "Clear request")))), renderAfter === null || renderAfter === void 0 ? void 0 : renderAfter(context));
@@ -15,8 +15,11 @@ export function DataTableList({
15
15
  data,
16
16
  params
17
17
  } = useContext(DataTableContext);
18
- if (data.loading || (_data$value = data.value) !== null && _data$value !== void 0 && (_data$value = _data$value.items) !== null && _data$value !== void 0 && _data$value.length) {
19
- return data.value ? React.createElement(React.Fragment, null, data.value.items.map(renderItem)) : React.createElement(Loading, null);
18
+ if (data.loading) {
19
+ return React.createElement(Loading, null);
20
+ }
21
+ if ((_data$value = data.value) !== null && _data$value !== void 0 && (_data$value = _data$value.items) !== null && _data$value !== void 0 && _data$value.length) {
22
+ return React.createElement(React.Fragment, null, data.value.items.map(renderItem));
20
23
  }
21
24
  if (!data.loading && data.error) {
22
25
  return React.createElement(Horizontal, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",