@pushwoosh/smart-components-kit 1.0.12 → 1.0.13

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.
@@ -0,0 +1,5 @@
1
+ import { type FC } from 'react';
2
+ import { type DynamicContent } from '@pushwoosh/dumb-components/RichMessageEditor/slate/types';
3
+ export declare const NewDynamicContentForm: FC<{
4
+ onSubmit: (dc: DynamicContent) => void;
5
+ }>;
@@ -0,0 +1,19 @@
1
+ import React, { useState } from 'react';
2
+ import { Button } from '@pushwoosh/dumb-components';
3
+ import { Horizontal } from '@pushwoosh/kit-helpers';
4
+ import { DynamicContentPicker } from '../DynamicContentPicker';
5
+ export const NewDynamicContentForm = ({
6
+ onSubmit
7
+ }) => {
8
+ const [dc, setDc] = useState();
9
+ return React.createElement(DynamicContentPicker, {
10
+ dc: dc,
11
+ onChange: setDc
12
+ }, React.createElement(Horizontal, {
13
+ "$justifyContent": "end"
14
+ }, React.createElement(Button, {
15
+ color: "secondary",
16
+ onClick: () => onSubmit(dc),
17
+ isDisabled: !dc
18
+ }, "Insert")));
19
+ };
@@ -1,15 +1,18 @@
1
1
  import React from 'react';
2
2
  import { RichMessageEditor } from '@pushwoosh/dumb-components';
3
3
  import { DynamicContentPicker } from '../DynamicContentPicker';
4
+ import { NewDynamicContentForm } from './NewDynamicContentForm';
4
5
  export const RichMessageEditorSmart = props => {
5
6
  return React.createElement(RichMessageEditor, {
6
7
  ...props,
7
8
  renderDynamicContent: ({
8
9
  dc,
9
10
  onChange
10
- }) => React.createElement(DynamicContentPicker, {
11
+ }) => dc ? React.createElement(DynamicContentPicker, {
11
12
  dc: dc,
12
13
  onChange: onChange
14
+ }) : React.createElement(NewDynamicContentForm, {
15
+ onSubmit: onChange
13
16
  })
14
17
  });
15
18
  };
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "pre-commit": "check",
18
18
  "dependencies": {
19
19
  "@emoji-mart/react": "^1.1.1",
20
- "@pushwoosh/dumb-components": "^1.0.49",
20
+ "@pushwoosh/dumb-components": "^1.0.56",
21
21
  "@pushwoosh/kit-constants": "^1.6.9",
22
22
  "@pushwoosh/kit-helpers": "^4.8.1",
23
23
  "@pushwoosh/kit-icons": "^2.1.2",
@@ -49,5 +49,5 @@
49
49
  "engines": {
50
50
  "node": ">= 18"
51
51
  },
52
- "version": "1.0.12"
52
+ "version": "1.0.13"
53
53
  }