@ulu/frontend-vue 0.1.0-beta.4 → 0.1.0-beta.6
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/README.md +106 -2
- package/dist/{breakpoints-BegXzJ94.js → breakpoints-SWofnYUx.js} +1 -1
- package/dist/frontend-vue.js +56 -62
- package/dist/{index-CGVy3UWS.js → index-CtdKSn3_.js} +1306 -1380
- package/lib/components/collapsible/UluAccordion.vue +1 -1
- package/lib/components/collapsible/UluModal.vue +4 -5
- package/lib/components/collapsible/UluOverflowPopover.vue +1 -1
- package/lib/components/elements/UluAlert.vue +1 -2
- package/lib/components/elements/UluButton.vue +2 -2
- package/lib/components/elements/UluExternalLink.vue +1 -2
- package/lib/components/elements/UluIcon.vue +11 -16
- package/lib/components/elements/UluTag.vue +1 -1
- package/lib/components/index.js +0 -1
- package/lib/components/layout/UluTitleRail.vue +2 -4
- package/lib/components/navigation/UluBreadcrumb.vue +1 -2
- package/lib/components/navigation/UluMenu.vue +1 -1
- package/lib/index.js +0 -1
- package/lib/plugins/core/index.js +87 -0
- package/lib/plugins/index.js +1 -0
- package/lib/plugins/toast/UluToast.vue +1 -1
- package/package.json +28 -8
- package/lib/components/forms/UluFormDropzone.vue +0 -62
- package/lib/settings.js +0 -119
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
<UluIcon
|
|
27
27
|
v-if="titleIcon"
|
|
28
28
|
class="modal__title-icon"
|
|
29
|
-
:
|
|
29
|
+
:icon="titleIcon"
|
|
30
30
|
/>
|
|
31
31
|
<span class="modal__title-text">{{ title }}</span>
|
|
32
32
|
</slot>
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
<slot name="closeIcon">
|
|
36
36
|
<UluIcon
|
|
37
37
|
class="modal__close-icon"
|
|
38
|
-
|
|
39
|
-
:definition="closeIcon"
|
|
38
|
+
:icon="closeIcon || 'type:close'"
|
|
40
39
|
/>
|
|
41
40
|
</slot>
|
|
42
41
|
</button>
|
|
@@ -56,7 +55,7 @@
|
|
|
56
55
|
</div>
|
|
57
56
|
<button v-if="resizerEnabled" class="modal__resizer" ref="resizer" type="button">
|
|
58
57
|
<slot name="resizerIcon">
|
|
59
|
-
<UluIcon class="modal__resizer-icon" :
|
|
58
|
+
<UluIcon class="modal__resizer-icon" :icon="resizerIcon || resizerIconType" />
|
|
60
59
|
</slot>
|
|
61
60
|
</button>
|
|
62
61
|
</dialog>
|
|
@@ -213,7 +212,7 @@
|
|
|
213
212
|
});
|
|
214
213
|
|
|
215
214
|
const resizerIconType = computed(() => {
|
|
216
|
-
return props.position === 'center' ? 'resizeBoth' : 'resizeHorizontal';
|
|
215
|
+
return props.position === 'center' ? 'type:resizeBoth' : 'type:resizeHorizontal';
|
|
217
216
|
});
|
|
218
217
|
|
|
219
218
|
// Define the internal modifiers object as a computed property (so it can react to changes)
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<slot name="before"/>
|
|
23
23
|
<UluIcon
|
|
24
24
|
v-if="icon && (iconBefore || iconOnly)"
|
|
25
|
-
:
|
|
25
|
+
:icon="icon"
|
|
26
26
|
class="button__icon"
|
|
27
27
|
/>
|
|
28
28
|
<span v-if="($slots.default || text) && !iconOnly">
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
</span>
|
|
33
33
|
<UluIcon
|
|
34
34
|
v-if="icon && (!iconBefore && !iconOnly)"
|
|
35
|
-
:
|
|
35
|
+
:icon="icon"
|
|
36
36
|
class="button__icon"
|
|
37
37
|
/>
|
|
38
38
|
<slot name="after"/>
|
|
@@ -17,53 +17,48 @@
|
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
19
|
<script setup>
|
|
20
|
-
import { ref, defineAsyncComponent, markRaw, watchEffect, computed } from "vue";
|
|
20
|
+
import { ref, defineAsyncComponent, markRaw, watchEffect, computed, inject } from "vue";
|
|
21
21
|
import { useIcon } from "../../composables/useIcon.js";
|
|
22
|
-
import { getSetting, getIconByType } from "../../settings.js";
|
|
23
22
|
|
|
23
|
+
const uluCore = inject('uluCore');
|
|
24
24
|
const faIconComponent = ref(null);
|
|
25
25
|
const { getIconProps, getClassesFromDefinition } = useIcon();
|
|
26
26
|
|
|
27
27
|
let FaModule;
|
|
28
28
|
|
|
29
29
|
const props = defineProps({
|
|
30
|
-
/**
|
|
31
|
-
* Semantic type of icon to use, will be resolved from settings
|
|
32
|
-
*/
|
|
33
|
-
type: String,
|
|
34
30
|
/**
|
|
35
31
|
* Icon definition can be string (fa classes), or array or object (any prop format FaIcon accepts)
|
|
36
32
|
* - This will override the 'type' prop if both are provided
|
|
37
33
|
*/
|
|
38
|
-
|
|
34
|
+
icon: [String, Array, Object, Boolean],
|
|
39
35
|
});
|
|
40
36
|
|
|
41
37
|
const useStaticFa = computed(() => {
|
|
42
|
-
return getSetting("fontAwesomeStatic");
|
|
38
|
+
return uluCore.getSetting("fontAwesomeStatic");
|
|
43
39
|
});
|
|
44
40
|
|
|
45
41
|
const customIconComponent = computed(() => {
|
|
46
|
-
return getSetting("iconComponent");
|
|
42
|
+
return uluCore.getSetting("iconComponent");
|
|
47
43
|
});
|
|
48
44
|
|
|
49
45
|
const iconPropResolver = computed(() => {
|
|
50
|
-
return getSetting("iconPropResolver");
|
|
46
|
+
return uluCore.getSetting("iconPropResolver");
|
|
51
47
|
});
|
|
52
48
|
|
|
53
49
|
// Resolve the final icon definition, giving precedence to the `definition` prop
|
|
54
50
|
const resolvedDefinition = computed(() => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
if (props.type) {
|
|
51
|
+
const { icon } = props;
|
|
52
|
+
if (typeof icon === 'string' && icon.startsWith('type:')) {
|
|
59
53
|
try {
|
|
60
|
-
|
|
54
|
+
const type = icon.substring(5);
|
|
55
|
+
return uluCore.getIcon(type);
|
|
61
56
|
} catch (e) {
|
|
62
57
|
console.warn(e);
|
|
63
58
|
return null;
|
|
64
59
|
}
|
|
65
60
|
}
|
|
66
|
-
return
|
|
61
|
+
return icon;
|
|
67
62
|
});
|
|
68
63
|
|
|
69
64
|
const customIconProps = computed(() => {
|
package/lib/components/index.js
CHANGED
|
@@ -28,7 +28,6 @@ export { default as UluSpokeSpinner } from './elements/UluSpokeSpinner.vue';
|
|
|
28
28
|
export { default as UluTag } from './elements/UluTag.vue';
|
|
29
29
|
export { default as UluCheckboxMenu } from './forms/UluCheckboxMenu.vue';
|
|
30
30
|
export { default as UluFileDisplay } from './forms/UluFileDisplay.vue';
|
|
31
|
-
export { default as UluFormDropzone } from './forms/UluFormDropzone.vue';
|
|
32
31
|
export { default as UluFormFile } from './forms/UluFormFile.vue';
|
|
33
32
|
export { default as UluFormMessage } from './forms/UluFormMessage.vue';
|
|
34
33
|
export { default as UluFormSelect } from './forms/UluFormSelect.vue';
|
|
@@ -8,10 +8,9 @@
|
|
|
8
8
|
:style="{ alignItems: iconAlign }"
|
|
9
9
|
>
|
|
10
10
|
<UluIcon
|
|
11
|
-
v-if="icon
|
|
11
|
+
v-if="icon"
|
|
12
12
|
:class="classes.icon"
|
|
13
|
-
:
|
|
14
|
-
:definition="icon"
|
|
13
|
+
:icon="icon"
|
|
15
14
|
/>
|
|
16
15
|
<slot>
|
|
17
16
|
{{ title }}
|
|
@@ -38,7 +37,6 @@
|
|
|
38
37
|
type: String,
|
|
39
38
|
default: "baseline"
|
|
40
39
|
},
|
|
41
|
-
iconType: String,
|
|
42
40
|
classes: {
|
|
43
41
|
type: Object,
|
|
44
42
|
default: () => ({
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
<slot :item="item" :index="index">
|
|
27
27
|
<UluIcon
|
|
28
28
|
v-if="item.icon"
|
|
29
|
-
:
|
|
29
|
+
:icon="item.icon"
|
|
30
30
|
:class="[classes.linkIcon, item?.classes?.linkIcon]"
|
|
31
31
|
/>
|
|
32
32
|
<span :class="[classes.linkText, item?.classes?.linkText]">{{ item.title }}</span>
|
package/lib/index.js
CHANGED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module plugins/core/index.js
|
|
3
|
+
* @description Core plugin for managing shared configuration for the library.
|
|
4
|
+
*/
|
|
5
|
+
import { reactive } from 'vue';
|
|
6
|
+
|
|
7
|
+
const defaults = {
|
|
8
|
+
fontAwesomeStatic: false,
|
|
9
|
+
iconComponent: null,
|
|
10
|
+
iconPropResolver: (definition) => ({ icon: definition }),
|
|
11
|
+
iconsByType: {
|
|
12
|
+
danger: "fas fa-triangle-exclamation",
|
|
13
|
+
warning: "fas fa-circle-exclamation",
|
|
14
|
+
info: "fas fa-circle-info",
|
|
15
|
+
success: "fas fa-circle-check",
|
|
16
|
+
externalLink: "fas fa-arrow-up-right-from-square",
|
|
17
|
+
close: "fas fa-xmark",
|
|
18
|
+
expand: "fas fa-plus",
|
|
19
|
+
collapse: "fas fa-minus",
|
|
20
|
+
resizeHorizontal: "fas fa-grip-lines-vertical",
|
|
21
|
+
resizeVertical: "fas fa-grip-lines",
|
|
22
|
+
resizeBoth: "fas fa-grip",
|
|
23
|
+
ellipsis: "fas fa-ellipsis",
|
|
24
|
+
pathSeparator: "fas fa-chevron-right"
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const iconKeys = Object.keys(defaults.iconsByType);
|
|
29
|
+
|
|
30
|
+
export default function install(app, userSettings = {}) {
|
|
31
|
+
// A single reactive object for all settings
|
|
32
|
+
const settings = reactive({ ...defaults });
|
|
33
|
+
|
|
34
|
+
// Separate icon overrides from other options to handle them safely
|
|
35
|
+
const { iconsByType: iconOverrides, ...otherOptions } = userSettings || {};
|
|
36
|
+
|
|
37
|
+
// Merge any user-provided options during installation
|
|
38
|
+
if (otherOptions) {
|
|
39
|
+
Object.assign(settings, otherOptions);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const api = {
|
|
43
|
+
// Methods to interact with settings
|
|
44
|
+
getSettings() {
|
|
45
|
+
return settings;
|
|
46
|
+
},
|
|
47
|
+
getDefaultSettings() {
|
|
48
|
+
return { ...defaults };
|
|
49
|
+
},
|
|
50
|
+
updateSettings(changes) {
|
|
51
|
+
return Object.assign(settings, changes);
|
|
52
|
+
},
|
|
53
|
+
getSetting(key) {
|
|
54
|
+
if (!settings.hasOwnProperty(key)) {
|
|
55
|
+
console.warn(`Attempted to access non-existent setting: ${key}`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
return settings[key];
|
|
59
|
+
},
|
|
60
|
+
updateSetting(key, value) {
|
|
61
|
+
if (typeof key !== "string") {
|
|
62
|
+
throw new Error("Expected key to be string");
|
|
63
|
+
}
|
|
64
|
+
settings[key] = value;
|
|
65
|
+
},
|
|
66
|
+
getIcon(type) {
|
|
67
|
+
const icons = settings.iconsByType;
|
|
68
|
+
if (!icons[type]) {
|
|
69
|
+
throw new Error(`Icon type "${type}" not found!`);
|
|
70
|
+
}
|
|
71
|
+
return icons[type];
|
|
72
|
+
},
|
|
73
|
+
setIcon(type, definition) {
|
|
74
|
+
settings.iconsByType[type] = definition;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Apply any individual icon overrides passed during installation
|
|
79
|
+
if (iconOverrides) {
|
|
80
|
+
for (const [type, definition] of Object.entries(iconOverrides)) {
|
|
81
|
+
api.setIcon(type, definition);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
app.provide('uluCore', api);
|
|
86
|
+
app.config.globalProperties.$uluCore = api;
|
|
87
|
+
}
|
package/lib/plugins/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ulu/frontend-vue",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0-beta.6",
|
|
4
|
+
"description": "A modular and tree-shakeable Vue 3 component library for the Ulu frontend",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"files"
|
|
6
|
+
"files": [
|
|
7
7
|
"lib",
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
@@ -18,17 +18,35 @@
|
|
|
18
18
|
"./*": "./lib/*",
|
|
19
19
|
"./scss": "./lib/_index.scss"
|
|
20
20
|
},
|
|
21
|
+
"typesVersions": {
|
|
22
|
+
"*": {
|
|
23
|
+
"lib/*": [
|
|
24
|
+
"./types/*"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
21
28
|
"repository": {
|
|
22
29
|
"type": "git",
|
|
23
30
|
"url": "git+https://github.com/Jscherbe/frontend-vue.git"
|
|
24
31
|
},
|
|
25
32
|
"scripts": {
|
|
26
33
|
"dev": "storybook dev -p 6006",
|
|
27
|
-
"docs:build": "storybook build -o docs
|
|
34
|
+
"docs:build": "storybook build -o docs",
|
|
28
35
|
"build": "vite build",
|
|
29
|
-
"
|
|
36
|
+
"types": "npx tsc",
|
|
37
|
+
"deploy": "npm run types && npm run build && npm run docs:build"
|
|
30
38
|
},
|
|
31
|
-
"keywords": [
|
|
39
|
+
"keywords": [
|
|
40
|
+
"vue",
|
|
41
|
+
"vue3",
|
|
42
|
+
"ui",
|
|
43
|
+
"components",
|
|
44
|
+
"component-library",
|
|
45
|
+
"design-system",
|
|
46
|
+
"ulu",
|
|
47
|
+
"frontend",
|
|
48
|
+
"scss"
|
|
49
|
+
],
|
|
32
50
|
"author": "Joseph Scherben <jscherbe@gmail.com>",
|
|
33
51
|
"license": "MIT",
|
|
34
52
|
"bugs": {
|
|
@@ -49,7 +67,7 @@
|
|
|
49
67
|
"dependencies": {
|
|
50
68
|
"@floating-ui/vue": "^1.1.8",
|
|
51
69
|
"@ulu/utils": "^0.0.30",
|
|
52
|
-
"lodash-es"
|
|
70
|
+
"lodash-es": "^4.17.21"
|
|
53
71
|
},
|
|
54
72
|
"devDependencies": {
|
|
55
73
|
"@fortawesome/fontawesome-svg-core": "^6.7.2",
|
|
@@ -68,9 +86,11 @@
|
|
|
68
86
|
"storybook": "^9.1.1",
|
|
69
87
|
"storybook-addon-vue-mdx": "^2.0.2",
|
|
70
88
|
"vite": "^7.0.0",
|
|
71
|
-
"vue-router": "^4.5.1"
|
|
89
|
+
"vue-router": "^4.5.1",
|
|
90
|
+
"typescript": "^5.3.3"
|
|
72
91
|
},
|
|
73
92
|
"volta": {
|
|
74
93
|
"node": "22.17.0"
|
|
75
94
|
}
|
|
76
95
|
}
|
|
96
|
+
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
<!-- Based on https://react-dropzone.js.org/#section-basic-example -->
|
|
2
|
-
<template>
|
|
3
|
-
<div
|
|
4
|
-
class="site-dropzone site-form__item site-form__item--file"
|
|
5
|
-
:class="{ 'is-danger' : fileErrors.length }"
|
|
6
|
-
>
|
|
7
|
-
<div
|
|
8
|
-
class="site-dropzone__target"
|
|
9
|
-
:class="{
|
|
10
|
-
'site-dropzone__target--dropping' : isDragActive
|
|
11
|
-
}"
|
|
12
|
-
v-bind="getRootProps()"
|
|
13
|
-
>
|
|
14
|
-
<input v-bind="getInputProps()" />
|
|
15
|
-
<div class="site-dropzone__instructions">
|
|
16
|
-
<strong class="type-normal">
|
|
17
|
-
Drag 'n' drop files here, or click to select
|
|
18
|
-
</strong>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
<p class="site-form__description">
|
|
22
|
-
<em>Only images allowed (.jpg, .png)</em>
|
|
23
|
-
</p>
|
|
24
|
-
<div v-if="fileErrors.length" class="site-dropzone__errors site-form__description site-form__error">
|
|
25
|
-
<ul class="list-unordered">
|
|
26
|
-
<li v-for="(fileErr, index) in fileErrors" :key="index">
|
|
27
|
-
<strong>{{ fileErr.file.name }}</strong>:
|
|
28
|
-
<span>{{ fileErr.errors.map(e => e.message).join() }}</span>
|
|
29
|
-
</li>
|
|
30
|
-
</ul>
|
|
31
|
-
</div>
|
|
32
|
-
<div class="site-dropzone__display margin-top" v-if="files.length">
|
|
33
|
-
<strong>Files</strong>
|
|
34
|
-
<FilesDisplay class="site-dropzone__list" :files="files"/>
|
|
35
|
-
</div>
|
|
36
|
-
</div>
|
|
37
|
-
</template>
|
|
38
|
-
|
|
39
|
-
<script setup>
|
|
40
|
-
import { ref } from "vue";
|
|
41
|
-
import { useDropzone } from "vue3-dropzone";
|
|
42
|
-
|
|
43
|
-
const files = ref([]);
|
|
44
|
-
const fileErrors = ref([]);
|
|
45
|
-
|
|
46
|
-
const $emit = defineEmits(["filesChange"]);
|
|
47
|
-
|
|
48
|
-
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
|
49
|
-
onDrop: (acceptFiles, rejectReasons) => {
|
|
50
|
-
if (rejectReasons) {
|
|
51
|
-
fileErrors.value = rejectReasons.map(err => err);
|
|
52
|
-
} else {
|
|
53
|
-
fileErrors.value = [];
|
|
54
|
-
}
|
|
55
|
-
if (acceptFiles.length) {
|
|
56
|
-
files.value = acceptFiles.map(file => file);
|
|
57
|
-
$emit("filesChange", files.value);
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
accept: [".png", ".jpg", ".jpeg"]
|
|
61
|
-
});
|
|
62
|
-
</script>
|
package/lib/settings.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module settings
|
|
3
|
-
* @description Manages shared configuration for the library.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { reactive } from 'vue';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Default settings
|
|
10
|
-
* @typedef {object} Defaults
|
|
11
|
-
* @property {string} fontAwesomeStatic - Whether the default UluIcon should use fontawesome vue or fontawesome CSS classes (static)
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @type {Defaults}
|
|
16
|
-
*/
|
|
17
|
-
const defaults = {
|
|
18
|
-
/**
|
|
19
|
-
* If set UluIcon will use global css classes instead of Font Awesome vue component
|
|
20
|
-
*/
|
|
21
|
-
fontAwesomeStatic: false,
|
|
22
|
-
/**
|
|
23
|
-
* Use a different icon component (if using a library other than Font Awesome)
|
|
24
|
-
* - Need to have this component map (iconsByType) to it's implementation
|
|
25
|
-
* - All components internally use type, so only user defined components change definitions
|
|
26
|
-
* - So you should only need to create definitions for the default types to replace this for the library
|
|
27
|
-
*/
|
|
28
|
-
iconComponent: null,
|
|
29
|
-
/**
|
|
30
|
-
* Which prop in iconComponent should receive the resolved definition
|
|
31
|
-
*/
|
|
32
|
-
iconPropResolver: (definition) => ({ icon: definition }),
|
|
33
|
-
/**
|
|
34
|
-
* Default icons by type
|
|
35
|
-
*/
|
|
36
|
-
iconsByType: {
|
|
37
|
-
danger: "fas fa-triangle-exclamation",
|
|
38
|
-
warning: "fas fa-circle-exclamation",
|
|
39
|
-
info: "fas fa-circle-info",
|
|
40
|
-
success: "fas fa-circle-check",
|
|
41
|
-
externalLink: "fas fa-arrow-up-right-from-square",
|
|
42
|
-
close: "fas fa-xmark",
|
|
43
|
-
expand: "fas fa-plus",
|
|
44
|
-
collapse: "fas fa-minus",
|
|
45
|
-
resizeHorizontal: "fas fa-grip-lines-vertical",
|
|
46
|
-
resizeVertical: "fas fa-grip-lines",
|
|
47
|
-
resizeBoth: "fas fa-grip",
|
|
48
|
-
ellipsis: "fas fa-ellipsis",
|
|
49
|
-
pathSeparator: "fas fa-chevron-right"
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// Current configuration, initialized with defaults and made reactive
|
|
54
|
-
// We wrap `defaults` in `reactive` so `currentSettings` becomes a reactive object.
|
|
55
|
-
let currentSettings = reactive({ ...defaults });
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Retrieves a copy of the default settings.
|
|
59
|
-
* @returns {object} A copy of the default settings object.
|
|
60
|
-
*/
|
|
61
|
-
export function getDefaultSettings() {
|
|
62
|
-
// Return a non-reactive copy of defaults
|
|
63
|
-
return { ...defaults };
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Updates multiple configuration settings.
|
|
68
|
-
* @param {object} changes An object containing the settings to update.
|
|
69
|
-
*/
|
|
70
|
-
export function updateSettings(changes) {
|
|
71
|
-
Object.assign(currentSettings, changes);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Retrieves a copy of the current configuration settings.
|
|
76
|
-
* @returns {object} A copy of the current settings object (vue reactive object)
|
|
77
|
-
*/
|
|
78
|
-
export function getSettings() {
|
|
79
|
-
return currentSettings;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Retrieves a specific configuration setting by key.
|
|
84
|
-
* @param {string} key The key of the setting to retrieve.
|
|
85
|
-
* @returns {*} The value of the setting, or undefined if not found.
|
|
86
|
-
*/
|
|
87
|
-
export function getSetting(key) {
|
|
88
|
-
if (!currentSettings.hasOwnProperty(key)) {
|
|
89
|
-
console.warn(`Attempted to access non-existent setting: ${key}`);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
return currentSettings[key];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Updates a specific configuration setting.
|
|
97
|
-
* @param {string} key The key of the setting to update.
|
|
98
|
-
* @param {*} value The new value for the setting.
|
|
99
|
-
*/
|
|
100
|
-
export function updateSetting(key, value) {
|
|
101
|
-
if (typeof key !== "string") {
|
|
102
|
-
throw new Error("Expected key to be string");
|
|
103
|
-
}
|
|
104
|
-
currentSettings[key] = value;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Retrieves the icon definition by type
|
|
109
|
-
* @param {string} type - The type of icon to retrieve (e.g., 'error', 'info').
|
|
110
|
-
* @returns {string} The icon definition
|
|
111
|
-
* @throws {Error} If the specified icon type is not found
|
|
112
|
-
*/
|
|
113
|
-
export function getIconByType(type) {
|
|
114
|
-
const icons = currentSettings.iconsByType;
|
|
115
|
-
if (!icons[type]) {
|
|
116
|
-
throw new Error(`Icon type "${ type }" not found!`);
|
|
117
|
-
}
|
|
118
|
-
return icons[type];
|
|
119
|
-
}
|