quasar-ui-danx 0.2.32 → 0.3.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.
- package/dist/danx.es.js +6496 -6291
- package/dist/danx.es.js.map +1 -1
- package/dist/danx.umd.js +5 -5
- package/dist/danx.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/ActionTable/ActionTableColumn.vue +5 -2
- package/src/components/ActionTable/ActionTableHeaderColumn.vue +2 -1
- package/src/components/ActionTable/Filters/FilterListToggle.vue +1 -2
- package/src/components/ActionTable/Form/Fields/BooleanField.vue +9 -2
- package/src/components/ActionTable/Form/RenderedForm.vue +146 -10
- package/src/components/ActionTable/listControls.ts +68 -38
- package/src/components/ActionTable/tableColumns.ts +3 -3
- package/src/components/PanelsDrawer/PanelsDrawerPanels.vue +1 -1
- package/src/components/Utility/Tools/RenderVnode.vue +16 -2
- package/src/helpers/actions.ts +34 -31
- package/src/helpers/array.ts +11 -16
- package/src/helpers/utils.ts +20 -25
- package/src/styles/quasar-reset.scss +4 -0
package/src/helpers/array.ts
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
/**
|
2
|
-
*
|
3
|
-
* @param array
|
4
|
-
* @param item
|
5
|
-
* @param newItem
|
6
|
-
* @returns {*[]}
|
2
|
+
* Replace an item in an array with a new item
|
7
3
|
*/
|
8
|
-
export function replace(array, item, newItem = undefined) {
|
9
|
-
const index =
|
10
|
-
|
11
|
-
|
12
|
-
console.error("Item not found in array", item, array);
|
13
|
-
throw new Error("Item not found in array");
|
4
|
+
export function replace(array: any[], item: any, newItem = undefined, appendIfMissing = false) {
|
5
|
+
const index: any = typeof item === "function" ? array.findIndex(item) : array.indexOf(item);
|
6
|
+
if (index === false || index === -1) {
|
7
|
+
return appendIfMissing ? [...array, newItem] : array;
|
14
8
|
}
|
9
|
+
|
15
10
|
const newArray = [...array];
|
16
11
|
newItem !== undefined
|
17
12
|
? newArray.splice(index, 1, newItem)
|
@@ -19,17 +14,17 @@ export function replace(array, item, newItem = undefined) {
|
|
19
14
|
return newArray;
|
20
15
|
}
|
21
16
|
|
22
|
-
|
17
|
+
/**
|
18
|
+
* Remove an item from an array
|
19
|
+
*/
|
20
|
+
export function remove(array: any[], item: any) {
|
23
21
|
return replace(array, item);
|
24
22
|
}
|
25
23
|
|
26
24
|
/**
|
27
25
|
* Remove duplicate items from an array using a callback to compare 2 elements
|
28
|
-
* @param array
|
29
|
-
* @param cb
|
30
|
-
* @returns {*}
|
31
26
|
*/
|
32
|
-
export function uniqueBy(array, cb) {
|
27
|
+
export function uniqueBy(array: any[], cb: Function) {
|
33
28
|
return array.filter((a, index, self) => {
|
34
29
|
// Check if the current element 'a' is the first occurrence in the array
|
35
30
|
return index === self.findIndex((b) => cb(a, b));
|
package/src/helpers/utils.ts
CHANGED
@@ -1,25 +1,18 @@
|
|
1
|
-
import { watch } from "vue";
|
1
|
+
import { Ref, watch } from "vue";
|
2
2
|
|
3
3
|
/**
|
4
|
-
* Sleep function to be used in
|
4
|
+
* Sleep function to be used in conjunction with async await:
|
5
5
|
*
|
6
6
|
* eg: await sleep(5000);
|
7
|
-
*
|
8
|
-
* @param delay
|
9
|
-
* @returns {Promise<any>}
|
10
7
|
*/
|
11
|
-
export function sleep(delay) {
|
8
|
+
export function sleep(delay: number) {
|
12
9
|
return new Promise((resolve) => setTimeout(resolve, delay));
|
13
10
|
}
|
14
11
|
|
15
12
|
/**
|
16
13
|
* Wait for a ref to have a value and then resolve the promise
|
17
|
-
*
|
18
|
-
* @param ref
|
19
|
-
* @param value
|
20
|
-
* @returns {Promise<void>}
|
21
14
|
*/
|
22
|
-
export function waitForRef(ref, value) {
|
15
|
+
export function waitForRef(ref: Ref, value: any) {
|
23
16
|
return new Promise<void>((resolve) => {
|
24
17
|
watch(ref, (newValue) => {
|
25
18
|
if (newValue === value) {
|
@@ -31,39 +24,29 @@ export function waitForRef(ref, value) {
|
|
31
24
|
|
32
25
|
/**
|
33
26
|
* Returns a number that is constrained to the given range.
|
34
|
-
* @param min
|
35
|
-
* @param max
|
36
|
-
* @param value
|
37
|
-
* @returns {number}
|
38
27
|
*/
|
39
|
-
export function minmax(min, max, value) {
|
28
|
+
export function minmax(min: number, max: number, value: number) {
|
40
29
|
return Math.max(min, Math.min(max, value));
|
41
30
|
}
|
42
31
|
|
43
32
|
/**
|
44
33
|
* Convert meters to miles
|
45
|
-
* @param meters
|
46
|
-
* @returns {number}
|
47
34
|
*/
|
48
|
-
export function metersToMiles(meters) {
|
35
|
+
export function metersToMiles(meters: number) {
|
49
36
|
return meters * 0.000621371;
|
50
37
|
}
|
51
38
|
|
52
39
|
/**
|
53
40
|
* Convert miles to meters
|
54
|
-
* @param miles
|
55
|
-
* @returns {number}
|
56
41
|
*/
|
57
|
-
export function milesToMeters(miles) {
|
42
|
+
export function milesToMeters(miles: number) {
|
58
43
|
return miles / 0.000621371;
|
59
44
|
}
|
60
45
|
|
61
46
|
/**
|
62
47
|
* Parses a string for Lat and Long coords
|
63
|
-
* @param location
|
64
|
-
* @returns {null|{lng: number, lat: number}}
|
65
48
|
*/
|
66
|
-
export function parseCoords(location) {
|
49
|
+
export function parseCoords(location: string) {
|
67
50
|
const latLong = location.split(",");
|
68
51
|
|
69
52
|
if (latLong.length === 2) {
|
@@ -80,3 +63,15 @@ export function parseCoords(location) {
|
|
80
63
|
|
81
64
|
return null;
|
82
65
|
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Increment a name by adding a number to the end of it or incrementing the number if it already exists
|
69
|
+
*/
|
70
|
+
export function incrementName(name: string) {
|
71
|
+
name = (name || "New Item").trim();
|
72
|
+
const match = name.match(/(\d+)$/);
|
73
|
+
if (match) {
|
74
|
+
return name.replace(/\d+$/, (match: string) => "" + (parseInt(match) + 1));
|
75
|
+
}
|
76
|
+
return `${name} 1`;
|
77
|
+
}
|