@seatsio/seatsio-vue 1.0.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.
@@ -0,0 +1,3 @@
1
+ current node
2
+ last 2 versions and > 2%
3
+ ie > 10
@@ -0,0 +1,21 @@
1
+ name: 'Build'
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ build:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - uses: actions/setup-node@v1
17
+ with:
18
+ node-version: 16
19
+ registry-url: https://registry.npmjs.org/
20
+ - run: yarn install
21
+ - run: yarn build
@@ -0,0 +1,20 @@
1
+ name: 'Publish'
2
+
3
+ on:
4
+ release:
5
+ types: [created]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - uses: actions/setup-node@v1
13
+ with:
14
+ node-version: 16
15
+ registry-url: https://registry.npmjs.org/
16
+ - run: yarn install
17
+ - run: yarn build
18
+ - run: yarn publish
19
+ env:
20
+ NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
package/README.md ADDED
@@ -0,0 +1,178 @@
1
+ # seatsio-vue, the official Seats.io Vue wrapper
2
+
3
+ Vue wrapper for rendering [Seats.io](https://www.seats.io) seating charts. Brought to you by the Seats.io team.
4
+
5
+ # Installation
6
+
7
+ ```
8
+ Npm
9
+ npm install --save @seatsio/seatsio-vue
10
+
11
+ Yarn
12
+ yarn add -dev @seatsio/seatsio-vue
13
+ ```
14
+
15
+ # Usage
16
+
17
+ ## Regular charts
18
+
19
+ ### Minimal example to render a seating chart:
20
+
21
+ ```jsx
22
+ import { SeatsioSeatingChart } from '@seatsio/seatsio-vue';
23
+
24
+ <div style="height: 500px">
25
+ <SeatsioSeatingChart
26
+ workspaceKey="<yourPublicWorkspaceKey>"
27
+ event="<yourEventKey>"
28
+ region="eu"
29
+ />
30
+ </div>
31
+ ```
32
+
33
+ The chart uses 100 % of the width and height of the DOM element (e.g. a div) in which you render it. Play with the size of that element to change the chart size.
34
+
35
+ ## Reacting to events
36
+
37
+ ### onRenderStarted()
38
+
39
+ `onRenderStarted` is fired when the chart has started loading, but hasn't rendered yet. If you store the chart object that's passed to the `onRenderStarted` callback, you can access the properties defined on the wrapped `seatsio.SeatingChart`:
40
+
41
+ ```jsx
42
+ // Single File Component (SFC) using SeatsioSeatingChart
43
+ export default {
44
+ ...
45
+ data() {
46
+ return {
47
+ chart: null
48
+ }
49
+ },
50
+ methods: {
51
+ onRenderStarted: function (chart) {
52
+ this.chart = chart
53
+ console.log(chart.selectedObjects)
54
+ }
55
+ }
56
+ }
57
+
58
+ <SeatsioSeatingChart
59
+ workspaceKey="<yourPublicWorkspaceKey>"
60
+ event="<yourEventKey>"
61
+ // Notice how the event handler is defined with @<eventListener>
62
+ // For more information, see https://vuejs.org/guide/essentials/event-handling.html
63
+ @onRenderStarted="onRenderStarted"
64
+ region="eu"
65
+ />
66
+ ```
67
+
68
+ ## onChartRendered()
69
+
70
+ `onChartRendered` is fired when the chart is rendered successfully:
71
+
72
+ ```jsx
73
+ export default {
74
+ ...
75
+ data() {
76
+ return {
77
+ chart: null
78
+ }
79
+ },
80
+ methods: {
81
+ onChartRendered: function (chart) {
82
+ this.chart = chart
83
+ console.log(chart.selectedObjects)
84
+ }
85
+ }
86
+ }
87
+
88
+ <SeatsioSeatingChart
89
+ workspaceKey="<yourPublicWorkspaceKey>"
90
+ event="<yourEventKey>"
91
+ @onChartRendered="onChartRendered"
92
+ region="eu"
93
+ />
94
+ ```
95
+ ## Supported properties
96
+
97
+ Other parameters are supported as well. For a full list, check https://docs.seats.io/docs/renderer/embed-a-floor-plan
98
+
99
+
100
+ Example: Passing in a custom object color:
101
+ ```jsx
102
+ export default {
103
+ ...
104
+ data() {
105
+ // Supports CSS color values
106
+ objectColor: () => 'grey',
107
+ },
108
+ }
109
+
110
+ <SeatsioSeatingChart
111
+ workspaceKey="<yourPublicWorkspaceKey>"
112
+ event="<yourEventKey>"
113
+ region="eu"
114
+ :objectColor="objectColor"
115
+ />
116
+ ```
117
+
118
+ Whenever one of the properties passed on to `<SeatsioSeatingChart />` changes, the chart destroys itself and rerenders. To avoid such a 'full refresh', you can use `chart.changeConfig()` instead of updating the properties directly. Please check https://docs.seats.io/docs/renderer-chart-properties-chartchangeconfig. Note that `changeConfig()` only supports a subset of all available chart parameters.
119
+
120
+ ## Event manager
121
+
122
+ ```jsx
123
+ import { SeatsioEventManager } from '@seatsio/seatsio-vue';
124
+
125
+ <div style="height: 500px">
126
+ <SeatsioEventManager
127
+ secretKey="<yourWorkspaceSecretKey>"
128
+ event="<yourEventKey>"
129
+ mode="<manageObjectStatuses or another mode>"
130
+ region="eu"
131
+ />
132
+ </div>
133
+ ```
134
+
135
+ Other parameters are supported as well. For a full list, check https://docs.seats.io/docs/event-manager/configuring
136
+
137
+ ## Chart manager
138
+
139
+ ```jsx
140
+ import { SeatsioChartManager } from '@seatsio/seatsio-vue';
141
+
142
+ <div style="height: 500px">
143
+ <SeatsioChartManager
144
+ secretKey="<yourWorkspaceSecretKey>"
145
+ chart="<yourChartKey>"
146
+ mode="<manageRulesets or another mode>"
147
+ region="eu"
148
+ />
149
+ </div>
150
+ ```
151
+ Other parameters are supported as well. For a full list, check https://docs.seats.io/docs/chart-manager/configuring/
152
+
153
+ ## Seating Chart Designer
154
+
155
+ To embed the seating chart designer for the purpose of creating a new chart, do this:
156
+
157
+ ```jsx
158
+ import { SeatsioDesigner } from '@seatsio/seatsio-vue';
159
+
160
+ <div style="height: 500px">
161
+ <SeatsioDesigner
162
+ secretKey="<yourWorkspaceSecretKey>"
163
+ region="eu"
164
+ />
165
+ </div>
166
+ ```
167
+
168
+ To be able to edit a chart from an embedded designer, you need to specify the chart to load:
169
+
170
+ ```jsx
171
+ <SeatsioDesigner
172
+ secretKey="<yourWorkspaceSecretKey>"
173
+ chartKey="<yourChartKey>"
174
+ region="eu"
175
+ />
176
+ ```
177
+
178
+ Other parameters are supported as well. For a full list, check https://docs.seats.io/docs/embedded-designer/introduction
@@ -0,0 +1,16 @@
1
+ const devPresets = ['@vue/babel-preset-app'];
2
+ const buildPresets = [
3
+ [
4
+ '@babel/preset-env',
5
+ // Config for @babel/preset-env
6
+ {
7
+ // Example: Always transpile optional chaining/nullish coalescing
8
+ // include: [
9
+ // /(optional-chaining|nullish-coalescing)/
10
+ // ],
11
+ },
12
+ ],
13
+ ];
14
+ module.exports = {
15
+ presets: (process.env.NODE_ENV === 'development' ? devPresets : buildPresets),
16
+ };
@@ -0,0 +1,143 @@
1
+ // rollup.config.js
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import vue from 'rollup-plugin-vue';
5
+ import alias from '@rollup/plugin-alias';
6
+ import commonjs from '@rollup/plugin-commonjs';
7
+ import resolve from '@rollup/plugin-node-resolve';
8
+ import replace from '@rollup/plugin-replace';
9
+ import babel from '@rollup/plugin-babel';
10
+ import { terser } from 'rollup-plugin-terser';
11
+ import minimist from 'minimist';
12
+
13
+ // Get browserslist config and remove ie from es build targets
14
+ const esbrowserslist = fs.readFileSync('./.browserslistrc')
15
+ .toString()
16
+ .split('\n')
17
+ .filter((entry) => entry && entry.substring(0, 2) !== 'ie');
18
+
19
+ // Extract babel preset-env config, to combine with esbrowserslist
20
+ const babelPresetEnvConfig = require('../babel.config')
21
+ .presets.filter((entry) => entry[0] === '@babel/preset-env')[0][1];
22
+
23
+ const argv = minimist(process.argv.slice(2));
24
+
25
+ const projectRoot = path.resolve(__dirname, '..');
26
+
27
+ const baseConfig = {
28
+ input: 'src/entry.js',
29
+ plugins: {
30
+ preVue: [
31
+ alias({
32
+ entries: [
33
+ {
34
+ find: '@',
35
+ replacement: `${path.resolve(projectRoot, 'src')}`,
36
+ },
37
+ ],
38
+ }),
39
+ ],
40
+ replace: {
41
+ 'process.env.NODE_ENV': JSON.stringify('production'),
42
+ preventAssignment: true
43
+ },
44
+ vue: {
45
+ css: true,
46
+ template: {
47
+ isProduction: true,
48
+ },
49
+ },
50
+ postVue: [
51
+ resolve({
52
+ extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
53
+ }),
54
+ commonjs(),
55
+ ],
56
+ babel: {
57
+ exclude: 'node_modules/**',
58
+ extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
59
+ babelHelpers: 'bundled',
60
+ },
61
+ },
62
+ };
63
+
64
+ // ESM/UMD/IIFE shared settings: externals
65
+ // Refer to https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
66
+ const external = [
67
+ // list external dependencies, exactly the way it is written in the import statement.
68
+ // eg. 'jquery'
69
+ 'vue',
70
+ ];
71
+
72
+ // UMD/IIFE shared settings: output.globals
73
+ // Refer to https://rollupjs.org/guide/en#output-globals for details
74
+ const globals = {
75
+ // Provide global variable names to replace your external imports
76
+ // eg. jquery: '$'
77
+ vue: 'Vue',
78
+ };
79
+
80
+ // Customize configs for individual targets
81
+ const buildFormats = [];
82
+ if (!argv.format || argv.format === 'es') {
83
+ const esConfig = {
84
+ ...baseConfig,
85
+ input: 'src/entry.js',
86
+ external,
87
+ output: {
88
+ file: 'dist/seatsio-vue.js',
89
+ format: 'esm',
90
+ exports: 'named',
91
+ },
92
+ plugins: [
93
+ replace(baseConfig.plugins.replace),
94
+ ...baseConfig.plugins.preVue,
95
+ vue(baseConfig.plugins.vue),
96
+ ...baseConfig.plugins.postVue,
97
+ babel({
98
+ ...baseConfig.plugins.babel,
99
+ presets: [
100
+ [
101
+ '@babel/preset-env',
102
+ {
103
+ ...babelPresetEnvConfig,
104
+ targets: esbrowserslist,
105
+ },
106
+ ],
107
+ ],
108
+ }),
109
+ ],
110
+ };
111
+ buildFormats.push(esConfig);
112
+ }
113
+
114
+ if (!argv.format || argv.format === 'iife') {
115
+ const unpkgConfig = {
116
+ ...baseConfig,
117
+ external,
118
+ output: {
119
+ compact: true,
120
+ file: 'dist/seatsio-vue.min.js',
121
+ format: 'iife',
122
+ name: 'SeatsioVue',
123
+ exports: 'named',
124
+ globals,
125
+ },
126
+ plugins: [
127
+ replace(baseConfig.plugins.replace),
128
+ ...baseConfig.plugins.preVue,
129
+ vue(baseConfig.plugins.vue),
130
+ ...baseConfig.plugins.postVue,
131
+ babel(baseConfig.plugins.babel),
132
+ terser({
133
+ output: {
134
+ ecma: 5,
135
+ },
136
+ }),
137
+ ],
138
+ };
139
+ buildFormats.push(unpkgConfig);
140
+ }
141
+
142
+ // Export config
143
+ export default buildFormats;
@@ -0,0 +1,31 @@
1
+ <script>
2
+ export default {
3
+ name: 'ComponentSelector',
4
+ methods: {
5
+ onClick: function(selection) {
6
+ this.$emit('selectChartType', selection)
7
+ }
8
+ }
9
+ }
10
+ </script>
11
+
12
+ <template>
13
+ <ul id="menu">
14
+ <li><button @click="onClick('seatingChart')">Seating Chart</button></li>
15
+ <li><button @click="onClick('chartDesigner')">Designer</button></li>
16
+ <li><button @click="onClick('chartManager')">ChartManager</button></li>
17
+ <li><button @click="onClick('eventManager')">EventManager</button></li>
18
+ </ul>
19
+ </template>
20
+
21
+ <style scoped>
22
+ #menu {
23
+ list-style-type: none;
24
+ display: inline;
25
+ }
26
+
27
+ #menu > li {
28
+ display: inline;
29
+ margin-right: 4px;
30
+ }
31
+ </style>
package/dev/serve.js ADDED
@@ -0,0 +1,4 @@
1
+ import { createApp } from 'vue';
2
+ import ServeDev from './serve.vue'
3
+
4
+ createApp(ServeDev).mount('#app')
package/dev/serve.vue ADDED
@@ -0,0 +1,87 @@
1
+ <script>
2
+ import ComponentSelector from './componentSelector.vue'
3
+ import SeatsioSeatingChart from '@/lib-components/seatsioSeatingChart.vue'
4
+ import SeatsioChartManager from '@/lib-components/seatsioChartManager.vue'
5
+ import SeatsioDesigner from '@/lib-components/seatsioDesigner.vue'
6
+ import SeatsioEventManager from '@/lib-components/seatsioEventManager.vue'
7
+
8
+ export default {
9
+ name: 'ServeDev',
10
+ components: {
11
+ ComponentSelector,
12
+ SeatsioSeatingChart,
13
+ SeatsioChartManager,
14
+ SeatsioDesigner,
15
+ SeatsioEventManager,
16
+ SeatsioSeatingChart,
17
+ },
18
+ data: () => ({
19
+ messages: { clickToSelect: 'Click to pick'},
20
+ objectColor: () => 'grey',
21
+ tooltipInfo: () => 'My custom info',
22
+ selectedComponent: 'seatingChart',
23
+ }),
24
+ methods: {
25
+ onRenderStarted: chart => console.log('Render started', chart),
26
+ onObjectClicked: clickedObject => console.log('Object clicked', clickedObject),
27
+ },
28
+ }
29
+ </script>
30
+
31
+ <template>
32
+ <ComponentSelector @selectChartType="component => selectedComponent = component" />
33
+ <SeatsioSeatingChart
34
+ v-if="selectedComponent === 'seatingChart'"
35
+ id="myChart"
36
+ workspaceKey="publicDemoKey"
37
+ event="smallTheatreEvent"
38
+ region="eu"
39
+ :messages="messages"
40
+ :objectColor="objectColor"
41
+ :tooltipInfo="tooltipInfo"
42
+ @onRenderStarted="onRenderStarted"
43
+ @onObjectClicked="onObjectClicked"
44
+ />
45
+ <SeatsioDesigner
46
+ v-if="selectedComponent === 'chartDesigner'"
47
+ event="437fd038-ba0c-42aa-9ba9-e06bd5b790a3"
48
+ id="myChartDesigner"
49
+ workspaceKey="publicDemoKey"
50
+ mode="readOnly"
51
+ :messages="messages"
52
+ :tooltipInfo="tooltipInfo"
53
+ @onRenderStarted="onRenderStarted"
54
+ @onObjectClicked="onObjectClicked"
55
+ chartKey="0bcf8295-0063-486b-85fe-77b8d85008b5"
56
+ />
57
+ <SeatsioChartManager
58
+ v-if="selectedComponent === 'chartManager'"
59
+ id="myChartManager"
60
+ mode="manageRulesets"
61
+ :messages="messages"
62
+ :tooltipInfo="tooltipInfo"
63
+ @onRenderStarted="onRenderStarted"
64
+ @onObjectClicked="onObjectClicked"
65
+ workspaceKey="<yourWorkspaceKey>"
66
+ chartKey="<yourChartKey>"
67
+ secretKey="<yourWorkspaceSecretKey>"
68
+ />
69
+ <SeatsioEventManager
70
+ v-if="selectedComponent === 'eventManager'"
71
+ id="myEventManager"
72
+ mode="manageCategories"
73
+ :messages="messages"
74
+ :tooltipInfo="tooltipInfo"
75
+ @onRenderStarted="onRenderStarted"
76
+ @onObjectClicked="onObjectClicked"
77
+ event="<yourEventKey"
78
+ secretKey="<yourWorkspaceSecretKey>"
79
+ workspaceKey="<yourWorkspaceKey>"
80
+ />
81
+ </template>
82
+
83
+ <style scoped>
84
+ #myChart, #myChartDesigner, #myChartManager, #myEventManager {
85
+ height: 100vh
86
+ }
87
+ </style>
@@ -0,0 +1,215 @@
1
+ import { openBlock, createElementBlock } from 'vue';
2
+
3
+ var script$4 = {
4
+ mounted() {
5
+ this.createAndRenderChart();
6
+ },
7
+ beforeUnmount() {
8
+ this.destroyChart();
9
+ },
10
+ props: {
11
+ chartJsUrl: {
12
+ type: String,
13
+ default: 'https://cdn-{region}.seatsio.net/chart.js'
14
+ },
15
+ event: String,
16
+ id: {
17
+ type: String,
18
+ default: 'chart'
19
+ },
20
+ extraConfig: Object,
21
+ fitTo: String,
22
+ language: String,
23
+ messages: Object,
24
+ mode: String,
25
+ objectColor: Function,
26
+ objectTooltip: Object,
27
+ workspaceKey: {
28
+ type: String,
29
+ required: true
30
+ },
31
+ region: {
32
+ type: String,
33
+ default: 'eu'
34
+ },
35
+ showFullscreenButton: Boolean,
36
+ tooltipInfo: Function,
37
+ chartKey: String,
38
+ secretKey: String
39
+ },
40
+ methods: {
41
+ createAndRenderChart: async function () {
42
+ const seatsio = await this.getSeatsio();
43
+ const callbacks = {
44
+ onChartRendered: chart => this.$emit('onChartRendered', chart),
45
+ onChartRenderingFailed: chart => this.$emit('onChartRenderingFailed', chart),
46
+ onChartRerenderingStarted: chart => this.$emit('onChartRerenderingStarted', chart),
47
+ onObjectSelected: selectedObject => this.$emit('onObjectSelected', selectedObject),
48
+ onObjectDeselected: deselectedObject => this.$emit('onObjectDeselected', deselectedObject),
49
+ onObjectClicked: clickedObject => this.$emit('onObjectClicked', clickedObject),
50
+ onFullScreenOpened: () => this.$emit('onFullScreenOpened'),
51
+ onFullScreenClosed: () => this.$emit('onFullScreenClosed'),
52
+ onSubmitSucceeded: () => this.$emit('onSubmitSucceeded'),
53
+ onSubmitFailed: () => this.$emit('onSubmitFailed')
54
+ };
55
+ const config = {
56
+ divId: this.$props.id,
57
+ ...this.finaliseProps(this.$props),
58
+ ...callbacks
59
+ };
60
+ this.chart = this.createChart(seatsio, config).render();
61
+ this.chart && this.$emit('onRenderStarted', this.chart);
62
+ },
63
+ finaliseProps: function (props) {
64
+ return props;
65
+ },
66
+ getSeatsio: async function () {
67
+ if (typeof window.seatsio === 'undefined') {
68
+ return this.loadSeatsio();
69
+ } else if (window.seatsio.region !== this.region) {
70
+ window.seatsio = undefined;
71
+ return this.loadSeatsio();
72
+ } else {
73
+ return Promise.resolve(seatsio);
74
+ }
75
+ },
76
+ loadSeatsio: async function () {
77
+ return new Promise((resolve, reject) => {
78
+ let script = document.createElement('script');
79
+ script.onload = () => {
80
+ window.seatsio.region = this.region;
81
+ resolve(window.seatsio);
82
+ };
83
+ script.onerror = () => reject(`Could not load ${script.src}`);
84
+ script.src = this.chartJsUrl.replace('{region}', this.region);
85
+ document.head.appendChild(script);
86
+ });
87
+ },
88
+ destroyChart: function () {
89
+ this.chart.destroy();
90
+ }
91
+ }
92
+ };
93
+
94
+ var script$3 = {
95
+ mixins: [script$4],
96
+ name: 'SeatsioChartManager',
97
+ methods: {
98
+ finaliseProps: function (props) {
99
+ const {
100
+ chartKey,
101
+ chartJsUrl,
102
+ id,
103
+ region,
104
+ showFullscreenButton,
105
+ ...finalProps
106
+ } = props;
107
+ return {
108
+ chart: chartKey,
109
+ ...finalProps
110
+ };
111
+ },
112
+ createChart: (seatsio, config) => {
113
+ return new seatsio.ChartManager(config);
114
+ }
115
+ }
116
+ };
117
+
118
+ const _hoisted_1$3 = ["id"];
119
+ function render$3(_ctx, _cache, $props, $setup, $data, $options) {
120
+ return openBlock(), createElementBlock("div", {
121
+ id: _ctx.id
122
+ }, null, 8, _hoisted_1$3);
123
+ }
124
+
125
+ script$3.render = render$3;
126
+
127
+ var script$2 = {
128
+ mixins: [script$4],
129
+ name: 'SeatsioDesigner',
130
+ methods: {
131
+ createChart: function (seatsio, config) {
132
+ return new seatsio.SeatingChartDesigner(config);
133
+ }
134
+ }
135
+ };
136
+
137
+ const _hoisted_1$2 = ["id"];
138
+ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
139
+ return openBlock(), createElementBlock("div", {
140
+ id: _ctx.id
141
+ }, null, 8, _hoisted_1$2);
142
+ }
143
+
144
+ script$2.render = render$2;
145
+
146
+ var script$1 = {
147
+ mixins: [script$4],
148
+ name: 'SeatsioEventManager',
149
+ methods: {
150
+ finaliseProps: function (props) {
151
+ const {
152
+ chartJsUrl,
153
+ id,
154
+ region,
155
+ showFullscreenButton,
156
+ chartKey,
157
+ ...finalProps
158
+ } = props;
159
+ return {
160
+ chart: chartKey,
161
+ ...finalProps
162
+ };
163
+ },
164
+ createChart: (seatsio, config) => {
165
+ return new seatsio.EventManager(config);
166
+ }
167
+ }
168
+ };
169
+
170
+ const _hoisted_1$1 = ["id"];
171
+ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
172
+ return openBlock(), createElementBlock("div", {
173
+ id: _ctx.id
174
+ }, null, 8, _hoisted_1$1);
175
+ }
176
+
177
+ script$1.render = render$1;
178
+
179
+ var script = {
180
+ mixins: [script$4],
181
+ name: 'SeatsioSeatingChart',
182
+ methods: {
183
+ createChart: function (seatsio, config) {
184
+ return new seatsio.SeatingChart(config);
185
+ }
186
+ }
187
+ };
188
+
189
+ const _hoisted_1 = ["id"];
190
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
191
+ return openBlock(), createElementBlock("div", {
192
+ id: _ctx.id
193
+ }, null, 8, _hoisted_1);
194
+ }
195
+
196
+ script.render = render;
197
+
198
+ const components = {
199
+ SeatsioChartManager: script$3,
200
+ SeatsioDesigner: script$2,
201
+ SeatsioEventManager: script$1,
202
+ SeatsioSeatingChart: script
203
+ };
204
+ var entry = {
205
+ install(app, _options) {
206
+ for (const prop in components) {
207
+ if (components.hasOwnProperty(prop)) {
208
+ const component = components[prop];
209
+ app.component(component.name, component);
210
+ }
211
+ }
212
+ }
213
+ };
214
+
215
+ export { script$3 as SeatsioChartManager, script$2 as SeatsioDesigner, script$1 as SeatsioEventManager, script as SeatsioSeatingChart, entry as default };
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@seatsio/seatsio-vue",
3
+ "version": "1.0.0",
4
+ "license": "MIT",
5
+ "main": "dist/seatsio-vue.js",
6
+ "sideEffects": false,
7
+ "scripts": {
8
+ "serve": "vue-cli-service serve dev/serve.js",
9
+ "prebuild": "rimraf ./dist",
10
+ "build": "cross-env NODE_ENV=production rollup --config build/rollup.config.js"
11
+ },
12
+ "devDependencies": {
13
+ "@babel/core": "^7.14.6",
14
+ "@babel/preset-env": "^7.14.7",
15
+ "@rollup/plugin-alias": "^3.1.2",
16
+ "@rollup/plugin-babel": "^5.3.0",
17
+ "@rollup/plugin-commonjs": "^14.0.0",
18
+ "@rollup/plugin-node-resolve": "^9.0.0",
19
+ "@rollup/plugin-replace": "^2.4.2",
20
+ "@vue/cli-plugin-babel": "^5.0.8",
21
+ "@vue/cli-service": "^5.0.8",
22
+ "cross-env": "^7.0.3",
23
+ "minimist": "^1.2.5",
24
+ "rimraf": "^3.0.2",
25
+ "rollup": "^2.52.8",
26
+ "rollup-plugin-terser": "^7.0.2",
27
+ "rollup-plugin-vue": "^6.0.0",
28
+ "vue": "3.2.47"
29
+ },
30
+ "peerDependencies": {
31
+ "vue": "^3.2.47"
32
+ }
33
+ }
package/src/entry.js ADDED
@@ -0,0 +1,26 @@
1
+ import {
2
+ SeatsioChartManager,
3
+ SeatsioDesigner,
4
+ SeatsioEventManager,
5
+ SeatsioSeatingChart
6
+ } from './lib-components';
7
+
8
+ const components = {
9
+ SeatsioChartManager,
10
+ SeatsioDesigner,
11
+ SeatsioEventManager,
12
+ SeatsioSeatingChart
13
+ }
14
+
15
+ export default {
16
+ install (app, _options) {
17
+ for (const prop in components) {
18
+ if (components.hasOwnProperty(prop)) {
19
+ const component = components[prop]
20
+ app.component(component.name, component)
21
+ }
22
+ }
23
+ }
24
+ }
25
+
26
+ export { SeatsioChartManager, SeatsioDesigner, SeatsioEventManager, SeatsioSeatingChart }
@@ -0,0 +1,5 @@
1
+ /* eslint-disable import/prefer-default-export */
2
+ export { default as SeatsioChartManager } from './seatsioChartManager.vue';
3
+ export { default as SeatsioDesigner } from './seatsioDesigner.vue';
4
+ export { default as SeatsioEventManager } from './seatsioEventManager.vue';
5
+ export { default as SeatsioSeatingChart } from './seatsioSeatingChart.vue';
@@ -0,0 +1,21 @@
1
+ <script>
2
+ import SeatsioEmbeddable from './seatsioEmbeddable.vue'
3
+
4
+ export default {
5
+ mixins: [SeatsioEmbeddable],
6
+ name: 'SeatsioChartManager',
7
+ methods: {
8
+ finaliseProps: function (props) {
9
+ const { chartKey, chartJsUrl, id, region, showFullscreenButton, ...finalProps } = props
10
+ return { chart: chartKey, ...finalProps }
11
+ },
12
+ createChart: (seatsio, config) => {
13
+ return new seatsio.ChartManager(config)
14
+ }
15
+ }
16
+ }
17
+ </script>
18
+
19
+ <template>
20
+ <div :id="id"></div>
21
+ </template>
@@ -0,0 +1,17 @@
1
+ <script>
2
+ import SeatsioEmbeddable from './seatsioEmbeddable.vue'
3
+
4
+ export default {
5
+ mixins: [SeatsioEmbeddable],
6
+ name: 'SeatsioDesigner',
7
+ methods: {
8
+ createChart: function (seatsio, config) {
9
+ return new seatsio.SeatingChartDesigner(config)
10
+ }
11
+ }
12
+ }
13
+ </script>
14
+
15
+ <template>
16
+ <div :id="id"></div>
17
+ </template>
@@ -0,0 +1,77 @@
1
+ <script>
2
+ export default {
3
+ mounted() {
4
+ this.createAndRenderChart()
5
+ },
6
+ beforeUnmount() {
7
+ this.destroyChart()
8
+ },
9
+ props: {
10
+ chartJsUrl: {type: String, default: 'https://cdn-{region}.seatsio.net/chart.js'},
11
+ event: String,
12
+ id: {type: String, default: 'chart'},
13
+ extraConfig: Object,
14
+ fitTo: String,
15
+ language: String,
16
+ messages: Object,
17
+ mode: String,
18
+ objectColor: Function,
19
+ objectTooltip: Object,
20
+ workspaceKey: {type: String, required: true},
21
+ region: {type: String, default: 'eu'},
22
+ showFullscreenButton: Boolean,
23
+ tooltipInfo: Function,
24
+ chartKey: String,
25
+ secretKey: String
26
+ },
27
+ methods: {
28
+ createAndRenderChart: async function () {
29
+ const seatsio = await this.getSeatsio()
30
+ const callbacks = {
31
+ onChartRendered: chart => this.$emit('onChartRendered', chart),
32
+ onChartRenderingFailed: chart => this.$emit('onChartRenderingFailed', chart),
33
+ onChartRerenderingStarted: chart => this.$emit('onChartRerenderingStarted', chart),
34
+ onObjectSelected: selectedObject => this.$emit('onObjectSelected', selectedObject),
35
+ onObjectDeselected: deselectedObject => this.$emit('onObjectDeselected', deselectedObject),
36
+ onObjectClicked: clickedObject => this.$emit('onObjectClicked', clickedObject),
37
+ onFullScreenOpened: () => this.$emit('onFullScreenOpened'),
38
+ onFullScreenClosed: () => this.$emit('onFullScreenClosed'),
39
+ onSubmitSucceeded: () => this.$emit('onSubmitSucceeded'),
40
+ onSubmitFailed: () => this.$emit('onSubmitFailed'),
41
+ }
42
+
43
+ const config = {divId: this.$props.id, ...this.finaliseProps(this.$props), ...callbacks}
44
+ this.chart = this.createChart(seatsio, config).render()
45
+ this.chart && this.$emit('onRenderStarted', this.chart)
46
+ },
47
+ finaliseProps: function (props) {
48
+ return props
49
+ },
50
+ getSeatsio: async function () {
51
+ if (typeof window.seatsio === 'undefined') {
52
+ return this.loadSeatsio()
53
+ } else if (window.seatsio.region !== this.region) {
54
+ window.seatsio = undefined
55
+ return this.loadSeatsio()
56
+ } else {
57
+ return Promise.resolve(seatsio)
58
+ }
59
+ },
60
+ loadSeatsio: async function () {
61
+ return new Promise((resolve, reject) => {
62
+ let script = document.createElement('script')
63
+ script.onload = () => {
64
+ window.seatsio.region = this.region
65
+ resolve(window.seatsio)
66
+ }
67
+ script.onerror = () => reject(`Could not load ${script.src}`)
68
+ script.src = this.chartJsUrl.replace('{region}', this.region)
69
+ document.head.appendChild(script)
70
+ })
71
+ },
72
+ destroyChart: function () {
73
+ this.chart.destroy()
74
+ }
75
+ }
76
+ }
77
+ </script>
@@ -0,0 +1,21 @@
1
+ <script>
2
+ import SeatsioEmbeddable from './seatsioEmbeddable.vue'
3
+
4
+ export default {
5
+ mixins: [SeatsioEmbeddable],
6
+ name: 'SeatsioEventManager',
7
+ methods: {
8
+ finaliseProps: function (props) {
9
+ const { chartJsUrl, id, region, showFullscreenButton, chartKey, ...finalProps } = props
10
+ return { chart: chartKey, ...finalProps }
11
+ },
12
+ createChart: (seatsio, config) => {
13
+ return new seatsio.EventManager(config)
14
+ }
15
+ }
16
+ }
17
+ </script>
18
+
19
+ <template>
20
+ <div :id="id"></div>
21
+ </template>
@@ -0,0 +1,17 @@
1
+ <script>
2
+ import SeatsioEmbeddable from './seatsioEmbeddable.vue'
3
+
4
+ export default {
5
+ mixins: [SeatsioEmbeddable],
6
+ name: 'SeatsioSeatingChart',
7
+ methods: {
8
+ createChart: function (seatsio, config) {
9
+ return new seatsio.SeatingChart(config)
10
+ }
11
+ }
12
+ }
13
+ </script>
14
+
15
+ <template>
16
+ <div :id="id"></div>
17
+ </template>