@pushwoosh/smart-components-kit 1.0.73 → 1.0.75

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,3 @@
1
+ import React from 'react';
2
+ import type { DocsButtonProps } from './types';
3
+ export declare function DocsButton(props: DocsButtonProps): React.JSX.Element | null;
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { Button, DrawerDocs, useDocs } from '@pushwoosh/dumb-components';
3
+ import { DocsIcon } from '@pushwoosh/kit-icons';
4
+ import { useDocsButtonUrl } from './hooks';
5
+ export function DocsButton(props) {
6
+ const {
7
+ pathname,
8
+ children,
9
+ color = 'secondary',
10
+ view = 'ghost',
11
+ size,
12
+ openInNewWindow = false
13
+ } = props;
14
+ const {
15
+ docsOpen,
16
+ openDocsDrawer,
17
+ closeDocsDrawer
18
+ } = useDocs();
19
+ const url = useDocsButtonUrl(pathname);
20
+ if (!url) {
21
+ return null;
22
+ }
23
+ const handleClick = () => {
24
+ if (openInNewWindow) {
25
+ window.open(url, '_blank', 'noopener,noreferrer');
26
+ return;
27
+ }
28
+ openDocsDrawer();
29
+ };
30
+ return React.createElement(React.Fragment, null, React.createElement(Button, {
31
+ "aria-label": "Documentation",
32
+ color: color,
33
+ view: view,
34
+ size: size,
35
+ icon: React.createElement(DocsIcon, {
36
+ size: "medium",
37
+ view: "lined"
38
+ }),
39
+ onClick: handleClick
40
+ }, children), !openInNewWindow && React.createElement(DrawerDocs, {
41
+ url: url,
42
+ isOpen: docsOpen,
43
+ onClose: closeDocsDrawer
44
+ }));
45
+ }
@@ -0,0 +1,2 @@
1
+ export declare function useIsAllowDocsButton(): boolean;
2
+ export declare function useDocsButtonUrl(pathname: string): string;
@@ -0,0 +1,24 @@
1
+ import { useSPAContext } from '@pushwoosh/spa-context';
2
+ const PUSHWOOSH_DOCS_BASE = 'https://docs.pushwoosh.com';
3
+ const WAVESEND_DOCS_BASE = 'https://docs.wavesend.ru';
4
+ export function useIsAllowDocsButton() {
5
+ const {
6
+ environment
7
+ } = useSPAContext();
8
+ return !environment.isOMO;
9
+ }
10
+ export function useDocsButtonUrl(pathname) {
11
+ const {
12
+ environment
13
+ } = useSPAContext();
14
+ const isAllowDocsButton = useIsAllowDocsButton();
15
+ if (!isAllowDocsButton) {
16
+ return '';
17
+ }
18
+ const base = environment.isWavesend ? WAVESEND_DOCS_BASE : PUSHWOOSH_DOCS_BASE;
19
+ if (!pathname) {
20
+ return base;
21
+ }
22
+ const normalizedPath = pathname.startsWith('/') ? pathname : `/${pathname}`;
23
+ return `${base}${normalizedPath}`;
24
+ }
@@ -0,0 +1,3 @@
1
+ export { DocsButton } from './DocsButton';
2
+ export { useIsAllowDocsButton, useDocsButtonUrl } from './hooks';
3
+ export type { DocsButtonProps } from './types';
@@ -0,0 +1,2 @@
1
+ export { DocsButton } from './DocsButton';
2
+ export { useIsAllowDocsButton, useDocsButtonUrl } from './hooks';
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface DocsButtonProps {
3
+ pathname: string;
4
+ children?: ReactNode;
5
+ color?: 'primary' | 'secondary' | 'danger';
6
+ size?: 'field' | 'compact';
7
+ view?: 'shape' | 'ghost';
8
+ openInNewWindow?: boolean;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
package/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './hooks';
2
2
  export * from './CampaignsConfigurationDrawer';
3
+ export * from './DocsButton';
3
4
  export * from './DynamicContentPicker';
4
5
  export * from './DynamicContentPickerForm';
5
6
  export * from './EmailTemplatePreview';
package/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './hooks';
2
2
  export * from './CampaignsConfigurationDrawer';
3
+ export * from './DocsButton';
3
4
  export * from './DynamicContentPicker';
4
5
  export * from './DynamicContentPickerForm';
5
6
  export * from './EmailTemplatePreview';
package/package.json CHANGED
@@ -48,5 +48,5 @@
48
48
  "react": "^16.14.0 || ^18.0.0",
49
49
  "react-dom": "^16.14.0 || ^18.0.0"
50
50
  },
51
- "version": "1.0.73"
51
+ "version": "1.0.75"
52
52
  }