@brightspot/ui 1.9.0 → 1.11.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/dist/components/action-bar/ActionBar.d.ts +163 -0
- package/dist/components/action-bar/ActionBar.d.ts.map +1 -0
- package/dist/components/action-bar/ActionBar.js +479 -0
- package/dist/components/action-bar/ActionBar.js.map +1 -0
- package/dist/components/action-bar/ActionItem.d.ts +103 -0
- package/dist/components/action-bar/ActionItem.d.ts.map +1 -0
- package/dist/components/action-bar/ActionItem.js +237 -0
- package/dist/components/action-bar/ActionItem.js.map +1 -0
- package/dist/components/copy-to-clipboard/CopyToClipboard.d.ts.map +1 -1
- package/dist/components/copy-to-clipboard/CopyToClipboard.js +4 -0
- package/dist/components/copy-to-clipboard/CopyToClipboard.js.map +1 -1
- package/dist/components/dropdown/Dropdown.d.ts +3 -1
- package/dist/components/dropdown/Dropdown.d.ts.map +1 -1
- package/dist/components/dropdown/Dropdown.js +22 -6
- package/dist/components/dropdown/Dropdown.js.map +1 -1
- package/dist/components/dropdown/DropdownItem.d.ts +14 -1
- package/dist/components/dropdown/DropdownItem.d.ts.map +1 -1
- package/dist/components/dropdown/DropdownItem.js +20 -1
- package/dist/components/dropdown/DropdownItem.js.map +1 -1
- package/dist/components/dropdown/DropdownMenu.d.ts +3 -5
- package/dist/components/dropdown/DropdownMenu.d.ts.map +1 -1
- package/dist/components/dropdown/DropdownMenu.js +17 -32
- package/dist/components/dropdown/DropdownMenu.js.map +1 -1
- package/dist/components/pagination/Pagination.d.ts +33 -4
- package/dist/components/pagination/Pagination.d.ts.map +1 -1
- package/dist/components/pagination/Pagination.js +80 -16
- package/dist/components/pagination/Pagination.js.map +1 -1
- package/dist/components/switch/Switch.d.ts +92 -0
- package/dist/components/switch/Switch.d.ts.map +1 -0
- package/dist/components/switch/Switch.js +189 -0
- package/dist/components/switch/Switch.js.map +1 -0
- package/dist/components/tabs/Tab.d.ts +108 -0
- package/dist/components/tabs/Tab.d.ts.map +1 -0
- package/dist/components/tabs/Tab.js +152 -0
- package/dist/components/tabs/Tab.js.map +1 -0
- package/dist/components/tabs/Tabs.d.ts +126 -0
- package/dist/components/tabs/Tabs.d.ts.map +1 -0
- package/dist/components/tabs/Tabs.js +390 -0
- package/dist/components/tabs/Tabs.js.map +1 -0
- package/dist/custom-elements.json +2736 -1390
- package/dist/effects/celebrate.d.ts +18 -0
- package/dist/effects/celebrate.d.ts.map +1 -0
- package/dist/effects/celebrate.js +81 -0
- package/dist/effects/celebrate.js.map +1 -0
- package/dist/effects/ripple.d.ts +31 -0
- package/dist/effects/ripple.d.ts.map +1 -0
- package/dist/effects/ripple.js +131 -0
- package/dist/effects/ripple.js.map +1 -0
- package/dist/effects/sparkle-worklet.d.ts +7 -0
- package/dist/effects/sparkle-worklet.d.ts.map +1 -0
- package/dist/effects/sparkle-worklet.js +211 -0
- package/dist/effects/sparkle-worklet.js.map +1 -0
- package/dist/effects/sparkle.d.ts +6 -0
- package/dist/effects/sparkle.d.ts.map +1 -0
- package/dist/effects/sparkle.js +91 -0
- package/dist/effects/sparkle.js.map +1 -0
- package/dist/storybook/BSPLogoMark.svg +3 -0
- package/dist/storybook/WelcomeBG.svg +292 -0
- package/dist/storybook/assets/ActionBar.stories--nAeDC-G.js +408 -0
- package/dist/storybook/assets/ActionItem.stories-BHrGjk-P.js +203 -0
- package/dist/storybook/assets/{Avatar.stories-Du1qM73U.js → Avatar.stories-Da-mRj6_.js} +1 -1
- package/dist/storybook/assets/{AvatarGroup.stories-DxwZQE-q.js → AvatarGroup.stories-BQlaC_yl.js} +1 -1
- package/dist/storybook/assets/{Badge.stories-CfvkMIx2.js → Badge.stories-DnVnOrnF.js} +1 -1
- package/dist/storybook/assets/Button-CFLAI1H9.js +10 -0
- package/dist/storybook/assets/Button.stories-DxaBOjwv.js +54 -0
- package/dist/storybook/assets/Celebrate.stories-CuMm15Nr.js +184 -0
- package/dist/storybook/assets/{CircularProgress.stories-rPzKwQYD.js → CircularProgress.stories-DRN8Mtvj.js} +1 -1
- package/dist/storybook/assets/{ClipboardMixin.stories-BlUeYDSi.js → ClipboardMixin.stories-DR7Ou2Av.js} +1 -1
- package/dist/storybook/assets/Color-6BZIO3FS-Die62Y0Z.js +1 -0
- package/dist/storybook/assets/{Colors.stories-BspfjZ5q.js → Colors.stories-bIq_ssbI.js} +1 -1
- package/dist/storybook/assets/CombinedEffects.stories-CtKzOUZn.js +355 -0
- package/dist/storybook/assets/{ComponentStatesMixin-eTV7XXqB.js → ComponentStatesMixin-DMLCk9fE.js} +1 -1
- package/dist/storybook/assets/{ComponentStatesMixin.stories-BbLSY3df.js → ComponentStatesMixin.stories-D8UI9o-d.js} +1 -1
- package/dist/storybook/assets/{CopyToClipboard.stories-B2ailiFF.js → CopyToClipboard.stories-ti6CpJNp.js} +1 -1
- package/dist/storybook/assets/{Debounce.stories-DJmp4eNo.js → Debounce.stories-DzZUSvbk.js} +1 -1
- package/dist/storybook/assets/DocsRenderer-LL677BLK-CIRGv5IX.js +10 -0
- package/dist/storybook/assets/{Dropdown.stories-Dd6vKiDd.js → Dropdown.stories-Lt4cY0Re.js} +41 -14
- package/dist/storybook/assets/{Events.stories-Byj-VOM9.js → Events.stories-B1ddcgpT.js} +1 -1
- package/dist/storybook/assets/{Heading.stories-Dqw-wzpx.js → Heading.stories-DI4w61cf.js} +1 -1
- package/dist/storybook/assets/HueRipple.stories-DjhoxxEw.js +310 -0
- package/dist/storybook/assets/{Icon.stories-Bp1nvWER.js → Icon.stories-CpziAhae.js} +1 -1
- package/dist/storybook/assets/{IconButton.stories-o9g9mGdh.js → IconButton.stories-KjN28hfc.js} +1 -1
- package/dist/storybook/assets/{LinearProgress.stories-DnXQVpzX.js → LinearProgress.stories-DcIpdz6R.js} +1 -1
- package/dist/storybook/assets/Pagination.stories-BBkLEwoP.js +252 -0
- package/dist/storybook/assets/{Popover.stories-BvavsRfq.js → Popover.stories-DLv48c2h.js} +3 -11
- package/dist/storybook/assets/{ReadyMixin-6On1MFFr.js → ReadyMixin-Cw2Dfbu2.js} +1 -1
- package/dist/storybook/assets/RovingTabindexMixin.stories-BWaFx9mu.js +192 -0
- package/dist/storybook/assets/{Rtc.stories-Bb5Y-908.js → Rtc.stories-Ve7Bwo_l.js} +1 -1
- package/dist/storybook/assets/ScrollShadow.stories-C6XmrRLm.js +17 -0
- package/dist/storybook/assets/Switch.stories-Cf8WM1LG.js +312 -0
- package/dist/storybook/assets/Tab.stories-CEtdEtOx.js +218 -0
- package/dist/storybook/assets/Tabs.stories-CIAO1bPO.js +211 -0
- package/dist/storybook/assets/{Throttle.stories-DmP-yKke.js → Throttle.stories-BqxVIb-r.js} +1 -1
- package/dist/storybook/assets/{Tooltip.stories-Dl6xHBaM.js → Tooltip.stories-B6fw6875.js} +3 -7
- package/dist/storybook/assets/Welcome.stories-CfJtSM19.js +215 -0
- package/dist/storybook/assets/{Widget.stories-BjXfgNjZ.js → Widget.stories-CiOho7lO.js} +1 -1
- package/dist/storybook/assets/WithTooltip-65CFNBJE-PGcopp73.js +9 -0
- package/dist/storybook/assets/blocks-dP2DwISI.js +707 -0
- package/dist/storybook/assets/celebrate-KwPoF1K3.js +21 -0
- package/dist/storybook/assets/formatter-EIJCOSYU-CZSAC3tg.js +1 -0
- package/dist/storybook/assets/if-defined-B1RdczOE.js +1 -0
- package/dist/storybook/assets/iframe-DloIUNZz.js +1104 -0
- package/dist/storybook/assets/{iframe-CNxIA3cQ.css → iframe-bJgLXZKK.css} +1 -1
- package/dist/storybook/assets/index-DKF0ypu5.js +1 -0
- package/dist/storybook/assets/onFind-C0l4Gew0.js +1 -0
- package/dist/storybook/assets/{onFind.stories-B2GYLrjV.js → onFind.stories-DOTt9puO.js} +2 -2
- package/dist/storybook/assets/{onRemove.stories-CoLJFkWa.js → onRemove.stories-CQ9ZC5dm.js} +1 -1
- package/dist/storybook/assets/{onVisible.stories-DOeZx7wi.js → onVisible.stories-Cbj5_Vz0.js} +2 -2
- package/dist/storybook/assets/position-CFNQy3J6.js +1 -0
- package/dist/storybook/assets/ripple-DQbyyRUw.js +251 -0
- package/dist/storybook/assets/style-map-DLXysq3r.js +1 -0
- package/dist/storybook/assets/syntaxhighlighter-ED5Y7EFY-Bjjbl9ca.js +6 -0
- package/dist/storybook/brightspot-logo.svg +19 -0
- package/dist/storybook/iframe.html +23 -3
- package/dist/storybook/index.html +42 -1
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/storybook/sb-addons/storybook-3/manager-bundle.js +3 -0
- package/dist/tailwind-plugin-action-bar.d.ts +2 -0
- package/dist/tailwind-plugin-action-bar.d.ts.map +1 -0
- package/dist/tailwind-plugin-action-bar.js +120 -0
- package/dist/tailwind-plugin-action-bar.js.map +1 -0
- package/dist/tailwind-plugin-action-bar.ts +134 -0
- package/dist/tailwind-plugin-badge.js +4 -5
- package/dist/tailwind-plugin-badge.js.map +1 -1
- package/dist/tailwind-plugin-badge.ts +4 -5
- package/dist/tailwind-plugin-button.js +1 -0
- package/dist/tailwind-plugin-button.js.map +1 -1
- package/dist/tailwind-plugin-button.ts +1 -0
- package/dist/tailwind-plugin-pagination.js +13 -23
- package/dist/tailwind-plugin-pagination.js.map +1 -1
- package/dist/tailwind-plugin-pagination.ts +15 -25
- package/dist/tailwind-plugin-switch.d.ts +2 -0
- package/dist/tailwind-plugin-switch.d.ts.map +1 -0
- package/dist/tailwind-plugin-switch.js +223 -0
- package/dist/tailwind-plugin-switch.js.map +1 -0
- package/dist/tailwind-plugin-switch.ts +252 -0
- package/dist/tailwind-plugin-tabs.d.ts +2 -0
- package/dist/tailwind-plugin-tabs.d.ts.map +1 -0
- package/dist/tailwind-plugin-tabs.js +151 -0
- package/dist/tailwind-plugin-tabs.js.map +1 -0
- package/dist/tailwind-plugin-tabs.ts +162 -0
- package/dist/util/EventEmitterMixin.d.ts +21 -0
- package/dist/util/EventEmitterMixin.d.ts.map +1 -1
- package/dist/util/EventEmitterMixin.js.map +1 -1
- package/dist/util/RovingTabindexMixin.d.ts +38 -0
- package/dist/util/RovingTabindexMixin.d.ts.map +1 -0
- package/dist/util/RovingTabindexMixin.js +83 -0
- package/dist/util/RovingTabindexMixin.js.map +1 -0
- package/dist/util/position.d.ts +9 -0
- package/dist/util/position.d.ts.map +1 -0
- package/dist/util/position.js +11 -0
- package/dist/util/position.js.map +1 -0
- package/docs/components/ActionBar.md +71 -0
- package/docs/components/ActionItem.md +76 -0
- package/docs/components/Dropdown.md +7 -7
- package/docs/components/DropdownItem.md +9 -5
- package/docs/components/DropdownMenu.md +12 -12
- package/docs/components/Pagination.md +37 -34
- package/docs/components/README.md +5 -0
- package/docs/components/Switch.md +79 -0
- package/docs/components/Tab.md +73 -0
- package/docs/components/Tabs.md +77 -0
- package/package.json +2 -1
- package/dist/storybook/assets/Button.stories-hDMDDh81.js +0 -63
- package/dist/storybook/assets/Color-6BZIO3FS-C_nQSB2u.js +0 -1
- package/dist/storybook/assets/DocsRenderer-LL677BLK-56Pige1J.js +0 -758
- package/dist/storybook/assets/Pagination.stories-DQD8uvDc.js +0 -272
- package/dist/storybook/assets/ScrollShadow.stories-ZovRXpte.js +0 -17
- package/dist/storybook/assets/WithTooltip-65CFNBJE-CGB5q-AN.js +0 -9
- package/dist/storybook/assets/_commonjsHelpers-CqkleIqs.js +0 -1
- package/dist/storybook/assets/formatter-EIJCOSYU-BhNtSFM9.js +0 -1
- package/dist/storybook/assets/if-defined-BFyUeSVF.js +0 -1
- package/dist/storybook/assets/iframe-BeKreX-l.js +0 -1061
- package/dist/storybook/assets/index-Uz2kGy8J.js +0 -1
- package/dist/storybook/assets/onFind-DqriYjEB.js +0 -1
- package/dist/storybook/assets/style-map-CmHqpCu1.js +0 -1
- package/dist/storybook/assets/syntaxhighlighter-ED5Y7EFY-BqFfcc7x.js +0 -6
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import '../icon/Icon.js';
|
|
3
|
+
declare const Switch_base: (new (...args: any[]) => import("../../util/EventEmitterMixin.js").EventEmitterMixinInterface) & (new (...args: any[]) => import("../../util/ReadyMixin.js").ReadyMixinInterface) & typeof LitElement;
|
|
4
|
+
/**
|
|
5
|
+
* A toggle switch component for binary on/off states.
|
|
6
|
+
*
|
|
7
|
+
* Uses a hidden checkbox internally for accessibility, styled via the
|
|
8
|
+
* `btu-switch` Tailwind plugin classes.
|
|
9
|
+
*
|
|
10
|
+
* @element btu-switch
|
|
11
|
+
*
|
|
12
|
+
* @fires {CustomEvent} btu-switch-ready - Fired after the toggle is first rendered and initialized
|
|
13
|
+
* @fires {CustomEvent<{ checked: boolean }>} btu-switch-change - Fired when the user toggles the switch
|
|
14
|
+
* @fires {CustomEvent} btu-switch-focus - Fired when the component gains focus
|
|
15
|
+
*
|
|
16
|
+
* @cssprop --switch-color-track-on - Background color when the toggle is checked (default: var(--btu-theme-primary-700))
|
|
17
|
+
* @cssprop --switch-color-track-off - Background color when the toggle is unchecked (default: var(--btu-theme-gray-300))
|
|
18
|
+
* @cssprop --switch-color-knob - Color of the sliding circular handle (default: var(--btu-theme-white))
|
|
19
|
+
* @cssprop --switch-label-spacing - Distance between the switch and the text label (default: 0.75rem)
|
|
20
|
+
* @cssprop --switch-track-icon-size - Size of the track icons (default: sm 0.5rem, md 0.625rem, lg 0.75rem)
|
|
21
|
+
*/
|
|
22
|
+
export default class Switch extends Switch_base {
|
|
23
|
+
/**
|
|
24
|
+
* Controls the physical dimensions of the switch and the associated label typography.
|
|
25
|
+
* @attr
|
|
26
|
+
*/
|
|
27
|
+
size: 'small' | 'medium' | 'large';
|
|
28
|
+
/**
|
|
29
|
+
* The primary text displayed next to the toggle.
|
|
30
|
+
* @attr
|
|
31
|
+
*/
|
|
32
|
+
label: string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Optional helper text or secondary information displayed below the label.
|
|
35
|
+
* @attr
|
|
36
|
+
*/
|
|
37
|
+
description: string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The current state of the switch (on/off).
|
|
40
|
+
* @attr
|
|
41
|
+
*/
|
|
42
|
+
checked: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* If true, the toggle is non-interactive and visually muted.
|
|
45
|
+
* @attr
|
|
46
|
+
*/
|
|
47
|
+
disabled: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Name of the control for form participation.
|
|
50
|
+
* @attr
|
|
51
|
+
*/
|
|
52
|
+
name: string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Determines if the label appears to the left or right of the switch.
|
|
55
|
+
* @attr label-position
|
|
56
|
+
*/
|
|
57
|
+
labelPosition: 'start' | 'end';
|
|
58
|
+
/**
|
|
59
|
+
* Lucide icon name shown on the track when the switch is checked (on).
|
|
60
|
+
* @attr on-icon
|
|
61
|
+
*/
|
|
62
|
+
onIcon: string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Lucide icon name shown on the track when the switch is unchecked (off).
|
|
65
|
+
* @attr off-icon
|
|
66
|
+
*/
|
|
67
|
+
offIcon: string | undefined;
|
|
68
|
+
/** @internal */
|
|
69
|
+
private _userInitiated;
|
|
70
|
+
/** @internal */
|
|
71
|
+
private initialClasses;
|
|
72
|
+
/** @internal */
|
|
73
|
+
private _initialClassesCaptured;
|
|
74
|
+
/** @internal */
|
|
75
|
+
private _descId;
|
|
76
|
+
connectedCallback(): void;
|
|
77
|
+
createRenderRoot(): this;
|
|
78
|
+
willUpdate(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
79
|
+
firstUpdated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
80
|
+
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
81
|
+
private _onInputChange;
|
|
82
|
+
private _onFocus;
|
|
83
|
+
private _toggleInput;
|
|
84
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
85
|
+
}
|
|
86
|
+
declare global {
|
|
87
|
+
interface HTMLElementTagNameMap {
|
|
88
|
+
'btu-switch': Switch;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
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AAC,GAAG,IAAI;IAK7E,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAWxE,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,YAAY;IAKpB,MAAM;CA4CP;AAMD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,MAAM,CAAA;KACrB;CACF"}
|
|
@@ -0,0 +1,189 @@
|
|
|
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, nothing } from 'lit';
|
|
8
|
+
import { property } from 'lit/decorators.js';
|
|
9
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
|
+
import { EventEmitterMixin } from '../../util/EventEmitterMixin.js';
|
|
11
|
+
import { ReadyMixin } from '../../util/ReadyMixin.js';
|
|
12
|
+
import '../icon/Icon.js';
|
|
13
|
+
// 'small' is omitted — it uses the base btu-switch dimensions with no modifier class
|
|
14
|
+
const SIZE_CLASSES = {
|
|
15
|
+
medium: 'btu-switch-md',
|
|
16
|
+
large: 'btu-switch-lg',
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A toggle switch component for binary on/off states.
|
|
20
|
+
*
|
|
21
|
+
* Uses a hidden checkbox internally for accessibility, styled via the
|
|
22
|
+
* `btu-switch` Tailwind plugin classes.
|
|
23
|
+
*
|
|
24
|
+
* @element btu-switch
|
|
25
|
+
*
|
|
26
|
+
* @fires {CustomEvent} btu-switch-ready - Fired after the toggle is first rendered and initialized
|
|
27
|
+
* @fires {CustomEvent<{ checked: boolean }>} btu-switch-change - Fired when the user toggles the switch
|
|
28
|
+
* @fires {CustomEvent} btu-switch-focus - Fired when the component gains focus
|
|
29
|
+
*
|
|
30
|
+
* @cssprop --switch-color-track-on - Background color when the toggle is checked (default: var(--btu-theme-primary-700))
|
|
31
|
+
* @cssprop --switch-color-track-off - Background color when the toggle is unchecked (default: var(--btu-theme-gray-300))
|
|
32
|
+
* @cssprop --switch-color-knob - Color of the sliding circular handle (default: var(--btu-theme-white))
|
|
33
|
+
* @cssprop --switch-label-spacing - Distance between the switch and the text label (default: 0.75rem)
|
|
34
|
+
* @cssprop --switch-track-icon-size - Size of the track icons (default: sm 0.5rem, md 0.625rem, lg 0.75rem)
|
|
35
|
+
*/
|
|
36
|
+
export default class Switch extends EventEmitterMixin(ReadyMixin(LitElement)) {
|
|
37
|
+
constructor() {
|
|
38
|
+
super(...arguments);
|
|
39
|
+
/**
|
|
40
|
+
* Controls the physical dimensions of the switch and the associated label typography.
|
|
41
|
+
* @attr
|
|
42
|
+
*/
|
|
43
|
+
this.size = 'small';
|
|
44
|
+
/**
|
|
45
|
+
* The current state of the switch (on/off).
|
|
46
|
+
* @attr
|
|
47
|
+
*/
|
|
48
|
+
this.checked = false;
|
|
49
|
+
/**
|
|
50
|
+
* If true, the toggle is non-interactive and visually muted.
|
|
51
|
+
* @attr
|
|
52
|
+
*/
|
|
53
|
+
this.disabled = false;
|
|
54
|
+
/**
|
|
55
|
+
* Determines if the label appears to the left or right of the switch.
|
|
56
|
+
* @attr label-position
|
|
57
|
+
*/
|
|
58
|
+
this.labelPosition = 'end';
|
|
59
|
+
/** @internal */
|
|
60
|
+
this._userInitiated = false;
|
|
61
|
+
/** @internal */
|
|
62
|
+
this.initialClasses = [];
|
|
63
|
+
/** @internal */
|
|
64
|
+
this._initialClassesCaptured = false;
|
|
65
|
+
/** @internal */
|
|
66
|
+
this._descId = `switch-desc-${crypto.randomUUID()}`;
|
|
67
|
+
}
|
|
68
|
+
connectedCallback() {
|
|
69
|
+
super.connectedCallback();
|
|
70
|
+
if (!this._initialClassesCaptured && this.className) {
|
|
71
|
+
this.initialClasses = this.className.split(' ').filter(c => c.trim());
|
|
72
|
+
this._initialClassesCaptured = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
createRenderRoot() {
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
willUpdate(changedProperties) {
|
|
79
|
+
super.willUpdate(changedProperties);
|
|
80
|
+
const classes = [
|
|
81
|
+
...this.initialClasses,
|
|
82
|
+
'btu-switch',
|
|
83
|
+
SIZE_CLASSES[this.size],
|
|
84
|
+
this.labelPosition === 'start' && 'btu-switch-label-start',
|
|
85
|
+
];
|
|
86
|
+
this.className = classes.filter(Boolean).join(' ');
|
|
87
|
+
}
|
|
88
|
+
firstUpdated(changedProperties) {
|
|
89
|
+
super.firstUpdated(changedProperties);
|
|
90
|
+
this.emit('btu-switch-ready');
|
|
91
|
+
}
|
|
92
|
+
updated(changedProperties) {
|
|
93
|
+
super.updated(changedProperties);
|
|
94
|
+
if (!this._userInitiated)
|
|
95
|
+
return;
|
|
96
|
+
this._userInitiated = false;
|
|
97
|
+
if (changedProperties.has('checked')) {
|
|
98
|
+
this.emit('btu-switch-change', { checked: this.checked });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
_onInputChange(e) {
|
|
102
|
+
const input = e.target;
|
|
103
|
+
this._userInitiated = true;
|
|
104
|
+
this.checked = input.checked;
|
|
105
|
+
}
|
|
106
|
+
_onFocus() {
|
|
107
|
+
this.emit('btu-switch-focus');
|
|
108
|
+
}
|
|
109
|
+
_toggleInput() {
|
|
110
|
+
if (this.disabled)
|
|
111
|
+
return;
|
|
112
|
+
this.renderRoot.querySelector('.btu-switch-input')?.click();
|
|
113
|
+
}
|
|
114
|
+
render() {
|
|
115
|
+
return html `
|
|
116
|
+
<input
|
|
117
|
+
type="checkbox"
|
|
118
|
+
role="switch"
|
|
119
|
+
class="btu-switch-input"
|
|
120
|
+
.checked=${this.checked}
|
|
121
|
+
?disabled=${this.disabled}
|
|
122
|
+
name=${ifDefined(this.name)}
|
|
123
|
+
aria-checked=${this.checked}
|
|
124
|
+
aria-label=${ifDefined(this.label)}
|
|
125
|
+
aria-describedby=${ifDefined(this.description ? this._descId : undefined)}
|
|
126
|
+
@change=${this._onInputChange}
|
|
127
|
+
@focus=${this._onFocus}
|
|
128
|
+
/>
|
|
129
|
+
<span class="btu-switch-track" @click=${this._toggleInput}>
|
|
130
|
+
${this.onIcon
|
|
131
|
+
? html `<btu-icon
|
|
132
|
+
class="btu-switch-track-icon-on"
|
|
133
|
+
symbol=${this.onIcon}
|
|
134
|
+
style="--Icon-size: var(--switch-track-icon-size)"
|
|
135
|
+
></btu-icon>`
|
|
136
|
+
: nothing}
|
|
137
|
+
<span class="btu-switch-knob"></span>
|
|
138
|
+
${this.offIcon
|
|
139
|
+
? html `<btu-icon
|
|
140
|
+
class="btu-switch-track-icon-off"
|
|
141
|
+
symbol=${this.offIcon}
|
|
142
|
+
style="--Icon-size: var(--switch-track-icon-size)"
|
|
143
|
+
></btu-icon>`
|
|
144
|
+
: nothing}
|
|
145
|
+
</span>
|
|
146
|
+
${this.label || this.description
|
|
147
|
+
? html `
|
|
148
|
+
<span class="btu-switch-text" @click=${this._toggleInput}>
|
|
149
|
+
${this.label ? html `<span class="btu-switch-label">${this.label}</span>` : nothing}
|
|
150
|
+
${this.description
|
|
151
|
+
? html `<span id=${this._descId} class="btu-switch-description">${this.description}</span>`
|
|
152
|
+
: nothing}
|
|
153
|
+
</span>
|
|
154
|
+
`
|
|
155
|
+
: nothing}
|
|
156
|
+
`;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
__decorate([
|
|
160
|
+
property()
|
|
161
|
+
], Switch.prototype, "size", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
property()
|
|
164
|
+
], Switch.prototype, "label", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
property()
|
|
167
|
+
], Switch.prototype, "description", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
property({ type: Boolean })
|
|
170
|
+
], Switch.prototype, "checked", void 0);
|
|
171
|
+
__decorate([
|
|
172
|
+
property({ type: Boolean })
|
|
173
|
+
], Switch.prototype, "disabled", void 0);
|
|
174
|
+
__decorate([
|
|
175
|
+
property()
|
|
176
|
+
], Switch.prototype, "name", void 0);
|
|
177
|
+
__decorate([
|
|
178
|
+
property({ attribute: 'label-position' })
|
|
179
|
+
], Switch.prototype, "labelPosition", void 0);
|
|
180
|
+
__decorate([
|
|
181
|
+
property({ attribute: 'on-icon' })
|
|
182
|
+
], Switch.prototype, "onIcon", void 0);
|
|
183
|
+
__decorate([
|
|
184
|
+
property({ attribute: 'off-icon' })
|
|
185
|
+
], Switch.prototype, "offIcon", void 0);
|
|
186
|
+
if (!customElements.get('btu-switch')) {
|
|
187
|
+
customElements.define('btu-switch', Switch);
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=Switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../../src/components/switch/Switch.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,iBAAiB,CAAA;AAExB,qFAAqF;AACrF,MAAM,YAAY,GAA2B;IAC3C,MAAM,EAAE,eAAe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S,EAAE,UAAU,EAAE,CAAC;uCACT;AAkH7B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;IACtC,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;AAC7C,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import '../badge/Badge.js';
|
|
3
|
+
import '../icon/Icon.js';
|
|
4
|
+
export interface TabProps {
|
|
5
|
+
name?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
iconName?: string;
|
|
10
|
+
iconPosition?: 'leading' | 'trailing';
|
|
11
|
+
iconOnly?: boolean;
|
|
12
|
+
error?: boolean;
|
|
13
|
+
badge?: string;
|
|
14
|
+
}
|
|
15
|
+
declare const Tab_base: (new (...args: any[]) => import("../../util/EventEmitterMixin.js").EventEmitterMixinInterface) & (new (...args: any[]) => import("../../util/ReadyMixin.js").ReadyMixinInterface) & typeof LitElement;
|
|
16
|
+
/**
|
|
17
|
+
* An individual tab within a tab group.
|
|
18
|
+
*
|
|
19
|
+
* Renders a button with role="tab" that participates in keyboard navigation
|
|
20
|
+
* and selection state managed by the parent `btu-tabs` container.
|
|
21
|
+
*
|
|
22
|
+
* @element btu-tab
|
|
23
|
+
*
|
|
24
|
+
* @fires {CustomEvent} btu-tab-ready - Fired after first render
|
|
25
|
+
* @fires {CustomEvent<{name: string}>} btu-tab-change - Fired when a non-disabled tab with a name is clicked
|
|
26
|
+
*
|
|
27
|
+
* @cssprop --badge-color-background - Background color of the count indicator badge (default: gray-50)
|
|
28
|
+
* @cssprop --badge-color-foreground - Text color of the count indicator badge (default: gray-700)
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```html
|
|
32
|
+
* <btu-tabs>
|
|
33
|
+
* <btu-tab name="main" label="Main"></btu-tab>
|
|
34
|
+
* <btu-tab name="seo" label="SEO"></btu-tab>
|
|
35
|
+
* <btu-tab name="styles" label="Styles" disabled></btu-tab>
|
|
36
|
+
* </btu-tabs>
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export default class Tab extends Tab_base {
|
|
40
|
+
static get tagName(): string;
|
|
41
|
+
/**
|
|
42
|
+
* Value that identifies this tab and links it to panel elements that share the same `name` attribute.
|
|
43
|
+
* @attr name
|
|
44
|
+
*/
|
|
45
|
+
name?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Text displayed in the tab.
|
|
48
|
+
* @attr
|
|
49
|
+
*/
|
|
50
|
+
label?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Accessibility description for screen readers.
|
|
53
|
+
* @attr
|
|
54
|
+
*/
|
|
55
|
+
description?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Whether the tab is disabled and non-interactive.
|
|
58
|
+
* @attr
|
|
59
|
+
*/
|
|
60
|
+
disabled: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Lucide icon name to display.
|
|
63
|
+
* @attr icon-name
|
|
64
|
+
*/
|
|
65
|
+
iconName?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Placement of the icon relative to the label.
|
|
68
|
+
* @attr icon-position
|
|
69
|
+
*/
|
|
70
|
+
iconPosition: 'leading' | 'trailing';
|
|
71
|
+
/**
|
|
72
|
+
* When true, hides the label visually while maintaining accessibility.
|
|
73
|
+
* @attr icon-only
|
|
74
|
+
*/
|
|
75
|
+
iconOnly: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* When true, displays an error badge on the tab.
|
|
78
|
+
* @attr
|
|
79
|
+
*/
|
|
80
|
+
error: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Displays a badge with the given value alongside the label.
|
|
83
|
+
* @attr
|
|
84
|
+
*/
|
|
85
|
+
badge?: string;
|
|
86
|
+
/** @internal Active state set by parent btu-tabs */
|
|
87
|
+
_active: boolean;
|
|
88
|
+
/** @internal Roving tabindex value set by parent btu-tabs */
|
|
89
|
+
_tabindex: number;
|
|
90
|
+
/** @internal Set by parent btu-tabs */
|
|
91
|
+
size: 'xs' | 'sm' | 'md' | 'lg';
|
|
92
|
+
/** @internal */
|
|
93
|
+
private initialClasses;
|
|
94
|
+
connectedCallback(): void;
|
|
95
|
+
createRenderRoot(): this;
|
|
96
|
+
willUpdate(): void;
|
|
97
|
+
firstUpdated(): void;
|
|
98
|
+
/** @internal */
|
|
99
|
+
private handleClick;
|
|
100
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
101
|
+
}
|
|
102
|
+
declare global {
|
|
103
|
+
interface HTMLElementTagNameMap {
|
|
104
|
+
'btu-tab': Tab;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export {};
|
|
108
|
+
//# sourceMappingURL=Tab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/Tab.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAA;AAK/C,OAAO,mBAAmB,CAAA;AAC1B,OAAO,iBAAiB,CAAA;AAExB,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,YAAY,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,QAAyC;IACxE,MAAM,KAAK,OAAO,WAEjB;IAED;;;OAGG;IAEH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;;OAGG;IAEH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;OAGG;IAEH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;OAGG;IAEH,QAAQ,UAAQ;IAEhB;;;OAGG;IAEH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;OAGG;IAEH,YAAY,EAAE,SAAS,GAAG,UAAU,CAAY;IAEhD;;;OAGG;IAEH,QAAQ,UAAQ;IAEhB;;;OAGG;IAEH,KAAK,UAAQ;IAEb;;;OAGG;IAEH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd,oDAAoD;IACpD,OAAO,UAAQ;IAEf,6DAA6D;IAC7D,SAAS,SAAK;IAEd,uCAAuC;IACvC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAO;IAEtC,gBAAgB;IAChB,OAAO,CAAC,cAAc,CAAe;IAErC,iBAAiB,IAAI,IAAI;IAOzB,gBAAgB;IAIhB,UAAU,IAAI,IAAI;IAIlB,YAAY,IAAI,IAAI;IAIpB,gBAAgB;IAChB,OAAO,CAAC,WAAW;IAKnB,MAAM;CAkCP;AAMD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,SAAS,EAAE,GAAG,CAAA;KACf;CACF"}
|
|
@@ -0,0 +1,152 @@
|
|
|
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, nothing } from 'lit';
|
|
8
|
+
import { property } from 'lit/decorators.js';
|
|
9
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
10
|
+
import { EventEmitterMixin } from '../../util/EventEmitterMixin.js';
|
|
11
|
+
import { ReadyMixin } from '../../util/ReadyMixin.js';
|
|
12
|
+
import '../badge/Badge.js';
|
|
13
|
+
import '../icon/Icon.js';
|
|
14
|
+
/**
|
|
15
|
+
* An individual tab within a tab group.
|
|
16
|
+
*
|
|
17
|
+
* Renders a button with role="tab" that participates in keyboard navigation
|
|
18
|
+
* and selection state managed by the parent `btu-tabs` container.
|
|
19
|
+
*
|
|
20
|
+
* @element btu-tab
|
|
21
|
+
*
|
|
22
|
+
* @fires {CustomEvent} btu-tab-ready - Fired after first render
|
|
23
|
+
* @fires {CustomEvent<{name: string}>} btu-tab-change - Fired when a non-disabled tab with a name is clicked
|
|
24
|
+
*
|
|
25
|
+
* @cssprop --badge-color-background - Background color of the count indicator badge (default: gray-50)
|
|
26
|
+
* @cssprop --badge-color-foreground - Text color of the count indicator badge (default: gray-700)
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```html
|
|
30
|
+
* <btu-tabs>
|
|
31
|
+
* <btu-tab name="main" label="Main"></btu-tab>
|
|
32
|
+
* <btu-tab name="seo" label="SEO"></btu-tab>
|
|
33
|
+
* <btu-tab name="styles" label="Styles" disabled></btu-tab>
|
|
34
|
+
* </btu-tabs>
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export default class Tab extends EventEmitterMixin(ReadyMixin(LitElement)) {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(...arguments);
|
|
40
|
+
/**
|
|
41
|
+
* Whether the tab is disabled and non-interactive.
|
|
42
|
+
* @attr
|
|
43
|
+
*/
|
|
44
|
+
this.disabled = false;
|
|
45
|
+
/**
|
|
46
|
+
* Placement of the icon relative to the label.
|
|
47
|
+
* @attr icon-position
|
|
48
|
+
*/
|
|
49
|
+
this.iconPosition = 'leading';
|
|
50
|
+
/**
|
|
51
|
+
* When true, hides the label visually while maintaining accessibility.
|
|
52
|
+
* @attr icon-only
|
|
53
|
+
*/
|
|
54
|
+
this.iconOnly = false;
|
|
55
|
+
/**
|
|
56
|
+
* When true, displays an error badge on the tab.
|
|
57
|
+
* @attr
|
|
58
|
+
*/
|
|
59
|
+
this.error = false;
|
|
60
|
+
/** @internal Active state set by parent btu-tabs */
|
|
61
|
+
this._active = false;
|
|
62
|
+
/** @internal Roving tabindex value set by parent btu-tabs */
|
|
63
|
+
this._tabindex = -1;
|
|
64
|
+
/** @internal Set by parent btu-tabs */
|
|
65
|
+
this.size = 'md';
|
|
66
|
+
/** @internal */
|
|
67
|
+
this.initialClasses = [];
|
|
68
|
+
}
|
|
69
|
+
static get tagName() {
|
|
70
|
+
return 'BTU-TAB';
|
|
71
|
+
}
|
|
72
|
+
connectedCallback() {
|
|
73
|
+
super.connectedCallback();
|
|
74
|
+
if (this.className) {
|
|
75
|
+
this.initialClasses = this.className.split(' ').filter(c => c.trim());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
createRenderRoot() {
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
willUpdate() {
|
|
82
|
+
this.className = [...this.initialClasses, 'btu-tab'].filter(Boolean).join(' ');
|
|
83
|
+
}
|
|
84
|
+
firstUpdated() {
|
|
85
|
+
this.emit('btu-tab-ready');
|
|
86
|
+
}
|
|
87
|
+
/** @internal */
|
|
88
|
+
handleClick() {
|
|
89
|
+
if (this.disabled || !this.name)
|
|
90
|
+
return;
|
|
91
|
+
this.emit('btu-tab-change', { name: this.name });
|
|
92
|
+
}
|
|
93
|
+
render() {
|
|
94
|
+
const iconTemplate = this.iconName
|
|
95
|
+
? html `<btu-icon symbol="${this.iconName}" size="${this.size === 'lg' ? 'md' : 'sm'}"></btu-icon>`
|
|
96
|
+
: nothing;
|
|
97
|
+
const labelTemplate = this.iconOnly && this.iconName ? nothing : html `<span>${this.label}</span>`;
|
|
98
|
+
const badgeTemplate = this.badge != null ? html `<btu-badge size="sm">${this.badge}</btu-badge>` : nothing;
|
|
99
|
+
const errorDot = this.error ? html `<btu-badge size="sm" variant="error">!</btu-badge>` : nothing;
|
|
100
|
+
const indicator = this._active && !this.disabled
|
|
101
|
+
? html `<span
|
|
102
|
+
class="btu-tab-indicator"
|
|
103
|
+
style=${styleMap(this.error ? { background: 'oklch(var(--btu-theme-error-600))' } : {})}
|
|
104
|
+
></span>`
|
|
105
|
+
: nothing;
|
|
106
|
+
return html `<button
|
|
107
|
+
type="button"
|
|
108
|
+
role="tab"
|
|
109
|
+
class="btu-tab-button btu-tab-button-${this.size}"
|
|
110
|
+
aria-selected="${this._active}"
|
|
111
|
+
aria-disabled="${this.disabled || nothing}"
|
|
112
|
+
aria-description="${this.description || nothing}"
|
|
113
|
+
aria-label="${this.iconOnly && this.label ? this.label : nothing}"
|
|
114
|
+
tabindex="${this._tabindex}"
|
|
115
|
+
@click=${this.handleClick}
|
|
116
|
+
>
|
|
117
|
+
${this.iconPosition === 'leading' ? iconTemplate : nothing} ${labelTemplate}
|
|
118
|
+
${this.iconPosition === 'trailing' ? iconTemplate : nothing} ${badgeTemplate} ${errorDot} ${indicator}
|
|
119
|
+
</button>`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
__decorate([
|
|
123
|
+
property({ type: String, attribute: 'name', reflect: true })
|
|
124
|
+
], Tab.prototype, "name", void 0);
|
|
125
|
+
__decorate([
|
|
126
|
+
property({ type: String })
|
|
127
|
+
], Tab.prototype, "label", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
property({ type: String })
|
|
130
|
+
], Tab.prototype, "description", void 0);
|
|
131
|
+
__decorate([
|
|
132
|
+
property({ type: Boolean, reflect: true })
|
|
133
|
+
], Tab.prototype, "disabled", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
property({ type: String, attribute: 'icon-name' })
|
|
136
|
+
], Tab.prototype, "iconName", void 0);
|
|
137
|
+
__decorate([
|
|
138
|
+
property({ type: String, attribute: 'icon-position' })
|
|
139
|
+
], Tab.prototype, "iconPosition", void 0);
|
|
140
|
+
__decorate([
|
|
141
|
+
property({ type: Boolean, attribute: 'icon-only' })
|
|
142
|
+
], Tab.prototype, "iconOnly", void 0);
|
|
143
|
+
__decorate([
|
|
144
|
+
property({ type: Boolean, attribute: 'error' })
|
|
145
|
+
], Tab.prototype, "error", void 0);
|
|
146
|
+
__decorate([
|
|
147
|
+
property({ attribute: 'badge' })
|
|
148
|
+
], Tab.prototype, "badge", void 0);
|
|
149
|
+
if (!customElements.get('btu-tab')) {
|
|
150
|
+
customElements.define('btu-tab', Tab);
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=Tab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tab.js","sourceRoot":"","sources":["../../../src/components/tabs/Tab.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,mBAAmB,CAAA;AAC1B,OAAO,iBAAiB,CAAA;AAcxB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,iBAAiB,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAA1E;;QA0BE;;;WAGG;QAEH,aAAQ,GAAG,KAAK,CAAA;QAShB;;;WAGG;QAEH,iBAAY,GAA2B,SAAS,CAAA;QAEhD;;;WAGG;QAEH,aAAQ,GAAG,KAAK,CAAA;QAEhB;;;WAGG;QAEH,UAAK,GAAG,KAAK,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