Radio correction

This commit is contained in:
2026-03-31 19:38:10 +02:00
parent 3de48fe222
commit dcfd7b67b6
6 changed files with 28 additions and 31 deletions

13
dist/sigpro-ui.cjs vendored
View File

@@ -1104,26 +1104,25 @@ var NavbarModule = /*#__PURE__*/Object.freeze({
/** RADIO */ /** RADIO */
const Radio = (props) => { const Radio = (props) => {
const { label, tooltip, value, name, ...rest } = props; const { label, tooltip, value, inputValue, name, ...rest } = props;
const radioEl = sigpro.$html("input", { const radioEl = sigpro.$html("input", {
...rest, ...rest,
type: "radio", type: "radio",
name: name, name: name,
class: joinClass("radio", props.class), class: joinClass("radio", props.class),
checked: () => val(value) === props.value, checked: () => val(value) === inputValue,
disabled: () => val(props.disabled), onclick: () => {
onclick: () => typeof value === "function" && value(props.value), if (typeof value === "function") value(inputValue);
},
}); });
if (!label && !tooltip) return radioEl; if (!label && !tooltip) return radioEl;
const layout = sigpro.$html("label", { class: "label cursor-pointer justify-start gap-3" }, [ return sigpro.$html("label", { class: "label cursor-pointer justify-start gap-3" }, [
radioEl, radioEl,
label ? sigpro.$html("span", { class: "label-text" }, label) : null, label ? sigpro.$html("span", { class: "label-text" }, label) : null,
]); ]);
return tooltip ? sigpro.$html("div", { class: "tooltip", "data-tip": tooltip }, layout) : layout;
}; };
var RadioModule = /*#__PURE__*/Object.freeze({ var RadioModule = /*#__PURE__*/Object.freeze({

13
dist/sigpro-ui.esm.js vendored
View File

@@ -1100,26 +1100,25 @@ var NavbarModule = /*#__PURE__*/Object.freeze({
/** RADIO */ /** RADIO */
const Radio = (props) => { const Radio = (props) => {
const { label, tooltip, value, name, ...rest } = props; const { label, tooltip, value, inputValue, name, ...rest } = props;
const radioEl = $html("input", { const radioEl = $html("input", {
...rest, ...rest,
type: "radio", type: "radio",
name: name, name: name,
class: joinClass("radio", props.class), class: joinClass("radio", props.class),
checked: () => val(value) === props.value, checked: () => val(value) === inputValue,
disabled: () => val(props.disabled), onclick: () => {
onclick: () => typeof value === "function" && value(props.value), if (typeof value === "function") value(inputValue);
},
}); });
if (!label && !tooltip) return radioEl; if (!label && !tooltip) return radioEl;
const layout = $html("label", { class: "label cursor-pointer justify-start gap-3" }, [ return $html("label", { class: "label cursor-pointer justify-start gap-3" }, [
radioEl, radioEl,
label ? $html("span", { class: "label-text" }, label) : null, label ? $html("span", { class: "label-text" }, label) : null,
]); ]);
return tooltip ? $html("div", { class: "tooltip", "data-tip": tooltip }, layout) : layout;
}; };
var RadioModule = /*#__PURE__*/Object.freeze({ var RadioModule = /*#__PURE__*/Object.freeze({

13
dist/sigpro-ui.umd.js vendored
View File

@@ -1101,26 +1101,25 @@ var SigProUI = (function (exports, sigpro) {
/** RADIO */ /** RADIO */
const Radio = (props) => { const Radio = (props) => {
const { label, tooltip, value, name, ...rest } = props; const { label, tooltip, value, inputValue, name, ...rest } = props;
const radioEl = sigpro.$html("input", { const radioEl = sigpro.$html("input", {
...rest, ...rest,
type: "radio", type: "radio",
name: name, name: name,
class: joinClass("radio", props.class), class: joinClass("radio", props.class),
checked: () => val(value) === props.value, checked: () => val(value) === inputValue,
disabled: () => val(props.disabled), onclick: () => {
onclick: () => typeof value === "function" && value(props.value), if (typeof value === "function") value(inputValue);
},
}); });
if (!label && !tooltip) return radioEl; if (!label && !tooltip) return radioEl;
const layout = sigpro.$html("label", { class: "label cursor-pointer justify-start gap-3" }, [ return sigpro.$html("label", { class: "label cursor-pointer justify-start gap-3" }, [
radioEl, radioEl,
label ? sigpro.$html("span", { class: "label-text" }, label) : null, label ? sigpro.$html("span", { class: "label-text" }, label) : null,
]); ]);
return tooltip ? sigpro.$html("div", { class: "tooltip", "data-tip": tooltip }, layout) : layout;
}; };
var RadioModule = /*#__PURE__*/Object.freeze({ var RadioModule = /*#__PURE__*/Object.freeze({

File diff suppressed because one or more lines are too long

View File

@@ -40,7 +40,8 @@
</script> </script>
<script src="https://unpkg.com/sigpro"></script> <script src="https://unpkg.com/sigpro"></script>
<script src="https://unpkg.com/sigpro-ui"></script> <script src="https://cdn.jsdelivr.net/gh/natxocc/sigpro-ui@main/dist/sigpro-ui.umd.min.js"></script>
<!-- <script src="https://unpkg.com/sigpro-ui"></script> -->
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script> <script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script> <script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script>
</body> </body>

View File

@@ -3,24 +3,23 @@ import { val, joinClass } from "../core/utils.js";
/** RADIO */ /** RADIO */
export const Radio = (props) => { export const Radio = (props) => {
const { label, tooltip, value, name, ...rest } = props; const { label, tooltip, value, inputValue, name, ...rest } = props;
const radioEl = $html("input", { const radioEl = $html("input", {
...rest, ...rest,
type: "radio", type: "radio",
name: name, name: name,
class: joinClass("radio", props.class), class: joinClass("radio", props.class),
checked: () => val(value) === props.value, checked: () => val(value) === inputValue,
disabled: () => val(props.disabled), onclick: () => {
onclick: () => typeof value === "function" && value(props.value), if (typeof value === "function") value(inputValue);
},
}); });
if (!label && !tooltip) return radioEl; if (!label && !tooltip) return radioEl;
const layout = $html("label", { class: "label cursor-pointer justify-start gap-3" }, [ return $html("label", { class: "label cursor-pointer justify-start gap-3" }, [
radioEl, radioEl,
label ? $html("span", { class: "label-text" }, label) : null, label ? $html("span", { class: "label-text" }, label) : null,
]); ]);
};
return tooltip ? $html("div", { class: "tooltip", "data-tip": tooltip }, layout) : layout;
};