@fremtind/jkl-checkbox-react
Advanced tools
Comparing version 11.1.44 to 11.1.45
@@ -37,53 +37,57 @@ "use strict"; | ||
var import_react = __toESM(require("react")); | ||
const Checkbox = (0, import_react.forwardRef)((props, ref) => { | ||
const { | ||
id, | ||
children, | ||
invalid, | ||
className, | ||
inline = false, | ||
density, | ||
"data-testautoid": testAutoId, | ||
checked, | ||
indeterminate, | ||
...rest | ||
} = props; | ||
const inputRef = (0, import_react.useRef)(null); | ||
(0, import_react.useImperativeHandle)(ref, () => inputRef.current, []); | ||
const inputId = (0, import_jkl_react_hooks.useId)(id || "jkl-checkbox", { generateSuffix: !id }); | ||
(0, import_react.useEffect)(() => { | ||
if (checked === true && indeterminate === true && true) { | ||
console.warn("A Checkbox can not be both checked and indeterminate, and will be treated as checked"); | ||
} | ||
if (inputRef.current) { | ||
inputRef.current.indeterminate = !checked && !!indeterminate; | ||
} | ||
}, [checked, indeterminate]); | ||
return /* @__PURE__ */ import_react.default.createElement( | ||
"div", | ||
{ | ||
className: (0, import_classnames.default)("jkl-checkbox", className, { | ||
"jkl-checkbox--inline": inline, | ||
"jkl-checkbox--error": invalid | ||
}), | ||
"data-density": density | ||
}, | ||
/* @__PURE__ */ import_react.default.createElement( | ||
"input", | ||
const Checkbox = (0, import_react.forwardRef)( | ||
(props, ref) => { | ||
const { | ||
id, | ||
children, | ||
invalid, | ||
className, | ||
inline = false, | ||
density, | ||
"data-testautoid": testAutoId, | ||
checked, | ||
indeterminate, | ||
...rest | ||
} = props; | ||
const inputRef = (0, import_react.useRef)(null); | ||
(0, import_react.useImperativeHandle)(ref, () => inputRef.current, []); | ||
const inputId = (0, import_jkl_react_hooks.useId)(id || "jkl-checkbox", { generateSuffix: !id }); | ||
(0, import_react.useEffect)(() => { | ||
if (checked === true && indeterminate === true && true) { | ||
console.warn( | ||
"A Checkbox can not be both checked and indeterminate, and will be treated as checked" | ||
); | ||
} | ||
if (inputRef.current) { | ||
inputRef.current.indeterminate = !checked && !!indeterminate; | ||
} | ||
}, [checked, indeterminate]); | ||
return /* @__PURE__ */ import_react.default.createElement( | ||
"div", | ||
{ | ||
id: inputId, | ||
ref: inputRef, | ||
className: "jkl-checkbox__input", | ||
"data-testid": "jkl-checkbox-input", | ||
"aria-invalid": invalid, | ||
type: "checkbox", | ||
"data-testautoid": testAutoId, | ||
checked, | ||
...rest | ||
} | ||
), | ||
/* @__PURE__ */ import_react.default.createElement("label", { htmlFor: inputId, className: "jkl-checkbox__label" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "jkl-checkbox__mark" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "jkl-checkbox__indeterminate-mark" }), /* @__PURE__ */ import_react.default.createElement("span", { className: "jkl-checkbox__check-mark" })), /* @__PURE__ */ import_react.default.createElement("span", { className: "jkl-checkbox__text" }, children)) | ||
); | ||
}); | ||
className: (0, import_classnames.default)("jkl-checkbox", className, { | ||
"jkl-checkbox--inline": inline, | ||
"jkl-checkbox--error": invalid | ||
}), | ||
"data-density": density | ||
}, | ||
/* @__PURE__ */ import_react.default.createElement( | ||
"input", | ||
{ | ||
id: inputId, | ||
ref: inputRef, | ||
className: "jkl-checkbox__input", | ||
"data-testid": "jkl-checkbox-input", | ||
"aria-invalid": invalid, | ||
type: "checkbox", | ||
"data-testautoid": testAutoId, | ||
checked, | ||
...rest | ||
} | ||
), | ||
/* @__PURE__ */ import_react.default.createElement("label", { htmlFor: inputId, className: "jkl-checkbox__label" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "jkl-checkbox__mark" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "jkl-checkbox__indeterminate-mark" }), /* @__PURE__ */ import_react.default.createElement("span", { className: "jkl-checkbox__check-mark" })), /* @__PURE__ */ import_react.default.createElement("span", { className: "jkl-checkbox__text" }, children)) | ||
); | ||
} | ||
); | ||
Checkbox.displayName = "Checkbox"; | ||
//# sourceMappingURL=Checkbox.js.map |
@@ -9,52 +9,56 @@ import { useId } from "@fremtind/jkl-react-hooks"; | ||
} from "react"; | ||
const Checkbox = forwardRef((props, ref) => { | ||
const { | ||
id, | ||
children, | ||
invalid, | ||
className, | ||
inline = false, | ||
density, | ||
"data-testautoid": testAutoId, | ||
checked, | ||
indeterminate, | ||
...rest | ||
} = props; | ||
const inputRef = useRef(null); | ||
useImperativeHandle(ref, () => inputRef.current, []); | ||
const inputId = useId(id || "jkl-checkbox", { generateSuffix: !id }); | ||
useEffect(() => { | ||
if (checked === true && indeterminate === true && true) { | ||
console.warn("A Checkbox can not be both checked and indeterminate, and will be treated as checked"); | ||
} | ||
if (inputRef.current) { | ||
inputRef.current.indeterminate = !checked && !!indeterminate; | ||
} | ||
}, [checked, indeterminate]); | ||
return /* @__PURE__ */ React.createElement( | ||
"div", | ||
{ | ||
className: cn("jkl-checkbox", className, { | ||
"jkl-checkbox--inline": inline, | ||
"jkl-checkbox--error": invalid | ||
}), | ||
"data-density": density | ||
}, | ||
/* @__PURE__ */ React.createElement( | ||
"input", | ||
const Checkbox = forwardRef( | ||
(props, ref) => { | ||
const { | ||
id, | ||
children, | ||
invalid, | ||
className, | ||
inline = false, | ||
density, | ||
"data-testautoid": testAutoId, | ||
checked, | ||
indeterminate, | ||
...rest | ||
} = props; | ||
const inputRef = useRef(null); | ||
useImperativeHandle(ref, () => inputRef.current, []); | ||
const inputId = useId(id || "jkl-checkbox", { generateSuffix: !id }); | ||
useEffect(() => { | ||
if (checked === true && indeterminate === true && true) { | ||
console.warn( | ||
"A Checkbox can not be both checked and indeterminate, and will be treated as checked" | ||
); | ||
} | ||
if (inputRef.current) { | ||
inputRef.current.indeterminate = !checked && !!indeterminate; | ||
} | ||
}, [checked, indeterminate]); | ||
return /* @__PURE__ */ React.createElement( | ||
"div", | ||
{ | ||
id: inputId, | ||
ref: inputRef, | ||
className: "jkl-checkbox__input", | ||
"data-testid": "jkl-checkbox-input", | ||
"aria-invalid": invalid, | ||
type: "checkbox", | ||
"data-testautoid": testAutoId, | ||
checked, | ||
...rest | ||
} | ||
), | ||
/* @__PURE__ */ React.createElement("label", { htmlFor: inputId, className: "jkl-checkbox__label" }, /* @__PURE__ */ React.createElement("span", { className: "jkl-checkbox__mark" }, /* @__PURE__ */ React.createElement("span", { className: "jkl-checkbox__indeterminate-mark" }), /* @__PURE__ */ React.createElement("span", { className: "jkl-checkbox__check-mark" })), /* @__PURE__ */ React.createElement("span", { className: "jkl-checkbox__text" }, children)) | ||
); | ||
}); | ||
className: cn("jkl-checkbox", className, { | ||
"jkl-checkbox--inline": inline, | ||
"jkl-checkbox--error": invalid | ||
}), | ||
"data-density": density | ||
}, | ||
/* @__PURE__ */ React.createElement( | ||
"input", | ||
{ | ||
id: inputId, | ||
ref: inputRef, | ||
className: "jkl-checkbox__input", | ||
"data-testid": "jkl-checkbox-input", | ||
"aria-invalid": invalid, | ||
type: "checkbox", | ||
"data-testautoid": testAutoId, | ||
checked, | ||
...rest | ||
} | ||
), | ||
/* @__PURE__ */ React.createElement("label", { htmlFor: inputId, className: "jkl-checkbox__label" }, /* @__PURE__ */ React.createElement("span", { className: "jkl-checkbox__mark" }, /* @__PURE__ */ React.createElement("span", { className: "jkl-checkbox__indeterminate-mark" }), /* @__PURE__ */ React.createElement("span", { className: "jkl-checkbox__check-mark" })), /* @__PURE__ */ React.createElement("span", { className: "jkl-checkbox__text" }, children)) | ||
); | ||
} | ||
); | ||
Checkbox.displayName = "Checkbox"; | ||
@@ -61,0 +65,0 @@ export { |
{ | ||
"name": "@fremtind/jkl-checkbox-react", | ||
"version": "11.1.44", | ||
"version": "11.1.45", | ||
"publishConfig": { | ||
@@ -41,9 +41,9 @@ "access": "public" | ||
"dependencies": { | ||
"@fremtind/jkl-checkbox": "^11.1.5", | ||
"@fremtind/jkl-core": "^14.8.1", | ||
"@fremtind/jkl-react-hooks": "^12.2.5", | ||
"@fremtind/jkl-checkbox": "^11.1.6", | ||
"@fremtind/jkl-core": "^14.8.2", | ||
"@fremtind/jkl-react-hooks": "^12.2.6", | ||
"classnames": "^2.3.2" | ||
}, | ||
"devDependencies": { | ||
"@fremtind/jkl-input-group-react": "^3.0.51" | ||
"@fremtind/jkl-input-group-react": "^3.0.52" | ||
}, | ||
@@ -63,3 +63,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "9c4193c00f51b351ca7c65f951c78adf682c2c15" | ||
"gitHead": "82508b6f72780226367f81cd8a6a2f5417484c9a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
22237
240