@bitrise/bitkit-v2 0.3.543 → 0.3.544-beta.3440

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.
@@ -1,8 +1,17 @@
1
1
  import { BoxProps } from '@chakra-ui/react/box';
2
- import { ReactNode, Ref } from 'react';
2
+ import { ComponentPropsWithoutRef, ReactNode, Ref } from 'react';
3
3
  export interface BitkitDraggableCardProps extends Omit<BoxProps, 'children'> {
4
4
  children: ReactNode;
5
- /** Ref for the drag handle element — pass useSortable().handleRef here. When provided, only the handle initiates drag. */
5
+ /**
6
+ * Props spread onto the drag handle `<button>` — pass `{ ...attributes, ...listeners }` from `@dnd-kit/core`'s
7
+ * `useSortable()` / `useDraggable()` here. When provided, only the handle initiates drag. Overrides the default
8
+ * `aria-label="Drag handle"`, so name what is being reordered (e.g. `aria-label="Reorder trigger"`).
9
+ */
10
+ handleProps?: Omit<ComponentPropsWithoutRef<'button'>, 'children' | 'type'>;
11
+ /**
12
+ * Ref for the drag handle `<button>` — pass `handleRef` from `@dnd-kit/react`'s `useSortable()`, or
13
+ * `setActivatorNodeRef` from `@dnd-kit/core`'s. When provided, only the handle initiates drag.
14
+ */
6
15
  handleRef?: Ref<HTMLButtonElement>;
7
16
  /** Whether this card is currently being dragged */
8
17
  isDragging?: boolean;
@@ -10,10 +19,10 @@ export interface BitkitDraggableCardProps extends Omit<BoxProps, 'children'> {
10
19
  isDropTarget?: boolean;
11
20
  }
12
21
  /**
13
- * A card with a drag handle, designed for use with `@dnd-kit/react`.
22
+ * A card with a drag handle, designed for use with `@dnd-kit/react` or `@dnd-kit/core`.
14
23
  *
15
24
  * The component is purely presentational — it does not depend on `@dnd-kit`.
16
- * Pass the refs and state flags from `useSortable` (or `useDraggable`) to wire it up.
25
+ * Pass the refs, handle props and state flags from `useSortable` (or `useDraggable`) to wire it up.
17
26
  *
18
27
  * @example Full-card drag (default — the entire card is draggable)
19
28
  * ```tsx
@@ -32,6 +41,20 @@ export interface BitkitDraggableCardProps extends Omit<BoxProps, 'children'> {
32
41
  * {children}
33
42
  * </BitkitDraggableCard>
34
43
  * ```
44
+ *
45
+ * @example Handle-only drag with `@dnd-kit/core` / `@dnd-kit/sortable` (pass handleProps and handleRef)
46
+ * ```tsx
47
+ * const { attributes, isDragging, listeners, setActivatorNodeRef, setNodeRef } = useSortable({ id });
48
+ *
49
+ * <BitkitDraggableCard
50
+ * ref={setNodeRef}
51
+ * handleProps={{ ...attributes, ...listeners, 'aria-label': 'Reorder trigger' }}
52
+ * handleRef={setActivatorNodeRef}
53
+ * isDragging={isDragging}
54
+ * >
55
+ * {children}
56
+ * </BitkitDraggableCard>
57
+ * ```
35
58
  */
36
59
  declare const BitkitDraggableCard: import('react').ForwardRefExoticComponent<BitkitDraggableCardProps & import('react').RefAttributes<HTMLDivElement>>;
37
60
  export default BitkitDraggableCard;
@@ -5,10 +5,10 @@ import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { Box } from "@chakra-ui/react/box";
6
6
  // lib/components/BitkitDraggableCard/BitkitDraggableCard.tsx
7
7
  /**
8
- * A card with a drag handle, designed for use with `@dnd-kit/react`.
8
+ * A card with a drag handle, designed for use with `@dnd-kit/react` or `@dnd-kit/core`.
9
9
  *
10
10
  * The component is purely presentational — it does not depend on `@dnd-kit`.
11
- * Pass the refs and state flags from `useSortable` (or `useDraggable`) to wire it up.
11
+ * Pass the refs, handle props and state flags from `useSortable` (or `useDraggable`) to wire it up.
12
12
  *
13
13
  * @example Full-card drag (default — the entire card is draggable)
14
14
  * ```tsx
@@ -27,10 +27,24 @@ import { Box } from "@chakra-ui/react/box";
27
27
  * {children}
28
28
  * </BitkitDraggableCard>
29
29
  * ```
30
+ *
31
+ * @example Handle-only drag with `@dnd-kit/core` / `@dnd-kit/sortable` (pass handleProps and handleRef)
32
+ * ```tsx
33
+ * const { attributes, isDragging, listeners, setActivatorNodeRef, setNodeRef } = useSortable({ id });
34
+ *
35
+ * <BitkitDraggableCard
36
+ * ref={setNodeRef}
37
+ * handleProps={{ ...attributes, ...listeners, 'aria-label': 'Reorder trigger' }}
38
+ * handleRef={setActivatorNodeRef}
39
+ * isDragging={isDragging}
40
+ * >
41
+ * {children}
42
+ * </BitkitDraggableCard>
43
+ * ```
30
44
  */
31
45
  var BitkitDraggableCard = forwardRef((props, ref) => {
32
- const { children, css, handleRef, isDragging = false, isDropTarget = false, ...rest } = props;
33
- const isFullCardDrag = !handleRef;
46
+ const { children, css, handleProps, handleRef, isDragging = false, isDropTarget = false, ...rest } = props;
47
+ const isFullCardDrag = !handleRef && !handleProps;
34
48
  const styles = useSlotRecipe({ key: "draggableCard" })({
35
49
  isDragging,
36
50
  isDropTarget,
@@ -44,9 +58,10 @@ var BitkitDraggableCard = forwardRef((props, ref) => {
44
58
  css: styles.handle,
45
59
  children: /* @__PURE__ */ jsx(IconDragHandle, { size: "16" })
46
60
  }) : /* @__PURE__ */ jsx(chakra.button, {
61
+ "aria-label": "Drag handle",
62
+ ...handleProps,
47
63
  ref: handleRef,
48
64
  type: "button",
49
- "aria-label": "Drag handle",
50
65
  css: styles.handle,
51
66
  children: /* @__PURE__ */ jsx(IconDragHandle, { size: "16" })
52
67
  }), /* @__PURE__ */ jsx(Box, {
@@ -1 +1 @@
1
- {"version":3,"file":"BitkitDraggableCard.js","names":[],"sources":["../../../lib/components/BitkitDraggableCard/BitkitDraggableCard.tsx"],"sourcesContent":["import { Box, type BoxProps } from '@chakra-ui/react/box';\nimport { chakra, useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { forwardRef, type ReactNode, type Ref } from 'react';\n\nimport IconDragHandle from '../../icons/IconDragHandle';\n\n// ----- Props -----\n\nexport interface BitkitDraggableCardProps extends Omit<BoxProps, 'children'> {\n children: ReactNode;\n /** Ref for the drag handle element — pass useSortable().handleRef here. When provided, only the handle initiates drag. */\n handleRef?: Ref<HTMLButtonElement>;\n /** Whether this card is currently being dragged */\n isDragging?: boolean;\n /** Whether this card is a drop target placeholder */\n isDropTarget?: boolean;\n}\n\n// ----- Component -----\n\n/**\n * A card with a drag handle, designed for use with `@dnd-kit/react`.\n *\n * The component is purely presentational — it does not depend on `@dnd-kit`.\n * Pass the refs and state flags from `useSortable` (or `useDraggable`) to wire it up.\n *\n * @example Full-card drag (default — the entire card is draggable)\n * ```tsx\n * const { ref, isDragSource, isDropTarget } = useSortable({ id, index });\n *\n * <BitkitDraggableCard ref={ref} isDragging={isDragSource} isDropTarget={isDropTarget}>\n * {children}\n * </BitkitDraggableCard>\n * ```\n *\n * @example Handle-only drag (pass handleRef to restrict drag to the handle)\n * ```tsx\n * const { ref, handleRef, isDragSource, isDropTarget } = useSortable({ id, index });\n *\n * <BitkitDraggableCard ref={ref} handleRef={handleRef} isDragging={isDragSource} isDropTarget={isDropTarget}>\n * {children}\n * </BitkitDraggableCard>\n * ```\n */\nconst BitkitDraggableCard = forwardRef<HTMLDivElement, BitkitDraggableCardProps>((props, ref) => {\n const { children, css, handleRef, isDragging = false, isDropTarget = false, ...rest } = props;\n\n const isFullCardDrag = !handleRef;\n const recipe = useSlotRecipe({ key: 'draggableCard' });\n const styles = recipe({ isDragging, isDropTarget, isFullCardDrag });\n\n return (\n <Box ref={ref} css={[styles.root, css]} {...rest}>\n {isFullCardDrag ? (\n <chakra.div css={styles.handle}>\n <IconDragHandle size=\"16\" />\n </chakra.div>\n ) : (\n <chakra.button ref={handleRef} type=\"button\" aria-label=\"Drag handle\" css={styles.handle}>\n <IconDragHandle size=\"16\" />\n </chakra.button>\n )}\n <Box css={styles.content}>{children}</Box>\n </Box>\n );\n});\n\nBitkitDraggableCard.displayName = 'BitkitDraggableCard';\n\nexport default BitkitDraggableCard;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,IAAM,sBAAsB,YAAsD,OAAO,QAAQ;CAC/F,MAAM,EAAE,UAAU,KAAK,WAAW,aAAa,OAAO,eAAe,OAAO,GAAG,SAAS;CAExF,MAAM,iBAAiB,CAAC;CAExB,MAAM,SADS,cAAc,EAAE,KAAK,gBAAgB,CACrC,CAAA,CAAO;EAAE;EAAY;EAAc;CAAe,CAAC;CAElE,OACE,qBAAC,KAAD;EAAU;EAAK,KAAK,CAAC,OAAO,MAAM,GAAG;EAAG,GAAI;EAA5C,UAAA,CACG,iBACC,oBAAC,OAAO,KAAR;GAAY,KAAK,OAAO;GACtB,UAAA,oBAAC,gBAAD,EAAgB,MAAK,KAAM,CAAA;EACjB,CAAA,IAEZ,oBAAC,OAAO,QAAR;GAAe,KAAK;GAAW,MAAK;GAAS,cAAW;GAAc,KAAK,OAAO;GAChF,UAAA,oBAAC,gBAAD,EAAgB,MAAK,KAAM,CAAA;EACd,CAAA,GAEjB,oBAAC,KAAD;GAAK,KAAK,OAAO;GAAU;EAAc,CAAA,CACtC;;AAET,CAAC;AAED,oBAAoB,cAAc"}
1
+ {"version":3,"file":"BitkitDraggableCard.js","names":[],"sources":["../../../lib/components/BitkitDraggableCard/BitkitDraggableCard.tsx"],"sourcesContent":["import { Box, type BoxProps } from '@chakra-ui/react/box';\nimport { chakra, useSlotRecipe } from '@chakra-ui/react/styled-system';\nimport { type ComponentPropsWithoutRef, forwardRef, type ReactNode, type Ref } from 'react';\n\nimport IconDragHandle from '../../icons/IconDragHandle';\n\n// ----- Props -----\n\nexport interface BitkitDraggableCardProps extends Omit<BoxProps, 'children'> {\n children: ReactNode;\n /**\n * Props spread onto the drag handle `<button>` — pass `{ ...attributes, ...listeners }` from `@dnd-kit/core`'s\n * `useSortable()` / `useDraggable()` here. When provided, only the handle initiates drag. Overrides the default\n * `aria-label=\"Drag handle\"`, so name what is being reordered (e.g. `aria-label=\"Reorder trigger\"`).\n */\n handleProps?: Omit<ComponentPropsWithoutRef<'button'>, 'children' | 'type'>;\n /**\n * Ref for the drag handle `<button>` — pass `handleRef` from `@dnd-kit/react`'s `useSortable()`, or\n * `setActivatorNodeRef` from `@dnd-kit/core`'s. When provided, only the handle initiates drag.\n */\n handleRef?: Ref<HTMLButtonElement>;\n /** Whether this card is currently being dragged */\n isDragging?: boolean;\n /** Whether this card is a drop target placeholder */\n isDropTarget?: boolean;\n}\n\n// ----- Component -----\n\n/**\n * A card with a drag handle, designed for use with `@dnd-kit/react` or `@dnd-kit/core`.\n *\n * The component is purely presentational — it does not depend on `@dnd-kit`.\n * Pass the refs, handle props and state flags from `useSortable` (or `useDraggable`) to wire it up.\n *\n * @example Full-card drag (default — the entire card is draggable)\n * ```tsx\n * const { ref, isDragSource, isDropTarget } = useSortable({ id, index });\n *\n * <BitkitDraggableCard ref={ref} isDragging={isDragSource} isDropTarget={isDropTarget}>\n * {children}\n * </BitkitDraggableCard>\n * ```\n *\n * @example Handle-only drag (pass handleRef to restrict drag to the handle)\n * ```tsx\n * const { ref, handleRef, isDragSource, isDropTarget } = useSortable({ id, index });\n *\n * <BitkitDraggableCard ref={ref} handleRef={handleRef} isDragging={isDragSource} isDropTarget={isDropTarget}>\n * {children}\n * </BitkitDraggableCard>\n * ```\n *\n * @example Handle-only drag with `@dnd-kit/core` / `@dnd-kit/sortable` (pass handleProps and handleRef)\n * ```tsx\n * const { attributes, isDragging, listeners, setActivatorNodeRef, setNodeRef } = useSortable({ id });\n *\n * <BitkitDraggableCard\n * ref={setNodeRef}\n * handleProps={{ ...attributes, ...listeners, 'aria-label': 'Reorder trigger' }}\n * handleRef={setActivatorNodeRef}\n * isDragging={isDragging}\n * >\n * {children}\n * </BitkitDraggableCard>\n * ```\n */\nconst BitkitDraggableCard = forwardRef<HTMLDivElement, BitkitDraggableCardProps>((props, ref) => {\n const { children, css, handleProps, handleRef, isDragging = false, isDropTarget = false, ...rest } = props;\n\n const isFullCardDrag = !handleRef && !handleProps;\n const recipe = useSlotRecipe({ key: 'draggableCard' });\n const styles = recipe({ isDragging, isDropTarget, isFullCardDrag });\n\n return (\n <Box ref={ref} css={[styles.root, css]} {...rest}>\n {isFullCardDrag ? (\n <chakra.div css={styles.handle}>\n <IconDragHandle size=\"16\" />\n </chakra.div>\n ) : (\n <chakra.button aria-label=\"Drag handle\" {...handleProps} ref={handleRef} type=\"button\" css={styles.handle}>\n <IconDragHandle size=\"16\" />\n </chakra.button>\n )}\n <Box css={styles.content}>{children}</Box>\n </Box>\n );\n});\n\nBitkitDraggableCard.displayName = 'BitkitDraggableCard';\n\nexport default BitkitDraggableCard;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,IAAM,sBAAsB,YAAsD,OAAO,QAAQ;CAC/F,MAAM,EAAE,UAAU,KAAK,aAAa,WAAW,aAAa,OAAO,eAAe,OAAO,GAAG,SAAS;CAErG,MAAM,iBAAiB,CAAC,aAAa,CAAC;CAEtC,MAAM,SADS,cAAc,EAAE,KAAK,gBAAgB,CACrC,CAAA,CAAO;EAAE;EAAY;EAAc;CAAe,CAAC;CAElE,OACE,qBAAC,KAAD;EAAU;EAAK,KAAK,CAAC,OAAO,MAAM,GAAG;EAAG,GAAI;EAA5C,UAAA,CACG,iBACC,oBAAC,OAAO,KAAR;GAAY,KAAK,OAAO;GACtB,UAAA,oBAAC,gBAAD,EAAgB,MAAK,KAAM,CAAA;EACjB,CAAA,IAEZ,oBAAC,OAAO,QAAR;GAAe,cAAW;GAAc,GAAI;GAAa,KAAK;GAAW,MAAK;GAAS,KAAK,OAAO;GACjG,UAAA,oBAAC,gBAAD,EAAgB,MAAK,KAAM,CAAA;EACd,CAAA,GAEjB,oBAAC,KAAD;GAAK,KAAK,OAAO;GAAU;EAAc,CAAA,CACtC;;AAET,CAAC;AAED,oBAAoB,cAAc"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit-v2",
3
3
  "private": false,
4
- "version": "0.3.543",
4
+ "version": "0.3.544-beta.3440",
5
5
  "description": "Bitrise Design System Components built with Chakra UI V3",
6
6
  "keywords": [
7
7
  "react",