@react-spectrum/checkbox 3.8.2 → 3.9.1

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/import.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ "use client";
2
+
1
3
  import "./main.css";
2
4
  import $gpy1V$spectrumiconsuiCheckmarkSmall from "@spectrum-icons/ui/CheckmarkSmall";
3
5
  import {useStyleProps as $gpy1V$useStyleProps, useFocusableRef as $gpy1V$useFocusableRef, classNames as $gpy1V$classNames, useDOMRef as $gpy1V$useDOMRef} from "@react-spectrum/utils";
@@ -5,16 +7,18 @@ import $gpy1V$spectrumiconsuiDashSmall from "@spectrum-icons/ui/DashSmall";
5
7
  import {FocusRing as $gpy1V$FocusRing} from "@react-aria/focus";
6
8
  import $gpy1V$react, {useRef as $gpy1V$useRef, useContext as $gpy1V$useContext, forwardRef as $gpy1V$forwardRef} from "react";
7
9
  import {useCheckboxGroupItem as $gpy1V$useCheckboxGroupItem, useCheckbox as $gpy1V$useCheckbox, useCheckboxGroup as $gpy1V$useCheckboxGroup} from "@react-aria/checkbox";
10
+ import {useFormProps as $gpy1V$useFormProps} from "@react-spectrum/form";
8
11
  import {useHover as $gpy1V$useHover} from "@react-aria/interactions";
9
12
  import {useProviderProps as $gpy1V$useProviderProps, Provider as $gpy1V$Provider} from "@react-spectrum/provider";
10
13
  import {useToggleState as $gpy1V$useToggleState} from "@react-stately/toggle";
11
14
  import {Field as $gpy1V$Field} from "@react-spectrum/label";
12
15
  import {useCheckboxGroupState as $gpy1V$useCheckboxGroupState} from "@react-stately/checkbox";
13
- import {useFormProps as $gpy1V$useFormProps} from "@react-spectrum/form";
16
+
14
17
 
15
18
  function $parcel$interopDefault(a) {
16
19
  return a && a.__esModule ? a.default : a;
17
20
  }
21
+
18
22
  function $parcel$export(e, n, v, s) {
19
23
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
20
24
  }
@@ -117,21 +121,20 @@ $fe1a56c62936037c$export$2927016961429360 = `ISsn1a_spectrum-FocusRing--quiet`;
117
121
 
118
122
 
119
123
 
124
+
120
125
  function $25b6292d81af2844$var$Checkbox(props, ref) {
121
126
  let originalProps = props;
122
127
  props = (0, $gpy1V$useProviderProps)(props);
123
- let { isIndeterminate: isIndeterminate = false, isEmphasized: isEmphasized = false, isDisabled: isDisabled = false, autoFocus: autoFocus, children: children, validationState: validationState, isInvalid: isInvalid, ...otherProps } = props;
128
+ props = (0, $gpy1V$useFormProps)(props);
129
+ let { isIndeterminate: isIndeterminate = false, isEmphasized: isEmphasized = false, autoFocus: autoFocus, children: children, ...otherProps } = props;
124
130
  let { styleProps: styleProps } = (0, $gpy1V$useStyleProps)(otherProps);
125
- let { hoverProps: hoverProps, isHovered: isHovered } = (0, $gpy1V$useHover)({
126
- isDisabled: isDisabled
127
- });
128
131
  let inputRef = (0, $gpy1V$useRef)(null);
129
132
  let domRef = (0, $gpy1V$useFocusableRef)(ref, inputRef);
130
133
  // Swap hooks depending on whether this checkbox is inside a CheckboxGroup.
131
134
  // This is a bit unorthodox. Typically, hooks cannot be called in a conditional,
132
135
  // but since the checkbox won't move in and out of a group, it should be safe.
133
136
  let groupState = (0, $gpy1V$useContext)((0, $8c8ab388b155237e$export$baf37c4be89255b8));
134
- let { inputProps: inputProps } = groupState ? (0, $gpy1V$useCheckboxGroupItem)({
137
+ let { inputProps: inputProps, isInvalid: isInvalid, isDisabled: isDisabled } = groupState ? (0, $gpy1V$useCheckboxGroupItem)({
135
138
  ...props,
136
139
  // Value is optional for standalone checkboxes, but required for CheckboxGroup items;
137
140
  // it's passed explicitly here to avoid typescript error (requires ignore).
@@ -143,6 +146,9 @@ function $25b6292d81af2844$var$Checkbox(props, ref) {
143
146
  validationState: originalProps.validationState,
144
147
  isInvalid: originalProps.isInvalid
145
148
  }, groupState, inputRef) : (0, $gpy1V$useCheckbox)(props, (0, $gpy1V$useToggleState)(props), inputRef);
149
+ let { hoverProps: hoverProps, isHovered: isHovered } = (0, $gpy1V$useHover)({
150
+ isDisabled: isDisabled
151
+ });
146
152
  let markIcon = isIndeterminate ? /*#__PURE__*/ (0, $gpy1V$react).createElement((0, $gpy1V$spectrumiconsuiDashSmall), {
147
153
  UNSAFE_className: (0, $gpy1V$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($fe1a56c62936037c$exports))), "spectrum-Checkbox-partialCheckmark")
148
154
  }) : /*#__PURE__*/ (0, $gpy1V$react).createElement((0, $gpy1V$spectrumiconsuiCheckmarkSmall), {
@@ -164,7 +170,7 @@ function $25b6292d81af2844$var$Checkbox(props, ref) {
164
170
  "is-checked": inputProps.checked,
165
171
  "is-indeterminate": isIndeterminate,
166
172
  "spectrum-Checkbox--quiet": !isEmphasized,
167
- "is-invalid": isInvalid || validationState === "invalid",
173
+ "is-invalid": isInvalid,
168
174
  "is-disabled": isDisabled,
169
175
  "is-hovered": isHovered
170
176
  }, styleProps.className)
@@ -239,14 +245,12 @@ function $73f43ce9d441cc69$var$CheckboxGroup(props, ref) {
239
245
  let { isEmphasized: isEmphasized, children: children, orientation: orientation = "vertical" } = props;
240
246
  let domRef = (0, $gpy1V$useDOMRef)(ref);
241
247
  let state = (0, $gpy1V$useCheckboxGroupState)(props);
242
- let { labelProps: labelProps, groupProps: groupProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $gpy1V$useCheckboxGroup)(props, state);
248
+ let { groupProps: groupProps, ...otherProps } = (0, $gpy1V$useCheckboxGroup)(props, state);
243
249
  return /*#__PURE__*/ (0, $gpy1V$react).createElement((0, $gpy1V$Field), {
244
250
  ...props,
251
+ ...otherProps,
245
252
  ref: domRef,
246
253
  wrapperClassName: (0, $gpy1V$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($4cb2b26710154c56$exports))), "spectrum-FieldGroup"),
247
- labelProps: labelProps,
248
- descriptionProps: descriptionProps,
249
- errorMessageProps: errorMessageProps,
250
254
  elementType: "span",
251
255
  includeNecessityIndicatorInAccessibilityName: true
252
256
  }, /*#__PURE__*/ (0, $gpy1V$react).createElement("div", {
@@ -255,8 +259,7 @@ function $73f43ce9d441cc69$var$CheckboxGroup(props, ref) {
255
259
  "spectrum-FieldGroup-group--horizontal": orientation === "horizontal"
256
260
  })
257
261
  }, /*#__PURE__*/ (0, $gpy1V$react).createElement((0, $gpy1V$Provider), {
258
- isEmphasized: isEmphasized,
259
- validationState: state.isInvalid ? "invalid" : undefined
262
+ isEmphasized: isEmphasized
260
263
  }, /*#__PURE__*/ (0, $gpy1V$react).createElement((0, $8c8ab388b155237e$export$baf37c4be89255b8).Provider, {
261
264
  value: state
262
265
  }, children))));