@spothero/ui 25.1.5 → 25.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -9,7 +9,7 @@ import { accordionAnatomy, selectAnatomy } from '@chakra-ui/anatomy';
9
9
  import template from 'lodash/template';
10
10
  import cn from 'classnames';
11
11
  import AsyncSelect from 'react-select/async';
12
- import { motion } from 'framer-motion';
12
+ import { motion, AnimatePresence } from 'framer-motion';
13
13
  import Creatable from 'react-select/creatable';
14
14
  import { components as components$1 } from 'react-select';
15
15
 
@@ -4170,7 +4170,7 @@ RadioGroup.propTypes = {
4170
4170
  direction: PropTypes.oneOf(['row', 'column'])
4171
4171
  };
4172
4172
 
4173
- const _excluded$5 = ["isChecked", "isDisabled", "value", "helperText", "expandableChildren", "defaultChecked", "isRadio", "label", "isExpandable", "size", "expandableChildrenStyles", "topChild"];
4173
+ const _excluded$5 = ["isChecked", "isDisabled", "value", "helperText", "expandableChildren", "defaultChecked", "isRadio", "label", "isExpandable", "size", "expandableChildrenStyles", "topChild", "expandableContentKey"];
4174
4174
  const SelectionCard = /*#__PURE__*/forwardRef((_ref, ref) => {
4175
4175
  let {
4176
4176
  isChecked,
@@ -4184,15 +4184,23 @@ const SelectionCard = /*#__PURE__*/forwardRef((_ref, ref) => {
4184
4184
  isExpandable,
4185
4185
  size = 'md',
4186
4186
  expandableChildrenStyles = {},
4187
- topChild
4187
+ topChild,
4188
+ expandableContentKey = 'selection-card-content'
4188
4189
  } = _ref,
4189
4190
  props = _objectWithoutProperties(_ref, _excluded$5);
4190
4191
  const Component = isRadio ? Radio : Checkbox;
4191
4192
  const expandableTextSize = size === 'sm' || size === 'md' ? 'xs' : 'sm';
4192
4193
  const hasExpandableContent = isExpandable && isChecked && expandableChildren;
4193
4194
  const prefersReducedMotion = usePrefersReducedMotion();
4195
+
4196
+ // Create a unique key based on the content to force re-animation
4197
+ const contentKey = React__default.useMemo(() => {
4198
+ if (typeof expandableChildren === 'string') {
4199
+ return expandableChildren;
4200
+ }
4201
+ return expandableContentKey || JSON.stringify(expandableChildren === null || expandableChildren === void 0 ? void 0 : expandableChildren.props) || Math.random();
4202
+ }, [expandableChildren, expandableContentKey]);
4194
4203
  return /*#__PURE__*/React__default.createElement(Box, {
4195
- paddingBottom: hasExpandableContent ? 3 : 0,
4196
4204
  borderRadius: "lg",
4197
4205
  borderColor: isChecked ? 'primary.default' : 'gray.medium',
4198
4206
  borderWidth: "1px",
@@ -4215,21 +4223,34 @@ const SelectionCard = /*#__PURE__*/forwardRef((_ref, ref) => {
4215
4223
  width: "100%",
4216
4224
  paddingX: 4,
4217
4225
  paddingY: 3
4218
- }, props), label)), /*#__PURE__*/React__default.createElement(Box, {
4219
- overflow: "hidden",
4220
- display: "grid"
4221
- // Using this as a pseudo height transition to get around no height auto transition
4222
- ,
4223
- gridTemplateRows: hasExpandableContent ? '1fr' : '0fr',
4224
- opacity: hasExpandableContent ? '100%' : '0%',
4225
- transition: prefersReducedMotion ? '' : 'all 150ms ease-out'
4226
- }, /*#__PURE__*/React__default.createElement(Box, {
4226
+ }, props), label)), /*#__PURE__*/React__default.createElement(AnimatePresence, {
4227
+ mode: "wait"
4228
+ }, hasExpandableContent && /*#__PURE__*/React__default.createElement(Box, {
4229
+ as: motion.div,
4230
+ key: contentKey,
4231
+ initial: {
4232
+ height: 0,
4233
+ opacity: 0
4234
+ },
4235
+ animate: {
4236
+ height: 'auto',
4237
+ opacity: 1
4238
+ },
4239
+ exit: {
4240
+ height: 0,
4241
+ opacity: 0
4242
+ },
4243
+ transition: {
4244
+ duration: prefersReducedMotion ? 0 : 0.15,
4245
+ ease: 'easeOut'
4246
+ },
4227
4247
  overflow: "hidden"
4228
- }, hasExpandableContent && /*#__PURE__*/React__default.createElement(Box, _extends$6({
4248
+ }, /*#__PURE__*/React__default.createElement(Box, _extends$6({
4229
4249
  color: "gray.600",
4230
4250
  fontSize: expandableTextSize,
4231
4251
  paddingTop: 3,
4232
- paddingX: 4
4252
+ paddingX: 4,
4253
+ paddingBottom: 3
4233
4254
  }, expandableChildrenStyles), expandableChildren))));
4234
4255
  });
4235
4256
  SelectionCard.propTypes = {
@@ -4244,7 +4265,8 @@ SelectionCard.propTypes = {
4244
4265
  isExpandable: PropTypes.bool,
4245
4266
  expandableChildrenStyles: PropTypes.object,
4246
4267
  size: PropTypes.oneOf(['sm', 'md', 'lg']),
4247
- topChild: PropTypes.element
4268
+ topChild: PropTypes.element,
4269
+ expandableContentKey: PropTypes.string
4248
4270
  };
4249
4271
 
4250
4272
  const _excluded$4 = ["variant", "colorScheme"];