@pushwoosh/smart-components-kit 1.3.6 → 1.3.8
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/LanguagesSelector/LanguagesModal.d.ts +2 -0
- package/LanguagesSelector/LanguagesModal.js +4 -2
- package/LanguagesSelector/LanguagesSelectFormLoader.d.ts +2 -0
- package/LanguagesSelector/LanguagesSelectFormLoader.js +5 -3
- package/LanguagesSelector/LanguagesSelector.d.ts +3 -0
- package/LanguagesSelector/LanguagesSelector.js +3 -1
- package/LanguagesSelector/index.d.ts +1 -0
- package/LanguagesSelector/index.js +2 -1
- package/LanguagesSelector/platforms.d.ts +13 -0
- package/LanguagesSelector/platforms.js +14 -0
- package/mmsAttachments/index.d.ts +1 -1
- package/mmsAttachments/index.js +1 -1
- package/mmsAttachments/rules.d.ts +6 -6
- package/mmsAttachments/rules.js +8 -8
- package/package.json +2 -2
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type FC } from 'react';
|
|
2
|
+
import { type AllPlatforms } from '@pushwoosh/kit-constants';
|
|
2
3
|
type LanguagesModalProps = {
|
|
3
4
|
applicationCode: string;
|
|
4
5
|
initialLanguages: string[];
|
|
5
6
|
onSubmit: (languages: string[]) => void;
|
|
6
7
|
onClose: () => void;
|
|
8
|
+
platforms?: AllPlatforms[];
|
|
7
9
|
};
|
|
8
10
|
export declare const LanguagesModal: FC<LanguagesModalProps>;
|
|
9
11
|
export {};
|
|
@@ -9,7 +9,8 @@ export const LanguagesModal = ({
|
|
|
9
9
|
applicationCode,
|
|
10
10
|
initialLanguages,
|
|
11
11
|
onSubmit,
|
|
12
|
-
onClose
|
|
12
|
+
onClose,
|
|
13
|
+
platforms
|
|
13
14
|
}) => {
|
|
14
15
|
const lang = useLang();
|
|
15
16
|
const [selectedLanguages, setSelectedLanguages] = useState(initialLanguages);
|
|
@@ -24,7 +25,8 @@ export const LanguagesModal = ({
|
|
|
24
25
|
children: _jsx(LanguagesSelectFormLoader, {
|
|
25
26
|
application: applicationCode,
|
|
26
27
|
onChange: setSelectedLanguages,
|
|
27
|
-
value: selectedLanguages
|
|
28
|
+
value: selectedLanguages,
|
|
29
|
+
platforms: platforms
|
|
28
30
|
})
|
|
29
31
|
}), _jsx(ModalFooter, {
|
|
30
32
|
children: _jsxs(Horizontal, {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type FC } from 'react';
|
|
2
|
+
import { type AllPlatforms } from '@pushwoosh/kit-constants';
|
|
2
3
|
type LanguagesSelectFormLoaderProps = {
|
|
3
4
|
application: string;
|
|
4
5
|
value: string[];
|
|
5
6
|
onChange: (languages: string[]) => void;
|
|
6
7
|
systemLanguage?: string;
|
|
8
|
+
platforms?: AllPlatforms[];
|
|
7
9
|
};
|
|
8
10
|
export declare const LanguagesSelectFormLoader: FC<LanguagesSelectFormLoaderProps>;
|
|
9
11
|
export {};
|
|
@@ -9,7 +9,8 @@ export const LanguagesSelectFormLoader = ({
|
|
|
9
9
|
application,
|
|
10
10
|
value,
|
|
11
11
|
onChange,
|
|
12
|
-
systemLanguage = 'en'
|
|
12
|
+
systemLanguage = 'en',
|
|
13
|
+
platforms
|
|
13
14
|
}) => {
|
|
14
15
|
const getLangName = useGetLangName(systemLanguage);
|
|
15
16
|
const {
|
|
@@ -20,7 +21,8 @@ export const LanguagesSelectFormLoader = ({
|
|
|
20
21
|
values
|
|
21
22
|
} = await rpcGateway.tags.GetTagValues({
|
|
22
23
|
application,
|
|
23
|
-
name: 'Language'
|
|
24
|
+
name: 'Language',
|
|
25
|
+
platforms
|
|
24
26
|
});
|
|
25
27
|
const valuesLangCodes = values.map(v => canonicalizeLangCode(v.value));
|
|
26
28
|
const allLangCodes = Array.from(new Set([...valuesLangCodes, ...langCodes.map(canonicalizeLangCode)]).values());
|
|
@@ -33,7 +35,7 @@ export const LanguagesSelectFormLoader = ({
|
|
|
33
35
|
name: getLangName(code),
|
|
34
36
|
subscribers: values.find(val => canonicalizeLangCode(val.value) === code)?.count || 0
|
|
35
37
|
}));
|
|
36
|
-
}, [application, getLangName, systemLanguage]);
|
|
38
|
+
}, [application, getLangName, systemLanguage, platforms]);
|
|
37
39
|
if (langAsync.loading) {
|
|
38
40
|
return _jsx(Horizontal, {
|
|
39
41
|
"$placeItems": "center",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type FC } from 'react';
|
|
2
|
+
import { type AllPlatforms } from '@pushwoosh/kit-constants';
|
|
2
3
|
type SelectLanguageProps = {
|
|
3
4
|
applicationCode: string;
|
|
4
5
|
value: string;
|
|
@@ -6,6 +7,8 @@ type SelectLanguageProps = {
|
|
|
6
7
|
isDisabled?: boolean;
|
|
7
8
|
onChange: (language: string) => void;
|
|
8
9
|
onChangeLanguages: (languages: string[]) => void;
|
|
10
|
+
/** Count subscribers on these platforms only; see LANGUAGE_PLATFORMS. */
|
|
11
|
+
platforms?: AllPlatforms[];
|
|
9
12
|
};
|
|
10
13
|
export declare const LanguagesSelector: FC<SelectLanguageProps>;
|
|
11
14
|
export {};
|
|
@@ -13,7 +13,8 @@ export const LanguagesSelector = ({
|
|
|
13
13
|
languages,
|
|
14
14
|
isDisabled,
|
|
15
15
|
onChange,
|
|
16
|
-
onChangeLanguages
|
|
16
|
+
onChangeLanguages,
|
|
17
|
+
platforms
|
|
17
18
|
}) => {
|
|
18
19
|
const [showLanguagesModal, setShowLanguagesModal] = useState(false);
|
|
19
20
|
const lang = useLang();
|
|
@@ -107,6 +108,7 @@ export const LanguagesSelector = ({
|
|
|
107
108
|
children: _jsx(LanguagesModal, {
|
|
108
109
|
applicationCode: applicationCode,
|
|
109
110
|
initialLanguages: languages,
|
|
111
|
+
platforms: platforms,
|
|
110
112
|
onSubmit: langs => {
|
|
111
113
|
onChangeLanguages(langs);
|
|
112
114
|
setShowLanguagesModal(false);
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { LanguagesSelector } from './LanguagesSelector';
|
|
1
|
+
export { LanguagesSelector } from './LanguagesSelector';
|
|
2
|
+
export { LANGUAGE_PLATFORMS } from './platforms';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AllPlatforms } from '@pushwoosh/kit-constants';
|
|
2
|
+
/**
|
|
3
|
+
* Platforms a channel delivers to, so its language list counts only those
|
|
4
|
+
* devices. Wallet passes are out of inApp: they render no in-app content.
|
|
5
|
+
*/
|
|
6
|
+
export declare const LANGUAGE_PLATFORMS: {
|
|
7
|
+
email: AllPlatforms.Email[];
|
|
8
|
+
sms: AllPlatforms.SMS[];
|
|
9
|
+
line: AllPlatforms.Line[];
|
|
10
|
+
whatsApp: AllPlatforms.WhatsApp[];
|
|
11
|
+
push: AllPlatforms[];
|
|
12
|
+
inApp: (AllPlatforms.IOS | AllPlatforms.Blackberry | AllPlatforms.Android | AllPlatforms.Asha | AllPlatforms.WindowsPhone | AllPlatforms.Bada | AllPlatforms.OSX | AllPlatforms.Windows | AllPlatforms.Amazon | AllPlatforms.Safari | AllPlatforms.Chrome | AllPlatforms.Firefox | AllPlatforms.IE | AllPlatforms.Email | AllPlatforms.FBMessenger | AllPlatforms.BaiduAndroid | AllPlatforms.HuaweiAndroid | AllPlatforms.SMS | AllPlatforms.Xiaomi | AllPlatforms.Web | AllPlatforms.WhatsApp | AllPlatforms.Line | AllPlatforms.KakaoTalk | AllPlatforms.Telegram | AllPlatforms.Viber)[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AllPlatforms } from '@pushwoosh/kit-constants';
|
|
2
|
+
const PUSH_PLATFORMS = [AllPlatforms.IOS, AllPlatforms.Android, AllPlatforms.HuaweiAndroid, AllPlatforms.BaiduAndroid, AllPlatforms.Amazon, AllPlatforms.OSX, AllPlatforms.Windows, AllPlatforms.Safari, AllPlatforms.Chrome, AllPlatforms.Firefox, AllPlatforms.IE, AllPlatforms.Web, AllPlatforms.AppleWallet, AllPlatforms.GoogleWallet];
|
|
3
|
+
/**
|
|
4
|
+
* Platforms a channel delivers to, so its language list counts only those
|
|
5
|
+
* devices. Wallet passes are out of inApp: they render no in-app content.
|
|
6
|
+
*/
|
|
7
|
+
export const LANGUAGE_PLATFORMS = {
|
|
8
|
+
email: [AllPlatforms.Email],
|
|
9
|
+
sms: [AllPlatforms.SMS],
|
|
10
|
+
line: [AllPlatforms.Line],
|
|
11
|
+
whatsApp: [AllPlatforms.WhatsApp],
|
|
12
|
+
push: PUSH_PLATFORMS,
|
|
13
|
+
inApp: PUSH_PLATFORMS.filter(platform => platform !== AllPlatforms.AppleWallet && platform !== AllPlatforms.GoogleWallet)
|
|
14
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MMS_ALLOWED_EXTENSIONS, MMS_MAX_ATTACHMENTS,
|
|
1
|
+
export { MMS_ALLOWED_EXTENSIONS, MMS_MAX_ATTACHMENTS, MMS_MAX_FILE_SIZE_BYTES, MMS_SUBJECT_MAX_ASCII_LENGTH, MMS_SUBJECT_MAX_UNICODE_LENGTH, getMmsSubjectLength, getMmsSubjectMaxLength, isMmsAttachmentOversized, isMmsAttachmentUrl, isMmsMessageAtValid, isMmsSubjectTooLong, } from './rules';
|
package/mmsAttachments/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MMS_ALLOWED_EXTENSIONS, MMS_MAX_ATTACHMENTS,
|
|
1
|
+
export { MMS_ALLOWED_EXTENSIONS, MMS_MAX_ATTACHMENTS, MMS_MAX_FILE_SIZE_BYTES, MMS_SUBJECT_MAX_ASCII_LENGTH, MMS_SUBJECT_MAX_UNICODE_LENGTH, getMmsSubjectLength, getMmsSubjectMaxLength, isMmsAttachmentOversized, isMmsAttachmentUrl, isMmsMessageAtValid, isMmsSubjectTooLong } from './rules';
|
|
@@ -8,20 +8,20 @@ export declare const MMS_SUBJECT_MAX_ASCII_LENGTH = 40;
|
|
|
8
8
|
export declare const MMS_SUBJECT_MAX_UNICODE_LENGTH = 13;
|
|
9
9
|
export declare const MMS_ALLOWED_EXTENSIONS: string[];
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* The provider rejects anything heavier, so an oversized attachment fails the whole send.
|
|
12
|
+
* Media-library sizes are not always known, so the forms warn on it instead of blocking.
|
|
13
13
|
*/
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const MMS_MAX_FILE_SIZE_BYTES: number;
|
|
15
15
|
/**
|
|
16
16
|
* The provider downloads the attachment itself, so it has to be a public https url whose
|
|
17
17
|
* *path* ends with a supported image extension. Checking the path (not the whole url) matches
|
|
18
18
|
* the backend and keeps query strings — signatures, cache busters — from passing as extensions.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* PNG, JPEG, WebP and the legacy media-library files stored without an extension drop out
|
|
21
|
+
* here: all of them are fetchable, none is decoded by the provider.
|
|
22
22
|
*/
|
|
23
23
|
export declare const isMmsAttachmentUrl: (url: string) => boolean;
|
|
24
|
-
/** Whether the file is
|
|
24
|
+
/** Whether the file is over the provider's size limit and will be rejected on send. */
|
|
25
25
|
export declare const isMmsAttachmentOversized: (file: MediaFile) => boolean;
|
|
26
26
|
/**
|
|
27
27
|
* Subject length budget: the provider counts non-ASCII subjects against a much shorter
|
package/mmsAttachments/rules.js
CHANGED
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
export const MMS_MAX_ATTACHMENTS = 3;
|
|
6
6
|
export const MMS_SUBJECT_MAX_ASCII_LENGTH = 40;
|
|
7
7
|
export const MMS_SUBJECT_MAX_UNICODE_LENGTH = 13;
|
|
8
|
-
export const MMS_ALLOWED_EXTENSIONS = ['.jpg', '.
|
|
8
|
+
export const MMS_ALLOWED_EXTENSIONS = ['.jpg', '.gif'];
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* The provider rejects anything heavier, so an oversized attachment fails the whole send.
|
|
11
|
+
* Media-library sizes are not always known, so the forms warn on it instead of blocking.
|
|
12
12
|
*/
|
|
13
|
-
export const
|
|
13
|
+
export const MMS_MAX_FILE_SIZE_BYTES = 200 * 1024;
|
|
14
14
|
/**
|
|
15
15
|
* The provider downloads the attachment itself, so it has to be a public https url whose
|
|
16
16
|
* *path* ends with a supported image extension. Checking the path (not the whole url) matches
|
|
17
17
|
* the backend and keeps query strings — signatures, cache busters — from passing as extensions.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
19
|
+
* PNG, JPEG, WebP and the legacy media-library files stored without an extension drop out
|
|
20
|
+
* here: all of them are fetchable, none is decoded by the provider.
|
|
21
21
|
*/
|
|
22
22
|
export const isMmsAttachmentUrl = url => {
|
|
23
23
|
let parsed;
|
|
@@ -30,8 +30,8 @@ export const isMmsAttachmentUrl = url => {
|
|
|
30
30
|
const path = parsed.pathname.toLowerCase();
|
|
31
31
|
return MMS_ALLOWED_EXTENSIONS.some(extension => path.endsWith(extension));
|
|
32
32
|
};
|
|
33
|
-
/** Whether the file is
|
|
34
|
-
export const isMmsAttachmentOversized = file => file.fileSize >
|
|
33
|
+
/** Whether the file is over the provider's size limit and will be rejected on send. */
|
|
34
|
+
export const isMmsAttachmentOversized = file => file.fileSize > MMS_MAX_FILE_SIZE_BYTES;
|
|
35
35
|
/**
|
|
36
36
|
* Subject length budget: the provider counts non-ASCII subjects against a much shorter
|
|
37
37
|
* limit, so a single non-ASCII character drops the whole subject to 13.
|
package/package.json
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@pushwoosh/kit-helpers": "^4.12.0",
|
|
30
30
|
"@pushwoosh/kit-icons": "^2.1.22",
|
|
31
31
|
"@pushwoosh/kit-typography": "^1.7.6",
|
|
32
|
-
"@pushwoosh/rpc-v2-http-api-data": "^0.2.
|
|
32
|
+
"@pushwoosh/rpc-v2-http-api-data": "^0.2.114",
|
|
33
33
|
"@pushwoosh/spa-context": "^1.7.1",
|
|
34
34
|
"idb-keyval": "^6.2.2",
|
|
35
35
|
"react-hook-form": "^7.68.0",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"react": "^16.14.0 || ^18.0.0",
|
|
53
53
|
"react-dom": "^16.14.0 || ^18.0.0"
|
|
54
54
|
},
|
|
55
|
-
"version": "1.3.
|
|
55
|
+
"version": "1.3.8"
|
|
56
56
|
}
|