@beabee/beabee-common 0.20.1 → 0.20.2-alpha.1
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/dist/cjs/data/payment-method.cjs +1 -0
- package/dist/cjs/index.cjs +0 -1
- package/dist/cjs/search/callouts.cjs +5 -2
- package/dist/cjs/types/{callout-navigation-schema.cjs → callout-response-answers.cjs} +2 -2
- package/dist/cjs/types/{callout-form-schema.cjs → get-callout-form-schema.cjs} +2 -2
- package/dist/cjs/types/{callout-response-answers-nestable.cjs → get-callout-navigation-schema.cjs} +2 -2
- package/dist/cjs/types/get-callout-slide-schema.cjs +16 -0
- package/dist/cjs/types/index.cjs +14 -8
- package/dist/cjs/types/{callout-slide-schema.cjs → set-callout-form-schema.cjs} +2 -2
- package/dist/cjs/types/set-callout-navigation-schema.cjs +16 -0
- package/dist/cjs/types/set-callout-slide-schema.cjs +16 -0
- package/dist/cjs/utils/payments.cjs +7 -3
- package/dist/cjs/validators/callout-component-input-address.validator.cjs +1 -5
- package/dist/cjs/validators/callout-component-input-checkbox.validator.cjs +1 -5
- package/dist/cjs/validators/callout-component-input-currency.validator.cjs +1 -5
- package/dist/cjs/validators/callout-component-input-date-time.validator.cjs +0 -4
- package/dist/cjs/validators/callout-component-input-email.validator.cjs +1 -9
- package/dist/cjs/validators/callout-component-input-file.validator.cjs +5 -5
- package/dist/cjs/validators/callout-component-input-number.validator.cjs +0 -4
- package/dist/cjs/validators/callout-component-input-phone-number.validator.cjs +1 -5
- package/dist/cjs/validators/callout-component-input-select.validator.cjs +0 -9
- package/dist/cjs/validators/callout-component-input-selectable.validator.cjs +0 -12
- package/dist/cjs/validators/callout-component-input-text.validator.cjs +4 -5
- package/dist/cjs/validators/callout-component-input-time.validator.cjs +1 -5
- package/dist/cjs/validators/callout-component-input-url.validator.cjs +1 -9
- package/dist/cjs/validators/callout-component.validator.cjs +46 -32
- package/dist/esm/data/payment-method.js +1 -0
- package/dist/esm/search/callouts.js +5 -2
- package/dist/esm/types/index.js +7 -4
- package/dist/esm/types/set-callout-form-schema.js +0 -0
- package/dist/esm/types/set-callout-navigation-schema.js +0 -0
- package/dist/esm/types/set-callout-slide-schema.js +0 -0
- package/dist/esm/utils/payments.js +7 -3
- package/dist/esm/validators/callout-component-input-address.validator.js +1 -4
- package/dist/esm/validators/callout-component-input-checkbox.validator.js +1 -4
- package/dist/esm/validators/callout-component-input-currency.validator.js +1 -4
- package/dist/esm/validators/callout-component-input-date-time.validator.js +0 -3
- package/dist/esm/validators/callout-component-input-email.validator.js +2 -9
- package/dist/esm/validators/callout-component-input-file.validator.js +5 -4
- package/dist/esm/validators/callout-component-input-number.validator.js +0 -3
- package/dist/esm/validators/callout-component-input-phone-number.validator.js +1 -4
- package/dist/esm/validators/callout-component-input-select.validator.js +0 -8
- package/dist/esm/validators/callout-component-input-selectable.validator.js +0 -11
- package/dist/esm/validators/callout-component-input-text.validator.js +4 -4
- package/dist/esm/validators/callout-component-input-time.validator.js +1 -4
- package/dist/esm/validators/callout-component-input-url.validator.js +2 -9
- package/dist/esm/validators/callout-component.validator.js +48 -33
- package/dist/types/data/payment-method.d.ts +1 -0
- package/dist/types/search/callouts.d.ts +5 -2
- package/dist/types/types/callout-component-base-input-schema.d.ts +2 -0
- package/dist/types/types/callout-component-base-schema.d.ts +1 -1
- package/dist/types/types/callout-component-content-schema.d.ts +7 -0
- package/dist/types/types/callout-component-input-address-schema.d.ts +2 -0
- package/dist/types/types/callout-component-input-phone-number-schema.d.ts +2 -0
- package/dist/types/types/callout-component-input-select-schema.d.ts +2 -0
- package/dist/types/types/callout-response-answer.d.ts +1 -1
- package/dist/types/types/callout-response-answers-slide.d.ts +2 -2
- package/dist/types/types/callout-response-answers.d.ts +5 -0
- package/dist/types/types/get-callout-form-schema.d.ts +5 -0
- package/dist/types/types/get-callout-navigation-schema.d.ts +6 -0
- package/dist/types/types/get-callout-slide-schema.d.ts +4 -0
- package/dist/types/types/index.d.ts +7 -4
- package/dist/types/types/set-callout-form-schema.d.ts +4 -0
- package/dist/types/types/set-callout-navigation-schema.d.ts +3 -0
- package/dist/types/types/set-callout-slide-schema.d.ts +7 -0
- package/dist/types/types/validator-callout-component.d.ts +2 -2
- package/dist/types/utils/callouts.d.ts +5 -5
- package/dist/types/validators/callout-component-content.validator.d.ts +1 -1
- package/dist/types/validators/callout-component.validator.d.ts +5 -3
- package/package.json +12 -4
- package/dist/types/types/callout-form-schema.d.ts +0 -4
- package/dist/types/types/callout-navigation-schema.d.ts +0 -6
- package/dist/types/types/callout-response-answers-nestable.d.ts +0 -5
- package/dist/types/types/callout-slide-schema.d.ts +0 -7
- /package/dist/esm/types/{callout-form-schema.js → callout-response-answers.js} +0 -0
- /package/dist/esm/types/{callout-navigation-schema.js → get-callout-form-schema.js} +0 -0
- /package/dist/esm/types/{callout-response-answers-nestable.js → get-callout-navigation-schema.js} +0 -0
- /package/dist/esm/types/{callout-slide-schema.js → get-callout-slide-schema.js} +0 -0
|
@@ -3,19 +3,23 @@ const stripeFees = {
|
|
|
3
3
|
gb: {
|
|
4
4
|
[PaymentMethod.StripeCard]: (amount) => 0.2 + 0.015 * amount,
|
|
5
5
|
[PaymentMethod.StripeSEPA]: () => 0.3,
|
|
6
|
-
[PaymentMethod.StripeBACS]: (amount) => Math.min(2, Math.max(0.2, 0.01 * amount))
|
|
6
|
+
[PaymentMethod.StripeBACS]: (amount) => Math.min(2, Math.max(0.2, 0.01 * amount)),
|
|
7
|
+
[PaymentMethod.StripePayPal]: (amount) => 0.1 + 0.02 * amount
|
|
7
8
|
},
|
|
8
9
|
eu: {
|
|
9
10
|
[PaymentMethod.StripeCard]: (amount) => 0.25 + 0.015 * amount,
|
|
10
11
|
[PaymentMethod.StripeSEPA]: () => 0.35,
|
|
11
|
-
[PaymentMethod.StripeBACS]: () => 0
|
|
12
|
+
[PaymentMethod.StripeBACS]: () => 0,
|
|
12
13
|
// Not available
|
|
14
|
+
[PaymentMethod.StripePayPal]: (amount) => 0.1 + 0.02 * amount
|
|
13
15
|
},
|
|
14
16
|
ca: {
|
|
15
17
|
[PaymentMethod.StripeCard]: (amount) => 0.3 + 0.029 * amount,
|
|
16
18
|
[PaymentMethod.StripeSEPA]: () => 0,
|
|
17
19
|
// Not available
|
|
18
|
-
[PaymentMethod.StripeBACS]: () => 0
|
|
20
|
+
[PaymentMethod.StripeBACS]: () => 0,
|
|
21
|
+
// Not available
|
|
22
|
+
[PaymentMethod.StripePayPal]: () => 0
|
|
19
23
|
// Not available
|
|
20
24
|
}
|
|
21
25
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
const calloutComponentInputAddressValidator = (
|
|
2
|
-
if (!schema.validate?.required && answer === void 0) {
|
|
3
|
-
return true;
|
|
4
|
-
}
|
|
1
|
+
const calloutComponentInputAddressValidator = (_schema, _answer) => {
|
|
5
2
|
throw new Error(
|
|
6
3
|
`[calloutComponentInputAddressValidator] Not implemented yet`
|
|
7
4
|
);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { isAmountOfMoney } from "../utils/index.js";
|
|
2
|
-
const calloutComponentInputCurrencyValidator = (
|
|
3
|
-
if (schema.validate?.required && answer === void 0) {
|
|
4
|
-
return true;
|
|
5
|
-
}
|
|
2
|
+
const calloutComponentInputCurrencyValidator = (_schema, answer) => {
|
|
6
3
|
return isAmountOfMoney(answer);
|
|
7
4
|
};
|
|
8
5
|
export {
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const calloutComponentInputEmailValidator = (schema, answer) => {
|
|
4
|
-
if (!isCalloutComponentOfType(schema, CalloutComponentType.INPUT_EMAIL)) {
|
|
5
|
-
throw new Error("Schema is not a email component");
|
|
6
|
-
}
|
|
7
|
-
if (!schema.validate?.required && answer === void 0) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
1
|
+
import { isEmail } from "../utils/index.js";
|
|
2
|
+
const calloutComponentInputEmailValidator = (_schema, answer) => {
|
|
10
3
|
return isEmail(answer);
|
|
11
4
|
};
|
|
12
5
|
export {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { isURL } from "../utils/index.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { isFileUploadAnswer } from "../utils/callouts.js";
|
|
3
|
+
const calloutComponentInputFileValidator = (_schema, answer) => {
|
|
4
|
+
if (isFileUploadAnswer(answer)) {
|
|
5
|
+
return isURL(answer.url);
|
|
5
6
|
}
|
|
6
|
-
return
|
|
7
|
+
return false;
|
|
7
8
|
};
|
|
8
9
|
export {
|
|
9
10
|
calloutComponentInputFileValidator
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { isNumber, isNumberInRange } from "../utils/index.js";
|
|
2
2
|
const calloutComponentInputNumberValidator = (schema, answer) => {
|
|
3
|
-
if (!schema.validate?.required && answer === void 0) {
|
|
4
|
-
return true;
|
|
5
|
-
}
|
|
6
3
|
if (schema.validate && !isNumberInRange(answer, schema.validate.min, schema.validate.max)) {
|
|
7
4
|
return false;
|
|
8
5
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { isPhoneNumber } from "../utils/index.js";
|
|
2
|
-
const calloutComponentInputPhoneNumberValidator = (
|
|
3
|
-
if (!schema.validate?.required && answer === void 0) {
|
|
4
|
-
return true;
|
|
5
|
-
}
|
|
2
|
+
const calloutComponentInputPhoneNumberValidator = (_schema, answer) => {
|
|
6
3
|
return isPhoneNumber(answer);
|
|
7
4
|
};
|
|
8
5
|
export {
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import { isCalloutComponentOfType } from "../utils/index.js";
|
|
2
|
-
import { CalloutComponentType } from "../data/index.js";
|
|
3
1
|
const calloutComponentInputSelectValidator = (schema, answer) => {
|
|
4
|
-
if (!isCalloutComponentOfType(schema, CalloutComponentType.INPUT_SELECT)) {
|
|
5
|
-
throw new Error("Schema is not a select component");
|
|
6
|
-
}
|
|
7
|
-
if (!schema.validate?.required && !answer) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
2
|
const optionValue = schema.data.values.find((v) => v.value === answer);
|
|
11
3
|
return !!optionValue;
|
|
12
4
|
};
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import { isCalloutComponentOfBaseType } from "../utils/index.js";
|
|
2
|
-
import { CalloutComponentBaseType } from "../data/index.js";
|
|
3
1
|
const calloutComponentInputSelectableValidator = (schema, answer) => {
|
|
4
|
-
if (!isCalloutComponentOfBaseType(
|
|
5
|
-
schema,
|
|
6
|
-
CalloutComponentBaseType.INPUT_SELECTABLE
|
|
7
|
-
)) {
|
|
8
|
-
throw new Error("Schema is not a selectable component");
|
|
9
|
-
}
|
|
10
|
-
if (!schema.validate?.required && !answer) {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
2
|
const optionValue = schema.values.find((v) => v.value === answer);
|
|
14
3
|
return !!optionValue;
|
|
15
4
|
};
|
|
@@ -3,7 +3,10 @@ const validateRules = (rules, answer) => {
|
|
|
3
3
|
if (!rules) {
|
|
4
4
|
return true;
|
|
5
5
|
}
|
|
6
|
-
if (
|
|
6
|
+
if (!answer && rules.required) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (typeof rules.pattern === "string" && rules.pattern.length && !new RegExp(rules.pattern).test(answer || "")) {
|
|
7
10
|
return false;
|
|
8
11
|
}
|
|
9
12
|
if (!isTextInWordRange(answer, rules.minWords, rules.maxWords)) {
|
|
@@ -15,9 +18,6 @@ const validateRules = (rules, answer) => {
|
|
|
15
18
|
return true;
|
|
16
19
|
};
|
|
17
20
|
const calloutComponentInputTextValidator = (schema, answer) => {
|
|
18
|
-
if (!schema.validate?.required && !answer) {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
21
|
if (typeof answer !== "string") {
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
const calloutComponentInputTimeValidator = (
|
|
2
|
-
if (!schema.validate?.required && answer === void 0) {
|
|
3
|
-
return true;
|
|
4
|
-
}
|
|
1
|
+
const calloutComponentInputTimeValidator = (_schema, _answer) => {
|
|
5
2
|
throw new Error(
|
|
6
3
|
`[calloutComponentInputTimeValidator] Not implemented yet`
|
|
7
4
|
);
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const calloutComponentInputUrlValidator = (schema, answer) => {
|
|
4
|
-
if (!isCalloutComponentOfType(schema, CalloutComponentType.INPUT_URL)) {
|
|
5
|
-
throw new Error("Schema is not a url component");
|
|
6
|
-
}
|
|
7
|
-
if (!schema.validate?.required && answer === void 0) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
1
|
+
import { isURL } from "../utils/index.js";
|
|
2
|
+
const calloutComponentInputUrlValidator = (_schema, answer) => {
|
|
10
3
|
return isURL(answer);
|
|
11
4
|
};
|
|
12
5
|
export {
|
|
@@ -13,31 +13,24 @@ import { calloutComponentInputSignatureValidator } from "./callout-component-inp
|
|
|
13
13
|
import { calloutComponentInputTextValidator } from "./callout-component-input-text.validator.js";
|
|
14
14
|
import { calloutComponentInputTimeValidator } from "./callout-component-input-time.validator.js";
|
|
15
15
|
import { calloutComponentInputUrlValidator } from "./callout-component-input-url.validator.js";
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
import {
|
|
17
|
+
CalloutComponentBaseType,
|
|
18
|
+
CalloutComponentType
|
|
19
|
+
} from "../data/index.js";
|
|
20
|
+
import { isCalloutComponentOfBaseType } from "../utils/callouts.js";
|
|
21
|
+
const calloutComponentNestableValidator = (schema, answers) => {
|
|
19
22
|
for (const component of schema.components) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
for (const _answersLevel2 of answers) {
|
|
28
|
-
const answersLevel2 = Array.isArray(_answersLevel2) ? _answersLevel2 : [_answersLevel2];
|
|
29
|
-
for (const answer2 of answersLevel2) {
|
|
30
|
-
valid = calloutComponentValidator(component, answer2) && valid;
|
|
31
|
-
if (!valid) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
23
|
+
const valid = calloutComponentValidator(
|
|
24
|
+
component,
|
|
25
|
+
answers[component.key]
|
|
26
|
+
);
|
|
27
|
+
if (!valid) {
|
|
28
|
+
return false;
|
|
35
29
|
}
|
|
36
30
|
}
|
|
37
|
-
return
|
|
31
|
+
return true;
|
|
38
32
|
};
|
|
39
|
-
const
|
|
40
|
-
[CalloutComponentType.CONTENT]: calloutComponentContentValidator,
|
|
33
|
+
const calloutInputValidatorsMap = {
|
|
41
34
|
// Input
|
|
42
35
|
[CalloutComponentType.INPUT_EMAIL]: calloutComponentInputEmailValidator,
|
|
43
36
|
[CalloutComponentType.INPUT_ADDRESS]: calloutComponentInputAddressValidator,
|
|
@@ -56,24 +49,46 @@ const calloutValidatorsMap = {
|
|
|
56
49
|
[CalloutComponentType.INPUT_TEXT_AREA]: calloutComponentInputTextValidator,
|
|
57
50
|
// Selectable
|
|
58
51
|
[CalloutComponentType.INPUT_SELECTABLE_RADIO]: calloutComponentInputSelectableValidator,
|
|
59
|
-
[CalloutComponentType.INPUT_SELECTABLE_SELECTBOXES]: calloutComponentInputSelectableValidator
|
|
60
|
-
// NESTABLE
|
|
61
|
-
[CalloutComponentType.NESTABLE_PANEL]: calloutComponentNestableValidator,
|
|
62
|
-
[CalloutComponentType.NESTABLE_WELL]: calloutComponentNestableValidator,
|
|
63
|
-
[CalloutComponentType.NESTABLE_TABS]: calloutComponentNestableValidator
|
|
52
|
+
[CalloutComponentType.INPUT_SELECTABLE_SELECTBOXES]: calloutComponentInputSelectableValidator
|
|
64
53
|
};
|
|
65
|
-
|
|
66
|
-
const validator =
|
|
54
|
+
function calloutComponentInputValidator(schema, answer) {
|
|
55
|
+
const validator = calloutInputValidatorsMap[schema.type];
|
|
67
56
|
if (!validator) {
|
|
68
57
|
console.error(`No validator found for ${schema.type}`);
|
|
69
58
|
return false;
|
|
70
59
|
}
|
|
71
|
-
|
|
72
|
-
schema
|
|
73
|
-
|
|
74
|
-
);
|
|
75
|
-
|
|
60
|
+
if (answer === void 0) {
|
|
61
|
+
return schema.validate?.required ? false : true;
|
|
62
|
+
}
|
|
63
|
+
const values = Array.isArray(answer) ? answer : [answer];
|
|
64
|
+
for (const value of values) {
|
|
65
|
+
const valid = validator(schema, value);
|
|
66
|
+
if (!valid) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
function calloutComponentValidator(schema, answer) {
|
|
73
|
+
if (isCalloutComponentOfBaseType(schema, CalloutComponentBaseType.NESTABLE)) {
|
|
74
|
+
return calloutComponentNestableValidator(
|
|
75
|
+
schema,
|
|
76
|
+
answer
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
if (isCalloutComponentOfBaseType(schema, CalloutComponentBaseType.INPUT)) {
|
|
80
|
+
return calloutComponentInputValidator(
|
|
81
|
+
schema,
|
|
82
|
+
answer
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
if (isCalloutComponentOfBaseType(schema, CalloutComponentBaseType.CONTENT)) {
|
|
86
|
+
return calloutComponentContentValidator(schema, answer);
|
|
87
|
+
}
|
|
88
|
+
throw new Error("Invalid schema type");
|
|
89
|
+
}
|
|
76
90
|
export {
|
|
91
|
+
calloutComponentInputValidator,
|
|
77
92
|
calloutComponentNestableValidator,
|
|
78
93
|
calloutComponentValidator
|
|
79
94
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ItemStatus } from "../data/index.ts";
|
|
2
2
|
export declare const calloutFilters: {
|
|
3
|
+
readonly id: {
|
|
4
|
+
readonly type: "text";
|
|
5
|
+
};
|
|
3
6
|
readonly slug: {
|
|
4
7
|
readonly type: "text";
|
|
5
8
|
};
|
|
@@ -33,7 +36,7 @@ export declare const calloutResponseFilters: {
|
|
|
33
36
|
readonly type: "contact";
|
|
34
37
|
readonly nullable: true;
|
|
35
38
|
};
|
|
36
|
-
readonly
|
|
39
|
+
readonly calloutId: {
|
|
37
40
|
readonly type: "text";
|
|
38
41
|
};
|
|
39
42
|
readonly createdAt: {
|
|
@@ -87,7 +90,7 @@ export declare const calloutTagFilters: {
|
|
|
87
90
|
readonly description: {
|
|
88
91
|
readonly type: "text";
|
|
89
92
|
};
|
|
90
|
-
readonly
|
|
93
|
+
readonly calloutId: {
|
|
91
94
|
readonly type: "text";
|
|
92
95
|
};
|
|
93
96
|
};
|
|
@@ -14,7 +14,7 @@ export interface CalloutComponentBaseSchema {
|
|
|
14
14
|
/** True if multiple responses / answers allowed */
|
|
15
15
|
multiple?: boolean;
|
|
16
16
|
/** If defined then this is the default value */
|
|
17
|
-
defaultValue?: CalloutResponseAnswer | CalloutResponseAnswer[];
|
|
17
|
+
defaultValue?: CalloutResponseAnswer | CalloutResponseAnswer[] | null;
|
|
18
18
|
/** `true` if this component should be hidden */
|
|
19
19
|
hidden?: boolean;
|
|
20
20
|
/** Unused property */
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { CalloutComponentType } from "../data/index.ts";
|
|
2
2
|
import type { CalloutComponentBaseSchema } from "./index.ts";
|
|
3
|
+
/** A Callout content component only providing html content and accepts no answers. */
|
|
3
4
|
export interface CalloutComponentContentSchema extends CalloutComponentBaseSchema {
|
|
4
5
|
type: CalloutComponentType.CONTENT;
|
|
6
|
+
/** The html content of the callout component. */
|
|
7
|
+
html: string;
|
|
8
|
+
/** The label for this field that will appear next to it. */
|
|
9
|
+
label: string;
|
|
10
|
+
/** This is always false for content components. */
|
|
11
|
+
input: false;
|
|
5
12
|
}
|
|
@@ -4,4 +4,6 @@ export interface CalloutComponentInputAddressSchema extends CalloutComponentBase
|
|
|
4
4
|
type: CalloutComponentType.INPUT_ADDRESS;
|
|
5
5
|
/** The validation rules for the form */
|
|
6
6
|
validate?: CalloutComponentInputAddressRules;
|
|
7
|
+
/** Placeholder for the form */
|
|
8
|
+
placeholder?: string;
|
|
7
9
|
}
|
|
@@ -4,4 +4,6 @@ export interface CalloutComponentInputPhoneNumberSchema extends CalloutComponent
|
|
|
4
4
|
type: CalloutComponentType.INPUT_PHONE_NUMBER;
|
|
5
5
|
/** The validation rules for the form */
|
|
6
6
|
validate?: CalloutComponentInputPhoneNumberRules;
|
|
7
|
+
/** The placeholder for the component */
|
|
8
|
+
placeholder?: string;
|
|
7
9
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { CalloutResponseAnswerAddress, CalloutResponseAnswerFileUpload } from "./index.ts";
|
|
2
|
-
export type CalloutResponseAnswer = string | boolean | number |
|
|
2
|
+
export type CalloutResponseAnswer = string | boolean | number | Record<string, boolean> | CalloutResponseAnswerAddress | CalloutResponseAnswerFileUpload;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CalloutResponseAnswers } from "./index.ts";
|
|
2
2
|
/**
|
|
3
3
|
* Answers are grouped by slide key: `{[slideId]: {[componentKey]: answer | answer[]}}`
|
|
4
4
|
*/
|
|
5
|
-
export type CalloutResponseAnswersSlide = Record<string,
|
|
5
|
+
export type CalloutResponseAnswersSlide = Record<string, CalloutResponseAnswers | undefined>;
|
|
@@ -51,16 +51,13 @@ export * from "./callout-component-nestable-tabs-schema.ts";
|
|
|
51
51
|
export * from "./callout-component-nestable-well-schema.ts";
|
|
52
52
|
export * from "./callout-component-schema.ts";
|
|
53
53
|
export * from "./callout-filter-name.ts";
|
|
54
|
-
export * from "./callout-form-schema.ts";
|
|
55
|
-
export * from "./callout-navigation-schema.ts";
|
|
56
54
|
export * from "./callout-response-answer-address.ts";
|
|
57
55
|
export * from "./callout-response-answer-file-upload.ts";
|
|
58
56
|
export * from "./callout-response-answer.ts";
|
|
59
|
-
export * from "./callout-response-answers-nestable.ts";
|
|
60
57
|
export * from "./callout-response-answers-slide.ts";
|
|
58
|
+
export * from "./callout-response-answers.ts";
|
|
61
59
|
export * from "./callout-response-comment-filter-name.ts";
|
|
62
60
|
export * from "./callout-response-filter-name.ts";
|
|
63
|
-
export * from "./callout-slide-schema.ts";
|
|
64
61
|
export * from "./callout-tag-filter-name.ts";
|
|
65
62
|
export * from "./date-unit.ts";
|
|
66
63
|
export * from "./duration.ts";
|
|
@@ -69,6 +66,9 @@ export * from "./feeable.ts";
|
|
|
69
66
|
export * from "./filter-args.ts";
|
|
70
67
|
export * from "./filter-type.ts";
|
|
71
68
|
export * from "./filters.ts";
|
|
69
|
+
export * from "./get-callout-form-schema.ts";
|
|
70
|
+
export * from "./get-callout-navigation-schema.ts";
|
|
71
|
+
export * from "./get-callout-slide-schema.ts";
|
|
72
72
|
export * from "./notice-filter-name.ts";
|
|
73
73
|
export * from "./operators-by-type.ts";
|
|
74
74
|
export * from "./other-filter-args.ts";
|
|
@@ -82,6 +82,9 @@ export * from "./rule-opperator-params.ts";
|
|
|
82
82
|
export * from "./rule-value.ts";
|
|
83
83
|
export * from "./rule.ts";
|
|
84
84
|
export * from "./segment-filter-name.ts";
|
|
85
|
+
export * from "./set-callout-form-schema.ts";
|
|
86
|
+
export * from "./set-callout-navigation-schema.ts";
|
|
87
|
+
export * from "./set-callout-slide-schema.ts";
|
|
85
88
|
export * from "./stripe-fee-country.ts";
|
|
86
89
|
export * from "./text-case.ts";
|
|
87
90
|
export * from "./unit-matches.ts";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CalloutComponentBaseSchema } from "./index.ts";
|
|
2
|
-
export type ValidatorCalloutComponent<S extends CalloutComponentBaseSchema> = (schema: S, answer:
|
|
1
|
+
import type { CalloutComponentBaseSchema, CalloutResponseAnswer } from "./index.ts";
|
|
2
|
+
export type ValidatorCalloutComponent<S extends CalloutComponentBaseSchema, A = CalloutResponseAnswer> = (schema: S, answer: A) => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CalloutComponentBaseType, CalloutComponentType } from "../data/index.ts";
|
|
2
|
-
import type { CalloutComponentBaseMap, CalloutComponentBaseSchema, CalloutComponentMap, CalloutComponentSchema,
|
|
2
|
+
import type { CalloutComponentBaseMap, CalloutComponentBaseSchema, CalloutComponentMap, CalloutComponentSchema, CalloutResponseAnswer, CalloutResponseAnswerAddress, CalloutResponseAnswerFileUpload, FilterArgs, SetCalloutFormSchema } from "../types/index.ts";
|
|
3
3
|
/**
|
|
4
4
|
* Check if a component is a specific component type
|
|
5
5
|
*
|
|
@@ -18,13 +18,13 @@ export declare function isCalloutComponentOfType<T extends CalloutComponentType>
|
|
|
18
18
|
export declare function isCalloutComponentOfBaseType<T extends CalloutComponentBaseType>(component: CalloutComponentBaseSchema, type: T): component is CalloutComponentBaseMap[T];
|
|
19
19
|
export declare function flattenComponents(components: CalloutComponentSchema[]): CalloutComponentSchema[];
|
|
20
20
|
export declare function filterComponents(components: CalloutComponentSchema[], filterFn: (component: CalloutComponentSchema) => boolean): CalloutComponentSchema[];
|
|
21
|
-
export declare function getCalloutComponents(formSchema:
|
|
21
|
+
export declare function getCalloutComponents(formSchema: SetCalloutFormSchema): (CalloutComponentSchema & {
|
|
22
22
|
slideId: string;
|
|
23
23
|
fullKey: string;
|
|
24
24
|
})[];
|
|
25
|
-
export declare function getCalloutFilters(formSchema:
|
|
25
|
+
export declare function getCalloutFilters(formSchema: SetCalloutFormSchema): Record<string, FilterArgs & {
|
|
26
26
|
label: string;
|
|
27
27
|
}>;
|
|
28
28
|
export declare function isAddressAnswer(answer: CalloutResponseAnswer): answer is CalloutResponseAnswerAddress;
|
|
29
|
-
export declare function isFileUploadAnswer(answer: CalloutResponseAnswer): answer is CalloutResponseAnswerFileUpload;
|
|
30
|
-
export declare function stringifyAnswer(component: CalloutComponentSchema, answer: CalloutResponseAnswer | CalloutResponseAnswer[]): string;
|
|
29
|
+
export declare function isFileUploadAnswer(answer: CalloutResponseAnswer | undefined): answer is CalloutResponseAnswerFileUpload;
|
|
30
|
+
export declare function stringifyAnswer(component: CalloutComponentSchema, answer: CalloutResponseAnswer | CalloutResponseAnswer[] | undefined): string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { CalloutComponentContentSchema, ValidatorCalloutComponent } from "../types/index.ts";
|
|
2
|
-
export declare const calloutComponentContentValidator: ValidatorCalloutComponent<CalloutComponentContentSchema>;
|
|
2
|
+
export declare const calloutComponentContentValidator: ValidatorCalloutComponent<CalloutComponentContentSchema, unknown>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import type { CalloutComponentNestableSchema, CalloutComponentSchema, CalloutResponseAnswer,
|
|
2
|
-
export declare const calloutComponentNestableValidator:
|
|
3
|
-
export declare
|
|
1
|
+
import type { CalloutComponentInputSchema, CalloutComponentNestableSchema, CalloutComponentSchema, CalloutResponseAnswer, CalloutResponseAnswers } from "../types/index.ts";
|
|
2
|
+
export declare const calloutComponentNestableValidator: (schema: CalloutComponentNestableSchema, answers: CalloutResponseAnswers) => boolean;
|
|
3
|
+
export declare function calloutComponentInputValidator(schema: CalloutComponentInputSchema, answer: CalloutResponseAnswer | CalloutResponseAnswer[] | undefined): boolean;
|
|
4
|
+
export declare function calloutComponentValidator(schema: CalloutComponentSchema, answer: CalloutResponseAnswer | CalloutResponseAnswer[] | undefined): boolean;
|
|
5
|
+
export declare function calloutComponentValidator(schema: CalloutComponentNestableSchema, answer: CalloutResponseAnswers): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beabee/beabee-common",
|
|
3
|
-
"version": "0.20.1",
|
|
3
|
+
"version": "0.20.2-alpha.1",
|
|
4
4
|
"description": "Shared code between Beabee projects for Node.js, Deno and the browser",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.cjs",
|
|
@@ -29,7 +29,9 @@
|
|
|
29
29
|
"test": "deno task test",
|
|
30
30
|
"test:deno": "deno task test:deno",
|
|
31
31
|
"test:node": "deno task test:node",
|
|
32
|
-
"test:types": "
|
|
32
|
+
"test:types": "deno task test:types",
|
|
33
|
+
"test:deno:types": "deno task test:deno:types",
|
|
34
|
+
"test:node:types": "tsc --noEmit --emitDeclarationOnly false",
|
|
33
35
|
"test:node:esm": "node test/node/import.mjs",
|
|
34
36
|
"test:node:cjs": "node test/node/require.cjs",
|
|
35
37
|
"build": "deno task build",
|
|
@@ -39,7 +41,13 @@
|
|
|
39
41
|
"build:types": "tsc && echo 'export * from \"./index.ts\";' > dist/types/index.d.cts",
|
|
40
42
|
"generate:index": "deno task generate:index",
|
|
41
43
|
"sync": "deno task sync",
|
|
42
|
-
"prepublishOnly": "npm run build"
|
|
44
|
+
"prepublishOnly": "npm run build",
|
|
45
|
+
"cache": "deno task cache",
|
|
46
|
+
"cache:deno": "deno task cache:deno",
|
|
47
|
+
"cache:node": "deno task cache:node",
|
|
48
|
+
"check": "deno task check",
|
|
49
|
+
"check:format": "deno task check:format",
|
|
50
|
+
"check:types": "deno task check:types"
|
|
43
51
|
},
|
|
44
52
|
"repository": {
|
|
45
53
|
"type": "git",
|
|
@@ -56,6 +64,6 @@
|
|
|
56
64
|
"typescript": "^5.3.3"
|
|
57
65
|
},
|
|
58
66
|
"dependencies": {
|
|
59
|
-
"date-fns": "^3.
|
|
67
|
+
"date-fns": "^3.3.1"
|
|
60
68
|
}
|
|
61
69
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { CalloutResponseAnswer } from "./index.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Answers are grouped by nestable component key: `{[slideId]: {[componentKey]: answer | answer[]}}`
|
|
4
|
-
*/
|
|
5
|
-
export type CalloutResponseAnswersNestable = Record<string, CalloutResponseAnswer | CalloutResponseAnswer[]>;
|
|
File without changes
|
|
File without changes
|
/package/dist/esm/types/{callout-response-answers-nestable.js → get-callout-navigation-schema.js}
RENAMED
|
File without changes
|
|
File without changes
|