@melodicdev/components 1.5.11 → 1.5.12

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.
@@ -4171,32 +4171,49 @@ lt = v([_({
4171
4171
  attributes: ["size", "label"]
4172
4172
  })], lt);
4173
4173
  function ol(e) {
4174
- return i`
4175
- <button
4176
- type="${e.type}"
4177
- class=${g({
4174
+ const t = g({
4178
4175
  "ml-button": !0,
4179
4176
  [`ml-button--${e.variant}`]: !0,
4180
4177
  [`ml-button--${e.size}`]: !0,
4181
4178
  "ml-button--disabled": e.isDisabled,
4182
4179
  "ml-button--loading": e.loading,
4183
4180
  "ml-button--full-width": e.fullWidth
4184
- })}
4181
+ }), r = i`
4182
+ ${d(e.loading, () => i`
4183
+ <span class="ml-button__spinner">
4184
+ <ml-spinner size="sm"></ml-spinner>
4185
+ </span>
4186
+ `)}
4187
+ <span class="ml-button__content">
4188
+ <slot name="icon-start"></slot>
4189
+ <slot></slot>
4190
+ <slot name="icon-end"></slot>
4191
+ </span>
4192
+ `;
4193
+ return e.href != null ? i`
4194
+ <a
4195
+ href=${e.isDisabled ? void 0 : e.href}
4196
+ target=${e.target ?? void 0}
4197
+ rel=${e.rel ?? void 0}
4198
+ download=${e.download ?? void 0}
4199
+ class=${t}
4200
+ role="button"
4201
+ @click=${e.handleClick}
4202
+ aria-disabled=${e.isDisabled ? "true" : "false"}
4203
+ aria-busy=${e.loading ? "true" : "false"}
4204
+ >
4205
+ ${r}
4206
+ </a>
4207
+ ` : i`
4208
+ <button
4209
+ type="${e.type}"
4210
+ class=${t}
4185
4211
  ?disabled=${e.isDisabled}
4186
4212
  @click=${e.handleClick}
4187
4213
  aria-disabled=${e.isDisabled ? "true" : "false"}
4188
4214
  aria-busy=${e.loading ? "true" : "false"}
4189
4215
  >
4190
- ${d(e.loading, () => i`
4191
- <span class="ml-button__spinner">
4192
- <ml-spinner size="sm"></ml-spinner>
4193
- </span>
4194
- `)}
4195
- <span class="ml-button__content">
4196
- <slot name="icon-start"></slot>
4197
- <slot></slot>
4198
- <slot name="icon-end"></slot>
4199
- </span>
4216
+ ${r}
4200
4217
  </button>
4201
4218
  `;
4202
4219
  }
@@ -4455,7 +4472,7 @@ const il = () => w`
4455
4472
  `;
4456
4473
  var ot = class {
4457
4474
  constructor() {
4458
- this.variant = "primary", this.size = "md", this.type = "button", this.disabled = !1, this.loading = !1, this.fullWidth = !1, this.handleClick = (t) => {
4475
+ this.variant = "primary", this.size = "md", this.type = "button", this.disabled = !1, this.loading = !1, this.fullWidth = !1, this.href = null, this.target = null, this.rel = null, this.download = null, this.handleClick = (t) => {
4459
4476
  if (this.isDisabled) {
4460
4477
  t.preventDefault(), t.stopPropagation();
4461
4478
  return;
@@ -4485,7 +4502,11 @@ ot = v([_({
4485
4502
  "type",
4486
4503
  "disabled",
4487
4504
  "loading",
4488
- "full-width"
4505
+ "full-width",
4506
+ "href",
4507
+ "target",
4508
+ "rel",
4509
+ "download"
4489
4510
  ]
4490
4511
  })], ot);
4491
4512
  function sl(e) {
@@ -34,6 +34,14 @@ export declare class ButtonComponent implements IElementRef, OnInit {
34
34
  loading: boolean;
35
35
  /** Make button full width */
36
36
  fullWidth: boolean;
37
+ /** If set, renders as an anchor tag instead of a button */
38
+ href: string | null;
39
+ /** Anchor target (only used when href is set) */
40
+ target: string | null;
41
+ /** Anchor rel (only used when href is set) */
42
+ rel: string | null;
43
+ /** Anchor download (only used when href is set) */
44
+ download: string | null;
37
45
  onInit(): void;
38
46
  /** Whether the button is effectively disabled */
39
47
  get isDisabled(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"button.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/button/button.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,6CAA6C,CAAC;AAIrD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAMa,eAAgB,YAAW,WAAW,EAAE,MAAM;IACnD,UAAU,EAAG,WAAW,CAAC;IAEhC,2BAA2B;IACpB,OAAO,EAAE,aAAa,CAAa;IAE1C,kBAAkB;IACX,IAAI,EAAE,IAAI,CAAQ;IAEzB,uBAAuB;IAChB,IAAI,EAAE,UAAU,CAAY;IAEnC,yBAAyB;IAClB,QAAQ,UAAS;IAExB,yBAAyB;IAClB,OAAO,UAAS;IAEvB,6BAA6B;IACtB,SAAS,UAAS;IAElB,MAAM,IAAI,IAAI;IAOrB,iDAAiD;IACjD,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED,0BAA0B;IACnB,WAAW,GAAI,OAAO,UAAU,KAAG,IAAI,CAe5C;CACF"}
1
+ {"version":3,"file":"button.component.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/button/button.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,6CAA6C,CAAC;AAIrD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAMa,eAAgB,YAAW,WAAW,EAAE,MAAM;IACnD,UAAU,EAAG,WAAW,CAAC;IAEhC,2BAA2B;IACpB,OAAO,EAAE,aAAa,CAAa;IAE1C,kBAAkB;IACX,IAAI,EAAE,IAAI,CAAQ;IAEzB,uBAAuB;IAChB,IAAI,EAAE,UAAU,CAAY;IAEnC,yBAAyB;IAClB,QAAQ,UAAS;IAExB,yBAAyB;IAClB,OAAO,UAAS;IAEvB,6BAA6B;IACtB,SAAS,UAAS;IAEzB,2DAA2D;IACpD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAQ;IAElC,iDAAiD;IAC1C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEpC,8CAA8C;IACvC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAQ;IAEjC,mDAAmD;IAC5C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B,MAAM,IAAI,IAAI;IAOrB,iDAAiD;IACjD,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED,0BAA0B;IACnB,WAAW,GAAI,OAAO,UAAU,KAAG,IAAI,CAe5C;CACF"}
@@ -41,6 +41,14 @@ let ButtonComponent = class ButtonComponent {
41
41
  this.loading = false;
42
42
  /** Make button full width */
43
43
  this.fullWidth = false;
44
+ /** If set, renders as an anchor tag instead of a button */
45
+ this.href = null;
46
+ /** Anchor target (only used when href is set) */
47
+ this.target = null;
48
+ /** Anchor rel (only used when href is set) */
49
+ this.rel = null;
50
+ /** Anchor download (only used when href is set) */
51
+ this.download = null;
44
52
  /** Handle click events */
45
53
  this.handleClick = (event) => {
46
54
  if (this.isDisabled) {
@@ -72,7 +80,7 @@ ButtonComponent = __decorate([
72
80
  selector: 'ml-button',
73
81
  template: buttonTemplate,
74
82
  styles: buttonStyles,
75
- attributes: ['variant', 'size', 'type', 'disabled', 'loading', 'full-width']
83
+ attributes: ['variant', 'size', 'type', 'disabled', 'loading', 'full-width', 'href', 'target', 'rel', 'download']
76
84
  })
77
85
  ], ButtonComponent);
78
86
  export { ButtonComponent };
@@ -1 +1 @@
1
- {"version":3,"file":"button.template.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/button/button.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,wBAAgB,cAAc,CAAC,CAAC,EAAE,eAAe,6CAgChD"}
1
+ {"version":3,"file":"button.template.d.ts","sourceRoot":"","sources":["../../../../src/components/forms/button/button.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,wBAAgB,cAAc,CAAC,CAAC,EAAE,eAAe,6CAwDhD"}
@@ -1,31 +1,52 @@
1
1
  import { html, classMap, when } from '@melodicdev/core';
2
2
  export function buttonTemplate(c) {
3
- return html `
4
- <button
5
- type="${c.type}"
6
- class=${classMap({
3
+ const classes = classMap({
7
4
  'ml-button': true,
8
5
  [`ml-button--${c.variant}`]: true,
9
6
  [`ml-button--${c.size}`]: true,
10
7
  'ml-button--disabled': c.isDisabled,
11
8
  'ml-button--loading': c.loading,
12
9
  'ml-button--full-width': c.fullWidth
13
- })}
10
+ });
11
+ const content = html `
12
+ ${when(c.loading, () => html `
13
+ <span class="ml-button__spinner">
14
+ <ml-spinner size="sm"></ml-spinner>
15
+ </span>
16
+ `)}
17
+ <span class="ml-button__content">
18
+ <slot name="icon-start"></slot>
19
+ <slot></slot>
20
+ <slot name="icon-end"></slot>
21
+ </span>
22
+ `;
23
+ if (c.href != null) {
24
+ return html `
25
+ <a
26
+ href=${c.isDisabled ? undefined : c.href}
27
+ target=${c.target ?? undefined}
28
+ rel=${c.rel ?? undefined}
29
+ download=${c.download ?? undefined}
30
+ class=${classes}
31
+ role="button"
32
+ @click=${c.handleClick}
33
+ aria-disabled=${c.isDisabled ? 'true' : 'false'}
34
+ aria-busy=${c.loading ? 'true' : 'false'}
35
+ >
36
+ ${content}
37
+ </a>
38
+ `;
39
+ }
40
+ return html `
41
+ <button
42
+ type="${c.type}"
43
+ class=${classes}
14
44
  ?disabled=${c.isDisabled}
15
45
  @click=${c.handleClick}
16
46
  aria-disabled=${c.isDisabled ? 'true' : 'false'}
17
47
  aria-busy=${c.loading ? 'true' : 'false'}
18
48
  >
19
- ${when(c.loading, () => html `
20
- <span class="ml-button__spinner">
21
- <ml-spinner size="sm"></ml-spinner>
22
- </span>
23
- `)}
24
- <span class="ml-button__content">
25
- <slot name="icon-start"></slot>
26
- <slot></slot>
27
- <slot name="icon-end"></slot>
28
- </span>
49
+ ${content}
29
50
  </button>
30
51
  `;
31
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melodicdev/components",
3
- "version": "1.5.11",
3
+ "version": "1.5.12",
4
4
  "description": "Themeable UI component library built on the Melodic Framework",
5
5
  "license": "MIT",
6
6
  "author": "Melodic Development",