@ulu/frontend-vue 0.3.1 → 0.3.2

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.
@@ -14,9 +14,11 @@ declare const __VLS_component: import('vue').DefineComponent<{}, {
14
14
  positive: boolean;
15
15
  negative: boolean;
16
16
  loader: boolean;
17
+ rounded: boolean;
17
18
  indeterminate: boolean;
18
19
  noValues: boolean;
19
20
  amountInHeader: boolean;
21
+ modifiers?: string | unknown[] | undefined;
20
22
  label?: string | undefined;
21
23
  formatValue?: Function | undefined;
22
24
  $props: {
@@ -30,9 +32,11 @@ declare const __VLS_component: import('vue').DefineComponent<{}, {
30
32
  readonly positive?: boolean | undefined;
31
33
  readonly negative?: boolean | undefined;
32
34
  readonly loader?: boolean | undefined;
35
+ readonly rounded?: boolean | undefined;
33
36
  readonly indeterminate?: boolean | undefined;
34
37
  readonly noValues?: boolean | undefined;
35
38
  readonly amountInHeader?: boolean | undefined;
39
+ readonly modifiers?: string | unknown[] | undefined;
36
40
  readonly label?: string | undefined;
37
41
  readonly formatValue?: Function | undefined;
38
42
  };
@@ -1 +1 @@
1
- {"version":3,"file":"UluProgressBar.vue.d.ts","sourceRoot":"","sources":["../../../lib/components/visualizations/UluProgressBar.vue"],"names":[],"mappings":"AAsDA;wBA8aqB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;;6BAEtE,CAAC,EAAE,CAAC;;;AAXjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sPAQG"}
1
+ {"version":3,"file":"UluProgressBar.vue.d.ts","sourceRoot":"","sources":["../../../lib/components/visualizations/UluProgressBar.vue"],"names":[],"mappings":"AA4DA;wBA4cqB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;;6BAEtE,CAAC,EAAE,CAAC;;;AAXjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sPAQG"}
@@ -1,172 +1,186 @@
1
- import { computed as m, createElementBlock as r, openBlock as s, normalizeClass as v, createCommentVNode as n, createElementVNode as o, createBlock as B, resolveDynamicComponent as h, withCtx as k, renderSlot as i, createTextVNode as u, toDisplayString as d, normalizeStyle as b } from "vue";
2
- const V = {
1
+ import { computed as m, createElementBlock as n, openBlock as s, normalizeClass as v, unref as B, createCommentVNode as r, createElementVNode as o, createBlock as h, resolveDynamicComponent as k, withCtx as V, renderSlot as i, createTextVNode as d, toDisplayString as u, normalizeStyle as b } from "vue";
2
+ import { useModifiers as $ } from "../../composables/useModifiers.js";
3
+ const C = {
3
4
  key: 0,
4
5
  class: "progress-bar__header"
5
- }, $ = {
6
+ }, H = {
6
7
  key: 1,
7
8
  class: "progress-bar__value progress-bar__value--amount"
8
- }, C = {
9
+ }, N = {
9
10
  key: 2,
10
11
  class: "progress-bar__icon"
11
- }, H = { class: "progress-bar__track" }, N = {
12
+ }, S = { class: "progress-bar__track" }, A = {
12
13
  key: 1,
13
14
  class: "progress-bar__values"
14
- }, S = { class: "progress-bar__value progress-bar__value--amount" }, A = {
15
+ }, D = { class: "progress-bar__value progress-bar__value--amount" }, E = {
15
16
  key: 0,
16
17
  class: "progress-bar__value progress-bar__value--deficit"
17
- }, D = { class: "progress-bar__value progress-bar__value--total" }, w = {
18
+ }, I = { class: "progress-bar__value progress-bar__value--total" }, M = {
18
19
  __name: "UluProgressBar",
19
20
  props: {
20
21
  /**
21
- * The label to display above the progress bar. (or use label slot)
22
- */
22
+ * The label to display above the progress bar. (or use label slot)
23
+ */
23
24
  label: String,
24
25
  /**
25
- * Hides the label visually, but keeps it for screen readers.
26
- */
26
+ * Hides the label visually, but keeps it for screen readers.
27
+ */
27
28
  labelHidden: Boolean,
28
29
  /**
29
- * Optional classes object (currently only allowing { label } class)
30
- */
30
+ * Optional classes object (currently only allowing { label } class)
31
+ */
31
32
  classes: {
32
33
  type: Object,
33
34
  default: () => ({})
34
35
  },
35
36
  /**
36
- * Element to use for label
37
- */
37
+ * Element to use for label
38
+ */
38
39
  labelElement: {
39
40
  type: String,
40
41
  default: "strong"
41
42
  },
42
43
  /**
43
- * The current amount of progress.
44
- */
44
+ * The current amount of progress.
45
+ */
45
46
  amount: {
46
47
  type: Number,
47
48
  default: 0
48
49
  },
49
50
  /**
50
- * The total amount that represents 100% progress.
51
- */
51
+ * The total amount that represents 100% progress.
52
+ */
52
53
  total: {
53
54
  type: Number,
54
55
  default: 100
55
56
  },
56
57
  /**
57
- * The amount of deficit to display on the bar.
58
- */
58
+ * The amount of deficit to display on the bar.
59
+ */
59
60
  deficit: {
60
61
  type: Number,
61
62
  default: 0
62
63
  },
63
64
  /**
64
- * Renders a smaller version of the progress bar.
65
- */
65
+ * Renders a smaller version of the progress bar.
66
+ */
66
67
  small: Boolean,
67
68
  /**
68
- * Applies the 'positive' style (e.g., green).
69
- */
69
+ * Applies the 'positive' style (e.g., green).
70
+ */
70
71
  positive: Boolean,
71
72
  /**
72
- * Applies the 'negative' style (e.g., red).
73
- */
73
+ * Applies the 'negative' style (e.g., red).
74
+ */
74
75
  negative: Boolean,
75
76
  /**
76
- * Applies styles for use as a thin loader.
77
- */
77
+ * Applies styles for use as a thin loader.
78
+ */
78
79
  loader: Boolean,
79
80
  /**
80
- * Applies an indeterminate animation for unknown progress.
81
- */
81
+ * Applies styles for use as a thin loader.
82
+ */
83
+ rounded: Boolean,
84
+ /**
85
+ * Applies an indeterminate animation for unknown progress.
86
+ */
82
87
  indeterminate: Boolean,
83
88
  /**
84
- * Omit values from output (the numbers below the progress bar)
85
- */
89
+ * Omit values from output (the numbers below the progress bar)
90
+ */
86
91
  noValues: Boolean,
87
92
  /**
88
- * A function to format the numerical values (amount, deficit, total).
89
- * Takes the value and type ('amount', 'deficit', 'total') as input and should return a string.
90
- */
93
+ * A function to format the numerical values (amount, deficit, total).
94
+ * Takes the value and type ('amount', 'deficit', 'total') as input and should return a string.
95
+ */
91
96
  formatValue: {
92
97
  type: Function,
93
98
  default: (e, a) => e
94
99
  },
95
100
  /**
96
- * Will put the amount only in header (there is a headerValue slot it you want to format)
101
+ * Will put the amount only in header (there is a headerValue slot it you want to format)
102
+ */
103
+ amountInHeader: Boolean,
104
+ /**
105
+ * Modifiers (to add any modifier classes based on base class [ie. 'tertiary'])
97
106
  */
98
- amountInHeader: Boolean
107
+ modifiers: [String, Array]
99
108
  },
100
109
  setup(e) {
101
- const a = e, c = (t, l) => `${l === 0 ? 0 : t / l * 100}%`, g = m(() => a.indeterminate ? null : c(a.amount, a.total)), f = m(() => c(a.deficit, a.total)), y = m(() => ({
102
- "progress-bar": !0,
103
- "progress-bar--small": a.small,
104
- "progress-bar--positive": a.positive,
105
- "progress-bar--negative": a.negative,
106
- "progress-bar--loader": a.loader,
107
- "progress-bar--indeterminate": a.indeterminate,
108
- "type-small": a.small
109
- // From original component, seems to control font size
110
- }));
111
- return (t, l) => (s(), r("div", {
112
- class: v(y.value)
110
+ const a = e, c = (t, l) => `${l === 0 ? 0 : t / l * 100}%`, f = m(() => a.indeterminate ? null : c(a.amount, a.total)), g = m(() => c(a.deficit, a.total)), { resolvedModifiers: y } = $({
111
+ props: a,
112
+ baseClass: "progress-bar",
113
+ internal: m(() => ({
114
+ small: a.small,
115
+ positive: a.positive,
116
+ negative: a.negative,
117
+ loader: a.loader,
118
+ rounded: a.rounded,
119
+ indeterminate: a.indeterminate
120
+ }))
121
+ });
122
+ return (t, l) => (s(), n("div", {
123
+ class: v(["progress-bar", [
124
+ B(y),
125
+ { "type-small": e.small }
126
+ ]])
113
127
  }, [
114
- e.label || t.$slots.label || t.$slots.icon || e.amountInHeader ? (s(), r("div", V, [
115
- e.label ? (s(), B(h(e.labelElement), {
128
+ e.label || t.$slots.label || t.$slots.icon || e.amountInHeader ? (s(), n("div", C, [
129
+ e.label ? (s(), h(k(e.labelElement), {
116
130
  key: 0,
117
131
  class: v(["progress-bar__label", [e.classes.label, { "hidden-visually": e.labelHidden }]])
118
132
  }, {
119
- default: k(() => [
133
+ default: V(() => [
120
134
  i(t.$slots, "label", {}, () => [
121
- u(d(e.label), 1)
135
+ d(u(e.label), 1)
122
136
  ])
123
137
  ]),
124
138
  _: 3
125
- }, 8, ["class"])) : n("", !0),
126
- e.amountInHeader ? (s(), r("div", $, [
139
+ }, 8, ["class"])) : r("", !0),
140
+ e.amountInHeader ? (s(), n("div", H, [
127
141
  l[0] || (l[0] = o("strong", { class: "hidden-visually" }, "Amount:", -1)),
128
142
  i(t.$slots, "valueAmount", { value: e.amount }, () => [
129
- u(d(e.formatValue(e.amount, "amount")), 1)
143
+ d(u(e.formatValue(e.amount, "amount")), 1)
130
144
  ])
131
- ])) : n("", !0),
132
- t.$slots.icon ? (s(), r("div", C, [
145
+ ])) : r("", !0),
146
+ t.$slots.icon ? (s(), n("div", N, [
133
147
  i(t.$slots, "icon")
134
- ])) : n("", !0)
135
- ])) : n("", !0),
136
- o("div", H, [
148
+ ])) : r("", !0)
149
+ ])) : r("", !0),
150
+ o("div", S, [
137
151
  o("div", {
138
152
  class: "progress-bar__bar",
139
- style: b({ width: g.value })
153
+ style: b({ width: f.value })
140
154
  }, null, 4),
141
- e.deficit > 0 ? (s(), r("div", {
155
+ e.deficit > 0 ? (s(), n("div", {
142
156
  key: 0,
143
157
  class: "progress-bar__bar--deficit",
144
- style: b({ width: f.value })
145
- }, null, 4)) : n("", !0)
158
+ style: b({ width: g.value })
159
+ }, null, 4)) : r("", !0)
146
160
  ]),
147
- !e.noValues && !e.amountInHeader && !e.loader && !e.indeterminate ? (s(), r("div", N, [
148
- o("div", S, [
161
+ !e.noValues && !e.amountInHeader && !e.loader && !e.indeterminate ? (s(), n("div", A, [
162
+ o("div", D, [
149
163
  l[1] || (l[1] = o("strong", { class: "hidden-visually" }, "Amount:", -1)),
150
164
  i(t.$slots, "valueAmount", { value: e.amount }, () => [
151
- u(d(e.formatValue(e.amount, "amount")), 1)
165
+ d(u(e.formatValue(e.amount, "amount")), 1)
152
166
  ])
153
167
  ]),
154
- e.deficit > 0 ? (s(), r("div", A, [
168
+ e.deficit > 0 ? (s(), n("div", E, [
155
169
  l[2] || (l[2] = o("strong", { class: "hidden-visually" }, "Deficit: ", -1)),
156
170
  i(t.$slots, "valueDeficit", { value: e.deficit }, () => [
157
- u("-" + d(e.formatValue(e.deficit, "deficit")), 1)
171
+ d("-" + u(e.formatValue(e.deficit, "deficit")), 1)
158
172
  ])
159
- ])) : n("", !0),
160
- o("div", D, [
173
+ ])) : r("", !0),
174
+ o("div", I, [
161
175
  l[3] || (l[3] = o("strong", { class: "hidden-visually" }, "Total:", -1)),
162
176
  i(t.$slots, "valueTotal", { value: e.total }, () => [
163
- u(d(e.formatValue(e.total, "total")), 1)
177
+ d(u(e.formatValue(e.total, "total")), 1)
164
178
  ])
165
179
  ])
166
- ])) : n("", !0)
180
+ ])) : r("", !0)
167
181
  ], 2));
168
182
  }
169
183
  };
170
184
  export {
171
- w as default
185
+ M as default
172
186
  };
@@ -1,5 +1,11 @@
1
1
  <template>
2
- <div :class="componentClasses">
2
+ <div
3
+ class="progress-bar"
4
+ :class="[
5
+ resolvedModifiers,
6
+ { 'type-small': small }
7
+ ]"
8
+ >
3
9
  <div
4
10
  v-if="label || $slots.label || $slots.icon || amountInHeader"
5
11
  class="progress-bar__header"
@@ -54,115 +60,125 @@
54
60
  </template>
55
61
 
56
62
  <script setup>
57
- import { computed } from "vue";
63
+ import { computed } from "vue";
64
+ import { useModifiers } from "../../composables/useModifiers.js";
58
65
 
59
- /**
60
- * A linear progress bar to display progress, with support for various styles and a deficit indicator.
61
- * @slot icon - A slot for placing an icon in the header, typically to indicate status.
62
- */
63
- const props = defineProps({
64
66
  /**
65
- * The label to display above the progress bar. (or use label slot)
66
- */
67
- label: String,
68
- /**
69
- * Hides the label visually, but keeps it for screen readers.
70
- */
71
- labelHidden: Boolean,
72
- /**
73
- * Optional classes object (currently only allowing { label } class)
74
- */
75
- classes: {
76
- type: Object,
77
- default: () => ({})
78
- },
79
- /**
80
- * Element to use for label
81
- */
82
- labelElement: {
83
- type: String,
84
- default: "strong"
85
- },
86
- /**
87
- * The current amount of progress.
88
- */
89
- amount: {
90
- type: Number,
91
- default: 0,
92
- },
93
- /**
94
- * The total amount that represents 100% progress.
95
- */
96
- total: {
97
- type: Number,
98
- default: 100,
99
- },
100
- /**
101
- * The amount of deficit to display on the bar.
102
- */
103
- deficit: {
104
- type: Number,
105
- default: 0,
106
- },
107
- /**
108
- * Renders a smaller version of the progress bar.
109
- */
110
- small: Boolean,
111
- /**
112
- * Applies the 'positive' style (e.g., green).
113
- */
114
- positive: Boolean,
115
- /**
116
- * Applies the 'negative' style (e.g., red).
117
- */
118
- negative: Boolean,
119
- /**
120
- * Applies styles for use as a thin loader.
121
- */
122
- loader: Boolean,
123
- /**
124
- * Applies an indeterminate animation for unknown progress.
125
- */
126
- indeterminate: Boolean,
127
- /**
128
- * Omit values from output (the numbers below the progress bar)
129
- */
130
- noValues: Boolean,
131
- /**
132
- * A function to format the numerical values (amount, deficit, total).
133
- * Takes the value and type ('amount', 'deficit', 'total') as input and should return a string.
134
- */
135
- formatValue: {
136
- type: Function,
137
- default: (value, type) => value,
138
- },
139
- /**
140
- * Will put the amount only in header (there is a headerValue slot it you want to format)
141
- */
142
- amountInHeader: Boolean
143
- });
67
+ * A linear progress bar to display progress, with support for various styles and a deficit indicator.
68
+ * @slot icon - A slot for placing an icon in the header, typically to indicate status.
69
+ */
70
+ const props = defineProps({
71
+ /**
72
+ * The label to display above the progress bar. (or use label slot)
73
+ */
74
+ label: String,
75
+ /**
76
+ * Hides the label visually, but keeps it for screen readers.
77
+ */
78
+ labelHidden: Boolean,
79
+ /**
80
+ * Optional classes object (currently only allowing { label } class)
81
+ */
82
+ classes: {
83
+ type: Object,
84
+ default: () => ({})
85
+ },
86
+ /**
87
+ * Element to use for label
88
+ */
89
+ labelElement: {
90
+ type: String,
91
+ default: "strong"
92
+ },
93
+ /**
94
+ * The current amount of progress.
95
+ */
96
+ amount: {
97
+ type: Number,
98
+ default: 0,
99
+ },
100
+ /**
101
+ * The total amount that represents 100% progress.
102
+ */
103
+ total: {
104
+ type: Number,
105
+ default: 100,
106
+ },
107
+ /**
108
+ * The amount of deficit to display on the bar.
109
+ */
110
+ deficit: {
111
+ type: Number,
112
+ default: 0,
113
+ },
114
+ /**
115
+ * Renders a smaller version of the progress bar.
116
+ */
117
+ small: Boolean,
118
+ /**
119
+ * Applies the 'positive' style (e.g., green).
120
+ */
121
+ positive: Boolean,
122
+ /**
123
+ * Applies the 'negative' style (e.g., red).
124
+ */
125
+ negative: Boolean,
126
+ /**
127
+ * Applies styles for use as a thin loader.
128
+ */
129
+ loader: Boolean,
130
+ /**
131
+ * Applies styles for use as a thin loader.
132
+ */
133
+ rounded: Boolean,
134
+ /**
135
+ * Applies an indeterminate animation for unknown progress.
136
+ */
137
+ indeterminate: Boolean,
138
+ /**
139
+ * Omit values from output (the numbers below the progress bar)
140
+ */
141
+ noValues: Boolean,
142
+ /**
143
+ * A function to format the numerical values (amount, deficit, total).
144
+ * Takes the value and type ('amount', 'deficit', 'total') as input and should return a string.
145
+ */
146
+ formatValue: {
147
+ type: Function,
148
+ default: (value, type) => value,
149
+ },
150
+ /**
151
+ * Will put the amount only in header (there is a headerValue slot it you want to format)
152
+ */
153
+ amountInHeader: Boolean,
154
+ /**
155
+ * Modifiers (to add any modifier classes based on base class [ie. 'tertiary'])
156
+ */
157
+ modifiers: [String, Array]
158
+ });
144
159
 
145
- const getCssPercentage = (amount, total) => {
146
- const percent = total === 0 ? 0 : (amount / total) * 100;
147
- return `${ percent }%`;
148
- };
160
+ const getCssPercentage = (amount, total) => {
161
+ const percent = total === 0 ? 0 : (amount / total) * 100;
162
+ return `${ percent }%`;
163
+ };
149
164
 
150
- const barWidth = computed(() => {
151
- if (props.indeterminate) return null; // No value for width
152
- return getCssPercentage(props.amount, props.total);
153
- });
165
+ const barWidth = computed(() => {
166
+ if (props.indeterminate) return null; // No value for width
167
+ return getCssPercentage(props.amount, props.total);
168
+ });
154
169
 
155
- const deficitBarWidth = computed(() => getCssPercentage(props.deficit, props.total));
170
+ const deficitBarWidth = computed(() => getCssPercentage(props.deficit, props.total));
156
171
 
157
- const componentClasses = computed(() => {
158
- return {
159
- 'progress-bar': true,
160
- 'progress-bar--small': props.small,
161
- 'progress-bar--positive': props.positive,
162
- 'progress-bar--negative': props.negative,
163
- 'progress-bar--loader': props.loader,
164
- 'progress-bar--indeterminate': props.indeterminate,
165
- 'type-small': props.small, // From original component, seems to control font size
166
- };
167
- });
172
+ const { resolvedModifiers } = useModifiers({
173
+ props,
174
+ baseClass: "progress-bar",
175
+ internal: computed(() => ({
176
+ 'small': props.small,
177
+ 'positive': props.positive,
178
+ 'negative': props.negative,
179
+ 'loader': props.loader,
180
+ 'rounded': props.rounded,
181
+ 'indeterminate': props.indeterminate,
182
+ }))
183
+ });
168
184
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulu/frontend-vue",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "A modular, tree-shakeable Vue 3 component library for the Ulu Frontend theming system, plus general utilities for Vue development",
5
5
  "type": "module",
6
6
  "files": [