@shoplflow/base 0.30.3 → 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.d.cts CHANGED
@@ -1090,11 +1090,11 @@ declare const CheckboxStyleVariants: {
1090
1090
  declare type CheckboxStyleVariantType = $Values<typeof CheckboxStyleVariants>;
1091
1091
  interface CheckboxProps extends CheckboxOptionProps {
1092
1092
  }
1093
- interface CheckboxOptionProps extends StyleVariantProps<CheckboxStyleVariantType>, SelectedProps, DefaultSelectedProps, DisableProps, ButtonHTMLAttributes<HTMLButtonElement> {
1093
+ interface CheckboxOptionProps extends StyleVariantProps<CheckboxStyleVariantType>, SelectedProps, DefaultSelectedProps, DisableProps, Omit<InputHTMLAttributes<HTMLInputElement>, 'onMouseLeave' | 'onMouseEnter'>, Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'onMouseLeave' | 'onMouseEnter'> {
1094
1094
  }
1095
1095
 
1096
1096
  declare const CHECKBOX_SYMBOL_KEY: unique symbol;
1097
- declare const Checkbox: ({ defaultSelected, isSelected, disabled, onClick, onMouseEnter, onMouseLeave, styleVar, ...rest }: CheckboxProps) => react_jsx_runtime.JSX.Element;
1097
+ declare const Checkbox: React__default.ForwardRefExoticComponent<CheckboxProps & React__default.RefAttributes<HTMLInputElement>>;
1098
1098
 
1099
1099
  interface RadioProps extends RadioOptionProps {
1100
1100
  }
package/dist/index.d.ts CHANGED
@@ -1090,11 +1090,11 @@ declare const CheckboxStyleVariants: {
1090
1090
  declare type CheckboxStyleVariantType = $Values<typeof CheckboxStyleVariants>;
1091
1091
  interface CheckboxProps extends CheckboxOptionProps {
1092
1092
  }
1093
- interface CheckboxOptionProps extends StyleVariantProps<CheckboxStyleVariantType>, SelectedProps, DefaultSelectedProps, DisableProps, ButtonHTMLAttributes<HTMLButtonElement> {
1093
+ interface CheckboxOptionProps extends StyleVariantProps<CheckboxStyleVariantType>, SelectedProps, DefaultSelectedProps, DisableProps, Omit<InputHTMLAttributes<HTMLInputElement>, 'onMouseLeave' | 'onMouseEnter'>, Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'onMouseLeave' | 'onMouseEnter'> {
1094
1094
  }
1095
1095
 
1096
1096
  declare const CHECKBOX_SYMBOL_KEY: unique symbol;
1097
- declare const Checkbox: ({ defaultSelected, isSelected, disabled, onClick, onMouseEnter, onMouseLeave, styleVar, ...rest }: CheckboxProps) => react_jsx_runtime.JSX.Element;
1097
+ declare const Checkbox: React__default.ForwardRefExoticComponent<CheckboxProps & React__default.RefAttributes<HTMLInputElement>>;
1098
1098
 
1099
1099
  interface RadioProps extends RadioOptionProps {
1100
1100
  }
package/dist/index.js CHANGED
@@ -2358,7 +2358,14 @@ var getStylesByStyleVariant = (styleVariant, isSelected, isHovered) => {
2358
2358
  return "";
2359
2359
  }
2360
2360
  };
2361
- var StyledCheckbox = styled6.button`
2361
+ var StyledCheckHiddenInput = styled6.input`
2362
+ position: absolute;
2363
+ width: 0;
2364
+ height: 0;
2365
+ opacity: 0;
2366
+ visibility: hidden;
2367
+ `;
2368
+ var StyledCheckbox = styled6.label`
2362
2369
  display: flex;
2363
2370
  align-items: center;
2364
2371
  justify-content: center;
@@ -2383,62 +2390,60 @@ var Container3 = styled6.button`
2383
2390
  background-color: transparent;
2384
2391
  `;
2385
2392
  var CHECKBOX_SYMBOL_KEY = Symbol("SHOPLFLOW_CHECKBOX");
2386
- var Checkbox = (_a) => {
2387
- var _b = _a, {
2388
- defaultSelected,
2389
- isSelected,
2390
- disabled,
2391
- onClick,
2392
- onMouseEnter,
2393
- onMouseLeave,
2394
- styleVar = "PRIMARY"
2395
- } = _b, rest = __objRest(_b, [
2396
- "defaultSelected",
2397
- "isSelected",
2398
- "disabled",
2399
- "onClick",
2400
- "onMouseEnter",
2401
- "onMouseLeave",
2402
- "styleVar"
2403
- ]);
2404
- const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
2405
- const [isHovered, toggleHovered] = useState(false);
2406
- const handleMouseLeave = (e) => {
2407
- toggleHovered(false);
2408
- onMouseLeave && onMouseLeave(e);
2409
- };
2410
- const handleMouseEnter = (e) => {
2411
- toggleHovered(true);
2412
- onMouseEnter && onMouseEnter(e);
2413
- };
2414
- const handleClick = (e) => {
2415
- if (disabled) {
2416
- return;
2417
- }
2418
- onClick && onClick(e);
2419
- toggleSelected();
2420
- };
2421
- return /* @__PURE__ */ jsx(
2422
- Container3,
2423
- __spreadProps(__spreadValues({
2424
- onClick: handleClick,
2425
- onMouseLeave: handleMouseLeave,
2426
- onMouseEnter: handleMouseEnter,
2427
- disabled
2428
- }, rest), {
2429
- "data-shoplflow": "Checkbox",
2430
- children: /* @__PURE__ */ jsx(StyledCheckbox, { styleVar, isHovered, isSelected: selected, disabled, children: /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "8", viewBox: "0 0 12 8", fill: "none", children: /* @__PURE__ */ jsx(
2431
- "path",
2432
- {
2433
- fillRule: "evenodd",
2434
- clipRule: "evenodd",
2435
- 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",
2436
- fill: "white"
2437
- }
2438
- ) }) })
2439
- })
2440
- );
2441
- };
2393
+ var Checkbox = forwardRef(
2394
+ (_a, ref) => {
2395
+ var _b = _a, { defaultSelected, isSelected, disabled, onMouseEnter, onMouseLeave, styleVar = "PRIMARY", id } = _b, rest = __objRest(_b, ["defaultSelected", "isSelected", "disabled", "onMouseEnter", "onMouseLeave", "styleVar", "id"]);
2396
+ const [selected, toggleSelected] = useOnToggle(isSelected, defaultSelected);
2397
+ const [isHovered, toggleHovered] = useState(false);
2398
+ const handleMouseLeave = (e) => {
2399
+ toggleHovered(false);
2400
+ onMouseLeave && onMouseLeave(e);
2401
+ };
2402
+ const handleMouseEnter = (e) => {
2403
+ toggleHovered(true);
2404
+ onMouseEnter && onMouseEnter(e);
2405
+ };
2406
+ const handleClick = () => {
2407
+ if (disabled) {
2408
+ return;
2409
+ }
2410
+ toggleSelected();
2411
+ };
2412
+ return /* @__PURE__ */ jsxs(
2413
+ Container3,
2414
+ {
2415
+ onClick: handleClick,
2416
+ onMouseLeave: handleMouseLeave,
2417
+ onMouseEnter: handleMouseEnter,
2418
+ disabled,
2419
+ type: "button",
2420
+ "data-shoplflow": "Checkbox",
2421
+ children: [
2422
+ /* @__PURE__ */ jsx(StyledCheckHiddenInput, __spreadProps(__spreadValues({ type: "checkbox", disabled, id }, rest), { ref })),
2423
+ /* @__PURE__ */ jsx(
2424
+ StyledCheckbox,
2425
+ {
2426
+ styleVar,
2427
+ htmlFor: "id",
2428
+ isHovered,
2429
+ isSelected: selected,
2430
+ disabled,
2431
+ children: /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "8", viewBox: "0 0 12 8", fill: "none", children: /* @__PURE__ */ jsx(
2432
+ "path",
2433
+ {
2434
+ fillRule: "evenodd",
2435
+ clipRule: "evenodd",
2436
+ 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",
2437
+ fill: "white"
2438
+ }
2439
+ ) })
2440
+ }
2441
+ )
2442
+ ]
2443
+ }
2444
+ );
2445
+ }
2446
+ );
2442
2447
  Checkbox[CHECKBOX_SYMBOL_KEY] = true;
2443
2448
  var Checkbox_default = Checkbox;
2444
2449