@pushwoosh/smart-components-kit 1.0.15 → 1.0.16

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.
@@ -3,6 +3,7 @@ import { type DynamicContent } from '@pushwoosh/dumb-components/RichMessageEdito
3
3
  type DynamicContentFormProps = {
4
4
  dc?: DynamicContent;
5
5
  onChange: (dc: DynamicContent) => void;
6
+ update?: () => void;
6
7
  };
7
8
  export declare const DynamicContentPicker: FC<PropsWithChildren<DynamicContentFormProps>>;
8
9
  export {};
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import { FieldBox, NativeInput, NativeSelect, Spinner } from '@pushwoosh/dumb-components';
1
+ import React, { useEffect } from 'react';
2
+ import { FieldBox, NativeInput, Select, Spinner } from '@pushwoosh/dumb-components';
3
3
  import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
4
4
  import { useDynamicContentTags } from './hooks';
5
5
  import { TagPickerDiv } from './styled';
@@ -11,9 +11,15 @@ const defaultDynamicContent = {
11
11
  export const DynamicContentPicker = ({
12
12
  dc = defaultDynamicContent,
13
13
  onChange,
14
+ update,
14
15
  children
15
16
  }) => {
16
17
  const asyncResult = useDynamicContentTags();
18
+ useEffect(() => {
19
+ if (!asyncResult.loading) {
20
+ update === null || update === void 0 || update();
21
+ }
22
+ }, [asyncResult.loading, update]);
17
23
  if (asyncResult.loading) {
18
24
  return React.createElement(TagPickerDiv, null, React.createElement(Horizontal, {
19
25
  "$placeItems": "center",
@@ -31,33 +37,43 @@ export const DynamicContentPicker = ({
31
37
  title: "Tag"
32
38
  }, React.createElement(Vertical, {
33
39
  "$gap": 8
34
- }, React.createElement(NativeSelect, {
35
- value: dc.tagName,
36
- onChange: e => {
40
+ }, React.createElement(Select, {
41
+ width: "auto",
42
+ menuPlacement: "auto",
43
+ value: {
44
+ value: dc.tagName,
45
+ label: dc.tagName
46
+ },
47
+ onChange: option => {
37
48
  onChange({
38
- tagName: e.target.value,
49
+ tagName: option.value,
39
50
  modifier: currentTag.modifiers[0],
40
51
  defaultValue: ''
41
52
  });
42
- }
43
- }, !currentTag.name && React.createElement("option", {
44
- value: ""
45
- }, "Select tag"), tags.map(tag => React.createElement("option", {
46
- value: tag.name,
47
- key: tag.name
48
- }, tag.name))), React.createElement(NativeSelect, {
49
- value: dc.modifier,
50
- onChange: e => {
53
+ },
54
+ options: tags.map(tag => ({
55
+ value: tag.name,
56
+ label: tag.name
57
+ }))
58
+ }), React.createElement(Select, {
59
+ width: "auto",
60
+ menuPlacement: "auto",
61
+ value: {
62
+ value: dc.modifier,
63
+ label: dc.modifier
64
+ },
65
+ onChange: option => {
51
66
  onChange({
52
67
  ...dc,
53
- modifier: e.target.value
68
+ modifier: option.value
54
69
  });
55
70
  },
56
- disabled: !currentTag.name
57
- }, currentTag.modifiers.map(modifier => React.createElement("option", {
58
- value: modifier,
59
- key: modifier
60
- }, modifier))))), React.createElement(FieldBox, {
71
+ options: currentTag.modifiers.map(modifier => ({
72
+ value: modifier,
73
+ label: modifier
74
+ })),
75
+ isDisabled: !currentTag.name
76
+ }))), React.createElement(FieldBox, {
61
77
  title: "Default Tag Value"
62
78
  }, React.createElement(NativeInput, {
63
79
  value: dc.defaultValue,
@@ -1,5 +1,8 @@
1
1
  import { type FC } from 'react';
2
2
  import { type DynamicContent } from '@pushwoosh/dumb-components/RichMessageEditor/slate/types';
3
- export declare const NewDynamicContentForm: FC<{
3
+ type NewDynamicContentFormProps = {
4
+ update?: () => void;
4
5
  onSubmit: (dc: DynamicContent) => void;
5
- }>;
6
+ };
7
+ export declare const NewDynamicContentForm: FC<NewDynamicContentFormProps>;
8
+ export {};
@@ -3,12 +3,14 @@ import { Button } from '@pushwoosh/dumb-components';
3
3
  import { Horizontal } from '@pushwoosh/kit-helpers';
4
4
  import { DynamicContentPicker } from '../DynamicContentPicker';
5
5
  export const NewDynamicContentForm = ({
6
+ update,
6
7
  onSubmit
7
8
  }) => {
8
9
  const [dc, setDc] = useState();
9
10
  return React.createElement(DynamicContentPicker, {
10
11
  dc: dc,
11
- onChange: setDc
12
+ onChange: setDc,
13
+ update: update
12
14
  }, React.createElement(Horizontal, {
13
15
  "$justifyContent": "end"
14
16
  }, React.createElement(Button, {
@@ -7,11 +7,14 @@ export const RichMessageEditorSmart = props => {
7
7
  ...props,
8
8
  renderDynamicContent: ({
9
9
  dc,
10
- onChange
10
+ onChange,
11
+ update
11
12
  }) => dc ? React.createElement(DynamicContentPicker, {
12
13
  dc: dc,
13
- onChange: onChange
14
+ onChange: onChange,
15
+ update: update
14
16
  }) : React.createElement(NewDynamicContentForm, {
17
+ update: update,
15
18
  onSubmit: onChange
16
19
  })
17
20
  });
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.56",
20
+ "@pushwoosh/dumb-components": "^1.0.64",
21
21
  "@pushwoosh/kit-constants": "^1.6.9",
22
22
  "@pushwoosh/kit-helpers": "^4.8.1",
23
23
  "@pushwoosh/kit-icons": "^2.1.2",
@@ -26,7 +26,7 @@
26
26
  "devDependencies": {
27
27
  "@pushwoosh/frontend-builder-engine": "^1.0.17",
28
28
  "@pushwoosh/grpc-bridge": "^1.5.36",
29
- "@pushwoosh/http-client": "^2.4.12",
29
+ "@pushwoosh/http-client": "^2.5.0",
30
30
  "@pushwoosh/session-store": "^2.5.0",
31
31
  "@types/react": "^18.3.5",
32
32
  "@types/react-dom": "^18.3.0",
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@pushwoosh/grpc-bridge": "^1.5.36",
43
- "@pushwoosh/http-client": "^2.4.12",
43
+ "@pushwoosh/http-client": "^2.5.0",
44
44
  "@pushwoosh/rpc-v2-http-api-data": "^0.1.466",
45
45
  "@pushwoosh/session-store": "^2.5.0",
46
46
  "react": "^16.14.0 || ^18.0.0",
@@ -49,5 +49,5 @@
49
49
  "engines": {
50
50
  "node": ">= 18"
51
51
  },
52
- "version": "1.0.15"
52
+ "version": "1.0.16"
53
53
  }