@pushwoosh/dumb-components 1.1.107 → 1.1.109

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/Badge/maps.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare const BadgeColorToColorMap: {
7
7
  purple: Color;
8
8
  sky: Color;
9
9
  locked: Color;
10
+ black: Color;
10
11
  };
11
12
  export declare const BadgeColorToLightColorMap: {
12
13
  gray: Color;
@@ -16,4 +17,5 @@ export declare const BadgeColorToLightColorMap: {
16
17
  purple: Color;
17
18
  sky: Color;
18
19
  locked: Color;
20
+ black: Color;
19
21
  };
package/Badge/maps.js CHANGED
@@ -6,7 +6,8 @@ export const BadgeColorToColorMap = {
6
6
  red: Color.DANGER,
7
7
  purple: Color.EXCEPTIONAL,
8
8
  sky: Color.BRIGHT,
9
- locked: Color.LOCKED
9
+ locked: Color.LOCKED,
10
+ black: Color.MAIN
10
11
  };
11
12
  export const BadgeColorToLightColorMap = {
12
13
  gray: Color.SOFT_LIGHT,
@@ -15,5 +16,6 @@ export const BadgeColorToLightColorMap = {
15
16
  red: Color.DANGER_LIGHT,
16
17
  purple: Color.EXCEPTIONAL_LIGHT,
17
18
  sky: Color.BRIGHT_LIGHT,
18
- locked: Color.FROZEN
19
+ locked: Color.FROZEN,
20
+ black: Color.CLEAR
19
21
  };
package/Badge/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Ref, ReactNode } from 'react';
2
- export type BadgeColor = 'gray' | 'green' | 'orange' | 'red' | 'purple' | 'sky' | 'locked';
2
+ export type BadgeColor = 'gray' | 'green' | 'orange' | 'red' | 'purple' | 'sky' | 'locked' | 'black';
3
3
  export type BadgeProps = Omit<JSX.IntrinsicElements['div'], 'ref'> & {
4
4
  readonly boxRef?: Ref<HTMLDivElement>;
5
5
  readonly color: BadgeColor;
@@ -0,0 +1,3 @@
1
+ import { type ReactElement } from 'react';
2
+ import { type FrequencyCappingInAppsProps } from './types';
3
+ export declare function FrequencyCappingInApps(props: FrequencyCappingInAppsProps): ReactElement;
@@ -0,0 +1,49 @@
1
+ import React, { useCallback } from 'react';
2
+ import { Color } from '@pushwoosh/kit-constants';
3
+ import { Vertical } from '@pushwoosh/kit-helpers';
4
+ import { FieldBox } from '../FieldBox';
5
+ import { Select } from '../Select';
6
+ import { EditInAppCappingSettings } from './components/Settings';
7
+ import { cappingOptions } from './constants';
8
+ import { Container } from './styles';
9
+ import { CappingTypes } from './types';
10
+ export function FrequencyCappingInApps(props) {
11
+ const {
12
+ capping,
13
+ isDisabled,
14
+ onChange
15
+ } = props;
16
+ const options = cappingOptions.filter(({
17
+ value
18
+ }) => value !== CappingTypes.GLOBAL);
19
+ const cappingOption = capping !== null ? CappingTypes.CUSTOM : CappingTypes.IGNORE;
20
+ const onChangeFrequencyCapping = useCallback(value => {
21
+ if (value === CappingTypes.IGNORE) {
22
+ onChange(null);
23
+ }
24
+ if (value === CappingTypes.CUSTOM) {
25
+ onChange({});
26
+ }
27
+ }, [onChange]);
28
+ const onSettingsChange = useCallback(newCapping => {
29
+ onChange(newCapping);
30
+ }, [onChange]);
31
+ return React.createElement(Container, {
32
+ "$padding": 16,
33
+ "$bgColor": Color.SOFT_LIGHT,
34
+ "$borderRadius": 8
35
+ }, React.createElement(Vertical, {
36
+ "$gap": 12
37
+ }, React.createElement(FieldBox, {
38
+ title: "Frequency capping"
39
+ }, React.createElement(Select, {
40
+ name: "cappingOption",
41
+ isDisabled: isDisabled,
42
+ options: options,
43
+ value: options.find(option => option.value === cappingOption),
44
+ onChange: newValue => onChangeFrequencyCapping(newValue.value)
45
+ })), capping !== null && !isDisabled && React.createElement(EditInAppCappingSettings, {
46
+ capping: capping,
47
+ onChange: onSettingsChange
48
+ })));
49
+ }
@@ -0,0 +1,3 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { EditCappingSettingsProps } from './types';
3
+ export declare function EditCappingSettings(props: EditCappingSettingsProps): ReactElement;
@@ -0,0 +1,34 @@
1
+ import React, { useCallback } from 'react';
2
+ import { Horizontal } from '@pushwoosh/kit-helpers';
3
+ import { Paragraph } from '@pushwoosh/kit-typography';
4
+ import { NumberPicker } from '../../../NumberPicker';
5
+ export function EditCappingSettings(props) {
6
+ const {
7
+ messages,
8
+ days,
9
+ onChange
10
+ } = props;
11
+ const onMessagesChange = useCallback(value => {
12
+ onChange(value, days);
13
+ }, [days, onChange]);
14
+ const onDaysChange = useCallback(value => {
15
+ onChange(messages, value);
16
+ }, [messages, onChange]);
17
+ return React.createElement(Horizontal, {
18
+ "$gap": 12,
19
+ "$alignItems": "center",
20
+ style: {
21
+ gridTemplateColumns: '145px 70px 90px 70px 40px'
22
+ }
23
+ }, React.createElement(Paragraph, null, "Limit to a\u00A0maximum\u00A0of"), React.createElement(NumberPicker, {
24
+ value: messages,
25
+ minValue: 1,
26
+ maxValue: 1000,
27
+ onChange: value => onMessagesChange(value)
28
+ }), React.createElement(Paragraph, null, "messages per"), React.createElement(NumberPicker, {
29
+ maxValue: 30,
30
+ minValue: 1,
31
+ value: days,
32
+ onChange: value => onDaysChange(value)
33
+ }), React.createElement(Paragraph, null, "day(s)"));
34
+ }
@@ -0,0 +1,3 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { EditInAppCappingSettingsProps } from './types';
3
+ export declare function EditInAppCappingSettings(props: EditInAppCappingSettingsProps): ReactElement;
@@ -0,0 +1,143 @@
1
+ import React, { useCallback } from 'react';
2
+ import { Columns, Vertical } from '@pushwoosh/kit-helpers';
3
+ import { Paragraph, Text } from '@pushwoosh/kit-typography';
4
+ import { Checkbox } from '../../../Checkbox';
5
+ import { NumberPicker } from '../../../NumberPicker';
6
+ export function EditInAppCappingSettings(props) {
7
+ var _capping$total, _capping$perDays, _capping$perDays2, _capping$leastDays;
8
+ const {
9
+ capping,
10
+ onChange
11
+ } = props;
12
+ const hasTotal = capping.total !== undefined;
13
+ const hasPerDays = capping.perDays !== undefined;
14
+ const hasLeastDays = capping.leastDays !== undefined;
15
+ const onTotalToggle = useCallback(() => {
16
+ const next = {
17
+ ...capping
18
+ };
19
+ if (hasTotal) {
20
+ delete next.total;
21
+ } else {
22
+ next.total = {
23
+ count: 1
24
+ };
25
+ }
26
+ onChange(next);
27
+ }, [capping, hasTotal, onChange]);
28
+ const onTotalCountChange = useCallback(count => {
29
+ onChange({
30
+ ...capping,
31
+ total: {
32
+ count
33
+ }
34
+ });
35
+ }, [capping, onChange]);
36
+ const onPerDaysToggle = useCallback(() => {
37
+ const next = {
38
+ ...capping
39
+ };
40
+ if (hasPerDays) {
41
+ delete next.perDays;
42
+ } else {
43
+ next.perDays = {
44
+ count: 1,
45
+ days: 1
46
+ };
47
+ }
48
+ onChange(next);
49
+ }, [capping, hasPerDays, onChange]);
50
+ const onPerDaysCountChange = useCallback(count => {
51
+ onChange({
52
+ ...capping,
53
+ perDays: {
54
+ ...capping.perDays,
55
+ count
56
+ }
57
+ });
58
+ }, [capping, onChange]);
59
+ const onPerDaysDaysChange = useCallback(days => {
60
+ onChange({
61
+ ...capping,
62
+ perDays: {
63
+ ...capping.perDays,
64
+ days
65
+ }
66
+ });
67
+ }, [capping, onChange]);
68
+ const onLeastDaysToggle = useCallback(() => {
69
+ const next = {
70
+ ...capping
71
+ };
72
+ if (hasLeastDays) {
73
+ delete next.leastDays;
74
+ } else {
75
+ next.leastDays = {
76
+ count: 1
77
+ };
78
+ }
79
+ onChange(next);
80
+ }, [capping, hasLeastDays, onChange]);
81
+ const onLeastDaysCountChange = useCallback(count => {
82
+ onChange({
83
+ ...capping,
84
+ leastDays: {
85
+ count
86
+ }
87
+ });
88
+ }, [capping, onChange]);
89
+ return React.createElement(Vertical, {
90
+ "$gap": 8
91
+ }, React.createElement(Paragraph, null, "Limit frequency of displaying this In-App to a particular user"), React.createElement(Columns, {
92
+ "$sizes": "100px 80px auto",
93
+ "$alignItems": "center",
94
+ "$justifyContent": "start",
95
+ "$gap": 8
96
+ }, React.createElement(Checkbox, {
97
+ label: "Limited to",
98
+ isChecked: hasTotal,
99
+ onChange: onTotalToggle
100
+ }), React.createElement(NumberPicker, {
101
+ value: ((_capping$total = capping.total) === null || _capping$total === void 0 ? void 0 : _capping$total.count) ?? 1,
102
+ minValue: 1,
103
+ maxValue: 1000,
104
+ isDisabled: !hasTotal,
105
+ onChange: onTotalCountChange
106
+ }), React.createElement(Text, null, "total impressions")), React.createElement(Columns, {
107
+ "$sizes": "100px 80px auto 80px auto",
108
+ "$alignItems": "center",
109
+ "$justifyContent": "start",
110
+ "$gap": 8
111
+ }, React.createElement(Checkbox, {
112
+ label: "Limited to",
113
+ isChecked: hasPerDays,
114
+ onChange: onPerDaysToggle
115
+ }), React.createElement(NumberPicker, {
116
+ value: ((_capping$perDays = capping.perDays) === null || _capping$perDays === void 0 ? void 0 : _capping$perDays.count) ?? 1,
117
+ minValue: 1,
118
+ maxValue: 1000,
119
+ isDisabled: !hasPerDays,
120
+ onChange: onPerDaysCountChange
121
+ }), React.createElement(Text, null, "impressions in"), React.createElement(NumberPicker, {
122
+ value: ((_capping$perDays2 = capping.perDays) === null || _capping$perDays2 === void 0 ? void 0 : _capping$perDays2.days) ?? 1,
123
+ minValue: 1,
124
+ maxValue: 366,
125
+ isDisabled: !hasPerDays,
126
+ onChange: onPerDaysDaysChange
127
+ }), React.createElement(Text, null, "day(s)")), React.createElement(Columns, {
128
+ "$sizes": "100px 80px auto",
129
+ "$alignItems": "center",
130
+ "$justifyContent": "start",
131
+ "$gap": 8
132
+ }, React.createElement(Checkbox, {
133
+ label: "Enable",
134
+ isChecked: hasLeastDays,
135
+ onChange: onLeastDaysToggle
136
+ }), React.createElement(NumberPicker, {
137
+ value: ((_capping$leastDays = capping.leastDays) === null || _capping$leastDays === void 0 ? void 0 : _capping$leastDays.count) ?? 1,
138
+ minValue: 1,
139
+ maxValue: 366,
140
+ isDisabled: !hasLeastDays,
141
+ onChange: onLeastDaysCountChange
142
+ }), React.createElement(Text, null, "day(s) interval between impressions")));
143
+ }
@@ -1,8 +1,2 @@
1
- import { type ReactElement } from 'react';
2
- type EditCappingSettingsProps = {
3
- messages: number;
4
- days: number;
5
- onChange: (messages: number, days: number) => void;
6
- };
7
- export declare function EditCappingSettings(props: EditCappingSettingsProps): ReactElement;
8
- export {};
1
+ export { EditCappingSettings } from './EditCappingSettings';
2
+ export { EditInAppCappingSettings } from './EditInAppCappingSettings';
@@ -1,34 +1,2 @@
1
- import React, { useCallback } from 'react';
2
- import { Horizontal } from '@pushwoosh/kit-helpers';
3
- import { Paragraph } from '@pushwoosh/kit-typography';
4
- import { NumberPicker } from '../../../NumberPicker';
5
- export function EditCappingSettings(props) {
6
- const {
7
- messages,
8
- days,
9
- onChange
10
- } = props;
11
- const onMessagesChange = useCallback(value => {
12
- onChange(value, days);
13
- }, [days, onChange]);
14
- const onDaysChange = useCallback(value => {
15
- onChange(messages, value);
16
- }, [messages, onChange]);
17
- return React.createElement(Horizontal, {
18
- "$gap": 12,
19
- "$alignItems": "center",
20
- style: {
21
- gridTemplateColumns: '145px 70px 90px 70px 40px'
22
- }
23
- }, React.createElement(Paragraph, null, "Limit to a\u00A0maximum\u00A0of"), React.createElement(NumberPicker, {
24
- value: messages,
25
- minValue: 1,
26
- maxValue: 1000,
27
- onChange: value => onMessagesChange(value)
28
- }), React.createElement(Paragraph, null, "messages per"), React.createElement(NumberPicker, {
29
- maxValue: 30,
30
- minValue: 1,
31
- value: days,
32
- onChange: value => onDaysChange(value)
33
- }), React.createElement(Paragraph, null, "day(s)"));
34
- }
1
+ export { EditCappingSettings } from './EditCappingSettings';
2
+ export { EditInAppCappingSettings } from './EditInAppCappingSettings';
@@ -0,0 +1,10 @@
1
+ import type { CappingInAppBase } from '../../types';
2
+ export type EditCappingSettingsProps = {
3
+ messages: number;
4
+ days: number;
5
+ onChange: (messages: number, days: number) => void;
6
+ };
7
+ export type EditInAppCappingSettingsProps = {
8
+ capping: CappingInAppBase;
9
+ onChange: (capping: CappingInAppBase) => void;
10
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
1
  export { FrequencyCappingEdit } from './FrequencyCappingEdit';
2
2
  export { FrequencyCappingReadonly } from './FrequencyCappingReadonly';
3
- export type { FrequencyCappingEditProps, FrequencyCappingReadonlyProps, CappingBase as LocalCapping } from './types';
3
+ export { FrequencyCappingInApps } from './FrequencyCappingInApps';
4
+ export type { FrequencyCappingEditProps, FrequencyCappingReadonlyProps, FrequencyCappingInAppsProps, CappingBase as LocalCapping, CappingInAppBase, } from './types';
@@ -1,2 +1,3 @@
1
1
  export { FrequencyCappingEdit } from './FrequencyCappingEdit';
2
- export { FrequencyCappingReadonly } from './FrequencyCappingReadonly';
2
+ export { FrequencyCappingReadonly } from './FrequencyCappingReadonly';
3
+ export { FrequencyCappingInApps } from './FrequencyCappingInApps';
@@ -12,4 +12,4 @@ export const IconWrapper = styled(Horizontal).withConfig({
12
12
  export const LinkWrapper = styled.span.withConfig({
13
13
  displayName: "LinkWrapper",
14
14
  componentId: "sc-1z3915-2"
15
- })(["display:inline-flex;gap:4px;align-items:center;justify-content:start;text-decoration:none;"]);
15
+ })(["display:inline-flex;align-items:center;justify-content:start;text-decoration:none;gap:4px;"]);
@@ -13,6 +13,18 @@ export type CappingBase = {
13
13
  days: number;
14
14
  ignoreGlobalCapping: boolean;
15
15
  };
16
+ export type CappingInAppBase = {
17
+ total?: {
18
+ count: number;
19
+ };
20
+ perDays?: {
21
+ count: number;
22
+ days: number;
23
+ };
24
+ leastDays?: {
25
+ count: number;
26
+ };
27
+ };
16
28
  export type FrequencyCappingEditProps<T extends CappingBase> = {
17
29
  capping: T;
18
30
  globalCapping: {
@@ -35,3 +47,8 @@ export type FrequencyCappingReadonlyProps<T extends CappingBase> = {
35
47
  editGlobalClicked: () => void;
36
48
  isInJourney?: boolean;
37
49
  };
50
+ export type FrequencyCappingInAppsProps = {
51
+ capping: CappingInAppBase | null;
52
+ isDisabled?: boolean;
53
+ onChange: (newCappingState: CappingInAppBase | null) => void;
54
+ };
package/index.d.ts CHANGED
@@ -41,7 +41,7 @@ export { EnhancedInput, SearchInput } from './EnhancedInput';
41
41
  export { Chip } from './Chip';
42
42
  export { RichmediaPreview, useRichmediaHtml } from './RichmediaPreview';
43
43
  export { RichMessageEditor, RichMessageViewer, type DynamicContent, } from './RichMessageEditor';
44
- export { FrequencyCappingEdit, FrequencyCappingReadonly, type LocalCapping, } from './FrequencyCapping';
44
+ export { FrequencyCappingEdit, FrequencyCappingReadonly, FrequencyCappingInApps, type LocalCapping, type CappingInAppBase, } from './FrequencyCapping';
45
45
  export { SendRateEdit, SendRateReadonly, type SendRateBase, type SendRateEditProps, type SendRateReadonlyProps, } from './SendRate';
46
46
  export { Alert } from './Alert';
47
47
  export { ApplicationPreloader, type ApplicationPreloaderProps, } from './ApplicationPreloader';
package/index.js CHANGED
@@ -41,7 +41,7 @@ export { EnhancedInput, SearchInput } from './EnhancedInput';
41
41
  export { Chip } from './Chip';
42
42
  export { RichmediaPreview, useRichmediaHtml } from './RichmediaPreview';
43
43
  export { RichMessageEditor, RichMessageViewer } from './RichMessageEditor';
44
- export { FrequencyCappingEdit, FrequencyCappingReadonly } from './FrequencyCapping';
44
+ export { FrequencyCappingEdit, FrequencyCappingReadonly, FrequencyCappingInApps } from './FrequencyCapping';
45
45
  export { SendRateEdit, SendRateReadonly } from './SendRate';
46
46
  export { Alert } from './Alert';
47
47
  export { ApplicationPreloader } from './ApplicationPreloader';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.107",
3
+ "version": "1.1.109",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",