@nuralyui/button 0.0.11 → 0.0.13
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/{nr-button.component.d.ts → button.component.d.ts} +28 -2
- package/button.component.d.ts.map +1 -0
- package/button.component.js +240 -0
- package/button.component.js.map +1 -0
- package/{nr-button.style.d.ts → button.style.d.ts} +2 -2
- package/button.style.d.ts.map +1 -0
- package/{nr-button.style.js → button.style.js} +176 -127
- package/button.style.js.map +1 -0
- package/button.style.variables.d.ts +11 -0
- package/button.style.variables.d.ts.map +1 -0
- package/button.style.variables.js +194 -0
- package/button.style.variables.js.map +1 -0
- package/{nr-button.types.d.ts → button.types.d.ts} +9 -2
- package/button.types.d.ts.map +1 -0
- package/button.types.js +2 -0
- package/button.types.js.map +1 -0
- package/demo/{nr-buttons-demo.d.ts → buttons-demo.d.ts} +2 -2
- package/demo/buttons-demo.d.ts.map +1 -0
- package/demo/{nr-buttons-demo.js → buttons-demo.js} +64 -2
- package/demo/buttons-demo.js.map +1 -0
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/react.d.ts +1 -1
- package/react.d.ts.map +1 -1
- package/react.js +1 -1
- package/react.js.map +1 -1
- package/test/nr-button_test.d.ts +1 -1
- package/test/nr-button_test.d.ts.map +1 -1
- package/test/nr-button_test.js +2 -2
- package/test/nr-button_test.js.map +1 -1
- package/demo/nr-buttons-demo.d.ts.map +0 -1
- package/demo/nr-buttons-demo.js.map +0 -1
- package/nr-button.component.d.ts.map +0 -1
- package/nr-button.component.js +0 -99
- package/nr-button.component.js.map +0 -1
- package/nr-button.style.d.ts.map +0 -1
- package/nr-button.style.js.map +0 -1
- package/nr-button.types.d.ts.map +0 -1
- package/nr-button.types.js +0 -2
- package/nr-button.types.js.map +0 -1
|
@@ -4,16 +4,21 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
6
|
import { LitElement } from 'lit';
|
|
7
|
-
import { ButtonType, IconPosition } from './
|
|
7
|
+
import { ButtonType, ButtonShape, IconPosition } from './button.types.js';
|
|
8
8
|
declare const NrButtonElement_base: (new (...args: any[]) => import("../../shared/dependency-mixin.js").DependencyAware) & (new (...args: any[]) => import("../../shared/theme-mixin.js").ThemeAware) & typeof LitElement;
|
|
9
9
|
export declare class NrButtonElement extends NrButtonElement_base {
|
|
10
10
|
disabled: boolean;
|
|
11
11
|
loading: boolean;
|
|
12
12
|
size: string;
|
|
13
13
|
type: ButtonType;
|
|
14
|
+
shape: ButtonShape;
|
|
15
|
+
block: boolean;
|
|
14
16
|
dashed: boolean;
|
|
15
17
|
icon: string[];
|
|
16
18
|
iconPosition: IconPosition;
|
|
19
|
+
href: string;
|
|
20
|
+
target: string;
|
|
21
|
+
ripple: boolean;
|
|
17
22
|
/**
|
|
18
23
|
* Required components that must be registered for this component to work properly
|
|
19
24
|
* Can be overridden by parent implementations
|
|
@@ -23,14 +28,35 @@ export declare class NrButtonElement extends NrButtonElement_base {
|
|
|
23
28
|
* Check for required dependencies when component is connected to DOM
|
|
24
29
|
*/
|
|
25
30
|
connectedCallback(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get the appropriate element tag based on button type
|
|
33
|
+
*/
|
|
34
|
+
private getElementTag;
|
|
35
|
+
/**
|
|
36
|
+
* Get attributes for accessibility and functionality
|
|
37
|
+
*/
|
|
38
|
+
private getElementAttributes;
|
|
39
|
+
buttonAriaLabel: string;
|
|
40
|
+
ariaDescribedBy: string;
|
|
41
|
+
htmlType: string;
|
|
26
42
|
/**
|
|
27
43
|
* Renders an icon if the hy-icon component is available
|
|
28
44
|
* @param iconName - The name of the icon to render
|
|
29
45
|
* @returns TemplateResult or nothing
|
|
30
46
|
*/
|
|
31
47
|
private renderIcon;
|
|
48
|
+
/**
|
|
49
|
+
* Creates ripple effect on button click
|
|
50
|
+
* @param event - The click event
|
|
51
|
+
*/
|
|
52
|
+
private createRipple;
|
|
53
|
+
/**
|
|
54
|
+
* Handle click events with ripple effect
|
|
55
|
+
* @param event - The click event
|
|
56
|
+
*/
|
|
57
|
+
private handleClick;
|
|
32
58
|
render(): import("lit").TemplateResult<1>;
|
|
33
59
|
static styles: import("lit").CSSResult[];
|
|
34
60
|
}
|
|
35
61
|
export {};
|
|
36
|
-
//# sourceMappingURL=
|
|
62
|
+
//# sourceMappingURL=button.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.component.d.ts","sourceRoot":"","sources":["../../../src/components/button/button.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,UAAU,EAAW,MAAM,KAAK,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAgB,YAAY,EAAE,MAAM,mBAAmB,CAAC;;AAIxF,qBACa,eAAgB,SAAQ,oBAA6B;IAEhE,QAAQ,UAAS;IAGjB,OAAO,UAAS;IAGhB,IAAI,SAAgB;IAGpB,IAAI,EAAE,UAAU,CAAsB;IAGtC,KAAK,EAAE,WAAW,CAAuB;IAGzC,KAAK,UAAS;IAGd,MAAM,UAAS;IAGf,IAAI,EAAE,MAAM,EAAE,CAAM;IAGpB,YAAY,eAAqB;IAGjC,IAAI,SAAgB;IAGpB,MAAM,SAAgB;IAGtB,MAAM,UAAQ;IAEd;;;OAGG;IACM,kBAAkB,WAAe;IAE1C;;OAEG;IACM,iBAAiB;IAK1B;;OAEG;IACH,OAAO,CAAC,aAAa;IAIrB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAoC5B,eAAe,SAAgB;IAG/B,eAAe,SAAgB;IAG/B,QAAQ,SAAgB;IAExB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAWlB;;;OAGG;IACH,OAAO,CAAC,YAAY;IA2BpB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAIV,MAAM;IAwDf,OAAgB,MAAM,4BAAU;CACjC"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Nuraly, Laabidi Aymen
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
+
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;
|
|
10
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
+
};
|
|
12
|
+
import { html, LitElement, nothing } from 'lit';
|
|
13
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
14
|
+
import { EMPTY_STRING } from './button.types.js';
|
|
15
|
+
import { styles } from './button.style.js';
|
|
16
|
+
import { NuralyUIBaseMixin } from '../../shared/base-mixin.js';
|
|
17
|
+
let NrButtonElement = class NrButtonElement extends NuralyUIBaseMixin(LitElement) {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.disabled = false;
|
|
21
|
+
this.loading = false;
|
|
22
|
+
this.size = EMPTY_STRING;
|
|
23
|
+
this.type = "default" /* ButtonType.Default */;
|
|
24
|
+
this.shape = "default" /* ButtonShape.Default */;
|
|
25
|
+
this.block = false;
|
|
26
|
+
this.dashed = false;
|
|
27
|
+
this.icon = [];
|
|
28
|
+
this.iconPosition = "left" /* IconPosition.Left */;
|
|
29
|
+
this.href = EMPTY_STRING;
|
|
30
|
+
this.target = EMPTY_STRING;
|
|
31
|
+
this.ripple = true;
|
|
32
|
+
/**
|
|
33
|
+
* Required components that must be registered for this component to work properly
|
|
34
|
+
* Can be overridden by parent implementations
|
|
35
|
+
*/
|
|
36
|
+
this.requiredComponents = ['hy-icon'];
|
|
37
|
+
this.buttonAriaLabel = EMPTY_STRING;
|
|
38
|
+
this.ariaDescribedBy = EMPTY_STRING;
|
|
39
|
+
this.htmlType = EMPTY_STRING;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Check for required dependencies when component is connected to DOM
|
|
43
|
+
*/
|
|
44
|
+
connectedCallback() {
|
|
45
|
+
super.connectedCallback();
|
|
46
|
+
this.validateDependencies();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get the appropriate element tag based on button type
|
|
50
|
+
*/
|
|
51
|
+
getElementTag() {
|
|
52
|
+
return this.type === "link" /* ButtonType.Link */ && this.href ? 'a' : 'button';
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get attributes for accessibility and functionality
|
|
56
|
+
*/
|
|
57
|
+
getElementAttributes() {
|
|
58
|
+
const attributes = {
|
|
59
|
+
'?disabled': this.disabled && this.type !== "link" /* ButtonType.Link */,
|
|
60
|
+
'data-type': this.type,
|
|
61
|
+
'data-shape': this.shape,
|
|
62
|
+
'data-size': this.size ? this.size : nothing,
|
|
63
|
+
'data-state': this.loading ? 'loading' : nothing,
|
|
64
|
+
'data-theme': this.currentTheme,
|
|
65
|
+
'data-block': this.block ? 'true' : nothing,
|
|
66
|
+
'class': this.dashed ? 'button-dashed' : '',
|
|
67
|
+
'role': this.type === "link" /* ButtonType.Link */ ? 'link' : 'button',
|
|
68
|
+
'aria-disabled': this.disabled ? 'true' : 'false',
|
|
69
|
+
'aria-label': this.buttonAriaLabel || nothing,
|
|
70
|
+
'aria-describedby': this.ariaDescribedBy || nothing,
|
|
71
|
+
};
|
|
72
|
+
// Add link-specific attributes
|
|
73
|
+
if (this.type === "link" /* ButtonType.Link */ && this.href) {
|
|
74
|
+
attributes.href = this.href;
|
|
75
|
+
if (this.target) {
|
|
76
|
+
attributes.target = this.target;
|
|
77
|
+
}
|
|
78
|
+
if (this.target === '_blank') {
|
|
79
|
+
attributes.rel = 'noopener noreferrer';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Add button-specific attributes
|
|
83
|
+
if (this.type !== "link" /* ButtonType.Link */) {
|
|
84
|
+
attributes.type = this.htmlType || 'button';
|
|
85
|
+
}
|
|
86
|
+
return attributes;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Renders an icon if the hy-icon component is available
|
|
90
|
+
* @param iconName - The name of the icon to render
|
|
91
|
+
* @returns TemplateResult or nothing
|
|
92
|
+
*/
|
|
93
|
+
renderIcon(iconName) {
|
|
94
|
+
if (!this.isComponentAvailable('hy-icon')) {
|
|
95
|
+
console.warn(`hy-icon component not found. Icon "${iconName}" will not be displayed. ` +
|
|
96
|
+
`Please import hy-icon component.`);
|
|
97
|
+
return nothing;
|
|
98
|
+
}
|
|
99
|
+
return html `<hy-icon name=${iconName}></hy-icon>`;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Creates ripple effect on button click
|
|
103
|
+
* @param event - The click event
|
|
104
|
+
*/
|
|
105
|
+
createRipple(event) {
|
|
106
|
+
if (!this.ripple || this.disabled)
|
|
107
|
+
return;
|
|
108
|
+
const button = event.currentTarget;
|
|
109
|
+
const rect = button.getBoundingClientRect();
|
|
110
|
+
const size = Math.max(rect.width, rect.height);
|
|
111
|
+
const x = event.clientX - rect.left - size / 2;
|
|
112
|
+
const y = event.clientY - rect.top - size / 2;
|
|
113
|
+
const ripple = document.createElement('span');
|
|
114
|
+
ripple.className = 'ripple';
|
|
115
|
+
ripple.style.width = ripple.style.height = size + 'px';
|
|
116
|
+
ripple.style.left = x + 'px';
|
|
117
|
+
ripple.style.top = y + 'px';
|
|
118
|
+
// Remove any existing ripples
|
|
119
|
+
const existingRipples = button.querySelectorAll('.ripple');
|
|
120
|
+
existingRipples.forEach(r => r.remove());
|
|
121
|
+
button.appendChild(ripple);
|
|
122
|
+
// Remove ripple after animation
|
|
123
|
+
setTimeout(() => {
|
|
124
|
+
ripple.remove();
|
|
125
|
+
}, 600);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Handle click events with ripple effect
|
|
129
|
+
* @param event - The click event
|
|
130
|
+
*/
|
|
131
|
+
handleClick(event) {
|
|
132
|
+
this.createRipple(event);
|
|
133
|
+
}
|
|
134
|
+
render() {
|
|
135
|
+
var _a, _b, _c, _d;
|
|
136
|
+
const elementTag = this.getElementTag();
|
|
137
|
+
const attributes = this.getElementAttributes();
|
|
138
|
+
if (elementTag === 'a') {
|
|
139
|
+
return html `
|
|
140
|
+
<a
|
|
141
|
+
href="${attributes.href}"
|
|
142
|
+
target="${attributes.target || nothing}"
|
|
143
|
+
rel="${attributes.rel || nothing}"
|
|
144
|
+
data-type="${attributes['data-type']}"
|
|
145
|
+
data-shape="${attributes['data-shape']}"
|
|
146
|
+
data-size="${attributes['data-size']}"
|
|
147
|
+
data-state="${attributes['data-state']}"
|
|
148
|
+
data-theme="${attributes['data-theme']}"
|
|
149
|
+
data-block="${attributes['data-block']}"
|
|
150
|
+
class="${attributes.class}"
|
|
151
|
+
role="${attributes.role}"
|
|
152
|
+
aria-disabled="${attributes['aria-disabled']}"
|
|
153
|
+
aria-label="${attributes['aria-label']}"
|
|
154
|
+
aria-describedby="${attributes['aria-describedby']}"
|
|
155
|
+
>
|
|
156
|
+
<span id="container">
|
|
157
|
+
${((_a = this.icon) === null || _a === void 0 ? void 0 : _a.length) ? this.renderIcon(this.icon[0]) : nothing}
|
|
158
|
+
<slot id="slot"></slot>
|
|
159
|
+
${((_b = this.icon) === null || _b === void 0 ? void 0 : _b.length) == 2 ? this.renderIcon(this.icon[1]) : nothing}
|
|
160
|
+
</span>
|
|
161
|
+
</a>
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
return html `
|
|
165
|
+
<button
|
|
166
|
+
?disabled="${attributes['?disabled']}"
|
|
167
|
+
type="${attributes.type || nothing}"
|
|
168
|
+
data-type="${attributes['data-type']}"
|
|
169
|
+
data-shape="${attributes['data-shape']}"
|
|
170
|
+
data-size="${attributes['data-size']}"
|
|
171
|
+
data-state="${attributes['data-state']}"
|
|
172
|
+
data-theme="${attributes['data-theme']}"
|
|
173
|
+
data-block="${attributes['data-block']}"
|
|
174
|
+
class="${attributes.class}"
|
|
175
|
+
role="${attributes.role}"
|
|
176
|
+
aria-disabled="${attributes['aria-disabled']}"
|
|
177
|
+
aria-label="${attributes['aria-label']}"
|
|
178
|
+
aria-describedby="${attributes['aria-describedby']}"
|
|
179
|
+
@click="${this.handleClick}"
|
|
180
|
+
>
|
|
181
|
+
<span id="container">
|
|
182
|
+
${((_c = this.icon) === null || _c === void 0 ? void 0 : _c.length) ? this.renderIcon(this.icon[0]) : nothing}
|
|
183
|
+
<slot id="slot"></slot>
|
|
184
|
+
${((_d = this.icon) === null || _d === void 0 ? void 0 : _d.length) == 2 ? this.renderIcon(this.icon[1]) : nothing}
|
|
185
|
+
</span>
|
|
186
|
+
</button>
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
NrButtonElement.styles = styles;
|
|
191
|
+
__decorate([
|
|
192
|
+
property({ type: Boolean })
|
|
193
|
+
], NrButtonElement.prototype, "disabled", void 0);
|
|
194
|
+
__decorate([
|
|
195
|
+
property({ type: Boolean })
|
|
196
|
+
], NrButtonElement.prototype, "loading", void 0);
|
|
197
|
+
__decorate([
|
|
198
|
+
property({ type: String })
|
|
199
|
+
], NrButtonElement.prototype, "size", void 0);
|
|
200
|
+
__decorate([
|
|
201
|
+
property({ type: String })
|
|
202
|
+
], NrButtonElement.prototype, "type", void 0);
|
|
203
|
+
__decorate([
|
|
204
|
+
property({ type: String })
|
|
205
|
+
], NrButtonElement.prototype, "shape", void 0);
|
|
206
|
+
__decorate([
|
|
207
|
+
property({ type: Boolean })
|
|
208
|
+
], NrButtonElement.prototype, "block", void 0);
|
|
209
|
+
__decorate([
|
|
210
|
+
property({ type: Boolean })
|
|
211
|
+
], NrButtonElement.prototype, "dashed", void 0);
|
|
212
|
+
__decorate([
|
|
213
|
+
property({ type: Array })
|
|
214
|
+
], NrButtonElement.prototype, "icon", void 0);
|
|
215
|
+
__decorate([
|
|
216
|
+
property({ reflect: true })
|
|
217
|
+
], NrButtonElement.prototype, "iconPosition", void 0);
|
|
218
|
+
__decorate([
|
|
219
|
+
property({ type: String })
|
|
220
|
+
], NrButtonElement.prototype, "href", void 0);
|
|
221
|
+
__decorate([
|
|
222
|
+
property({ type: String })
|
|
223
|
+
], NrButtonElement.prototype, "target", void 0);
|
|
224
|
+
__decorate([
|
|
225
|
+
property({ type: Boolean })
|
|
226
|
+
], NrButtonElement.prototype, "ripple", void 0);
|
|
227
|
+
__decorate([
|
|
228
|
+
property({ type: String })
|
|
229
|
+
], NrButtonElement.prototype, "buttonAriaLabel", void 0);
|
|
230
|
+
__decorate([
|
|
231
|
+
property({ type: String })
|
|
232
|
+
], NrButtonElement.prototype, "ariaDescribedBy", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
property({ type: String })
|
|
235
|
+
], NrButtonElement.prototype, "htmlType", void 0);
|
|
236
|
+
NrButtonElement = __decorate([
|
|
237
|
+
customElement('nr-button')
|
|
238
|
+
], NrButtonElement);
|
|
239
|
+
export { NrButtonElement };
|
|
240
|
+
//# sourceMappingURL=button.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.component.js","sourceRoot":"","sources":["../../../src/components/button/button.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAA2B,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,IAA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AAQ,CAAC,EAAC,IAAI,EAAE,KAAK,EAAC,CAAC;6CACJ;AAGpB;IADC,QAAQ,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC;qDACO;AAGjC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;6CACL;AAGpB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;+CACH;AAGtB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;+CACZ;AA8Dd;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;wDACM;AAG/B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;wDACM;AAG/B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;iDACD;AAvGb,eAAe;IAD3B,aAAa,CAAC,WAAW,CAAC;GACd,eAAe,CAyN3B;SAzNY,eAAe","sourcesContent":["/**\n * @license\n * Copyright 2023 Nuraly, Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport { html, LitElement, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { ButtonType, ButtonShape, EMPTY_STRING, IconPosition } from './button.types.js';\nimport { styles } from './button.style.js';\nimport { NuralyUIBaseMixin } from '../../shared/base-mixin.js';\n\n@customElement('nr-button')\nexport class NrButtonElement extends NuralyUIBaseMixin(LitElement) {\n @property({type: Boolean})\n disabled = false;\n\n @property({type: Boolean})\n loading = false;\n\n @property({type: String})\n size = EMPTY_STRING;\n\n @property({type: String})\n type: ButtonType = ButtonType.Default;\n\n @property({type: String})\n shape: ButtonShape = ButtonShape.Default;\n\n @property({type: Boolean})\n block = false;\n\n @property({type: Boolean})\n dashed = false;\n\n @property({type: Array})\n icon: string[] = [];\n\n @property({reflect: true})\n iconPosition = IconPosition.Left;\n\n @property({type: String})\n href = EMPTY_STRING;\n\n @property({type: String})\n target = EMPTY_STRING;\n\n @property({type: Boolean})\n ripple = true;\n\n /**\n * Required components that must be registered for this component to work properly\n * Can be overridden by parent implementations\n */\n override requiredComponents = ['hy-icon'];\n\n /**\n * Check for required dependencies when component is connected to DOM\n */\n override connectedCallback() {\n super.connectedCallback();\n this.validateDependencies();\n }\n\n /**\n * Get the appropriate element tag based on button type\n */\n private getElementTag() {\n return this.type === ButtonType.Link && this.href ? 'a' : 'button';\n }\n\n /**\n * Get attributes for accessibility and functionality\n */\n private getElementAttributes() {\n const attributes: any = {\n '?disabled': this.disabled && this.type !== ButtonType.Link,\n 'data-type': this.type,\n 'data-shape': this.shape,\n 'data-size': this.size ? this.size : nothing,\n 'data-state': this.loading ? 'loading' : nothing,\n 'data-theme': this.currentTheme,\n 'data-block': this.block ? 'true' : nothing,\n 'class': this.dashed ? 'button-dashed' : '',\n 'role': this.type === ButtonType.Link ? 'link' : 'button',\n 'aria-disabled': this.disabled ? 'true' : 'false',\n 'aria-label': this.buttonAriaLabel || nothing,\n 'aria-describedby': this.ariaDescribedBy || nothing,\n };\n\n // Add link-specific attributes\n if (this.type === ButtonType.Link && this.href) {\n attributes.href = this.href;\n if (this.target) {\n attributes.target = this.target;\n }\n if (this.target === '_blank') {\n attributes.rel = 'noopener noreferrer';\n }\n }\n\n // Add button-specific attributes\n if (this.type !== ButtonType.Link) {\n attributes.type = this.htmlType || 'button';\n }\n\n return attributes;\n }\n\n @property({type: String})\n buttonAriaLabel = EMPTY_STRING;\n\n @property({type: String})\n ariaDescribedBy = EMPTY_STRING;\n\n @property({type: String})\n htmlType = EMPTY_STRING;\n\n /**\n * Renders an icon if the hy-icon component is available\n * @param iconName - The name of the icon to render\n * @returns TemplateResult or nothing\n */\n private renderIcon(iconName: string) {\n if (!this.isComponentAvailable('hy-icon')) {\n console.warn(\n `hy-icon component not found. Icon \"${iconName}\" will not be displayed. ` +\n `Please import hy-icon component.`\n );\n return nothing;\n }\n return html`<hy-icon name=${iconName}></hy-icon>`;\n }\n\n /**\n * Creates ripple effect on button click\n * @param event - The click event\n */\n private createRipple(event: MouseEvent) {\n if (!this.ripple || this.disabled) return;\n\n const button = event.currentTarget as HTMLElement;\n const rect = button.getBoundingClientRect();\n const size = Math.max(rect.width, rect.height);\n const x = event.clientX - rect.left - size / 2;\n const y = event.clientY - rect.top - size / 2;\n\n const ripple = document.createElement('span');\n ripple.className = 'ripple';\n ripple.style.width = ripple.style.height = size + 'px';\n ripple.style.left = x + 'px';\n ripple.style.top = y + 'px';\n\n // Remove any existing ripples\n const existingRipples = button.querySelectorAll('.ripple');\n existingRipples.forEach(r => r.remove());\n\n button.appendChild(ripple);\n\n // Remove ripple after animation\n setTimeout(() => {\n ripple.remove();\n }, 600);\n }\n\n /**\n * Handle click events with ripple effect\n * @param event - The click event\n */\n private handleClick(event: MouseEvent) {\n this.createRipple(event);\n }\n\n override render() {\n const elementTag = this.getElementTag();\n const attributes = this.getElementAttributes();\n \n if (elementTag === 'a') {\n return html`\n <a\n href=\"${attributes.href}\"\n target=\"${attributes.target || nothing}\"\n rel=\"${attributes.rel || nothing}\"\n data-type=\"${attributes['data-type']}\"\n data-shape=\"${attributes['data-shape']}\"\n data-size=\"${attributes['data-size']}\"\n data-state=\"${attributes['data-state']}\"\n data-theme=\"${attributes['data-theme']}\"\n data-block=\"${attributes['data-block']}\"\n class=\"${attributes.class}\"\n role=\"${attributes.role}\"\n aria-disabled=\"${attributes['aria-disabled']}\"\n aria-label=\"${attributes['aria-label']}\"\n aria-describedby=\"${attributes['aria-describedby']}\"\n >\n <span id=\"container\">\n ${this.icon?.length ? this.renderIcon(this.icon[0]) : nothing}\n <slot id=\"slot\"></slot>\n ${this.icon?.length == 2 ? this.renderIcon(this.icon[1]) : nothing}\n </span>\n </a>\n `;\n }\n \n return html`\n <button\n ?disabled=\"${attributes['?disabled']}\"\n type=\"${attributes.type || nothing}\"\n data-type=\"${attributes['data-type']}\"\n data-shape=\"${attributes['data-shape']}\"\n data-size=\"${attributes['data-size']}\"\n data-state=\"${attributes['data-state']}\"\n data-theme=\"${attributes['data-theme']}\"\n data-block=\"${attributes['data-block']}\"\n class=\"${attributes.class}\"\n role=\"${attributes.role}\"\n aria-disabled=\"${attributes['aria-disabled']}\"\n aria-label=\"${attributes['aria-label']}\"\n aria-describedby=\"${attributes['aria-describedby']}\"\n @click=\"${this.handleClick}\"\n >\n <span id=\"container\">\n ${this.icon?.length ? this.renderIcon(this.icon[0]) : nothing}\n <slot id=\"slot\"></slot>\n ${this.icon?.length == 2 ? this.renderIcon(this.icon[1]) : nothing}\n </span>\n </button>\n `;\n }\n static override styles = styles;\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @description
|
|
5
5
|
* This export provides the complete styling system for the button component,
|
|
6
|
-
* including all variants, states, sizes, and
|
|
6
|
+
* including all variants, states, sizes, theme support, and CSS custom properties.
|
|
7
7
|
*
|
|
8
8
|
* @usage
|
|
9
9
|
* Import and use in the component's styles property:
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
export declare const styles: import("lit").CSSResult[];
|
|
19
|
-
//# sourceMappingURL=
|
|
19
|
+
//# sourceMappingURL=button.style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.style.d.ts","sourceRoot":"","sources":["../../../src/components/button/button.style.ts"],"names":[],"mappings":"AA4mBA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,MAAM,2BAAkC,CAAC"}
|