@bento/checkbox 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -26,53 +26,8 @@ The following properties are available to be used on the `CheckboxGroup` and `Ch
26
26
 
27
27
  ### Checkbox
28
28
 
29
- | Prop | Type | Required | Description |
30
- |------|------|----------|------------|
31
- | `value` | `string` | No | The value of the checkbox, used when submitting an HTML form. |
32
- | `name` | `string` | No | The name of the checkbox. |
33
- | `inputRef` | `Ref<HTMLInputElement>` | No | A ref for the HTML input element. |
34
- | `children` | `ReactNode` | No | The label for the checkbox. Accepts any renderable node. |
35
- | `isRequired` | `boolean` | No | Whether the checkbox is required or not. |
36
- | `isReadOnly` | `boolean` | No | Whether the input can be selected but not changed by the user. |
37
- | `isDisabled` | `boolean` | No | Whether the checkbox is disabled or not. Shows that a selection exists,
38
- but is not available in that circumstance. |
39
- | `autoFocus` | `boolean` | No | Whether the element should receive focus on render. |
40
- | `isIndeterminate` | `boolean` | No | Whether the checkbox is in an indeterminate state. |
41
- | `isSelected` | `boolean` | No | Whether the checkbox is in a selected state. |
42
- | `slot` | `string` | No | A named part of a component that can be customized. This is implemented by the consuming component.
43
- The exposed slot names of a component are available in the components documentation. |
44
- | `slots` | `Record<string, object \| Function>` | No | An object that contains the customizations for the slots.
45
- The main way you interact with the slot system as a consumer. |
46
- | `ref` | `Ref<HTMLDivElement> \| LegacyRef<Component<CheckboxProps & Slots, any, any>>` | No | Allows getting a ref to the component instance.
47
- Once the component unmounts, React will set `ref.current` to `null`
48
- (or call the ref with `null` if you passed a callback ref).
49
- @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
50
- | `as` | `"div"` | No | |
51
-
52
29
  ### CheckboxGroup
53
30
 
54
- | Prop | Type | Required | Description |
55
- |------|------|----------|------------|
56
- | `value` | `string[]` | No | The current value of the checkbox group (controlled). |
57
- | `defaultValue` | `string[]` | No | The default value of the checkbox group (uncontrolled). |
58
- | `isDisabled` | `boolean` | No | Whether the input is disabled. |
59
- | `isReadOnly` | `boolean` | No | Whether the input can be selected but not changed by the user. |
60
- | `isRequired` | `boolean` | No | Whether user input is required on the input before form submission. |
61
- | `isInvalid` | `boolean` | No | Whether the input value is invalid. |
62
- | `name` | `string` | No | The name of the input element, used when submitting an HTML form. |
63
- | `form` | `string` | No | The `<form>` element to associate the input with.
64
- The value of this attribute must be the id of a `<form>` in the same document. |
65
- | `children` | `ReactNode` | No | Checkbox children. |
66
- | `slot` | `string` | No | A named part of a component that can be customized. This is implemented by the consuming component.
67
- The exposed slot names of a component are available in the components documentation. |
68
- | `slots` | `Record<string, object \| Function>` | No | An object that contains the customizations for the slots.
69
- The main way you interact with the slot system as a consumer. |
70
- | `ref` | `Ref<HTMLDivElement> \| LegacyRef<Component<CheckboxGroupProps & Slots, any, any>>` | No | Allows getting a ref to the component instance.
71
- Once the component unmounts, React will set `ref.current` to `null`
72
- (or call the ref with `null` if you passed a callback ref).
73
- @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
74
- | `as` | `"div"` | No | |
75
-
76
31
  ## Data Attributes, Slot Map and Props
77
32
 
78
33
  ### Data Attributes
package/dist/index.cjs CHANGED
@@ -1,29 +1,29 @@
1
1
  'use strict';
2
2
 
3
- var React2 = require('react');
3
+ var React = require('react');
4
4
  var container = require('@bento/container');
5
5
  var useDataAttributes = require('@bento/use-data-attributes');
6
6
  var icon = require('@bento/icon');
7
+ var input = require('@bento/input');
7
8
  var slots = require('@bento/slots');
8
9
  var useProps = require('@bento/use-props');
9
10
  var visuallyHidden = require('@bento/visually-hidden');
10
11
  var utils = require('@react-aria/utils');
11
12
  var reactAria = require('react-aria');
12
13
  var reactStately = require('react-stately');
14
+ var jsxRuntime = require('react/jsx-runtime');
13
15
 
14
16
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
17
 
16
- var React2__default = /*#__PURE__*/_interopDefault(React2);
17
-
18
- // src/checkbox.tsx
19
- var CheckboxGroupStateContext = React2__default.default.createContext(null);
18
+ var React__default = /*#__PURE__*/_interopDefault(React);
20
19
 
21
20
  // src/checkbox.tsx
21
+ var CheckboxGroupStateContext = React__default.default.createContext(null);
22
22
  var Checkbox = slots.withSlots("BentoCheckbox", function Checkbox2(args) {
23
23
  const { props, apply } = useProps.useProps(args);
24
- const groupState = React2.useContext(CheckboxGroupStateContext);
25
- const ref = React2.useRef(null);
26
- const inputRef = utils.useObjectRef(React2.useMemo(() => utils.mergeRefs(ref, props.inputRef), [ref, props.inputRef]));
24
+ const groupState = React.useContext(CheckboxGroupStateContext);
25
+ const ref = React.useRef(null);
26
+ const inputRef = utils.useObjectRef(React.useMemo(() => utils.mergeRefs(ref, props.inputRef), [ref, props.inputRef]));
27
27
  const { isFocused, isFocusVisible, focusProps } = reactAria.useFocusRing();
28
28
  const { labelProps, inputProps, isSelected, isPressed, isDisabled, isReadOnly, isInvalid } = groupState ? reactAria.useCheckboxGroupItem(
29
29
  {
@@ -40,7 +40,7 @@ var Checkbox = slots.withSlots("BentoCheckbox", function Checkbox2(args) {
40
40
  ...props,
41
41
  isDisabled: interactionDisabled
42
42
  });
43
- return /* @__PURE__ */ React2__default.default.createElement(
43
+ return /* @__PURE__ */ jsxRuntime.jsxs(
44
44
  container.Container,
45
45
  {
46
46
  as: "label",
@@ -57,11 +57,13 @@ var Checkbox = slots.withSlots("BentoCheckbox", function Checkbox2(args) {
57
57
  invalid: isInvalid,
58
58
  required: props.isRequired,
59
59
  indeterminate: props.isIndeterminate
60
- })
61
- },
62
- /* @__PURE__ */ React2__default.default.createElement(visuallyHidden.VisuallyHidden, null, /* @__PURE__ */ React2__default.default.createElement("input", { ...utils.mergeProps(inputProps, focusProps), ref: inputRef })),
63
- props.isIndeterminate ? /* @__PURE__ */ React2__default.default.createElement(icon.Icon, { slot: "icon-indeterminate", icon: "checkboxIndeterminate" }, /* @__PURE__ */ React2__default.default.createElement("svg", { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React2__default.default.createElement("rect", { x: "6", y: "11", width: "12", height: "2", fill: "currentColor" }))) : isSelected ? /* @__PURE__ */ React2__default.default.createElement(icon.Icon, { slot: "icon-checked", icon: "checkboxChecked" }, /* @__PURE__ */ React2__default.default.createElement("svg", { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React2__default.default.createElement("path", { d: "M9,16.2L4.8,12l-1.4,1.4L9,19L21,7l-1.4-1.4L9,16.2z", fill: "currentColor" }))) : /* @__PURE__ */ React2__default.default.createElement(icon.Icon, { slot: "icon-unchecked", icon: "checkboxUnchecked" }, /* @__PURE__ */ React2__default.default.createElement("svg", { width: 24, height: 24 }, /* @__PURE__ */ React2__default.default.createElement("rect", { x: 4, y: 4, width: 16, height: 16, rx: 3, fill: "none", stroke: "gray", strokeWidth: 2 }))),
64
- props.children
60
+ }),
61
+ children: [
62
+ /* @__PURE__ */ jsxRuntime.jsx(visuallyHidden.VisuallyHidden, { children: /* @__PURE__ */ jsxRuntime.jsx(input.Input, { ...utils.mergeProps(inputProps, focusProps), ref: inputRef }) }),
63
+ props.isIndeterminate ? /* @__PURE__ */ jsxRuntime.jsx(icon.Icon, { slot: "icon-indeterminate", icon: "checkboxIndeterminate", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "6", y: "11", width: "12", height: "2", fill: "currentColor" }) }) }) : isSelected ? /* @__PURE__ */ jsxRuntime.jsx(icon.Icon, { slot: "icon-checked", icon: "checkboxChecked", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9,16.2L4.8,12l-1.4,1.4L9,19L21,7l-1.4-1.4L9,16.2z", fill: "currentColor" }) }) }) : /* @__PURE__ */ jsxRuntime.jsx(icon.Icon, { slot: "icon-unchecked", icon: "checkboxUnchecked", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: 24, height: 24, children: /* @__PURE__ */ jsxRuntime.jsx("rect", { x: 4, y: 4, width: 16, height: 16, rx: 3, fill: "none", stroke: "gray", strokeWidth: 2 }) }) }),
64
+ props.children
65
+ ]
66
+ }
65
67
  );
66
68
  });
67
69
  var CheckboxGroup = slots.withSlots("BentoCheckboxGroup", function CheckboxGroup2(args) {
@@ -71,7 +73,7 @@ var CheckboxGroup = slots.withSlots("BentoCheckboxGroup", function CheckboxGroup
71
73
  { ...props, label: props.label ?? "Checkbox Group", description: props.description ?? "Description" },
72
74
  state
73
75
  );
74
- return /* @__PURE__ */ React2__default.default.createElement(CheckboxGroupStateContext.Provider, { value: state }, /* @__PURE__ */ React2__default.default.createElement(
76
+ return /* @__PURE__ */ jsxRuntime.jsx(CheckboxGroupStateContext.Provider, { value: state, children: /* @__PURE__ */ jsxRuntime.jsx(
75
77
  container.Container,
76
78
  {
77
79
  ...apply(groupProps),
@@ -86,10 +88,10 @@ var CheckboxGroup = slots.withSlots("BentoCheckboxGroup", function CheckboxGroup
86
88
  label: labelProps,
87
89
  description: descriptionProps,
88
90
  error: reactAria.mergeProps(errorMessageProps, validationResult)
89
- }
90
- },
91
- props.children
92
- ));
91
+ },
92
+ children: props.children
93
+ }
94
+ ) });
93
95
  });
94
96
 
95
97
  exports.Checkbox = Checkbox;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/checkbox-group-state.tsx","../src/checkbox.tsx","../src/checkbox-group.tsx"],"names":["React","withSlots","Checkbox","useProps","useContext","useRef","useObjectRef","useMemo","mergeRefs","useFocusRing","useCheckboxGroupItem","useCheckbox","useToggleState","useHover","Container","mergeProps","useDataAttributes","VisuallyHidden","Icon","CheckboxGroup","useCheckboxGroupState","useCheckboxGroup"],"mappings":";;;;;;;;;;;;;;;;;;AAGO,IAAM,yBAAA,GAA4BA,uBAA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AAA,EAAa,MAAM,WAAA,IAAe,UAAA;AAAA,QAClC,SAAS,KAAA,CAAM,SAAA;AAAA,QACf,UAAU,KAAA,CAAM,UAAA;AAAA,QAChB,UAAU,KAAA,CAAM,UAAA;AAAA,QAChB,UAAU,KAAA,CAAM;AAAA,OACjB,CAAA;AAAA,MACD,KAAA,EAAO;AAAA,QACL,KAAA,EAAO,UAAA;AAAA,QACP,WAAA,EAAa,gBAAA;AAAA,QACb,KAAA,EAAOD,oBAAAA,CAAW,iBAAA,EAAmB,gBAAgB;AAAA;AACvD,KAAA;AAAA,IAEC,KAAA,CAAM;AAAA,GAEX,CAAA;AAEJ,CAAC","file":"index.cjs","sourcesContent":["import React from 'react';\nimport { CheckboxGroupState } from 'react-stately';\n\nexport const CheckboxGroupStateContext = React.createContext<CheckboxGroupState | null>(null);\n","import React, { useContext, useRef, useMemo } from 'react';\nimport { Container, type ContainerProps } from '@bento/container';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { Icon } from '@bento/icon';\nimport { withSlots } from '@bento/slots';\nimport { useProps } from '@bento/use-props';\nimport { VisuallyHidden } from '@bento/visually-hidden';\nimport { mergeProps, mergeRefs, useObjectRef } from '@react-aria/utils';\nimport { useFocusRing, useHover, useCheckbox, useCheckboxGroupItem, type AriaCheckboxProps } from 'react-aria';\nimport { useToggleState } from 'react-stately';\nimport { CheckboxGroupStateContext } from './checkbox-group-state';\n\nexport interface CheckboxProps extends AriaCheckboxProps, Omit<ContainerProps, keyof AriaCheckboxProps> {\n /** The value of the checkbox, used when submitting an HTML form. */\n value?: string;\n\n /** The name of the checkbox. */\n name?: string;\n\n /** A ref for the HTML input element. */\n inputRef?: React.Ref<HTMLInputElement>;\n\n /** The label for the checkbox. Accepts any renderable node. */\n children?: React.ReactNode;\n\n /** Whether the checkbox is required or not. */\n isRequired?: boolean;\n\n /** Whether the input can be selected but not changed by the user. */\n isReadOnly?: boolean;\n\n /**\n * Whether the checkbox is disabled or not. Shows that a selection exists,\n * but is not available in that circumstance.\n */\n isDisabled?: boolean;\n\n /** Whether the element should receive focus on render. */\n autoFocus?: boolean;\n\n /** Whether the checkbox is in an indeterminate state. */\n isIndeterminate?: boolean;\n\n /** Whether the checkbox is in a selected state. */\n isSelected?: boolean;\n}\n\n/**\n * The `Checkbox` is a single checkbox option that can be selected by the user.\n */\nexport const Checkbox = withSlots('BentoCheckbox', function Checkbox(args: CheckboxProps) {\n const { props, apply } = useProps(args);\n const groupState = useContext(CheckboxGroupStateContext);\n const ref = useRef<HTMLInputElement>(null);\n const inputRef = useObjectRef(useMemo(() => mergeRefs(ref, props.inputRef), [ref, props.inputRef]));\n const { isFocused, isFocusVisible, focusProps } = useFocusRing();\n\n const { labelProps, inputProps, isSelected, isPressed, isDisabled, isReadOnly, isInvalid } = groupState\n ? useCheckboxGroupItem(\n {\n ...props,\n // Value is optional for standalone checkboxes, but required for CheckboxGroup items;\n // it's passed explicitly here to avoid typescript error (requires ignore)(recommendation from React Aria).\n value: (props as Required<Pick<typeof props, 'value'>>).value\n },\n groupState,\n inputRef\n )\n : useCheckbox(props, useToggleState(props), inputRef);\n\n const interactionDisabled = props.isDisabled || isDisabled || isReadOnly;\n const { hoverProps, isHovered } = useHover({\n ...props,\n isDisabled: interactionDisabled\n });\n\n return (\n <Container\n as=\"label\"\n aria-checked={props.isIndeterminate ? 'mixed' : undefined}\n {...apply(mergeProps(labelProps, hoverProps))}\n {...useDataAttributes({\n selected: isSelected,\n pressed: isPressed,\n hovered: isHovered,\n focused: isFocused,\n focusVisible: isFocusVisible,\n disabled: interactionDisabled,\n readonly: isReadOnly,\n invalid: isInvalid,\n required: props.isRequired,\n indeterminate: props.isIndeterminate\n })}\n >\n <VisuallyHidden>\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n\n {props.isIndeterminate ? (\n <Icon slot=\"icon-indeterminate\" icon=\"checkboxIndeterminate\">\n <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"6\" y=\"11\" width=\"12\" height=\"2\" fill=\"currentColor\" />\n </svg>\n </Icon>\n ) : isSelected ? (\n <Icon slot=\"icon-checked\" icon=\"checkboxChecked\">\n <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M9,16.2L4.8,12l-1.4,1.4L9,19L21,7l-1.4-1.4L9,16.2z\" fill=\"currentColor\" />\n </svg>\n </Icon>\n ) : (\n <Icon slot=\"icon-unchecked\" icon=\"checkboxUnchecked\">\n <svg width={24} height={24}>\n <rect x={4} y={4} width={16} height={16} rx={3} fill=\"none\" stroke=\"gray\" strokeWidth={2} />\n </svg>\n </Icon>\n )}\n {props.children}\n </Container>\n );\n});\n","import React from 'react';\nimport { withSlots } from '@bento/slots';\nimport { Container, type ContainerProps } from '@bento/container';\nimport { useProps } from '@bento/use-props';\nimport { useCheckboxGroup, mergeProps, type AriaCheckboxGroupProps } from 'react-aria';\nimport { useCheckboxGroupState } from 'react-stately';\nimport { CheckboxGroupStateContext } from './checkbox-group-state';\nimport { useDataAttributes } from '@bento/use-data-attributes';\n\nexport interface CheckboxGroupProps extends AriaCheckboxGroupProps, Omit<ContainerProps, keyof AriaCheckboxGroupProps> {\n /** The current value of the checkbox group (controlled). */\n value?: string[];\n\n /** The default value of the checkbox group (uncontrolled). */\n defaultValue?: string[];\n\n /** Whether the input is disabled. */\n isDisabled?: boolean;\n\n /** Whether the input can be selected but not changed by the user. */\n isReadOnly?: boolean;\n\n /** Whether user input is required on the input before form submission. */\n isRequired?: boolean;\n\n /** Whether the input value is invalid. */\n isInvalid?: boolean;\n\n /** The name of the input element, used when submitting an HTML form. */\n name?: string;\n\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n */\n form?: string;\n\n /** Checkbox children. */\n children?: React.ReactNode;\n}\n\n/**\n * The `CheckboxGroup` allows a user to select items from a list of `Checkbox` components.\n */\nexport const CheckboxGroup = withSlots('BentoCheckboxGroup', function CheckboxGroup(args: CheckboxGroupProps) {\n const { props, apply } = useProps(args);\n const state = useCheckboxGroupState(props);\n const { groupProps, labelProps, descriptionProps, errorMessageProps, ...validationResult } = useCheckboxGroup(\n { ...props, label: props.label ?? 'Checkbox Group', description: props.description ?? 'Description' },\n state\n );\n\n return (\n <CheckboxGroupStateContext.Provider value={state}>\n <Container\n {...apply(groupProps)}\n {...useDataAttributes({\n orientation: props.orientation || 'vertical',\n invalid: state.isInvalid,\n disabled: state.isDisabled,\n readonly: state.isReadOnly,\n required: state.isRequired\n })}\n slots={{\n label: labelProps,\n description: descriptionProps,\n error: mergeProps(errorMessageProps, validationResult)\n }}\n >\n {props.children}\n </Container>\n </CheckboxGroupStateContext.Provider>\n );\n});\n"]}
1
+ {"version":3,"sources":["../src/checkbox-group-state.tsx","../src/checkbox.tsx","../src/checkbox-group.tsx"],"names":["React","withSlots","Checkbox","useProps","useContext","useRef","useObjectRef","useMemo","mergeRefs","useFocusRing","useCheckboxGroupItem","useCheckbox","useToggleState","useHover","jsxs","Container","mergeProps","useDataAttributes","jsx","VisuallyHidden","Input","Icon","CheckboxGroup","useCheckboxGroupState","useCheckboxGroup"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGO,IAAM,yBAAA,GAA4BA,sBAAA,CAAM,aAAA,CAAyC,IAAI,CAAA;ACgDrF,IAAM,QAAA,GAAWC,eAAA,CAAU,eAAA,EAAiB,SAASC,UAAS,IAAA,EAAqB;AACxF,EAAA,MAAM,EAAE,KAAA,EAAO,KAAA,EAAM,GAAIC,kBAAS,IAAI,CAAA;AACtC,EAAA,MAAM,UAAA,GAAaC,iBAAW,yBAAyB,CAAA;AACvD,EAAA,MAAM,GAAA,GAAMC,aAAyB,IAAI,CAAA;AACzC,EAAA,MAAM,QAAA,GAAWC,kBAAA,CAAaC,aAAA,CAAQ,MAAMC,gBAAU,GAAA,EAAK,KAAA,CAAM,QAAQ,CAAA,EAAG,CAAC,GAAA,EAAK,KAAA,CAAM,QAAQ,CAAC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AAAA;AAAA,GACT;AAEJ,CAAC;AC7EM,IAAM,aAAA,GAAgBjB,eAAAA,CAAU,oBAAA,EAAsB,SAASqB,eAAc,IAAA,EAA0B;AAC5G,EAAA,MAAM,EAAE,KAAA,EAAO,KAAA,EAAM,GAAInB,kBAAS,IAAI,CAAA;AACtC,EAAA,MAAM,KAAA,GAAQoB,mCAAsB,KAAK,CAAA;AACzC,EAAA,MAAM,EAAE,UAAA,EAAY,UAAA,EAAY,kBAAkB,iBAAA,EAAmB,GAAG,kBAAiB,GAAIC,0BAAA;AAAA,IAC3F,EAAE,GAAG,KAAA,EAAO,KAAA,EAAO,KAAA,CAAM,SAAS,gBAAA,EAAkB,WAAA,EAAa,KAAA,CAAM,WAAA,IAAe,aAAA,EAAc;AAAA,IACpG;AAAA,GACF;AAEA,EAAA,uBACEN,cAAAA,CAAC,yBAAA,CAA0B,UAA1B,EAAmC,KAAA,EAAO,OACzC,QAAA,kBAAAA,cAAAA;AAAA,IAACH,mBAAAA;AAAA,IAAA;AAAA,MACE,GAAG,MAAM,UAAU,CAAA;AAAA,MACnB,GAAGE,mCAAAA,CAAkB;AAAA,QACpB,WAAA,EAAa,MAAM,WAAA,IAAe,UAAA;AAAA,QAClC,SAAS,KAAA,CAAM,SAAA;AAAA,QACf,UAAU,KAAA,CAAM,UAAA;AAAA,QAChB,UAAU,KAAA,CAAM,UAAA;AAAA,QAChB,UAAU,KAAA,CAAM;AAAA,OACjB,CAAA;AAAA,MACD,KAAA,EAAO;AAAA,QACL,KAAA,EAAO,UAAA;AAAA,QACP,WAAA,EAAa,gBAAA;AAAA,QACb,KAAA,EAAOD,oBAAAA,CAAW,iBAAA,EAAmB,gBAAgB;AAAA,OACvD;AAAA,MAEC,QAAA,EAAA,KAAA,CAAM;AAAA;AAAA,GACT,EACF,CAAA;AAEJ,CAAC","file":"index.cjs","sourcesContent":["import React from 'react';\nimport { CheckboxGroupState } from 'react-stately';\n\nexport const CheckboxGroupStateContext = React.createContext<CheckboxGroupState | null>(null);\n","import React, { useContext, useRef, useMemo } from 'react';\nimport { Container, type ContainerProps } from '@bento/container';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { Icon } from '@bento/icon';\nimport { Input } from '@bento/input';\nimport { withSlots } from '@bento/slots';\nimport { useProps } from '@bento/use-props';\nimport { VisuallyHidden } from '@bento/visually-hidden';\nimport { mergeProps, mergeRefs, useObjectRef } from '@react-aria/utils';\nimport { useFocusRing, useHover, useCheckbox, useCheckboxGroupItem, type AriaCheckboxProps } from 'react-aria';\nimport { useToggleState } from 'react-stately';\nimport { CheckboxGroupStateContext } from './checkbox-group-state';\n\nexport interface CheckboxProps extends AriaCheckboxProps, Omit<ContainerProps, keyof AriaCheckboxProps> {\n /** The value of the checkbox, used when submitting an HTML form. */\n value?: string;\n\n /** The name of the checkbox. */\n name?: string;\n\n /** A ref for the HTML input element. */\n inputRef?: React.Ref<HTMLInputElement>;\n\n /** The label for the checkbox. Accepts any renderable node. */\n children?: React.ReactNode;\n\n /** Whether the checkbox is required or not. */\n isRequired?: boolean;\n\n /** Whether the input can be selected but not changed by the user. */\n isReadOnly?: boolean;\n\n /**\n * Whether the checkbox is disabled or not. Shows that a selection exists,\n * but is not available in that circumstance.\n */\n isDisabled?: boolean;\n\n /** Whether the element should receive focus on render. */\n autoFocus?: boolean;\n\n /** Whether the checkbox is in an indeterminate state. */\n isIndeterminate?: boolean;\n\n /** Whether the checkbox is in a selected state. */\n isSelected?: boolean;\n}\n\n/**\n * The `Checkbox` is a single checkbox option that can be selected by the user.\n */\nexport const Checkbox = withSlots('BentoCheckbox', function Checkbox(args: CheckboxProps) {\n const { props, apply } = useProps(args);\n const groupState = useContext(CheckboxGroupStateContext);\n const ref = useRef<HTMLInputElement>(null);\n const inputRef = useObjectRef(useMemo(() => mergeRefs(ref, props.inputRef), [ref, props.inputRef]));\n const { isFocused, isFocusVisible, focusProps } = useFocusRing();\n\n const { labelProps, inputProps, isSelected, isPressed, isDisabled, isReadOnly, isInvalid } = groupState\n ? useCheckboxGroupItem(\n {\n ...props,\n // Value is optional for standalone checkboxes, but required for CheckboxGroup items;\n // it's passed explicitly here to avoid typescript error (requires ignore)(recommendation from React Aria).\n value: (props as Required<Pick<typeof props, 'value'>>).value\n },\n groupState,\n inputRef\n )\n : useCheckbox(props, useToggleState(props), inputRef);\n\n const interactionDisabled = props.isDisabled || isDisabled || isReadOnly;\n const { hoverProps, isHovered } = useHover({\n ...props,\n isDisabled: interactionDisabled\n });\n\n return (\n <Container\n as=\"label\"\n aria-checked={props.isIndeterminate ? 'mixed' : undefined}\n {...apply(mergeProps(labelProps, hoverProps))}\n {...useDataAttributes({\n selected: isSelected,\n pressed: isPressed,\n hovered: isHovered,\n focused: isFocused,\n focusVisible: isFocusVisible,\n disabled: interactionDisabled,\n readonly: isReadOnly,\n invalid: isInvalid,\n required: props.isRequired,\n indeterminate: props.isIndeterminate\n })}\n >\n <VisuallyHidden>\n <Input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n\n {props.isIndeterminate ? (\n <Icon slot=\"icon-indeterminate\" icon=\"checkboxIndeterminate\">\n <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"6\" y=\"11\" width=\"12\" height=\"2\" fill=\"currentColor\" />\n </svg>\n </Icon>\n ) : isSelected ? (\n <Icon slot=\"icon-checked\" icon=\"checkboxChecked\">\n <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M9,16.2L4.8,12l-1.4,1.4L9,19L21,7l-1.4-1.4L9,16.2z\" fill=\"currentColor\" />\n </svg>\n </Icon>\n ) : (\n <Icon slot=\"icon-unchecked\" icon=\"checkboxUnchecked\">\n <svg width={24} height={24}>\n <rect x={4} y={4} width={16} height={16} rx={3} fill=\"none\" stroke=\"gray\" strokeWidth={2} />\n </svg>\n </Icon>\n )}\n {props.children}\n </Container>\n );\n});\n","import React from 'react';\nimport { withSlots } from '@bento/slots';\nimport { Container, type ContainerProps } from '@bento/container';\nimport { useProps } from '@bento/use-props';\nimport { useCheckboxGroup, mergeProps, type AriaCheckboxGroupProps } from 'react-aria';\nimport { useCheckboxGroupState } from 'react-stately';\nimport { CheckboxGroupStateContext } from './checkbox-group-state';\nimport { useDataAttributes } from '@bento/use-data-attributes';\n\nexport interface CheckboxGroupProps extends AriaCheckboxGroupProps, Omit<ContainerProps, keyof AriaCheckboxGroupProps> {\n /** The current value of the checkbox group (controlled). */\n value?: string[];\n\n /** The default value of the checkbox group (uncontrolled). */\n defaultValue?: string[];\n\n /** Whether the input is disabled. */\n isDisabled?: boolean;\n\n /** Whether the input can be selected but not changed by the user. */\n isReadOnly?: boolean;\n\n /** Whether user input is required on the input before form submission. */\n isRequired?: boolean;\n\n /** Whether the input value is invalid. */\n isInvalid?: boolean;\n\n /** The name of the input element, used when submitting an HTML form. */\n name?: string;\n\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n */\n form?: string;\n\n /** Checkbox children. */\n children?: React.ReactNode;\n}\n\n/**\n * The `CheckboxGroup` allows a user to select items from a list of `Checkbox` components.\n */\nexport const CheckboxGroup = withSlots('BentoCheckboxGroup', function CheckboxGroup(args: CheckboxGroupProps) {\n const { props, apply } = useProps(args);\n const state = useCheckboxGroupState(props);\n const { groupProps, labelProps, descriptionProps, errorMessageProps, ...validationResult } = useCheckboxGroup(\n { ...props, label: props.label ?? 'Checkbox Group', description: props.description ?? 'Description' },\n state\n );\n\n return (\n <CheckboxGroupStateContext.Provider value={state}>\n <Container\n {...apply(groupProps)}\n {...useDataAttributes({\n orientation: props.orientation || 'vertical',\n invalid: state.isInvalid,\n disabled: state.isDisabled,\n readonly: state.isReadOnly,\n required: state.isRequired\n })}\n slots={{\n label: labelProps,\n description: descriptionProps,\n error: mergeProps(errorMessageProps, validationResult)\n }}\n >\n {props.children}\n </Container>\n </CheckboxGroupStateContext.Provider>\n );\n});\n"]}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,3 @@
1
- import * as _bento_slots from '@bento/slots';
2
1
  import React from 'react';
3
2
  import { ContainerProps } from '@bento/container';
4
3
  import { AriaCheckboxProps, AriaCheckboxGroupProps } from 'react-aria';
@@ -31,7 +30,7 @@ interface CheckboxProps extends AriaCheckboxProps, Omit<ContainerProps, keyof Ar
31
30
  /**
32
31
  * The `Checkbox` is a single checkbox option that can be selected by the user.
33
32
  */
34
- declare const Checkbox: React.MemoExoticComponent<React.ComponentType<CheckboxProps & _bento_slots.Slots>>;
33
+ declare const Checkbox: React.MemoExoticComponent<React.ComponentType<any>>;
35
34
 
36
35
  interface CheckboxGroupProps extends AriaCheckboxGroupProps, Omit<ContainerProps, keyof AriaCheckboxGroupProps> {
37
36
  /** The current value of the checkbox group (controlled). */
@@ -59,6 +58,6 @@ interface CheckboxGroupProps extends AriaCheckboxGroupProps, Omit<ContainerProps
59
58
  /**
60
59
  * The `CheckboxGroup` allows a user to select items from a list of `Checkbox` components.
61
60
  */
62
- declare const CheckboxGroup: React.MemoExoticComponent<React.ComponentType<CheckboxGroupProps & _bento_slots.Slots>>;
61
+ declare const CheckboxGroup: React.MemoExoticComponent<React.ComponentType<any>>;
63
62
 
64
63
  export { Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import * as _bento_slots from '@bento/slots';
2
1
  import React from 'react';
3
2
  import { ContainerProps } from '@bento/container';
4
3
  import { AriaCheckboxProps, AriaCheckboxGroupProps } from 'react-aria';
@@ -31,7 +30,7 @@ interface CheckboxProps extends AriaCheckboxProps, Omit<ContainerProps, keyof Ar
31
30
  /**
32
31
  * The `Checkbox` is a single checkbox option that can be selected by the user.
33
32
  */
34
- declare const Checkbox: React.MemoExoticComponent<React.ComponentType<CheckboxProps & _bento_slots.Slots>>;
33
+ declare const Checkbox: React.MemoExoticComponent<React.ComponentType<any>>;
35
34
 
36
35
  interface CheckboxGroupProps extends AriaCheckboxGroupProps, Omit<ContainerProps, keyof AriaCheckboxGroupProps> {
37
36
  /** The current value of the checkbox group (controlled). */
@@ -59,6 +58,6 @@ interface CheckboxGroupProps extends AriaCheckboxGroupProps, Omit<ContainerProps
59
58
  /**
60
59
  * The `CheckboxGroup` allows a user to select items from a list of `Checkbox` components.
61
60
  */
62
- declare const CheckboxGroup: React.MemoExoticComponent<React.ComponentType<CheckboxGroupProps & _bento_slots.Slots>>;
61
+ declare const CheckboxGroup: React.MemoExoticComponent<React.ComponentType<any>>;
63
62
 
64
63
  export { Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps };
package/dist/index.js CHANGED
@@ -1,18 +1,18 @@
1
- import React2, { useContext, useRef, useMemo } from 'react';
1
+ import React, { useContext, useRef, useMemo } from 'react';
2
2
  import { Container } from '@bento/container';
3
3
  import { useDataAttributes } from '@bento/use-data-attributes';
4
4
  import { Icon } from '@bento/icon';
5
+ import { Input } from '@bento/input';
5
6
  import { withSlots } from '@bento/slots';
6
7
  import { useProps } from '@bento/use-props';
7
8
  import { VisuallyHidden } from '@bento/visually-hidden';
8
9
  import { useObjectRef, mergeRefs, mergeProps } from '@react-aria/utils';
9
10
  import { useFocusRing, useCheckboxGroupItem, useCheckbox, useHover, useCheckboxGroup, mergeProps as mergeProps$1 } from 'react-aria';
10
11
  import { useToggleState, useCheckboxGroupState } from 'react-stately';
12
+ import { jsxs, jsx } from 'react/jsx-runtime';
11
13
 
12
14
  // src/checkbox.tsx
13
- var CheckboxGroupStateContext = React2.createContext(null);
14
-
15
- // src/checkbox.tsx
15
+ var CheckboxGroupStateContext = React.createContext(null);
16
16
  var Checkbox = withSlots("BentoCheckbox", function Checkbox2(args) {
17
17
  const { props, apply } = useProps(args);
18
18
  const groupState = useContext(CheckboxGroupStateContext);
@@ -34,7 +34,7 @@ var Checkbox = withSlots("BentoCheckbox", function Checkbox2(args) {
34
34
  ...props,
35
35
  isDisabled: interactionDisabled
36
36
  });
37
- return /* @__PURE__ */ React2.createElement(
37
+ return /* @__PURE__ */ jsxs(
38
38
  Container,
39
39
  {
40
40
  as: "label",
@@ -51,11 +51,13 @@ var Checkbox = withSlots("BentoCheckbox", function Checkbox2(args) {
51
51
  invalid: isInvalid,
52
52
  required: props.isRequired,
53
53
  indeterminate: props.isIndeterminate
54
- })
55
- },
56
- /* @__PURE__ */ React2.createElement(VisuallyHidden, null, /* @__PURE__ */ React2.createElement("input", { ...mergeProps(inputProps, focusProps), ref: inputRef })),
57
- props.isIndeterminate ? /* @__PURE__ */ React2.createElement(Icon, { slot: "icon-indeterminate", icon: "checkboxIndeterminate" }, /* @__PURE__ */ React2.createElement("svg", { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React2.createElement("rect", { x: "6", y: "11", width: "12", height: "2", fill: "currentColor" }))) : isSelected ? /* @__PURE__ */ React2.createElement(Icon, { slot: "icon-checked", icon: "checkboxChecked" }, /* @__PURE__ */ React2.createElement("svg", { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React2.createElement("path", { d: "M9,16.2L4.8,12l-1.4,1.4L9,19L21,7l-1.4-1.4L9,16.2z", fill: "currentColor" }))) : /* @__PURE__ */ React2.createElement(Icon, { slot: "icon-unchecked", icon: "checkboxUnchecked" }, /* @__PURE__ */ React2.createElement("svg", { width: 24, height: 24 }, /* @__PURE__ */ React2.createElement("rect", { x: 4, y: 4, width: 16, height: 16, rx: 3, fill: "none", stroke: "gray", strokeWidth: 2 }))),
58
- props.children
54
+ }),
55
+ children: [
56
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx(Input, { ...mergeProps(inputProps, focusProps), ref: inputRef }) }),
57
+ props.isIndeterminate ? /* @__PURE__ */ jsx(Icon, { slot: "icon-indeterminate", icon: "checkboxIndeterminate", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("rect", { x: "6", y: "11", width: "12", height: "2", fill: "currentColor" }) }) }) : isSelected ? /* @__PURE__ */ jsx(Icon, { slot: "icon-checked", icon: "checkboxChecked", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { d: "M9,16.2L4.8,12l-1.4,1.4L9,19L21,7l-1.4-1.4L9,16.2z", fill: "currentColor" }) }) }) : /* @__PURE__ */ jsx(Icon, { slot: "icon-unchecked", icon: "checkboxUnchecked", children: /* @__PURE__ */ jsx("svg", { width: 24, height: 24, children: /* @__PURE__ */ jsx("rect", { x: 4, y: 4, width: 16, height: 16, rx: 3, fill: "none", stroke: "gray", strokeWidth: 2 }) }) }),
58
+ props.children
59
+ ]
60
+ }
59
61
  );
60
62
  });
61
63
  var CheckboxGroup = withSlots("BentoCheckboxGroup", function CheckboxGroup2(args) {
@@ -65,7 +67,7 @@ var CheckboxGroup = withSlots("BentoCheckboxGroup", function CheckboxGroup2(args
65
67
  { ...props, label: props.label ?? "Checkbox Group", description: props.description ?? "Description" },
66
68
  state
67
69
  );
68
- return /* @__PURE__ */ React2.createElement(CheckboxGroupStateContext.Provider, { value: state }, /* @__PURE__ */ React2.createElement(
70
+ return /* @__PURE__ */ jsx(CheckboxGroupStateContext.Provider, { value: state, children: /* @__PURE__ */ jsx(
69
71
  Container,
70
72
  {
71
73
  ...apply(groupProps),
@@ -80,10 +82,10 @@ var CheckboxGroup = withSlots("BentoCheckboxGroup", function CheckboxGroup2(args
80
82
  label: labelProps,
81
83
  description: descriptionProps,
82
84
  error: mergeProps$1(errorMessageProps, validationResult)
83
- }
84
- },
85
- props.children
86
- ));
85
+ },
86
+ children: props.children
87
+ }
88
+ ) });
87
89
  });
88
90
 
89
91
  export { Checkbox, CheckboxGroup };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/checkbox-group-state.tsx","../src/checkbox.tsx","../src/checkbox-group.tsx"],"names":["React","Checkbox","with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BAAAA,CAAkB;AAAA,QACpB,WAAA,EAAa,MAAM,WAAA,IAAe,UAAA;AAAA,QAClC,SAAS,KAAA,CAAM,SAAA;AAAA,QACf,UAAU,KAAA,CAAM,UAAA;AAAA,QAChB,UAAU,KAAA,CAAM,UAAA;AAAA,QAChB,UAAU,KAAA,CAAM;AAAA,OACjB,CAAA;AAAA,MACD,KAAA,EAAO;AAAA,QACL,KAAA,EAAO,UAAA;AAAA,QACP,WAAA,EAAa,gBAAA;AAAA,QACb,KAAA,EAAOC,YAAAA,CAAW,iBAAA,EAAmB,gBAAgB;AAAA;AACvD,KAAA;AAAA,IAEC,KAAA,CAAM;AAAA,GAEX,CAAA;AAEJ,CAAC","file":"index.js","sourcesContent":["import React from 'react';\nimport { CheckboxGroupState } from 'react-stately';\n\nexport const CheckboxGroupStateContext = React.createContext<CheckboxGroupState | null>(null);\n","import React, { useContext, useRef, useMemo } from 'react';\nimport { Container, type ContainerProps } from '@bento/container';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { Icon } from '@bento/icon';\nimport { withSlots } from '@bento/slots';\nimport { useProps } from '@bento/use-props';\nimport { VisuallyHidden } from '@bento/visually-hidden';\nimport { mergeProps, mergeRefs, useObjectRef } from '@react-aria/utils';\nimport { useFocusRing, useHover, useCheckbox, useCheckboxGroupItem, type AriaCheckboxProps } from 'react-aria';\nimport { useToggleState } from 'react-stately';\nimport { CheckboxGroupStateContext } from './checkbox-group-state';\n\nexport interface CheckboxProps extends AriaCheckboxProps, Omit<ContainerProps, keyof AriaCheckboxProps> {\n /** The value of the checkbox, used when submitting an HTML form. */\n value?: string;\n\n /** The name of the checkbox. */\n name?: string;\n\n /** A ref for the HTML input element. */\n inputRef?: React.Ref<HTMLInputElement>;\n\n /** The label for the checkbox. Accepts any renderable node. */\n children?: React.ReactNode;\n\n /** Whether the checkbox is required or not. */\n isRequired?: boolean;\n\n /** Whether the input can be selected but not changed by the user. */\n isReadOnly?: boolean;\n\n /**\n * Whether the checkbox is disabled or not. Shows that a selection exists,\n * but is not available in that circumstance.\n */\n isDisabled?: boolean;\n\n /** Whether the element should receive focus on render. */\n autoFocus?: boolean;\n\n /** Whether the checkbox is in an indeterminate state. */\n isIndeterminate?: boolean;\n\n /** Whether the checkbox is in a selected state. */\n isSelected?: boolean;\n}\n\n/**\n * The `Checkbox` is a single checkbox option that can be selected by the user.\n */\nexport const Checkbox = withSlots('BentoCheckbox', function Checkbox(args: CheckboxProps) {\n const { props, apply } = useProps(args);\n const groupState = useContext(CheckboxGroupStateContext);\n const ref = useRef<HTMLInputElement>(null);\n const inputRef = useObjectRef(useMemo(() => mergeRefs(ref, props.inputRef), [ref, props.inputRef]));\n const { isFocused, isFocusVisible, focusProps } = useFocusRing();\n\n const { labelProps, inputProps, isSelected, isPressed, isDisabled, isReadOnly, isInvalid } = groupState\n ? useCheckboxGroupItem(\n {\n ...props,\n // Value is optional for standalone checkboxes, but required for CheckboxGroup items;\n // it's passed explicitly here to avoid typescript error (requires ignore)(recommendation from React Aria).\n value: (props as Required<Pick<typeof props, 'value'>>).value\n },\n groupState,\n inputRef\n )\n : useCheckbox(props, useToggleState(props), inputRef);\n\n const interactionDisabled = props.isDisabled || isDisabled || isReadOnly;\n const { hoverProps, isHovered } = useHover({\n ...props,\n isDisabled: interactionDisabled\n });\n\n return (\n <Container\n as=\"label\"\n aria-checked={props.isIndeterminate ? 'mixed' : undefined}\n {...apply(mergeProps(labelProps, hoverProps))}\n {...useDataAttributes({\n selected: isSelected,\n pressed: isPressed,\n hovered: isHovered,\n focused: isFocused,\n focusVisible: isFocusVisible,\n disabled: interactionDisabled,\n readonly: isReadOnly,\n invalid: isInvalid,\n required: props.isRequired,\n indeterminate: props.isIndeterminate\n })}\n >\n <VisuallyHidden>\n <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n\n {props.isIndeterminate ? (\n <Icon slot=\"icon-indeterminate\" icon=\"checkboxIndeterminate\">\n <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"6\" y=\"11\" width=\"12\" height=\"2\" fill=\"currentColor\" />\n </svg>\n </Icon>\n ) : isSelected ? (\n <Icon slot=\"icon-checked\" icon=\"checkboxChecked\">\n <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M9,16.2L4.8,12l-1.4,1.4L9,19L21,7l-1.4-1.4L9,16.2z\" fill=\"currentColor\" />\n </svg>\n </Icon>\n ) : (\n <Icon slot=\"icon-unchecked\" icon=\"checkboxUnchecked\">\n <svg width={24} height={24}>\n <rect x={4} y={4} width={16} height={16} rx={3} fill=\"none\" stroke=\"gray\" strokeWidth={2} />\n </svg>\n </Icon>\n )}\n {props.children}\n </Container>\n );\n});\n","import React from 'react';\nimport { withSlots } from '@bento/slots';\nimport { Container, type ContainerProps } from '@bento/container';\nimport { useProps } from '@bento/use-props';\nimport { useCheckboxGroup, mergeProps, type AriaCheckboxGroupProps } from 'react-aria';\nimport { useCheckboxGroupState } from 'react-stately';\nimport { CheckboxGroupStateContext } from './checkbox-group-state';\nimport { useDataAttributes } from '@bento/use-data-attributes';\n\nexport interface CheckboxGroupProps extends AriaCheckboxGroupProps, Omit<ContainerProps, keyof AriaCheckboxGroupProps> {\n /** The current value of the checkbox group (controlled). */\n value?: string[];\n\n /** The default value of the checkbox group (uncontrolled). */\n defaultValue?: string[];\n\n /** Whether the input is disabled. */\n isDisabled?: boolean;\n\n /** Whether the input can be selected but not changed by the user. */\n isReadOnly?: boolean;\n\n /** Whether user input is required on the input before form submission. */\n isRequired?: boolean;\n\n /** Whether the input value is invalid. */\n isInvalid?: boolean;\n\n /** The name of the input element, used when submitting an HTML form. */\n name?: string;\n\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n */\n form?: string;\n\n /** Checkbox children. */\n children?: React.ReactNode;\n}\n\n/**\n * The `CheckboxGroup` allows a user to select items from a list of `Checkbox` components.\n */\nexport const CheckboxGroup = withSlots('BentoCheckboxGroup', function CheckboxGroup(args: CheckboxGroupProps) {\n const { props, apply } = useProps(args);\n const state = useCheckboxGroupState(props);\n const { groupProps, labelProps, descriptionProps, errorMessageProps, ...validationResult } = useCheckboxGroup(\n { ...props, label: props.label ?? 'Checkbox Group', description: props.description ?? 'Description' },\n state\n );\n\n return (\n <CheckboxGroupStateContext.Provider value={state}>\n <Container\n {...apply(groupProps)}\n {...useDataAttributes({\n orientation: props.orientation || 'vertical',\n invalid: state.isInvalid,\n disabled: state.isDisabled,\n readonly: state.isReadOnly,\n required: state.isRequired\n })}\n slots={{\n label: labelProps,\n description: descriptionProps,\n error: mergeProps(errorMessageProps, validationResult)\n }}\n >\n {props.children}\n </Container>\n </CheckboxGroupStateContext.Provider>\n );\n});\n"]}
1
+ {"version":3,"sources":["../src/checkbox-group-state.tsx","../src/checkbox.tsx","../src/checkbox-group.tsx"],"names":["Checkbox","withSlots","CheckboxGroup","useProps","jsx","Container","useDataAttributes","mergeProps"],"mappings":";;;;;;;;;;;;;;AAGO,IAAM,yBAAA,GAA4B,KAAA,CAAM,aAAA,CAAyC,IAAI,CAAA;ACgDrF,IAAM,QAAA,GAAW,SAAA,CAAU,eAAA,EAAiB,SAASA,UAAS,IAAA,EAAqB;AACxF,EAAA,MAAM,EAAE,KAAA,EAAO,KAAA,EAAM,GAAI,SAAS,IAAI,CAAA;AACtC,EAAA,MAAM,UAAA,GAAa,WAAW,yBAAyB,CAAA;AACvD,EAAA,MAAM,GAAA,GAAM,OAAyB,IAAI,CAAA;AACzC,EAAA,MAAM,QAAA,GAAW,YAAA,CAAa,OAAA,CAAQ,MAAM,UAAU,GAAA,EAAK,KAAA,CAAM,QAAQ,CAAA,EAAG,CAAC,GAAA,EAAK,KAAA,CAAM,QAAQ,CAAC,CAAC,CAAA;AAClG,EAAA,MAAM,EAAE,SAAA,EAAW,cAAA,EAAgB,UAAA,KAAe,YAAA,EAAa;AAE/D,EAAA,MAAM,EAAE,YAAY,UAAA,EAA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AIC,SAAS,IAAI,CAAA;AACtC,EAAA,MAAM,KAAA,GAAQ,sBAAsB,KAAK,CAAA;AACzC,EAAA,MAAM,EAAE,UAAA,EAAY,UAAA,EAAY,kBAAkB,iBAAA,EAAmB,GAAG,kBAAiB,GAAI,gBAAA;AAAA,IAC3F,EAAE,GAAG,KAAA,EAAO,KAAA,EAAO,KAAA,CAAM,SAAS,gBAAA,EAAkB,WAAA,EAAa,KAAA,CAAM,WAAA,IAAe,aAAA,EAAc;AAAA,IACpG;AAAA,GACF;AAEA,EAAA,uBACEC,GAAAA,CAAC,yBAAA,CAA0B,UAA1B,EAAmC,KAAA,EAAO,OACzC,QAAA,kBAAAA,GAAAA;AAAA,IAACC,SAAAA;AAAA,IAAA;AAAA,MACE,GAAG,MAAM,UAAU,CAAA;AAAA,MACnB,GAAGC,iBAAAA,CAAkB;AAAA,QACpB,WAAA,EAAa,MAAM,WAAA,IAAe,UAAA;AAAA,QAClC,SAAS,KAAA,CAAM,SAAA;AAAA,QACf,UAAU,KAAA,CAAM,UAAA;AAAA,QAChB,UAAU,KAAA,CAAM,UAAA;AAAA,QAChB,UAAU,KAAA,CAAM;AAAA,OACjB,CAAA;AAAA,MACD,KAAA,EAAO;AAAA,QACL,KAAA,EAAO,UAAA;AAAA,QACP,WAAA,EAAa,gBAAA;AAAA,QACb,KAAA,EAAOC,YAAAA,CAAW,iBAAA,EAAmB,gBAAgB;AAAA,OACvD;AAAA,MAEC,QAAA,EAAA,KAAA,CAAM;AAAA;AAAA,GACT,EACF,CAAA;AAEJ,CAAC","file":"index.js","sourcesContent":["import React from 'react';\nimport { CheckboxGroupState } from 'react-stately';\n\nexport const CheckboxGroupStateContext = React.createContext<CheckboxGroupState | null>(null);\n","import React, { useContext, useRef, useMemo } from 'react';\nimport { Container, type ContainerProps } from '@bento/container';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { Icon } from '@bento/icon';\nimport { Input } from '@bento/input';\nimport { withSlots } from '@bento/slots';\nimport { useProps } from '@bento/use-props';\nimport { VisuallyHidden } from '@bento/visually-hidden';\nimport { mergeProps, mergeRefs, useObjectRef } from '@react-aria/utils';\nimport { useFocusRing, useHover, useCheckbox, useCheckboxGroupItem, type AriaCheckboxProps } from 'react-aria';\nimport { useToggleState } from 'react-stately';\nimport { CheckboxGroupStateContext } from './checkbox-group-state';\n\nexport interface CheckboxProps extends AriaCheckboxProps, Omit<ContainerProps, keyof AriaCheckboxProps> {\n /** The value of the checkbox, used when submitting an HTML form. */\n value?: string;\n\n /** The name of the checkbox. */\n name?: string;\n\n /** A ref for the HTML input element. */\n inputRef?: React.Ref<HTMLInputElement>;\n\n /** The label for the checkbox. Accepts any renderable node. */\n children?: React.ReactNode;\n\n /** Whether the checkbox is required or not. */\n isRequired?: boolean;\n\n /** Whether the input can be selected but not changed by the user. */\n isReadOnly?: boolean;\n\n /**\n * Whether the checkbox is disabled or not. Shows that a selection exists,\n * but is not available in that circumstance.\n */\n isDisabled?: boolean;\n\n /** Whether the element should receive focus on render. */\n autoFocus?: boolean;\n\n /** Whether the checkbox is in an indeterminate state. */\n isIndeterminate?: boolean;\n\n /** Whether the checkbox is in a selected state. */\n isSelected?: boolean;\n}\n\n/**\n * The `Checkbox` is a single checkbox option that can be selected by the user.\n */\nexport const Checkbox = withSlots('BentoCheckbox', function Checkbox(args: CheckboxProps) {\n const { props, apply } = useProps(args);\n const groupState = useContext(CheckboxGroupStateContext);\n const ref = useRef<HTMLInputElement>(null);\n const inputRef = useObjectRef(useMemo(() => mergeRefs(ref, props.inputRef), [ref, props.inputRef]));\n const { isFocused, isFocusVisible, focusProps } = useFocusRing();\n\n const { labelProps, inputProps, isSelected, isPressed, isDisabled, isReadOnly, isInvalid } = groupState\n ? useCheckboxGroupItem(\n {\n ...props,\n // Value is optional for standalone checkboxes, but required for CheckboxGroup items;\n // it's passed explicitly here to avoid typescript error (requires ignore)(recommendation from React Aria).\n value: (props as Required<Pick<typeof props, 'value'>>).value\n },\n groupState,\n inputRef\n )\n : useCheckbox(props, useToggleState(props), inputRef);\n\n const interactionDisabled = props.isDisabled || isDisabled || isReadOnly;\n const { hoverProps, isHovered } = useHover({\n ...props,\n isDisabled: interactionDisabled\n });\n\n return (\n <Container\n as=\"label\"\n aria-checked={props.isIndeterminate ? 'mixed' : undefined}\n {...apply(mergeProps(labelProps, hoverProps))}\n {...useDataAttributes({\n selected: isSelected,\n pressed: isPressed,\n hovered: isHovered,\n focused: isFocused,\n focusVisible: isFocusVisible,\n disabled: interactionDisabled,\n readonly: isReadOnly,\n invalid: isInvalid,\n required: props.isRequired,\n indeterminate: props.isIndeterminate\n })}\n >\n <VisuallyHidden>\n <Input {...mergeProps(inputProps, focusProps)} ref={inputRef} />\n </VisuallyHidden>\n\n {props.isIndeterminate ? (\n <Icon slot=\"icon-indeterminate\" icon=\"checkboxIndeterminate\">\n <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect x=\"6\" y=\"11\" width=\"12\" height=\"2\" fill=\"currentColor\" />\n </svg>\n </Icon>\n ) : isSelected ? (\n <Icon slot=\"icon-checked\" icon=\"checkboxChecked\">\n <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M9,16.2L4.8,12l-1.4,1.4L9,19L21,7l-1.4-1.4L9,16.2z\" fill=\"currentColor\" />\n </svg>\n </Icon>\n ) : (\n <Icon slot=\"icon-unchecked\" icon=\"checkboxUnchecked\">\n <svg width={24} height={24}>\n <rect x={4} y={4} width={16} height={16} rx={3} fill=\"none\" stroke=\"gray\" strokeWidth={2} />\n </svg>\n </Icon>\n )}\n {props.children}\n </Container>\n );\n});\n","import React from 'react';\nimport { withSlots } from '@bento/slots';\nimport { Container, type ContainerProps } from '@bento/container';\nimport { useProps } from '@bento/use-props';\nimport { useCheckboxGroup, mergeProps, type AriaCheckboxGroupProps } from 'react-aria';\nimport { useCheckboxGroupState } from 'react-stately';\nimport { CheckboxGroupStateContext } from './checkbox-group-state';\nimport { useDataAttributes } from '@bento/use-data-attributes';\n\nexport interface CheckboxGroupProps extends AriaCheckboxGroupProps, Omit<ContainerProps, keyof AriaCheckboxGroupProps> {\n /** The current value of the checkbox group (controlled). */\n value?: string[];\n\n /** The default value of the checkbox group (uncontrolled). */\n defaultValue?: string[];\n\n /** Whether the input is disabled. */\n isDisabled?: boolean;\n\n /** Whether the input can be selected but not changed by the user. */\n isReadOnly?: boolean;\n\n /** Whether user input is required on the input before form submission. */\n isRequired?: boolean;\n\n /** Whether the input value is invalid. */\n isInvalid?: boolean;\n\n /** The name of the input element, used when submitting an HTML form. */\n name?: string;\n\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n */\n form?: string;\n\n /** Checkbox children. */\n children?: React.ReactNode;\n}\n\n/**\n * The `CheckboxGroup` allows a user to select items from a list of `Checkbox` components.\n */\nexport const CheckboxGroup = withSlots('BentoCheckboxGroup', function CheckboxGroup(args: CheckboxGroupProps) {\n const { props, apply } = useProps(args);\n const state = useCheckboxGroupState(props);\n const { groupProps, labelProps, descriptionProps, errorMessageProps, ...validationResult } = useCheckboxGroup(\n { ...props, label: props.label ?? 'Checkbox Group', description: props.description ?? 'Description' },\n state\n );\n\n return (\n <CheckboxGroupStateContext.Provider value={state}>\n <Container\n {...apply(groupProps)}\n {...useDataAttributes({\n orientation: props.orientation || 'vertical',\n invalid: state.isInvalid,\n disabled: state.isDisabled,\n readonly: state.isReadOnly,\n required: state.isRequired\n })}\n slots={{\n label: labelProps,\n description: descriptionProps,\n error: mergeProps(errorMessageProps, validationResult)\n }}\n >\n {props.children}\n </Container>\n </CheckboxGroupStateContext.Provider>\n );\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bento/checkbox",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Checkbox component",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -8,15 +8,13 @@
8
8
  "scripts": {
9
9
  "build": "tsup-node",
10
10
  "lint": "biome lint && tsc",
11
- "posttest": "npm run lint",
12
- "prepublishOnly": "node ../../scripts/compile-readme.ts",
13
- "pretest": "npm run build",
11
+ "prepublishOnly": "node ../../../scripts/compile-readme.ts",
14
12
  "test": "vitest --run",
15
13
  "test:watch": "vitest"
16
14
  },
17
15
  "repository": {
18
16
  "type": "git",
19
- "url": "git+https://github.com/godaddy/bento.git"
17
+ "url": "git+https://github.com/godaddy/antares.git"
20
18
  },
21
19
  "keywords": [
22
20
  "accessibility",
@@ -31,24 +29,33 @@
31
29
  "author": "GoDaddy Operating Company, LLC",
32
30
  "license": "MIT",
33
31
  "bugs": {
34
- "url": "https://github.com/godaddy/bento/issues"
32
+ "url": "https://github.com/godaddy/antares/issues"
35
33
  },
36
- "homepage": "https://github.com/godaddy/bento#readme",
34
+ "homepage": "https://github.com/godaddy/antares#readme",
37
35
  "files": [
38
36
  "dist",
39
37
  "src",
40
38
  "package.json"
41
39
  ],
42
40
  "dependencies": {
43
- "@bento/container": "^0.2.0",
44
- "@bento/icon": "^0.1.3",
45
- "@bento/slots": "^0.2.0",
41
+ "@bento/container": "^0.2.1",
42
+ "@bento/icon": "^0.2.0",
43
+ "@bento/input": "^0.1.0",
44
+ "@bento/slots": "^0.3.0",
46
45
  "@bento/use-data-attributes": "^0.1.1",
47
- "@bento/use-props": "^0.2.0",
48
- "@bento/visually-hidden": "^0.1.0",
46
+ "@bento/use-props": "^0.2.1",
47
+ "@bento/visually-hidden": "^0.1.1",
49
48
  "@react-aria/utils": "^3.30.0",
50
- "react-aria": "^3.44.0",
51
- "react-stately": "^3.42.0"
49
+ "react-aria": "^3.45.0",
50
+ "react-stately": "^3.43.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/react": "^19.2.14",
54
+ "@types/react-dom": "^19.2.3",
55
+ "tsup": "^8.5.1",
56
+ "typescript": "^5.9.3",
57
+ "vitest": "^4.0.18",
58
+ "vitest-browser-react": "^2.1.0"
52
59
  },
53
60
  "peerDependencies": {
54
61
  "react": "18.x || 19.x",
package/src/checkbox.tsx CHANGED
@@ -2,6 +2,7 @@ import React, { useContext, useRef, useMemo } from 'react';
2
2
  import { Container, type ContainerProps } from '@bento/container';
3
3
  import { useDataAttributes } from '@bento/use-data-attributes';
4
4
  import { Icon } from '@bento/icon';
5
+ import { Input } from '@bento/input';
5
6
  import { withSlots } from '@bento/slots';
6
7
  import { useProps } from '@bento/use-props';
7
8
  import { VisuallyHidden } from '@bento/visually-hidden';
@@ -93,7 +94,7 @@ export const Checkbox = withSlots('BentoCheckbox', function Checkbox(args: Check
93
94
  })}
94
95
  >
95
96
  <VisuallyHidden>
96
- <input {...mergeProps(inputProps, focusProps)} ref={inputRef} />
97
+ <Input {...mergeProps(inputProps, focusProps)} ref={inputRef} />
97
98
  </VisuallyHidden>
98
99
 
99
100
  {props.isIndeterminate ? (