@vialiq/web-components 0.7.0 → 0.8.0

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.
@@ -0,0 +1,3 @@
1
+ export { ViBadge } from './vi-badge.js';
2
+ export type { BadgeVariant, BadgeSize } from './vi-badge.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../libs/web-components/src/badge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { type TemplateResult } from 'lit';
2
+ import { ViElement } from '../base/vi-element.js';
3
+ export type BadgeVariant = 'neutral' | 'primary' | 'success' | 'warning' | 'danger' | 'info';
4
+ export type BadgeSize = 'sm' | 'md' | 'lg';
5
+ /**
6
+ * vi-badge
7
+ * A compact inline indicator used to communicate status, category, or count.
8
+ *
9
+ * @element vi-badge
10
+ * @attr variant - Colour semantic: neutral | primary | success | warning | danger | info (default: neutral)
11
+ * @attr size - Size: sm | md | lg (default: md)
12
+ * @attr dot - Show coloured dot instead of text
13
+ * @attr pill - Fully rounded (pill shape) vs. square (default: true)
14
+ * @attr count - Numeric count to display
15
+ * @attr max - Max count before showing {max}+
16
+ * @attr outline - Outlined/ghost style
17
+ *
18
+ * @slot - Badge text content
19
+ * @slot icon - Optional leading icon
20
+ *
21
+ * @csspart badge - The badge <span> element
22
+ * @csspart dot - The dot indicator circle
23
+ * @csspart icon - Icon slot wrapper
24
+ */
25
+ export declare class ViBadge extends ViElement {
26
+ static styles: import("lit").CSSResult;
27
+ /** Colour semantic */
28
+ accessor variant: BadgeVariant;
29
+ /** Size */
30
+ accessor size: BadgeSize;
31
+ /** Show coloured dot */
32
+ accessor dot: boolean;
33
+ /** Fully rounded (pill shape) vs. square */
34
+ accessor pill: boolean;
35
+ /** Numeric count to display */
36
+ accessor count: number | undefined;
37
+ /** Max count before showing {max}+ */
38
+ accessor max: number;
39
+ /** Outlined/ghost style */
40
+ accessor outline: boolean;
41
+ private accessor _hasIcon;
42
+ private accessor _hasDefaultSlot;
43
+ connectedCallback(): void;
44
+ updated(changedProperties: Map<string | number | symbol, unknown>): void;
45
+ private updateAriaHidden;
46
+ private onIconSlotChange;
47
+ private onDefaultSlotChange;
48
+ render(): TemplateResult;
49
+ }
50
+ declare global {
51
+ interface HTMLElementTagNameMap {
52
+ 'vi-badge': ViBadge;
53
+ }
54
+ }
55
+ //# sourceMappingURL=vi-badge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vi-badge.d.ts","sourceRoot":"","sources":["../../../../libs/web-components/src/badge/vi-badge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;AAC7F,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,OAAQ,SAAQ,SAAS;IACpC,OAAgB,MAAM,0BAAkC;IAExD,sBAAsB;IACqB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAa;IAEtF,WAAW;IACgC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAQ;IAE3E,wBAAwB;IACoB,QAAQ,CAAC,GAAG,UAAS;IAEjE,4CAA4C;IACA,QAAQ,CAAC,IAAI,UAAQ;IAEjE,+BAA+B;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAa;IAE3E,sCAAsC;IACV,QAAQ,CAAC,GAAG,SAAM;IAE9C,2BAA2B;IACiB,QAAQ,CAAC,OAAO,UAAS;IAE5D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IAEzC,iBAAiB,IAAI,IAAI;IAKzB,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAOjF,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,mBAAmB;IASlB,MAAM,IAAI,cAAc;CA0BlC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,OAAO,CAAC;KACrB;CACF"}
package/index.d.ts CHANGED
@@ -21,4 +21,6 @@ export type { TextareaResize } from './textarea/vi-textarea.js';
21
21
  export { ViAccordion } from './accordion/vi-accordion.js';
22
22
  export type { AccordionVariant, AccordionSize } from './accordion/vi-accordion.js';
23
23
  export { ViAccordionItem } from './accordion/vi-accordion-item.js';
24
+ export { ViBadge } from './badge/vi-badge.js';
25
+ export type { BadgeVariant, BadgeSize } from './badge/vi-badge.js';
24
26
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { V as ViElement } from './vi-element-C6GfDPs3.js';
1
+ import { V as ViElement } from './vi-element-C6GfDPs3.js';
2
2
  export { ViButton } from './button/vi-button.js';
3
3
  export { ViInput } from './input/vi-input.js';
4
4
  export { ViIcon } from './icons/vi-icon.js';
@@ -10,3 +10,588 @@ export { ViTooltip } from './tooltip/vi-tooltip.js';
10
10
  export { ViTextarea } from './textarea/vi-textarea.js';
11
11
  export { ViAccordion } from './accordion/vi-accordion.js';
12
12
  export { ViAccordionItem } from './accordion/vi-accordion-item.js';
13
+ import { unsafeCSS, css, html } from 'lit';
14
+ import { customElement, property, state } from 'lit/decorators.js';
15
+
16
+ const badgeStyles = "@charset \"UTF-8\";@layer reset,components,utilities;@layer components{.badge{display:inline-flex;align-items:center;justify-content:center;white-space:nowrap;box-sizing:border-box;font-size:var(--vi-badge-font-size, 11px);font-weight:var(--vi-badge-font-weight, var(--vi-font-weight-semibold, 600));padding:var(--vi-badge-padding, 2px 8px);border-radius:var(--vi-badge-border-radius, 9999px);gap:var(--vi-badge-gap, 4px);border:var(--vi-border-width-thin, 1px) solid transparent}.dot{display:inline-block;width:var(--vi-badge-dot-size, 8px);height:var(--vi-badge-dot-size, 8px);border-radius:50%;background-color:currentColor;flex-shrink:0}.icon{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}}:host{display:inline-block;vertical-align:middle}:host([hidden]){display:none!important}:host([size=sm]){--vi-badge-font-size: 10px;--vi-badge-padding: 0 6px;--vi-badge-gap: 2px;--vi-badge-dot-size: 6px}:host([size=md]){--vi-badge-font-size: 11px;--vi-badge-padding: 2px 8px;--vi-badge-gap: 4px;--vi-badge-dot-size: 8px}:host([size=lg]){--vi-badge-font-size: 13px;--vi-badge-padding: 4px 12px;--vi-badge-gap: 6px;--vi-badge-dot-size: 10px}:host([pill]){--vi-badge-border-radius: 9999px}:host(:not([pill])){--vi-badge-border-radius: var(--vi-border-radius-sm, 2px)}.badge.dot-only{--vi-badge-padding: 4px}:host([variant=neutral]) .badge{background-color:var(--vi-badge-neutral-background, var(--vi-layer-03, #e5e7eb));color:var(--vi-badge-neutral-color, var(--vi-text-primary, #111827))}:host([variant=primary]) .badge{background-color:var(--vi-badge-primary-background, var(--vi-color-blue-100, var(--vi-color-blue-100, #ebf5ff)));color:var(--vi-badge-primary-color, var(--vi-color-primary, var(--vi-color-primary, #3676d0)))}:host([variant=success]) .badge{background-color:var(--vi-badge-success-background, var(--vi-color-green-100, var(--vi-color-green-100, #e6f0eb)));color:var(--vi-badge-success-color, var(--vi-color-success, var(--vi-color-success, #489167)))}:host([variant=warning]) .badge{background-color:var(--vi-badge-warning-background, var(--vi-color-yellow-100, var(--vi-color-yellow-100, #ffeab1)));color:var(--vi-badge-warning-color, var(--vi-color-warning, var(--vi-color-warning, #ffba00)))}:host([variant=danger]) .badge{background-color:var(--vi-badge-danger-background, var(--vi-color-red-100, var(--vi-color-red-100, #ffccce)));color:var(--vi-badge-danger-color, var(--vi-color-error, var(--vi-color-error, #ef4444)))}:host([variant=info]) .badge{background-color:var(--vi-badge-info-background, var(--vi-color-cyan-100, var(--vi-color-blue-100, #ebf5ff)));color:var(--vi-badge-info-color, var(--vi-color-info, var(--vi-color-info, #3676d0)))}:host([outline][variant=neutral]) .badge{background-color:transparent;color:var(--vi-badge-neutral-color, var(--vi-text-primary, #111827));border-color:var(--vi-badge-neutral-border, var(--vi-border-03, #e0e0e0))}:host([outline][variant=primary]) .badge{background-color:transparent;color:var(--vi-badge-primary-color, var(--vi-color-primary, var(--vi-color-primary, #3676d0)));border-color:var(--vi-badge-primary-border, var(--vi-color-blue-200, var(--vi-color-blue-200, #cee6ff)))}:host([outline][variant=success]) .badge{background-color:transparent;color:var(--vi-badge-success-color, var(--vi-color-success, var(--vi-color-success, #489167)));border-color:var(--vi-badge-success-border, var(--vi-color-green-200, var(--vi-color-green-200, #c0dbcd)))}:host([outline][variant=warning]) .badge{background-color:transparent;color:var(--vi-badge-warning-color, var(--vi-color-warning, var(--vi-color-warning, #ffba00)));border-color:var(--vi-badge-warning-border, var(--vi-color-yellow-200, var(--vi-color-yellow-200, #ffde85)))}:host([outline][variant=danger]) .badge{background-color:transparent;color:var(--vi-badge-danger-color, var(--vi-color-error, var(--vi-color-error, #ef4444)));border-color:var(--vi-badge-danger-border, var(--vi-color-red-200, var(--vi-color-red-200, #f69892)))}:host([outline][variant=info]) .badge{background-color:transparent;color:var(--vi-badge-info-color, var(--vi-color-info, var(--vi-color-info, #3676d0)));border-color:var(--vi-badge-info-border, var(--vi-color-cyan-200, var(--vi-color-blue-200, #cee6ff)))}.icon{display:inline-flex;flex-shrink:0}.icon[hidden]{display:none}::slotted(vi-icon),::slotted(svg){--vi-icon-size: 1em;width:1em;height:1em}";
17
+
18
+ function applyDecs2203RFactory() {
19
+ function createAddInitializerMethod(initializers, decoratorFinishedRef) {
20
+ return function addInitializer(initializer) {
21
+ assertNotFinished(decoratorFinishedRef, "addInitializer");
22
+ assertCallable(initializer, "An initializer");
23
+ initializers.push(initializer);
24
+ };
25
+ }
26
+ function memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value) {
27
+ var kindStr;
28
+ switch(kind){
29
+ case 1:
30
+ kindStr = "accessor";
31
+ break;
32
+ case 2:
33
+ kindStr = "method";
34
+ break;
35
+ case 3:
36
+ kindStr = "getter";
37
+ break;
38
+ case 4:
39
+ kindStr = "setter";
40
+ break;
41
+ default:
42
+ kindStr = "field";
43
+ }
44
+ var ctx = {
45
+ kind: kindStr,
46
+ name: isPrivate ? "#" + name : name,
47
+ static: isStatic,
48
+ private: isPrivate,
49
+ metadata: metadata
50
+ };
51
+ var decoratorFinishedRef = {
52
+ v: false
53
+ };
54
+ ctx.addInitializer = createAddInitializerMethod(initializers, decoratorFinishedRef);
55
+ var get, set;
56
+ if (kind === 0) {
57
+ if (isPrivate) {
58
+ get = desc.get;
59
+ set = desc.set;
60
+ } else {
61
+ get = function() {
62
+ return this[name];
63
+ };
64
+ set = function(v) {
65
+ this[name] = v;
66
+ };
67
+ }
68
+ } else if (kind === 2) {
69
+ get = function() {
70
+ return desc.value;
71
+ };
72
+ } else {
73
+ if (kind === 1 || kind === 3) {
74
+ get = function() {
75
+ return desc.get.call(this);
76
+ };
77
+ }
78
+ if (kind === 1 || kind === 4) {
79
+ set = function(v) {
80
+ desc.set.call(this, v);
81
+ };
82
+ }
83
+ }
84
+ ctx.access = get && set ? {
85
+ get: get,
86
+ set: set
87
+ } : get ? {
88
+ get: get
89
+ } : {
90
+ set: set
91
+ };
92
+ try {
93
+ return dec(value, ctx);
94
+ } finally{
95
+ decoratorFinishedRef.v = true;
96
+ }
97
+ }
98
+ function assertNotFinished(decoratorFinishedRef, fnName) {
99
+ if (decoratorFinishedRef.v) {
100
+ throw new Error("attempted to call " + fnName + " after decoration was finished");
101
+ }
102
+ }
103
+ function assertCallable(fn, hint) {
104
+ if (typeof fn !== "function") {
105
+ throw new TypeError(hint + " must be a function");
106
+ }
107
+ }
108
+ function assertValidReturnValue(kind, value) {
109
+ var type = typeof value;
110
+ if (kind === 1) {
111
+ if (type !== "object" || value === null) {
112
+ throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
113
+ }
114
+ if (value.get !== undefined) {
115
+ assertCallable(value.get, "accessor.get");
116
+ }
117
+ if (value.set !== undefined) {
118
+ assertCallable(value.set, "accessor.set");
119
+ }
120
+ if (value.init !== undefined) {
121
+ assertCallable(value.init, "accessor.init");
122
+ }
123
+ } else if (type !== "function") {
124
+ var hint;
125
+ if (kind === 0) {
126
+ hint = "field";
127
+ } else if (kind === 10) {
128
+ hint = "class";
129
+ } else {
130
+ hint = "method";
131
+ }
132
+ throw new TypeError(hint + " decorators must return a function or void 0");
133
+ }
134
+ }
135
+ function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata) {
136
+ var decs = decInfo[0];
137
+ var desc, init, value;
138
+ if (isPrivate) {
139
+ if (kind === 0 || kind === 1) {
140
+ desc = {
141
+ get: decInfo[3],
142
+ set: decInfo[4]
143
+ };
144
+ } else if (kind === 3) {
145
+ desc = {
146
+ get: decInfo[3]
147
+ };
148
+ } else if (kind === 4) {
149
+ desc = {
150
+ set: decInfo[3]
151
+ };
152
+ } else {
153
+ desc = {
154
+ value: decInfo[3]
155
+ };
156
+ }
157
+ } else if (kind !== 0) {
158
+ desc = Object.getOwnPropertyDescriptor(base, name);
159
+ }
160
+ if (kind === 1) {
161
+ value = {
162
+ get: desc.get,
163
+ set: desc.set
164
+ };
165
+ } else if (kind === 2) {
166
+ value = desc.value;
167
+ } else if (kind === 3) {
168
+ value = desc.get;
169
+ } else if (kind === 4) {
170
+ value = desc.set;
171
+ }
172
+ var newValue, get, set;
173
+ if (typeof decs === "function") {
174
+ newValue = memberDec(decs, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
175
+ if (newValue !== void 0) {
176
+ assertValidReturnValue(kind, newValue);
177
+ if (kind === 0) {
178
+ init = newValue;
179
+ } else if (kind === 1) {
180
+ init = newValue.init;
181
+ get = newValue.get || value.get;
182
+ set = newValue.set || value.set;
183
+ value = {
184
+ get: get,
185
+ set: set
186
+ };
187
+ } else {
188
+ value = newValue;
189
+ }
190
+ }
191
+ } else {
192
+ for(var i = decs.length - 1; i >= 0; i--){
193
+ var dec = decs[i];
194
+ newValue = memberDec(dec, name, desc, initializers, kind, isStatic, isPrivate, metadata, value);
195
+ if (newValue !== void 0) {
196
+ assertValidReturnValue(kind, newValue);
197
+ var newInit;
198
+ if (kind === 0) {
199
+ newInit = newValue;
200
+ } else if (kind === 1) {
201
+ newInit = newValue.init;
202
+ get = newValue.get || value.get;
203
+ set = newValue.set || value.set;
204
+ value = {
205
+ get: get,
206
+ set: set
207
+ };
208
+ } else {
209
+ value = newValue;
210
+ }
211
+ if (newInit !== void 0) {
212
+ if (init === void 0) {
213
+ init = newInit;
214
+ } else if (typeof init === "function") {
215
+ init = [
216
+ init,
217
+ newInit
218
+ ];
219
+ } else {
220
+ init.push(newInit);
221
+ }
222
+ }
223
+ }
224
+ }
225
+ }
226
+ if (kind === 0 || kind === 1) {
227
+ if (init === void 0) {
228
+ init = function(instance, init) {
229
+ return init;
230
+ };
231
+ } else if (typeof init !== "function") {
232
+ var ownInitializers = init;
233
+ init = function(instance, init) {
234
+ var value = init;
235
+ for(var i = 0; i < ownInitializers.length; i++){
236
+ value = ownInitializers[i].call(instance, value);
237
+ }
238
+ return value;
239
+ };
240
+ } else {
241
+ var originalInitializer = init;
242
+ init = function(instance, init) {
243
+ return originalInitializer.call(instance, init);
244
+ };
245
+ }
246
+ ret.push(init);
247
+ }
248
+ if (kind !== 0) {
249
+ if (kind === 1) {
250
+ desc.get = value.get;
251
+ desc.set = value.set;
252
+ } else if (kind === 2) {
253
+ desc.value = value;
254
+ } else if (kind === 3) {
255
+ desc.get = value;
256
+ } else if (kind === 4) {
257
+ desc.set = value;
258
+ }
259
+ if (isPrivate) {
260
+ if (kind === 1) {
261
+ ret.push(function(instance, args) {
262
+ return value.get.call(instance, args);
263
+ });
264
+ ret.push(function(instance, args) {
265
+ return value.set.call(instance, args);
266
+ });
267
+ } else if (kind === 2) {
268
+ ret.push(value);
269
+ } else {
270
+ ret.push(function(instance, args) {
271
+ return value.call(instance, args);
272
+ });
273
+ }
274
+ } else {
275
+ Object.defineProperty(base, name, desc);
276
+ }
277
+ }
278
+ }
279
+ function applyMemberDecs(Class, decInfos, metadata) {
280
+ var ret = [];
281
+ var protoInitializers;
282
+ var staticInitializers;
283
+ var existingProtoNonFields = new Map();
284
+ var existingStaticNonFields = new Map();
285
+ for(var i = 0; i < decInfos.length; i++){
286
+ var decInfo = decInfos[i];
287
+ if (!Array.isArray(decInfo)) continue;
288
+ var kind = decInfo[1];
289
+ var name = decInfo[2];
290
+ var isPrivate = decInfo.length > 3;
291
+ var isStatic = kind >= 5;
292
+ var base;
293
+ var initializers;
294
+ if (isStatic) {
295
+ base = Class;
296
+ kind = kind - 5;
297
+ staticInitializers = staticInitializers || [];
298
+ initializers = staticInitializers;
299
+ } else {
300
+ base = Class.prototype;
301
+ protoInitializers = protoInitializers || [];
302
+ initializers = protoInitializers;
303
+ }
304
+ if (kind !== 0 && !isPrivate) {
305
+ var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
306
+ var existingKind = existingNonFields.get(name) || 0;
307
+ if (existingKind === true || existingKind === 3 && kind !== 4 || existingKind === 4 && kind !== 3) {
308
+ throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + name);
309
+ } else if (!existingKind && kind > 2) {
310
+ existingNonFields.set(name, kind);
311
+ } else {
312
+ existingNonFields.set(name, true);
313
+ }
314
+ }
315
+ applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, initializers, metadata);
316
+ }
317
+ pushInitializers(ret, protoInitializers);
318
+ pushInitializers(ret, staticInitializers);
319
+ return ret;
320
+ }
321
+ function pushInitializers(ret, initializers) {
322
+ if (initializers) {
323
+ ret.push(function(instance) {
324
+ for(var i = 0; i < initializers.length; i++){
325
+ initializers[i].call(instance);
326
+ }
327
+ return instance;
328
+ });
329
+ }
330
+ }
331
+ function applyClassDecs(targetClass, classDecs, metadata) {
332
+ if (classDecs.length > 0) {
333
+ var initializers = [];
334
+ var newClass = targetClass;
335
+ var name = targetClass.name;
336
+ for(var i = classDecs.length - 1; i >= 0; i--){
337
+ var decoratorFinishedRef = {
338
+ v: false
339
+ };
340
+ try {
341
+ var nextNewClass = classDecs[i](newClass, {
342
+ kind: "class",
343
+ name: name,
344
+ addInitializer: createAddInitializerMethod(initializers, decoratorFinishedRef),
345
+ metadata
346
+ });
347
+ } finally{
348
+ decoratorFinishedRef.v = true;
349
+ }
350
+ if (nextNewClass !== undefined) {
351
+ assertValidReturnValue(10, nextNewClass);
352
+ newClass = nextNewClass;
353
+ }
354
+ }
355
+ return [
356
+ defineMetadata(newClass, metadata),
357
+ function() {
358
+ for(var i = 0; i < initializers.length; i++){
359
+ initializers[i].call(newClass);
360
+ }
361
+ }
362
+ ];
363
+ }
364
+ }
365
+ function defineMetadata(Class, metadata) {
366
+ return Object.defineProperty(Class, Symbol.metadata || Symbol.for("Symbol.metadata"), {
367
+ configurable: true,
368
+ enumerable: true,
369
+ value: metadata
370
+ });
371
+ }
372
+ return function applyDecs2203R(targetClass, memberDecs, classDecs, parentClass) {
373
+ if (parentClass !== void 0) {
374
+ var parentMetadata = parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
375
+ }
376
+ var metadata = Object.create(parentMetadata === void 0 ? null : parentMetadata);
377
+ var e = applyMemberDecs(targetClass, memberDecs, metadata);
378
+ if (!classDecs.length) defineMetadata(targetClass, metadata);
379
+ return {
380
+ e: e,
381
+ get c () {
382
+ return applyClassDecs(targetClass, classDecs, metadata);
383
+ }
384
+ };
385
+ };
386
+ }
387
+ function _apply_decs_2203_r(targetClass, memberDecs, classDecs, parentClass) {
388
+ return (_apply_decs_2203_r = applyDecs2203RFactory())(targetClass, memberDecs, classDecs, parentClass);
389
+ }
390
+ function _identity(x) {
391
+ return x;
392
+ }
393
+ var _dec, _initClass, _ViElement, _dec1, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, /** Colour semantic */ _init_variant, /** Size */ _init_size, /** Show coloured dot */ _init_dot, /** Fully rounded (pill shape) vs. square */ _init_pill, /** Numeric count to display */ _init_count, /** Max count before showing {max}+ */ _init_max, /** Outlined/ghost style */ _init_outline, _init__hasIcon, _init__hasDefaultSlot, _initProto;
394
+ let _ViBadge;
395
+ _dec = customElement('vi-badge'), _dec1 = property({
396
+ type: String,
397
+ reflect: true
398
+ }), _dec2 = property({
399
+ type: String,
400
+ reflect: true
401
+ }), _dec3 = property({
402
+ type: Boolean,
403
+ reflect: true
404
+ }), _dec4 = property({
405
+ type: Boolean,
406
+ reflect: true
407
+ }), _dec5 = property({
408
+ type: Number
409
+ }), _dec6 = property({
410
+ type: Number
411
+ }), _dec7 = property({
412
+ type: Boolean,
413
+ reflect: true
414
+ }), _dec8 = state(), _dec9 = state();
415
+ new class extends _identity {
416
+ constructor(){
417
+ super(_ViBadge), _initClass();
418
+ }
419
+ static{
420
+ class ViBadge extends (_ViElement = ViElement) {
421
+ static{
422
+ ({ e: [_init_variant, _init_size, _init_dot, _init_pill, _init_count, _init_max, _init_outline, _init__hasIcon, _init__hasDefaultSlot, _initProto], c: [_ViBadge, _initClass] } = _apply_decs_2203_r(this, [
423
+ [
424
+ _dec1,
425
+ 1,
426
+ "variant"
427
+ ],
428
+ [
429
+ _dec2,
430
+ 1,
431
+ "size"
432
+ ],
433
+ [
434
+ _dec3,
435
+ 1,
436
+ "dot"
437
+ ],
438
+ [
439
+ _dec4,
440
+ 1,
441
+ "pill"
442
+ ],
443
+ [
444
+ _dec5,
445
+ 1,
446
+ "count"
447
+ ],
448
+ [
449
+ _dec6,
450
+ 1,
451
+ "max"
452
+ ],
453
+ [
454
+ _dec7,
455
+ 1,
456
+ "outline"
457
+ ],
458
+ [
459
+ _dec8,
460
+ 1,
461
+ "_hasIcon"
462
+ ],
463
+ [
464
+ _dec9,
465
+ 1,
466
+ "_hasDefaultSlot"
467
+ ]
468
+ ], [
469
+ _dec
470
+ ], _ViElement));
471
+ }
472
+ static styles = css`${unsafeCSS(badgeStyles)}`;
473
+ #___private_variant_1 = (_initProto(this), _init_variant(this, 'neutral'));
474
+ get variant() {
475
+ return this.#___private_variant_1;
476
+ }
477
+ set variant(_v) {
478
+ this.#___private_variant_1 = _v;
479
+ }
480
+ #___private_size_2 = _init_size(this, 'md');
481
+ get size() {
482
+ return this.#___private_size_2;
483
+ }
484
+ set size(_v) {
485
+ this.#___private_size_2 = _v;
486
+ }
487
+ #___private_dot_3 = _init_dot(this, false);
488
+ get dot() {
489
+ return this.#___private_dot_3;
490
+ }
491
+ set dot(_v) {
492
+ this.#___private_dot_3 = _v;
493
+ }
494
+ #___private_pill_4 = _init_pill(this, true);
495
+ get pill() {
496
+ return this.#___private_pill_4;
497
+ }
498
+ set pill(_v) {
499
+ this.#___private_pill_4 = _v;
500
+ }
501
+ #___private_count_5 = _init_count(this, undefined);
502
+ get count() {
503
+ return this.#___private_count_5;
504
+ }
505
+ set count(_v) {
506
+ this.#___private_count_5 = _v;
507
+ }
508
+ #___private_max_6 = _init_max(this, 99);
509
+ get max() {
510
+ return this.#___private_max_6;
511
+ }
512
+ set max(_v) {
513
+ this.#___private_max_6 = _v;
514
+ }
515
+ #___private_outline_7 = _init_outline(this, false);
516
+ get outline() {
517
+ return this.#___private_outline_7;
518
+ }
519
+ set outline(_v) {
520
+ this.#___private_outline_7 = _v;
521
+ }
522
+ #___private__hasIcon_8 = _init__hasIcon(this, false);
523
+ get _hasIcon() {
524
+ return this.#___private__hasIcon_8;
525
+ }
526
+ set _hasIcon(_v) {
527
+ this.#___private__hasIcon_8 = _v;
528
+ }
529
+ #___private__hasDefaultSlot_9 = _init__hasDefaultSlot(this, false);
530
+ get _hasDefaultSlot() {
531
+ return this.#___private__hasDefaultSlot_9;
532
+ }
533
+ set _hasDefaultSlot(_v) {
534
+ this.#___private__hasDefaultSlot_9 = _v;
535
+ }
536
+ connectedCallback() {
537
+ super.connectedCallback();
538
+ this.updateAriaHidden();
539
+ }
540
+ updated(changedProperties) {
541
+ super.updated(changedProperties);
542
+ if (changedProperties.has('dot') || changedProperties.has('count') || changedProperties.has('_hasDefaultSlot')) {
543
+ this.updateAriaHidden();
544
+ }
545
+ }
546
+ updateAriaHidden() {
547
+ const isPurelyDecorative = this.dot && !this._hasDefaultSlot && this.count === undefined && !this.hasAttribute('aria-label') && !this.hasAttribute('aria-labelledby');
548
+ if (isPurelyDecorative) {
549
+ this.setAttribute('aria-hidden', 'true');
550
+ } else {
551
+ this.removeAttribute('aria-hidden');
552
+ }
553
+ }
554
+ onIconSlotChange(e) {
555
+ const slot = e.target;
556
+ this._hasIcon = slot.assignedElements({
557
+ flatten: true
558
+ }).length > 0;
559
+ }
560
+ onDefaultSlotChange(e) {
561
+ const slot = e.target;
562
+ this._hasDefaultSlot = slot.assignedNodes({
563
+ flatten: true
564
+ }).some((node)=>{
565
+ // Check if it's text with actual content or an element
566
+ return node.nodeType === Node.TEXT_NODE && node.textContent?.trim().length || node.nodeType === Node.ELEMENT_NODE;
567
+ });
568
+ this.updateAriaHidden();
569
+ }
570
+ render() {
571
+ let countContent = '';
572
+ // If count is defined, render it, and we do not render the default slot content
573
+ const hideDefaultSlot = this.count !== undefined;
574
+ if (this.count !== undefined) {
575
+ countContent = html`${this.count > this.max ? `${this.max}+` : `${this.count}`}`;
576
+ }
577
+ const dotContent = this.dot ? html`<span part="dot" class="dot"></span>` : '';
578
+ return html`
579
+ <span class="badge ${this.dot && !this._hasDefaultSlot && this.count === undefined ? 'dot-only' : ''}" part="badge">
580
+ <slot
581
+ name="icon"
582
+ part="icon"
583
+ class="icon"
584
+ ?hidden=${!this._hasIcon}
585
+ @slotchange=${this.onIconSlotChange}
586
+ ></slot>
587
+ ${dotContent}
588
+ ${countContent}
589
+ <slot ?hidden=${hideDefaultSlot} @slotchange=${this.onDefaultSlotChange}></slot>
590
+ </span>
591
+ `;
592
+ }
593
+ }
594
+ }
595
+ }();
596
+
597
+ export { _ViBadge as ViBadge, ViElement };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vialiq/web-components",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -88,6 +88,14 @@
88
88
  "types": "./accordion/vi-accordion.d.ts",
89
89
  "default": "./accordion/vi-accordion.js"
90
90
  },
91
+ "./badge": {
92
+ "types": "./badge/index.d.ts",
93
+ "default": "./badge/index.js"
94
+ },
95
+ "./badge/vi-badge": {
96
+ "types": "./badge/vi-badge.d.ts",
97
+ "default": "./badge/vi-badge.js"
98
+ },
91
99
  "./accordion/vi-accordion-item": {
92
100
  "types": "./accordion/vi-accordion-item.d.ts",
93
101
  "default": "./accordion/vi-accordion-item.js"
@@ -95,7 +103,7 @@
95
103
  },
96
104
  "peerDependencies": {
97
105
  "@floating-ui/dom": ">=1.0.0",
98
- "@vialiq/flux-ui": "^0.6.0",
106
+ "@vialiq/flux-ui": "^0.6.1",
99
107
  "@vialiq/icons": ">=0.0.3 <0.1.0",
100
108
  "lit": "^3.0.0"
101
109
  },
@@ -117,6 +125,7 @@
117
125
  "radio/",
118
126
  "checkbox/",
119
127
  "tooltip/",
128
+ "badge/",
120
129
  "README.md"
121
130
  ]
122
131
  }