@pushwoosh/smart-components-kit 1.0.0 → 1.0.2

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,8 +1,5 @@
1
- import { type FC, type PropsWithChildren, type ReactNode } from 'react';
1
+ import { type FC, type PropsWithChildren } from 'react';
2
2
  import type { DynamicContent } from './DynamicContentPicker.types';
3
- export declare const Field: FC<PropsWithChildren<{
4
- title: ReactNode;
5
- }>>;
6
3
  type DynamicContentFormProps = {
7
4
  dc?: DynamicContent;
8
5
  onChange: (dc: DynamicContent) => void;
@@ -1,17 +1,8 @@
1
1
  import React from 'react';
2
- import { NativeInput, NativeSelect } from '@pushwoosh/dumb-components';
2
+ import { FieldBox, NativeInput, NativeSelect, Spinner } from '@pushwoosh/dumb-components';
3
3
  import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
4
- import { Spinner } from '@pushwoosh/kit-spinner';
5
4
  import { useDynamicContentTags } from './hooks';
6
- import { FieldTitle, TagPickerDiv } from './styled';
7
- export const Field = ({
8
- title,
9
- children
10
- }) => {
11
- return React.createElement(Vertical, {
12
- "$gap": 4
13
- }, React.createElement(FieldTitle, null, title), children);
14
- };
5
+ import { TagPickerDiv } from './styled';
15
6
  const defaultDynamicContent = {
16
7
  tagName: '',
17
8
  modifier: 'regular',
@@ -36,7 +27,7 @@ export const DynamicContentPicker = ({
36
27
  name: '',
37
28
  modifiers: ['regular']
38
29
  };
39
- return React.createElement(TagPickerDiv, null, React.createElement(Field, {
30
+ return React.createElement(TagPickerDiv, null, React.createElement(FieldBox, {
40
31
  title: "Tag"
41
32
  }, React.createElement(Vertical, {
42
33
  "$gap": 8
@@ -66,7 +57,7 @@ export const DynamicContentPicker = ({
66
57
  }, currentTag.modifiers.map(modifier => React.createElement("option", {
67
58
  value: modifier,
68
59
  key: modifier
69
- }, modifier))))), React.createElement(Field, {
60
+ }, modifier))))), React.createElement(FieldBox, {
70
61
  title: "Default Tag Value"
71
62
  }, React.createElement(NativeInput, {
72
63
  value: dc.defaultValue,
@@ -1,10 +1,11 @@
1
+ import { DynamicContentModifiers } from '@pushwoosh/kit-constants';
1
2
  import { useAsync } from '@pushwoosh/kit-helpers';
2
3
  import { collectPaginatedData } from '../asyncHelpers';
3
4
  import { useSPAContext } from '../context';
4
5
  const ignoreTagTypes = ['BOOLEAN', 'LIST'];
5
6
  const numberTypes = ['INTEGER', 'PRICE'];
6
7
  export async function fetchDynamicContentTags(context) {
7
- const [originalTags, modifiers] = await Promise.all([collectPaginatedData(1000, async (perPage, page) => {
8
+ const originalTags = await collectPaginatedData(1000, async (perPage, page) => {
8
9
  const res = await context.rpcGateway.tags.List({
9
10
  orderBy: 'NAME',
10
11
  orderDirection: 'ASC',
@@ -12,13 +13,10 @@ export async function fetchDynamicContentTags(context) {
12
13
  perPage
13
14
  });
14
15
  return res.tags;
15
- }), context.rpcClient.callRemoteProcedure('base.modifiers', {})]);
16
- const {
17
- result
18
- } = modifiers.response;
16
+ });
19
17
  return originalTags.filter(tag => !ignoreTagTypes.includes(tag.type)).map(tag => ({
20
18
  ...tag,
21
- modifiers: numberTypes.includes(tag.type) ? result[1] : result[2]
19
+ modifiers: numberTypes.includes(tag.type) ? DynamicContentModifiers.integer : DynamicContentModifiers.string
22
20
  }));
23
21
  }
24
22
  export function useDynamicContentTags() {
@@ -14,4 +14,3 @@ export declare const TagPickerDiv: import("styled-components").StyledComponent<"
14
14
  $gap: number;
15
15
  $padding: number;
16
16
  }, "$gridAutoFlow" | "$gap" | "$padding">;
17
- export declare const FieldTitle: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,4 +1,5 @@
1
1
  import styled from 'styled-components';
2
+ import { Color, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
2
3
  import { Vertical } from '@pushwoosh/kit-helpers';
3
4
  export const TagPickerDiv = styled(Vertical).attrs({
4
5
  $gap: 16,
@@ -6,8 +7,4 @@ export const TagPickerDiv = styled(Vertical).attrs({
6
7
  }).withConfig({
7
8
  displayName: "TagPickerDiv",
8
9
  componentId: "sc-1blii2o-0"
9
- })(["width:240px;border-radius:4px;background:#F7F9FA;box-shadow:0 0 4px 0 rgba(0,0,0,0.06),0 4px 6px 0 rgba(0,0,0,0.06);"]);
10
- export const FieldTitle = styled.div.withConfig({
11
- displayName: "FieldTitle",
12
- componentId: "sc-1blii2o-1"
13
- })(["font-size:12px;font-style:normal;font-weight:500;line-height:130%;"]);
10
+ })(["width:240px;border-radius:", ";background:", ";box-shadow:", ";"], ShapeRadius.CONTROL, Color.FROZEN, Shadow.REGULAR);
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- import { EmailTemplatePreview as DumbPreview } from '@pushwoosh/dumb-components';
2
+ import { EmailTemplatePreview as DumbPreview, RectangularSkeleton } from '@pushwoosh/dumb-components';
3
3
  import { useAsync } from '@pushwoosh/kit-helpers';
4
- import { RectangularSkeleton } from '@pushwoosh/kit-skeleton';
5
4
  import { useSPAContext } from '../context';
6
5
  export const EmailTemplatePreview = ({
7
6
  code,
@@ -10,20 +9,21 @@ export const EmailTemplatePreview = ({
10
9
  scale
11
10
  }) => {
12
11
  const {
13
- grpcBridge
12
+ rpcGateway
14
13
  } = useSPAContext();
15
14
  const res = useAsync(async () => {
16
15
  const {
17
- content: {
18
- content: {
19
- html,
20
- localizationData
21
- }
22
- },
23
- previewSettings
24
- } = await grpcBridge.emailTemplates.get({
16
+ emailTemplate: {
17
+ content,
18
+ previewSettings
19
+ }
20
+ } = await rpcGateway.emailTemplates.Get({
25
21
  code
26
22
  });
23
+ const {
24
+ html,
25
+ localizationData
26
+ } = content.kind.data;
27
27
  return {
28
28
  template: html,
29
29
  localization: localizationData.default || {},
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from 'react';
2
- import { Drawer, DrawerBody } from '@pushwoosh/kit-drawer';
2
+ import { Drawer, DrawerBody } from '@pushwoosh/dumb-components';
3
3
  import { DesktopPage } from './components/DesktopPage';
4
4
  import { MainPage } from './components/MainPage';
5
5
  import { MobilePage } from './components/MobilePage';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Button } from '@pushwoosh/kit-button';
2
+ import { Button } from '@pushwoosh/dumb-components';
3
3
  import { Spacing, Color, AllPlatforms } from '@pushwoosh/kit-constants';
4
4
  import { Vertical, Columns } from '@pushwoosh/kit-helpers';
5
5
  import { ArrowRoundIcon, CloseIcon, PlatformLogoIcon } from '@pushwoosh/kit-icons';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Button } from '@pushwoosh/kit-button';
2
+ import { Button } from '@pushwoosh/dumb-components';
3
3
  import { Spacing, Color, AllPlatforms } from '@pushwoosh/kit-constants';
4
4
  import { Vertical, Columns } from '@pushwoosh/kit-helpers';
5
5
  import { CloseIcon, DeviceIcon, EmailIcon, WhatsappIcon, SmsIcon } from '@pushwoosh/kit-icons';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Button } from '@pushwoosh/kit-button';
2
+ import { Button } from '@pushwoosh/dumb-components';
3
3
  import { Spacing, Color } from '@pushwoosh/kit-constants';
4
4
  import { Columns, Vertical } from '@pushwoosh/kit-helpers';
5
5
  import { ArrowRoundIcon, CloseIcon, PlatformLogoIcon } from '@pushwoosh/kit-icons';
@@ -1,4 +1,4 @@
1
- import { Link } from '@pushwoosh/kit-link';
1
+ import { Link } from '@pushwoosh/dumb-components';
2
2
  export declare const Header: import("styled-components").StyledComponent<"div", any, {}, never>;
3
3
  export declare const Close: import("styled-components").StyledComponent<"div", any, {}, never>;
4
4
  export declare const ColumnsWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,6 +1,6 @@
1
1
  import styled from 'styled-components';
2
+ import { Link } from '@pushwoosh/dumb-components';
2
3
  import { Color, Spacing } from '@pushwoosh/kit-constants';
3
- import { Link } from '@pushwoosh/kit-link';
4
4
  export const Header = styled.div.withConfig({
5
5
  displayName: "Header",
6
6
  componentId: "sc-1rmglxf-0"
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable no-console */
2
2
  import React, { useState } from 'react';
3
- import { Button } from '@pushwoosh/kit-button';
3
+ import { Button } from '@pushwoosh/dumb-components';
4
4
  import { Horizontal } from '@pushwoosh/kit-helpers';
5
5
  import { DynamicContentPicker } from '../../DynamicContentPicker';
6
6
  export function DynamicContentPickerExample() {
@@ -6,9 +6,7 @@ export function useSession() {
6
6
  } = useSPAContext();
7
7
  const [session, setSession] = useState(sessionStore.getLastSession());
8
8
  useEffect(() => {
9
- const subscriber = sessionStore.subscribe(s => {
10
- setSession(s);
11
- });
9
+ const subscriber = sessionStore.subscribe(setSession);
12
10
  return () => {
13
11
  subscriber.unsubscribe();
14
12
  };
package/package.json CHANGED
@@ -15,15 +15,10 @@
15
15
  },
16
16
  "pre-commit": "check",
17
17
  "dependencies": {
18
- "@pushwoosh/dumb-components": "^1.0.0",
19
- "@pushwoosh/kit-button": "^2.2.5",
20
- "@pushwoosh/kit-constants": "^1.6.5",
21
- "@pushwoosh/kit-drawer": "^1.0.11",
18
+ "@pushwoosh/dumb-components": "^1.0.27",
19
+ "@pushwoosh/kit-constants": "^1.6.8",
22
20
  "@pushwoosh/kit-helpers": "^4.6.1",
23
21
  "@pushwoosh/kit-icons": "^2.1.1",
24
- "@pushwoosh/kit-link": "^1.5.0",
25
- "@pushwoosh/kit-skeleton": "^1.1.6",
26
- "@pushwoosh/kit-spinner": "^1.5.1",
27
22
  "@pushwoosh/kit-typography": "^1.7.2"
28
23
  },
29
24
  "devDependencies": {
@@ -52,5 +47,5 @@
52
47
  "engines": {
53
48
  "node": ">= 18"
54
49
  },
55
- "version": "1.0.0"
50
+ "version": "1.0.2"
56
51
  }