@ulu/frontend-vue 0.1.0-beta.16 → 0.1.0-beta.18

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.
@@ -54,7 +54,7 @@
54
54
  </component>
55
55
  <slot name="body"/>
56
56
  </div>
57
- <div class="card__aside" v-if="$slots.body">
57
+ <div class="card__aside" v-if="$slots.aside">
58
58
  <slot name="aside"/>
59
59
  </div>
60
60
  </div>
@@ -54,9 +54,8 @@ $config: (
54
54
  $prefix: selector.class("facets");
55
55
 
56
56
  #{ $prefix }__body {
57
- .FacetView__body {
58
- display: flex
59
- ;
57
+ .FacetView__body {
58
+ display: flex;
60
59
  }
61
60
  }
62
61
  }
@@ -5,17 +5,21 @@ export { default as UluFacetsSearch } from './facets/UluFacetsSearch.vue';
5
5
  export { default as UluFacetsSidebarLayout } from './facets/UluFacetsSidebarLayout.vue';
6
6
  export { default as UluFacetsSort } from './facets/UluFacetsSort.vue';
7
7
  export { default as UluFacetsList } from './facets/UluFacetsList.vue';
8
+
8
9
  export { default as UluScrollAnchors } from './scroll-anchors/UluScrollAnchors.vue';
9
10
  export { default as UluScrollAnchorsNav } from './scroll-anchors/UluScrollAnchorsNav.vue';
10
11
  export { default as UluScrollAnchorsNavAnimated } from './scroll-anchors/UluScrollAnchorsNavAnimated.vue';
11
12
  export { default as UluScrollAnchorsSection } from './scroll-anchors/UluScrollAnchorsSection.vue';
13
+
12
14
  export { default as UluShowSkeleton } from './skeleton/UluShowSkeleton.vue';
13
15
  export { default as UluSkeletonContent } from './skeleton/UluSkeletonContent.vue';
14
16
  export { default as UluSkeletonMedia } from './skeleton/UluSkeletonMedia.vue';
15
- export { default as UluSkeletonTextInline } from './skeleton/UluSkeletonTextInline.vue';
17
+ export { default as UluSkeletonText } from './skeleton/UluSkeletonText.vue';
18
+
16
19
  export { default as UluImageSlideShow } from './slider/UluImageSlideShow.vue';
17
20
  export { default as UluSlideShow } from './slider/UluSlideShow.vue';
18
21
  export { default as UluSlideShowSlide } from './slider/UluSlideShowSlide.vue';
22
+
19
23
  export { default as UluTableSticky } from './table-sticky/UluTableSticky.vue';
20
24
  export { default as UluTableStickyRows } from './table-sticky/UluTableStickyRows.vue';
21
25
  export { default as UluTableStickyTable } from './table-sticky/UluTableStickyTable.vue';
@@ -1,13 +1,14 @@
1
1
  <template>
2
2
  <slot v-if="!when"/>
3
- <SkeletonTextInline class="skeleton" v-else/>
3
+ <UluSkeletonText v-else inline/>
4
4
  </template>
5
5
 
6
- <script>
7
- export default {
8
- name: "ShowSkeleton",
9
- props: {
10
- when: Boolean,
11
- },
12
- };
6
+ <script setup>
7
+ import UluSkeletonText from "./UluSkeletonText.vue";
8
+ defineProps({
9
+ /**
10
+ * If true will show whatever is passed to slot, else skeleton text
11
+ */
12
+ when: Boolean,
13
+ });
13
14
  </script>
@@ -1,11 +1,11 @@
1
1
  <template>
2
- <div class="skeleton">
2
+ <div>
3
3
  <div v-for="(line, index) in linesWithSegments" :key="index">
4
4
  <span
5
5
  v-for="segment in line"
6
6
  :key="segment"
7
- class="skeleton__text skeleton__text--inline"
8
- :class="{ 'skeleton__alt' : segment.alt }"
7
+ class="skeleton skeleton--text skeleton--inline"
8
+ :class="{ 'skeleton--background-alt' : segment.alt }"
9
9
  :style="{ width: `${ segment.width }%` }"
10
10
  >
11
11
  </span>
@@ -13,48 +13,44 @@
13
13
  </div>
14
14
  </template>
15
15
 
16
- <script>
16
+ <script setup>
17
+ import { computed } from "vue";
17
18
  import { randomInt } from "@ulu/utils/random.js";
18
19
  import { arrayCreate } from "@ulu/utils/array.js";
19
- export default {
20
- name: "SkeletonContent",
21
- props: {
22
- lines: {
23
- type: Number,
24
- default: 6
25
- },
26
- },
27
- methods: {
28
- randomInt
20
+
21
+ const props = defineProps({
22
+ /**
23
+ * Amount of lines to generate
24
+ */
25
+ lines: {
26
+ type: Number,
27
+ default: 6
29
28
  },
30
- computed: {
31
- /**
32
- * Creates the segments (like words) for the given line count
33
- * - Uses random number of segments and makes sure to fill the line between 70% - 100%
34
- */
35
- linesWithSegments() {
36
- return arrayCreate(this.lines, () => {
37
- const minWidth = 15;
38
- const total = randomInt(70, 100);
39
- let widthCurrent = 0;
40
- const newWidth = () => {
41
- const remaining = total - widthCurrent;
42
- const width = randomInt(minWidth, remaining);
43
- widthCurrent += width;
44
- return width;
45
- };
46
- const segments = [];
47
- while (widthCurrent < total - minWidth) {
48
- segments.push(newWidth());
49
- }
50
- const getActualTotal = () => segments.reduce((acc, a) => acc + a, 0);
51
- while (getActualTotal() >= total) {
52
- let removed = segments.pop();
53
- if (!removed) break;
54
- }
55
- return segments.map(width => ({ width, alt: Math.random() < 0.5 }));
56
- });
57
- }
29
+ });
30
+
31
+ /**
32
+ * Creates the segments (like words) for the given line count
33
+ * - Uses random number of segments and makes sure to fill the line between 70% - 100%
34
+ */
35
+ const linesWithSegments = computed(() => arrayCreate(props.lines, () => {
36
+ const minWidth = 15;
37
+ const total = randomInt(70, 100);
38
+ let widthCurrent = 0;
39
+ const newWidth = () => {
40
+ const remaining = total - widthCurrent;
41
+ const width = randomInt(minWidth, remaining);
42
+ widthCurrent += width;
43
+ return width;
44
+ };
45
+ const segments = [];
46
+ while (widthCurrent < total - minWidth) {
47
+ segments.push(newWidth());
48
+ }
49
+ const getActualTotal = () => segments.reduce((acc, a) => acc + a, 0);
50
+ while (getActualTotal() >= total) {
51
+ let removed = segments.pop();
52
+ if (!removed) break;
58
53
  }
59
- };
54
+ return segments.map(width => ({ width, alt: Math.random() < 0.5 }));
55
+ }));
60
56
  </script>
@@ -1,11 +1,9 @@
1
1
  <template>
2
- <div class="skeleton__block skeleton__block--media layout-flex-center-all">
3
- <FaIcon style="font-size: 2rem" icon="image"/>
2
+ <div class="skeleton skeleton-block--media">
3
+ <UluIcon icon="type:image"/>
4
4
  </div>
5
5
  </template>
6
6
 
7
- <script>
8
- export default {
9
- name: "SkeletonMedia",
10
- };
7
+ <script setup>
8
+ import UluIcon from "../../elements/UluIcon.vue";
11
9
  </script>
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <span
3
+ class="skeleton skeleton--text"
4
+ :class="{
5
+ 'skeleton--inline' : inline,
6
+ 'skeleton--background-alt' : alt,
7
+ [`skeleton--width-${ width }`] : width
8
+ }"
9
+ ></span>
10
+ </template>
11
+
12
+ <script setup>
13
+ defineProps({
14
+ /**
15
+ * Inline modifier
16
+ */
17
+ inline: Boolean,
18
+ /**
19
+ * Use alternate background color
20
+ */
21
+ alt: Boolean,
22
+ /**
23
+ * Optional size (width) - should correspond with width setup in scss component
24
+ */
25
+ width: String
26
+ });
27
+ </script>
package/lib/index.js CHANGED
@@ -7,3 +7,4 @@
7
7
  export * from './plugins/index.js';
8
8
  export * from './components/index.js';
9
9
  export * from './composables/index.js';
10
+ export * as utils from './utils/index.js';
@@ -21,7 +21,8 @@ const defaults = {
21
21
  resizeVertical: "fas fa-grip-lines",
22
22
  resizeBoth: "fas fa-grip",
23
23
  ellipsis: "fas fa-ellipsis",
24
- pathSeparator: "fas fa-chevron-right"
24
+ pathSeparator: "fas fa-chevron-right",
25
+ image: "fas fa-image"
25
26
  }
26
27
  };
27
28
 
@@ -0,0 +1,2 @@
1
+ export * as dom from './dom.js';
2
+ export * as router from './router.js';
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This Module Creates Menus from route or router config
3
3
  * - Note: Functions prefixed with "$" work with $route objects (running application, provided by vue-router ie $router, useRoute, etc),
4
- * @module utils/router-utils
4
+ * @module router-utils
5
5
  */
6
6
 
7
7
  /**
@@ -21,21 +21,56 @@
21
21
  */
22
22
  export function createBaseMenu(routes, options) {
23
23
  const defaults = {
24
- qualifier: isStaticBaseRoute,
24
+ qualifier(route, parentPath) {
25
+ if (!parentPath) {
26
+ return isStaticBaseRoute(route);
27
+ } else {
28
+ return isStaticRoute(route);
29
+ }
30
+ },
25
31
  sort: sortByWeight,
26
- item: {}
32
+ item: {},
33
+ includeChildren: false
27
34
  };
28
35
  const opts = Object.assign({}, defaults, options);
29
- return routes
30
- .filter(opts.qualifier)
31
- .map(r => {
32
- // Need to grab meta from child but use the parent path
33
- const menuRoute = r.children ? getChildIndexRoute(r.children) : r;
34
- return createMenuItem(menuRoute, r.path, opts.item);
35
- })
36
- .sort(opts.sort);
36
+ const getItemPath = (r, parentPath) => parentPath ? `${ parentPath }/${ r.path }` : r.path;
37
+ const toMenuItems = (currentRoutes, parentPath = null) => {
38
+ return currentRoutes
39
+ .filter(r => opts.qualifier(r, parentPath))
40
+ .map(r => {
41
+ // Need to grab meta from child but use the parent path
42
+ const menuRoute = r.children ? getChildIndexRoute(r.children) : r;
43
+ const children = r.children ? r.children.filter(child => child.path !== "") : false;
44
+ const item = createMenuItem(menuRoute, getItemPath(r, parentPath), opts.item);
45
+ if (opts.includeChildren && children.length) {
46
+ item.children = toMenuItems(children, item.path);
47
+ }
48
+ return item;
49
+ })
50
+ .sort(opts.sort);
51
+ };
52
+ return toMenuItems(routes);
37
53
  }
38
54
 
55
+ /**
56
+ * Returns menu flat (no parent children)
57
+ */
58
+ export function flattenMenu(menu) {
59
+ function flatten(items) {
60
+ const result = [];
61
+ for (const item of items) {
62
+ const newItem = { ...item };
63
+ delete newItem.children;
64
+ result.push(newItem);
65
+ if (item.children) {
66
+ result.push(...flatten(item.children));
67
+ }
68
+ }
69
+ return result;
70
+ }
71
+ return flatten(menu);
72
+ }
73
+
39
74
  /**
40
75
  * Print out a section's menu based on path
41
76
  * @param {*} routes All routes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulu/frontend-vue",
3
- "version": "0.1.0-beta.16",
3
+ "version": "0.1.0-beta.18",
4
4
  "description": "A modular and tree-shakeable Vue 3 component library for the Ulu frontend",
5
5
  "type": "module",
6
6
  "files": [
@@ -35,7 +35,8 @@
35
35
  "docs:build": "storybook build -o docs",
36
36
  "build": "vite build",
37
37
  "types": "npx tsc",
38
- "deploy": "npm run types && npm run build && npm run docs:build"
38
+ "deploy": "npm run types && npm run build && npm run docs:build",
39
+ "update-contexts": "rm -rf .contexts && mkdir -p .contexts/frontend && cp -R node_modules/@ulu/frontend/scss node_modules/@ulu/frontend/js .contexts/frontend/"
39
40
  },
40
41
  "keywords": [
41
42
  "vue",
@@ -56,7 +57,7 @@
56
57
  "homepage": "https://github.com/Jscherbe/frontend-vue#readme",
57
58
  "peerDependencies": {
58
59
  "@headlessui/vue": "^1.7.23",
59
- "@ulu/frontend": "^0.1.0-beta.94",
60
+ "@ulu/frontend": "^0.1.0-beta.100",
60
61
  "vue": "^3.5.17",
61
62
  "vue-router": "^4.5.1"
62
63
  },
@@ -78,7 +79,7 @@
78
79
  "@storybook/addon-links": "^9.1.1",
79
80
  "@storybook/addon-essentials": "^9.0.0-alpha.12",
80
81
  "@storybook/vue3-vite": "^9.1.1",
81
- "@ulu/frontend": "^0.1.0-beta.94",
82
+ "@ulu/frontend": "^0.1.0-beta.100",
82
83
  "@vitejs/plugin-vue": "^6.0.0",
83
84
  "ollama": "^0.5.16",
84
85
  "react": "^19.1.1",
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./plugins/index.js";
2
2
  export * from "./components/index.js";
3
3
  export * from "./composables/index.js";
4
+ export * as utils from "./utils/index.js";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/plugins/core/index.js"],"names":[],"mappings":"AA6BA,mEAyDC;AA3DD,gCAA0D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/plugins/core/index.js"],"names":[],"mappings":"AA8BA,mEAyDC;AA3DD,gCAA0D"}
@@ -0,0 +1,3 @@
1
+ export * as dom from "./dom.js";
2
+ export * as router from "./router.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/utils/index.js"],"names":[],"mappings":""}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * This Module Creates Menus from route or router config
3
+ * - Note: Functions prefixed with "$" work with $route objects (running application, provided by vue-router ie $router, useRoute, etc),
4
+ * @module router-utils
5
+ */
6
+ /**
7
+ * Route Menu Item
8
+ * @typedef {Object} RouteMenuItem
9
+ * @property {String} path - Menu item route path
10
+ * @property {String} title - Menu item title
11
+ */
12
+ /**
13
+ * Get root/base static routes as menu items
14
+ * @param {*} routes Routes to build menu from (not router instance)
15
+ * @param {Object} options Options
16
+ * @param {Object} options.qualifier Callback to qualify as a base route (defaults to isStaticBaseRoute)
17
+ * @param {Object} options.item Options for createMenuItem
18
+ * @returns {Array.<RouteMenuItem>} Array of menu items
19
+ */
20
+ export function createBaseMenu(routes: any, options: {
21
+ qualifier: any;
22
+ item: any;
23
+ }): Array<RouteMenuItem>;
24
+ /**
25
+ * Returns menu flat (no parent children)
26
+ */
27
+ export function flattenMenu(menu: any): any;
28
+ /**
29
+ * Print out a section's menu based on path
30
+ * @param {*} routes All routes
31
+ * @param {*} sectionPath Path for section to create menu
32
+ * @param {Object} options Options
33
+ * @param {Boolean} options.includeIndex Include the parent/index in the menu items ie ({ path: "" })
34
+ * @param {Object} options.item Options to be passed to createMenuItem
35
+ * @returns {Array.<RouteMenuItem>} Array of menu items
36
+ */
37
+ export function createSectionMenu(routes: any, sectionPath: any, options: {
38
+ includeIndex: boolean;
39
+ item: any;
40
+ }): Array<RouteMenuItem>;
41
+ /**
42
+ * For a given route this will return the route that renders. For routes without
43
+ * children this is the route itself for those with children (first child with empty path)
44
+ * @param {Object} route Route object to resolve
45
+ * @returns {Object} Resolved route
46
+ */
47
+ /**
48
+ * For a given array of child routes return the index
49
+ * @param {Array} children Children array of routes
50
+ * @returns {Object} Route
51
+ */
52
+ export function getChildIndexRoute(children: any[]): any;
53
+ /**
54
+ * Creates common menu item structure from route, pulls title and weight from meta (on route or index child)
55
+ * @param {Object} route Route
56
+ * @param {Object} routePath The final path for the menu item
57
+ * @param {Object} options Function to allow alterering the menu item (adding meta, etc)
58
+ * @param {Function} options.modify Function to allow alterering the menu item (adding meta, etc) (args: item, route)
59
+ * @param {Function} options.indexMeta Include the routes index child's meta (merged on top of route meta)
60
+ * @returns {RouteMenuItem} Menu item
61
+ */
62
+ export function createMenuItem(route: any, routePath: any, options: {
63
+ modify: Function;
64
+ indexMeta: Function;
65
+ }): RouteMenuItem;
66
+ /**
67
+ * Test if route is static (doesn't incude parameters)
68
+ * @param {Object} route Route object to test
69
+ * @returns {Boolean} Whether or not this route is static (not dynamic)
70
+ */
71
+ export function isStaticRoute(route: any): boolean;
72
+ /**
73
+ *
74
+ * @param {Object} route Route object to test
75
+ * @returns {Boolean} Whether or not this route is a static base route
76
+ */
77
+ export function isStaticBaseRoute(route: any): boolean;
78
+ /**
79
+ * Function to make normal <a> behave as router links instread of page reload
80
+ * @param {Object} router Router instance (ie src/router) to push routes to
81
+ * @param {Object} event The event object that triggered route change (ie. onclick) pass event object
82
+ */
83
+ export function nativeLinkRouter(router: any, event: any): void;
84
+ /**
85
+ * Returns the child routes for base route
86
+ * @param {Object} route Route Object
87
+ * @returns
88
+ */
89
+ export function $getRouteChildren(route: any, parent?: any): any;
90
+ /**
91
+ * Returns the route's parent
92
+ * @param {Object} route Route Object
93
+ * @param {Object} deepest By default this returns the routes parent, if deepest it will return it's base route (top level parent)
94
+ * @return {Object|Null} Parent route, if there is no parent route for the given route this will return null
95
+ */
96
+ export function $getParentRoute(route: any, deepest: any): any | null;
97
+ /**
98
+ * For a given $route will return all it's children as menu items,
99
+ * using the route's meta.title property for the title. This is for sections only (routes with children)
100
+ * - Useful for dynamic menus (menus within some unknown section) where you don't want to write static paths
101
+ * @param {Object} route Actual $route object
102
+ * @param {Object} options Options
103
+ * @param {Object} options.parent Route parent object, defaults to parent of route
104
+ * @param {Boolean} options.includeIndex Include the parent/index in the menu items ie ({ path: "" })
105
+ * @param {Object} options.item Options for createMenuItem
106
+ * @returns {Array.<RouteMenuItem>} Array of menu items
107
+ */
108
+ export function $createSectionMenu(route: any, options: {
109
+ parent: any;
110
+ includeIndex: boolean;
111
+ item: any;
112
+ }): Array<RouteMenuItem>;
113
+ /**
114
+ * Route Menu Item
115
+ */
116
+ export type RouteMenuItem = {
117
+ /**
118
+ * - Menu item route path
119
+ */
120
+ path: string;
121
+ /**
122
+ * - Menu item title
123
+ */
124
+ title: string;
125
+ };
126
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../lib/utils/router.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;;;;GAOG;AACH,uCANW,GAAC,WAET;IAAwB,SAAS;IACT,IAAI;CAC5B,GAAU,KAAK,CAAE,aAAa,CAAC,CAiCjC;AAED;;GAEG;AACH,4CAcC;AAED;;;;;;;;GAQG;AACH,0CAPW,GAAC,eACD,GAAC,WAET;IAAyB,YAAY;IACb,IAAI;CAC5B,GAAU,KAAK,CAAE,aAAa,CAAC,CA6BjC;AAED;;;;;GAKG;AASH;;;;GAIG;AACH,yDAEC;AACD;;;;;;;;GAQG;AACH,oEAJG;IAA0B,MAAM;IACN,SAAS;CACnC,GAAU,aAAa,CAsBzB;AACD;;;;GAIG;AACH,mDAEC;AACD;;;;GAIG;AACH,uDAGC;AACD;;;;GAIG;AACH,gEAUC;AACD;;;;GAIG;AACH,iEAEC;AACD;;;;;GAKG;AACH,2DAFY,UAAW,CAUtB;AAUD;;;;;;;;;;GAUG;AACH,wDALG;IAAwB,MAAM;IACL,YAAY;IACb,IAAI;CAC5B,GAAU,KAAK,CAAE,aAAa,CAAC,CAgBjC"}
@@ -1,9 +0,0 @@
1
- <template>
2
- <span class="skeleton__text skeleton__text--inline"></span>
3
- </template>
4
-
5
- <script>
6
- export default {
7
- name: "SkeletonTextInline",
8
- };
9
- </script>
@@ -1,6 +0,0 @@
1
- export default {
2
- text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis nisi, nec pretium justo varius sit amet. Vestibulum vitae quam in velit scelerisque tincidunt et vitae mauris. Fusce aliquet, ipsum sit amet lacinia euismod, est risus rhoncus ligula, eget egestas urna ligula nec enim. Fusce vulputate ornare ligula ut tempus. Sed accumsan orci sed turpis iaculis, at aliquam nibh rhoncus. Maecenas porta lorem a sem tincidunt, sed tristique ex laoreet. Nullam accumsan metus at lobortis interdum. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam sagittis sem erat, quis fermentum lectus ultrices quis.",
3
- textSmall: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis nisi, nec pretium justo varius sit amet.",
4
- paragraph: "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis nisi, nec pretium justo varius sit amet. Vestibulum vitae quam in velit scelerisque tincidunt et vitae mauris. Fusce aliquet, ipsum sit amet lacinia euismod, est risus rhoncus ligula, eget egestas urna ligula nec enim. Fusce vulputate ornare ligula ut tempus. Sed accumsan orci sed turpis iaculis, at aliquam nibh rhoncus. Maecenas porta lorem a sem tincidunt, sed tristique ex laoreet. Nullam accumsan metus at lobortis interdum. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam sagittis sem erat, quis fermentum lectus ultrices quis.</p>",
5
- paragraphSmall: "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam commodo felis nisi, nec pretium justo varius sit amet. Vestibulum vitae quam in velit scelerisque tincidunt et vitae mauris. </p>"
6
- }