@questwork/vue-q-list-vue3 3.1.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,106 @@
1
+ Name: moment
2
+ Version: 2.30.1
3
+ License: MIT
4
+ Private: false
5
+ Description: Parse, validate, manipulate, and display dates
6
+ Repository: https://github.com/moment/moment.git
7
+ Homepage: https://momentjs.com
8
+ Author: Iskren Ivov Chernev <iskren.chernev@gmail.com> (https://github.com/ichernev)
9
+ Contributors:
10
+ Tim Wood <washwithcare@gmail.com> (http://timwoodcreates.com/)
11
+ Rocky Meza (http://rockymeza.com)
12
+ Matt Johnson <mj1856@hotmail.com> (http://codeofmatt.com)
13
+ Isaac Cambron <isaac@isaaccambron.com> (http://isaaccambron.com)
14
+ Andre Polykanine <andre@oire.org> (https://github.com/oire)
15
+ License Copyright:
16
+ ===
17
+
18
+ Copyright (c) JS Foundation and other contributors
19
+
20
+ Permission is hereby granted, free of charge, to any person
21
+ obtaining a copy of this software and associated documentation
22
+ files (the "Software"), to deal in the Software without
23
+ restriction, including without limitation the rights to use,
24
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
25
+ copies of the Software, and to permit persons to whom the
26
+ Software is furnished to do so, subject to the following
27
+ conditions:
28
+
29
+ The above copyright notice and this permission notice shall be
30
+ included in all copies or substantial portions of the Software.
31
+
32
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
34
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
35
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
36
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
37
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
38
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
39
+ OTHER DEALINGS IN THE SOFTWARE.
40
+
41
+ ---
42
+
43
+ Name: moment-timezone
44
+ Version: 0.5.46
45
+ License: MIT
46
+ Private: false
47
+ Description: Parse and display moments in any timezone.
48
+ Repository: https://github.com/moment/moment-timezone.git
49
+ Homepage: http://momentjs.com/timezone/
50
+ Author: Tim Wood <washwithcare@gmail.com> (http://timwoodcreates.com/)
51
+ License Copyright:
52
+ ===
53
+
54
+ The MIT License (MIT)
55
+
56
+ Copyright (c) JS Foundation and other contributors
57
+
58
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
59
+ this software and associated documentation files (the "Software"), to deal in
60
+ the Software without restriction, including without limitation the rights to
61
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
62
+ the Software, and to permit persons to whom the Software is furnished to do so,
63
+ subject to the following conditions:
64
+
65
+ The above copyright notice and this permission notice shall be included in all
66
+ copies or substantial portions of the Software.
67
+
68
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
69
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
70
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
71
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
72
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
73
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
74
+
75
+ ---
76
+
77
+ Name: @questwork/utilities
78
+ Version: 0.1.65
79
+ License: MIT
80
+ Private: false
81
+ Description: Questwork utilities
82
+ Author: Questwork Consulting Limited <info@questwork.com> (https://questwork.com/)
83
+ License Copyright:
84
+ ===
85
+
86
+ Copyright 2019 Questwork Consulting Limited
87
+
88
+ This project is free software released under the MIT/X11 license:
89
+
90
+ Permission is hereby granted, free of charge, to any person obtaining a copy
91
+ of this software and associated documentation files (the "Software"), to deal
92
+ in the Software without restriction, including without limitation the rights
93
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
94
+ copies of the Software, and to permit persons to whom the Software is
95
+ furnished to do so, subject to the following conditions:
96
+
97
+ The above copyright notice and this permission notice shall be included in
98
+ all copies or substantial portions of the Software.
99
+
100
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
101
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
102
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
103
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
104
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
105
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
106
+ THE SOFTWARE.
@@ -0,0 +1,6 @@
1
+ const qListButtonFactory = require('./qListButtonFactory')
2
+
3
+ module.exports = {
4
+ ...qListButtonFactory,
5
+ }
6
+ exports.QListButtonFactory = qListButtonFactory.QListButtonFactory
@@ -0,0 +1,5 @@
1
+ const { QListButtonFactory } = require('./qListButtonFactory')
2
+
3
+ module.exports = {
4
+ QListButtonFactory
5
+ }
@@ -0,0 +1,16 @@
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
+
@@ -0,0 +1,64 @@
1
+
2
+ function getPopupPosition({ popupContainer, popupButton, qList, window }) {
3
+ const windowWidth = window.innerWidth
4
+ const windowHeight = window.innerHeight
5
+ const {
6
+ bottom: qListBottom,
7
+ height: qListHeight,
8
+ left: qListLeft,
9
+ right: qListRight,
10
+ top: qListTop,
11
+ width: qListWidth
12
+ } = qList.getBoundingClientRect()
13
+
14
+ // get popup width and height, bottom and right
15
+ const {
16
+ bottom: popupBottom,
17
+ height: popupHeight,
18
+ left: popupLeft,
19
+ right: popupRight,
20
+ top: popupTop,
21
+ width: popupWidth
22
+ } = popupContainer.getBoundingClientRect()
23
+
24
+ const {
25
+ bottom: popupButtonBottom,
26
+ height: popupButtonHeight,
27
+ left: popupButtonLeft,
28
+ right: popupButtonRight,
29
+ top: popupButtonTop,
30
+ width: popupButtonWidth,
31
+ } = popupButton.getBoundingClientRect()
32
+
33
+
34
+ const top = qListTop > 0 ? qListTop : 0
35
+ const bottom = windowHeight > qListBottom ? qListBottom : windowHeight
36
+
37
+ const _popupHeight = (bottom - top) > popupHeight ? popupHeight : (bottom - top)
38
+
39
+ let popupTransform = {
40
+ x: popupLeft - popupButtonRight,
41
+ y: popupTop - popupButtonTop - popupButtonHeight,
42
+ }
43
+ // get position
44
+ const currentRight = qListRight - (popupLeft - popupTransform.x + popupWidth)
45
+ const transformedPopupBottom = (popupTop - popupTransform.y + _popupHeight)
46
+ const currentBottom = bottom - transformedPopupBottom
47
+
48
+ if (currentRight < 0) {
49
+ popupTransform.x = popupTransform.x + popupButtonWidth + popupWidth
50
+ }
51
+
52
+ if (currentBottom < 0) {
53
+ popupTransform.y = popupTransform.y - currentBottom
54
+ }
55
+ return {
56
+ height: `${_popupHeight}px`,
57
+ overflow: 'auto',
58
+ transform: `translate(${-popupTransform.x}px, ${-popupTransform.y}px)`
59
+ }
60
+ }
61
+
62
+ module.exports = {
63
+ getPopupPosition
64
+ }
@@ -0,0 +1,6 @@
1
+ const { getPopupPosition } = require('./getPopupPosition')
2
+
3
+ module.exports = {
4
+ getPopupPosition
5
+ }
6
+ exports.getPopupPosition = getPopupPosition
package/lib/index.js ADDED
@@ -0,0 +1,11 @@
1
+ // const factories = require('./factories')
2
+ const models = require('./models')
3
+
4
+ module.exports = {
5
+ // ...factories,
6
+ ...models,
7
+ }
8
+
9
+ exports.QListBulkButton = models.QListBulkButton
10
+ exports.QRow = models.QRow
11
+ exports.QListButton = models.QListButton
@@ -0,0 +1,9 @@
1
+ const qListBulkButton = require('./qListBulkButton')
2
+ const qListButton = require('./qListButton')
3
+ const qRow = require('./qRow')
4
+
5
+ module.exports = {
6
+ ...qListBulkButton,
7
+ ...qListButton,
8
+ ...qRow,
9
+ }
@@ -0,0 +1,7 @@
1
+ 'use strict'
2
+
3
+ const { KeyValueObject } = require('./keyValueObject')
4
+
5
+ module.exports = {
6
+ KeyValueObject
7
+ }
@@ -0,0 +1,161 @@
1
+ 'use strict'
2
+
3
+ class KeyValueObject {
4
+ constructor(options = {}) {
5
+ options = options || {}
6
+ this.key = options.key || null
7
+ this.value = (typeof options.value !== 'undefined') ? options.value : ''
8
+ }
9
+
10
+ // Class methods
11
+
12
+ static addItem(arr, key, value) {
13
+ arr.push(
14
+ { key, value }
15
+ )
16
+ }
17
+ static addRecord(arr = [], key, value) {
18
+ const self = this
19
+ if (!KeyValueObject.hasKeyValue(arr, key, value)) {
20
+ arr.push(self.init({ key, value }))
21
+ }
22
+ return arr
23
+ }
24
+
25
+ static fromObject(options = {}) {
26
+ const self = this
27
+ return Object.keys(options).reduce((acc, key) => {
28
+ acc.push(self.init({ key, value: options[key] }))
29
+ return acc
30
+ }, [])
31
+ }
32
+
33
+ static removeByKey(arr, key) {
34
+ return arr.reduce((acc, item) => {
35
+ if (item.key !== key) {
36
+ acc.push(item)
37
+ }
38
+ return acc
39
+ }, [])
40
+ }
41
+
42
+
43
+ static getValuesByKey(arr = [], key) {
44
+ return arr.reduce((acc, item) => {
45
+ if (item.key === key) {
46
+ acc.push(item.value)
47
+ }
48
+ return acc
49
+ }, [])
50
+ }
51
+
52
+ static hasKeyValue(arr = [], key, value) {
53
+ if (typeof value === 'undefined') {
54
+ return arr.filter((item) => item.key === key).length > 0
55
+ }
56
+ return arr.filter((item) => (item.key === key && item.value === value)).length > 0
57
+ }
58
+
59
+ static init(options = {}) {
60
+ const kvObject = new KeyValueObject(options)
61
+ return kvObject.isValid ? kvObject : null
62
+ }
63
+
64
+ static initFromArray(arr = []) {
65
+ const self = this
66
+ if (Array.isArray(arr)) {
67
+ return arr.map(self.init)
68
+ }
69
+ return []
70
+ }
71
+
72
+ static initOnlyValidFromArray(arr = []) {
73
+ return this.initFromArray(arr).filter((i) => i)
74
+ }
75
+
76
+ static keys(arr = []) {
77
+ if (Array.isArray(arr)) {
78
+ return arr.reduce((acc, item) => {
79
+ acc.push(item.key)
80
+ return acc
81
+ }, [])
82
+ }
83
+ return []
84
+ }
85
+
86
+ static toObject(arr = []) {
87
+ if (Array.isArray(arr)) {
88
+ return arr.reduce((acc, item) => {
89
+ acc[item.key] = item.value
90
+ return acc
91
+ }, {})
92
+ }
93
+ return {}
94
+ }
95
+
96
+ static toString(arr = [], delimiter = '; ') {
97
+ if (Array.isArray(arr)) {
98
+ return arr.reduce((acc, item) => {
99
+ acc.push(`${item.key}: ${item.value}`)
100
+ return acc
101
+ }, []).join(delimiter)
102
+ }
103
+ return ''
104
+ }
105
+
106
+ static updateRecord(arr = [], key, value) {
107
+ return arr.map((item) => {
108
+ if (item.key === key) {
109
+ item.value = value
110
+ }
111
+ return item
112
+ }, {})
113
+ }
114
+
115
+ static updateOrInsertRecord(arr = [], key, value) {
116
+ const self = this
117
+ let copy = [...arr]
118
+ if (!self.hasKeyValue(arr, key)) {
119
+ copy.push(self.init({ key, value }))
120
+ } else {
121
+ copy = self.updateRecord(arr, key, value)
122
+ }
123
+ return copy
124
+ }
125
+
126
+ static updateRecordsFromArray(arr = [], updateArr = []) {
127
+ if (Array.isArray(arr) && Array.isArray(updateArr)) {
128
+ const obj1 = KeyValueObject.toObject(arr)
129
+ const obj2 = KeyValueObject.toObject(updateArr)
130
+ return KeyValueObject.fromObject(Object.assign({}, obj1, obj2))
131
+ }
132
+ return []
133
+ }
134
+
135
+ static values(arr = []) {
136
+ if (Array.isArray(arr)) {
137
+ return arr.reduce((acc, item) => {
138
+ acc.push(item.value)
139
+ return acc
140
+ }, [])
141
+ }
142
+ return []
143
+ }
144
+
145
+ // getters
146
+ get isValid() {
147
+ return !!this.key
148
+ }
149
+
150
+ get toObject() {
151
+ const obj = {}
152
+ if (this.isValid) {
153
+ obj[this.key] = this.value
154
+ }
155
+ return obj
156
+ }
157
+ }
158
+
159
+ module.exports = {
160
+ KeyValueObject
161
+ }
@@ -0,0 +1,59 @@
1
+ 'use strict'
2
+
3
+ /* eslint func-names: 0 */
4
+
5
+ const { expect } = require('chai')
6
+ const { KeyValueObject } = require('./index')
7
+
8
+ describe('KeyValueObject', function () {
9
+ let keyValueObjects
10
+
11
+
12
+ describe('create', function () {
13
+ const options = {
14
+ firstName: 'Peter',
15
+ lastName: 'Wong'
16
+ }
17
+
18
+ it('fromObject', function () {
19
+ keyValueObjects = KeyValueObject.fromObject(options)
20
+ expect(keyValueObjects.length).to.eql(2)
21
+ expect(KeyValueObject.keys(keyValueObjects)).to.eql(['firstName', 'lastName'])
22
+ })
23
+
24
+ it('toObject', function () {
25
+ expect(keyValueObjects[0].toObject).to.eql({ firstName: 'Peter' })
26
+ })
27
+ })
28
+
29
+ describe('from Array', function () {
30
+ const arr = [
31
+ { key: 'firstName', value: 'Peter' },
32
+ { key: 'lastName', value: 'Wong' },
33
+ ]
34
+ it('initFromArray', function () {
35
+ keyValueObjects = KeyValueObject.initFromArray(arr)
36
+ expect(keyValueObjects.length).to.eql(2)
37
+ expect(KeyValueObject.keys(keyValueObjects)).to.eql(['firstName', 'lastName'])
38
+ })
39
+
40
+ it('initOnlyValidFromArray', function () {
41
+ arr.push({key: null, value: 'hi' })
42
+ arr.push({ value: 'hi' })
43
+ keyValueObjects = KeyValueObject.initOnlyValidFromArray(arr)
44
+ expect(keyValueObjects.length).to.eql(2)
45
+ expect(KeyValueObject.keys(keyValueObjects)).to.eql(['firstName', 'lastName'])
46
+ })
47
+
48
+ it('toObject', function () {
49
+ expect(keyValueObjects[1].toObject).to.eql({ lastName: 'Wong' })
50
+ })
51
+
52
+ it('KeyValueObject.toObject', function () {
53
+ expect(KeyValueObject.toObject(keyValueObjects)).to.eql({
54
+ firstName: 'Peter',
55
+ lastName: 'Wong'
56
+ })
57
+ })
58
+ })
59
+ })
@@ -0,0 +1,5 @@
1
+ const { QListBulkButton } = require('./qListBulkButton')
2
+
3
+ module.exports = {
4
+ QListBulkButton
5
+ }
@@ -0,0 +1,44 @@
1
+
2
+ class QListBulkButton {
3
+ constructor(options = {}) {
4
+ options = options || {}
5
+ this.active = (typeof options.active !== 'undefined') ? !!options.active : true
6
+ this.creator = options.creator
7
+ this.css = options.css || {}
8
+ this.deleted = options.deleted || false
9
+ this.icon = options.icon
10
+ this.label = options.label
11
+ this.onClick = options.onClick
12
+ this.owner = options.owner
13
+ this.qListButtonType = options.qListButtonType
14
+ // this.qRow = options.qRow
15
+ this.showLabel = options.showLabel
16
+ this.title = options.title
17
+ }
18
+
19
+ static init(options) {
20
+ if (options instanceof QListBulkButton) {
21
+ return options
22
+ }
23
+ return new QListBulkButton(options)
24
+ }
25
+
26
+ // get isValid() {
27
+ // return !!this.qListButtonType || (typeof this.onClick === 'function')
28
+ // }
29
+
30
+ click(...obj) {
31
+ if (this.onClick && typeof this.onClick === 'function') {
32
+ return this.onClick(...obj)
33
+ }
34
+ }
35
+
36
+ makeCss() {
37
+ return `__q-list-button ${this.css.element || ''}`
38
+ }
39
+ }
40
+
41
+ module.exports = {
42
+ QListBulkButton
43
+ }
44
+
@@ -0,0 +1,5 @@
1
+ const { QListButton } = require('./qListButton')
2
+
3
+ module.exports = {
4
+ QListButton
5
+ }