@abi-software/flatmapvuer 1.17.1-demo.0 → 1.18.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.
@@ -1,24 +1,24 @@
1
- import { defineStore } from 'pinia'
1
+ import { defineStore } from 'pinia';
2
2
 
3
3
  /**
4
4
  * Activate the store when run the application individually.
5
- * If the store exist in parent application,
5
+ * If the store exist in parent application,
6
6
  * instead of creating a new store it will access the parent main store.
7
7
  */
8
8
  export const useMainStore = defineStore('main', {
9
9
  state: () => ({
10
10
  userProfile: {
11
- token: ''
11
+ token: '',
12
12
  },
13
13
  }),
14
14
  getters: {
15
15
  userToken(state) {
16
- return state.userProfile.token
16
+ return state.userProfile.token;
17
17
  },
18
18
  },
19
19
  actions: {
20
20
  setUserToken(value) {
21
- this.userProfile.token = value
21
+ this.userProfile.token = value;
22
22
  },
23
- }
24
- })
23
+ },
24
+ });
package/vite.config.js CHANGED
@@ -1,11 +1,12 @@
1
- import path from "path";
2
- import { defineConfig } from 'vite'
3
- import vue from '@vitejs/plugin-vue'
4
- import Components from 'unplugin-vue-components/vite'
5
- import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
1
+ import path from 'path';
2
+ import { defineConfig } from 'vite';
3
+ import vue from '@vitejs/plugin-vue';
4
+ import AutoImport from 'unplugin-auto-import/vite';
5
+ import Components from 'unplugin-vue-components/vite';
6
+ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
6
7
 
7
8
  // https://vitejs.dev/config/
8
- export default defineConfig(({ command, mode }) => {
9
+ export default defineConfig(({ command }) => {
9
10
  const config = {
10
11
  css: {
11
12
  preprocessorOptions: {
@@ -20,8 +21,11 @@ export default defineConfig(({ command, mode }) => {
20
21
  template: {
21
22
  compilerOptions: {
22
23
  isCustomElement: (tag) => ['bx:grid'].includes(tag),
23
- }
24
- }
24
+ },
25
+ },
26
+ }),
27
+ AutoImport({
28
+ resolvers: [ElementPlusResolver()],
25
29
  }),
26
30
  Components({
27
31
  // allow auto load markdown components under `./src/components/`
@@ -35,52 +39,47 @@ export default defineConfig(({ command, mode }) => {
35
39
  ],
36
40
  dts: 'src/components.d.ts',
37
41
  }),
38
-
39
- // https://github.com/antfu/unocss
40
- // see unocss.config.ts for config
41
42
  ],
42
43
  resolve: {
43
44
  alias: {
44
45
  '@': path.resolve(import.meta.dirname, './src'),
45
- }
46
+ },
46
47
  },
47
48
  build: {
48
49
  lib: {
49
- entry: path.resolve(import.meta.dirname, "./src/components/index.js"),
50
- name: "FlatmapVuer",
50
+ entry: path.resolve(import.meta.dirname, './src/components/index.js'),
51
+ name: 'FlatmapVuer',
51
52
  fileName: 'flatmapvuer',
52
53
  },
53
54
  rollupOptions: {
54
55
  external: [
55
- "vue",
56
- "@abi-software/sparc-annotation",
57
- "@abi-software/svg-sprite",
58
- "@abi-software/map-utilities",
59
- "@element-plus/icons-vue",
60
- "pinia",
61
- "@abi-software/svg-sprite/dist/style.css",
62
- "@abi-software/map-utilities/dist/style.css"
56
+ 'vue',
57
+ '@abi-software/sparc-annotation',
58
+ '@abi-software/svg-sprite',
59
+ '@abi-software/map-utilities',
60
+ '@element-plus/icons-vue',
61
+ 'pinia',
62
+ '@abi-software/svg-sprite/dist/style.css',
63
+ '@abi-software/map-utilities/dist/style.css',
63
64
  ],
64
65
  output: {
65
66
  globals: {
66
- vue: "Vue",
67
- "@abi-software/sparc-annotation": "@abi-software/sparc-annotation",
68
- "@abi-software/svg-sprite": "@abi-software/svg-sprite",
69
- "@abi-software/map-utilities": "@abi-software/map-utilities",
70
- "@element-plus/icons-vue": "@element-plus/icons-vue",
71
- "pinia": "pinia"
67
+ vue: 'Vue',
68
+ '@abi-software/sparc-annotation': '@abi-software/sparc-annotation',
69
+ '@abi-software/svg-sprite': '@abi-software/svg-sprite',
70
+ '@abi-software/map-utilities': '@abi-software/map-utilities',
71
+ '@element-plus/icons-vue': '@element-plus/icons-vue',
72
+ pinia: 'pinia',
72
73
  },
73
74
  // keep css output name stable for the "./dist/style.css" export/import paths
74
75
  assetFileNames: (assetInfo) =>
75
- assetInfo.name?.endsWith(".css")
76
- ? "style.css"
77
- : "assets/[name][extname]",
76
+ assetInfo.name?.endsWith('.css') ? 'style.css' : 'assets/[name][extname]',
78
77
  },
79
78
  },
80
79
  },
81
80
  optimizeDeps: {
82
- entries: ['./cypress/*']
83
- }
81
+ entries: ['./cypress/*'],
82
+ },
84
83
  };
85
84
 
86
85
  if (command === 'serve') {
@@ -89,4 +88,4 @@ export default defineConfig(({ command, mode }) => {
89
88
  };
90
89
  }
91
90
  return config;
92
- })
91
+ });
@@ -1,12 +1,12 @@
1
- import { defineConfig } from 'vite'
2
- import rootConfig from './vite.config.js'
1
+ import { defineConfig } from 'vite';
2
+ import rootConfig from './vite.config.js';
3
3
 
4
4
  // defineWorkspace provides a nice type hinting DX
5
5
  export default defineConfig((configEnv) => {
6
6
  const config = rootConfig(configEnv);
7
7
  config.build = {
8
- outDir: "test-html"
8
+ outDir: 'test-html',
9
9
  };
10
10
 
11
11
  return config;
12
- })
12
+ });
@@ -5,120 +5,111 @@
5
5
  * To watch components changes for Vitepress on Dev Mode
6
6
  */
7
7
 
8
- import fs from 'fs'
9
- import path from 'path'
10
- import chokidar from 'chokidar'
8
+ import fs from 'fs';
9
+ import path from 'path';
10
+ import chokidar from 'chokidar';
11
11
  // import { parser } from '@vuese/parser'
12
- import { parseSource } from 'vue-docgen-api'
13
- import { Render } from '@vuese/markdown-render'
12
+ import { parseSource } from 'vue-docgen-api';
13
+ import { Render } from '@vuese/markdown-render';
14
14
 
15
- const watchMode = process.argv.find((argv) => argv === 'watch')
15
+ const watchMode = process.argv.find((argv) => argv === 'watch');
16
16
 
17
- const componentsDir = 'src/components'
18
- const components = ['FlatmapVuer.vue', 'MultiFlatmapVuer.vue']
19
- const outputDir = 'docs/components'
17
+ const componentsDir = 'src/components';
18
+ const components = ['FlatmapVuer.vue', 'MultiFlatmapVuer.vue'];
19
+ const outputDir = 'docs/components';
20
20
 
21
21
  function generateMarkdown(file) {
22
- const fileWithPath = `${componentsDir}/${file}`
23
- const fileContent = fs.readFileSync(fileWithPath, 'utf-8')
22
+ const fileWithPath = `${componentsDir}/${file}`;
23
+ const fileContent = fs.readFileSync(fileWithPath, 'utf-8');
24
24
 
25
25
  try {
26
26
  // const parserResult = parser(fileContent)
27
- const parserResult = parseSource(fileContent, fileWithPath)
27
+ const parserResult = parseSource(fileContent, fileWithPath);
28
28
  parserResult.then((result) => {
29
- const {
30
- displayName: name,
31
- description: desc,
32
- props,
33
- events,
34
- methods
35
- } = result
29
+ const { displayName: name, description: desc, props, events, methods } = result;
36
30
 
37
31
  // transform props to vuese styles
38
32
  const parseResult = {
39
33
  name: name,
40
34
  componentDesc: {
41
- default: [desc]
35
+ default: [desc],
42
36
  },
43
37
  props: transformData(props),
44
38
  events: transformData(events),
45
39
  methods: transformData(methods),
46
- }
47
- const r = new Render(parseResult)
48
- const renderResult = r.render()
49
- const markdownResult = r.renderMarkdown()
50
- const markdownContent = markdownResult.content
51
- const componentName = path.basename(fileWithPath, '.vue')
40
+ };
41
+ const r = new Render(parseResult);
42
+ const markdownResult = r.renderMarkdown();
43
+ const markdownContent = markdownResult.content;
44
+ const componentName = path.basename(fileWithPath, '.vue');
52
45
 
53
46
  if (!fs.existsSync(outputDir)) {
54
- fs.mkdirSync(outputDir)
47
+ fs.mkdirSync(outputDir);
55
48
  }
56
49
 
57
50
  fs.writeFile(`${outputDir}/${componentName}.md`, markdownContent, (err) => {
58
51
  if (err) {
59
- console.error(`Error writing markdown file for ${componentName}`, err)
52
+ console.error(`Error writing markdown file for ${componentName}`, err);
60
53
  } else {
61
- console.log(`Markdown file for ${componentName} is generated!`)
54
+ console.log(`Markdown file for ${componentName} is generated!`);
62
55
  }
63
- })
64
- })
65
- } catch(e) {
66
- console.error(e)
56
+ });
57
+ });
58
+ } catch (e) {
59
+ console.error(e);
67
60
  }
68
61
  }
69
62
 
70
63
  function transformData(data = []) {
71
64
  data.forEach((prop) => {
72
- prop.name = prop.name
73
-
74
65
  if (prop.description) {
75
- prop.describe = [prop.description.replaceAll('\n', ' ')]
66
+ prop.describe = [prop.description.replaceAll('\n', ' ')];
76
67
  }
77
68
 
78
69
  if (prop.type) {
79
- prop.type = prop.type.name
70
+ prop.type = prop.type.name;
80
71
  }
81
72
 
82
73
  if (prop.defaultValue) {
83
- prop.default = prop.defaultValue.value.replaceAll('\n', ' ')
74
+ prop.default = prop.defaultValue.value.replaceAll('\n', ' ');
84
75
  }
85
76
 
86
77
  // events
87
78
  if (prop.properties) {
88
- prop.argumentsDesc = []
79
+ prop.argumentsDesc = [];
89
80
  prop.properties.forEach((param) => {
90
- const argName = param.name || param.description
91
- prop.argumentsDesc.push(argName)
92
- })
81
+ const argName = param.name || param.description;
82
+ prop.argumentsDesc.push(argName);
83
+ });
93
84
  }
94
85
 
95
86
  // methods
96
87
  if (prop.params) {
97
- prop.argumentsDesc = []
88
+ prop.argumentsDesc = [];
98
89
  prop.params.forEach((param) => {
99
- const argName = param.description || param.name
100
- prop.argumentsDesc.push(argName)
101
- })
90
+ const argName = param.description || param.name;
91
+ prop.argumentsDesc.push(argName);
92
+ });
102
93
  }
103
- })
104
- return data
94
+ });
95
+ return data;
105
96
  }
106
97
 
107
98
  // To generate markdown files - one time
108
99
  components.forEach((component) => {
109
- console.log(`Write markdown file for ${component} on first load.`)
110
- generateMarkdown(component)
111
- })
100
+ console.log(`Write markdown file for ${component} on first load.`);
101
+ generateMarkdown(component);
102
+ });
112
103
 
113
104
  // To watch component changes and generate markdown files
114
105
  if (watchMode) {
115
106
  const watcher = chokidar.watch(components, {
116
107
  cwd: componentsDir,
117
108
  ignoreInitial: true,
118
- })
109
+ });
119
110
 
120
111
  watcher.on('change', (file) => {
121
- console.log(`The component ${file} has changed!`)
122
- generateMarkdown(file)
123
- })
124
- }
112
+ console.log(`The component ${file} has changed!`);
113
+ generateMarkdown(file);
114
+ });
115
+ }
@@ -1,125 +0,0 @@
1
- const SOMA_MARKER_COLOUR = '#1b7f6b'
2
- const SOMA_MARKER_SECONDARY_COLOUR = '#f4f1de'
3
- const SOMA_MARKER_TEXT_COLOUR = '#12312b'
4
- const SOMA_MARKER_MAX_COUNT_LABEL = '99+'
5
-
6
- const normalizeSomaLocations = function (somaLocations) {
7
- return (Array.isArray(somaLocations) ? somaLocations : [])
8
- .map((item) => ({
9
- label: String(item?.label || '').trim(),
10
- curie: String(item?.curie || '').trim(),
11
- count: Number(item?.count || 0),
12
- }))
13
- .filter((item) => item.curie && item.count > 0)
14
- }
15
-
16
- const formatCount = function (count) {
17
- if (count > 99) return SOMA_MARKER_MAX_COUNT_LABEL
18
- return String(count)
19
- }
20
-
21
- const createSomaLocationMarkerElement = function (somaLocation) {
22
- const wrapper = document.createElement('div')
23
- wrapper.className = 'flatmapvuer-soma-location-marker'
24
- wrapper.title = somaLocation.label || somaLocation.curie
25
- wrapper.style.width = '34px'
26
- wrapper.style.height = '48px'
27
- wrapper.style.display = 'flex'
28
- wrapper.style.alignItems = 'center'
29
- wrapper.style.justifyContent = 'center'
30
- wrapper.style.transform = 'translate(-50%, -100%)'
31
-
32
- const countLabel = formatCount(somaLocation.count)
33
- wrapper.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="-1 -1 27 42" width="34" height="48" aria-hidden="true">
34
- <ellipse style="fill: rgb(0, 0, 0); fill-opacity: 0.18;" cx="12" cy="36" rx="8" ry="4"/>
35
- <path d="M12.25.25a12.254 12.254 0 0 0-12 12.494
36
- c0 6.444 6.488 12.109 11.059 22.564.549 1.256 1.333 1.256 1.882 0
37
- C17.762 24.853 24.25 19.186 24.25 12.744A12.254 12.254 0 0 0 12.25.25Z"
38
- style="fill:${SOMA_MARKER_COLOUR};stroke:${SOMA_MARKER_SECONDARY_COLOUR};stroke-width:1.1"/>
39
- <circle cx="12.5" cy="12.5" r="8" fill="${SOMA_MARKER_SECONDARY_COLOUR}"/>
40
- <text x="12.5" y="16.1" text-anchor="middle" style="font-size:7.5px;font-weight:700;fill:${SOMA_MARKER_TEXT_COLOUR};font-family:Arial, sans-serif">${countLabel}</text>
41
- </svg>`
42
-
43
- return wrapper
44
- }
45
-
46
- const resolveMarkerPlacement = function (mapImp, curie) {
47
- const featureIds = Array.isArray(mapImp?.modelFeatureIds?.(curie)) ? mapImp.modelFeatureIds(curie) : []
48
- const placements = []
49
- const seenFeatureUris = new Set()
50
-
51
- for (const featureId of featureIds) {
52
- const annotation = mapImp.annotation(featureId)
53
- const featureUri = String(annotation?.uri || '').trim()
54
- if (featureUri && !seenFeatureUris.has(featureUri)) {
55
- seenFeatureUris.add(featureUri)
56
- placements.push({
57
- type: 'feature-uri',
58
- value: featureUri,
59
- })
60
- }
61
- }
62
-
63
- // Fall back to model placement only when no feature URI can be resolved.
64
- if (!placements.length && featureIds.length) {
65
- placements.push({
66
- type: 'model',
67
- value: curie,
68
- })
69
- }
70
-
71
- return placements
72
- }
73
-
74
- export const attachSomaLocationMarkerMethods = function (mapImp) {
75
- if (!mapImp || mapImp.addSomaLocationMarkers) {
76
- return mapImp
77
- }
78
-
79
- let markerIds = []
80
-
81
- mapImp.clearSomaLocationMarkers = function () {
82
- markerIds.forEach((markerId) => {
83
- mapImp.removeMarker(markerId)
84
- })
85
- markerIds = []
86
- }
87
-
88
- mapImp.addSomaLocationMarkers = function (somaLocations) {
89
- const normalizedSomaLocations = normalizeSomaLocations(somaLocations)
90
- const placedSomaLocations = []
91
-
92
- mapImp.clearSomaLocationMarkers()
93
-
94
- normalizedSomaLocations.forEach((somaLocation) => {
95
- const placements = resolveMarkerPlacement(mapImp, somaLocation.curie)
96
- if (!placements.length) return
97
-
98
- let somaLocationPlaced = false
99
- placements.forEach((placement) => {
100
- const markerElement = createSomaLocationMarkerElement(somaLocation)
101
- let addedMarkerIds = []
102
-
103
- if (placement.type === 'feature-uri') {
104
- addedMarkerIds = mapImp.addMarkerByFeatureUri(placement.value, { element: markerElement })
105
- } else if (placement.type === 'model') {
106
- const markerId = mapImp.addMarker(placement.value, { element: markerElement })
107
- addedMarkerIds = markerId > -1 ? [markerId] : []
108
- }
109
-
110
- if (!addedMarkerIds.length) return
111
-
112
- markerIds.push(...addedMarkerIds)
113
- somaLocationPlaced = true
114
- })
115
-
116
- if (somaLocationPlaced) {
117
- placedSomaLocations.push(somaLocation)
118
- }
119
- })
120
-
121
- return placedSomaLocations
122
- }
123
-
124
- return mapImp
125
- }