@brightspot/ui 1.0.1-wc.4 → 1.2.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.
- package/README.md +7 -90
- package/dist/LucideDynamicLoader.d.ts +1 -0
- package/dist/LucideDynamicLoader.d.ts.map +1 -1
- package/dist/LucideDynamicLoader.js +2 -0
- package/dist/LucideDynamicLoader.js.map +1 -1
- package/dist/LucideDynamicLoader.ts +3 -0
- package/dist/components/avatar/Avatar.d.ts +82 -0
- package/dist/components/avatar/Avatar.d.ts.map +1 -0
- package/dist/components/avatar/Avatar.js +162 -0
- package/dist/components/avatar/Avatar.js.map +1 -0
- package/dist/components/avatar/AvatarGroup.d.ts +70 -0
- package/dist/components/avatar/AvatarGroup.d.ts.map +1 -0
- package/dist/components/avatar/AvatarGroup.js +145 -0
- package/dist/components/avatar/AvatarGroup.js.map +1 -0
- package/dist/components/badge/Badge.d.ts +75 -0
- package/dist/components/badge/Badge.d.ts.map +1 -0
- package/dist/components/badge/Badge.js +118 -0
- package/dist/components/badge/Badge.js.map +1 -0
- package/dist/components/circular-progress/CircularProgress.d.ts +57 -0
- package/dist/components/circular-progress/CircularProgress.d.ts.map +1 -0
- package/dist/components/circular-progress/CircularProgress.js +173 -0
- package/dist/components/circular-progress/CircularProgress.js.map +1 -0
- package/dist/components/icon/Icon.d.ts +90 -0
- package/dist/components/icon/Icon.d.ts.map +1 -0
- package/dist/components/icon/Icon.js +172 -0
- package/dist/components/icon/Icon.js.map +1 -0
- package/dist/components/linear-progress/LinearProgress.d.ts +40 -0
- package/dist/components/linear-progress/LinearProgress.d.ts.map +1 -0
- package/dist/components/linear-progress/LinearProgress.js +95 -0
- package/dist/components/linear-progress/LinearProgress.js.map +1 -0
- package/dist/custom-elements.json +772 -0
- package/dist/global.d.ts +4 -0
- package/dist/storybook/assets/Avatar.stories-BlxrclP0.js +209 -0
- package/dist/storybook/assets/AvatarGroup.stories-E3VUvBae.js +211 -0
- package/dist/storybook/assets/Badge.stories-f4YvPz0W.js +121 -0
- package/dist/storybook/assets/Button.stories-N66xrq4q.js +63 -0
- package/dist/storybook/assets/CircularProgress.stories-zWyELtfc.js +451 -0
- package/dist/storybook/assets/{Color-64QXVMR3-BV_8WWIP.js → Color-64QXVMR3-B3Y5c9dl.js} +1 -1
- package/dist/storybook/assets/{Colors.stories-CcpJ2Txp.js → Colors.stories-nEoNeHhf.js} +1 -1
- package/dist/storybook/assets/Events.stories-BP3ensxX.js +108 -0
- package/dist/storybook/assets/Heading.stories-DGqWaBpi.js +3 -0
- package/dist/storybook/assets/Icon.stories-BWWjh4NZ.js +245 -0
- package/dist/storybook/assets/LinearProgress.stories-DMVolkoE.js +397 -0
- package/dist/storybook/assets/ReadyMixin.stories-DavcxbQ0.js +55 -0
- package/dist/storybook/assets/ScrollShadow.stories-BmwSRNje.js +17 -0
- package/dist/storybook/assets/Throttle.stories-DBj-9rhV.js +303 -0
- package/dist/storybook/assets/{WithTooltip-SK46ZJ2J-DyavE1Bj.js → WithTooltip-SK46ZJ2J-DW4NXFWt.js} +5 -5
- package/dist/storybook/assets/formatter-OMEEQ6HG-BBn014aZ.js +1 -0
- package/dist/storybook/assets/iframe-CxsKJSj-.css +1 -0
- package/dist/storybook/assets/{iframe-mIh0R_Av.js → iframe-Z4F0Cgki.js} +87 -100
- package/dist/storybook/assets/{index-C8IjQgz6.js → index-BUj5S-B7.js} +1 -1
- package/dist/storybook/assets/{syntaxhighlighter-CAVLW7PM-36bUIV4n.js → syntaxhighlighter-CAVLW7PM-CsQveU1N.js} +1 -1
- package/dist/storybook/iframe.html +2 -2
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/tailwind-plugin-avatar.d.ts +2 -0
- package/dist/tailwind-plugin-avatar.d.ts.map +1 -0
- package/dist/tailwind-plugin-avatar.js +130 -0
- package/dist/tailwind-plugin-avatar.js.map +1 -0
- package/dist/tailwind-plugin-avatar.ts +181 -0
- package/dist/tailwind-plugin-badge.js +24 -9
- package/dist/tailwind-plugin-badge.js.map +1 -1
- package/dist/tailwind-plugin-badge.ts +30 -11
- package/dist/tailwind-plugin-button.js +14 -15
- package/dist/tailwind-plugin-button.js.map +1 -1
- package/dist/tailwind-plugin-button.ts +14 -17
- package/dist/tailwind-plugin-contrast.d.ts +2 -0
- package/dist/tailwind-plugin-contrast.d.ts.map +1 -0
- package/dist/tailwind-plugin-contrast.js +17 -0
- package/dist/tailwind-plugin-contrast.js.map +1 -0
- package/dist/tailwind-plugin-contrast.ts +18 -0
- package/dist/tailwind-plugin-icon.js +17 -10
- package/dist/tailwind-plugin-icon.js.map +1 -1
- package/dist/tailwind-plugin-icon.ts +17 -10
- package/dist/tailwind-plugin-ring-contrast.d.ts +2 -0
- package/dist/tailwind-plugin-ring-contrast.d.ts.map +1 -0
- package/dist/tailwind-plugin-ring-contrast.js +76 -0
- package/dist/tailwind-plugin-ring-contrast.js.map +1 -0
- package/dist/tailwind-plugin-ring-contrast.ts +90 -0
- package/dist/tailwind.config.d.ts +21 -0
- package/dist/tailwind.config.d.ts.map +1 -1
- package/dist/tailwind.config.js +27 -2
- package/dist/tailwind.config.js.map +1 -1
- package/dist/tailwind.config.ts +27 -2
- package/dist/{utils → util}/EventEmitterMixin.d.ts +23 -17
- package/dist/util/EventEmitterMixin.d.ts.map +1 -0
- package/dist/{utils → util}/EventEmitterMixin.js +7 -7
- package/dist/util/EventEmitterMixin.js.map +1 -0
- package/dist/util/ProgressMixin.d.ts +52 -0
- package/dist/util/ProgressMixin.d.ts.map +1 -0
- package/dist/util/ProgressMixin.js +190 -0
- package/dist/util/ProgressMixin.js.map +1 -0
- package/dist/util/ReadyMixin.d.ts +31 -0
- package/dist/util/ReadyMixin.d.ts.map +1 -0
- package/dist/util/ReadyMixin.js +42 -0
- package/dist/util/ReadyMixin.js.map +1 -0
- package/dist/util/aria.d.ts +3 -0
- package/dist/util/aria.d.ts.map +1 -0
- package/dist/util/aria.js +44 -0
- package/dist/util/aria.js.map +1 -0
- package/dist/util/svg.d.ts +9 -0
- package/dist/util/svg.d.ts.map +1 -1
- package/dist/util/svg.js +22 -0
- package/dist/util/svg.js.map +1 -1
- package/dist/util/throttle.d.ts +4 -0
- package/dist/util/throttle.d.ts.map +1 -0
- package/dist/util/throttle.js +30 -0
- package/dist/util/throttle.js.map +1 -0
- package/package.json +7 -6
- package/custom-elements.json +0 -214
- package/dist/components/widget/Widget.css +0 -118
- package/dist/components/widget/Widget.d.ts +0 -90
- package/dist/components/widget/Widget.d.ts.map +0 -1
- package/dist/components/widget/Widget.js +0 -196
- package/dist/components/widget/Widget.js.map +0 -1
- package/dist/components/widget/WidgetUtils.d.ts +0 -14
- package/dist/components/widget/WidgetUtils.d.ts.map +0 -1
- package/dist/components/widget/WidgetUtils.js +0 -42
- package/dist/components/widget/WidgetUtils.js.map +0 -1
- package/dist/storybook/assets/Badge.stories-cKvztBhm.js +0 -43
- package/dist/storybook/assets/Button.stories-BH3fEuOH.js +0 -63
- package/dist/storybook/assets/Heading.stories-cqZamo-6.js +0 -3
- package/dist/storybook/assets/Icon.stories-uPhO3RBG.js +0 -28543
- package/dist/storybook/assets/Loader.stories-D7Bl-LN9.js +0 -3
- package/dist/storybook/assets/ScrollShadow.stories-CWKYDYLk.js +0 -17
- package/dist/storybook/assets/Widget-CRTwFkFc.css +0 -1
- package/dist/storybook/assets/Widget.stories-CcjywoYR.js +0 -300
- package/dist/storybook/assets/formatter-OMEEQ6HG-DBJ97XaR.js +0 -1
- package/dist/storybook/assets/iframe-BdHEYpHD.css +0 -1
- package/dist/utils/EventEmitterMixin.d.ts.map +0 -1
- package/dist/utils/EventEmitterMixin.js.map +0 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, html } from 'lit';
|
|
8
|
+
import { property } from 'lit/decorators.js';
|
|
9
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
10
|
+
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
|
|
11
|
+
import * as LucideExports from 'lucide-static/dist/cjs/lucide-static';
|
|
12
|
+
import { getIcon } from '../../LucideDynamicLoader.js';
|
|
13
|
+
import { EventEmitterMixin } from '../../util/EventEmitterMixin.js';
|
|
14
|
+
import { ReadyMixin } from '../../util/ReadyMixin.js';
|
|
15
|
+
import { pascalToKebab } from '../../util/string.js';
|
|
16
|
+
import { addMask } from '../../util/svg.js';
|
|
17
|
+
const svgs = {};
|
|
18
|
+
for (const [key, value] of Object.entries(LucideExports)) {
|
|
19
|
+
if (typeof value === 'string') {
|
|
20
|
+
svgs[key] = value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* An icon component for displaying Lucide icons.
|
|
25
|
+
*
|
|
26
|
+
* Icons inherit parent text color by default or can use gradient fills.
|
|
27
|
+
* All icons are from the Lucide icon library (https://lucide.dev/icons/).
|
|
28
|
+
* Supports both direct SVG rendering and mask-based gradient fills.
|
|
29
|
+
*
|
|
30
|
+
* @element btu-icon
|
|
31
|
+
*
|
|
32
|
+
* @fires {CustomEvent} btu-icon-ready - Fired after first render and initialization
|
|
33
|
+
*
|
|
34
|
+
* @cssprop --Icon-size - Icon size (overrides size default)
|
|
35
|
+
* @cssprop --Icon-fill - Icon fill color for filled icons (e.g., "currentColor")
|
|
36
|
+
* @cssprop --Icon-svg - SVG data URI for mask-based rendering
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```html
|
|
40
|
+
* <!-- Icon inheriting parent text color -->
|
|
41
|
+
* <btu-icon symbol="heart" size="md"></btu-icon>
|
|
42
|
+
*
|
|
43
|
+
* <!-- Gradient icon -->
|
|
44
|
+
* <btu-icon symbol="star" size="lg" gradient="primary"></btu-icon>
|
|
45
|
+
*
|
|
46
|
+
* <!-- Custom size via CSS -->
|
|
47
|
+
* <btu-icon symbol="check" style="--Icon-size: 3rem"></btu-icon>
|
|
48
|
+
*
|
|
49
|
+
* <!-- Filled icon via CSS (advanced usage) -->
|
|
50
|
+
* <btu-icon symbol="heart" style="--Icon-fill: currentColor"></btu-icon>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* // Programmatic usage
|
|
56
|
+
* const icon = document.createElement('btu-icon')
|
|
57
|
+
* icon.symbol = 'smile'
|
|
58
|
+
* icon.size = 'lg'
|
|
59
|
+
* icon.addEventListener('btu-icon-ready', () => console.log('Icon loaded'))
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export default class Icon extends EventEmitterMixin(ReadyMixin(LitElement)) {
|
|
63
|
+
constructor() {
|
|
64
|
+
super(...arguments);
|
|
65
|
+
/**
|
|
66
|
+
* Size of the icon.
|
|
67
|
+
* - 'xs': Extra small (0.75rem)
|
|
68
|
+
* - 'sm': Small (1rem)
|
|
69
|
+
* - 'md': Medium (1.25rem, default)
|
|
70
|
+
* - 'lg': Large (1.5rem)
|
|
71
|
+
* - 'xl': Extra large (1.75rem)
|
|
72
|
+
* @attr
|
|
73
|
+
*/
|
|
74
|
+
this.size = 'md';
|
|
75
|
+
/**
|
|
76
|
+
* Lucide icon name to display.
|
|
77
|
+
* See https://lucide.dev/icons/ for available icons.
|
|
78
|
+
* @attr
|
|
79
|
+
*/
|
|
80
|
+
this.symbol = 'circle-dashed';
|
|
81
|
+
/** @internal */
|
|
82
|
+
this.initialClasses = [];
|
|
83
|
+
}
|
|
84
|
+
static get tagName() {
|
|
85
|
+
return 'BTU-ICON';
|
|
86
|
+
}
|
|
87
|
+
connectedCallback() {
|
|
88
|
+
super.connectedCallback();
|
|
89
|
+
// Capture initial classes from backend HTML
|
|
90
|
+
if (this.className) {
|
|
91
|
+
this.initialClasses = this.className.split(' ').filter(c => c.trim());
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
createRenderRoot() {
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
willUpdate() {
|
|
98
|
+
const classes = [...this.initialClasses, 'btu-icon', `btu-icon-${this.size}`];
|
|
99
|
+
// Add gradient class if gradient is set
|
|
100
|
+
if (this.gradient) {
|
|
101
|
+
const iconName = window.BRIGHTSPOT?.icons?.materialToLucide?.[this.symbol] || this.symbol;
|
|
102
|
+
const kebabName = pascalToKebab(iconName);
|
|
103
|
+
classes.push(`btu-icon-gradient-${this.gradient}`);
|
|
104
|
+
classes.push(`btu-icon-via-mask-${kebabName}`);
|
|
105
|
+
}
|
|
106
|
+
this.className = classes.filter(Boolean).join(' ');
|
|
107
|
+
}
|
|
108
|
+
firstUpdated() {
|
|
109
|
+
this.emit('btu-icon-ready');
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Escape HTML special characters to prevent XSS attacks in comments.
|
|
113
|
+
* @internal
|
|
114
|
+
*/
|
|
115
|
+
escapeHtml(text) {
|
|
116
|
+
return text
|
|
117
|
+
.replace(/&/g, '&')
|
|
118
|
+
.replace(/</g, '<')
|
|
119
|
+
.replace(/>/g, '>')
|
|
120
|
+
.replace(/"/g, '"')
|
|
121
|
+
.replace(/'/g, ''');
|
|
122
|
+
}
|
|
123
|
+
render() {
|
|
124
|
+
const iconName = window.BRIGHTSPOT?.icons?.materialToLucide?.[this.symbol] || this.symbol;
|
|
125
|
+
const data = getIcon(iconName);
|
|
126
|
+
let svgContent = data?.iconSvg ?? '';
|
|
127
|
+
let isInvalid = false;
|
|
128
|
+
if (!svgContent) {
|
|
129
|
+
// Fallback to default icon and mark as invalid
|
|
130
|
+
isInvalid = true;
|
|
131
|
+
const fallbackData = getIcon('circle-dashed');
|
|
132
|
+
svgContent = fallbackData?.iconSvg ?? '';
|
|
133
|
+
// If fallback also fails, show comment
|
|
134
|
+
if (!svgContent) {
|
|
135
|
+
return html `${unsafeHTML(`<!-- btu-icon: Icon "${this.escapeHtml(this.symbol)}" not found and fallback failed -->`)}`;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const decodedSvg = decodeURIComponent(svgContent);
|
|
139
|
+
// Prevent HTML comment injection by escaping dashes
|
|
140
|
+
const debugComment = isInvalid
|
|
141
|
+
? `<!-- btu-icon: Icon "${this.escapeHtml(this.symbol)}" not found. Showing fallback "circle-dashed". See https://lucide.dev/icons/ for available icons. -->\n`
|
|
142
|
+
: '';
|
|
143
|
+
// For gradient fill, generate mask SVG and let Tailwind handle sizing/styling
|
|
144
|
+
if (this.gradient) {
|
|
145
|
+
const kebabName = pascalToKebab(iconName);
|
|
146
|
+
// Set mask URL for Tailwind plugin to reference
|
|
147
|
+
this.style.setProperty('--mask-url', `url(#${kebabName})`);
|
|
148
|
+
// Add mask element to SVG - Tailwind class handles display/sizing
|
|
149
|
+
const maskedSvg = addMask(decodedSvg, kebabName);
|
|
150
|
+
return html `${unsafeHTML(debugComment)}${unsafeSVG(maskedSvg)}`;
|
|
151
|
+
}
|
|
152
|
+
// Non-gradient path: render SVG with sizing
|
|
153
|
+
const fillAttr = this.style.getPropertyValue('--Icon-fill') ? `fill="var(--Icon-fill)"` : ''; // Optional fill
|
|
154
|
+
const styledSvg = decodedSvg.replace('<svg', `<svg ${fillAttr} style="width: var(--Icon-size); height: var(--Icon-size); display: inline-block;"`);
|
|
155
|
+
return html `${unsafeHTML(debugComment)}${unsafeSVG(styledSvg)}`;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
__decorate([
|
|
159
|
+
property({ type: String })
|
|
160
|
+
], Icon.prototype, "size", void 0);
|
|
161
|
+
__decorate([
|
|
162
|
+
property({ type: String })
|
|
163
|
+
], Icon.prototype, "symbol", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
property({ type: String })
|
|
166
|
+
], Icon.prototype, "gradient", void 0);
|
|
167
|
+
// Register custom element with guard to prevent double registration
|
|
168
|
+
// (common with yarn link, HMR, or webpack bundle duplication)
|
|
169
|
+
if (!customElements.get('btu-icon')) {
|
|
170
|
+
customElements.define('btu-icon', Icon);
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=Icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icon.js","sourceRoot":"","sources":["../../../src/components/icon/Icon.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,OAAO,KAAK,aAAa,MAAM,sCAAsC,CAAA;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAQ3C,MAAM,IAAI,GAA2B,EAAE,CAAA;AACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;IACzD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACnB,CAAC;AACH,CAAC;AAED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c,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACzC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare const LinearProgress_base: (new (...args: any[]) => import("../../util/ProgressMixin.js").ProgressMixinInterface) & (new (...args: any[]) => import("../../util/EventEmitterMixin.js").EventEmitterMixinInterface) & (new (...args: any[]) => import("../../util/ReadyMixin.js").ReadyMixinInterface) & typeof LitElement;
|
|
3
|
+
/**
|
|
4
|
+
* A horizontal linear progress bar for showing task completion.
|
|
5
|
+
*
|
|
6
|
+
* @element btu-linear-progress
|
|
7
|
+
*
|
|
8
|
+
* @fires {CustomEvent} btu-progress-ready - Fired after first render and initialization
|
|
9
|
+
* @fires {CustomEvent} btu-progress-complete - Fired when progress reaches 100
|
|
10
|
+
*
|
|
11
|
+
* @cssprop --progress-color - Custom progress bar color (overrides theme color)
|
|
12
|
+
* @cssprop --track-color - Track/background color (overrides default gray-100)
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```html
|
|
16
|
+
* <!-- Basic progress bar (fills container width) -->
|
|
17
|
+
* <btu-linear-progress progress="50" color="primary"></btu-linear-progress>
|
|
18
|
+
*
|
|
19
|
+
* <!-- Control width via CSS -->
|
|
20
|
+
* <btu-linear-progress progress="75" color="success" label="75%" style="width: 300px;"></btu-linear-progress>
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export default class LinearProgress extends LinearProgress_base {
|
|
24
|
+
/** @internal */
|
|
25
|
+
private _initialClasses;
|
|
26
|
+
connectedCallback(): void;
|
|
27
|
+
createRenderRoot(): this;
|
|
28
|
+
willUpdate(): void;
|
|
29
|
+
firstUpdated(changedProperties: Map<PropertyKey, unknown>): void;
|
|
30
|
+
disconnectedCallback(): void;
|
|
31
|
+
updated(changedProperties: Map<PropertyKey, unknown>): void;
|
|
32
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface HTMLElementTagNameMap {
|
|
36
|
+
'btu-linear-progress': LinearProgress;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=LinearProgress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinearProgress.d.ts","sourceRoot":"","sources":["../../../src/components/linear-progress/LinearProgress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAA;;AAKpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,mBAAwD;IAClG,gBAAgB;IAChB,OAAO,CAAC,eAAe,CAAe;IAEtC,iBAAiB,IAAI,IAAI;IAQzB,gBAAgB;IAIhB,UAAU,IAAI,IAAI;IAMlB,YAAY,CAAC,iBAAiB,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI;IAKhE,oBAAoB,IAAI,IAAI;IAK5B,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI;IAO3D,MAAM;CAiCP;AAOD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,qBAAqB,EAAE,cAAc,CAAA;KACtC;CACF"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { LitElement, css, html, nothing } from 'lit';
|
|
2
|
+
import { EventEmitterMixin } from '../../util/EventEmitterMixin.js';
|
|
3
|
+
import { ProgressMixin } from '../../util/ProgressMixin.js';
|
|
4
|
+
import { ReadyMixin } from '../../util/ReadyMixin.js';
|
|
5
|
+
/**
|
|
6
|
+
* A horizontal linear progress bar for showing task completion.
|
|
7
|
+
*
|
|
8
|
+
* @element btu-linear-progress
|
|
9
|
+
*
|
|
10
|
+
* @fires {CustomEvent} btu-progress-ready - Fired after first render and initialization
|
|
11
|
+
* @fires {CustomEvent} btu-progress-complete - Fired when progress reaches 100
|
|
12
|
+
*
|
|
13
|
+
* @cssprop --progress-color - Custom progress bar color (overrides theme color)
|
|
14
|
+
* @cssprop --track-color - Track/background color (overrides default gray-100)
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```html
|
|
18
|
+
* <!-- Basic progress bar (fills container width) -->
|
|
19
|
+
* <btu-linear-progress progress="50" color="primary"></btu-linear-progress>
|
|
20
|
+
*
|
|
21
|
+
* <!-- Control width via CSS -->
|
|
22
|
+
* <btu-linear-progress progress="75" color="success" label="75%" style="width: 300px;"></btu-linear-progress>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export default class LinearProgress extends ProgressMixin(EventEmitterMixin(ReadyMixin(LitElement))) {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
/** @internal */
|
|
29
|
+
this._initialClasses = [];
|
|
30
|
+
}
|
|
31
|
+
connectedCallback() {
|
|
32
|
+
super.connectedCallback();
|
|
33
|
+
// Capture initial classes from backend HTML
|
|
34
|
+
if (this.className) {
|
|
35
|
+
this._initialClasses = this.className.split(' ').filter(c => c.trim());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
createRenderRoot() {
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
willUpdate() {
|
|
42
|
+
const classes = [...this._initialClasses, 'inline-flex', 'items-center', 'w-full'];
|
|
43
|
+
this.className = classes.join(' ');
|
|
44
|
+
}
|
|
45
|
+
firstUpdated(changedProperties) {
|
|
46
|
+
super.firstUpdated(changedProperties);
|
|
47
|
+
this._setupInitialAnimation();
|
|
48
|
+
}
|
|
49
|
+
disconnectedCallback() {
|
|
50
|
+
super.disconnectedCallback();
|
|
51
|
+
this._cleanupInitialAnimation();
|
|
52
|
+
}
|
|
53
|
+
updated(changedProperties) {
|
|
54
|
+
super.updated(changedProperties);
|
|
55
|
+
// Track completion at 100%
|
|
56
|
+
this._trackCompletion();
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
const height = this.thickness ?? 8; // default thickness is 8
|
|
60
|
+
const color = this._getProgressColorValue();
|
|
61
|
+
const progressValue = this._getAnimatedProgress();
|
|
62
|
+
return html `
|
|
63
|
+
<div class="flex w-full items-center gap-3">
|
|
64
|
+
<span
|
|
65
|
+
class="block flex-1"
|
|
66
|
+
role="progressbar"
|
|
67
|
+
aria-label="${this.ariaLabel || nothing}"
|
|
68
|
+
aria-labelledby="${this.ariaLabelledBy || nothing}"
|
|
69
|
+
aria-valuenow="${progressValue}"
|
|
70
|
+
aria-valuemin="0"
|
|
71
|
+
aria-valuemax="100"
|
|
72
|
+
aria-valuetext="${this.ariaValueText || this.label || `${progressValue} percent`}"
|
|
73
|
+
>
|
|
74
|
+
<div
|
|
75
|
+
class="relative overflow-hidden rounded-full bg-[var(--track-color,_oklch(var(--btu-theme-gray-100)))]"
|
|
76
|
+
style="height: ${height}px;"
|
|
77
|
+
>
|
|
78
|
+
<div
|
|
79
|
+
class="h-full rounded-full [transition:_width_0.3s_ease]"
|
|
80
|
+
style="width: ${progressValue}%; background-color: ${color};"
|
|
81
|
+
></div>
|
|
82
|
+
</div>
|
|
83
|
+
</span>
|
|
84
|
+
${this.label
|
|
85
|
+
? html `<span class="flex-shrink-0 whitespace-nowrap text-sm font-medium text-gray-700">${this.label}</span>`
|
|
86
|
+
: ''}
|
|
87
|
+
</div>
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Register custom element with guard to prevent double registration
|
|
92
|
+
if (!customElements.get('btu-linear-progress')) {
|
|
93
|
+
customElements.define('btu-linear-progress', LinearProgress);
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=LinearProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinearProgress.js","sourceRoot":"","sources":["../../../src/components/linear-progress/LinearProgress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG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