@pushwoosh/dumb-components 1.0.10 → 1.0.12
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.
- package/EmailTemplatePreview/EmailTemplatePreview.js +10 -7
- package/EmailTemplatePreview/components/NoEmailTemplatePreview/NoEmailTemplatePreview.js +3 -3
- package/EmailTemplatePreview/components/NoEmailTemplatePreview/assets/email.svg +5 -0
- package/Table/hooks/index.d.ts +1 -1
- package/Table/hooks/index.js +1 -1
- package/Table/hooks/{useDataTableParams.d.ts → useDataTableGetParams.d.ts} +2 -1
- package/Table/hooks/{useDataTableParams.js → useDataTableGetParams.js} +23 -6
- package/Table/index.d.ts +1 -1
- package/Table/index.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/EmailTemplatePreview/components/NoEmailTemplatePreview/assets/PW_logo.svg +0 -1
|
@@ -4,13 +4,16 @@ import { replacePlaceholders } from './helpers';
|
|
|
4
4
|
import { IframeStyled } from './styles';
|
|
5
5
|
const createLiquidInstance = () => {
|
|
6
6
|
const liquidInstance = new Liquid();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const tags = ['email_content', 'connected_content'];
|
|
8
|
+
tags.forEach(tag => {
|
|
9
|
+
liquidInstance.registerTag(tag, {
|
|
10
|
+
parse: function (tagToken) {
|
|
11
|
+
this.content = tagToken.args;
|
|
12
|
+
},
|
|
13
|
+
render: function (_ctx, emitter) {
|
|
14
|
+
emitter.write(`{% ${tag} ${this.content} %}`);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
14
17
|
});
|
|
15
18
|
return liquidInstance;
|
|
16
19
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Spacing } from '@pushwoosh/kit-constants';
|
|
3
3
|
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
-
import
|
|
4
|
+
import Email from './assets/email.svg?url';
|
|
5
5
|
import { Container, PreviewMock } from './styles';
|
|
6
6
|
import { LockedText, LockedTitle } from '../../../common';
|
|
7
7
|
export function NoEmailTemplatePreview() {
|
|
@@ -12,8 +12,8 @@ export function NoEmailTemplatePreview() {
|
|
|
12
12
|
"$alignItems": "center",
|
|
13
13
|
"$justifyContent": "center"
|
|
14
14
|
}, React.createElement("img", {
|
|
15
|
-
src:
|
|
16
|
-
alt: "
|
|
15
|
+
src: Email,
|
|
16
|
+
alt: "Email envelop icon"
|
|
17
17
|
})), React.createElement(Vertical, null, React.createElement(LockedTitle, null, "Content missed..."), React.createElement(LockedText, {
|
|
18
18
|
"$small": true
|
|
19
19
|
}, "Might be old data or deleted presets")));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="40" height="41" viewBox="0 0 40 41" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<g id="logo - for light bg - outlines" opacity="0.5">
|
|
3
|
+
<path id="shape" fill-rule="evenodd" clip-rule="evenodd" d="M9.16671 9.25C7.09564 9.25 5.41671 10.9289 5.41671 13V13.393C5.41644 13.408 5.41644 13.423 5.41671 13.438V28C5.41671 30.0711 7.09564 31.75 9.16671 31.75H30.8334C32.9044 31.75 34.5834 30.0711 34.5834 28V13.44C34.5837 13.4237 34.5837 13.4074 34.5834 13.391V13C34.5834 10.9289 32.9044 9.25 30.8334 9.25H9.16671ZM32.0484 12.7053C31.9159 12.1571 31.4222 11.75 30.8334 11.75H9.16671C8.57788 11.75 8.08415 12.1571 7.95166 12.7052L20.0001 19.4825L32.0484 12.7053ZM7.91671 15.554V28C7.91671 28.6904 8.47635 29.25 9.16671 29.25H30.8334C31.5237 29.25 32.0834 28.6904 32.0834 28V15.554L20.6129 22.0061C20.2324 22.2202 19.7677 22.2202 19.3872 22.0061L7.91671 15.554Z" fill="#7694B8" fill-opacity="0.2"/>
|
|
4
|
+
</g>
|
|
5
|
+
</svg>
|
package/Table/hooks/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { useDataTableContext } from './useDataTableContext';
|
|
2
|
-
export {
|
|
2
|
+
export { useDataTableGetParams } from './useDataTableGetParams';
|
package/Table/hooks/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { useDataTableContext } from './useDataTableContext';
|
|
2
|
-
export {
|
|
2
|
+
export { useDataTableGetParams } from './useDataTableGetParams';
|
|
@@ -4,7 +4,8 @@ type UseDataTableParamsParams<P extends DataTableParams> = {
|
|
|
4
4
|
defaultDirection?: 'asc' | 'desc';
|
|
5
5
|
defaultPerPage?: number;
|
|
6
6
|
extend?: (obj: Record<string, string>, params: DataTableParams) => P;
|
|
7
|
+
prefix?: string;
|
|
7
8
|
};
|
|
8
9
|
type UseDataTableParamsReturn<P> = readonly [P, (params: P) => void];
|
|
9
|
-
export declare function
|
|
10
|
+
export declare function useDataTableGetParams<P extends DataTableParams>({ defaultOrder, defaultDirection, defaultPerPage, extend, prefix, }: UseDataTableParamsParams<P>): UseDataTableParamsReturn<P>;
|
|
10
11
|
export {};
|
|
@@ -4,11 +4,18 @@ import { usePersistentFunction } from '@pushwoosh/kit-helpers';
|
|
|
4
4
|
function pickBy(obj) {
|
|
5
5
|
return Object.fromEntries(Object.entries(obj).filter(([, value]) => !!value));
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
function mapKeys(obj, mapper) {
|
|
8
|
+
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [mapper(key), value]));
|
|
9
|
+
}
|
|
10
|
+
function shallowEqual(a, b) {
|
|
11
|
+
return Object.keys(a).every(key => a[key] === b[key]);
|
|
12
|
+
}
|
|
13
|
+
export function useDataTableGetParams({
|
|
8
14
|
defaultOrder,
|
|
9
15
|
defaultDirection = 'asc',
|
|
10
16
|
defaultPerPage = 10,
|
|
11
|
-
extend
|
|
17
|
+
extend,
|
|
18
|
+
prefix = ''
|
|
12
19
|
}) {
|
|
13
20
|
const history = useHistory();
|
|
14
21
|
const {
|
|
@@ -16,9 +23,10 @@ export function useDataTableParams({
|
|
|
16
23
|
} = useLocation();
|
|
17
24
|
const extendRef = useRef(extend);
|
|
18
25
|
extendRef.current = extend;
|
|
26
|
+
const prevRef = useRef({});
|
|
19
27
|
const dataTableParams = useMemo(() => {
|
|
20
28
|
const searchParams = new URLSearchParams(locationSearch);
|
|
21
|
-
const obj = Object.fromEntries(searchParams);
|
|
29
|
+
const obj = mapKeys(Object.fromEntries(searchParams), key => key.startsWith(prefix) ? key.slice(prefix.length) : key);
|
|
22
30
|
// eslint-disable-next-line no-nested-ternary
|
|
23
31
|
const realOrderDirection = !obj.direction ? defaultDirection : obj.direction === 'asc' ? 'asc' : 'desc';
|
|
24
32
|
const params = {
|
|
@@ -28,11 +36,20 @@ export function useDataTableParams({
|
|
|
28
36
|
page: +obj.page || 1,
|
|
29
37
|
perPage: +obj.perPage || defaultPerPage
|
|
30
38
|
};
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
const resultParams = extendRef.current ? extendRef.current(obj, params) : params;
|
|
40
|
+
if (!shallowEqual(resultParams, prevRef.current)) {
|
|
41
|
+
prevRef.current = resultParams;
|
|
42
|
+
}
|
|
43
|
+
return prevRef.current;
|
|
44
|
+
}, [locationSearch, defaultDirection, defaultOrder, defaultPerPage, prefix]);
|
|
33
45
|
const changeDataTableParams = usePersistentFunction(params => {
|
|
46
|
+
const searchParams = new URLSearchParams(locationSearch);
|
|
47
|
+
const paramsWithPrefix = pickBy(mapKeys(params, key => `${prefix}${key}`));
|
|
48
|
+
Object.entries(paramsWithPrefix).forEach(([key, value]) => {
|
|
49
|
+
searchParams.set(key, value);
|
|
50
|
+
});
|
|
34
51
|
history.push({
|
|
35
|
-
search:
|
|
52
|
+
search: searchParams.toString()
|
|
36
53
|
});
|
|
37
54
|
});
|
|
38
55
|
return [dataTableParams, changeDataTableParams];
|
package/Table/index.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ export { DataTableSortableCell } from './components/DataTableSortableCell';
|
|
|
8
8
|
export { Loading } from './components/Loading';
|
|
9
9
|
export { TableList } from './components/TableList';
|
|
10
10
|
export { TablePagination } from './components/TablePagination';
|
|
11
|
-
export { useDataTableContext,
|
|
11
|
+
export { useDataTableContext, useDataTableGetParams } from './hooks';
|
|
12
12
|
export { Table, Td, Tr, Th, ElementHover, ItemDetailLink, ItemName, LockedText, Description, } from './styles';
|
|
13
13
|
export type { DataTableParams, DataTableData, DataTableContextType } from './types';
|
package/Table/index.js
CHANGED
|
@@ -8,5 +8,5 @@ export { DataTableSortableCell } from './components/DataTableSortableCell';
|
|
|
8
8
|
export { Loading } from './components/Loading';
|
|
9
9
|
export { TableList } from './components/TableList';
|
|
10
10
|
export { TablePagination } from './components/TablePagination';
|
|
11
|
-
export { useDataTableContext,
|
|
11
|
+
export { useDataTableContext, useDataTableGetParams } from './hooks';
|
|
12
12
|
export { Table, Td, Tr, Th, ElementHover, ItemDetailLink, ItemName, LockedText, Description } from './styles';
|
package/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export { StatisticCard } from './StatisticCard';
|
|
|
26
26
|
export { EmailTemplatePreview, NoEmailTemplatePreview } from './EmailTemplatePreview';
|
|
27
27
|
export { PushPreview } from './PushPreview';
|
|
28
28
|
export { Toast, ToastProvider, useToast } from './Toast';
|
|
29
|
-
export { ClearableInput, DataTable, DataTableList, DataTableGetContext, DataTablePagination, DataTableSearchInput, DataTableSortableCell, Loading, TableList, TablePagination, useDataTableContext,
|
|
29
|
+
export { ClearableInput, DataTable, DataTableList, DataTableGetContext, DataTablePagination, DataTableSearchInput, DataTableSortableCell, Loading, TableList, TablePagination, useDataTableContext, useDataTableGetParams, Table, Td, Tr, Th, ElementHover, ItemDetailLink, ItemName, LockedText, Description, type DataTableParams, type DataTableData, type DataTableContextType, } from './Table';
|
|
30
30
|
export { AutosizeInput, PageHeader, PageHeaderEditable } from './PageHeader';
|
|
31
31
|
export { ExportResult } from './ExportResult';
|
|
32
32
|
export { NativeInput, NativeTextarea, NativeSelect } from './native';
|
package/index.js
CHANGED
|
@@ -26,7 +26,7 @@ export { StatisticCard } from './StatisticCard';
|
|
|
26
26
|
export { EmailTemplatePreview, NoEmailTemplatePreview } from './EmailTemplatePreview';
|
|
27
27
|
export { PushPreview } from './PushPreview';
|
|
28
28
|
export { Toast, ToastProvider, useToast } from './Toast';
|
|
29
|
-
export { ClearableInput, DataTable, DataTableList, DataTableGetContext, DataTablePagination, DataTableSearchInput, DataTableSortableCell, Loading, TableList, TablePagination, useDataTableContext,
|
|
29
|
+
export { ClearableInput, DataTable, DataTableList, DataTableGetContext, DataTablePagination, DataTableSearchInput, DataTableSortableCell, Loading, TableList, TablePagination, useDataTableContext, useDataTableGetParams, Table, Td, Tr, Th, ElementHover, ItemDetailLink, ItemName, LockedText, Description } from './Table';
|
|
30
30
|
export { AutosizeInput, PageHeader, PageHeaderEditable } from './PageHeader';
|
|
31
31
|
export { ExportResult } from './ExportResult';
|
|
32
32
|
export { NativeInput, NativeTextarea, NativeSelect } from './native';
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="41" fill="none"><path fill="#7694B8" fill-opacity=".2" fill-rule="evenodd" d="M10.81 7.488c-1.412 0-3.17.697-3.707 2.948-.604 2.524-1.273 5.425-1.76 7.538l-.168.727c-.192.832-.03 1.485.285 1.909.307.414.845.725 1.655.725h.874a.3.3 0 0 1 .293.365l-.19.853-.256 1.143a.3.3 0 0 0 .465.311l3.557-2.491.18-.127a.3.3 0 0 1 .173-.054h2.022a.31.31 0 0 0 .278-.179c1.092-2.284 3.455-3.431 5.27-3.431h4.28a.26.26 0 0 0 .254-.21c.123-.622.29-1.472.473-2.388.364-1.827.787-3.925 1.015-4.972.172-.793.01-1.452-.332-1.895-.332-.432-.92-.772-1.832-.772H10.81m2.67 15.847a.3.3 0 0 1 .292.368l-.347 1.478-.002.007a766 766 0 0 0-1.215 5.22c-.625 2.754 1.54 5.099 3.856 5.099h13.11c2.046 0 4.94-1.587 5.664-4.675l.68-2.907.001-.004v-.002c.422-1.806.85-3.633 1.19-5.074.322-1.362.094-2.653-.642-3.62a3.7 3.7 0 0 0-1.719-1.25.32.32 0 0 1-.209-.364l.474-2.129c.28-1.254-1.137-2.19-2.181-1.442l-5.067 3.629a.3.3 0 0 1-.174.056h-.563a.26.26 0 0 1-.255-.31c.108-.547.238-1.204.377-1.897.364-1.832.784-3.911 1.007-4.937.279-1.28.052-2.562-.7-3.54-.76-.989-1.97-1.553-3.418-1.553H10.81c-2.037 0-4.836 1.07-5.653 4.483-.605 2.533-1.276 5.441-1.763 7.554l-.168.726c-.3 1.303-.093 2.58.628 3.551.446.6 1.056 1.04 1.775 1.29a.317.317 0 0 1 .211.365l-.461 2.067C5.1 26.771 6.5 27.71 7.549 26.976l5.12-3.587a.3.3 0 0 1 .173-.054zm14.128-3.61H19.78c-1.33 0-3.27 1.05-3.753 3.117l-.66 2.816c-.444 1.885-.893 3.797-1.21 5.192-.335 1.48.849 2.657 1.906 2.657h13.11c1.248 0 3.234-1.07 3.717-3.131l.675-2.885.001-.006.003-.011c.422-1.81.851-3.644 1.193-5.09.207-.878.029-1.532-.288-1.95-.316-.415-.856-.71-1.608-.71h-.872a.3.3 0 0 1-.293-.365l.19-.852.258-1.161a.3.3 0 0 0-.468-.31l-3.491 2.502-.198.141a.243.243 0 0 1-.385-.197v-.757zm-8.084-9.947a2.6 2.6 0 0 0-1.126-.202H12.64a1.12 1.12 0 0 0-1.093.868L9.712 18.4v.001a1.12 1.12 0 0 0 .838 1.347h.002q.124.028.252.028v-.25.25a1.12 1.12 0 0 0 1.093-.868v-.001l.608-2.611h4.972c1.086 0 2-.534 2.635-1.287.633-.75 1.003-1.733 1.004-2.672a2.82 2.82 0 0 0-.648-1.884l-.006-.008a2.6 2.6 0 0 0-.937-.666m-1.098 1.856a.63.63 0 0 1 .483.163c.107.152.16.335.15.521v.014c0 .393-.156.88-.442 1.265-.284.383-.674.639-1.14.639h-4.7l.609-2.601h5.029zM31.22 23.92h-.073a1.166 1.166 0 0 0-1.163-1.314v.25l-.001-.25a1.17 1.17 0 0 0-1.057.677l-2.1 4.525-1.386-2.47v-.001a1.16 1.16 0 0 0-.825-.578 1.17 1.17 0 0 0-.967.278l-2.694 2.39.437-3.509a1.166 1.166 0 0 0-1.46-1.309 1.17 1.17 0 0 0-.854 1l-.848 6.615v.002a1.17 1.17 0 0 0 .624 1.179 1.19 1.19 0 0 0 1.316-.158l.002-.002 3.94-3.496 1.803 3.187a1.17 1.17 0 0 0 1.015.592h.045a1.16 1.16 0 0 0 1.02-.656l.001-.003 3.06-6.594z" clip-rule="evenodd" opacity=".5"/></svg>
|