@bagelink/vue 0.0.239 → 0.0.243
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/components/Avatar.vue.d.ts +19 -3
- package/dist/components/Avatar.vue.d.ts.map +1 -1
- package/dist/components/ListItem.vue.d.ts +4 -0
- package/dist/components/ListItem.vue.d.ts.map +1 -1
- package/dist/components/ListView.vue.d.ts +1 -1
- package/dist/components/Modal.vue.d.ts.map +1 -1
- package/dist/components/ModalForm.vue.d.ts +6 -0
- package/dist/components/ModalForm.vue.d.ts.map +1 -1
- package/dist/components/form/ItemRef.vue.d.ts +0 -1
- package/dist/components/form/ItemRef.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/SelectField.vue.d.ts +4 -1
- package/dist/components/form/inputs/SelectField.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/TextInput.vue.d.ts +2 -0
- package/dist/components/form/inputs/TextInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ToggleInput.vue.d.ts +7 -20
- package/dist/components/form/inputs/ToggleInput.vue.d.ts.map +1 -1
- package/dist/index.cjs +1849 -1860
- package/dist/index.mjs +1849 -1860
- package/dist/plugins/modal.d.ts +8 -6
- package/dist/plugins/modal.d.ts.map +1 -1
- package/dist/style.css +246 -87
- package/dist/types/BagelForm.d.ts +16 -8
- package/dist/types/BagelForm.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Avatar.vue +14 -17
- package/src/components/ListItem.vue +16 -9
- package/src/components/Modal.vue +2 -4
- package/src/components/ModalForm.vue +7 -3
- package/src/components/form/BglField.vue +1 -1
- package/src/components/form/BglForm.vue +14 -11
- package/src/components/form/inputs/TextInput.vue +27 -60
- package/src/components/form/inputs/ToggleInput.vue +29 -40
- package/src/plugins/modal.ts +12 -28
- package/src/styles/layout.css +197 -30
- package/src/styles/modal.css +38 -13
- package/src/styles/text.css +12 -0
- package/src/styles/theme.css +9 -11
- package/src/types/BagelForm.ts +17 -6
- package/dist/components/Drop.vue.d.ts +0 -34
- package/dist/components/Drop.vue.d.ts.map +0 -1
- package/dist/components/FileUploader.vue.d.ts +0 -60
- package/dist/components/FileUploader.vue.d.ts.map +0 -1
- package/src/types/BagelField.ts +0 -52
- package/src/utils/objects.ts +0 -81
package/src/utils/objects.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { BagelField } from '@bagelink/vue';
|
|
2
|
-
|
|
3
|
-
function returnTypes(bagelField?: BagelField) {
|
|
4
|
-
if (bagelField?.is_array) return [];
|
|
5
|
-
if (bagelField?.inputType === 'BagelForm') return {};
|
|
6
|
-
if (bagelField?.inputType === 'CheckInput') return false;
|
|
7
|
-
return '';
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function getPropByPath(
|
|
11
|
-
obj: Record<string, any>,
|
|
12
|
-
propPath?: string,
|
|
13
|
-
bagelField?: BagelField,
|
|
14
|
-
) {
|
|
15
|
-
// Return the object if the path is empty or the object is not an 'object' type
|
|
16
|
-
if (!propPath || typeof obj !== 'object') return obj;
|
|
17
|
-
|
|
18
|
-
const props = propPath.split(/\.|\[(\d+)\]/).filter(Boolean);
|
|
19
|
-
let result = obj;
|
|
20
|
-
for (const prop of props) {
|
|
21
|
-
if (result !== null && typeof result === 'object' && prop in result) {
|
|
22
|
-
result = result[prop];
|
|
23
|
-
} else {
|
|
24
|
-
return bagelField ? returnTypes(bagelField) : '';
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function setPropByPath(
|
|
31
|
-
obj: Record<string, any>,
|
|
32
|
-
path?: string,
|
|
33
|
-
value?: any,
|
|
34
|
-
) {
|
|
35
|
-
const keys = path?.split(/\.|\[(\d+)\]/)?.filter(Boolean) || [];
|
|
36
|
-
let current = obj;
|
|
37
|
-
|
|
38
|
-
for (let i = 0; i < keys.length - 1; i++) {
|
|
39
|
-
const key = keys[i];
|
|
40
|
-
const nextKey = keys[i + 1];
|
|
41
|
-
|
|
42
|
-
const nextIsArrayIndex = !Number.isNaN(parseInt(nextKey, 10));
|
|
43
|
-
|
|
44
|
-
if (!current[key]) {
|
|
45
|
-
current[key] = nextIsArrayIndex ? [] : {};
|
|
46
|
-
} else if (typeof current[key] !== 'object') {
|
|
47
|
-
throw new Error(
|
|
48
|
-
`Cannot set property '${keys
|
|
49
|
-
.slice(i)
|
|
50
|
-
.join('.')}', object or array expected`,
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
current = current[key];
|
|
54
|
-
}
|
|
55
|
-
current[keys[keys.length - 1]] = value;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// export function setPropByPath(
|
|
59
|
-
// obj: Record<string, any>,
|
|
60
|
-
// propPath: string,
|
|
61
|
-
// value: any,
|
|
62
|
-
// ) {
|
|
63
|
-
// // console.log('getPropByPath', obj, { propPath });
|
|
64
|
-
// if (!propPath || typeof obj !== 'object') return obj;
|
|
65
|
-
|
|
66
|
-
// const props = propPath.split(/\.|\[(\d+)\]/).filter(Boolean);
|
|
67
|
-
// let result = obj;
|
|
68
|
-
// console.log(props);
|
|
69
|
-
// for (let i = 0; i < props.length; i++) {
|
|
70
|
-
// const prop = props[i];
|
|
71
|
-
// if (i === props.length - 1) {
|
|
72
|
-
// result[prop] = value;
|
|
73
|
-
// } else if (result && prop in result) {
|
|
74
|
-
// result = result[prop];
|
|
75
|
-
// } else {
|
|
76
|
-
// return undefined;
|
|
77
|
-
// }
|
|
78
|
-
// }
|
|
79
|
-
|
|
80
|
-
// return result;
|
|
81
|
-
// }
|