@conveyorhq/arrow-ds 1.35.0 → 1.36.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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@conveyorhq/arrow-ds",
3
3
  "author": "Conveyor",
4
4
  "license": "MIT",
5
- "version": "1.35.0",
5
+ "version": "1.36.0",
6
6
  "description": "Arrow Design System",
7
7
  "repository": "https://github.com/conveyor/arrow-ds",
8
8
  "publishConfig": {
@@ -3,7 +3,7 @@ import { BoxProps } from "../Box";
3
3
  import { StackProps } from "../Stack";
4
4
  import type { AccordionOwnProps, AccordionItemOwnProps, AccordionDisclosureProps, AccordionGroupOwnProps } from "./types";
5
5
  export declare type AccordionGroupProps = AccordionGroupOwnProps & Pick<StackProps, "children" | "spacing">;
6
- export declare const AccordionGroup: ({ children, spacing, defaultValue, ...rest }: AccordionGroupProps) => JSX.Element;
6
+ export declare const AccordionGroup: ({ children, spacing, defaultValue, disableAnimation, ...rest }: AccordionGroupProps) => JSX.Element;
7
7
  export declare type AccordionItemProps = AccordionItemOwnProps & BoxProps;
8
8
  export declare const AccordionItem: ({ value, defaultIsOpen: defaultIsOpenProp, children, className, ...rest }: AccordionItemProps) => JSX.Element;
9
9
  declare type AccordionButtonChildProps = Omit<AccordionDisclosureProps, "onToggle">;
@@ -25,7 +25,7 @@ export declare const AccordionContent: ({ children, maxHeight, style, className,
25
25
  export declare type AccordionProps = AccordionOwnProps & BoxProps;
26
26
  export declare const Accordion: {
27
27
  (props: AccordionProps): JSX.Element;
28
- Group: ({ children, spacing, defaultValue, ...rest }: AccordionGroupProps) => JSX.Element;
28
+ Group: ({ children, spacing, defaultValue, disableAnimation, ...rest }: AccordionGroupProps) => JSX.Element;
29
29
  Item: ({ value, defaultIsOpen: defaultIsOpenProp, children, className, ...rest }: AccordionItemProps) => JSX.Element;
30
30
  Button: React.ForwardRefExoticComponent<AccordionButtonProps & React.RefAttributes<HTMLButtonElement>>;
31
31
  Content: ({ children, maxHeight, style, className, ...rest }: AccordionContentProps) => JSX.Element;
@@ -20,8 +20,8 @@ const Heading_1 = require("../Heading");
20
20
  const Icon_1 = require("../Icon");
21
21
  const context_1 = require("./context");
22
22
  const cn = utilities_1.bemHOF("Accordion");
23
- const AccordionGroup = ({ children, spacing = 0, defaultValue, ...rest }) => {
24
- return (react_1.default.createElement(context_1.AccordionGroupContext.Provider, { value: { defaultValue } },
23
+ const AccordionGroup = ({ children, spacing = 0, defaultValue, disableAnimation, ...rest }) => {
24
+ return (react_1.default.createElement(context_1.AccordionGroupContext.Provider, { value: { defaultValue, disableAnimation } },
25
25
  react_1.default.createElement(Stack_1.Stack, Object.assign({ orientation: types_1.ORIENTATION.VERTICAL, spacing: spacing }, rest), children)));
26
26
  };
27
27
  exports.AccordionGroup = AccordionGroup;
@@ -62,6 +62,7 @@ exports.AccordionButton = react_1.default.forwardRef((props, forwardedRef) => {
62
62
  } }, rest), typeof children === "function" ? children({ isOpen }) : children));
63
63
  });
64
64
  const AccordionContent = ({ children, maxHeight, style, className, ...rest }) => {
65
+ const { disableAnimation } = context_1.useAccordionGroupContext();
65
66
  const { buttonId, contentId, defaultIsOpen, isOpen, } = context_1.useAccordionItemContext();
66
67
  const [childrenRef, setChildrenRef] = react_1.default.useState({ current: null });
67
68
  const onRefChange = react_1.default.useCallback((node) => {
@@ -76,7 +77,7 @@ const AccordionContent = ({ children, maxHeight, style, className, ...rest }) =>
76
77
  if (defaultIsOpen && isOpen) {
77
78
  setEnableTransition(true);
78
79
  }
79
- }, immediate: !enableTransition }, (show) => show
80
+ }, immediate: disableAnimation || !enableTransition }, (show) => show
80
81
  ? (styles) => (react_1.default.createElement(Box_1.Box, Object.assign({ className: classnames_1.default("overflow-hidden box-content", className), style: { ...styles, ...style }, "aria-labelledby": buttonId, id: contentId, role: "region" }, rest),
81
82
  react_1.default.createElement(Box_1.Box, { ref: onRefChange, className: classnames_1.default(maxHeight && "overflow-y-auto"), style: maxHeight ? { maxHeight } : undefined }, children)))
82
83
  : null));
@@ -4,6 +4,7 @@ exports.useAccordionItemContext = exports.AccordionItemContext = exports.useAcco
4
4
  const react_1 = require("react");
5
5
  const defaultGroupContext = {
6
6
  defaultValue: undefined,
7
+ disableAnimation: false,
7
8
  };
8
9
  exports.AccordionGroupContext = react_1.createContext(defaultGroupContext);
9
10
  function useAccordionGroupContext() {
@@ -2,6 +2,7 @@ import type { ReactNode } from "react";
2
2
  import type { DisclosureProps } from "../../types";
3
3
  export declare type AccordionGroupOwnProps = {
4
4
  defaultValue?: string;
5
+ disableAnimation?: boolean;
5
6
  };
6
7
  export declare type AccordionItemOwnProps = {
7
8
  defaultIsOpen?: boolean;
@@ -41,10 +41,11 @@ export const AccordionGroup = ({
41
41
  children,
42
42
  spacing = 0,
43
43
  defaultValue,
44
+ disableAnimation,
44
45
  ...rest
45
46
  }: AccordionGroupProps) => {
46
47
  return (
47
- <AccordionGroupContext.Provider value={{ defaultValue }}>
48
+ <AccordionGroupContext.Provider value={{ defaultValue, disableAnimation }}>
48
49
  <Stack orientation={ORIENTATION.VERTICAL} spacing={spacing} {...rest}>
49
50
  {children}
50
51
  </Stack>
@@ -174,6 +175,7 @@ export const AccordionContent = ({
174
175
  className,
175
176
  ...rest
176
177
  }: AccordionContentProps) => {
178
+ const { disableAnimation } = useAccordionGroupContext();
177
179
  const {
178
180
  buttonId,
179
181
  contentId,
@@ -209,7 +211,7 @@ export const AccordionContent = ({
209
211
  setEnableTransition(true);
210
212
  }
211
213
  }}
212
- immediate={!enableTransition}
214
+ immediate={disableAnimation || !enableTransition}
213
215
  >
214
216
  {(show) =>
215
217
  show
@@ -13,6 +13,7 @@ type AccordionGroupContextType = AccordionGroupOwnProps;
13
13
 
14
14
  const defaultGroupContext: AccordionGroupContextType = {
15
15
  defaultValue: undefined,
16
+ disableAnimation: false,
16
17
  };
17
18
 
18
19
  export const AccordionGroupContext: Context<AccordionGroupContextType> = createContext<AccordionGroupContextType>(
@@ -6,6 +6,10 @@ export type AccordionGroupOwnProps = {
6
6
  * The value of the item to expand when initially rendered.
7
7
  */
8
8
  defaultValue?: string;
9
+ /**
10
+ * A way to prevent the show/hide animation from running
11
+ */
12
+ disableAnimation?: boolean;
9
13
  };
10
14
 
11
15
  export type AccordionItemOwnProps = {