@uniformdev/canvas-vue 11.0.1-alpha.100
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.txt +2 -0
- package/README.md +3 -0
- package/dist/cjs/components/Composition.d.ts +18 -0
- package/dist/cjs/components/Composition.js +1 -0
- package/dist/cjs/components/DefaultNotImplementedComponent.d.ts +11 -0
- package/dist/cjs/components/DefaultNotImplementedComponent.js +1 -0
- package/dist/cjs/components/SlotContent.d.ts +40 -0
- package/dist/cjs/components/SlotContent.js +1 -0
- package/dist/cjs/helpers/index.d.ts +12 -0
- package/dist/cjs/helpers/index.js +1 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/mixins/index.d.ts +8 -0
- package/dist/cjs/mixins/index.js +1 -0
- package/dist/cjs/utils/constants.d.ts +4 -0
- package/dist/cjs/utils/constants.js +1 -0
- package/dist/esm/components/Composition.d.ts +18 -0
- package/dist/esm/components/Composition.js +1 -0
- package/dist/esm/components/DefaultNotImplementedComponent.d.ts +11 -0
- package/dist/esm/components/DefaultNotImplementedComponent.js +1 -0
- package/dist/esm/components/SlotContent.d.ts +40 -0
- package/dist/esm/components/SlotContent.js +1 -0
- package/dist/esm/helpers/index.d.ts +12 -0
- package/dist/esm/helpers/index.js +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/mixins/index.d.ts +8 -0
- package/dist/esm/mixins/index.js +1 -0
- package/dist/esm/utils/constants.d.ts +4 -0
- package/dist/esm/utils/constants.js +1 -0
- package/package.json +64 -0
package/LICENSE.txt
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Vue, { Component } from 'vue';
|
|
2
|
+
import { DefaultMethods, ThisTypedComponentOptionsWithRecordProps, DefaultData, DefaultComputed } from 'vue/types/options';
|
|
3
|
+
import { ComponentInstance } from '@uniformdev/canvas';
|
|
4
|
+
export declare type PageMetaProps = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
slug: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type CompositionProps = {
|
|
10
|
+
composition: ComponentInstance;
|
|
11
|
+
pageMeta?: PageMetaProps;
|
|
12
|
+
wrapper?: string | Component;
|
|
13
|
+
};
|
|
14
|
+
export declare type CompositionState = DefaultData<Vue>;
|
|
15
|
+
export declare type Methods = DefaultMethods<Vue>;
|
|
16
|
+
export declare type Computed = DefaultComputed;
|
|
17
|
+
export declare type VueSetupProps = ThisTypedComponentOptionsWithRecordProps<Vue, CompositionState, Methods, Computed, CompositionProps>;
|
|
18
|
+
export declare const Composition: VueSetupProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var s,i=1,o=arguments.length;i<o;i++)for(var e in s=arguments[i])Object.prototype.hasOwnProperty.call(s,e)&&(t[e]=s[e]);return t}).apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Composition=void 0;var uuid_1=require("uuid"),constants_1=require("./../utils/constants"),mixins_1=require("./../mixins");exports.Composition={name:constants_1.CANVAS_COMPOSITION_TYPE,inheritAttrs:!1,props:{composition:{type:Object,required:!0},pageMeta:{type:Object},wrapper:{type:[String,Object],default:"div"}},mixins:[mixins_1.UniformOptimizeMixin],provide:function(){var t;return{$__uniformData__:null===(t=this.$props.composition)||void 0===t?void 0:t.slots}},computed:{slots:function(){return this.$props.composition&&this.$props.composition.slots?this.$props.composition.slots:{}},pageMetaData:function(){var t;if(this.$props.pageMeta)return Object.keys(this.$props.pageMeta).length?{id:null===(t=this.$props.pageMeta)||void 0===t?void 0:t.id,name:null===(t=this.$props.pageMeta)||void 0===t?void 0:t.name,slug:null===(t=this.$props.pageMeta)||void 0===t?void 0:t.slug}:{}},parameters:function(){var t;return this.$props.composition&&null!==(t=this.$props.composition)&&void 0!==t&&t.parameters?this.$props.composition.parameters:{}},componentKey:function(){return"uniform-composition-"+(0,uuid_1.v4)()}},render:function(t){return Object.keys(this.slots).length&&this.$scopedSlots.default||0===Object.keys(this.slots).length&&this.$scopedSlots.default?t(this.wrapper,{key:this.componentKey,attrs:__assign({},this.$attrs)},this.$scopedSlots.default({slots:this.slots,parameters:this.parameters})):t(this.wrapper,{key:this.componentKey,attrs:__assign({},this.$attrs)},this.$slots.default)}};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Vue from 'vue';
|
|
2
|
+
import { DefaultMethods, ThisTypedComponentOptionsWithRecordProps, DefaultComputed, DefaultData } from 'vue/types/options';
|
|
3
|
+
import { ComponentInstance } from '@uniformdev/canvas';
|
|
4
|
+
export declare type DefaultNotImplementedComponentProps<TProps = unknown> = TProps & {
|
|
5
|
+
component: ComponentInstance;
|
|
6
|
+
};
|
|
7
|
+
export declare type VueSetupProps = ThisTypedComponentOptionsWithRecordProps<Vue, DefaultNotImplementedComponentState, Methods, Computed, DefaultNotImplementedComponentProps>;
|
|
8
|
+
export declare type DefaultNotImplementedComponentState = DefaultData<Vue>;
|
|
9
|
+
export declare type Methods = DefaultMethods<Vue>;
|
|
10
|
+
export declare type Computed = DefaultComputed;
|
|
11
|
+
export declare const DefaultNotImplementedComponent: VueSetupProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DefaultNotImplementedComponent=void 0;var inlineStyles={borderLeft:"10px solid #e42535",background:"rgba(122, 215, 218, 0.3)",color:"#1d3557",padding:"1rem",textAlign:"left",margin:"1rem 5vw"},headingStyle={margin:"0 0 1rem"};exports.DefaultNotImplementedComponent={name:"default-not-implemented-component",inheritAttrs:!1,props:{component:{type:Object,required:!0}},render:function(e){var t=null===(t=this.component)||void 0===t?void 0:t.type;return e("div",{key:"content",style:__assign({},inlineStyles)},[e("h2",{style:__assign({},headingStyle)},"Component: "+t),e("p",[e("strong",t+" has no Vue implementation. It may need to be added to your "),e("code",{},"resolveRenderer() function.")]),e("details",{},[e("summary",{},"props"),e("pre",{style:{overflowX:"auto"}},""+JSON.stringify(this.$props))])])}};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Vue, { Component } from 'vue';
|
|
2
|
+
import { DefaultMethods, ThisTypedComponentOptionsWithRecordProps, DefaultData } from 'vue/types/options';
|
|
3
|
+
import { ComponentInstance, ComponentParameter } from '@uniformdev/canvas';
|
|
4
|
+
import { ListPersonalizerArguments } from '@uniformdev/optimize-tracker-common';
|
|
5
|
+
export declare type SlotComponentProps = {
|
|
6
|
+
uniformData?: Record<string, unknown>;
|
|
7
|
+
slotName?: string;
|
|
8
|
+
wrapper?: string | Component;
|
|
9
|
+
};
|
|
10
|
+
export declare type SlotComponentState = DefaultData<Vue>;
|
|
11
|
+
export declare type Methods = DefaultMethods<Vue>;
|
|
12
|
+
export declare type mapComponentNameProps = {
|
|
13
|
+
name: string;
|
|
14
|
+
components: Array<ComponentInstance>;
|
|
15
|
+
};
|
|
16
|
+
export declare type Computed = {
|
|
17
|
+
slotItems: Array<mapComponentNameProps>;
|
|
18
|
+
};
|
|
19
|
+
export declare type VueSetupProps = ThisTypedComponentOptionsWithRecordProps<Vue, SlotComponentState, Methods, Computed, SlotComponentProps>;
|
|
20
|
+
export declare const SlotContent: VueSetupProps;
|
|
21
|
+
export declare type PersonalizeComponetProps = {
|
|
22
|
+
uniformData: {
|
|
23
|
+
parameters?: {
|
|
24
|
+
trackingEventName?: ComponentParameter<string>;
|
|
25
|
+
count?: ComponentParameter<string | number>;
|
|
26
|
+
matchFilter?: ComponentParameter<ListPersonalizerArguments<any>['matchFilter']>;
|
|
27
|
+
};
|
|
28
|
+
slots?: Record<string, ComponentInstance[]>;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare type TestComponentProps = {
|
|
32
|
+
uniformData: {
|
|
33
|
+
slots?: {
|
|
34
|
+
test?: ComponentInstance[];
|
|
35
|
+
};
|
|
36
|
+
parameters?: {
|
|
37
|
+
test?: ComponentParameter<string | undefined>;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var e,r=1,a=arguments.length;r<a;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SlotContent=void 0;var pascal_case_1=require("pascal-case"),canvas_1=require("@uniformdev/canvas"),optimize_tracker_vue_1=require("@uniformdev/optimize-tracker-vue"),helpers_1=require("./../helpers"),constants_1=require("./../utils/constants");function paramValueIfString(t){if("string"==typeof(null==t?void 0:t.value))return t.value}function renderPersonalizeComponent(r,t,e){var a=t.uniformData,t=null==a?void 0:a.parameters,a=(0,canvas_1.mapSlotToPersonalizedVariations)(null===(a=null==a?void 0:a.slots)||void 0===a?void 0:a.pz);return r(optimize_tracker_vue_1.Personalize,{props:{variations:a,count:Number(null!==(a=null===(a=null==t?void 0:t.count)||void 0===a?void 0:a.value)&&void 0!==a?a:1),trackingEventName:null===(a=null==t?void 0:t.trackingEventName)||void 0===a?void 0:a.value,matchFilter:null===(t=null==t?void 0:t.matchFilter)||void 0===t?void 0:t.value},key:e,scopedSlots:{default:function(t){return t.variations.map(function(t,e){return r(t.type,{props:{uniformData:t},key:t.type+"-"+e})})}}})}function renderTestComponent(e,t,r){var a=null!==(a=null===(a=null===(a=t.uniformData)||void 0===a?void 0:a.slots)||void 0===a?void 0:a.test)&&void 0!==a?a:[],t=(null===(t=null===(t=null===(t=t.uniformData)||void 0===t?void 0:t.parameters)||void 0===t?void 0:t.test)||void 0===t?void 0:t.value)||"Untitled Test",a=a.map(function(t,e){var r;return __assign(__assign({},t),{id:null!==(r=paramValueIfString(null===(r=t.parameters)||void 0===r?void 0:r.testId))&&void 0!==r?r:"variation-"+(e+1)+"-"+t.type})});return e(optimize_tracker_vue_1.Test,{props:{variations:a,name:t},key:r,scopedSlots:{default:function(t){t=t.variant;return e(t.type,{key:t.type+"-"+r,props:{uniformData:t}})}}})}exports.SlotContent={name:constants_1.CANVAS_SLOT_CONTENT_TYPE,inheritAttrs:!1,props:{uniformData:{type:Object},slotName:{type:String,required:!0},wrapper:{type:[String,Object],default:"div"}},inject:["$__uniformData__"],computed:{slotItems:function(){return this.uniformData?(0,helpers_1.mapSlotsData)(this.uniformData):(0,helpers_1.mapSlotsData)(this.$__uniformData__)}},render:function(a){var n=this;if(this.slotItems){if(this.slotName){var t=(0,helpers_1.getDataForSlot)(this.slotItems,this.slotName),t=null==t?void 0:t.components.map(function(t,e){var r={uniformData:t};if(t.type===canvas_1.CANVAS_TEST_TYPE)return renderTestComponent(a,r,t.type+"-"+e);if(t.type===canvas_1.CANVAS_PERSONALIZE_TYPE)return renderPersonalizeComponent(a,r,t.type+"-"+e);t=(0,pascal_case_1.pascalCase)(t.type);return a(t,{props:r,attrs:__assign({},n.$attrs),key:t+"-"+e})});return a(this.wrapper,{key:this.slotName,props:__assign({},this.$props),attrs:__assign({},this.$attrs)},t)}if(!this.slotName){t=this.slotItems.map(function(t,e){var r=null==t?void 0:t.components.map(function(t,e){var r={uniformData:t};if(t.type===canvas_1.CANVAS_TEST_TYPE)return renderTestComponent(a,r,t.type+"-"+e);if(t.type===canvas_1.CANVAS_PERSONALIZE_TYPE)return renderPersonalizeComponent(a,r,t.type+"-"+e);t=(0,pascal_case_1.pascalCase)(t.type);return a(t,{props:r,attrs:__assign({},n.$attrs),key:t+"-"+e})});return a(n.wrapper,{key:t.name+"-"+e},r)});return a(this.wrapper,{key:"slot-content",props:__assign({},this.$props),attrs:__assign({},this.$attrs)},t)}}return a(this.wrapper,{key:"slot-content",props:__assign({},this.$props),attrs:__assign({},this.$attrs)},this.$slots.default)}};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentInstance } from '@uniformdev/canvas';
|
|
2
|
+
declare type mapSlotDataProps = {
|
|
3
|
+
name: string;
|
|
4
|
+
components: Array<ComponentInstance>;
|
|
5
|
+
};
|
|
6
|
+
declare type slotDataProps = Record<string, any>;
|
|
7
|
+
declare type mapSlotDataResolve = Array<mapSlotDataProps>;
|
|
8
|
+
export declare const getDataForSlot: (slots: Array<any>, name: string) => any;
|
|
9
|
+
export declare const mapSlotsData: (slots: slotDataProps) => mapSlotDataResolve;
|
|
10
|
+
export declare const mapPzSlotToVariants: (slotData: slotDataProps) => any;
|
|
11
|
+
export declare const mapTestSlotToVariants: (slotData: slotDataProps) => any;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var a,e=1,n=arguments.length;e<n;e++)for(var o in a=arguments[e])Object.prototype.hasOwnProperty.call(a,o)&&(t[o]=a[o]);return t}).apply(this,arguments)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.mapTestSlotToVariants=exports.mapPzSlotToVariants=exports.mapSlotsData=exports.getDataForSlot=void 0;var pascal_case_1=require("pascal-case"),getDataForSlot=function(t,a){return t.find(function(t){return t.name===a})};exports.getDataForSlot=getDataForSlot;var mapSlotsData=function(t){var a,e=[];for(a in t)e.push({name:a,components:t[a]});return e};exports.mapSlotsData=mapSlotsData;var mapPzSlotToVariants=function(t){return t.components.map(function(t){var a;return __assign({component:(0,pascal_case_1.pascalCase)(t.type),intentTag:(null===(a=t.parameters.intentTag)||void 0===a?void 0:a.value)||{intents:{}}},(delete(t=t).parameters.intentTag,t))})};exports.mapPzSlotToVariants=mapPzSlotToVariants;var mapTestSlotToVariants=function(t){return t.components.map(function(t){return __assign({component:(0,pascal_case_1.pascalCase)(t.type)},t)})};exports.mapTestSlotToVariants=mapTestSlotToVariants;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Composition } from './components/Composition';
|
|
2
|
+
export { DefaultNotImplementedComponent } from './components/DefaultNotImplementedComponent';
|
|
3
|
+
export { SlotContent } from './components/SlotContent';
|
|
4
|
+
export * from './helpers';
|
|
5
|
+
export * from './utils/constants';
|
|
6
|
+
export type { SlotComponentProps, mapComponentNameProps, PersonalizeComponetProps, TestComponentProps, } from './components/SlotContent';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,o,n){void 0===n&&(n=o),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[o]}})}:function(e,t,o,n){e[n=void 0===n?o:n]=t[o]}),__exportStar=this&&this.__exportStar||function(e,t){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||__createBinding(t,e,o)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.SlotContent=exports.DefaultNotImplementedComponent=exports.Composition=void 0;var Composition_1=require("./components/Composition");Object.defineProperty(exports,"Composition",{enumerable:!0,get:function(){return Composition_1.Composition}});var DefaultNotImplementedComponent_1=require("./components/DefaultNotImplementedComponent");Object.defineProperty(exports,"DefaultNotImplementedComponent",{enumerable:!0,get:function(){return DefaultNotImplementedComponent_1.DefaultNotImplementedComponent}});var SlotContent_1=require("./components/SlotContent");Object.defineProperty(exports,"SlotContent",{enumerable:!0,get:function(){return SlotContent_1.SlotContent}}),__exportStar(require("./helpers"),exports),__exportStar(require("./utils/constants"),exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Vue from 'vue';
|
|
2
|
+
import { DefaultMethods, ThisTypedComponentOptionsWithRecordProps, DefaultData, DefaultComputed, DefaultProps } from 'vue/types/options';
|
|
3
|
+
export declare type CompositionState = DefaultData<Vue>;
|
|
4
|
+
export declare type Methods = DefaultMethods<Vue>;
|
|
5
|
+
export declare type Computed = DefaultComputed;
|
|
6
|
+
export declare type MixinProps = DefaultProps;
|
|
7
|
+
export declare type VueSetupProps = ThisTypedComponentOptionsWithRecordProps<Vue, CompositionState, Methods, Computed, MixinProps>;
|
|
8
|
+
export declare const UniformOptimizeMixin: VueSetupProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.UniformOptimizeMixin=void 0,exports.UniformOptimizeMixin={watch:{"$route.query":function(){this.reevaluateSignals()}},mounted:function(){var i=this;this.$nextTick(function(){i.reevaluateSignals()})},methods:{reevaluateSignals:function(){this.$uniformOptimizeContext.trackerInitializing||this.$uniformOptimizeContext.tracker.reevaluateSignals()}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CANVAS_SLOT_CONTENT_TYPE=exports.CANVAS_COMPOSITION_TYPE=void 0,exports.CANVAS_COMPOSITION_TYPE="Composition",exports.CANVAS_SLOT_CONTENT_TYPE="SlotContent";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Vue, { Component } from 'vue';
|
|
2
|
+
import { DefaultMethods, ThisTypedComponentOptionsWithRecordProps, DefaultData, DefaultComputed } from 'vue/types/options';
|
|
3
|
+
import { ComponentInstance } from '@uniformdev/canvas';
|
|
4
|
+
export declare type PageMetaProps = {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
slug: string;
|
|
8
|
+
};
|
|
9
|
+
export declare type CompositionProps = {
|
|
10
|
+
composition: ComponentInstance;
|
|
11
|
+
pageMeta?: PageMetaProps;
|
|
12
|
+
wrapper?: string | Component;
|
|
13
|
+
};
|
|
14
|
+
export declare type CompositionState = DefaultData<Vue>;
|
|
15
|
+
export declare type Methods = DefaultMethods<Vue>;
|
|
16
|
+
export declare type Computed = DefaultComputed;
|
|
17
|
+
export declare type VueSetupProps = ThisTypedComponentOptionsWithRecordProps<Vue, CompositionState, Methods, Computed, CompositionProps>;
|
|
18
|
+
export declare const Composition: VueSetupProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var s,i=1,o=arguments.length;i<o;i++)for(var e in s=arguments[i])Object.prototype.hasOwnProperty.call(s,e)&&(t[e]=s[e]);return t}).apply(this,arguments)};import{v4 as uuidv4}from"uuid";import{CANVAS_COMPOSITION_TYPE}from"./../utils/constants";import{UniformOptimizeMixin}from"./../mixins";var Composition={name:CANVAS_COMPOSITION_TYPE,inheritAttrs:!1,props:{composition:{type:Object,required:!0},pageMeta:{type:Object},wrapper:{type:[String,Object],default:"div"}},mixins:[UniformOptimizeMixin],provide:function(){var t;return{$__uniformData__:null===(t=this.$props.composition)||void 0===t?void 0:t.slots}},computed:{slots:function(){return this.$props.composition&&this.$props.composition.slots?this.$props.composition.slots:{}},pageMetaData:function(){var t;if(this.$props.pageMeta)return Object.keys(this.$props.pageMeta).length?{id:null===(t=this.$props.pageMeta)||void 0===t?void 0:t.id,name:null===(t=this.$props.pageMeta)||void 0===t?void 0:t.name,slug:null===(t=this.$props.pageMeta)||void 0===t?void 0:t.slug}:{}},parameters:function(){var t;return this.$props.composition&&null!==(t=this.$props.composition)&&void 0!==t&&t.parameters?this.$props.composition.parameters:{}},componentKey:function(){return"uniform-composition-"+uuidv4()}},render:function(t){return Object.keys(this.slots).length&&this.$scopedSlots.default||0===Object.keys(this.slots).length&&this.$scopedSlots.default?t(this.wrapper,{key:this.componentKey,attrs:__assign({},this.$attrs)},this.$scopedSlots.default({slots:this.slots,parameters:this.parameters})):t(this.wrapper,{key:this.componentKey,attrs:__assign({},this.$attrs)},this.$slots.default)}};export{Composition};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Vue from 'vue';
|
|
2
|
+
import { DefaultMethods, ThisTypedComponentOptionsWithRecordProps, DefaultComputed, DefaultData } from 'vue/types/options';
|
|
3
|
+
import { ComponentInstance } from '@uniformdev/canvas';
|
|
4
|
+
export declare type DefaultNotImplementedComponentProps<TProps = unknown> = TProps & {
|
|
5
|
+
component: ComponentInstance;
|
|
6
|
+
};
|
|
7
|
+
export declare type VueSetupProps = ThisTypedComponentOptionsWithRecordProps<Vue, DefaultNotImplementedComponentState, Methods, Computed, DefaultNotImplementedComponentProps>;
|
|
8
|
+
export declare type DefaultNotImplementedComponentState = DefaultData<Vue>;
|
|
9
|
+
export declare type Methods = DefaultMethods<Vue>;
|
|
10
|
+
export declare type Computed = DefaultComputed;
|
|
11
|
+
export declare const DefaultNotImplementedComponent: VueSetupProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},inlineStyles={borderLeft:"10px solid #e42535",background:"rgba(122, 215, 218, 0.3)",color:"#1d3557",padding:"1rem",textAlign:"left",margin:"1rem 5vw"},headingStyle={margin:"0 0 1rem"},DefaultNotImplementedComponent={name:"default-not-implemented-component",inheritAttrs:!1,props:{component:{type:Object,required:!0}},render:function(e){var t=null===(t=this.component)||void 0===t?void 0:t.type;return e("div",{key:"content",style:__assign({},inlineStyles)},[e("h2",{style:__assign({},headingStyle)},"Component: "+t),e("p",[e("strong",t+" has no Vue implementation. It may need to be added to your "),e("code",{},"resolveRenderer() function.")]),e("details",{},[e("summary",{},"props"),e("pre",{style:{overflowX:"auto"}},""+JSON.stringify(this.$props))])])}};export{DefaultNotImplementedComponent};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import Vue, { Component } from 'vue';
|
|
2
|
+
import { DefaultMethods, ThisTypedComponentOptionsWithRecordProps, DefaultData } from 'vue/types/options';
|
|
3
|
+
import { ComponentInstance, ComponentParameter } from '@uniformdev/canvas';
|
|
4
|
+
import { ListPersonalizerArguments } from '@uniformdev/optimize-tracker-common';
|
|
5
|
+
export declare type SlotComponentProps = {
|
|
6
|
+
uniformData?: Record<string, unknown>;
|
|
7
|
+
slotName?: string;
|
|
8
|
+
wrapper?: string | Component;
|
|
9
|
+
};
|
|
10
|
+
export declare type SlotComponentState = DefaultData<Vue>;
|
|
11
|
+
export declare type Methods = DefaultMethods<Vue>;
|
|
12
|
+
export declare type mapComponentNameProps = {
|
|
13
|
+
name: string;
|
|
14
|
+
components: Array<ComponentInstance>;
|
|
15
|
+
};
|
|
16
|
+
export declare type Computed = {
|
|
17
|
+
slotItems: Array<mapComponentNameProps>;
|
|
18
|
+
};
|
|
19
|
+
export declare type VueSetupProps = ThisTypedComponentOptionsWithRecordProps<Vue, SlotComponentState, Methods, Computed, SlotComponentProps>;
|
|
20
|
+
export declare const SlotContent: VueSetupProps;
|
|
21
|
+
export declare type PersonalizeComponetProps = {
|
|
22
|
+
uniformData: {
|
|
23
|
+
parameters?: {
|
|
24
|
+
trackingEventName?: ComponentParameter<string>;
|
|
25
|
+
count?: ComponentParameter<string | number>;
|
|
26
|
+
matchFilter?: ComponentParameter<ListPersonalizerArguments<any>['matchFilter']>;
|
|
27
|
+
};
|
|
28
|
+
slots?: Record<string, ComponentInstance[]>;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare type TestComponentProps = {
|
|
32
|
+
uniformData: {
|
|
33
|
+
slots?: {
|
|
34
|
+
test?: ComponentInstance[];
|
|
35
|
+
};
|
|
36
|
+
parameters?: {
|
|
37
|
+
test?: ComponentParameter<string | undefined>;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t}).apply(this,arguments)};import{pascalCase}from"pascal-case";import{CANVAS_PERSONALIZE_TYPE,CANVAS_TEST_TYPE,mapSlotToPersonalizedVariations}from"@uniformdev/canvas";import{Personalize,Test}from"@uniformdev/optimize-tracker-vue";import{mapSlotsData,getDataForSlot}from"./../helpers";import{CANVAS_SLOT_CONTENT_TYPE}from"./../utils/constants";var SlotContent={name:CANVAS_SLOT_CONTENT_TYPE,inheritAttrs:!1,props:{uniformData:{type:Object},slotName:{type:String,required:!0},wrapper:{type:[String,Object],default:"div"}},inject:["$__uniformData__"],computed:{slotItems:function(){return this.uniformData?mapSlotsData(this.uniformData):mapSlotsData(this.$__uniformData__)}},render:function(n){var a=this;if(this.slotItems){if(this.slotName){var t=getDataForSlot(this.slotItems,this.slotName),t=null==t?void 0:t.components.map(function(t,r){var e={uniformData:t};if(t.type===CANVAS_TEST_TYPE)return renderTestComponent(n,e,t.type+"-"+r);if(t.type===CANVAS_PERSONALIZE_TYPE)return renderPersonalizeComponent(n,e,t.type+"-"+r);t=pascalCase(t.type);return n(t,{props:e,attrs:__assign({},a.$attrs),key:t+"-"+r})});return n(this.wrapper,{key:this.slotName,props:__assign({},this.$props),attrs:__assign({},this.$attrs)},t)}if(!this.slotName){t=this.slotItems.map(function(t,r){var e=null==t?void 0:t.components.map(function(t,r){var e={uniformData:t};if(t.type===CANVAS_TEST_TYPE)return renderTestComponent(n,e,t.type+"-"+r);if(t.type===CANVAS_PERSONALIZE_TYPE)return renderPersonalizeComponent(n,e,t.type+"-"+r);t=pascalCase(t.type);return n(t,{props:e,attrs:__assign({},a.$attrs),key:t+"-"+r})});return n(a.wrapper,{key:t.name+"-"+r},e)});return n(this.wrapper,{key:"slot-content",props:__assign({},this.$props),attrs:__assign({},this.$attrs)},t)}}return n(this.wrapper,{key:"slot-content",props:__assign({},this.$props),attrs:__assign({},this.$attrs)},this.$slots.default)}};function paramValueIfString(t){if("string"==typeof(null==t?void 0:t.value))return t.value}function renderPersonalizeComponent(e,t,r){var n=t.uniformData,t=null==n?void 0:n.parameters,n=mapSlotToPersonalizedVariations(null===(n=null==n?void 0:n.slots)||void 0===n?void 0:n.pz);return e(Personalize,{props:{variations:n,count:Number(null!==(n=null===(n=null==t?void 0:t.count)||void 0===n?void 0:n.value)&&void 0!==n?n:1),trackingEventName:null===(n=null==t?void 0:t.trackingEventName)||void 0===n?void 0:n.value,matchFilter:null===(t=null==t?void 0:t.matchFilter)||void 0===t?void 0:t.value},key:r,scopedSlots:{default:function(t){return t.variations.map(function(t,r){return e(t.type,{props:{uniformData:t},key:t.type+"-"+r})})}}})}function renderTestComponent(r,t,e){var n=null!==(n=null===(n=null===(n=t.uniformData)||void 0===n?void 0:n.slots)||void 0===n?void 0:n.test)&&void 0!==n?n:[],t=(null===(t=null===(t=null===(t=t.uniformData)||void 0===t?void 0:t.parameters)||void 0===t?void 0:t.test)||void 0===t?void 0:t.value)||"Untitled Test",n=n.map(function(t,r){var e;return __assign(__assign({},t),{id:null!==(e=paramValueIfString(null===(e=t.parameters)||void 0===e?void 0:e.testId))&&void 0!==e?e:"variation-"+(r+1)+"-"+t.type})});return r(Test,{props:{variations:n,name:t},key:e,scopedSlots:{default:function(t){t=t.variant;return r(t.type,{key:t.type+"-"+e,props:{uniformData:t}})}}})}export{SlotContent};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComponentInstance } from '@uniformdev/canvas';
|
|
2
|
+
declare type mapSlotDataProps = {
|
|
3
|
+
name: string;
|
|
4
|
+
components: Array<ComponentInstance>;
|
|
5
|
+
};
|
|
6
|
+
declare type slotDataProps = Record<string, any>;
|
|
7
|
+
declare type mapSlotDataResolve = Array<mapSlotDataProps>;
|
|
8
|
+
export declare const getDataForSlot: (slots: Array<any>, name: string) => any;
|
|
9
|
+
export declare const mapSlotsData: (slots: slotDataProps) => mapSlotDataResolve;
|
|
10
|
+
export declare const mapPzSlotToVariants: (slotData: slotDataProps) => any;
|
|
11
|
+
export declare const mapTestSlotToVariants: (slotData: slotDataProps) => any;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var n,a=1,e=arguments.length;a<e;a++)for(var o in n=arguments[a])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)};import{pascalCase}from"pascal-case";var getDataForSlot=function(t,n){return t.find(function(t){return t.name===n})},mapSlotsData=function(t){var n,a=[];for(n in t)a.push({name:n,components:t[n]});return a},mapPzSlotToVariants=function(t){return t.components.map(function(t){var n;return __assign({component:pascalCase(t.type),intentTag:(null===(n=t.parameters.intentTag)||void 0===n?void 0:n.value)||{intents:{}}},(delete(t=t).parameters.intentTag,t))})},mapTestSlotToVariants=function(t){return t.components.map(function(t){return __assign({component:pascalCase(t.type)},t)})};export{getDataForSlot,mapSlotsData,mapPzSlotToVariants,mapTestSlotToVariants};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Composition } from './components/Composition';
|
|
2
|
+
export { DefaultNotImplementedComponent } from './components/DefaultNotImplementedComponent';
|
|
3
|
+
export { SlotContent } from './components/SlotContent';
|
|
4
|
+
export * from './helpers';
|
|
5
|
+
export * from './utils/constants';
|
|
6
|
+
export type { SlotComponentProps, mapComponentNameProps, PersonalizeComponetProps, TestComponentProps, } from './components/SlotContent';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{Composition}from"./components/Composition";export{DefaultNotImplementedComponent}from"./components/DefaultNotImplementedComponent";export{SlotContent}from"./components/SlotContent";export*from"./helpers";export*from"./utils/constants";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Vue from 'vue';
|
|
2
|
+
import { DefaultMethods, ThisTypedComponentOptionsWithRecordProps, DefaultData, DefaultComputed, DefaultProps } from 'vue/types/options';
|
|
3
|
+
export declare type CompositionState = DefaultData<Vue>;
|
|
4
|
+
export declare type Methods = DefaultMethods<Vue>;
|
|
5
|
+
export declare type Computed = DefaultComputed;
|
|
6
|
+
export declare type MixinProps = DefaultProps;
|
|
7
|
+
export declare type VueSetupProps = ThisTypedComponentOptionsWithRecordProps<Vue, CompositionState, Methods, Computed, MixinProps>;
|
|
8
|
+
export declare const UniformOptimizeMixin: VueSetupProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var UniformOptimizeMixin={watch:{"$route.query":function(){this.reevaluateSignals()}},mounted:function(){var i=this;this.$nextTick(function(){i.reevaluateSignals()})},methods:{reevaluateSignals:function(){this.$uniformOptimizeContext.trackerInitializing||this.$uniformOptimizeContext.tracker.reevaluateSignals()}}};export{UniformOptimizeMixin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var CANVAS_COMPOSITION_TYPE="Composition",CANVAS_SLOT_CONTENT_TYPE="SlotContent";export{CANVAS_COMPOSITION_TYPE,CANVAS_SLOT_CONTENT_TYPE};
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@uniformdev/canvas-vue",
|
|
3
|
+
"version": "11.0.1-alpha.100+620d5c7",
|
|
4
|
+
"description": "Vue SDK for Uniform Canvas",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
|
+
"main": "./dist/cjs/index.js",
|
|
7
|
+
"module": "./dist/esm/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"import": "./dist/esm/index.js",
|
|
10
|
+
"require": "./dist/cjs/index.js"
|
|
11
|
+
},
|
|
12
|
+
"types": "./dist/cjs/index.d.ts",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "run-p build:cjs build:esm",
|
|
16
|
+
"build:esm": "tsc",
|
|
17
|
+
"build:cjs": "tsc -p ./tsconfig.cjs.json",
|
|
18
|
+
"dev": "run-p dev:esm dev:cjs",
|
|
19
|
+
"dev:esm": "tsc -w",
|
|
20
|
+
"dev:cjs": "tsc -w -p ./tsconfig.cjs.json",
|
|
21
|
+
"clean": "rimraf dist",
|
|
22
|
+
"test": "jest --maxWorkers=1 --passWithNoTests",
|
|
23
|
+
"lint": "eslint \"src/**/*.{js,ts,tsx}\"",
|
|
24
|
+
"format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
|
|
25
|
+
"ci:verify": "run-p lint test",
|
|
26
|
+
"ci:build": "run-s clean build"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@uniformdev/canvas": "^11.0.1-alpha.100+620d5c7",
|
|
30
|
+
"@uniformdev/optimize-common": "^11.0.1-alpha.100+620d5c7",
|
|
31
|
+
"@uniformdev/optimize-tracker-browser": "^11.0.1-alpha.100+620d5c7",
|
|
32
|
+
"@uniformdev/optimize-tracker-vue": "^11.0.1-alpha.100+620d5c7",
|
|
33
|
+
"pascal-case": "^3.1.2"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"vue": ">=2.6 <3.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@testing-library/vue": "5.8.2",
|
|
40
|
+
"@types/jest": "27.0.2",
|
|
41
|
+
"@types/node": "16.7.1",
|
|
42
|
+
"@vue/server-test-utils": "1.2.1",
|
|
43
|
+
"eslint": "7.32.0",
|
|
44
|
+
"jest": "27.2.3",
|
|
45
|
+
"npm-run-all": "4.1.5",
|
|
46
|
+
"rimraf": "3.0.2",
|
|
47
|
+
"ts-jest": "27.0.5",
|
|
48
|
+
"vue": "2.6.14",
|
|
49
|
+
"vue-server-renderer": "2.6.14",
|
|
50
|
+
"vue-template-compiler": "2.6.14"
|
|
51
|
+
},
|
|
52
|
+
"files": [
|
|
53
|
+
"/dist"
|
|
54
|
+
],
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"browserslist": [
|
|
59
|
+
"> 1%",
|
|
60
|
+
"last 2 versions",
|
|
61
|
+
"not dead"
|
|
62
|
+
],
|
|
63
|
+
"gitHead": "620d5c75566fdb5ee98ab0d1e3969a92fceb2f7a"
|
|
64
|
+
}
|