@nr1e/qwik-ui 2.0.18 → 2.0.20
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/lib/components/processing-button.qwik.cjs +11 -22
- package/lib/components/processing-button.qwik.mjs +12 -23
- package/lib/components/submit-button.qwik.cjs +1 -0
- package/lib/components/submit-button.qwik.mjs +1 -0
- package/lib-types/components/button.d.ts +1 -1
- package/lib-types/components/processing-button.d.ts +1 -3
- package/lib-types/components/refresh-button.d.ts +1 -1
- package/lib-types/components/submit-button.d.ts +0 -4
- package/package.json +1 -1
|
@@ -5,37 +5,26 @@ const qwik = require("@builder.io/qwik");
|
|
|
5
5
|
const qwikIcons = require("@nr1e/qwik-icons");
|
|
6
6
|
const button = require("./button.qwik.cjs");
|
|
7
7
|
const ProcessingButton = qwik.component$((props) => {
|
|
8
|
-
const externalProcessing = qwik.isSignal(props.processing) ? props.processing : void 0;
|
|
9
8
|
const internalProcessing = qwik.useSignal(qwik.isSignal(props.processing) ? props.processing.value : props.processing ?? false);
|
|
9
|
+
const processing = qwik.isSignal(props.processing) ? props.processing : internalProcessing;
|
|
10
10
|
const onClick$ = props.onClick$;
|
|
11
|
-
qwik.useTask$(({ track }) => {
|
|
12
|
-
if (externalProcessing) {
|
|
13
|
-
track(() => externalProcessing.value);
|
|
14
|
-
if (externalProcessing.value !== internalProcessing.value) {
|
|
15
|
-
internalProcessing.value = externalProcessing.value;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
qwik.useTask$(({ track }) => {
|
|
20
|
-
if (externalProcessing) {
|
|
21
|
-
track(() => internalProcessing.value);
|
|
22
|
-
if (externalProcessing.value !== internalProcessing.value) {
|
|
23
|
-
externalProcessing.value = internalProcessing.value;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
11
|
return /* @__PURE__ */ jsxRuntime.jsx(button.Button, {
|
|
28
12
|
...props,
|
|
29
13
|
class: `${props.processing || props.disabled ? "disabled" : ""} ${props.class ?? ""}`,
|
|
30
|
-
disabled:
|
|
14
|
+
disabled: processing.value || props.disabled,
|
|
31
15
|
onClick$: (e) => {
|
|
32
|
-
|
|
16
|
+
processing.value = true;
|
|
33
17
|
if (onClick$) {
|
|
34
|
-
onClick$(e);
|
|
18
|
+
const result = onClick$(e);
|
|
19
|
+
if (result instanceof Promise) {
|
|
20
|
+
result.finally(() => {
|
|
21
|
+
processing.value = false;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
35
24
|
}
|
|
36
25
|
},
|
|
37
|
-
icon:
|
|
38
|
-
iconClass:
|
|
26
|
+
icon: processing.value ? qwikIcons.SpinnersBarsFade : props.icon,
|
|
27
|
+
iconClass: processing.value ? "animate-spin" : props.iconClass,
|
|
39
28
|
children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
|
|
40
29
|
});
|
|
41
30
|
});
|
|
@@ -1,39 +1,28 @@
|
|
|
1
1
|
import { jsx } from "@builder.io/qwik/jsx-runtime";
|
|
2
|
-
import { component$,
|
|
2
|
+
import { component$, useSignal, isSignal, Slot } from "@builder.io/qwik";
|
|
3
3
|
import { SpinnersBarsFade } from "@nr1e/qwik-icons";
|
|
4
4
|
import { Button } from "./button.qwik.mjs";
|
|
5
5
|
const ProcessingButton = component$((props) => {
|
|
6
|
-
const externalProcessing = isSignal(props.processing) ? props.processing : void 0;
|
|
7
6
|
const internalProcessing = useSignal(isSignal(props.processing) ? props.processing.value : props.processing ?? false);
|
|
7
|
+
const processing = isSignal(props.processing) ? props.processing : internalProcessing;
|
|
8
8
|
const onClick$ = props.onClick$;
|
|
9
|
-
useTask$(({ track }) => {
|
|
10
|
-
if (externalProcessing) {
|
|
11
|
-
track(() => externalProcessing.value);
|
|
12
|
-
if (externalProcessing.value !== internalProcessing.value) {
|
|
13
|
-
internalProcessing.value = externalProcessing.value;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
useTask$(({ track }) => {
|
|
18
|
-
if (externalProcessing) {
|
|
19
|
-
track(() => internalProcessing.value);
|
|
20
|
-
if (externalProcessing.value !== internalProcessing.value) {
|
|
21
|
-
externalProcessing.value = internalProcessing.value;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
9
|
return /* @__PURE__ */ jsx(Button, {
|
|
26
10
|
...props,
|
|
27
11
|
class: `${props.processing || props.disabled ? "disabled" : ""} ${props.class ?? ""}`,
|
|
28
|
-
disabled:
|
|
12
|
+
disabled: processing.value || props.disabled,
|
|
29
13
|
onClick$: (e) => {
|
|
30
|
-
|
|
14
|
+
processing.value = true;
|
|
31
15
|
if (onClick$) {
|
|
32
|
-
onClick$(e);
|
|
16
|
+
const result = onClick$(e);
|
|
17
|
+
if (result instanceof Promise) {
|
|
18
|
+
result.finally(() => {
|
|
19
|
+
processing.value = false;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
33
22
|
}
|
|
34
23
|
},
|
|
35
|
-
icon:
|
|
36
|
-
iconClass:
|
|
24
|
+
icon: processing.value ? SpinnersBarsFade : props.icon,
|
|
25
|
+
iconClass: processing.value ? "animate-spin" : props.iconClass,
|
|
37
26
|
children: /* @__PURE__ */ jsx(Slot, {})
|
|
38
27
|
});
|
|
39
28
|
});
|
|
@@ -2,9 +2,7 @@ import { Signal } from '@builder.io/qwik';
|
|
|
2
2
|
import { ButtonProps } from './button';
|
|
3
3
|
/**
|
|
4
4
|
* Props for the ProcessingButton component. This class will replace the icon
|
|
5
|
-
* with a rotating spinner when
|
|
6
|
-
* automatically set processing to true when the button is clicked. It does
|
|
7
|
-
* not set processing to false when the button is clicked.
|
|
5
|
+
* with a rotating spinner when clicked.
|
|
8
6
|
*/
|
|
9
7
|
export interface ProcessingButtonProps extends ButtonProps {
|
|
10
8
|
/**
|
|
@@ -11,7 +11,7 @@ export interface RefreshButtonProps {
|
|
|
11
11
|
/**
|
|
12
12
|
* Callback function to be called when the button is clicked.
|
|
13
13
|
*/
|
|
14
|
-
onClick$?: QRL<(event: Event) => void
|
|
14
|
+
onClick$?: QRL<(event: Event) => void | Promise<void>>;
|
|
15
15
|
/**
|
|
16
16
|
* Whether the button is disabled.
|
|
17
17
|
*/
|
|
@@ -16,10 +16,6 @@ export interface SubmitButtonProps {
|
|
|
16
16
|
* Whether the button is disabled.
|
|
17
17
|
*/
|
|
18
18
|
disabled?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Type of the button. Default is 'button'.
|
|
21
|
-
*/
|
|
22
|
-
type?: 'button' | 'submit' | 'reset';
|
|
23
19
|
/**
|
|
24
20
|
* Text to display on the button. Default is 'Submit'.
|
|
25
21
|
*/
|