@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
package/dist/tailwind.config.ts
CHANGED
|
@@ -11,11 +11,15 @@ export default {
|
|
|
11
11
|
],
|
|
12
12
|
content: [],
|
|
13
13
|
safelist: [
|
|
14
|
+
// Lucide icon mask classes
|
|
15
|
+
{
|
|
16
|
+
pattern: /btu-icon-via-mask-.+/,
|
|
17
|
+
},
|
|
14
18
|
// BTU component classes with dynamic color, size, and numbered variants
|
|
15
|
-
// Matches: btu-button-primary, btu-badge-lg, btu-icon-error, btu-heading-2xl, etc.
|
|
19
|
+
// Matches: btu-button-primary, btu-badge-lg, btu-icon-error, btu-heading-2xl, btu-avatar-md, etc.
|
|
16
20
|
{
|
|
17
21
|
pattern:
|
|
18
|
-
/btu-.*?-(ai|black|white|primary|teal|gray|purple|rose|error|warning|success|xs|sm|md|lg|xl|2xl|1|2|3|4|5|6)/,
|
|
22
|
+
/btu-.*?-(ai|black|white|primary|teal|gray|purple|rose|error|warning|success|xs|sm|md|lg|xl|xxl|2xl|1|2|3|4|5|6)/,
|
|
19
23
|
},
|
|
20
24
|
// Padding and margin classes for all directions and values 0-8 (including decimals)
|
|
21
25
|
// Matches: p-0, px-2, py-6, pt-4, pb-8, pl-1, pr-3, ps-5, pe-7, m-0, mx-2, p-1.5, mx-2.5, etc.
|
|
@@ -403,6 +407,8 @@ export default {
|
|
|
403
407
|
'sortable-added': `${theme('transitionDuration.1000')} forwards scale-up ease-in-out`,
|
|
404
408
|
'sortable-added-bg': `${theme('transitionDuration.1000')} forwards bg-color-change ease-in-out`,
|
|
405
409
|
'sortable-drag': `${theme('transitionDuration.250')} forwards scale-down`,
|
|
410
|
+
'circular-progress-rotate': 'circular-progress-rotate 1.6s linear infinite',
|
|
411
|
+
'circular-progress-dash': 'circular-progress-dash 1s infinite ease-in-out both',
|
|
406
412
|
}),
|
|
407
413
|
animationDuration: {
|
|
408
414
|
DEFAULT: '0.33s',
|
|
@@ -575,6 +581,25 @@ export default {
|
|
|
575
581
|
'slide-fade-scroll': {
|
|
576
582
|
from: { opacity: '0', transform: 'translateY(4dvh)' },
|
|
577
583
|
},
|
|
584
|
+
'circular-progress-rotate': {
|
|
585
|
+
'100%': {
|
|
586
|
+
transform: 'rotate(360deg)',
|
|
587
|
+
},
|
|
588
|
+
},
|
|
589
|
+
'circular-progress-dash': {
|
|
590
|
+
'0%': {
|
|
591
|
+
strokeDasharray: '1, 200',
|
|
592
|
+
strokeDashoffset: '0',
|
|
593
|
+
},
|
|
594
|
+
'50%': {
|
|
595
|
+
strokeDasharray: '89, 200',
|
|
596
|
+
strokeDashoffset: '-35',
|
|
597
|
+
},
|
|
598
|
+
'100%': {
|
|
599
|
+
strokeDasharray: '89, 200',
|
|
600
|
+
strokeDashoffset: '-124',
|
|
601
|
+
},
|
|
602
|
+
},
|
|
578
603
|
}),
|
|
579
604
|
spacing: {
|
|
580
605
|
xs: 'var(--gap-xs)',
|
|
@@ -5,22 +5,28 @@ type UnpackCustomEvent<T> = T extends CustomEvent<infer U> ? U : never;
|
|
|
5
5
|
* Map of custom events emitted by Brightspot UI components.
|
|
6
6
|
* All events use CustomEvent and bubble through the DOM with composed: true.
|
|
7
7
|
*/
|
|
8
|
-
interface CustomEventMap {
|
|
9
|
-
'btu-
|
|
10
|
-
'btu-
|
|
11
|
-
'btu-
|
|
8
|
+
export interface CustomEventMap {
|
|
9
|
+
'btu-element-connected': CustomEvent<unknown>;
|
|
10
|
+
'btu-element-disconnected': CustomEvent<unknown>;
|
|
11
|
+
'btu-element-error': CustomEvent<{
|
|
12
12
|
error: Error;
|
|
13
13
|
}>;
|
|
14
|
-
'btu-
|
|
15
|
-
'btu-
|
|
16
|
-
'btu-
|
|
17
|
-
'btu-
|
|
18
|
-
'btu-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'btu-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
'btu-badge-ready': CustomEvent<unknown>;
|
|
15
|
+
'btu-progress-ready': CustomEvent<unknown>;
|
|
16
|
+
'btu-progress-complete': CustomEvent<unknown>;
|
|
17
|
+
'btu-avatar-ready': CustomEvent<unknown>;
|
|
18
|
+
'btu-avatar-image-loaded': CustomEvent<{
|
|
19
|
+
src: string;
|
|
20
|
+
}>;
|
|
21
|
+
'btu-avatar-image-error': CustomEvent<{
|
|
22
|
+
src: string;
|
|
23
|
+
error: Event;
|
|
24
|
+
}>;
|
|
25
|
+
'btu-avatar-group-ready': CustomEvent<unknown>;
|
|
26
|
+
'btu-avatar-group-overflow': CustomEvent<{
|
|
27
|
+
hidden: number;
|
|
28
|
+
}>;
|
|
29
|
+
'btu-icon-ready': CustomEvent<unknown>;
|
|
24
30
|
}
|
|
25
31
|
interface CombinedEventMap extends HTMLElementEventMap, CustomEventMap {
|
|
26
32
|
}
|
|
@@ -42,9 +48,9 @@ export declare class EventEmitterMixinInterface {
|
|
|
42
48
|
*
|
|
43
49
|
* @mixin
|
|
44
50
|
*
|
|
45
|
-
* @fires {CustomEvent} btu-
|
|
46
|
-
* @fires {CustomEvent} btu-
|
|
47
|
-
* @fires {CustomEvent<{error: Error}>} btu-
|
|
51
|
+
* @fires {CustomEvent} btu-element-connected - Fired when element connects to DOM
|
|
52
|
+
* @fires {CustomEvent} btu-element-disconnected - Fired when element disconnects from DOM
|
|
53
|
+
* @fires {CustomEvent<{error: Error}>} btu-element-error - Fired on connection error
|
|
48
54
|
*
|
|
49
55
|
* @example
|
|
50
56
|
* ```typescript
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventEmitterMixin.d.ts","sourceRoot":"","sources":["../../src/util/EventEmitterMixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAEhC,KAAK,WAAW,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;AACxD,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AAEtE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,uBAAuB,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAC7C,0BAA0B,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAChD,mBAAmB,EAAE,WAAW,CAAC;QAAE,KAAK,EAAE,KAAK,CAAA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BAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,EAC9D,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GACvC,IAAI;CACR;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,WAAW,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC,KAqD/C,WAAW,CAAC,0BAA0B,CAAC,GAAG,CAC5E,CAAA"}
|
|
@@ -8,9 +8,9 @@ import { LitElement } from 'lit';
|
|
|
8
8
|
*
|
|
9
9
|
* @mixin
|
|
10
10
|
*
|
|
11
|
-
* @fires {CustomEvent} btu-
|
|
12
|
-
* @fires {CustomEvent} btu-
|
|
13
|
-
* @fires {CustomEvent<{error: Error}>} btu-
|
|
11
|
+
* @fires {CustomEvent} btu-element-connected - Fired when element connects to DOM
|
|
12
|
+
* @fires {CustomEvent} btu-element-disconnected - Fired when element disconnects from DOM
|
|
13
|
+
* @fires {CustomEvent<{error: Error}>} btu-element-error - Fired on connection error
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```typescript
|
|
@@ -27,21 +27,21 @@ export const EventEmitterMixin = (superClass) => {
|
|
|
27
27
|
class EventEmitterMixinClass extends superClass {
|
|
28
28
|
/**
|
|
29
29
|
* Lifecycle callback fired when element is connected to the DOM.
|
|
30
|
-
* Emits btu-
|
|
30
|
+
* Emits btu-element-connected or btu-element-error.
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
33
|
connectedCallback() {
|
|
34
34
|
super.connectedCallback();
|
|
35
|
-
Promise.resolve().then(() => this.emit('btu-
|
|
35
|
+
Promise.resolve().then(() => this.emit('btu-element-connected', {}), error => this.emit('btu-element-error', { error }));
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Lifecycle callback fired when element is disconnected from the DOM.
|
|
39
|
-
* Emits btu-
|
|
39
|
+
* Emits btu-element-disconnected.
|
|
40
40
|
* @internal
|
|
41
41
|
*/
|
|
42
42
|
disconnectedCallback() {
|
|
43
43
|
super.disconnectedCallback();
|
|
44
|
-
this.emit('btu-
|
|
44
|
+
this.emit('btu-element-disconnected');
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* Dispatches a type-safe CustomEvent with standardized configuration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventEmitterMixin.js","sourceRoot":"","sources":["../../src/util/EventEmitterMixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AA4ChC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAoC,UAAa,EAAE,EAAE;IACpF,MAAM,sBAAuB,SAAQ,UAAU;QAC7C;;;;WAIG;QACH,iBAAiB;YACf,KAAK,CAAC,iBAAiB,EAAE,CAAA;YACzB,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CACpB,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,CAAC,EAC5C,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,CAAC,CACnD,CAAA;QACH,CAAC;QAED;;;;WAIG;QACH,oBAAoB;YAClB,KAAK,CAAC,oBAAoB,EAAE,CAAA;YAC5B,IAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAA;QACvC,CAAC;QAED;;;;;;;;;;;;;;;;WAgBG;QACH,IAAI,CAAiC,IAAO,EAAE,MAA6C;YACzF,OAAO,IAAI,CAAC,aAAa,CACvB,IAAI,WAAW,CAAC,IAAI,EAAE;gBACpB,OAAO,EAAE,IAAI;gBACb,UAAU,EAAE,KAAK;gBACjB,QAAQ,EAAE,IAAI;gBACd,MAAM;aACP,CAAC,CACH,CAAA;QACH,CAAC;KACF;IACD,OAAO,sBAAqE,CAAA;AAC9E,CAAC,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { LitElement } from 'lit';
|
|
2
|
+
import type { ThemeColors } from '../tailwind-plugin-theme';
|
|
3
|
+
/**
|
|
4
|
+
* Progress indicator colors (excludes 'ai' gradient)
|
|
5
|
+
*/
|
|
6
|
+
export type ProgressColors = Exclude<ThemeColors, 'ai'>;
|
|
7
|
+
/**
|
|
8
|
+
* Interface for components using ProgressMixin.
|
|
9
|
+
* Provides common progress indicator properties and methods.
|
|
10
|
+
*/
|
|
11
|
+
export interface ProgressMixinInterface {
|
|
12
|
+
color: ProgressColors;
|
|
13
|
+
thickness?: number;
|
|
14
|
+
progress: number;
|
|
15
|
+
label?: string;
|
|
16
|
+
initialAnimation: boolean;
|
|
17
|
+
ariaLabel: string | null;
|
|
18
|
+
ariaLabelledBy: string | null;
|
|
19
|
+
ariaValueText: string | null;
|
|
20
|
+
completionAnnouncement?: string;
|
|
21
|
+
_getProgressColorValue(): string;
|
|
22
|
+
_getAnimatedProgress(): number;
|
|
23
|
+
_setupInitialAnimation(): void;
|
|
24
|
+
_cleanupInitialAnimation(): void;
|
|
25
|
+
_trackCompletion(): void;
|
|
26
|
+
}
|
|
27
|
+
type Constructor<T = {}> = new (...args: any[]) => T;
|
|
28
|
+
/**
|
|
29
|
+
* Mixin that adds common progress indicator properties.
|
|
30
|
+
* Used by progress components like CircularProgress and LinearProgress.
|
|
31
|
+
*
|
|
32
|
+
* @mixin
|
|
33
|
+
*
|
|
34
|
+
* @param Base - The base class to extend
|
|
35
|
+
* @returns Extended class with progress properties
|
|
36
|
+
*
|
|
37
|
+
* @fires {CustomEvent} btu-progress-ready - Fired after first render and initialization
|
|
38
|
+
* @fires {CustomEvent} btu-progress-complete - Fired when progress reaches 100
|
|
39
|
+
*
|
|
40
|
+
* @cssprop --progress-color - Progress indicator color (overrides theme color)
|
|
41
|
+
* @cssprop --track-color - Track/background color (overrides default gray-100)
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* class MyProgress extends ProgressMixin(LitElement) {
|
|
46
|
+
* // Component now has color, size, thickness, and progress properties
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare const ProgressMixin: <T extends Constructor<LitElement>>(Base: T) => Constructor<ProgressMixinInterface> & T;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=ProgressMixin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressMixin.d.ts","sourceRoot":"","sources":["../../src/util/ProgressMixin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAErC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAI3D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;AAEvD;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,cAAc,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gBAAgB,EAAE,OAAO,CAAA;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,sBAAsB,IAAI,MAAM,CAAA;IAChC,oBAAoB,IAAI,MAAM,CAAA;IAC9B,sBAAsB,IAAI,IAAI,CAAA;IAC9B,wBAAwB,IAAI,IAAI,CAAA;IAChC,gBAAgB,IAAI,IAAI,CAAA;CACzB;AAED,KAAK,WAAW,CAAC,CAAC,GAAG,EAAE,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,WAAW,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,KAkLzC,WAAW,CAAC,sBAAsB,CAAC,GAAG,CACpE,CAAA"}
|
|
@@ -0,0 +1,190 @@
|
|
|
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 { property } from 'lit/decorators.js';
|
|
8
|
+
import { announce } from '../util/aria';
|
|
9
|
+
/**
|
|
10
|
+
* Mixin that adds common progress indicator properties.
|
|
11
|
+
* Used by progress components like CircularProgress and LinearProgress.
|
|
12
|
+
*
|
|
13
|
+
* @mixin
|
|
14
|
+
*
|
|
15
|
+
* @param Base - The base class to extend
|
|
16
|
+
* @returns Extended class with progress properties
|
|
17
|
+
*
|
|
18
|
+
* @fires {CustomEvent} btu-progress-ready - Fired after first render and initialization
|
|
19
|
+
* @fires {CustomEvent} btu-progress-complete - Fired when progress reaches 100
|
|
20
|
+
*
|
|
21
|
+
* @cssprop --progress-color - Progress indicator color (overrides theme color)
|
|
22
|
+
* @cssprop --track-color - Track/background color (overrides default gray-100)
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* class MyProgress extends ProgressMixin(LitElement) {
|
|
27
|
+
* // Component now has color, size, thickness, and progress properties
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export const ProgressMixin = (Base) => {
|
|
32
|
+
class ProgressMixinClass extends Base {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments);
|
|
35
|
+
/**
|
|
36
|
+
* Color theme of the progress indicator.
|
|
37
|
+
* Supports: black, white, primary, teal, gray, purple, rose, error, warning, success
|
|
38
|
+
* @attr
|
|
39
|
+
*/
|
|
40
|
+
this.color = 'primary';
|
|
41
|
+
/**
|
|
42
|
+
* Progress value for determinate variant.
|
|
43
|
+
* Value between 0 and 100.
|
|
44
|
+
* @attr
|
|
45
|
+
*/
|
|
46
|
+
this._progress = 0;
|
|
47
|
+
/**
|
|
48
|
+
* Whether to animate progress from 0 to target value when component first becomes visible.
|
|
49
|
+
* @attr initial-animation
|
|
50
|
+
*/
|
|
51
|
+
this.initialAnimation = true;
|
|
52
|
+
/**
|
|
53
|
+
* Optional aria-label attribute for screen readers.
|
|
54
|
+
* Describes what the progress indicator represents.
|
|
55
|
+
* @attr aria-label
|
|
56
|
+
*/
|
|
57
|
+
this.ariaLabel = null;
|
|
58
|
+
/**
|
|
59
|
+
* Optional aria-labelledby attribute for screen readers.
|
|
60
|
+
* References the ID of an element that labels the progress indicator.
|
|
61
|
+
* @attr aria-labelledby
|
|
62
|
+
*/
|
|
63
|
+
this.ariaLabelledBy = null;
|
|
64
|
+
/**
|
|
65
|
+
* Optional aria-valuetext attribute for screen readers.
|
|
66
|
+
* Provides human-readable text alternative for progress value.
|
|
67
|
+
* @attr aria-valuetext
|
|
68
|
+
*/
|
|
69
|
+
this.ariaValueText = null;
|
|
70
|
+
this._isAnimationInitialized = false;
|
|
71
|
+
this._hasCompletedAt100 = false;
|
|
72
|
+
}
|
|
73
|
+
get progress() {
|
|
74
|
+
return this._progress;
|
|
75
|
+
}
|
|
76
|
+
set progress(value) {
|
|
77
|
+
const numValue = isNaN(value) ? 0 : value;
|
|
78
|
+
this._progress = Math.min(Math.max(numValue, 0), 100);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the color value with --progress-color custom property override support.
|
|
82
|
+
* Returns a CSS color string that checks for custom property first, then falls back to theme color.
|
|
83
|
+
*/
|
|
84
|
+
_getProgressColorValue() {
|
|
85
|
+
// Handle special colors (white, black)
|
|
86
|
+
if (this.color === 'white' || this.color === 'black') {
|
|
87
|
+
return `var(--progress-color, var(--btu-theme-${this.color}))`;
|
|
88
|
+
}
|
|
89
|
+
// Standard theme colors use -600 variant
|
|
90
|
+
return `var(--progress-color, oklch(var(--btu-theme-${this.color}-600)))`;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get the animated progress value.
|
|
94
|
+
* Returns 0 if initialAnimation is enabled and animation hasn't started yet, otherwise returns actual progress.
|
|
95
|
+
*/
|
|
96
|
+
_getAnimatedProgress() {
|
|
97
|
+
if (this.initialAnimation && !this._isAnimationInitialized) {
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
return this._progress;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Setup initial animation with IntersectionObserver when component first becomes visible.
|
|
104
|
+
* Should be called from component's firstUpdated() or updated() methods.
|
|
105
|
+
* Safe to call multiple times - will skip if already initialized.
|
|
106
|
+
*/
|
|
107
|
+
_setupInitialAnimation() {
|
|
108
|
+
if (!this.initialAnimation || this._isAnimationInitialized) {
|
|
109
|
+
this._isAnimationInitialized = true;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this._cleanupInitialAnimation();
|
|
113
|
+
this._intersectionObserver = new IntersectionObserver(entries => {
|
|
114
|
+
entries.forEach(entry => {
|
|
115
|
+
if (entry.isIntersecting && !this._isAnimationInitialized) {
|
|
116
|
+
requestAnimationFrame(() => {
|
|
117
|
+
this._isAnimationInitialized = true;
|
|
118
|
+
this.requestUpdate();
|
|
119
|
+
});
|
|
120
|
+
this._intersectionObserver?.disconnect();
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}, { threshold: 0.1 });
|
|
124
|
+
this._intersectionObserver.observe(this);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Cleanup intersection observer.
|
|
128
|
+
* Should be called from component's disconnectedCallback() method.
|
|
129
|
+
*/
|
|
130
|
+
_cleanupInitialAnimation() {
|
|
131
|
+
this._intersectionObserver?.disconnect();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Lifecycle callback fired after the first render.
|
|
135
|
+
* Emits btu-progress-ready event.
|
|
136
|
+
* @internal
|
|
137
|
+
*/
|
|
138
|
+
firstUpdated(changedProperties) {
|
|
139
|
+
super.firstUpdated(changedProperties);
|
|
140
|
+
this.emit('btu-progress-ready');
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Track progress completion and emit event when reaching 100%.
|
|
144
|
+
* Should be called from component's updated() method.
|
|
145
|
+
*/
|
|
146
|
+
_trackCompletion() {
|
|
147
|
+
if (this._progress === 100 && !this._hasCompletedAt100) {
|
|
148
|
+
this._hasCompletedAt100 = true;
|
|
149
|
+
this.emit('btu-progress-complete');
|
|
150
|
+
// Announce completion to screen readers if message provided
|
|
151
|
+
if (this.completionAnnouncement) {
|
|
152
|
+
announce(this.completionAnnouncement);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else if (this._progress < 100 && this._hasCompletedAt100) {
|
|
156
|
+
// Reset flag if progress drops below 100 (allows re-triggering)
|
|
157
|
+
this._hasCompletedAt100 = false;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
__decorate([
|
|
162
|
+
property({ type: String })
|
|
163
|
+
], ProgressMixinClass.prototype, "color", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
property({ type: Number })
|
|
166
|
+
], ProgressMixinClass.prototype, "thickness", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
property({ type: Number })
|
|
169
|
+
], ProgressMixinClass.prototype, "progress", null);
|
|
170
|
+
__decorate([
|
|
171
|
+
property({ type: String })
|
|
172
|
+
], ProgressMixinClass.prototype, "label", void 0);
|
|
173
|
+
__decorate([
|
|
174
|
+
property({ type: Boolean, attribute: 'initial-animation' })
|
|
175
|
+
], ProgressMixinClass.prototype, "initialAnimation", void 0);
|
|
176
|
+
__decorate([
|
|
177
|
+
property({ type: String, attribute: 'aria-label' })
|
|
178
|
+
], ProgressMixinClass.prototype, "ariaLabel", void 0);
|
|
179
|
+
__decorate([
|
|
180
|
+
property({ type: String, attribute: 'aria-labelledby' })
|
|
181
|
+
], ProgressMixinClass.prototype, "ariaLabelledBy", void 0);
|
|
182
|
+
__decorate([
|
|
183
|
+
property({ type: String, attribute: 'aria-valuetext' })
|
|
184
|
+
], ProgressMixinClass.prototype, "ariaValueText", void 0);
|
|
185
|
+
__decorate([
|
|
186
|
+
property({ type: String, attribute: 'completion-announcement' })
|
|
187
|
+
], ProgressMixinClass.prototype, "completionAnnouncement", void 0);
|
|
188
|
+
return ProgressMixinClass;
|
|
189
|
+
};
|
|
190
|
+
//# sourceMappingURL=ProgressMixin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressMixin.js","sourceRoot":"","sources":["../../src/util/ProgressMixin.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AA+BvC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAoC,IAAO,EAAE,EAAE;IAC1E,MAAM,kBAAmB,SAAQ,IAAI;QAArC;;YACE;;;;eAIG;YAEH,UAAK,GAAmB,SAAS,CAAA;YASjC;;;;eAIG;YACK,cAAS,GAAG,CAAC,CAAA;YAmBrB;;;eAGG;YAEH,qBAAgB,GAAG,IAAI,CAAA;YAEvB;;;;eAIG;YAEH,cAAS,GAAkB,IAAI,CAAA;YAE/B;;;;eAIG;YAEH,mBAAc,GAAkB,IAAI,CAAA;YAEpC;;;;eAIG;YAEH,kBAAa,GAAkB,IAAI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AE,IAAI,EAAE,MAAM,EAAE,CAAC;qDACM;IAOjC;QADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDACT;IAUlB;QADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAG1B;IAYD;QADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDACb;IAOd;QADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;gEACrC;IAQvB;QADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;yDACrB;IAQ/B;QADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;8DACrB;IAQpC;QADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;6DACrB;IAQnC;QADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,yBAAyB,EAAE,CAAC;sEAClC;IAoGjC,OAAO,kBAA6D,CAAA;AACtE,CAAC,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
type Constructor<T = object> = new (...args: any[]) => T;
|
|
3
|
+
export declare class ReadyMixinInterface {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* @mixin
|
|
7
|
+
* Mixin that ensures DOM is fully loaded before initializing component
|
|
8
|
+
* Prevents components from querying or manipulating DOM elements before
|
|
9
|
+
* they're available by deferring \`super.connectedCallback()\` until the DOM is ready.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { ReadyMixin } from './ReadyMixin'
|
|
14
|
+
*
|
|
15
|
+
* // Basic usage
|
|
16
|
+
* class MyComponent extends ReadyMixin(LitElement) {
|
|
17
|
+
* connectedCallback() {
|
|
18
|
+
* super.connectedCallback()
|
|
19
|
+
* // DOM is guaranteed to be ready here
|
|
20
|
+
* const child = this.querySelector('.child')
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* // With multiple mixins
|
|
25
|
+
* class NavRail extends EventEmitterMixin(ReadyMixin(LitElement)) {
|
|
26
|
+
* // All mixins benefit from DOM-ready guarantee
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
29
|
+
export declare const ReadyMixin: <T extends Constructor<LitElement>>(superClass: T) => Constructor<ReadyMixinInterface> & T;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=ReadyMixin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadyMixin.d.ts","sourceRoot":"","sources":["../../src/util/ReadyMixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAChC,KAAK,WAAW,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;AAExD,MAAM,CAAC,OAAO,OAAO,mBAAmB;CAAG;AAE3C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,WAAW,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC,KAc/C,WAAW,CAAC,mBAAmB,CAAC,GAAG,CAC9D,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* @mixin
|
|
4
|
+
* Mixin that ensures DOM is fully loaded before initializing component
|
|
5
|
+
* Prevents components from querying or manipulating DOM elements before
|
|
6
|
+
* they're available by deferring \`super.connectedCallback()\` until the DOM is ready.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { ReadyMixin } from './ReadyMixin'
|
|
11
|
+
*
|
|
12
|
+
* // Basic usage
|
|
13
|
+
* class MyComponent extends ReadyMixin(LitElement) {
|
|
14
|
+
* connectedCallback() {
|
|
15
|
+
* super.connectedCallback()
|
|
16
|
+
* // DOM is guaranteed to be ready here
|
|
17
|
+
* const child = this.querySelector('.child')
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* // With multiple mixins
|
|
22
|
+
* class NavRail extends EventEmitterMixin(ReadyMixin(LitElement)) {
|
|
23
|
+
* // All mixins benefit from DOM-ready guarantee
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
export const ReadyMixin = (superClass) => {
|
|
27
|
+
class ReadyMixinClass extends superClass {
|
|
28
|
+
connectedCallback() {
|
|
29
|
+
const init = () => {
|
|
30
|
+
super.connectedCallback();
|
|
31
|
+
};
|
|
32
|
+
if (document.readyState !== 'loading') {
|
|
33
|
+
init();
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
document.addEventListener('DOMContentLoaded', () => init());
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return ReadyMixinClass;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=ReadyMixin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadyMixin.js","sourceRoot":"","sources":["../../src/util/ReadyMixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAKhC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAoC,UAAa,EAAE,EAAE;IAC7E,MAAM,eAAgB,SAAQ,UAAU;QACtC,iBAAiB;YACf,MAAM,IAAI,GAAG,GAAG,EAAE;gBAChB,KAAK,CAAC,iBAAiB,EAAE,CAAA;YAC3B,CAAC,CAAA;YAED,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;gBACtC,IAAI,EAAE,CAAA;YACR,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAA;YAC7D,CAAC;QACH,CAAC;KACF;IACD,OAAO,eAAuD,CAAA;AAChE,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aria.d.ts","sourceRoot":"","sources":["../../src/util/aria.ts"],"names":[],"mappings":"AAUA,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAQ/D;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,QA+BxD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Simple string replacement utility.
|
|
3
|
+
Find all instances of "___" in the string
|
|
4
|
+
and replace with each string in the list of data.
|
|
5
|
+
eg:
|
|
6
|
+
template = 'Today is ___ and the weather is ___.'
|
|
7
|
+
data = ['Friday', 'sunnny']
|
|
8
|
+
--------------------------
|
|
9
|
+
<- 'Today is Friday and the weather is sunny.'
|
|
10
|
+
*/
|
|
11
|
+
export function replaceWithEach(template, data) {
|
|
12
|
+
return template.replace(/_{3}/g, (i => (_) => data[i++])(0));
|
|
13
|
+
}
|
|
14
|
+
export function announce(message, data) {
|
|
15
|
+
let container = document.getElementById('aria-live-container');
|
|
16
|
+
if (!container) {
|
|
17
|
+
container = document.createElement('div');
|
|
18
|
+
container.setAttribute('id', 'aria-live-container');
|
|
19
|
+
document.body.appendChild(container);
|
|
20
|
+
}
|
|
21
|
+
const status = document.createElement('div');
|
|
22
|
+
const id = 'speak-' + Date.now();
|
|
23
|
+
status.setAttribute('id', id);
|
|
24
|
+
status.setAttribute('aria-atomic', 'true');
|
|
25
|
+
status.setAttribute('aria-live', 'polite');
|
|
26
|
+
status.style.cssText =
|
|
27
|
+
'position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0;';
|
|
28
|
+
if (data && data.length) {
|
|
29
|
+
message = replaceWithEach(`${message}`, data);
|
|
30
|
+
}
|
|
31
|
+
container.appendChild(status);
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
const liveRegion = document.getElementById(id);
|
|
34
|
+
if (liveRegion)
|
|
35
|
+
liveRegion.innerHTML = message;
|
|
36
|
+
}, 150);
|
|
37
|
+
if (window.BRIGHTSPOT?.ariaDebug === true) {
|
|
38
|
+
console.log(`ARIA Announced: "${message}"`);
|
|
39
|
+
}
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
document.getElementById(id)?.remove();
|
|
42
|
+
}, 2000);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=aria.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aria.js","sourceRoot":"","sources":["../../src/util/aria.ts"],"names":[],"mappings":"AAAA;;;;;;;;;EASE;AACF,MAAM,UAAU,eAAe,CAAC,QAAgB,EAAE,IAAc;IAC9D,OAAO,QAAQ,CAAC,OAAO,CACrB,OAAO,EACP,CACE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAS,EAAE,EAAE,CACjB,IAAI,CAAC,CAAC,EAAE,CAAC,CACZ,CAAC,CAAC,CAAC,CACL,CAAA;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,IAAe;IACvD,IAAI,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAA;IAC9D,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QACzC,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAA;QACnD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;IACtC,CAAC;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAC5C,MAAM,EAAE,GAAG,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IAChC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IAC7B,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;IAC1C,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;IAC1C,MAAM,CAAC,KAAK,CAAC,OAAO;QAClB,wJAAwJ,CAAA;IAC1J,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QACxB,OAAO,GAAG,eAAe,CAAC,GAAG,OAAO,EAAE,EAAE,IAAI,CAAC,CAAA;IAC/C,CAAC;IACD,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IAE7B,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;QAC9C,IAAI,UAAU;YAAE,UAAU,CAAC,SAAS,GAAG,OAAO,CAAA;IAChD,CAAC,EAAE,GAAG,CAAC,CAAA;IAEP,IAAI,MAAM,CAAC,UAAU,EAAE,SAAS,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,oBAAoB,OAAO,GAAG,CAAC,CAAA;IAC7C,CAAC;IAED,UAAU,CAAC,GAAG,EAAE;QACd,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAA;IACvC,CAAC,EAAE,IAAI,CAAC,CAAA;AACV,CAAC"}
|
package/dist/util/svg.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
export declare function addNameSpaceXML(data: string): string;
|
|
2
|
+
/**
|
|
3
|
+
* Adds a mask element to an SVG string. The mask is inserted immediately after the opening <svg> tag
|
|
4
|
+
* and wraps the existing SVG content, ending before the closing </svg> tag.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} svg - The SVG string to which the mask will be added. Must contain valid <svg> tags.
|
|
7
|
+
* @param {string} maskId - The ID to assign to the <mask> element.
|
|
8
|
+
* @returns {string} - The modified SVG string with the mask element added.
|
|
9
|
+
*/
|
|
10
|
+
export declare function addMask(svg: string, maskId: string): string;
|
|
2
11
|
export declare function encodeSVG(data: string): string;
|
|
3
12
|
//# sourceMappingURL=svg.d.ts.map
|
package/dist/util/svg.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../src/util/svg.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKpD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK9C"}
|
|
1
|
+
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../../src/util/svg.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKpD;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAe3D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK9C"}
|
package/dist/util/svg.js
CHANGED
|
@@ -5,6 +5,28 @@ export function addNameSpaceXML(data) {
|
|
|
5
5
|
}
|
|
6
6
|
return data;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Adds a mask element to an SVG string. The mask is inserted immediately after the opening <svg> tag
|
|
10
|
+
* and wraps the existing SVG content, ending before the closing </svg> tag.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} svg - The SVG string to which the mask will be added. Must contain valid <svg> tags.
|
|
13
|
+
* @param {string} maskId - The ID to assign to the <mask> element.
|
|
14
|
+
* @returns {string} - The modified SVG string with the mask element added.
|
|
15
|
+
*/
|
|
16
|
+
export function addMask(svg, maskId) {
|
|
17
|
+
// Insert <mask id="..."> right after <svg ...>
|
|
18
|
+
const openingSvgTagMatch = svg.match(/<svg[^>]*>/);
|
|
19
|
+
if (!openingSvgTagMatch)
|
|
20
|
+
return svg;
|
|
21
|
+
const openingSvgTag = openingSvgTagMatch[0];
|
|
22
|
+
const maskOpen = `<mask id="${maskId}">`;
|
|
23
|
+
const maskClose = `</mask>`;
|
|
24
|
+
// Find positions
|
|
25
|
+
const start = svg.indexOf(openingSvgTag) + openingSvgTag.length;
|
|
26
|
+
const end = svg.lastIndexOf('</svg>');
|
|
27
|
+
// Insert mask tags
|
|
28
|
+
return svg.slice(0, start) + maskOpen + svg.slice(start, end) + maskClose + svg.slice(end);
|
|
29
|
+
}
|
|
8
30
|
export function encodeSVG(data) {
|
|
9
31
|
data = data.replace(/"/g, `'`);
|
|
10
32
|
data = data.replace(/>\s{1,}</g, `><`);
|
package/dist/util/svg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.js","sourceRoot":"","sources":["../../src/util/svg.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,0BAA0B,CAAA;AAE1C,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,IAAI,IAAI,CAAC,OAAO,CAAC,4BAA4B,CAAC,GAAG,CAAC,EAAE,CAAC;QACnD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,yCAAyC,CAAC,CAAA;IACzE,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAC9B,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;IACtC,IAAI,GAAG,IAAI,CAAC,OAAO,C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