@pushwoosh/smart-components-kit 1.3.20 → 1.3.22
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/DynamicContentPickerForm/SimpleDynamicContentPickerFormSmart.js +39 -41
- package/DynamicContentPickerForm/utils.d.ts +1 -0
- package/DynamicContentPickerForm/utils.js +3 -1
- package/ProductUpdates/styles.d.ts +8 -1
- package/ProductUpdates/styles.js +6 -1
- package/RichMessageEditorSmart/NewDynamicContentForm.js +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
|
-
import { FieldBox, NativeInput,
|
|
3
|
+
import { Combobox, FieldBox, NativeInput, Spinner } from '@pushwoosh/dumb-components';
|
|
4
4
|
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
5
5
|
import { useDynamicContentTags } from './hooks';
|
|
6
6
|
import { useLang } from './polyglot';
|
|
7
7
|
import { SimpleTagPickerDiv } from './styled';
|
|
8
|
-
import { buildOptions } from './utils';
|
|
8
|
+
import { allDynamicContentModifiers, buildOptions } from './utils';
|
|
9
|
+
const defaultModifier = 'regular';
|
|
10
|
+
const matchesQuery = (value, query) => value.toLowerCase().includes(query.trim().toLowerCase());
|
|
9
11
|
const defaultDynamicContent = {
|
|
10
12
|
tagName: '',
|
|
11
|
-
modifier:
|
|
13
|
+
modifier: defaultModifier,
|
|
12
14
|
defaultValue: ''
|
|
13
15
|
};
|
|
14
16
|
export const SimpleDynamicContentPickerFormSmart = ({
|
|
@@ -37,10 +39,19 @@ export const SimpleDynamicContentPickerFormSmart = ({
|
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
41
|
const options = buildOptions(systemVariables ?? [], asyncResult.value || []);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
const pickedOption = options.find(option => option.name === dc.tagName);
|
|
43
|
+
const modifiers = pickedOption?.modifiers ?? allDynamicContentModifiers;
|
|
44
|
+
const isEmpty = !dc.tagName.trim();
|
|
45
|
+
const labelOf = name => options.find(option => option.name === name)?.label ?? name;
|
|
46
|
+
const changeTagName = (tagName, isPicked) => {
|
|
47
|
+
const option = options.find(item => item.name === tagName);
|
|
48
|
+
const nextModifiers = option?.modifiers ?? allDynamicContentModifiers;
|
|
49
|
+
const keepModifier = !isPicked && nextModifiers.includes(dc.modifier);
|
|
50
|
+
onChange({
|
|
51
|
+
tagName,
|
|
52
|
+
modifier: keepModifier ? dc.modifier : nextModifiers[0] ?? defaultModifier,
|
|
53
|
+
defaultValue: isPicked ? '' : dc.defaultValue
|
|
54
|
+
});
|
|
44
55
|
};
|
|
45
56
|
return _jsxs(SimpleTagPickerDiv, {
|
|
46
57
|
children: [_jsx(FieldBox, {
|
|
@@ -49,43 +60,30 @@ export const SimpleDynamicContentPickerFormSmart = ({
|
|
|
49
60
|
}),
|
|
50
61
|
children: _jsxs(Vertical, {
|
|
51
62
|
"$gap": 8,
|
|
52
|
-
children: [_jsx(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
options: options.map(option => ({
|
|
68
|
-
value: option.name,
|
|
69
|
-
label: option.label
|
|
70
|
-
}))
|
|
71
|
-
}), _jsx(Select, {
|
|
72
|
-
width: "auto",
|
|
73
|
-
menuPlacement: "auto",
|
|
74
|
-
value: {
|
|
75
|
-
value: dc.modifier,
|
|
76
|
-
label: dc.modifier
|
|
77
|
-
},
|
|
78
|
-
onChange: option => {
|
|
63
|
+
children: [_jsx(Combobox, {
|
|
64
|
+
value: dc.tagName,
|
|
65
|
+
onChange: (value, meta) => changeTagName(value, meta.source === 'select'),
|
|
66
|
+
items: options.map(option => option.name),
|
|
67
|
+
getLabel: name => name,
|
|
68
|
+
renderItem: name => labelOf(name),
|
|
69
|
+
filter: (name, query) => matchesQuery(name, query) || matchesQuery(labelOf(name), query),
|
|
70
|
+
placeholder: lang({
|
|
71
|
+
message: 'SMART.DYNAMIC_CONTENT_PICKER_FORM.TAG.PLACEHOLDER'
|
|
72
|
+
}),
|
|
73
|
+
fullWidth: true
|
|
74
|
+
}), _jsx(Combobox, {
|
|
75
|
+
select: true,
|
|
76
|
+
value: dc.modifier || null,
|
|
77
|
+
onChange: modifier => {
|
|
79
78
|
onChange({
|
|
80
79
|
...dc,
|
|
81
|
-
modifier:
|
|
80
|
+
modifier: modifier ?? ''
|
|
82
81
|
});
|
|
83
82
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
isDisabled: !selectedTag.name
|
|
83
|
+
items: modifiers,
|
|
84
|
+
getLabel: modifier => modifier,
|
|
85
|
+
disabled: isEmpty,
|
|
86
|
+
fullWidth: true
|
|
89
87
|
})]
|
|
90
88
|
})
|
|
91
89
|
}), _jsx(FieldBox, {
|
|
@@ -100,7 +98,7 @@ export const SimpleDynamicContentPickerFormSmart = ({
|
|
|
100
98
|
defaultValue: e.target.value
|
|
101
99
|
});
|
|
102
100
|
},
|
|
103
|
-
disabled:
|
|
101
|
+
disabled: isEmpty
|
|
104
102
|
})
|
|
105
103
|
}), children]
|
|
106
104
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type FullTagData, type PickerOption, type SystemVariable, type VariedDynamicContent } from './types';
|
|
2
2
|
export declare function buildOptions(systemVariables: SystemVariable[], tags: FullTagData[]): PickerOption[];
|
|
3
3
|
export declare function createDefaultDynamicContent(kind: 'tag' | 'event' | 'customText'): VariedDynamicContent;
|
|
4
|
+
export declare const allDynamicContentModifiers: string[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DynamicContentModifiers } from '@pushwoosh/kit-constants';
|
|
1
2
|
export function buildOptions(systemVariables, tags) {
|
|
2
3
|
const taken = new Set(systemVariables.map(v => v.name));
|
|
3
4
|
const system = systemVariables.map(v => ({
|
|
@@ -40,4 +41,5 @@ export function createDefaultDynamicContent(kind) {
|
|
|
40
41
|
}
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
|
-
}
|
|
44
|
+
}
|
|
45
|
+
export const allDynamicContentModifiers = [...DynamicContentModifiers.string, ...DynamicContentModifiers.integer.filter(modifier => !DynamicContentModifiers.string.includes(modifier))];
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
export declare const CardImage: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
2
2
|
export declare const ContentBox: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
-
export declare const List: import("styled-components").StyledComponent<"
|
|
3
|
+
export declare const List: import("styled-components").StyledComponent<"span", any, {
|
|
4
|
+
$color?: string;
|
|
5
|
+
$uppercase?: boolean;
|
|
6
|
+
$ellipsis?: boolean;
|
|
7
|
+
$variant?: import("@pushwoosh/kit-typography").TypographyVariant;
|
|
8
|
+
} & {
|
|
9
|
+
as: string;
|
|
10
|
+
}, "as">;
|
|
4
11
|
export declare const Bold: import("styled-components").StyledComponent<"strong", any, {}, never>;
|
package/ProductUpdates/styles.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
2
|
import { FontWeight, ShapeRadius } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
3
4
|
// The only rule kit-helpers cannot express: object-fit has no prop there, and it is
|
|
4
5
|
// what keeps a wrongly proportioned upload from stretching the card.
|
|
5
6
|
export const CardImage = styled.img.withConfig({
|
|
@@ -12,7 +13,11 @@ export const ContentBox = styled.div.withConfig({
|
|
|
12
13
|
displayName: "ContentBox",
|
|
13
14
|
componentId: "sc-11vonu6-1"
|
|
14
15
|
})(["> * + *{margin-top:0.5em;}"]);
|
|
15
|
-
|
|
16
|
+
// Built on Text, not on a bare <ul>: the paragraph typography lives in that variant, and
|
|
17
|
+
// a plain list would keep the surrounding font size — 16px next to the card's 14px.
|
|
18
|
+
export const List = styled(Text).attrs({
|
|
19
|
+
as: 'ul'
|
|
20
|
+
}).withConfig({
|
|
16
21
|
displayName: "List",
|
|
17
22
|
componentId: "sc-11vonu6-2"
|
|
18
23
|
})(["margin:0;padding-left:1.25em;list-style:disc outside;li + li{margin-top:0.25em;}"]);
|
package/package.json
CHANGED