@nuralyui/button 0.0.14 → 0.0.16

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 +619 -0
  2. package/button.component.d.ts +64 -25
  3. package/button.component.js +136 -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,93 @@
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 { ButtonHost } from './interfaces/index.js';
9
+ 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
10
  /**
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
11
+ * Versatile button component with multiple variants, loading states, and enhanced icon support.
12
+ *
13
+ * @example
14
+ * ```html
15
+ * <!-- Simple usage -->
16
+ * <nr-button type="primary">Click me</nr-button>
17
+ *
18
+ * <!-- Array-based icons (original API) -->
19
+ * <nr-button type="primary" .icon=${['add']}>Add Item</nr-button>
20
+ * <nr-button type="primary" .icon=${['home', 'arrow-right']}>Home</nr-button>
21
+ *
22
+ * <!-- Separate icon properties (new API) -->
23
+ * <nr-button type="primary" iconLeft="home" iconRight="arrow-right">Navigate</nr-button>
24
+ * <nr-button type="primary" .iconLeft=${{name: 'home', color: 'blue'}}>Enhanced</nr-button>
25
+ *
26
+ * <!-- Object-based icons (new API) -->
27
+ * <nr-button type="primary" .icons=${{left: 'home', right: 'arrow-right'}}>Navigate</nr-button>
28
+ *
29
+ * <!-- Loading state -->
30
+ * <nr-button loading>Processing...</nr-button>
31
+ * ```
32
+ *
33
+ * @fires button-clicked - Button clicked
34
+ * @fires link-navigation - Link navigation
35
+ *
36
+ * @slot default - Button text content
14
37
  */
15
- export declare class NrButtonElement extends NrButtonElement_base {
38
+ export declare class NrButtonElement extends NrButtonElement_base implements ButtonHost {
39
+ static styles: import("lit").CSSResult;
40
+ /** Disables the button */
16
41
  disabled: boolean;
42
+ /** Shows loading spinner */
17
43
  loading: boolean;
18
- size: string;
44
+ /** Button size (small, medium, large) */
45
+ size: ButtonSize | '';
46
+ /** Button type (default, primary, secondary, danger, ghost, link) */
19
47
  type: ButtonType;
48
+ /** Button shape (default, circle, round) */
20
49
  shape: ButtonShape;
50
+ /** Makes button full width */
21
51
  block: boolean;
52
+ /** Applies dashed border */
22
53
  dashed: boolean;
23
- icon: string[];
54
+ /** Icon configuration (supports strings or enhanced config objects) */
55
+ icon: ButtonIcons;
56
+ /** Left icon (alternative to icon array) */
57
+ iconLeft?: ButtonIcon;
58
+ /** Right icon (alternative to icon array) */
59
+ iconRight?: ButtonIcon;
60
+ /** Icon configuration object (alternative to icon array) */
61
+ icons?: ButtonIconsConfig;
62
+ /** Icon position relative to text */
24
63
  iconPosition: IconPosition;
64
+ /** URL for link-type buttons */
25
65
  href: string;
66
+ /** Target attribute for links */
26
67
  target: string;
68
+ /** Enables ripple effect */
27
69
  ripple: boolean;
70
+ /** Custom aria-label */
28
71
  buttonAriaLabel: string;
72
+ /** References to descriptive elements */
29
73
  ariaDescribedBy: string;
74
+ /** HTML button type */
30
75
  htmlType: string;
31
- /**
32
- * Required components that must be registered for this component to work properly
33
- */
34
76
  requiredComponents: string[];
35
- /**
36
- * Check for required dependencies when component is connected to DOM
37
- */
77
+ private rippleController;
78
+ private keyboardController;
79
+ private linkController;
38
80
  connectedCallback(): void;
39
- /**
40
- * Get common attributes for both button and anchor elements
41
- */
42
81
  private getCommonAttributes;
82
+ private renderIcon;
83
+ private handleClick;
84
+ private handleKeydown;
43
85
  /**
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
86
+ * Get the resolved left icon from various sources
47
87
  */
48
- private renderIcon;
88
+ private getResolvedLeftIcon;
49
89
  /**
50
- * Handle comprehensive click events with proper event dispatching
90
+ * Get the resolved right icon from various sources
51
91
  */
52
- private handleClick;
92
+ private getResolvedRightIcon;
53
93
  render(): import("lit").TemplateResult<1>;
54
- static styles: import("lit").CSSResult[];
55
94
  }
56
95
  export {};
57
96
  //# sourceMappingURL=button.component.d.ts.map
@@ -11,54 +11,83 @@ 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 controllers
19
+ import { ButtonRippleController, ButtonKeyboardController, ButtonLinkController } from './controllers/index.js';
18
20
  /**
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
21
+ * Versatile button component with multiple variants, loading states, and enhanced icon support.
22
+ *
23
+ * @example
24
+ * ```html
25
+ * <!-- Simple usage -->
26
+ * <nr-button type="primary">Click me</nr-button>
27
+ *
28
+ * <!-- Array-based icons (original API) -->
29
+ * <nr-button type="primary" .icon=${['add']}>Add Item</nr-button>
30
+ * <nr-button type="primary" .icon=${['home', 'arrow-right']}>Home</nr-button>
31
+ *
32
+ * <!-- Separate icon properties (new API) -->
33
+ * <nr-button type="primary" iconLeft="home" iconRight="arrow-right">Navigate</nr-button>
34
+ * <nr-button type="primary" .iconLeft=${{name: 'home', color: 'blue'}}>Enhanced</nr-button>
35
+ *
36
+ * <!-- Object-based icons (new API) -->
37
+ * <nr-button type="primary" .icons=${{left: 'home', right: 'arrow-right'}}>Navigate</nr-button>
38
+ *
39
+ * <!-- Loading state -->
40
+ * <nr-button loading>Processing...</nr-button>
41
+ * ```
42
+ *
43
+ * @fires button-clicked - Button clicked
44
+ * @fires link-navigation - Link navigation
45
+ *
46
+ * @slot default - Button text content
23
47
  */
24
- let NrButtonElement = class NrButtonElement extends RippleMixin(KeyboardMixin(LinkMixin(NuralyUIBaseMixin(LitElement)))) {
48
+ let NrButtonElement = class NrButtonElement extends NuralyUIBaseMixin(LitElement) {
25
49
  constructor() {
26
50
  super(...arguments);
27
- // Button state properties
51
+ /** Disables the button */
28
52
  this.disabled = false;
53
+ /** Shows loading spinner */
29
54
  this.loading = false;
55
+ /** Button size (small, medium, large) */
30
56
  this.size = EMPTY_STRING;
57
+ /** Button type (default, primary, secondary, danger, ghost, link) */
31
58
  this.type = "default" /* ButtonType.Default */;
59
+ /** Button shape (default, circle, round) */
32
60
  this.shape = "default" /* ButtonShape.Default */;
61
+ /** Makes button full width */
33
62
  this.block = false;
63
+ /** Applies dashed border */
34
64
  this.dashed = false;
35
- // Icon properties
65
+ /** Icon configuration (supports strings or enhanced config objects) */
36
66
  this.icon = [];
67
+ /** Icon position relative to text */
37
68
  this.iconPosition = "left" /* IconPosition.Left */;
38
- // Link properties (inherited from LinkMixin)
69
+ /** URL for link-type buttons */
39
70
  this.href = EMPTY_STRING;
71
+ /** Target attribute for links */
40
72
  this.target = EMPTY_STRING;
41
- // Ripple property (inherited from RippleMixin)
73
+ /** Enables ripple effect */
42
74
  this.ripple = true;
43
- // Accessibility properties
75
+ /** Custom aria-label */
44
76
  this.buttonAriaLabel = EMPTY_STRING;
77
+ /** References to descriptive elements */
45
78
  this.ariaDescribedBy = EMPTY_STRING;
79
+ /** HTML button type */
46
80
  this.htmlType = EMPTY_STRING;
47
- /**
48
- * Required components that must be registered for this component to work properly
49
- */
50
- this.requiredComponents = ['hy-icon'];
81
+ this.requiredComponents = ['nr-icon'];
82
+ // Controllers
83
+ this.rippleController = new ButtonRippleController(this);
84
+ this.keyboardController = new ButtonKeyboardController(this);
85
+ this.linkController = new ButtonLinkController(this);
51
86
  }
52
- /**
53
- * Check for required dependencies when component is connected to DOM
54
- */
55
87
  connectedCallback() {
56
88
  super.connectedCallback();
57
89
  this.validateDependencies();
58
90
  }
59
- /**
60
- * Get common attributes for both button and anchor elements
61
- */
62
91
  getCommonAttributes() {
63
92
  return {
64
93
  'data-type': this.type,
@@ -74,39 +103,53 @@ let NrButtonElement = class NrButtonElement extends RippleMixin(KeyboardMixin(Li
74
103
  'tabindex': this.disabled ? '-1' : '0'
75
104
  };
76
105
  }
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.`);
106
+ renderIcon(iconConfig) {
107
+ if (!this.isComponentAvailable('nr-icon')) {
108
+ const iconName = typeof iconConfig === 'string' ? iconConfig : iconConfig.name;
109
+ console.warn(`[nr-button] Icon component 'nr-icon' not available. Icon "${iconName}" will not render. ` +
110
+ `Ensure the icon component is imported and registered.`);
86
111
  return nothing;
87
112
  }
88
- return html `<hy-icon name=${iconName}></hy-icon>`;
113
+ // Get appropriate icon size based on button size
114
+ const getIconSizeForButtonSize = () => {
115
+ switch (this.size) {
116
+ case "small" /* ButtonSize.Small */:
117
+ return 'small';
118
+ case "medium" /* ButtonSize.Medium */:
119
+ return 'medium';
120
+ case "large" /* ButtonSize.Large */:
121
+ return 'large';
122
+ default:
123
+ return 'medium'; // Default to medium if no size specified
124
+ }
125
+ };
126
+ // Handle simple string input (backward compatibility)
127
+ if (typeof iconConfig === 'string') {
128
+ const iconSize = getIconSizeForButtonSize();
129
+ return html `<nr-icon name=${iconConfig} size=${ifDefined(iconSize)}></nr-icon>`;
130
+ }
131
+ // Handle enhanced icon configuration
132
+ const { name, type = 'solid', size, color, alt } = iconConfig;
133
+ // Use explicit size if provided, otherwise use size based on button size
134
+ const resolvedSize = size || getIconSizeForButtonSize();
135
+ const iconSize = resolvedSize;
136
+ return html `<nr-icon
137
+ name=${name}
138
+ type=${type}
139
+ alt=${alt || ''}
140
+ size=${ifDefined(iconSize)}
141
+ color=${color || ''}
142
+ ></nr-icon>`;
89
143
  }
90
- /**
91
- * Handle comprehensive click events with proper event dispatching
92
- */
93
144
  handleClick(event) {
94
145
  if (this.disabled) {
95
146
  event.preventDefault();
96
147
  return;
97
148
  }
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
- });
149
+ this.rippleController.handleRippleClick(event);
150
+ if (this.linkController.isLinkType()) {
151
+ this.linkController.handleLinkNavigation(event);
108
152
  }
109
- // Dispatch button event with metadata using EventHandlerMixin
110
153
  this.dispatchEventWithMetadata('button-clicked', {
111
154
  type: this.type,
112
155
  disabled: this.disabled,
@@ -114,16 +157,48 @@ let NrButtonElement = class NrButtonElement extends RippleMixin(KeyboardMixin(Li
114
157
  href: this.href || null
115
158
  });
116
159
  }
117
- render() {
160
+ handleKeydown(event) {
161
+ this.keyboardController.handleKeydown(event);
162
+ }
163
+ /**
164
+ * Get the resolved left icon from various sources
165
+ */
166
+ getResolvedLeftIcon() {
167
+ var _a, _b;
168
+ // Priority: iconLeft > icons.left > icon[0]
169
+ if (this.iconLeft)
170
+ return this.iconLeft;
171
+ if ((_a = this.icons) === null || _a === void 0 ? void 0 : _a.left)
172
+ return this.icons.left;
173
+ if (((_b = this.icon) === null || _b === void 0 ? void 0 : _b.length) > 0)
174
+ return this.icon[0];
175
+ return undefined;
176
+ }
177
+ /**
178
+ * Get the resolved right icon from various sources
179
+ */
180
+ getResolvedRightIcon() {
118
181
  var _a, _b;
119
- const elementTag = this.getElementTag(); // From LinkMixin
182
+ // Priority: iconRight > icons.right > icon[1]
183
+ if (this.iconRight)
184
+ return this.iconRight;
185
+ if ((_a = this.icons) === null || _a === void 0 ? void 0 : _a.right)
186
+ return this.icons.right;
187
+ if (((_b = this.icon) === null || _b === void 0 ? void 0 : _b.length) === 2)
188
+ return this.icon[1];
189
+ return undefined;
190
+ }
191
+ render() {
192
+ const elementTag = this.linkController.getElementTag();
120
193
  const commonAttributes = this.getCommonAttributes();
121
- const linkAttributes = this.getLinkAttributes(); // From LinkMixin
194
+ const linkAttributes = this.linkController.getLinkAttributes();
195
+ const leftIcon = this.getResolvedLeftIcon();
196
+ const rightIcon = this.getResolvedRightIcon();
122
197
  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}
198
+ <span id="container" part="container">
199
+ ${leftIcon ? this.renderIcon(leftIcon) : nothing}
125
200
  <slot id="slot"></slot>
126
- ${((_b = this.icon) === null || _b === void 0 ? void 0 : _b.length) === 2 ? this.renderIcon(this.icon[1]) : nothing}
201
+ ${rightIcon ? this.renderIcon(rightIcon) : nothing}
127
202
  </span>
128
203
  `;
129
204
  if (elementTag === 'a') {
@@ -200,6 +275,15 @@ __decorate([
200
275
  __decorate([
201
276
  property({ type: Array })
202
277
  ], NrButtonElement.prototype, "icon", void 0);
278
+ __decorate([
279
+ property({ type: Object })
280
+ ], NrButtonElement.prototype, "iconLeft", void 0);
281
+ __decorate([
282
+ property({ type: Object })
283
+ ], NrButtonElement.prototype, "iconRight", void 0);
284
+ __decorate([
285
+ property({ type: Object })
286
+ ], NrButtonElement.prototype, "icons", void 0);
203
287
  __decorate([
204
288
  property({ reflect: true })
205
289
  ], 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,+CAA+C;QAEtC,WAAM,GAAG,IAAI,CAAC;QAEvB,2BAA2B;QAE3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AAQ,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"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;AAEH,OAAO,EAAE,IA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,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 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