@greghowe79/the-lib 2.13.6 → 2.13.7

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.
@@ -5,10 +5,45 @@ const qwik = require("@builder.io/qwik");
5
5
  const styles = require("./styles.css.qwik.cjs");
6
6
  const loader = require("../loader/loader.qwik.cjs");
7
7
  const button_utils = require("./button.utils.qwik.cjs");
8
- const Button = qwik.component$(({ id, label, variant = "primary", icon, disabled = false, ariaLabel, type = "button", size = "md", onClick$, isLoading, active = false, customColors }) => {
8
+ const Button = qwik.component$(({ id, label, variant = "primary", icon, disabled = false, ariaLabel, type = "button", size = "md", href, target, rel, className, onClick$, isLoading, active = false, customColors }) => {
9
9
  qwik.useStylesScoped$(styles);
10
10
  const loading = typeof isLoading === "object" && isLoading !== null && "value" in isLoading ? isLoading.value : isLoading;
11
11
  const hasCustomStyles = customColors && (customColors.bg || customColors.text || customColors.border || customColors.padding || customColors.width || customColors.height);
12
+ const classes = [
13
+ `button-${variant}`,
14
+ `button-${size}`,
15
+ disabled && "button-disabled",
16
+ active && "button-active",
17
+ className
18
+ ].filter(Boolean).join(" ");
19
+ if (href) {
20
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
21
+ children: [
22
+ hasCustomStyles && /* @__PURE__ */ jsxRuntime.jsx("style", {
23
+ dangerouslySetInnerHTML: button_utils.generateCustomCSS(id, customColors)
24
+ }),
25
+ /* @__PURE__ */ jsxRuntime.jsxs("a", {
26
+ id,
27
+ href: disabled ? void 0 : href,
28
+ target,
29
+ rel,
30
+ class: classes,
31
+ "aria-disabled": disabled,
32
+ children: [
33
+ icon && /* @__PURE__ */ jsxRuntime.jsx("span", {
34
+ class: "button__icon",
35
+ "aria-hidden": "true",
36
+ children: typeof icon === "function" ? icon({}, null, 0) : icon
37
+ }),
38
+ /* @__PURE__ */ jsxRuntime.jsx("span", {
39
+ class: "button__text",
40
+ children: loading ? /* @__PURE__ */ jsxRuntime.jsx(loader.Loader, {}) : label
41
+ })
42
+ ]
43
+ })
44
+ ]
45
+ });
46
+ }
12
47
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
13
48
  children: [
14
49
  hasCustomStyles && /* @__PURE__ */ jsxRuntime.jsx("style", {
@@ -17,12 +52,7 @@ const Button = qwik.component$(({ id, label, variant = "primary", icon, disabled
17
52
  /* @__PURE__ */ jsxRuntime.jsxs("button", {
18
53
  id,
19
54
  type,
20
- class: [
21
- `button-${variant}`,
22
- `button-${size}`,
23
- disabled && "button-disabled",
24
- active && "button-active"
25
- ].filter(Boolean).join(" "),
55
+ class: classes,
26
56
  disabled,
27
57
  "aria-disabled": disabled,
28
58
  "aria-label": ariaLabel || (icon ? label : void 0),
@@ -3,10 +3,45 @@ import { component$, useStylesScoped$ } from "@builder.io/qwik";
3
3
  import styles from "./styles.css.qwik.mjs";
4
4
  import { Loader } from "../loader/loader.qwik.mjs";
5
5
  import { generateCustomCSS } from "./button.utils.qwik.mjs";
6
- const Button = component$(({ id, label, variant = "primary", icon, disabled = false, ariaLabel, type = "button", size = "md", onClick$, isLoading, active = false, customColors }) => {
6
+ const Button = component$(({ id, label, variant = "primary", icon, disabled = false, ariaLabel, type = "button", size = "md", href, target, rel, className, onClick$, isLoading, active = false, customColors }) => {
7
7
  useStylesScoped$(styles);
8
8
  const loading = typeof isLoading === "object" && isLoading !== null && "value" in isLoading ? isLoading.value : isLoading;
9
9
  const hasCustomStyles = customColors && (customColors.bg || customColors.text || customColors.border || customColors.padding || customColors.width || customColors.height);
10
+ const classes = [
11
+ `button-${variant}`,
12
+ `button-${size}`,
13
+ disabled && "button-disabled",
14
+ active && "button-active",
15
+ className
16
+ ].filter(Boolean).join(" ");
17
+ if (href) {
18
+ return /* @__PURE__ */ jsxs(Fragment, {
19
+ children: [
20
+ hasCustomStyles && /* @__PURE__ */ jsx("style", {
21
+ dangerouslySetInnerHTML: generateCustomCSS(id, customColors)
22
+ }),
23
+ /* @__PURE__ */ jsxs("a", {
24
+ id,
25
+ href: disabled ? void 0 : href,
26
+ target,
27
+ rel,
28
+ class: classes,
29
+ "aria-disabled": disabled,
30
+ children: [
31
+ icon && /* @__PURE__ */ jsx("span", {
32
+ class: "button__icon",
33
+ "aria-hidden": "true",
34
+ children: typeof icon === "function" ? icon({}, null, 0) : icon
35
+ }),
36
+ /* @__PURE__ */ jsx("span", {
37
+ class: "button__text",
38
+ children: loading ? /* @__PURE__ */ jsx(Loader, {}) : label
39
+ })
40
+ ]
41
+ })
42
+ ]
43
+ });
44
+ }
10
45
  return /* @__PURE__ */ jsxs(Fragment, {
11
46
  children: [
12
47
  hasCustomStyles && /* @__PURE__ */ jsx("style", {
@@ -15,12 +50,7 @@ const Button = component$(({ id, label, variant = "primary", icon, disabled = fa
15
50
  /* @__PURE__ */ jsxs("button", {
16
51
  id,
17
52
  type,
18
- class: [
19
- `button-${variant}`,
20
- `button-${size}`,
21
- disabled && "button-disabled",
22
- active && "button-active"
23
- ].filter(Boolean).join(" "),
53
+ class: classes,
24
54
  disabled,
25
55
  "aria-disabled": disabled,
26
56
  "aria-label": ariaLabel || (icon ? label : void 0),
@@ -23,6 +23,10 @@ export interface ButtonProps {
23
23
  ariaLabel?: string;
24
24
  type?: ButtonType;
25
25
  size?: ButtonSize;
26
+ href?: string;
27
+ target?: string;
28
+ rel?: string;
29
+ className?: string;
26
30
  onClick$?: QRL<() => void> | QRL<() => boolean> | QRL<() => Promise<void>> | QRL<(type: string | unknown) => Promise<void>>;
27
31
  isLoading?: boolean | Signal<boolean>;
28
32
  active?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greghowe79/the-lib",
3
- "version": "2.13.6",
3
+ "version": "2.13.7",
4
4
  "description": "Collection of fast components for Qwik",
5
5
  "main": "./lib/index.qwik.mjs",
6
6
  "qwik": "./lib/index.qwik.mjs",