@shoplflow/base 0.30.2 → 0.30.4

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/dist/index.cjs CHANGED
@@ -2383,7 +2383,14 @@ var getStylesByStyleVariant = (styleVariant, isSelected, isHovered) => {
2383
2383
  return "";
2384
2384
  }
2385
2385
  };
2386
- var StyledCheckbox = styled6__default.default.button`
2386
+ var StyledCheckHiddenInput = styled6__default.default.input`
2387
+ position: absolute;
2388
+ width: 0;
2389
+ height: 0;
2390
+ opacity: 0;
2391
+ visibility: hidden;
2392
+ `;
2393
+ var StyledCheckbox = styled6__default.default.label`
2387
2394
  display: flex;
2388
2395
  align-items: center;
2389
2396
  justify-content: center;
@@ -2408,62 +2415,60 @@ var Container3 = styled6__default.default.button`
2408
2415
  background-color: transparent;
2409
2416
  `;
2410
2417
  exports.CHECKBOX_SYMBOL_KEY = Symbol("SHOPLFLOW_CHECKBOX");
2411
- var Checkbox = (_a) => {
2412
- var _b = _a, {
2413
- defaultSelected,
2414
- isSelected,
2415
- disabled,
2416
- onClick,
2417
- onMouseEnter,
2418
- onMouseLeave,
2419
- styleVar = "PRIMARY"
2420
- } = _b, rest = __objRest(_b, [
2421
- "defaultSelected",
2422
- "isSelected",
2423
- "disabled",
2424
- "onClick",
2425
- "onMouseEnter",
2426
- "onMouseLeave",
2427
- "styleVar"
2428
- ]);
2429
- const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
2430
- const [isHovered, toggleHovered] = React3.useState(false);
2431
- const handleMouseLeave = (e) => {
2432
- toggleHovered(false);
2433
- onMouseLeave && onMouseLeave(e);
2434
- };
2435
- const handleMouseEnter = (e) => {
2436
- toggleHovered(true);
2437
- onMouseEnter && onMouseEnter(e);
2438
- };
2439
- const handleClick = (e) => {
2440
- if (disabled) {
2441
- return;
2442
- }
2443
- onClick && onClick(e);
2444
- toggleSelected();
2445
- };
2446
- return /* @__PURE__ */ jsxRuntime.jsx(
2447
- Container3,
2448
- __spreadProps(__spreadValues({
2449
- onClick: handleClick,
2450
- onMouseLeave: handleMouseLeave,
2451
- onMouseEnter: handleMouseEnter,
2452
- disabled
2453
- }, rest), {
2454
- "data-shoplflow": "Checkbox",
2455
- children: /* @__PURE__ */ jsxRuntime.jsx(StyledCheckbox, { styleVar, isHovered, isSelected: selected, disabled, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "8", viewBox: "0 0 12 8", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
2456
- "path",
2457
- {
2458
- fillRule: "evenodd",
2459
- clipRule: "evenodd",
2460
- d: "M9.78822 0.297596C10.1761 -0.0955083 10.8093 -0.0997053 11.2024 0.288222C11.5653 0.646308 11.5968 1.21334 11.2943 1.60765L11.2118 1.7024L5.31714 7.7024C4.95248 8.07193 4.37282 8.09687 3.97909 7.77976L3.88476 7.69335L0.779404 4.42669C0.396475 4.02871 0.408672 3.39567 0.806647 3.01274C1.17401 2.65926 1.74167 2.64247 2.12801 2.95499L2.2206 3.03998L4.614 5.567L9.78822 0.297596Z",
2461
- fill: "white"
2462
- }
2463
- ) }) })
2464
- })
2465
- );
2466
- };
2418
+ var Checkbox = React3.forwardRef(
2419
+ (_a, ref) => {
2420
+ var _b = _a, { defaultSelected, isSelected, disabled, onMouseEnter, onMouseLeave, styleVar = "PRIMARY", id } = _b, rest = __objRest(_b, ["defaultSelected", "isSelected", "disabled", "onMouseEnter", "onMouseLeave", "styleVar", "id"]);
2421
+ const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
2422
+ const [isHovered, toggleHovered] = React3.useState(false);
2423
+ const handleMouseLeave = (e) => {
2424
+ toggleHovered(false);
2425
+ onMouseLeave && onMouseLeave(e);
2426
+ };
2427
+ const handleMouseEnter = (e) => {
2428
+ toggleHovered(true);
2429
+ onMouseEnter && onMouseEnter(e);
2430
+ };
2431
+ const handleClick = () => {
2432
+ if (disabled) {
2433
+ return;
2434
+ }
2435
+ toggleSelected();
2436
+ };
2437
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2438
+ Container3,
2439
+ {
2440
+ onClick: handleClick,
2441
+ onMouseLeave: handleMouseLeave,
2442
+ onMouseEnter: handleMouseEnter,
2443
+ disabled,
2444
+ type: "button",
2445
+ "data-shoplflow": "Checkbox",
2446
+ children: [
2447
+ /* @__PURE__ */ jsxRuntime.jsx(StyledCheckHiddenInput, __spreadProps(__spreadValues({ type: "checkbox", disabled, id }, rest), { ref })),
2448
+ /* @__PURE__ */ jsxRuntime.jsx(
2449
+ StyledCheckbox,
2450
+ {
2451
+ styleVar,
2452
+ htmlFor: "id",
2453
+ isHovered,
2454
+ isSelected: selected,
2455
+ disabled,
2456
+ children: /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "8", viewBox: "0 0 12 8", fill: "none", children: /* @__PURE__ */ jsxRuntime.jsx(
2457
+ "path",
2458
+ {
2459
+ fillRule: "evenodd",
2460
+ clipRule: "evenodd",
2461
+ d: "M9.78822 0.297596C10.1761 -0.0955083 10.8093 -0.0997053 11.2024 0.288222C11.5653 0.646308 11.5968 1.21334 11.2943 1.60765L11.2118 1.7024L5.31714 7.7024C4.95248 8.07193 4.37282 8.09687 3.97909 7.77976L3.88476 7.69335L0.779404 4.42669C0.396475 4.02871 0.408672 3.39567 0.806647 3.01274C1.17401 2.65926 1.74167 2.64247 2.12801 2.95499L2.2206 3.03998L4.614 5.567L9.78822 0.297596Z",
2462
+ fill: "white"
2463
+ }
2464
+ ) })
2465
+ }
2466
+ )
2467
+ ]
2468
+ }
2469
+ );
2470
+ }
2471
+ );
2467
2472
  Checkbox[exports.CHECKBOX_SYMBOL_KEY] = true;
2468
2473
  exports.Checkbox = Checkbox;
2469
2474