@kameleoon/react-sdk 1.2.0
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/LICENSE.md +165 -0
- package/README.md +1172 -0
- package/dist/Feature.d.ts +11 -0
- package/dist/Feature.js +26 -0
- package/dist/Feature.js.map +1 -0
- package/dist/KameleoonContext.d.ts +3 -0
- package/dist/KameleoonContext.js +6 -0
- package/dist/KameleoonContext.js.map +1 -0
- package/dist/KameleoonProvider.d.ts +14 -0
- package/dist/KameleoonProvider.js +25 -0
- package/dist/KameleoonProvider.js.map +1 -0
- package/dist/ProviderError.d.ts +3 -0
- package/dist/ProviderError.js +29 -0
- package/dist/ProviderError.js.map +1 -0
- package/dist/compose.d.ts +8 -0
- package/dist/compose.js +33 -0
- package/dist/compose.js.map +1 -0
- package/dist/constants.d.ts +13 -0
- package/dist/constants.js +19 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/kameleoonClient.d.ts +16 -0
- package/dist/kameleoonClient.js +17 -0
- package/dist/kameleoonClient.js.map +1 -0
- package/dist/stories/Form.d.ts +22 -0
- package/dist/stories/Form.js +97 -0
- package/dist/stories/Form.js.map +1 -0
- package/dist/stories/FormHOC.d.ts +2 -0
- package/dist/stories/FormHOC.js +36 -0
- package/dist/stories/FormHOC.js.map +1 -0
- package/dist/stories/FormHook.d.ts +2 -0
- package/dist/stories/FormHook.js +61 -0
- package/dist/stories/FormHook.js.map +1 -0
- package/dist/stories/FormRenderProps.d.ts +3 -0
- package/dist/stories/FormRenderProps.js +24 -0
- package/dist/stories/FormRenderProps.js.map +1 -0
- package/dist/stories/Radio.d.ts +8 -0
- package/dist/stories/Radio.js +9 -0
- package/dist/stories/Radio.js.map +1 -0
- package/dist/stories/constants.d.ts +13 -0
- package/dist/stories/constants.js +18 -0
- package/dist/stories/constants.js.map +1 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/useActivateFeature.d.ts +12 -0
- package/dist/useActivateFeature.js +23 -0
- package/dist/useActivateFeature.js.map +1 -0
- package/dist/useAddData.d.ts +14 -0
- package/dist/useAddData.js +33 -0
- package/dist/useAddData.js.map +1 -0
- package/dist/useBrowser.d.ts +13 -0
- package/dist/useBrowser.js +22 -0
- package/dist/useBrowser.js.map +1 -0
- package/dist/useConversion.d.ts +14 -0
- package/dist/useConversion.js +18 -0
- package/dist/useConversion.js.map +1 -0
- package/dist/useCustomData.d.ts +13 -0
- package/dist/useCustomData.js +18 -0
- package/dist/useCustomData.js.map +1 -0
- package/dist/useFeature.d.ts +5 -0
- package/dist/useFeature.js +75 -0
- package/dist/useFeature.js.map +1 -0
- package/dist/useFeatureVariable.d.ts +13 -0
- package/dist/useFeatureVariable.js +36 -0
- package/dist/useFeatureVariable.js.map +1 -0
- package/dist/useFlush.d.ts +11 -0
- package/dist/useFlush.js +19 -0
- package/dist/useFlush.js.map +1 -0
- package/dist/useInterest.d.ts +12 -0
- package/dist/useInterest.js +16 -0
- package/dist/useInterest.js.map +1 -0
- package/dist/useKameleoon.d.ts +10 -0
- package/dist/useKameleoon.js +20 -0
- package/dist/useKameleoon.js.map +1 -0
- package/dist/usePageView.d.ts +14 -0
- package/dist/usePageView.js +18 -0
- package/dist/usePageView.js.map +1 -0
- package/dist/useTrackingConversion.d.ts +13 -0
- package/dist/useTrackingConversion.js +19 -0
- package/dist/useTrackingConversion.js.map +1 -0
- package/dist/useTriggerExperiment.d.ts +15 -0
- package/dist/useTriggerExperiment.js +22 -0
- package/dist/useTriggerExperiment.js.map +1 -0
- package/dist/useVariationAssociatedData.d.ts +14 -0
- package/dist/useVariationAssociatedData.js +21 -0
- package/dist/useVariationAssociatedData.js.map +1 -0
- package/dist/useVisitorCode.d.ts +12 -0
- package/dist/useVisitorCode.js +19 -0
- package/dist/useVisitorCode.js.map +1 -0
- package/dist/withActivateFeature.d.ts +15 -0
- package/dist/withActivateFeature.js +37 -0
- package/dist/withActivateFeature.js.map +1 -0
- package/dist/withAddData.d.ts +16 -0
- package/dist/withAddData.js +49 -0
- package/dist/withAddData.js.map +1 -0
- package/dist/withBrowser.d.ts +16 -0
- package/dist/withBrowser.js +36 -0
- package/dist/withBrowser.js.map +1 -0
- package/dist/withConversion.d.ts +17 -0
- package/dist/withConversion.js +32 -0
- package/dist/withConversion.js.map +1 -0
- package/dist/withCustomData.d.ts +16 -0
- package/dist/withCustomData.js +32 -0
- package/dist/withCustomData.js.map +1 -0
- package/dist/withFeature.d.ts +6 -0
- package/dist/withFeature.js +31 -0
- package/dist/withFeature.js.map +1 -0
- package/dist/withFeatureVariable.d.ts +15 -0
- package/dist/withFeatureVariable.js +28 -0
- package/dist/withFeatureVariable.js.map +1 -0
- package/dist/withFlush.d.ts +14 -0
- package/dist/withFlush.js +36 -0
- package/dist/withFlush.js.map +1 -0
- package/dist/withInterest.d.ts +15 -0
- package/dist/withInterest.js +31 -0
- package/dist/withInterest.js.map +1 -0
- package/dist/withKameleoon.d.ts +13 -0
- package/dist/withKameleoon.js +34 -0
- package/dist/withKameleoon.js.map +1 -0
- package/dist/withPageView.d.ts +17 -0
- package/dist/withPageView.js +31 -0
- package/dist/withPageView.js.map +1 -0
- package/dist/withTrackingConversion.d.ts +16 -0
- package/dist/withTrackingConversion.js +36 -0
- package/dist/withTrackingConversion.js.map +1 -0
- package/dist/withTriggerExperiment.d.ts +17 -0
- package/dist/withTriggerExperiment.js +38 -0
- package/dist/withTriggerExperiment.js.map +1 -0
- package/dist/withVariationAssociatedData.d.ts +17 -0
- package/dist/withVariationAssociatedData.js +39 -0
- package/dist/withVariationAssociatedData.js.map +1 -0
- package/dist/withVisitorCode.d.ts +15 -0
- package/dist/withVisitorCode.js +36 -0
- package/dist/withVisitorCode.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useKameleoon = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var KameleoonContext_1 = require("./KameleoonContext");
|
|
6
|
+
var ProviderError_1 = require("./ProviderError");
|
|
7
|
+
/**
|
|
8
|
+
* A React Hook that validates if context is used within a KameleoonProvider and returns it
|
|
9
|
+
*/
|
|
10
|
+
function useKameleoon() {
|
|
11
|
+
var context = (0, react_1.useContext)(KameleoonContext_1.KameleoonContext);
|
|
12
|
+
if (!context) {
|
|
13
|
+
throw new ProviderError_1.ProviderError('useKameleoon');
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
client: context,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.useKameleoon = useKameleoon;
|
|
20
|
+
//# sourceMappingURL=useKameleoon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useKameleoon.js","sourceRoot":"","sources":["../src/useKameleoon.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AAEnC,uDAAsD;AACtD,iDAAgD;AAOhD;;GAEG;AACH,SAAgB,YAAY;IAC1B,IAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;IAE7C,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,6BAAa,CAAC,cAAc,CAAC,CAAC;KACzC;IAED,OAAO;QACL,MAAM,EAAE,OAAO;KAChB,CAAC;AACJ,CAAC;AAVD,oCAUC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PageView } from 'kameleoon-client-javascript/dist/data';
|
|
2
|
+
interface PageViewHookResult {
|
|
3
|
+
/**
|
|
4
|
+
* @param url - URL of the page viewed
|
|
5
|
+
* @param title - title of the page viewed
|
|
6
|
+
* @param referrer - referrer of the page viewed
|
|
7
|
+
*/
|
|
8
|
+
addPageView: (url: string, title: string, referrer?: number) => PageView;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A React Hook that returns callback function which adds page view
|
|
12
|
+
*/
|
|
13
|
+
export declare function usePageView(): PageViewHookResult;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePageView = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
|
|
6
|
+
/**
|
|
7
|
+
* A React Hook that returns callback function which adds page view
|
|
8
|
+
*/
|
|
9
|
+
function usePageView() {
|
|
10
|
+
var addPageView = (0, react_1.useCallback)(function (url, title, referrer) {
|
|
11
|
+
return new kameleoon_client_javascript_1.KameleoonData.PageView(url, title, referrer);
|
|
12
|
+
}, []);
|
|
13
|
+
return {
|
|
14
|
+
addPageView: addPageView,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.usePageView = usePageView;
|
|
18
|
+
//# sourceMappingURL=usePageView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePageView.js","sourceRoot":"","sources":["../src/usePageView.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,2EAA4D;AAY5D;;GAEG;AACH,SAAgB,WAAW;IACzB,IAAM,WAAW,GAAG,IAAA,mBAAW,EAC7B,UAAC,GAAW,EAAE,KAAa,EAAE,QAAiB;QAC5C,OAAA,IAAI,2CAAa,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC;IAAhD,CAAgD,EAClD,EAAE,CACH,CAAC;IAEF,OAAO;QACL,WAAW,aAAA;KACZ,CAAC;AACJ,CAAC;AAVD,kCAUC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface TrackingConversionHookResult {
|
|
2
|
+
/**
|
|
3
|
+
* @param visitorCode - unique identifier of the user
|
|
4
|
+
* @param goalId - unique identifier of the goal
|
|
5
|
+
* @param revenue - revenue of the conversion
|
|
6
|
+
*/
|
|
7
|
+
trackConversion: (visitorCode: string, goalId: number, revenue?: number) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A React Hook that returns callback function which tracks conversion
|
|
11
|
+
*/
|
|
12
|
+
export declare function useTrackingConversion(): TrackingConversionHookResult;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTrackingConversion = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var useKameleoon_1 = require("./useKameleoon");
|
|
6
|
+
/**
|
|
7
|
+
* A React Hook that returns callback function which tracks conversion
|
|
8
|
+
*/
|
|
9
|
+
function useTrackingConversion() {
|
|
10
|
+
var client = (0, useKameleoon_1.useKameleoon)().client;
|
|
11
|
+
var trackConversion = (0, react_1.useCallback)(function (visitorCode, goalId, revenue) {
|
|
12
|
+
client.trackConversion(visitorCode, goalId, revenue);
|
|
13
|
+
}, [client]);
|
|
14
|
+
return {
|
|
15
|
+
trackConversion: trackConversion,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.useTrackingConversion = useTrackingConversion;
|
|
19
|
+
//# sourceMappingURL=useTrackingConversion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrackingConversion.js","sourceRoot":"","sources":["../src/useTrackingConversion.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAe9C;;GAEG;AACH,SAAgB,qBAAqB;IAC3B,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,eAAe,GAAG,IAAA,mBAAW,EACjC,UAAC,WAAmB,EAAE,MAAc,EAAE,OAAgB;QACpD,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,eAAe,iBAAA;KAChB,CAAC;AACJ,CAAC;AAbD,sDAaC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface IGetVariationIdHookResult {
|
|
2
|
+
/**
|
|
3
|
+
* @param visitorCode - unique identifier of the user
|
|
4
|
+
* @param experimentId - unique identifier of the experiment you want to expose to a user
|
|
5
|
+
*/
|
|
6
|
+
getVariationId: (visitorCode: string, experimentId: number) => number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A React Hook that returns callback function which triggers experiment.
|
|
10
|
+
* If such a user has never been associated with any variation, the SDK returns a randomly selected variation.
|
|
11
|
+
* If a user with a given visitorCode is already registered with a variation,
|
|
12
|
+
* it will detect the previously registered variation and return the variationID
|
|
13
|
+
*/
|
|
14
|
+
export declare function useTriggerExperiment(): IGetVariationIdHookResult;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTriggerExperiment = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var useKameleoon_1 = require("./useKameleoon");
|
|
6
|
+
/**
|
|
7
|
+
* A React Hook that returns callback function which triggers experiment.
|
|
8
|
+
* If such a user has never been associated with any variation, the SDK returns a randomly selected variation.
|
|
9
|
+
* If a user with a given visitorCode is already registered with a variation,
|
|
10
|
+
* it will detect the previously registered variation and return the variationID
|
|
11
|
+
*/
|
|
12
|
+
function useTriggerExperiment() {
|
|
13
|
+
var client = (0, useKameleoon_1.useKameleoon)().client;
|
|
14
|
+
var getVariationId = (0, react_1.useCallback)(function (visitorCode, experimentId) {
|
|
15
|
+
return client.triggerExperiment(visitorCode, experimentId);
|
|
16
|
+
}, [client]);
|
|
17
|
+
return {
|
|
18
|
+
getVariationId: getVariationId,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.useTriggerExperiment = useTriggerExperiment;
|
|
22
|
+
//# sourceMappingURL=useTriggerExperiment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTriggerExperiment.js","sourceRoot":"","sources":["../src/useTriggerExperiment.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAa9C;;;;;GAKG;AACH,SAAgB,oBAAoB;IAC1B,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,cAAc,GAAG,IAAA,mBAAW,EAChC,UAAC,WAAmB,EAAE,YAAoB;QACxC,OAAA,MAAM,CAAC,iBAAiB,CAAC,WAAW,EAAE,YAAY,CAAC;IAAnD,CAAmD,EACrD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,cAAc,gBAAA;KACf,CAAC;AACJ,CAAC;AAZD,oDAYC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AnyType } from './types';
|
|
2
|
+
interface VariationAssociatedDataHoolResult {
|
|
3
|
+
/**
|
|
4
|
+
* @param variationId - unique identifier of the variation you want to obtain associated data for
|
|
5
|
+
*/
|
|
6
|
+
getVariationAssociatedData: (variationId: number) => AnyType;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A React Hook that returns callback function which retrieves JSON data associated with a variation.
|
|
10
|
+
* The JSON data usually represents some metadata of the variation,
|
|
11
|
+
* and can be configured on our web application interface or via our Automation API.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useVariationAssociatedData(): VariationAssociatedDataHoolResult;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useVariationAssociatedData = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var useKameleoon_1 = require("./useKameleoon");
|
|
6
|
+
/**
|
|
7
|
+
* A React Hook that returns callback function which retrieves JSON data associated with a variation.
|
|
8
|
+
* The JSON data usually represents some metadata of the variation,
|
|
9
|
+
* and can be configured on our web application interface or via our Automation API.
|
|
10
|
+
*/
|
|
11
|
+
function useVariationAssociatedData() {
|
|
12
|
+
var client = (0, useKameleoon_1.useKameleoon)().client;
|
|
13
|
+
var getVariationAssociatedData = (0, react_1.useCallback)(function (variationId) {
|
|
14
|
+
return client.obtainVariationAssociatedData(variationId);
|
|
15
|
+
}, [client]);
|
|
16
|
+
return {
|
|
17
|
+
getVariationAssociatedData: getVariationAssociatedData,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.useVariationAssociatedData = useVariationAssociatedData;
|
|
21
|
+
//# sourceMappingURL=useVariationAssociatedData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVariationAssociatedData.js","sourceRoot":"","sources":["../src/useVariationAssociatedData.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAU9C;;;;GAIG;AACH,SAAgB,0BAA0B;IAChC,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,0BAA0B,GAAG,IAAA,mBAAW,EAC5C,UAAC,WAAmB;QAClB,OAAA,MAAM,CAAC,6BAA6B,CAAC,WAAW,CAAC;IAAjD,CAAiD,EACnD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,0BAA0B,4BAAA;KAC3B,CAAC;AACJ,CAAC;AAZD,gEAYC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface VisitorCodeHookResult {
|
|
2
|
+
/**
|
|
3
|
+
* @param topLevelDomain - current top level domain for the concerned site
|
|
4
|
+
* @param defaultVisitorCode - this parameter will be used as the visitorCode
|
|
5
|
+
*/
|
|
6
|
+
getVisitorCode: (topLevelDomain: string, defaultVisitorCode?: string) => string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A React Hook that returns callback function which obtains the Kameleoon visitorCode for the current visitor
|
|
10
|
+
*/
|
|
11
|
+
export declare function useVisitorCode(): VisitorCodeHookResult;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useVisitorCode = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var useKameleoon_1 = require("./useKameleoon");
|
|
6
|
+
/**
|
|
7
|
+
* A React Hook that returns callback function which obtains the Kameleoon visitorCode for the current visitor
|
|
8
|
+
*/
|
|
9
|
+
function useVisitorCode() {
|
|
10
|
+
var client = (0, useKameleoon_1.useKameleoon)().client;
|
|
11
|
+
var getVisitorCode = (0, react_1.useCallback)(function (topLevelDomain, defaultVisitorCode) {
|
|
12
|
+
return client.obtainVisitorCode(topLevelDomain, defaultVisitorCode);
|
|
13
|
+
}, [client]);
|
|
14
|
+
return {
|
|
15
|
+
getVisitorCode: getVisitorCode,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.useVisitorCode = useVisitorCode;
|
|
19
|
+
//# sourceMappingURL=useVisitorCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVisitorCode.js","sourceRoot":"","sources":["../src/useVisitorCode.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AACpC,+CAA8C;AAa9C;;GAEG;AACH,SAAgB,cAAc;IACpB,IAAA,MAAM,GAAK,IAAA,2BAAY,GAAE,OAAnB,CAAoB;IAElC,IAAM,cAAc,GAAG,IAAA,mBAAW,EAChC,UAAC,cAAsB,EAAE,kBAA2B;QAClD,OAAA,MAAM,CAAC,iBAAiB,CAAC,cAAc,EAAE,kBAAkB,CAAC;IAA5D,CAA4D,EAC9D,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,cAAc,gBAAA;KACf,CAAC;AACJ,CAAC;AAZD,wCAYC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UnknownPropsType, Without } from './types';
|
|
3
|
+
interface IWithHasFeature {
|
|
4
|
+
/**
|
|
5
|
+
* @param visitorCode - unique identifier of the user
|
|
6
|
+
* @param featureKey - unique identifier or key of the feature you want to expose to a user
|
|
7
|
+
*/
|
|
8
|
+
hasFeature: (visitorCode: string, featureKey: string | number) => boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A React HOC that gives a wrapped component access to callback
|
|
12
|
+
* function which activates a feature toggle
|
|
13
|
+
*/
|
|
14
|
+
export declare function withActivateFeature<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithHasFeature>>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.withActivateFeature = void 0;
|
|
15
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var react_1 = require("react");
|
|
17
|
+
var KameleoonContext_1 = require("./KameleoonContext");
|
|
18
|
+
var ProviderError_1 = require("./ProviderError");
|
|
19
|
+
;
|
|
20
|
+
/**
|
|
21
|
+
* A React HOC that gives a wrapped component access to callback
|
|
22
|
+
* function which activates a feature toggle
|
|
23
|
+
*/
|
|
24
|
+
function withActivateFeature(Component) {
|
|
25
|
+
return function WrappedComponent(props) {
|
|
26
|
+
var client = (0, react_1.useContext)(KameleoonContext_1.KameleoonContext);
|
|
27
|
+
var hasFeature = (0, react_1.useCallback)(function (visitorCode, featureKey) {
|
|
28
|
+
if (!client) {
|
|
29
|
+
throw new ProviderError_1.ProviderError('withActivateFeature');
|
|
30
|
+
}
|
|
31
|
+
return client.activateFeature(visitorCode, featureKey);
|
|
32
|
+
}, [client]);
|
|
33
|
+
return (0, jsx_runtime_1.jsx)(Component, __assign({ hasFeature: hasFeature }, props), void 0);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
exports.withActivateFeature = withActivateFeature;
|
|
37
|
+
//# sourceMappingURL=withActivateFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withActivateFeature.js","sourceRoot":"","sources":["../src/withActivateFeature.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAAuD;AAEvD,uDAAsD;AACtD,iDAAgD;AAQ/C,CAAC;AAEF;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAM,UAAU,GAAG,IAAA,mBAAW,EAC5B,UAAC,WAAmB,EAAE,UAA2B;YAC/C,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,6BAAa,CAAC,qBAAqB,CAAC,CAAC;aAChD;YAED,OAAO,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACzD,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,UAAU,EAAE,UAAU,IAAO,KAAe,UAAI,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC;AAnBD,kDAmBC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DataInterface as IData } from 'kameleoon-client-javascript/dist/interfaces/interfaces';
|
|
3
|
+
import { UnknownPropsType, Without } from './types';
|
|
4
|
+
interface IWithAddData {
|
|
5
|
+
/**
|
|
6
|
+
* @param visitorCode - unique identifier of the user
|
|
7
|
+
* @param dataTypes - custom data types which may be passed separated by a comma
|
|
8
|
+
*/
|
|
9
|
+
addData: (visitorCode: string, ...dataTypes: IData[]) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A React HOC that gives a wrapped component access to callback function
|
|
13
|
+
* which adds various data to associate this data with the current user
|
|
14
|
+
*/
|
|
15
|
+
export declare function withAddData<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithAddData>>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.withAddData = void 0;
|
|
24
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
25
|
+
var react_1 = require("react");
|
|
26
|
+
var KameleoonContext_1 = require("./KameleoonContext");
|
|
27
|
+
var ProviderError_1 = require("./ProviderError");
|
|
28
|
+
/**
|
|
29
|
+
* A React HOC that gives a wrapped component access to callback function
|
|
30
|
+
* which adds various data to associate this data with the current user
|
|
31
|
+
*/
|
|
32
|
+
function withAddData(Component) {
|
|
33
|
+
return function WrappedComponent(props) {
|
|
34
|
+
var client = (0, react_1.useContext)(KameleoonContext_1.KameleoonContext);
|
|
35
|
+
var addData = (0, react_1.useCallback)(function (visitorCode) {
|
|
36
|
+
var dataTypes = [];
|
|
37
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
38
|
+
dataTypes[_i - 1] = arguments[_i];
|
|
39
|
+
}
|
|
40
|
+
if (!client) {
|
|
41
|
+
throw new ProviderError_1.ProviderError('withAddData');
|
|
42
|
+
}
|
|
43
|
+
return client.addData.apply(client, __spreadArray([visitorCode], dataTypes, false));
|
|
44
|
+
}, [client]);
|
|
45
|
+
return (0, jsx_runtime_1.jsx)(Component, __assign({ addData: addData }, props), void 0);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
exports.withAddData = withAddData;
|
|
49
|
+
//# sourceMappingURL=withAddData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withAddData.js","sourceRoot":"","sources":["../src/withAddData.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAuD;AAGvD,uDAAsD;AACtD,iDAAgD;AAUhD;;;GAGG;AACH,SAAgB,WAAW,CACzB,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,mCAAgB,CAAC,CAAC;QAE5C,IAAM,OAAO,GAAG,IAAA,mBAAW,EACzB,UAAC,WAAmB;YAAE,mBAAqB;iBAArB,UAAqB,EAArB,qBAAqB,EAArB,IAAqB;gBAArB,kCAAqB;;YACzC,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,6BAAa,CAAC,aAAa,CAAC,CAAC;aACxC;YAED,OAAO,MAAM,CAAC,OAAO,OAAd,MAAM,iBAAS,WAAW,GAAK,SAAS,UAAE;QACnD,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;QAEF,OAAO,uBAAC,SAAS,aAAC,OAAO,EAAE,OAAO,IAAO,KAAe,UAAI,CAAC;IAC/D,CAAC,CAAC;AACJ,CAAC;AAnBD,kCAmBC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Browser as IBrowser } from 'kameleoon-client-javascript/dist/data';
|
|
3
|
+
import { Browser } from './constants';
|
|
4
|
+
import { UnknownPropsType, Without } from './types';
|
|
5
|
+
interface IWithBrowser {
|
|
6
|
+
/**
|
|
7
|
+
* @param browser - browser types: CHROME, INTERNET_EXPLORER, FIREFOX, SAFARI, OPERA, OTHER
|
|
8
|
+
*/
|
|
9
|
+
addBrowser: (browser: Browser) => IBrowser;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A React HOC that gives a wrapped component access to callback function
|
|
13
|
+
* which adds browser type
|
|
14
|
+
*/
|
|
15
|
+
export declare function withBrowser<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithBrowser>>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.withBrowser = void 0;
|
|
18
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
var react_1 = require("react");
|
|
20
|
+
var data_1 = __importDefault(require("kameleoon-client-javascript/dist/data"));
|
|
21
|
+
var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
|
|
22
|
+
;
|
|
23
|
+
/**
|
|
24
|
+
* A React HOC that gives a wrapped component access to callback function
|
|
25
|
+
* which adds browser type
|
|
26
|
+
*/
|
|
27
|
+
function withBrowser(Component) {
|
|
28
|
+
return function WrappedComponent(props) {
|
|
29
|
+
var addBrowser = (0, react_1.useCallback)(function (browser) {
|
|
30
|
+
return new kameleoon_client_javascript_1.KameleoonData.Browser(data_1.default.browsers[browser]);
|
|
31
|
+
}, []);
|
|
32
|
+
return (0, jsx_runtime_1.jsx)(Component, __assign({ addBrowser: addBrowser }, props), void 0);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.withBrowser = withBrowser;
|
|
36
|
+
//# sourceMappingURL=withBrowser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withBrowser.js","sourceRoot":"","sources":["../src/withBrowser.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAA2C;AAC3C,+EAAkF;AAElF,2EAA4D;AAQ3D,CAAC;AAEF;;;GAGG;AACH,SAAgB,WAAW,CACzB,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,UAAU,GAAG,IAAA,mBAAW,EAAC,UAAC,OAAgB;YAC9C,OAAO,IAAI,2CAAa,CAAC,OAAO,CAAC,cAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3D,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,uBAAC,SAAS,aAAC,UAAU,EAAE,UAAU,IAAO,KAAe,UAAI,CAAC;IACrE,CAAC,CAAC;AACJ,CAAC;AAVD,kCAUC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Conversion } from 'kameleoon-client-javascript/dist/data';
|
|
3
|
+
import { UnknownPropsType, Without } from './types';
|
|
4
|
+
interface IWithConversion {
|
|
5
|
+
/**
|
|
6
|
+
* @param goalId - unique identifier of the goal
|
|
7
|
+
* @param revenue - coversion revenue
|
|
8
|
+
* @param negative - defines if the revenue is positive or negative
|
|
9
|
+
*/
|
|
10
|
+
addConversion: (goalId: number, revenue?: number, negative?: boolean) => Conversion;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A React HOC that gives a wrapped component access to callback function
|
|
14
|
+
* which adds conversion
|
|
15
|
+
*/
|
|
16
|
+
export declare function withConversion<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithConversion>>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.withConversion = void 0;
|
|
15
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var react_1 = require("react");
|
|
17
|
+
var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
|
|
18
|
+
;
|
|
19
|
+
/**
|
|
20
|
+
* A React HOC that gives a wrapped component access to callback function
|
|
21
|
+
* which adds conversion
|
|
22
|
+
*/
|
|
23
|
+
function withConversion(Component) {
|
|
24
|
+
return function WrappedComponent(props) {
|
|
25
|
+
var addConversion = (0, react_1.useCallback)(function (goalId, revenue, negative) {
|
|
26
|
+
return new kameleoon_client_javascript_1.KameleoonData.Conversion(goalId, revenue, negative);
|
|
27
|
+
}, []);
|
|
28
|
+
return (0, jsx_runtime_1.jsx)(Component, __assign({ addConversion: addConversion }, props), void 0);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.withConversion = withConversion;
|
|
32
|
+
//# sourceMappingURL=withConversion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withConversion.js","sourceRoot":"","sources":["../src/withConversion.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA2C;AAC3C,2EAA4D;AAW3D,CAAC;AAEF;;;GAGG;AACH,SAAgB,cAAc,CAC5B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,aAAa,GAAG,IAAA,mBAAW,EAAC,UAAC,MAAc,EAAE,OAAgB,EAAE,QAAkB;YACrF,OAAO,IAAI,2CAAa,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACjE,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,uBAAC,SAAS,aAAC,aAAa,EAAE,aAAa,IAAO,KAAe,UAAI,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC;AAVD,wCAUC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CustomData } from 'kameleoon-client-javascript/dist/data';
|
|
3
|
+
import { UnknownPropsType, Without } from './types';
|
|
4
|
+
interface IWithCustomData {
|
|
5
|
+
/**
|
|
6
|
+
* @param index - index or unique identifier of the custom data to be stored
|
|
7
|
+
* @param value - value of the custom data to be stored
|
|
8
|
+
*/
|
|
9
|
+
addCustomData: (index: number, value: string) => CustomData;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A React HOC that gives a wrapped component access to callback function
|
|
13
|
+
* which adds custom data
|
|
14
|
+
*/
|
|
15
|
+
export declare function withCustomData<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithCustomData>>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.withCustomData = void 0;
|
|
15
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var react_1 = require("react");
|
|
17
|
+
var kameleoon_client_javascript_1 = require("kameleoon-client-javascript");
|
|
18
|
+
;
|
|
19
|
+
/**
|
|
20
|
+
* A React HOC that gives a wrapped component access to callback function
|
|
21
|
+
* which adds custom data
|
|
22
|
+
*/
|
|
23
|
+
function withCustomData(Component) {
|
|
24
|
+
return function WrappedComponent(props) {
|
|
25
|
+
var addCustomData = (0, react_1.useCallback)(function (goalId, revenue, negative) {
|
|
26
|
+
return new kameleoon_client_javascript_1.KameleoonData.Conversion(goalId, revenue, negative);
|
|
27
|
+
}, []);
|
|
28
|
+
return (0, jsx_runtime_1.jsx)(Component, __assign({ addCustomData: addCustomData }, props), void 0);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.withCustomData = withCustomData;
|
|
32
|
+
//# sourceMappingURL=withCustomData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withCustomData.js","sourceRoot":"","sources":["../src/withCustomData.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA2C;AAC3C,2EAA4D;AAU3D,CAAC;AAEF;;;GAGG;AACH,SAAgB,cAAc,CAC5B,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QAC3C,IAAM,aAAa,GAAG,IAAA,mBAAW,EAAC,UAAC,MAAc,EAAE,OAAgB,EAAE,QAAkB;YACrF,OAAO,IAAI,2CAAa,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACjE,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,uBAAC,SAAS,aAAC,aAAa,EAAE,aAAa,IAAO,KAAe,UAAI,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC;AAVD,wCAUC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Without, IFeatureParams, UnknownPropsType } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* A React HOC that gives a wrapped component access to the status of a feature flag and its variables
|
|
5
|
+
*/
|
|
6
|
+
export declare function withFeature(args: IFeatureParams): <Props extends UnknownPropsType>(Component: React.ComponentType<Props>) => React.ComponentType<Props & Without<Props, IFeatureParams>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.withFeature = void 0;
|
|
15
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var useFeature_1 = require("./useFeature");
|
|
17
|
+
/**
|
|
18
|
+
* A React HOC that gives a wrapped component access to the status of a feature flag and its variables
|
|
19
|
+
*/
|
|
20
|
+
function withFeature(args) {
|
|
21
|
+
// Returns curried function that can be used with the specified args
|
|
22
|
+
// e.g. withFeature(...args)(Component)
|
|
23
|
+
return function callbackWithArgs(Component) {
|
|
24
|
+
return function WrappedComponent(props) {
|
|
25
|
+
var feature = (0, useFeature_1.useFeature)(__assign({}, args));
|
|
26
|
+
return (0, jsx_runtime_1.jsx)(Component, __assign({ feature: feature }, props), void 0);
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.withFeature = withFeature;
|
|
31
|
+
//# sourceMappingURL=withFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withFeature.js","sourceRoot":"","sources":["../src/withFeature.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,2CAA0C;AAE1C;;GAEG;AACH,SAAgB,WAAW,CAAC,IAAoB;IAC9C,oEAAoE;IACpE,uCAAuC;IACvC,OAAO,SAAS,gBAAgB,CAC9B,SAAqC;QAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;YAC3C,IAAM,OAAO,GAAG,IAAA,uBAAU,eAAM,IAAI,EAAG,CAAC;YAExC,OAAO,uBAAC,SAAS,aAAC,OAAO,EAAE,OAAO,IAAO,KAAe,UAAI,CAAC;QAC/D,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAZD,kCAYC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FeatureFlagVariableType, UnknownPropsType, Without } from './types';
|
|
3
|
+
interface IWithFeatureVariable {
|
|
4
|
+
/**
|
|
5
|
+
* @param featureKey - unique identifier or key of the feature you want to obtain to a user
|
|
6
|
+
* @param variableKey - key of the variable
|
|
7
|
+
*/
|
|
8
|
+
getFeatureVariable: (featureKey: string | number, variableKey: string) => FeatureFlagVariableType;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A React HOC that gives a wrapped component access to callback function
|
|
12
|
+
* which retrieves a feature variable
|
|
13
|
+
*/
|
|
14
|
+
export declare function withFeatureVariable<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithFeatureVariable>>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.withFeatureVariable = void 0;
|
|
15
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var useFeatureVariable_1 = require("./useFeatureVariable");
|
|
17
|
+
/**
|
|
18
|
+
* A React HOC that gives a wrapped component access to callback function
|
|
19
|
+
* which retrieves a feature variable
|
|
20
|
+
*/
|
|
21
|
+
function withFeatureVariable(Component) {
|
|
22
|
+
return function WrappedComponent(props) {
|
|
23
|
+
var getFeatureVariable = (0, useFeatureVariable_1.useFeatureVariable)().getFeatureVariable;
|
|
24
|
+
return (0, jsx_runtime_1.jsx)(Component, __assign({ getFeatureVariable: getFeatureVariable }, props), void 0);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.withFeatureVariable = withFeatureVariable;
|
|
28
|
+
//# sourceMappingURL=withFeatureVariable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withFeatureVariable.js","sourceRoot":"","sources":["../src/withFeatureVariable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,2DAA0D;AAU1D;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,SAAqC;IAErC,OAAO,SAAS,gBAAgB,CAAC,KAAY;QACnC,IAAA,kBAAkB,GAAK,IAAA,uCAAkB,GAAE,mBAAzB,CAA0B;QAEpD,OAAO,uBAAC,SAAS,aAAC,kBAAkB,EAAE,kBAAkB,IAAO,KAAe,UAAI,CAAC;IACrF,CAAC,CAAC;AACJ,CAAC;AARD,kDAQC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UnknownPropsType, Without } from './types';
|
|
3
|
+
interface IWithFlush {
|
|
4
|
+
/**
|
|
5
|
+
* @param visitorCode - unique identifier of the user
|
|
6
|
+
*/
|
|
7
|
+
flush: (visitorCode: string) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A React HOC that gives a wrapped component access to callback function
|
|
11
|
+
* which allows to flush data to servers
|
|
12
|
+
*/
|
|
13
|
+
export declare function withFlush<Props extends UnknownPropsType>(Component: React.ComponentType<Props>): React.ComponentType<Props & Without<Props, IWithFlush>>;
|
|
14
|
+
export {};
|