@ulu/frontend-vue 0.1.0-beta.3 → 0.1.0-beta.5

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.
@@ -17,10 +17,10 @@
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
 
@@ -39,15 +39,15 @@
39
39
  });
40
40
 
41
41
  const useStaticFa = computed(() => {
42
- return getSetting("fontAwesomeStatic");
42
+ return uluCore.getSetting("fontAwesomeStatic");
43
43
  });
44
44
 
45
45
  const customIconComponent = computed(() => {
46
- return getSetting("iconComponent");
46
+ return uluCore.getSetting("iconComponent");
47
47
  });
48
48
 
49
49
  const iconPropResolver = computed(() => {
50
- return getSetting("iconPropResolver");
50
+ return uluCore.getSetting("iconPropResolver");
51
51
  });
52
52
 
53
53
  // Resolve the final icon definition, giving precedence to the `definition` prop
@@ -57,7 +57,7 @@
57
57
  }
58
58
  if (props.type) {
59
59
  try {
60
- return getIconByType(props.type);
60
+ return uluCore.getIcon(props.type);
61
61
  } catch (e) {
62
62
  console.warn(e);
63
63
  return null;
@@ -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';
@@ -180,7 +180,7 @@
180
180
  import UluTableStickyTable from "./UluTableStickyTable.vue";
181
181
  import { debounce } from "@ulu/utils/performance.js";
182
182
  import { runAfterFramePaint } from "@ulu/utils/browser/performance.js";
183
- import cloneDeep from "lodash.clonedeep";
183
+ import cloneDeep from "lodash-es/cloneDeep.js";
184
184
 
185
185
  const arrayOfObjects = a => a.every(o => typeof o === "object");
186
186
  const required = true;
package/lib/index.js CHANGED
@@ -7,4 +7,3 @@
7
7
  export * from './plugins/index.js';
8
8
  export * from './components/index.js';
9
9
  export * from './composables/index.js';
10
- export * from './settings.js';
@@ -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
+ icons: {
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.icons);
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 { icons: 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.icons;
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.icons[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
+ }
@@ -5,6 +5,7 @@
5
5
  */
6
6
 
7
7
 
8
+ export { default as corePlugin } from './core/index.js';
8
9
  export { default as popoversPlugin } from './popovers/index.js';
9
10
  export { default as modalsPlugin } from './modals/index.js';
10
11
  export { default as toastPlugin } from './toast/index.js';
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@ulu/frontend-vue",
3
- "version": "0.1.0-beta.3",
4
- "description": "Frontend theming library (Vue)",
3
+ "version": "0.1.0-beta.5",
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
  ],
@@ -28,7 +28,17 @@
28
28
  "build": "vite build",
29
29
  "deploy": "npm run build && npm run docs:build"
30
30
  },
31
- "keywords": [],
31
+ "keywords": [
32
+ "vue",
33
+ "vue3",
34
+ "ui",
35
+ "components",
36
+ "component-library",
37
+ "design-system",
38
+ "ulu",
39
+ "frontend",
40
+ "scss"
41
+ ],
32
42
  "author": "Joseph Scherben <jscherbe@gmail.com>",
33
43
  "license": "MIT",
34
44
  "bugs": {
@@ -49,7 +59,7 @@
49
59
  "dependencies": {
50
60
  "@floating-ui/vue": "^1.1.8",
51
61
  "@ulu/utils": "^0.0.30",
52
- "lodash.clonedeep" : "^4.5.0"
62
+ "lodash-es": "^4.17.21"
53
63
  },
54
64
  "devDependencies": {
55
65
  "@fortawesome/fontawesome-svg-core": "^6.7.2",
@@ -74,3 +84,4 @@
74
84
  "node": "22.17.0"
75
85
  }
76
86
  }
87
+