@questwork/vue-q-list-vue3 3.1.0 → 3.1.2

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.
@@ -75,7 +75,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
75
75
  ---
76
76
 
77
77
  Name: @questwork/utilities
78
- Version: 0.1.65
78
+ Version: 0.1.67
79
79
  License: MIT
80
80
  Private: false
81
81
  Description: Questwork utilities
@@ -103,4 +103,25 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
103
103
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
104
104
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
105
105
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
106
- THE SOFTWARE.
106
+ THE SOFTWARE.
107
+
108
+ ---
109
+
110
+ Name: @questwork/q-utilities
111
+ Version: 0.1.12
112
+ License: MIT
113
+ Private: false
114
+ Description: Questwork QUtilities
115
+ Author: Questwork Consulting Limited <info@questwork.com> (https://questwork.com/)
116
+ License Copyright:
117
+ ===
118
+
119
+ Copyright 2019 Questwork Consulting Limited
120
+
121
+ This project is free software released under the MIT/X11 license:
122
+
123
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
124
+
125
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
126
+
127
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ const { getValidation } = require("./getValidation")
2
+ const { getValue } = require("./getValue")
3
+
4
+ function getTitle(titleTemplate, data) {
5
+ return titleTemplate.reduce((acc, item) => {
6
+ const { type, value = '', restriction, template, format, showMinutes } = item
7
+ switch (type) {
8
+ case('label'): {
9
+ if (getValidation({ rule: restriction, data })) {
10
+ acc += (value.toString())
11
+ }
12
+ break
13
+ }
14
+ case('value'): {
15
+ if (getValidation({ rule: restriction, data })) {
16
+ const _value = getValue(value, data) || ''
17
+ acc += (_value.toString())
18
+ }
19
+ break
20
+ }
21
+ case('array'): {
22
+ if (getValidation({ rule: restriction, data })) {
23
+ const _value = getValue(value, data) || []
24
+ acc += _value.reduce((_acc, item) => {
25
+ return _acc += getTitle(template, item)
26
+ }, '')
27
+ }
28
+
29
+ break
30
+ }
31
+ case('ellipsis'): {
32
+ if (getValidation({ rule: restriction, data })) {
33
+ const { maxLength } = item
34
+ const _value = getValue(value, data) || ''
35
+ if (_value.length <= maxLength) {
36
+ acc += (_value.toString())
37
+ } else {
38
+ acc += `${_value.substr(0, maxLength)}...`
39
+ }
40
+ }
41
+ break
42
+ }
43
+ case ('date'): {
44
+ if (getValidation({ rule: restriction, data })) {
45
+ const _value = getValue(value, data) || ''
46
+ acc += (formatDate({ date: _value, showMinutes, format }).toString())
47
+ }
48
+ break
49
+ }
50
+ }
51
+ return acc
52
+ }, '')
53
+ }
54
+
55
+ module.exports = {
56
+ getTitle
57
+ }
@@ -0,0 +1,26 @@
1
+ function getTooltipPosition({ tooltipContainer, cellText, window }) {
2
+ const containerRect = tooltipContainer.getBoundingClientRect()
3
+ const textRect = cellText.getBoundingClientRect()
4
+
5
+ let left = textRect.left + window.scrollX
6
+ let top = textRect.bottom + window.scrollY
7
+
8
+ if (left + containerRect.width > window.innerWidth) {
9
+ left = window.innerWidth - containerRect.width
10
+ }
11
+
12
+ if (top + containerRect.height > window.innerHeight) {
13
+ top = textRect.top + window.scrollY - containerRect.height
14
+ }
15
+
16
+ if (top < 0) {
17
+ top = textRect.bottom + window.scrollY
18
+ }
19
+
20
+ tooltipContainer.style.left = `${left}px`
21
+ tooltipContainer.style.top = `${top}px`
22
+ }
23
+
24
+ module.exports = {
25
+ getTooltipPosition
26
+ }
@@ -0,0 +1,11 @@
1
+ const { getValue } = require('./getValue')
2
+
3
+ const { getValidation: _getValidation, KeyValueObject } = require('@questwork/q-utilities')
4
+
5
+ function getValidation({ rule, data }) {
6
+ return _getValidation(rule, data, getValue, KeyValueObject)
7
+ }
8
+
9
+ module.exports = {
10
+ getValidation
11
+ }
@@ -0,0 +1,21 @@
1
+ const { getValueByKeys} = require('@questwork/q-utilities')
2
+
3
+ function getValue(key, value) {
4
+ return getValueByKeys(key.split('.'), value)
5
+ // return getValueInObj({ keys: key.split('.'), obj: value })
6
+ }
7
+
8
+ function getValueInObj({ keys, obj }) {
9
+ if (keys.length === 0) {
10
+ return obj
11
+ }
12
+ const firstKey = keys.shift()
13
+ if (obj && obj.hasOwnProperty(firstKey)) {
14
+ return getValueInObj({ keys, obj: obj[firstKey] })
15
+ }
16
+ return obj
17
+ }
18
+
19
+ module.exports = {
20
+ getValue
21
+ }
@@ -1,6 +1,13 @@
1
1
  const { getPopupPosition } = require('./getPopupPosition')
2
+ const { getTitle } = require('./getTitle')
3
+ const { getTooltipPosition } = require('./getTooltipPosition')
4
+ const { getValidation } = require('./getValidation')
5
+ const { getValue } = require('./getValue')
2
6
 
3
7
  module.exports = {
4
- getPopupPosition
8
+ getPopupPosition,
9
+ getTitle,
10
+ getTooltipPosition,
11
+ getValidation,
12
+ getValue
5
13
  }
6
- exports.getPopupPosition = getPopupPosition
package/lib/index.js CHANGED
@@ -1,11 +1,7 @@
1
- // const factories = require('./factories')
2
1
  const models = require('./models')
2
+ const helpers = require('./helpers')
3
3
 
4
4
  module.exports = {
5
- // ...factories,
6
5
  ...models,
6
+ ...helpers
7
7
  }
8
-
9
- exports.QListBulkButton = models.QListBulkButton
10
- exports.QRow = models.QRow
11
- exports.QListButton = models.QListButton
@@ -2,6 +2,7 @@ const { KeyValueObject } = require('../keyValueObject')
2
2
  class QListButton {
3
3
  constructor(options = {}) {
4
4
  options = options || {}
5
+ this.id = options.actionId
5
6
  this.active = (typeof options.active !== 'undefined') ? !!options.active : true
6
7
  this.creator = options.creator
7
8
  this.css = options.css || {}
@@ -1,5 +1,5 @@
1
1
  const { QRow } = require('./qRow')
2
2
 
3
3
  module.exports = {
4
- QRow
4
+ QRow,
5
5
  }
@@ -1,4 +1,5 @@
1
1
  const { dateHelper } = require('@questwork/utilities/lib/dateHelper')
2
+ const { TemplateCompiler } = require('@questwork/q-utilities')
2
3
 
3
4
  class QRow {
4
5
  constructor(options = {}) {
@@ -9,6 +10,7 @@ class QRow {
9
10
  this.cssNames = options.cssNames || []
10
11
  this.deleted = options.deleted || false
11
12
  this.duration = options.duration
13
+ this.editable = (typeof options.editable === 'boolean') ? options.editable : true
12
14
  this.getActions = options.getActions
13
15
  this.new = options.new || false
14
16
  this.owner = options.owner
@@ -17,6 +19,7 @@ class QRow {
17
19
  this.shouldBeVisible = setShouldBeVisible(options.shouldBeVisible || null)
18
20
  this.uniqueKey = options.uniqueKey
19
21
  this.unread = options.unread || false
22
+ this._templateCompiler = TemplateCompiler.init(this.row)
20
23
  }
21
24
 
22
25
  // Class methods
@@ -80,6 +83,10 @@ class QRow {
80
83
  // const realKey = arr[1]
81
84
  // return this[realKey]
82
85
  }
86
+ // check if regular expr
87
+ if (_useTemplateCompiler(key)) {
88
+ return this._templateCompiler.pipe(key)
89
+ }
83
90
  if (key.includes('.')) {
84
91
  const arr = key.split('.')
85
92
  return getRecursiveValue(this.row, arr)
@@ -145,11 +152,24 @@ class QRow {
145
152
  return cssArr
146
153
  }
147
154
 
155
+ // pipe(templateCompiler) {
156
+ // if (!this._templateCompiler && typeof templateCompiler.init === 'function') {
157
+ // this._templateCompiler = templateCompiler.init(this.row)
158
+ // }
159
+ // return (expr) => {
160
+ // return this._templateCompiler.pipe(expr)
161
+ // }
162
+ // }
163
+
148
164
  removeCss(className) {
149
165
  this.cssNames = this.cssNames.filter((e) => (e !== className))
150
166
  return this
151
167
  }
152
168
 
169
+ setEditable(val) {
170
+ this.editable = val
171
+ }
172
+
153
173
  toggleActive() {
154
174
  this.active = !this.active
155
175
  this.new = false
@@ -207,6 +227,11 @@ function setShouldBeVisible(shouldBeVisible) {
207
227
  }
208
228
  }
209
229
 
230
+ function _useTemplateCompiler(key) {
231
+ key = key.trim()
232
+ return (key.indexOf('{{') === 0) || (key.indexOf('<%') === 0)
233
+ }
234
+
210
235
  module.exports = {
211
- QRow
236
+ QRow,
212
237
  }
package/package.json CHANGED
@@ -1,70 +1,65 @@
1
1
  {
2
2
  "name": "@questwork/vue-q-list-vue3",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "Questwork vue component for displaying a list",
5
- "main": "dist/q-list.min.js",
5
+ "exports": {
6
+ ".": {
7
+ "import": "./dist/q-list.min.js",
8
+ "require": "./dist/q-list.min.js"
9
+ },
10
+ "./style.css": "./dist/q-list.min.css"
11
+ },
6
12
  "author": {
7
13
  "name": "Questwork Consulting Limited",
8
14
  "email": "info@questwork.com",
9
15
  "url": "http://www.questwork.com/"
10
16
  },
11
17
  "license": "MIT",
18
+ "dependencies": {
19
+ "@questwork/q-utilities": "^0.1.12"
20
+ },
12
21
  "devDependencies": {
13
22
  "@babel/core": "^7.17.8",
14
23
  "@babel/eslint-parser": "^7.17.0",
15
24
  "@babel/preset-env": "^7.22.10",
16
- "@questwork/utilities": "^0.1.51",
25
+ "@questwork/utilities": "^0.1.67",
17
26
  "@questwork/vue-q-buttons-vue3": "^3.1.0",
18
27
  "@questwork/vue-q-paginator-vue3": "^3.1.0",
19
- "@storybook/addon-links": "^7.3.2",
20
- "@storybook/addon-viewport": "^7.3.2",
21
- "@storybook/source-loader": "^7.3.2",
22
- "@storybook/vue": "^7.3.2",
23
- "@storybook/vue-webpack5": "^7.3.2",
24
- "@storybook/vue3": "^7.3.2",
25
- "@storybook/vue3-vite": "^7.3.2",
26
- "@vitejs/plugin-vue": "^5.1.4",
28
+ "@storybook/addon-essentials": "8.5.3",
29
+ "@storybook/addon-links": "^8.4.7",
30
+ "@storybook/addon-viewport": "^8.4.7",
31
+ "@storybook/vue3": "^8.4.7",
32
+ "@storybook/vue3-vite": "^8.4.7",
33
+ "@vitejs/plugin-vue": "^5.2.1",
27
34
  "babel-loader": "^8.2.4",
28
35
  "chai": "^4.3.6",
29
36
  "chromedriver": "^116.0.0",
30
- "clean-webpack-plugin": "^3.0.0",
37
+ "color-name": "^2.0.0",
31
38
  "cross-env": "^7.0.3",
32
- "css-loader": "^3.6.0",
33
39
  "eslint": "^8.47.0",
34
- "eslint-plugin-storybook": "^0.9.0",
35
- "eslint-plugin-vue": "^9.29.0",
36
- "file-loader": "^6.2.0",
37
- "gulp": "^4.0.2",
40
+ "eslint-plugin-storybook": "^0.11.1",
41
+ "eslint-plugin-vue": "^9.32.0",
38
42
  "mocha": "^9.2.2",
39
43
  "rollup-plugin-license": "^3.5.3",
40
- "rollup-webpack-umd": "^0.1.2",
41
- "sass": "^1.49.11",
42
- "sass-loader": "^8.0.2",
44
+ "sass": "^1.83.4",
43
45
  "selenium-webdriver": "^4.11.1",
44
46
  "sinon": "^9.2.4",
45
47
  "sinon-chai": "^3.7.0",
46
- "storybook": "^7.3.2",
47
- "style-loader": "^1.3.0",
48
- "url-loader": "^4.1.1",
48
+ "storybook": "^8.4.7",
49
49
  "vite": "^5.4.9",
50
50
  "vite-plugin-commonjs": "^0.10.3",
51
- "vite-plugin-lib-inject-css": "^2.1.1",
52
- "vue": "^3.5.12",
53
- "vue-loader": "^15.9.8",
54
- "vue-template-compiler": "^2.6.14",
55
- "webpack": "^5.71.0",
56
- "webpack-cli": "^4.9.2",
57
- "webpack-merge": "^4.2.2",
58
- "webpack-node-externals": "^1.7.2"
51
+ "vue": "^3.5.12"
59
52
  },
60
53
  "engines": {
61
54
  "node": ">=10.0.0"
62
55
  },
63
56
  "scripts": {
64
57
  "build": "vite build",
58
+ "build:copy": "vite build && cp -r dist/*.js '../congress.system/public/libs/vue.v3/' && cp -r dist/*.js '../wordpress.plugins/wp-q-components/assets/js/vue.v3/' && cp -r dist/*.css '../congress.system/public/userfile/shared/css/vue.v3/' && cp -r dist/*.css '../wordpress.plugins/wp-q-components/assets/css/vue.v3/'",
59
+ "build:wordpress": "vite build && cp -r dist/* '../wordpress.plugins/wp-q-components/assets/js/'",
65
60
  "build:storybook": "storybook build -c .storybook -o storybook",
66
61
  "storybook": "storybook dev -p 6017",
67
- "test:playground": "NODE_ENV=test mocha --no-timeouts 'lib/test.setup.js' 'lib/**/*.spec.js'",
68
- "test:selenium": "NODE_ENV=test mocha --no-timeouts 'test/selenium/test.setup.js' 'test/selenium/**/*.spec.js'"
62
+ "test:playground": "cross-env NODE_ENV=test mocha --no-timeouts 'lib/test.setup.js' 'lib/**/*.spec.js'",
63
+ "test:selenium": "cross-env NODE_ENV=test mocha --no-timeouts 'test/selenium/test.setup.js' 'test/selenium/**/*.spec.js'"
69
64
  }
70
65
  }
package/vite.config.js CHANGED
@@ -1,19 +1,13 @@
1
- import { fileURLToPath, URL } from 'node:url'
2
1
  import { defineConfig } from 'vite'
3
- import { libInjectCss } from 'vite-plugin-lib-inject-css'
4
2
  import vue from '@vitejs/plugin-vue'
5
3
  import license from 'rollup-plugin-license'
6
4
  import commonjs from 'vite-plugin-commonjs'
7
- import rewriteUmdPlugin from 'rollup-webpack-umd'
8
5
 
9
- // 与 ./webpack/prod.config.js 的 output.library 名一致
10
6
  const libName = 'QList'
11
- // libName 的 kebab-case 格式
12
7
  const fileName = 'q-list'
13
8
 
14
9
  export default defineConfig({
15
10
  build: {
16
- target: ['chrome100', 'safari15', 'firefox91'],
17
11
  lib: {
18
12
  entry: './src/index.js',
19
13
  name: libName,
@@ -23,6 +17,7 @@ export default defineConfig({
23
17
  rollupOptions: {
24
18
  external: ['vue'],
25
19
  output: {
20
+ assetFileNames: `${fileName}.min.[ext]`,
26
21
  globals: {
27
22
  vue: 'Vue',
28
23
  },
@@ -39,20 +34,19 @@ export default defineConfig({
39
34
  }),
40
35
  ],
41
36
  },
37
+ target: ['chrome100', 'safari15', 'firefox91'],
38
+ terserOptions: {
39
+ compress: false,
40
+ mangle: false,
41
+ },
42
42
  },
43
43
  esbuild: {
44
44
  legalComments: 'none',
45
45
  },
46
46
  plugins: [
47
47
  vue(),
48
- libInjectCss(),
49
48
  commonjs(),
50
49
  ],
51
- resolve: {
52
- alias: {
53
- '@': fileURLToPath(new URL('./src', import.meta.url)),
54
- },
55
- },
56
50
  css: {
57
51
  preprocessorOptions: {
58
52
  scss: {
@@ -61,3 +55,48 @@ export default defineConfig({
61
55
  },
62
56
  },
63
57
  })
58
+
59
+ function rewriteUmdPlugin(options) {
60
+ const {
61
+ banner
62
+ } = options || {}
63
+ return {
64
+ name: "rewrite-umd",
65
+ generateBundle(_ctx, options2) {
66
+ if (_ctx.format !== "umd") {
67
+ return
68
+ }
69
+ const data = Object.values(options2)[0]
70
+ const { code, exports, imports } = data
71
+ const defineReg = /^\(function\((?<root>\w+),(?<factory>\w+)\)\{(?<rest>.*?)\|\|self,(?<scriptTag>.*?)\)\}\)\(this,function/s
72
+ const rewritten = code
73
+ .replace(defineReg, (...args) => {
74
+ const { root, factory, scriptTag } = args.at(-1)
75
+ return `${banner || ""}
76
+ ;(function(${root},${factory}){
77
+ if (typeof exports == "object" && typeof module < "u") { // for commonjs
78
+ const returns = {}
79
+ ${factory}(returns, ${imports.map((i) => `require("${i}")`).join(", ")});
80
+ module.exports = returns;
81
+ ${exports.map((exp) => `exports.${exp} = returns.${exp};`).join("\n")}
82
+ }
83
+ else if (typeof define == "function" && define.amd) { // for amd
84
+ define(["exports", ${imports.map((i) => `"${i}"`).join(", ")}], ${factory});
85
+ }
86
+ else { // for browser script tag
87
+ ${root} = (typeof globalThis < "u") ? globalThis : ${root} || self;
88
+ ${scriptTag};
89
+ }
90
+ })(this,function`
91
+ })
92
+
93
+ // return the exports object at the end
94
+ .replace(new RegExp(/Object.defineProperty\((?<name>\w+),Symbol.toStringTag,{value:"Module"}\)}\);/), (...args) => {
95
+ const { name } = args.at(-1)
96
+ return `Object.defineProperty(${name},Symbol.toStringTag,{value:"Module"}); return ${name}; });`
97
+ })
98
+
99
+ data.code = rewritten
100
+ }
101
+ }
102
+ }
@@ -1,6 +0,0 @@
1
- const qListButtonFactory = require('./qListButtonFactory')
2
-
3
- module.exports = {
4
- ...qListButtonFactory,
5
- }
6
- exports.QListButtonFactory = qListButtonFactory.QListButtonFactory
@@ -1,5 +0,0 @@
1
- const { QListButtonFactory } = require('./qListButtonFactory')
2
-
3
- module.exports = {
4
- QListButtonFactory
5
- }
@@ -1,16 +0,0 @@
1
- // const { QListButton } = require('../../models')
2
-
3
- // class QListButtonFactory {
4
- // static init(options) {
5
- // const { action, qRow, row } = options
6
- // if (action.qListButtonType) {
7
- // return new QListButton(action)
8
- // }
9
- // return action
10
- // }
11
- // }
12
-
13
- // module.exports = {
14
- // QListButtonFactory
15
- // }
16
-