@nuralyui/button 0.0.14 → 0.0.15

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.
Files changed (43) hide show
  1. package/bundle.js +921 -0
  2. package/button.component.d.ts +65 -25
  3. package/button.component.js +138 -52
  4. package/button.component.js.map +1 -1
  5. package/button.style.d.ts +6 -15
  6. package/button.style.js +406 -545
  7. package/button.style.js.map +1 -1
  8. package/button.types.d.ts +38 -2
  9. package/button.types.js.map +1 -1
  10. package/package.json +29 -2
  11. package/button.component.d.ts.map +0 -1
  12. package/button.style.d.ts.map +0 -1
  13. package/button.style.variables.d.ts +0 -11
  14. package/button.style.variables.d.ts.map +0 -1
  15. package/button.style.variables.js +0 -194
  16. package/button.style.variables.js.map +0 -1
  17. package/button.types.d.ts.map +0 -1
  18. package/demo/buttons-demo.d.ts +0 -17
  19. package/demo/buttons-demo.d.ts.map +0 -1
  20. package/demo/buttons-demo.js +0 -273
  21. package/demo/buttons-demo.js.map +0 -1
  22. package/index.d.ts.map +0 -1
  23. package/mixins/index.d.ts +0 -14
  24. package/mixins/index.d.ts.map +0 -1
  25. package/mixins/index.js +0 -10
  26. package/mixins/index.js.map +0 -1
  27. package/mixins/keyboard-mixin.d.ts +0 -52
  28. package/mixins/keyboard-mixin.d.ts.map +0 -1
  29. package/mixins/keyboard-mixin.js +0 -78
  30. package/mixins/keyboard-mixin.js.map +0 -1
  31. package/mixins/link-mixin.d.ts +0 -67
  32. package/mixins/link-mixin.d.ts.map +0 -1
  33. package/mixins/link-mixin.js +0 -87
  34. package/mixins/link-mixin.js.map +0 -1
  35. package/mixins/ripple-mixin.d.ts +0 -53
  36. package/mixins/ripple-mixin.d.ts.map +0 -1
  37. package/mixins/ripple-mixin.js +0 -77
  38. package/mixins/ripple-mixin.js.map +0 -1
  39. package/react.d.ts.map +0 -1
  40. package/test/nr-button_test.d.ts +0 -2
  41. package/test/nr-button_test.d.ts.map +0 -1
  42. package/test/nr-button_test.js +0 -91
  43. package/test/nr-button_test.js.map +0 -1
@@ -4,54 +4,94 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  */
6
6
  import { LitElement } from 'lit';
7
- import { ButtonType, ButtonShape, IconPosition } from './button.types.js';
8
- declare const NrButtonElement_base: (new (...args: any[]) => import("./mixins/ripple-mixin.js").RippleCapable) & (new (...args: any[]) => import("./mixins/keyboard-mixin.js").KeyboardCapable) & (new (...args: any[]) => import("./mixins/link-mixin.js").LinkCapable) & (new (...args: any[]) => import("../../shared/dependency-mixin.js").DependencyAware) & (new (...args: any[]) => import("../../shared/theme-mixin.js").ThemeAware) & (new (...args: any[]) => import("../../shared/event-handler-mixin.js").EventHandlerCapable) & typeof LitElement;
7
+ import { ButtonType, ButtonSize, ButtonShape, IconPosition, ButtonIcons, ButtonIcon, ButtonIconsConfig } from './button.types.js';
8
+ import '../icon/icon.component.js';
9
+ import { ButtonHost } from './interfaces/index.js';
10
+ declare const NrButtonElement_base: (new (...args: any[]) => import("@nuralyui/common/mixins").DependencyAware) & (new (...args: any[]) => import("@nuralyui/common/mixins").ThemeAware) & (new (...args: any[]) => import("@nuralyui/common/mixins").EventHandlerCapable) & typeof LitElement;
9
11
  /**
10
- * - NuralyUIBaseMixin: Core functionality (theme, dependencies, events)
11
- * - RippleMixin: Ripple effect handling
12
- * - KeyboardMixin: Keyboard interaction (Enter/Space activation)
13
- * - LinkMixin: Link-specific behavior for ButtonType.Link
12
+ * Versatile button component with multiple variants, loading states, and enhanced icon support.
13
+ *
14
+ * @example
15
+ * ```html
16
+ * <!-- Simple usage -->
17
+ * <nr-button type="primary">Click me</nr-button>
18
+ *
19
+ * <!-- Array-based icons (original API) -->
20
+ * <nr-button type="primary" .icon=${['add']}>Add Item</nr-button>
21
+ * <nr-button type="primary" .icon=${['home', 'arrow-right']}>Home</nr-button>
22
+ *
23
+ * <!-- Separate icon properties (new API) -->
24
+ * <nr-button type="primary" iconLeft="home" iconRight="arrow-right">Navigate</nr-button>
25
+ * <nr-button type="primary" .iconLeft=${{name: 'home', color: 'blue'}}>Enhanced</nr-button>
26
+ *
27
+ * <!-- Object-based icons (new API) -->
28
+ * <nr-button type="primary" .icons=${{left: 'home', right: 'arrow-right'}}>Navigate</nr-button>
29
+ *
30
+ * <!-- Loading state -->
31
+ * <nr-button loading>Processing...</nr-button>
32
+ * ```
33
+ *
34
+ * @fires button-clicked - Button clicked
35
+ * @fires link-navigation - Link navigation
36
+ *
37
+ * @slot default - Button text content
14
38
  */
15
- export declare class NrButtonElement extends NrButtonElement_base {
39
+ export declare class NrButtonElement extends NrButtonElement_base implements ButtonHost {
40
+ static styles: import("lit").CSSResult;
41
+ /** Disables the button */
16
42
  disabled: boolean;
43
+ /** Shows loading spinner */
17
44
  loading: boolean;
18
- size: string;
45
+ /** Button size (small, medium, large) */
46
+ size: ButtonSize | '';
47
+ /** Button type (default, primary, secondary, danger, ghost, link) */
19
48
  type: ButtonType;
49
+ /** Button shape (default, circle, round) */
20
50
  shape: ButtonShape;
51
+ /** Makes button full width */
21
52
  block: boolean;
53
+ /** Applies dashed border */
22
54
  dashed: boolean;
23
- icon: string[];
55
+ /** Icon configuration (supports strings or enhanced config objects) */
56
+ icon: ButtonIcons;
57
+ /** Left icon (alternative to icon array) */
58
+ iconLeft?: ButtonIcon;
59
+ /** Right icon (alternative to icon array) */
60
+ iconRight?: ButtonIcon;
61
+ /** Icon configuration object (alternative to icon array) */
62
+ icons?: ButtonIconsConfig;
63
+ /** Icon position relative to text */
24
64
  iconPosition: IconPosition;
65
+ /** URL for link-type buttons */
25
66
  href: string;
67
+ /** Target attribute for links */
26
68
  target: string;
69
+ /** Enables ripple effect */
27
70
  ripple: boolean;
71
+ /** Custom aria-label */
28
72
  buttonAriaLabel: string;
73
+ /** References to descriptive elements */
29
74
  ariaDescribedBy: string;
75
+ /** HTML button type */
30
76
  htmlType: string;
31
- /**
32
- * Required components that must be registered for this component to work properly
33
- */
34
77
  requiredComponents: string[];
35
- /**
36
- * Check for required dependencies when component is connected to DOM
37
- */
78
+ private rippleController;
79
+ private keyboardController;
80
+ private linkController;
38
81
  connectedCallback(): void;
39
- /**
40
- * Get common attributes for both button and anchor elements
41
- */
42
82
  private getCommonAttributes;
83
+ private renderIcon;
84
+ private handleClick;
85
+ private handleKeydown;
43
86
  /**
44
- * Renders an icon if the hy-icon component is available
45
- * @param iconName - The name of the icon to render
46
- * @returns TemplateResult or nothing
87
+ * Get the resolved left icon from various sources
47
88
  */
48
- private renderIcon;
89
+ private getResolvedLeftIcon;
49
90
  /**
50
- * Handle comprehensive click events with proper event dispatching
91
+ * Get the resolved right icon from various sources
51
92
  */
52
- private handleClick;
93
+ private getResolvedRightIcon;
53
94
  render(): import("lit").TemplateResult<1>;
54
- static styles: import("lit").CSSResult[];
55
95
  }
56
96
  export {};
57
97
  //# sourceMappingURL=button.component.d.ts.map
@@ -11,54 +11,85 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
11
11
  };
12
12
  import { html, LitElement, nothing } from 'lit';
13
13
  import { customElement, property } from 'lit/decorators.js';
14
+ import { ifDefined } from 'lit/directives/if-defined.js';
14
15
  import { EMPTY_STRING } from './button.types.js';
15
16
  import { styles } from './button.style.js';
16
- import { NuralyUIBaseMixin } from '../../shared/base-mixin.js';
17
- import { RippleMixin, KeyboardMixin, LinkMixin } from './mixins/index.js';
17
+ import { NuralyUIBaseMixin } from '@nuralyui/common/mixins';
18
+ // Import icon component
19
+ import '../icon/icon.component.js';
20
+ // Import controllers
21
+ import { ButtonRippleController, ButtonKeyboardController, ButtonLinkController } from './controllers/index.js';
18
22
  /**
19
- * - NuralyUIBaseMixin: Core functionality (theme, dependencies, events)
20
- * - RippleMixin: Ripple effect handling
21
- * - KeyboardMixin: Keyboard interaction (Enter/Space activation)
22
- * - LinkMixin: Link-specific behavior for ButtonType.Link
23
+ * Versatile button component with multiple variants, loading states, and enhanced icon support.
24
+ *
25
+ * @example
26
+ * ```html
27
+ * <!-- Simple usage -->
28
+ * <nr-button type="primary">Click me</nr-button>
29
+ *
30
+ * <!-- Array-based icons (original API) -->
31
+ * <nr-button type="primary" .icon=${['add']}>Add Item</nr-button>
32
+ * <nr-button type="primary" .icon=${['home', 'arrow-right']}>Home</nr-button>
33
+ *
34
+ * <!-- Separate icon properties (new API) -->
35
+ * <nr-button type="primary" iconLeft="home" iconRight="arrow-right">Navigate</nr-button>
36
+ * <nr-button type="primary" .iconLeft=${{name: 'home', color: 'blue'}}>Enhanced</nr-button>
37
+ *
38
+ * <!-- Object-based icons (new API) -->
39
+ * <nr-button type="primary" .icons=${{left: 'home', right: 'arrow-right'}}>Navigate</nr-button>
40
+ *
41
+ * <!-- Loading state -->
42
+ * <nr-button loading>Processing...</nr-button>
43
+ * ```
44
+ *
45
+ * @fires button-clicked - Button clicked
46
+ * @fires link-navigation - Link navigation
47
+ *
48
+ * @slot default - Button text content
23
49
  */
24
- let NrButtonElement = class NrButtonElement extends RippleMixin(KeyboardMixin(LinkMixin(NuralyUIBaseMixin(LitElement)))) {
50
+ let NrButtonElement = class NrButtonElement extends NuralyUIBaseMixin(LitElement) {
25
51
  constructor() {
26
52
  super(...arguments);
27
- // Button state properties
53
+ /** Disables the button */
28
54
  this.disabled = false;
55
+ /** Shows loading spinner */
29
56
  this.loading = false;
57
+ /** Button size (small, medium, large) */
30
58
  this.size = EMPTY_STRING;
59
+ /** Button type (default, primary, secondary, danger, ghost, link) */
31
60
  this.type = "default" /* ButtonType.Default */;
61
+ /** Button shape (default, circle, round) */
32
62
  this.shape = "default" /* ButtonShape.Default */;
63
+ /** Makes button full width */
33
64
  this.block = false;
65
+ /** Applies dashed border */
34
66
  this.dashed = false;
35
- // Icon properties
67
+ /** Icon configuration (supports strings or enhanced config objects) */
36
68
  this.icon = [];
69
+ /** Icon position relative to text */
37
70
  this.iconPosition = "left" /* IconPosition.Left */;
38
- // Link properties (inherited from LinkMixin)
71
+ /** URL for link-type buttons */
39
72
  this.href = EMPTY_STRING;
73
+ /** Target attribute for links */
40
74
  this.target = EMPTY_STRING;
41
- // Ripple property (inherited from RippleMixin)
75
+ /** Enables ripple effect */
42
76
  this.ripple = true;
43
- // Accessibility properties
77
+ /** Custom aria-label */
44
78
  this.buttonAriaLabel = EMPTY_STRING;
79
+ /** References to descriptive elements */
45
80
  this.ariaDescribedBy = EMPTY_STRING;
81
+ /** HTML button type */
46
82
  this.htmlType = EMPTY_STRING;
47
- /**
48
- * Required components that must be registered for this component to work properly
49
- */
50
- this.requiredComponents = ['hy-icon'];
83
+ this.requiredComponents = ['nr-icon'];
84
+ // Controllers
85
+ this.rippleController = new ButtonRippleController(this);
86
+ this.keyboardController = new ButtonKeyboardController(this);
87
+ this.linkController = new ButtonLinkController(this);
51
88
  }
52
- /**
53
- * Check for required dependencies when component is connected to DOM
54
- */
55
89
  connectedCallback() {
56
90
  super.connectedCallback();
57
91
  this.validateDependencies();
58
92
  }
59
- /**
60
- * Get common attributes for both button and anchor elements
61
- */
62
93
  getCommonAttributes() {
63
94
  return {
64
95
  'data-type': this.type,
@@ -74,39 +105,53 @@ let NrButtonElement = class NrButtonElement extends RippleMixin(KeyboardMixin(Li
74
105
  'tabindex': this.disabled ? '-1' : '0'
75
106
  };
76
107
  }
77
- /**
78
- * Renders an icon if the hy-icon component is available
79
- * @param iconName - The name of the icon to render
80
- * @returns TemplateResult or nothing
81
- */
82
- renderIcon(iconName) {
83
- if (!this.isComponentAvailable('hy-icon')) {
84
- console.warn(`hy-icon component not found. Icon "${iconName}" will not be displayed. ` +
85
- `Please import hy-icon component.`);
108
+ renderIcon(iconConfig) {
109
+ if (!this.isComponentAvailable('nr-icon')) {
110
+ const iconName = typeof iconConfig === 'string' ? iconConfig : iconConfig.name;
111
+ console.warn(`[nr-button] Icon component 'nr-icon' not available. Icon "${iconName}" will not render. ` +
112
+ `Ensure the icon component is imported and registered.`);
86
113
  return nothing;
87
114
  }
88
- return html `<hy-icon name=${iconName}></hy-icon>`;
115
+ // Get appropriate icon size based on button size
116
+ const getIconSizeForButtonSize = () => {
117
+ switch (this.size) {
118
+ case "small" /* ButtonSize.Small */:
119
+ return 'small';
120
+ case "medium" /* ButtonSize.Medium */:
121
+ return 'medium';
122
+ case "large" /* ButtonSize.Large */:
123
+ return 'large';
124
+ default:
125
+ return 'medium'; // Default to medium if no size specified
126
+ }
127
+ };
128
+ // Handle simple string input (backward compatibility)
129
+ if (typeof iconConfig === 'string') {
130
+ const iconSize = getIconSizeForButtonSize();
131
+ return html `<nr-icon name=${iconConfig} size=${ifDefined(iconSize)}></nr-icon>`;
132
+ }
133
+ // Handle enhanced icon configuration
134
+ const { name, type = 'solid', size, color, alt } = iconConfig;
135
+ // Use explicit size if provided, otherwise use size based on button size
136
+ const resolvedSize = size || getIconSizeForButtonSize();
137
+ const iconSize = resolvedSize;
138
+ return html `<nr-icon
139
+ name=${name}
140
+ type=${type}
141
+ alt=${alt || ''}
142
+ size=${ifDefined(iconSize)}
143
+ color=${color || ''}
144
+ ></nr-icon>`;
89
145
  }
90
- /**
91
- * Handle comprehensive click events with proper event dispatching
92
- */
93
146
  handleClick(event) {
94
147
  if (this.disabled) {
95
148
  event.preventDefault();
96
149
  return;
97
150
  }
98
- // Use RippleMixin method
99
- this.handleRippleClick(event);
100
- // Handle link navigation if it's a link type
101
- if (this.isLinkType()) {
102
- this.dispatchCustomEvent('link-navigation', {
103
- href: this.href,
104
- target: this.target,
105
- timestamp: Date.now(),
106
- originalEvent: event
107
- });
151
+ this.rippleController.handleRippleClick(event);
152
+ if (this.linkController.isLinkType()) {
153
+ this.linkController.handleLinkNavigation(event);
108
154
  }
109
- // Dispatch button event with metadata using EventHandlerMixin
110
155
  this.dispatchEventWithMetadata('button-clicked', {
111
156
  type: this.type,
112
157
  disabled: this.disabled,
@@ -114,16 +159,48 @@ let NrButtonElement = class NrButtonElement extends RippleMixin(KeyboardMixin(Li
114
159
  href: this.href || null
115
160
  });
116
161
  }
117
- render() {
162
+ handleKeydown(event) {
163
+ this.keyboardController.handleKeydown(event);
164
+ }
165
+ /**
166
+ * Get the resolved left icon from various sources
167
+ */
168
+ getResolvedLeftIcon() {
169
+ var _a, _b;
170
+ // Priority: iconLeft > icons.left > icon[0]
171
+ if (this.iconLeft)
172
+ return this.iconLeft;
173
+ if ((_a = this.icons) === null || _a === void 0 ? void 0 : _a.left)
174
+ return this.icons.left;
175
+ if (((_b = this.icon) === null || _b === void 0 ? void 0 : _b.length) > 0)
176
+ return this.icon[0];
177
+ return undefined;
178
+ }
179
+ /**
180
+ * Get the resolved right icon from various sources
181
+ */
182
+ getResolvedRightIcon() {
118
183
  var _a, _b;
119
- const elementTag = this.getElementTag(); // From LinkMixin
184
+ // Priority: iconRight > icons.right > icon[1]
185
+ if (this.iconRight)
186
+ return this.iconRight;
187
+ if ((_a = this.icons) === null || _a === void 0 ? void 0 : _a.right)
188
+ return this.icons.right;
189
+ if (((_b = this.icon) === null || _b === void 0 ? void 0 : _b.length) === 2)
190
+ return this.icon[1];
191
+ return undefined;
192
+ }
193
+ render() {
194
+ const elementTag = this.linkController.getElementTag();
120
195
  const commonAttributes = this.getCommonAttributes();
121
- const linkAttributes = this.getLinkAttributes(); // From LinkMixin
196
+ const linkAttributes = this.linkController.getLinkAttributes();
197
+ const leftIcon = this.getResolvedLeftIcon();
198
+ const rightIcon = this.getResolvedRightIcon();
122
199
  const content = html `
123
- <span id="container">
124
- ${((_a = this.icon) === null || _a === void 0 ? void 0 : _a.length) ? this.renderIcon(this.icon[0]) : nothing}
200
+ <span id="container" part="container">
201
+ ${leftIcon ? this.renderIcon(leftIcon) : nothing}
125
202
  <slot id="slot"></slot>
126
- ${((_b = this.icon) === null || _b === void 0 ? void 0 : _b.length) === 2 ? this.renderIcon(this.icon[1]) : nothing}
203
+ ${rightIcon ? this.renderIcon(rightIcon) : nothing}
127
204
  </span>
128
205
  `;
129
206
  if (elementTag === 'a') {
@@ -200,6 +277,15 @@ __decorate([
200
277
  __decorate([
201
278
  property({ type: Array })
202
279
  ], NrButtonElement.prototype, "icon", void 0);
280
+ __decorate([
281
+ property({ type: Object })
282
+ ], NrButtonElement.prototype, "iconLeft", void 0);
283
+ __decorate([
284
+ property({ type: Object })
285
+ ], NrButtonElement.prototype, "iconRight", void 0);
286
+ __decorate([
287
+ property({ type: Object })
288
+ ], NrButtonElement.prototype, "icons", void 0);
203
289
  __decorate([
204
290
  property({ reflect: true })
205
291
  ], NrButtonElement.prototype, "iconPosition", void 0);
@@ -1 +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;AAC/D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE1E;;;;;GAKG;AAEH,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,WAAW,CAC9C,aAAa,CACX,SAAS,CACP,iBAAiB,CAAC,UAAU,CAAC,CAC9B,CACF,CACF;IAND;;QAOE,0BAA0B;QAEjB,aAAQ,GAAG,KAAK,CAAC;QAG1B,YAAO,GAAG,KAAK,CAAC;QAGhB,SAAI,GAAG,YAAY,CAAC;QAGX,SAAI,sCAAkC;QAG/C,UAAK,uCAAoC;QAGzC,UAAK,GAAG,KAAK,CAAC;QAGd,WAAM,GAAG,KAAK,CAAC;QAEf,kBAAkB;QAElB,SAAI,GAAa,EAAE,CAAC;QAGpB,iBAAY,kCAAqB;QAEjC,6CAA6C;QAEpC,SAAI,GAAG,YAAY,CAAC;QAGpB,WAAM,GAAG,YAAY,CAAC;QAE/B,+CA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,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDACI;AAG/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACH;AAvDb,eAAe;IAD3B,aAAa,CAAC,WAAW,CAAC;GACd,eAAe,CAuM3B;SAvMY,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';\nimport { RippleMixin, KeyboardMixin, LinkMixin } from './mixins/index.js';\n\n/**\n * - NuralyUIBaseMixin: Core functionality (theme, dependencies, events)\n * - RippleMixin: Ripple effect handling\n * - KeyboardMixin: Keyboard interaction (Enter/Space activation)\n * - LinkMixin: Link-specific behavior for ButtonType.Link\n */\n@customElement('nr-button')\nexport class NrButtonElement extends RippleMixin(\n KeyboardMixin(\n LinkMixin(\n NuralyUIBaseMixin(LitElement)\n )\n )\n) {\n // Button state properties\n @property({ type: Boolean })\n override 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 override 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 // Icon properties\n @property({ type: Array })\n icon: string[] = [];\n\n @property({ reflect: true })\n iconPosition = IconPosition.Left;\n\n // Link properties (inherited from LinkMixin)\n @property({ type: String })\n override href = EMPTY_STRING;\n\n @property({ type: String })\n override target = EMPTY_STRING;\n\n // Ripple property (inherited from RippleMixin)\n @property({ type: Boolean })\n override ripple = true;\n\n // Accessibility properties\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 * Required components that must be registered for this component to work properly\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 common attributes for both button and anchor elements\n */\n private getCommonAttributes() {\n return {\n 'data-type': this.type,\n 'data-shape': this.shape,\n 'data-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 'aria-disabled': this.disabled ? 'true' : 'false',\n 'aria-label': this.buttonAriaLabel || nothing,\n 'aria-describedby': this.ariaDescribedBy || nothing,\n 'tabindex': this.disabled ? '-1' : '0'\n };\n }\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 * Handle comprehensive click events with proper event dispatching\n */\n private handleClick(event: MouseEvent) {\n if (this.disabled) {\n event.preventDefault();\n return;\n }\n\n // Use RippleMixin method\n this.handleRippleClick(event);\n \n // Handle link navigation if it's a link type\n if (this.isLinkType()) {\n this.dispatchCustomEvent('link-navigation', {\n href: this.href,\n target: this.target,\n timestamp: Date.now(),\n originalEvent: event\n });\n }\n \n // Dispatch button event with metadata using EventHandlerMixin\n this.dispatchEventWithMetadata('button-clicked', {\n type: this.type,\n disabled: this.disabled,\n loading: this.loading,\n href: this.href || null\n });\n }\n\n override render() {\n const elementTag = this.getElementTag(); // From LinkMixin\n const commonAttributes = this.getCommonAttributes();\n const linkAttributes = this.getLinkAttributes(); // From LinkMixin\n \n const content = html`\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 `;\n \n if (elementTag === 'a') {\n return html`\n <a\n href=\"${linkAttributes.href}\"\n target=\"${linkAttributes.target || nothing}\"\n rel=\"${linkAttributes.rel || nothing}\"\n role=\"${linkAttributes.role}\"\n data-type=\"${commonAttributes['data-type']}\"\n data-shape=\"${commonAttributes['data-shape']}\"\n data-size=\"${commonAttributes['data-size']}\"\n data-state=\"${commonAttributes['data-state']}\"\n data-theme=\"${commonAttributes['data-theme']}\"\n data-block=\"${commonAttributes['data-block']}\"\n class=\"${commonAttributes.class}\"\n aria-disabled=\"${this.disabled}\"\n aria-label=\"${this.buttonAriaLabel || nothing}\"\n aria-describedby=\"${this.ariaDescribedBy || nothing}\"\n tabindex=\"${this.disabled ? -1 : 0}\"\n @click=\"${this.handleClick}\"\n @keydown=\"${this.handleKeydown}\"\n >\n ${content}\n </a>\n `;\n }\n \n return html`\n <button\n ?disabled=\"${this.disabled}\"\n type=\"${(this.htmlType || 'button') as 'button' | 'submit' | 'reset'}\"\n role=\"${linkAttributes.role}\"\n data-type=\"${commonAttributes['data-type']}\"\n data-shape=\"${commonAttributes['data-shape']}\"\n data-size=\"${commonAttributes['data-size']}\" \n data-state=\"${commonAttributes['data-state']}\"\n data-theme=\"${commonAttributes['data-theme']}\"\n data-block=\"${commonAttributes['data-block']}\"\n class=\"${commonAttributes.class}\"\n aria-disabled=\"${this.disabled}\"\n aria-label=\"${this.buttonAriaLabel || nothing}\"\n aria-describedby=\"${this.ariaDescribedBy || nothing}\"\n tabindex=\"${this.disabled ? -1 : 0}\"\n @click=\"${this.handleClick}\"\n @keydown=\"${this.handleKeydown}\"\n >\n ${content}\n </button>\n `;\n }\n static override styles = styles;\n}\n"]}
1
+ {"version":3,"file":"button.component.js","sourceRoot":"","sources":["../../../src/components/button/button.component.ts"],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C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACL;AAItB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDACJ;AAIvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACD;AAI1B;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;qDACmB;AAI/C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CACP;AAIpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CACL;AAItB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CACd;AAId;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDACI;AAI/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDACI;AAI/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACH;AAxEb,eAAe;IAD3B,aAAa,CAAC,WAAW,CAAC;GACd,eAAe,CAwQ3B;SAxQY,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 { ifDefined } from 'lit/directives/if-defined.js';\nimport { ButtonType, ButtonSize, ButtonShape, EMPTY_STRING, IconPosition, ButtonIcons, ButtonIcon, ButtonIconsConfig } from './button.types.js';\nimport { styles } from './button.style.js';\nimport { NuralyUIBaseMixin } from '@nuralyui/common/mixins';\n\n// Import icon component\nimport '../icon/icon.component.js';\n\n// Import controllers\nimport {\n ButtonRippleController,\n ButtonKeyboardController,\n ButtonLinkController\n} from './controllers/index.js';\n\n// Import interfaces\nimport { ButtonHost } from './interfaces/index.js';\n\n/**\n * Versatile button component with multiple variants, loading states, and enhanced icon support.\n * \n * @example\n * ```html\n * <!-- Simple usage -->\n * <nr-button type=\"primary\">Click me</nr-button>\n * \n * <!-- Array-based icons (original API) -->\n * <nr-button type=\"primary\" .icon=${['add']}>Add Item</nr-button>\n * <nr-button type=\"primary\" .icon=${['home', 'arrow-right']}>Home</nr-button>\n * \n * <!-- Separate icon properties (new API) -->\n * <nr-button type=\"primary\" iconLeft=\"home\" iconRight=\"arrow-right\">Navigate</nr-button>\n * <nr-button type=\"primary\" .iconLeft=${{name: 'home', color: 'blue'}}>Enhanced</nr-button>\n * \n * <!-- Object-based icons (new API) -->\n * <nr-button type=\"primary\" .icons=${{left: 'home', right: 'arrow-right'}}>Navigate</nr-button>\n * \n * <!-- Loading state -->\n * <nr-button loading>Processing...</nr-button>\n * ```\n * \n * @fires button-clicked - Button clicked\n * @fires link-navigation - Link navigation\n * \n * @slot default - Button text content\n */\n@customElement('nr-button')\nexport class NrButtonElement extends NuralyUIBaseMixin(LitElement) implements ButtonHost {\n static override styles = styles;\n /** Disables the button */\n @property({ type: Boolean })\n disabled = false;\n\n /** Shows loading spinner */\n @property({ type: Boolean })\n loading = false;\n\n /** Button size (small, medium, large) */\n @property({ type: String })\n size: ButtonSize | '' = EMPTY_STRING;\n\n /** Button type (default, primary, secondary, danger, ghost, link) */\n @property({ type: String })\n type: ButtonType = ButtonType.Default;\n\n /** Button shape (default, circle, round) */\n @property({ type: String })\n shape: ButtonShape = ButtonShape.Default;\n\n /** Makes button full width */\n @property({ type: Boolean })\n block = false;\n\n /** Applies dashed border */\n @property({ type: Boolean })\n dashed = false;\n\n /** Icon configuration (supports strings or enhanced config objects) */\n @property({ type: Array })\n icon: ButtonIcons = [];\n\n /** Left icon (alternative to icon array) */\n @property({ type: Object })\n iconLeft?: ButtonIcon;\n\n /** Right icon (alternative to icon array) */\n @property({ type: Object })\n iconRight?: ButtonIcon;\n\n /** Icon configuration object (alternative to icon array) */\n @property({ type: Object })\n icons?: ButtonIconsConfig;\n\n /** Icon position relative to text */\n @property({ reflect: true })\n iconPosition: IconPosition = IconPosition.Left;\n\n /** URL for link-type buttons */\n @property({ type: String })\n href = EMPTY_STRING;\n\n /** Target attribute for links */\n @property({ type: String })\n target = EMPTY_STRING;\n\n /** Enables ripple effect */\n @property({ type: Boolean })\n ripple = true;\n\n /** Custom aria-label */\n @property({ type: String })\n buttonAriaLabel = EMPTY_STRING;\n\n /** References to descriptive elements */\n @property({ type: String })\n ariaDescribedBy = EMPTY_STRING;\n\n /** HTML button type */\n @property({ type: String })\n htmlType = EMPTY_STRING;\n\n override requiredComponents = ['nr-icon'];\n\n // Controllers\n private rippleController = new ButtonRippleController(this);\n private keyboardController = new ButtonKeyboardController(this);\n private linkController = new ButtonLinkController(this);\n\n override connectedCallback() {\n super.connectedCallback();\n this.validateDependencies();\n }\n\n private getCommonAttributes() {\n return {\n 'data-type': this.type,\n 'data-shape': this.shape,\n 'data-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 'aria-disabled': this.disabled ? 'true' : 'false',\n 'aria-label': this.buttonAriaLabel || nothing,\n 'aria-describedby': this.ariaDescribedBy || nothing,\n 'tabindex': this.disabled ? '-1' : '0'\n };\n }\n\n private renderIcon(iconConfig: ButtonIcon) {\n if (!this.isComponentAvailable('nr-icon')) {\n const iconName = typeof iconConfig === 'string' ? iconConfig : iconConfig.name;\n console.warn(\n `[nr-button] Icon component 'nr-icon' not available. Icon \"${iconName}\" will not render. ` +\n `Ensure the icon component is imported and registered.`\n );\n return nothing;\n }\n\n // Get appropriate icon size based on button size\n const getIconSizeForButtonSize = (): 'small' | 'medium' | 'large' | undefined => {\n switch (this.size) {\n case ButtonSize.Small:\n return 'small';\n case ButtonSize.Medium:\n return 'medium';\n case ButtonSize.Large:\n return 'large';\n default:\n return 'medium'; // Default to medium if no size specified\n }\n };\n\n // Handle simple string input (backward compatibility)\n if (typeof iconConfig === 'string') {\n const iconSize = getIconSizeForButtonSize();\n return html`<nr-icon name=${iconConfig} size=${ifDefined(iconSize)}></nr-icon>`;\n }\n\n // Handle enhanced icon configuration\n const {\n name,\n type = 'solid',\n size,\n color,\n alt\n } = iconConfig;\n\n // Use explicit size if provided, otherwise use size based on button size\n const resolvedSize = size || getIconSizeForButtonSize();\n const iconSize = resolvedSize as 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | undefined;\n\n return html`<nr-icon \n name=${name}\n type=${type}\n alt=${alt || ''}\n size=${ifDefined(iconSize)}\n color=${color || ''}\n ></nr-icon>`;\n }\n\n private handleClick(event: MouseEvent) {\n if (this.disabled) {\n event.preventDefault();\n return;\n }\n\n this.rippleController.handleRippleClick(event);\n \n if (this.linkController.isLinkType()) {\n this.linkController.handleLinkNavigation(event);\n }\n \n this.dispatchEventWithMetadata('button-clicked', {\n type: this.type,\n disabled: this.disabled,\n loading: this.loading,\n href: this.href || null\n });\n }\n\n private handleKeydown(event: KeyboardEvent) {\n this.keyboardController.handleKeydown(event);\n }\n\n /**\n * Get the resolved left icon from various sources\n */\n private getResolvedLeftIcon(): ButtonIcon | undefined {\n // Priority: iconLeft > icons.left > icon[0]\n if (this.iconLeft) return this.iconLeft;\n if (this.icons?.left) return this.icons.left;\n if (this.icon?.length > 0) return this.icon[0];\n return undefined;\n }\n\n /**\n * Get the resolved right icon from various sources\n */\n private getResolvedRightIcon(): ButtonIcon | undefined {\n // Priority: iconRight > icons.right > icon[1]\n if (this.iconRight) return this.iconRight;\n if (this.icons?.right) return this.icons.right;\n if (this.icon?.length === 2) return this.icon[1];\n return undefined;\n }\n\n override render() {\n const elementTag = this.linkController.getElementTag();\n const commonAttributes = this.getCommonAttributes();\n const linkAttributes = this.linkController.getLinkAttributes();\n \n const leftIcon = this.getResolvedLeftIcon();\n const rightIcon = this.getResolvedRightIcon();\n \n const content = html`\n <span id=\"container\" part=\"container\">\n ${leftIcon ? this.renderIcon(leftIcon) : nothing}\n <slot id=\"slot\"></slot>\n ${rightIcon ? this.renderIcon(rightIcon) : nothing}\n </span>\n `;\n if (elementTag === 'a') {\n return html`\n <a\n href=\"${linkAttributes.href}\"\n target=\"${linkAttributes.target || nothing}\"\n rel=\"${linkAttributes.rel || nothing}\"\n role=\"${linkAttributes.role}\"\n data-type=\"${commonAttributes['data-type']}\"\n data-shape=\"${commonAttributes['data-shape']}\"\n data-size=\"${commonAttributes['data-size']}\"\n data-state=\"${commonAttributes['data-state']}\"\n data-theme=\"${commonAttributes['data-theme']}\"\n data-block=\"${commonAttributes['data-block']}\"\n class=\"${commonAttributes.class}\"\n aria-disabled=\"${this.disabled}\"\n aria-label=\"${this.buttonAriaLabel || nothing}\"\n aria-describedby=\"${this.ariaDescribedBy || nothing}\"\n tabindex=\"${this.disabled ? -1 : 0}\"\n @click=\"${this.handleClick}\"\n @keydown=\"${this.handleKeydown}\"\n >\n ${content}\n </a>\n `;\n }\n \n return html`\n <button\n ?disabled=\"${this.disabled}\"\n type=\"${(this.htmlType || 'button') as 'button' | 'submit' | 'reset'}\"\n role=\"${linkAttributes.role}\"\n data-type=\"${commonAttributes['data-type']}\"\n data-shape=\"${commonAttributes['data-shape']}\"\n data-size=\"${commonAttributes['data-size']}\" \n data-state=\"${commonAttributes['data-state']}\"\n data-theme=\"${commonAttributes['data-theme']}\"\n data-block=\"${commonAttributes['data-block']}\"\n class=\"${commonAttributes.class}\"\n aria-disabled=\"${this.disabled}\"\n aria-label=\"${this.buttonAriaLabel || nothing}\"\n aria-describedby=\"${this.ariaDescribedBy || nothing}\"\n tabindex=\"${this.disabled ? -1 : 0}\"\n @click=\"${this.handleClick}\"\n @keydown=\"${this.handleKeydown}\"\n >\n ${content}\n </button>\n `;\n }\n}\n"]}
package/button.style.d.ts CHANGED
@@ -1,19 +1,10 @@
1
1
  /**
2
- * Exported styles for the nr-button component
2
+ * Button component styles for the Hybrid UI Library
3
+ * Using shared CSS variables from /src/shared/themes/
3
4
  *
4
- * @description
5
- * This export provides the complete styling system for the button component,
6
- * including all variants, states, sizes, theme support, and CSS custom properties.
7
- *
8
- * @usage
9
- * Import and use in the component's styles property:
10
- * ```typescript
11
- * import { styles } from './nr-button.style.ts';
12
- *
13
- * @Component({
14
- * styles: styles
15
- * })
16
- * ```
5
+ * This file contains all the styling for the nr-button component with
6
+ * clean CSS variable usage without local fallbacks and proper theme switching support.
17
7
  */
18
- export declare const styles: import("lit").CSSResult[];
8
+ export declare const buttonStyles: import("lit").CSSResult;
9
+ export declare const styles: import("lit").CSSResult;
19
10
  //# sourceMappingURL=button.style.d.ts.map