@react-spectrum/checkbox 3.7.3 → 3.8.0
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 +6 -5
- package/dist/main.js +6 -5
- package/dist/main.js.map +1 -1
- package/dist/module.js +6 -5
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/Checkbox.tsx +4 -2
- package/src/CheckboxGroup.tsx +2 -3
package/dist/import.mjs
CHANGED
|
@@ -108,7 +108,7 @@ $fe1a56c62936037c$export$14a30de2866685fa = "is-invalid_4870fc";
|
|
|
108
108
|
function $25b6292d81af2844$var$Checkbox(props, ref) {
|
|
109
109
|
let originalProps = props;
|
|
110
110
|
props = (0, $gpy1V$useProviderProps)(props);
|
|
111
|
-
let { isIndeterminate: isIndeterminate = false , isEmphasized: isEmphasized = false , isDisabled: isDisabled = false , autoFocus: autoFocus , children: children , validationState: validationState , ...otherProps } = props;
|
|
111
|
+
let { isIndeterminate: isIndeterminate = false , isEmphasized: isEmphasized = false , isDisabled: isDisabled = false , autoFocus: autoFocus , children: children , validationState: validationState , isInvalid: isInvalid , ...otherProps } = props;
|
|
112
112
|
let { styleProps: styleProps } = (0, $gpy1V$useStyleProps)(otherProps);
|
|
113
113
|
let { hoverProps: hoverProps , isHovered: isHovered } = (0, $gpy1V$useHover)({
|
|
114
114
|
isDisabled: isDisabled
|
|
@@ -128,7 +128,8 @@ function $25b6292d81af2844$var$Checkbox(props, ref) {
|
|
|
128
128
|
// Only pass isRequired and validationState to react-aria if they came from
|
|
129
129
|
// the props for this individual checkbox, and not from the group via context.
|
|
130
130
|
isRequired: originalProps.isRequired,
|
|
131
|
-
validationState: originalProps.validationState
|
|
131
|
+
validationState: originalProps.validationState,
|
|
132
|
+
isInvalid: originalProps.isInvalid
|
|
132
133
|
}, groupState, inputRef) : (0, $gpy1V$useCheckbox)(props, (0, $gpy1V$useToggleState)(props), inputRef);
|
|
133
134
|
let markIcon = isIndeterminate ? /*#__PURE__*/ (0, $gpy1V$react).createElement((0, $gpy1V$spectrumiconsuiDashSmall), {
|
|
134
135
|
UNSAFE_className: (0, $gpy1V$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($fe1a56c62936037c$exports))), "spectrum-Checkbox-partialCheckmark")
|
|
@@ -151,7 +152,7 @@ function $25b6292d81af2844$var$Checkbox(props, ref) {
|
|
|
151
152
|
"is-checked": inputProps.checked,
|
|
152
153
|
"is-indeterminate": isIndeterminate,
|
|
153
154
|
"spectrum-Checkbox--quiet": !isEmphasized,
|
|
154
|
-
"is-invalid": validationState === "invalid",
|
|
155
|
+
"is-invalid": isInvalid || validationState === "invalid",
|
|
155
156
|
"is-disabled": isDisabled,
|
|
156
157
|
"is-hovered": isHovered
|
|
157
158
|
}, styleProps.className)
|
|
@@ -208,7 +209,7 @@ $4cb2b26710154c56$export$1ad8646bcba21c0e = "spectrum-FieldGroup-group--horizont
|
|
|
208
209
|
function $73f43ce9d441cc69$var$CheckboxGroup(props, ref) {
|
|
209
210
|
props = (0, $gpy1V$useProviderProps)(props);
|
|
210
211
|
props = (0, $gpy1V$useFormProps)(props);
|
|
211
|
-
let { isEmphasized: isEmphasized , children: children , orientation: orientation = "vertical"
|
|
212
|
+
let { isEmphasized: isEmphasized , children: children , orientation: orientation = "vertical" } = props;
|
|
212
213
|
let domRef = (0, $gpy1V$useDOMRef)(ref);
|
|
213
214
|
let state = (0, $gpy1V$useCheckboxGroupState)(props);
|
|
214
215
|
let { labelProps: labelProps , groupProps: groupProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $gpy1V$useCheckboxGroup)(props, state);
|
|
@@ -228,7 +229,7 @@ function $73f43ce9d441cc69$var$CheckboxGroup(props, ref) {
|
|
|
228
229
|
})
|
|
229
230
|
}, /*#__PURE__*/ (0, $gpy1V$react).createElement((0, $gpy1V$Provider), {
|
|
230
231
|
isEmphasized: isEmphasized,
|
|
231
|
-
validationState:
|
|
232
|
+
validationState: state.isInvalid ? "invalid" : undefined
|
|
232
233
|
}, /*#__PURE__*/ (0, $gpy1V$react).createElement((0, $8c8ab388b155237e$export$baf37c4be89255b8).Provider, {
|
|
233
234
|
value: state
|
|
234
235
|
}, children))));
|
package/dist/main.js
CHANGED
|
@@ -111,7 +111,7 @@ $591f3ccba6339bdb$export$14a30de2866685fa = "is-invalid_4870fc";
|
|
|
111
111
|
function $096ccd12d23dd6cc$var$Checkbox(props, ref) {
|
|
112
112
|
let originalProps = props;
|
|
113
113
|
props = (0, $5Ft2u$reactspectrumprovider.useProviderProps)(props);
|
|
114
|
-
let { isIndeterminate: isIndeterminate = false , isEmphasized: isEmphasized = false , isDisabled: isDisabled = false , autoFocus: autoFocus , children: children , validationState: validationState , ...otherProps } = props;
|
|
114
|
+
let { isIndeterminate: isIndeterminate = false , isEmphasized: isEmphasized = false , isDisabled: isDisabled = false , autoFocus: autoFocus , children: children , validationState: validationState , isInvalid: isInvalid , ...otherProps } = props;
|
|
115
115
|
let { styleProps: styleProps } = (0, $5Ft2u$reactspectrumutils.useStyleProps)(otherProps);
|
|
116
116
|
let { hoverProps: hoverProps , isHovered: isHovered } = (0, $5Ft2u$reactariainteractions.useHover)({
|
|
117
117
|
isDisabled: isDisabled
|
|
@@ -131,7 +131,8 @@ function $096ccd12d23dd6cc$var$Checkbox(props, ref) {
|
|
|
131
131
|
// Only pass isRequired and validationState to react-aria if they came from
|
|
132
132
|
// the props for this individual checkbox, and not from the group via context.
|
|
133
133
|
isRequired: originalProps.isRequired,
|
|
134
|
-
validationState: originalProps.validationState
|
|
134
|
+
validationState: originalProps.validationState,
|
|
135
|
+
isInvalid: originalProps.isInvalid
|
|
135
136
|
}, groupState, inputRef) : (0, $5Ft2u$reactariacheckbox.useCheckbox)(props, (0, $5Ft2u$reactstatelytoggle.useToggleState)(props), inputRef);
|
|
136
137
|
let markIcon = isIndeterminate ? /*#__PURE__*/ (0, ($parcel$interopDefault($5Ft2u$react))).createElement((0, ($parcel$interopDefault($5Ft2u$spectrumiconsuiDashSmall))), {
|
|
137
138
|
UNSAFE_className: (0, $5Ft2u$reactspectrumutils.classNames)((0, (/*@__PURE__*/$parcel$interopDefault($591f3ccba6339bdb$exports))), "spectrum-Checkbox-partialCheckmark")
|
|
@@ -154,7 +155,7 @@ function $096ccd12d23dd6cc$var$Checkbox(props, ref) {
|
|
|
154
155
|
"is-checked": inputProps.checked,
|
|
155
156
|
"is-indeterminate": isIndeterminate,
|
|
156
157
|
"spectrum-Checkbox--quiet": !isEmphasized,
|
|
157
|
-
"is-invalid": validationState === "invalid",
|
|
158
|
+
"is-invalid": isInvalid || validationState === "invalid",
|
|
158
159
|
"is-disabled": isDisabled,
|
|
159
160
|
"is-hovered": isHovered
|
|
160
161
|
}, styleProps.className)
|
|
@@ -211,7 +212,7 @@ $53124a3a0fd56fca$export$1ad8646bcba21c0e = "spectrum-FieldGroup-group--horizont
|
|
|
211
212
|
function $1151290755e16c44$var$CheckboxGroup(props, ref) {
|
|
212
213
|
props = (0, $5Ft2u$reactspectrumprovider.useProviderProps)(props);
|
|
213
214
|
props = (0, $5Ft2u$reactspectrumform.useFormProps)(props);
|
|
214
|
-
let { isEmphasized: isEmphasized , children: children , orientation: orientation = "vertical"
|
|
215
|
+
let { isEmphasized: isEmphasized , children: children , orientation: orientation = "vertical" } = props;
|
|
215
216
|
let domRef = (0, $5Ft2u$reactspectrumutils.useDOMRef)(ref);
|
|
216
217
|
let state = (0, $5Ft2u$reactstatelycheckbox.useCheckboxGroupState)(props);
|
|
217
218
|
let { labelProps: labelProps , groupProps: groupProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $5Ft2u$reactariacheckbox.useCheckboxGroup)(props, state);
|
|
@@ -231,7 +232,7 @@ function $1151290755e16c44$var$CheckboxGroup(props, ref) {
|
|
|
231
232
|
})
|
|
232
233
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($5Ft2u$react))).createElement((0, $5Ft2u$reactspectrumprovider.Provider), {
|
|
233
234
|
isEmphasized: isEmphasized,
|
|
234
|
-
validationState:
|
|
235
|
+
validationState: state.isInvalid ? "invalid" : undefined
|
|
235
236
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($5Ft2u$react))).createElement((0, $bdf3bf7fe71fe120$export$baf37c4be89255b8).Provider, {
|
|
236
237
|
value: state
|
|
237
238
|
}, children))));
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GACD,0CAA0C;ACX1C;;;;;;;;;;ACAA;;;;;;;;;;CAUC;AAKM,MAAM,4CAAuB,CAAA,GAAA,sCAAI,EAAE,cAAyC;;CDLlF;;;;;;;;;;;;;;;;;;;;;AEVD,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAZA,4CAAsC;AACtC,4CAA4C;AAC5C,4CAA+B;AAC/B,4CAA0C;AAC1C,2CAAqC;AACrC,4CAAgD;AAChD,4CAAuD;AACvD,4CAA+B;AAC/B,4CAA4C;AAC5C,4CAA+B;AAC/B,4CAAgC;AAChC,4CAA6C;AAC7C,4CAA+B;;;;;;;AFc/B,SAAS,+BAAS,KAA4B,EAAE,GAAmC;IACjF,IAAI,gBAAgB;IACpB,QAAQ,CAAA,GAAA,6CAAe,EAAE;IACzB,IAAI,mBACF,kBAAkB,sBAClB,eAAe,oBACf,aAAa,mBACb,UAAS,YACT,SAAQ,mBACR,gBAAe,EACf,GAAG,YACJ,GAAG;IACJ,IAAI,cAAC,WAAU,EAAC,GAAG,CAAA,GAAA,uCAAY,EAAE;IACjC,IAAI,cAAC,WAAU,aAAE,UAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;oBAAC;IAAU;IAElD,IAAI,WAAW,CAAA,GAAA,mBAAK,EAAoB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;QAAc,iBAAiB;qBACrD,0DAAC,CAAA,GAAA,yCAAmB,EAAE;QAAS,OAAO;OACnC;AAMb;AAEA;;CAEC,GACD,MAAM,0DAAiB,CAAA,GAAA,sCAAI,EAAE,WAAW;;","sources":["packages/@react-spectrum/checkbox/src/index.ts","packages/@react-spectrum/checkbox/src/Checkbox.tsx","packages/@react-spectrum/checkbox/src/context.ts","packages/@adobe/spectrum-css-temp/components/checkbox/vars.css","packages/@react-spectrum/checkbox/src/CheckboxGroup.tsx","packages/@adobe/spectrum-css-temp/components/fieldgroup/vars.css"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/// <reference types=\"css-module-types\" />\nexport {Checkbox} from './Checkbox';\nexport {CheckboxGroup} from './CheckboxGroup';\nexport type {SpectrumCheckboxProps, SpectrumCheckboxGroupProps} from '@react-types/checkbox';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupContext} from './context';\nimport CheckmarkSmall from '@spectrum-icons/ui/CheckmarkSmall';\nimport {classNames, useFocusableRef, useStyleProps} from '@react-spectrum/utils';\nimport DashSmall from '@spectrum-icons/ui/DashSmall';\nimport {FocusableRef} from '@react-types/shared';\nimport {FocusRing} from '@react-aria/focus';\nimport React, {forwardRef, useContext, useRef} from 'react';\nimport {SpectrumCheckboxProps} from '@react-types/checkbox';\nimport styles from '@adobe/spectrum-css-temp/components/checkbox/vars.css';\nimport {useCheckbox, useCheckboxGroupItem} from '@react-aria/checkbox';\nimport {useHover} from '@react-aria/interactions';\nimport {useProviderProps} from '@react-spectrum/provider';\nimport {useToggleState} from '@react-stately/toggle';\n\nfunction Checkbox(props: SpectrumCheckboxProps, ref: FocusableRef<HTMLLabelElement>) {\n let originalProps = props;\n props = useProviderProps(props);\n let {\n isIndeterminate = false,\n isEmphasized = false,\n isDisabled = false,\n autoFocus,\n children,\n validationState,\n ...otherProps\n } = props;\n let {styleProps} = useStyleProps(otherProps);\n let {hoverProps, isHovered} = useHover({isDisabled});\n\n let inputRef = useRef<HTMLInputElement>(null);\n let domRef = useFocusableRef(ref, inputRef);\n\n // Swap hooks depending on whether this checkbox is inside a CheckboxGroup.\n // This is a bit unorthodox. Typically, hooks cannot be called in a conditional,\n // but since the checkbox won't move in and out of a group, it should be safe.\n let groupState = useContext(CheckboxGroupContext);\n let {inputProps} = groupState\n // eslint-disable-next-line react-hooks/rules-of-hooks\n ? useCheckboxGroupItem({\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).\n // @ts-ignore\n value: props.value,\n // Only pass isRequired and validationState to react-aria if they came from\n // the props for this individual checkbox, and not from the group via context.\n isRequired: originalProps.isRequired,\n validationState: originalProps.validationState\n }, groupState, inputRef)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n : useCheckbox(props, useToggleState(props), inputRef);\n\n let markIcon = isIndeterminate\n ? <DashSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-partialCheckmark')} />\n : <CheckmarkSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-checkmark')} />;\n\n if (groupState) {\n for (let key of ['isSelected', 'defaultSelected', 'isEmphasized']) {\n if (originalProps[key] != null) {\n console.warn(`${key} is unsupported on individual <Checkbox> elements within a <CheckboxGroup>. Please apply these props to the group instead.`);\n }\n }\n if (props.value == null) {\n console.warn('A <Checkbox> element within a <CheckboxGroup> requires a `value` property.');\n }\n }\n\n return (\n <label\n {...styleProps}\n {...hoverProps}\n ref={domRef}\n className={\n classNames(\n styles,\n 'spectrum-Checkbox',\n {\n 'is-checked': inputProps.checked,\n 'is-indeterminate': isIndeterminate,\n 'spectrum-Checkbox--quiet': !isEmphasized,\n 'is-invalid': validationState === 'invalid',\n 'is-disabled': isDisabled,\n 'is-hovered': isHovered\n },\n styleProps.className\n )\n }>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>\n <input\n {...inputProps}\n ref={inputRef}\n className={classNames(styles, 'spectrum-Checkbox-input')} />\n </FocusRing>\n <span className={classNames(styles, 'spectrum-Checkbox-box')}>{markIcon}</span>\n {children && (\n <span className={classNames(styles, 'spectrum-Checkbox-label')}>\n {children}\n </span>\n )}\n </label>\n );\n}\n/**\n * Checkboxes allow users to select multiple items from a list of individual items,\n * or to mark one individual item as selected.\n */\nlet _Checkbox = forwardRef(Checkbox);\nexport {_Checkbox as Checkbox};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport React from 'react';\n\nexport const CheckboxGroupContext = React.createContext<CheckboxGroupState | null>(null);\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n@import './skin.css';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupContext} from './context';\nimport {classNames, useDOMRef} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport {Field} from '@react-spectrum/label';\nimport {Provider, useProviderProps} from '@react-spectrum/provider';\nimport React from 'react';\nimport {SpectrumCheckboxGroupProps} from '@react-types/checkbox';\nimport styles from '@adobe/spectrum-css-temp/components/fieldgroup/vars.css';\nimport {useCheckboxGroup} from '@react-aria/checkbox';\nimport {useCheckboxGroupState} from '@react-stately/checkbox';\nimport {useFormProps} from '@react-spectrum/form';\n\nfunction CheckboxGroup(props: SpectrumCheckboxGroupProps, ref: DOMRef<HTMLDivElement>) {\n props = useProviderProps(props);\n props = useFormProps(props);\n let {\n isEmphasized,\n children,\n orientation = 'vertical',\n validationState\n } = props;\n let domRef = useDOMRef(ref);\n let state = useCheckboxGroupState(props);\n let {labelProps, groupProps, descriptionProps, errorMessageProps} = useCheckboxGroup(props, state);\n\n return (\n <Field\n {...props}\n ref={domRef}\n wrapperClassName={classNames(styles, 'spectrum-FieldGroup')}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorMessageProps={errorMessageProps}\n elementType=\"span\"\n includeNecessityIndicatorInAccessibilityName>\n <div\n {...groupProps}\n className={\n classNames(\n styles,\n 'spectrum-FieldGroup-group',\n {\n 'spectrum-FieldGroup-group--horizontal': orientation === 'horizontal'\n }\n )\n }>\n <Provider isEmphasized={isEmphasized} validationState={validationState}>\n <CheckboxGroupContext.Provider value={state}>\n {children}\n </CheckboxGroupContext.Provider>\n </Provider>\n </div>\n </Field>\n );\n}\n\n/**\n * A CheckboxGroup allows users to select one or more items from a list of choices.\n */\nconst _CheckboxGroup = React.forwardRef(CheckboxGroup);\nexport {_CheckboxGroup as CheckboxGroup};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GACD,0CAA0C;ACX1C;;;;;;;;;;ACAA;;;;;;;;;;CAUC;AAKM,MAAM,4CAAuB,CAAA,GAAA,sCAAI,EAAE,cAAyC;;CDLlF;;;;;;;;;;;;;;;;;;;;;AEVD,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAZA,4CAAsC;AACtC,4CAA4C;AAC5C,4CAA+B;AAC/B,4CAA0C;AAC1C,2CAAqC;AACrC,4CAAgD;AAChD,4CAAuD;AACvD,4CAA+B;AAC/B,4CAA4C;AAC5C,4CAA+B;AAC/B,4CAAgC;AAChC,4CAA6C;AAC7C,4CAA+B;;;;;;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gB,qBAAE,kBAAiB,EAAC,GAAG,CAAA,GAAA,yCAAe,EAAE,OAAO;IAE5F,qBACE,0DAAC,CAAA,GAAA,+BAAI;QACF,GAAG,KAAK;QACT,KAAK;QACL,kBAAkB,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,gEAAK,GAAG;QACrC,YAAY;QACZ,kBAAkB;QAClB,mBAAmB;QACnB,aAAY;QACZ,8CAAA;qBACA,0DAAC;QACE,GAAG,UAAU;QACd,WACE,CAAA,GAAA,oCAAS,EACP,CAAA,GAAA,gEAAK,GACL,6BACA;YACE,yCAAyC,gBAAgB;QAC3D;qBAGJ,0DAAC,CAAA,GAAA,qCAAO;QAAE,cAAc;QAAc,iBAAiB,MAAM,YAAY,YAAY;qBACnF,0DAAC,CAAA,GAAA,yCAAmB,EAAE;QAAS,OAAO;OACnC;AAMb;AAEA;;CAEC,GACD,MAAM,0DAAiB,CAAA,GAAA,sCAAI,EAAE,WAAW;;","sources":["packages/@react-spectrum/checkbox/src/index.ts","packages/@react-spectrum/checkbox/src/Checkbox.tsx","packages/@react-spectrum/checkbox/src/context.ts","packages/@adobe/spectrum-css-temp/components/checkbox/vars.css","packages/@react-spectrum/checkbox/src/CheckboxGroup.tsx","packages/@adobe/spectrum-css-temp/components/fieldgroup/vars.css"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/// <reference types=\"css-module-types\" />\nexport {Checkbox} from './Checkbox';\nexport {CheckboxGroup} from './CheckboxGroup';\nexport type {SpectrumCheckboxProps, SpectrumCheckboxGroupProps} from '@react-types/checkbox';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupContext} from './context';\nimport CheckmarkSmall from '@spectrum-icons/ui/CheckmarkSmall';\nimport {classNames, useFocusableRef, useStyleProps} from '@react-spectrum/utils';\nimport DashSmall from '@spectrum-icons/ui/DashSmall';\nimport {FocusableRef} from '@react-types/shared';\nimport {FocusRing} from '@react-aria/focus';\nimport React, {forwardRef, useContext, useRef} from 'react';\nimport {SpectrumCheckboxProps} from '@react-types/checkbox';\nimport styles from '@adobe/spectrum-css-temp/components/checkbox/vars.css';\nimport {useCheckbox, useCheckboxGroupItem} from '@react-aria/checkbox';\nimport {useHover} from '@react-aria/interactions';\nimport {useProviderProps} from '@react-spectrum/provider';\nimport {useToggleState} from '@react-stately/toggle';\n\nfunction Checkbox(props: SpectrumCheckboxProps, ref: FocusableRef<HTMLLabelElement>) {\n let originalProps = props;\n props = useProviderProps(props);\n let {\n isIndeterminate = false,\n isEmphasized = false,\n isDisabled = false,\n autoFocus,\n children,\n validationState,\n isInvalid,\n ...otherProps\n } = props;\n let {styleProps} = useStyleProps(otherProps);\n let {hoverProps, isHovered} = useHover({isDisabled});\n\n let inputRef = useRef<HTMLInputElement>(null);\n let domRef = useFocusableRef(ref, inputRef);\n\n // Swap hooks depending on whether this checkbox is inside a CheckboxGroup.\n // This is a bit unorthodox. Typically, hooks cannot be called in a conditional,\n // but since the checkbox won't move in and out of a group, it should be safe.\n let groupState = useContext(CheckboxGroupContext);\n let {inputProps} = groupState\n // eslint-disable-next-line react-hooks/rules-of-hooks\n ? useCheckboxGroupItem({\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).\n // @ts-ignore\n value: props.value,\n // Only pass isRequired and validationState to react-aria if they came from\n // the props for this individual checkbox, and not from the group via context.\n isRequired: originalProps.isRequired,\n validationState: originalProps.validationState,\n isInvalid: originalProps.isInvalid\n }, groupState, inputRef)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n : useCheckbox(props, useToggleState(props), inputRef);\n\n let markIcon = isIndeterminate\n ? <DashSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-partialCheckmark')} />\n : <CheckmarkSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-checkmark')} />;\n\n if (groupState) {\n for (let key of ['isSelected', 'defaultSelected', 'isEmphasized']) {\n if (originalProps[key] != null) {\n console.warn(`${key} is unsupported on individual <Checkbox> elements within a <CheckboxGroup>. Please apply these props to the group instead.`);\n }\n }\n if (props.value == null) {\n console.warn('A <Checkbox> element within a <CheckboxGroup> requires a `value` property.');\n }\n }\n\n return (\n <label\n {...styleProps}\n {...hoverProps}\n ref={domRef}\n className={\n classNames(\n styles,\n 'spectrum-Checkbox',\n {\n 'is-checked': inputProps.checked,\n 'is-indeterminate': isIndeterminate,\n 'spectrum-Checkbox--quiet': !isEmphasized,\n 'is-invalid': isInvalid || validationState === 'invalid',\n 'is-disabled': isDisabled,\n 'is-hovered': isHovered\n },\n styleProps.className\n )\n }>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>\n <input\n {...inputProps}\n ref={inputRef}\n className={classNames(styles, 'spectrum-Checkbox-input')} />\n </FocusRing>\n <span className={classNames(styles, 'spectrum-Checkbox-box')}>{markIcon}</span>\n {children && (\n <span className={classNames(styles, 'spectrum-Checkbox-label')}>\n {children}\n </span>\n )}\n </label>\n );\n}\n/**\n * Checkboxes allow users to select multiple items from a list of individual items,\n * or to mark one individual item as selected.\n */\nlet _Checkbox = forwardRef(Checkbox);\nexport {_Checkbox as Checkbox};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport React from 'react';\n\nexport const CheckboxGroupContext = React.createContext<CheckboxGroupState | null>(null);\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n@import './skin.css';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupContext} from './context';\nimport {classNames, useDOMRef} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport {Field} from '@react-spectrum/label';\nimport {Provider, useProviderProps} from '@react-spectrum/provider';\nimport React from 'react';\nimport {SpectrumCheckboxGroupProps} from '@react-types/checkbox';\nimport styles from '@adobe/spectrum-css-temp/components/fieldgroup/vars.css';\nimport {useCheckboxGroup} from '@react-aria/checkbox';\nimport {useCheckboxGroupState} from '@react-stately/checkbox';\nimport {useFormProps} from '@react-spectrum/form';\n\nfunction CheckboxGroup(props: SpectrumCheckboxGroupProps, ref: DOMRef<HTMLDivElement>) {\n props = useProviderProps(props);\n props = useFormProps(props);\n let {\n isEmphasized,\n children,\n orientation = 'vertical'\n } = props;\n let domRef = useDOMRef(ref);\n let state = useCheckboxGroupState(props);\n let {labelProps, groupProps, descriptionProps, errorMessageProps} = useCheckboxGroup(props, state);\n\n return (\n <Field\n {...props}\n ref={domRef}\n wrapperClassName={classNames(styles, 'spectrum-FieldGroup')}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorMessageProps={errorMessageProps}\n elementType=\"span\"\n includeNecessityIndicatorInAccessibilityName>\n <div\n {...groupProps}\n className={\n classNames(\n styles,\n 'spectrum-FieldGroup-group',\n {\n 'spectrum-FieldGroup-group--horizontal': orientation === 'horizontal'\n }\n )\n }>\n <Provider isEmphasized={isEmphasized} validationState={state.isInvalid ? 'invalid' : undefined}>\n <CheckboxGroupContext.Provider value={state}>\n {children}\n </CheckboxGroupContext.Provider>\n </Provider>\n </div>\n </Field>\n );\n}\n\n/**\n * A CheckboxGroup allows users to select one or more items from a list of choices.\n */\nconst _CheckboxGroup = React.forwardRef(CheckboxGroup);\nexport {_CheckboxGroup as CheckboxGroup};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -108,7 +108,7 @@ $fe1a56c62936037c$export$14a30de2866685fa = "is-invalid_4870fc";
|
|
|
108
108
|
function $25b6292d81af2844$var$Checkbox(props, ref) {
|
|
109
109
|
let originalProps = props;
|
|
110
110
|
props = (0, $gpy1V$useProviderProps)(props);
|
|
111
|
-
let { isIndeterminate: isIndeterminate = false , isEmphasized: isEmphasized = false , isDisabled: isDisabled = false , autoFocus: autoFocus , children: children , validationState: validationState , ...otherProps } = props;
|
|
111
|
+
let { isIndeterminate: isIndeterminate = false , isEmphasized: isEmphasized = false , isDisabled: isDisabled = false , autoFocus: autoFocus , children: children , validationState: validationState , isInvalid: isInvalid , ...otherProps } = props;
|
|
112
112
|
let { styleProps: styleProps } = (0, $gpy1V$useStyleProps)(otherProps);
|
|
113
113
|
let { hoverProps: hoverProps , isHovered: isHovered } = (0, $gpy1V$useHover)({
|
|
114
114
|
isDisabled: isDisabled
|
|
@@ -128,7 +128,8 @@ function $25b6292d81af2844$var$Checkbox(props, ref) {
|
|
|
128
128
|
// Only pass isRequired and validationState to react-aria if they came from
|
|
129
129
|
// the props for this individual checkbox, and not from the group via context.
|
|
130
130
|
isRequired: originalProps.isRequired,
|
|
131
|
-
validationState: originalProps.validationState
|
|
131
|
+
validationState: originalProps.validationState,
|
|
132
|
+
isInvalid: originalProps.isInvalid
|
|
132
133
|
}, groupState, inputRef) : (0, $gpy1V$useCheckbox)(props, (0, $gpy1V$useToggleState)(props), inputRef);
|
|
133
134
|
let markIcon = isIndeterminate ? /*#__PURE__*/ (0, $gpy1V$react).createElement((0, $gpy1V$spectrumiconsuiDashSmall), {
|
|
134
135
|
UNSAFE_className: (0, $gpy1V$classNames)((0, (/*@__PURE__*/$parcel$interopDefault($fe1a56c62936037c$exports))), "spectrum-Checkbox-partialCheckmark")
|
|
@@ -151,7 +152,7 @@ function $25b6292d81af2844$var$Checkbox(props, ref) {
|
|
|
151
152
|
"is-checked": inputProps.checked,
|
|
152
153
|
"is-indeterminate": isIndeterminate,
|
|
153
154
|
"spectrum-Checkbox--quiet": !isEmphasized,
|
|
154
|
-
"is-invalid": validationState === "invalid",
|
|
155
|
+
"is-invalid": isInvalid || validationState === "invalid",
|
|
155
156
|
"is-disabled": isDisabled,
|
|
156
157
|
"is-hovered": isHovered
|
|
157
158
|
}, styleProps.className)
|
|
@@ -208,7 +209,7 @@ $4cb2b26710154c56$export$1ad8646bcba21c0e = "spectrum-FieldGroup-group--horizont
|
|
|
208
209
|
function $73f43ce9d441cc69$var$CheckboxGroup(props, ref) {
|
|
209
210
|
props = (0, $gpy1V$useProviderProps)(props);
|
|
210
211
|
props = (0, $gpy1V$useFormProps)(props);
|
|
211
|
-
let { isEmphasized: isEmphasized , children: children , orientation: orientation = "vertical"
|
|
212
|
+
let { isEmphasized: isEmphasized , children: children , orientation: orientation = "vertical" } = props;
|
|
212
213
|
let domRef = (0, $gpy1V$useDOMRef)(ref);
|
|
213
214
|
let state = (0, $gpy1V$useCheckboxGroupState)(props);
|
|
214
215
|
let { labelProps: labelProps , groupProps: groupProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $gpy1V$useCheckboxGroup)(props, state);
|
|
@@ -228,7 +229,7 @@ function $73f43ce9d441cc69$var$CheckboxGroup(props, ref) {
|
|
|
228
229
|
})
|
|
229
230
|
}, /*#__PURE__*/ (0, $gpy1V$react).createElement((0, $gpy1V$Provider), {
|
|
230
231
|
isEmphasized: isEmphasized,
|
|
231
|
-
validationState:
|
|
232
|
+
validationState: state.isInvalid ? "invalid" : undefined
|
|
232
233
|
}, /*#__PURE__*/ (0, $gpy1V$react).createElement((0, $8c8ab388b155237e$export$baf37c4be89255b8).Provider, {
|
|
233
234
|
value: state
|
|
234
235
|
}, children))));
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GACD,0CAA0C;ACX1C;;;;;;;;;;ACAA;;;;;;;;;;CAUC;AAKM,MAAM,4CAAuB,CAAA,GAAA,YAAI,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C,4CAA8C;AAC9C,4CAA0D;;;;;;ADsB1D,SAAS,oCAAc,KAAiC,EAAE,GAA2B;IACnF,QAAQ,CAAA,GAAA,uBAAe,EAAE;IACzB,QAAQ,CAAA,GAAA,mBAAW,EAAE;IACrB,IAAI,gBACF,aAAY,YACZ,SAAQ,eACR,cAAc,8BACd,gBAAe,EAChB,GAAG;IACJ,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IACvB,IAAI,QAAQ,CAAA,GAAA,4BAAoB,EAAE;IAClC,IAAI,cAAC,WAAU,cAAE,WAAU,oBAAE,iBAAgB,qBAAE,kBAAiB,EAAC,GAAG,CAAA,GAAA,uBAAe,EAAE,OAAO;IAE5F,qBACE,gCAAC,CAAA,GAAA,YAAI;QACF,GAAG,KAAK;QACT,KAAK;QACL,kBAAkB,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,gEAAK,GAAG;QACrC,YAAY;QACZ,kBAAkB;QAClB,mBAAmB;QACnB,aAAY;QACZ,8CAAA;qBACA,gCAAC;QACE,GAAG,UAAU;QACd,WACE,CAAA,GAAA,iBAAS,EACP,CAAA,GAAA,gEAAK,GACL,6BACA;YACE,yCAAyC,gBAAgB;QAC3D;qBAGJ,gCAAC,CAAA,GAAA,eAAO;QAAE,cAAc;QAAc,iBAAiB;qBACrD,gCAAC,CAAA,GAAA,yCAAmB,EAAE;QAAS,OAAO;OACnC;AAMb;AAEA;;CAEC,GACD,MAAM,0DAAiB,CAAA,GAAA,YAAI,EAAE,WAAW;;","sources":["packages/@react-spectrum/checkbox/src/index.ts","packages/@react-spectrum/checkbox/src/Checkbox.tsx","packages/@react-spectrum/checkbox/src/context.ts","packages/@adobe/spectrum-css-temp/components/checkbox/vars.css","packages/@react-spectrum/checkbox/src/CheckboxGroup.tsx","packages/@adobe/spectrum-css-temp/components/fieldgroup/vars.css"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/// <reference types=\"css-module-types\" />\nexport {Checkbox} from './Checkbox';\nexport {CheckboxGroup} from './CheckboxGroup';\nexport type {SpectrumCheckboxProps, SpectrumCheckboxGroupProps} from '@react-types/checkbox';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupContext} from './context';\nimport CheckmarkSmall from '@spectrum-icons/ui/CheckmarkSmall';\nimport {classNames, useFocusableRef, useStyleProps} from '@react-spectrum/utils';\nimport DashSmall from '@spectrum-icons/ui/DashSmall';\nimport {FocusableRef} from '@react-types/shared';\nimport {FocusRing} from '@react-aria/focus';\nimport React, {forwardRef, useContext, useRef} from 'react';\nimport {SpectrumCheckboxProps} from '@react-types/checkbox';\nimport styles from '@adobe/spectrum-css-temp/components/checkbox/vars.css';\nimport {useCheckbox, useCheckboxGroupItem} from '@react-aria/checkbox';\nimport {useHover} from '@react-aria/interactions';\nimport {useProviderProps} from '@react-spectrum/provider';\nimport {useToggleState} from '@react-stately/toggle';\n\nfunction Checkbox(props: SpectrumCheckboxProps, ref: FocusableRef<HTMLLabelElement>) {\n let originalProps = props;\n props = useProviderProps(props);\n let {\n isIndeterminate = false,\n isEmphasized = false,\n isDisabled = false,\n autoFocus,\n children,\n validationState,\n ...otherProps\n } = props;\n let {styleProps} = useStyleProps(otherProps);\n let {hoverProps, isHovered} = useHover({isDisabled});\n\n let inputRef = useRef<HTMLInputElement>(null);\n let domRef = useFocusableRef(ref, inputRef);\n\n // Swap hooks depending on whether this checkbox is inside a CheckboxGroup.\n // This is a bit unorthodox. Typically, hooks cannot be called in a conditional,\n // but since the checkbox won't move in and out of a group, it should be safe.\n let groupState = useContext(CheckboxGroupContext);\n let {inputProps} = groupState\n // eslint-disable-next-line react-hooks/rules-of-hooks\n ? useCheckboxGroupItem({\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).\n // @ts-ignore\n value: props.value,\n // Only pass isRequired and validationState to react-aria if they came from\n // the props for this individual checkbox, and not from the group via context.\n isRequired: originalProps.isRequired,\n validationState: originalProps.validationState\n }, groupState, inputRef)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n : useCheckbox(props, useToggleState(props), inputRef);\n\n let markIcon = isIndeterminate\n ? <DashSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-partialCheckmark')} />\n : <CheckmarkSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-checkmark')} />;\n\n if (groupState) {\n for (let key of ['isSelected', 'defaultSelected', 'isEmphasized']) {\n if (originalProps[key] != null) {\n console.warn(`${key} is unsupported on individual <Checkbox> elements within a <CheckboxGroup>. Please apply these props to the group instead.`);\n }\n }\n if (props.value == null) {\n console.warn('A <Checkbox> element within a <CheckboxGroup> requires a `value` property.');\n }\n }\n\n return (\n <label\n {...styleProps}\n {...hoverProps}\n ref={domRef}\n className={\n classNames(\n styles,\n 'spectrum-Checkbox',\n {\n 'is-checked': inputProps.checked,\n 'is-indeterminate': isIndeterminate,\n 'spectrum-Checkbox--quiet': !isEmphasized,\n 'is-invalid': validationState === 'invalid',\n 'is-disabled': isDisabled,\n 'is-hovered': isHovered\n },\n styleProps.className\n )\n }>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>\n <input\n {...inputProps}\n ref={inputRef}\n className={classNames(styles, 'spectrum-Checkbox-input')} />\n </FocusRing>\n <span className={classNames(styles, 'spectrum-Checkbox-box')}>{markIcon}</span>\n {children && (\n <span className={classNames(styles, 'spectrum-Checkbox-label')}>\n {children}\n </span>\n )}\n </label>\n );\n}\n/**\n * Checkboxes allow users to select multiple items from a list of individual items,\n * or to mark one individual item as selected.\n */\nlet _Checkbox = forwardRef(Checkbox);\nexport {_Checkbox as Checkbox};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport React from 'react';\n\nexport const CheckboxGroupContext = React.createContext<CheckboxGroupState | null>(null);\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n@import './skin.css';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupContext} from './context';\nimport {classNames, useDOMRef} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport {Field} from '@react-spectrum/label';\nimport {Provider, useProviderProps} from '@react-spectrum/provider';\nimport React from 'react';\nimport {SpectrumCheckboxGroupProps} from '@react-types/checkbox';\nimport styles from '@adobe/spectrum-css-temp/components/fieldgroup/vars.css';\nimport {useCheckboxGroup} from '@react-aria/checkbox';\nimport {useCheckboxGroupState} from '@react-stately/checkbox';\nimport {useFormProps} from '@react-spectrum/form';\n\nfunction CheckboxGroup(props: SpectrumCheckboxGroupProps, ref: DOMRef<HTMLDivElement>) {\n props = useProviderProps(props);\n props = useFormProps(props);\n let {\n isEmphasized,\n children,\n orientation = 'vertical',\n validationState\n } = props;\n let domRef = useDOMRef(ref);\n let state = useCheckboxGroupState(props);\n let {labelProps, groupProps, descriptionProps, errorMessageProps} = useCheckboxGroup(props, state);\n\n return (\n <Field\n {...props}\n ref={domRef}\n wrapperClassName={classNames(styles, 'spectrum-FieldGroup')}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorMessageProps={errorMessageProps}\n elementType=\"span\"\n includeNecessityIndicatorInAccessibilityName>\n <div\n {...groupProps}\n className={\n classNames(\n styles,\n 'spectrum-FieldGroup-group',\n {\n 'spectrum-FieldGroup-group--horizontal': orientation === 'horizontal'\n }\n )\n }>\n <Provider isEmphasized={isEmphasized} validationState={validationState}>\n <CheckboxGroupContext.Provider value={state}>\n {children}\n </CheckboxGroupContext.Provider>\n </Provider>\n </div>\n </Field>\n );\n}\n\n/**\n * A CheckboxGroup allows users to select one or more items from a list of choices.\n */\nconst _CheckboxGroup = React.forwardRef(CheckboxGroup);\nexport {_CheckboxGroup as CheckboxGroup};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GACD,0CAA0C;ACX1C;;;;;;;;;;ACAA;;;;;;;;;;CAUC;AAKM,MAAM,4CAAuB,CAAA,GAAA,YAAI,EAAE,cAAyC;;CDLlF;;;;;;;;;;;;;;;;;;;;;AEVD,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAZA,4CAAsC;AACtC,4CAA4C;AAC5C,4CAA+B;AAC/B,4CAA0C;AAC1C,2CAAqC;AACrC,4CAAgD;AAChD,4CAAuD;AACvD,4CAA+B;AAC/B,4CAA4C;AAC5C,4CAA+B;AAC/B,4CAAgC;AAChC,4CAA6C;AAC7C,4CAA+B;;;;;;;AFc/B,SAAS,+BAAS,KAA4B,EAAE,GAAmC;IACjF,IAAI,gBAAgB;IACpB,QAAQ,CAAA,GAAA,uBAAe,EAAE;IACzB,IAAI,mBACF,kBAAkB,sBAClB,eAAe,oBACf,aAAa,mBACb,UAAS,YACT,SAAQ,mBACR,gBAAe,aACf,UAAS,EACT,GAAG,YACJ,GAAG;IACJ,IAAI,cAAC,WAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE;IACjC,IAAI,cAAC,WAAU,aAAE,UAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;oBAAC;IAAU;IAElD,IAAI,WAAW,CAAA,GAAA,aAAK,EAAoB;IACxC,IAAI,SAAS,CAAA,GAAA,sBAA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Y,YAAY;qBACnF,gCAAC,CAAA,GAAA,yCAAmB,EAAE;QAAS,OAAO;OACnC;AAMb;AAEA;;CAEC,GACD,MAAM,0DAAiB,CAAA,GAAA,YAAI,EAAE,WAAW;;","sources":["packages/@react-spectrum/checkbox/src/index.ts","packages/@react-spectrum/checkbox/src/Checkbox.tsx","packages/@react-spectrum/checkbox/src/context.ts","packages/@adobe/spectrum-css-temp/components/checkbox/vars.css","packages/@react-spectrum/checkbox/src/CheckboxGroup.tsx","packages/@adobe/spectrum-css-temp/components/fieldgroup/vars.css"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/// <reference types=\"css-module-types\" />\nexport {Checkbox} from './Checkbox';\nexport {CheckboxGroup} from './CheckboxGroup';\nexport type {SpectrumCheckboxProps, SpectrumCheckboxGroupProps} from '@react-types/checkbox';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupContext} from './context';\nimport CheckmarkSmall from '@spectrum-icons/ui/CheckmarkSmall';\nimport {classNames, useFocusableRef, useStyleProps} from '@react-spectrum/utils';\nimport DashSmall from '@spectrum-icons/ui/DashSmall';\nimport {FocusableRef} from '@react-types/shared';\nimport {FocusRing} from '@react-aria/focus';\nimport React, {forwardRef, useContext, useRef} from 'react';\nimport {SpectrumCheckboxProps} from '@react-types/checkbox';\nimport styles from '@adobe/spectrum-css-temp/components/checkbox/vars.css';\nimport {useCheckbox, useCheckboxGroupItem} from '@react-aria/checkbox';\nimport {useHover} from '@react-aria/interactions';\nimport {useProviderProps} from '@react-spectrum/provider';\nimport {useToggleState} from '@react-stately/toggle';\n\nfunction Checkbox(props: SpectrumCheckboxProps, ref: FocusableRef<HTMLLabelElement>) {\n let originalProps = props;\n props = useProviderProps(props);\n let {\n isIndeterminate = false,\n isEmphasized = false,\n isDisabled = false,\n autoFocus,\n children,\n validationState,\n isInvalid,\n ...otherProps\n } = props;\n let {styleProps} = useStyleProps(otherProps);\n let {hoverProps, isHovered} = useHover({isDisabled});\n\n let inputRef = useRef<HTMLInputElement>(null);\n let domRef = useFocusableRef(ref, inputRef);\n\n // Swap hooks depending on whether this checkbox is inside a CheckboxGroup.\n // This is a bit unorthodox. Typically, hooks cannot be called in a conditional,\n // but since the checkbox won't move in and out of a group, it should be safe.\n let groupState = useContext(CheckboxGroupContext);\n let {inputProps} = groupState\n // eslint-disable-next-line react-hooks/rules-of-hooks\n ? useCheckboxGroupItem({\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).\n // @ts-ignore\n value: props.value,\n // Only pass isRequired and validationState to react-aria if they came from\n // the props for this individual checkbox, and not from the group via context.\n isRequired: originalProps.isRequired,\n validationState: originalProps.validationState,\n isInvalid: originalProps.isInvalid\n }, groupState, inputRef)\n // eslint-disable-next-line react-hooks/rules-of-hooks\n : useCheckbox(props, useToggleState(props), inputRef);\n\n let markIcon = isIndeterminate\n ? <DashSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-partialCheckmark')} />\n : <CheckmarkSmall UNSAFE_className={classNames(styles, 'spectrum-Checkbox-checkmark')} />;\n\n if (groupState) {\n for (let key of ['isSelected', 'defaultSelected', 'isEmphasized']) {\n if (originalProps[key] != null) {\n console.warn(`${key} is unsupported on individual <Checkbox> elements within a <CheckboxGroup>. Please apply these props to the group instead.`);\n }\n }\n if (props.value == null) {\n console.warn('A <Checkbox> element within a <CheckboxGroup> requires a `value` property.');\n }\n }\n\n return (\n <label\n {...styleProps}\n {...hoverProps}\n ref={domRef}\n className={\n classNames(\n styles,\n 'spectrum-Checkbox',\n {\n 'is-checked': inputProps.checked,\n 'is-indeterminate': isIndeterminate,\n 'spectrum-Checkbox--quiet': !isEmphasized,\n 'is-invalid': isInvalid || validationState === 'invalid',\n 'is-disabled': isDisabled,\n 'is-hovered': isHovered\n },\n styleProps.className\n )\n }>\n <FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>\n <input\n {...inputProps}\n ref={inputRef}\n className={classNames(styles, 'spectrum-Checkbox-input')} />\n </FocusRing>\n <span className={classNames(styles, 'spectrum-Checkbox-box')}>{markIcon}</span>\n {children && (\n <span className={classNames(styles, 'spectrum-Checkbox-label')}>\n {children}\n </span>\n )}\n </label>\n );\n}\n/**\n * Checkboxes allow users to select multiple items from a list of individual items,\n * or to mark one individual item as selected.\n */\nlet _Checkbox = forwardRef(Checkbox);\nexport {_Checkbox as Checkbox};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport React from 'react';\n\nexport const CheckboxGroupContext = React.createContext<CheckboxGroupState | null>(null);\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n@import './skin.css';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CheckboxGroupContext} from './context';\nimport {classNames, useDOMRef} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport {Field} from '@react-spectrum/label';\nimport {Provider, useProviderProps} from '@react-spectrum/provider';\nimport React from 'react';\nimport {SpectrumCheckboxGroupProps} from '@react-types/checkbox';\nimport styles from '@adobe/spectrum-css-temp/components/fieldgroup/vars.css';\nimport {useCheckboxGroup} from '@react-aria/checkbox';\nimport {useCheckboxGroupState} from '@react-stately/checkbox';\nimport {useFormProps} from '@react-spectrum/form';\n\nfunction CheckboxGroup(props: SpectrumCheckboxGroupProps, ref: DOMRef<HTMLDivElement>) {\n props = useProviderProps(props);\n props = useFormProps(props);\n let {\n isEmphasized,\n children,\n orientation = 'vertical'\n } = props;\n let domRef = useDOMRef(ref);\n let state = useCheckboxGroupState(props);\n let {labelProps, groupProps, descriptionProps, errorMessageProps} = useCheckboxGroup(props, state);\n\n return (\n <Field\n {...props}\n ref={domRef}\n wrapperClassName={classNames(styles, 'spectrum-FieldGroup')}\n labelProps={labelProps}\n descriptionProps={descriptionProps}\n errorMessageProps={errorMessageProps}\n elementType=\"span\"\n includeNecessityIndicatorInAccessibilityName>\n <div\n {...groupProps}\n className={\n classNames(\n styles,\n 'spectrum-FieldGroup-group',\n {\n 'spectrum-FieldGroup-group--horizontal': orientation === 'horizontal'\n }\n )\n }>\n <Provider isEmphasized={isEmphasized} validationState={state.isInvalid ? 'invalid' : undefined}>\n <CheckboxGroupContext.Provider value={state}>\n {children}\n </CheckboxGroupContext.Provider>\n </Provider>\n </div>\n </Field>\n );\n}\n\n/**\n * A CheckboxGroup allows users to select one or more items from a list of choices.\n */\nconst _CheckboxGroup = React.forwardRef(CheckboxGroup);\nexport {_CheckboxGroup as CheckboxGroup};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;
|
|
1
|
+
{"mappings":";;ACoHA;;;GAGG;AACH,OAAA,IAAI,2KAAgC,CAAC;ACrDrC;;GAEG;AACH,OAAA,MAAM,2JAAgD,CAAC;ACxDvD,YAAY,EAAC,qBAAqB,EAAE,0BAA0B,EAAC,MAAM,uBAAuB,CAAC","sources":["packages/@react-spectrum/checkbox/src/packages/@react-spectrum/checkbox/src/context.ts","packages/@react-spectrum/checkbox/src/packages/@react-spectrum/checkbox/src/Checkbox.tsx","packages/@react-spectrum/checkbox/src/packages/@react-spectrum/checkbox/src/CheckboxGroup.tsx","packages/@react-spectrum/checkbox/src/packages/@react-spectrum/checkbox/src/index.ts","packages/@react-spectrum/checkbox/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n/// <reference types=\"css-module-types\" />\nexport {Checkbox} from './Checkbox';\nexport {CheckboxGroup} from './CheckboxGroup';\nexport type {SpectrumCheckboxProps, SpectrumCheckboxGroupProps} from '@react-types/checkbox';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/checkbox",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@react-aria/checkbox": "^3.
|
|
40
|
-
"@react-aria/focus": "^3.
|
|
41
|
-
"@react-aria/interactions": "^3.
|
|
42
|
-
"@react-spectrum/form": "^3.6.
|
|
43
|
-
"@react-spectrum/label": "^3.
|
|
44
|
-
"@react-spectrum/utils": "^3.10.
|
|
45
|
-
"@react-stately/checkbox": "^3.
|
|
46
|
-
"@react-stately/toggle": "^3.6.
|
|
47
|
-
"@react-types/checkbox": "^3.
|
|
48
|
-
"@react-types/shared": "^3.
|
|
49
|
-
"@spectrum-icons/ui": "^3.5.
|
|
39
|
+
"@react-aria/checkbox": "^3.11.0",
|
|
40
|
+
"@react-aria/focus": "^3.14.1",
|
|
41
|
+
"@react-aria/interactions": "^3.18.0",
|
|
42
|
+
"@react-spectrum/form": "^3.6.5",
|
|
43
|
+
"@react-spectrum/label": "^3.14.0",
|
|
44
|
+
"@react-spectrum/utils": "^3.10.2",
|
|
45
|
+
"@react-stately/checkbox": "^3.5.0",
|
|
46
|
+
"@react-stately/toggle": "^3.6.2",
|
|
47
|
+
"@react-types/checkbox": "^3.5.1",
|
|
48
|
+
"@react-types/shared": "^3.20.0",
|
|
49
|
+
"@spectrum-icons/ui": "^3.5.5",
|
|
50
50
|
"@swc/helpers": "^0.5.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "54fbaa67cc56867506811819fef765546d403253"
|
|
63
63
|
}
|
package/src/Checkbox.tsx
CHANGED
|
@@ -34,6 +34,7 @@ function Checkbox(props: SpectrumCheckboxProps, ref: FocusableRef<HTMLLabelEleme
|
|
|
34
34
|
autoFocus,
|
|
35
35
|
children,
|
|
36
36
|
validationState,
|
|
37
|
+
isInvalid,
|
|
37
38
|
...otherProps
|
|
38
39
|
} = props;
|
|
39
40
|
let {styleProps} = useStyleProps(otherProps);
|
|
@@ -57,7 +58,8 @@ function Checkbox(props: SpectrumCheckboxProps, ref: FocusableRef<HTMLLabelEleme
|
|
|
57
58
|
// Only pass isRequired and validationState to react-aria if they came from
|
|
58
59
|
// the props for this individual checkbox, and not from the group via context.
|
|
59
60
|
isRequired: originalProps.isRequired,
|
|
60
|
-
validationState: originalProps.validationState
|
|
61
|
+
validationState: originalProps.validationState,
|
|
62
|
+
isInvalid: originalProps.isInvalid
|
|
61
63
|
}, groupState, inputRef)
|
|
62
64
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
63
65
|
: useCheckbox(props, useToggleState(props), inputRef);
|
|
@@ -90,7 +92,7 @@ function Checkbox(props: SpectrumCheckboxProps, ref: FocusableRef<HTMLLabelEleme
|
|
|
90
92
|
'is-checked': inputProps.checked,
|
|
91
93
|
'is-indeterminate': isIndeterminate,
|
|
92
94
|
'spectrum-Checkbox--quiet': !isEmphasized,
|
|
93
|
-
'is-invalid': validationState === 'invalid',
|
|
95
|
+
'is-invalid': isInvalid || validationState === 'invalid',
|
|
94
96
|
'is-disabled': isDisabled,
|
|
95
97
|
'is-hovered': isHovered
|
|
96
98
|
},
|
package/src/CheckboxGroup.tsx
CHANGED
|
@@ -28,8 +28,7 @@ function CheckboxGroup(props: SpectrumCheckboxGroupProps, ref: DOMRef<HTMLDivEle
|
|
|
28
28
|
let {
|
|
29
29
|
isEmphasized,
|
|
30
30
|
children,
|
|
31
|
-
orientation = 'vertical'
|
|
32
|
-
validationState
|
|
31
|
+
orientation = 'vertical'
|
|
33
32
|
} = props;
|
|
34
33
|
let domRef = useDOMRef(ref);
|
|
35
34
|
let state = useCheckboxGroupState(props);
|
|
@@ -56,7 +55,7 @@ function CheckboxGroup(props: SpectrumCheckboxGroupProps, ref: DOMRef<HTMLDivEle
|
|
|
56
55
|
}
|
|
57
56
|
)
|
|
58
57
|
}>
|
|
59
|
-
<Provider isEmphasized={isEmphasized} validationState={
|
|
58
|
+
<Provider isEmphasized={isEmphasized} validationState={state.isInvalid ? 'invalid' : undefined}>
|
|
60
59
|
<CheckboxGroupContext.Provider value={state}>
|
|
61
60
|
{children}
|
|
62
61
|
</CheckboxGroupContext.Provider>
|