@bento/pressable 0.1.3 → 0.1.5

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/README.md CHANGED
@@ -24,7 +24,7 @@ The following properties are available to be used on the `Pressable` primitive:
24
24
 
25
25
  | Prop | Type | Required | Description |
26
26
  |------|------|----------|------------|
27
- | `children` | `ReactElement<any, string \| JSXElementConstructor<any>>` | Yes | A single React element that will be made pressable. |
27
+ | `children` | `React.ReactElement` | Yes | A single React element that will be made pressable. |
28
28
  | `onPress` | `(e: PressEvent) => void` | No | Handler that is called when the pressable is pressed.
29
29
  Similar to the standard `onClick` event, but normalized to handle all interaction methods consistently. |
30
30
  | `onPressStart` | `(e: PressEvent) => void` | No | Handler that is called when a press interaction starts. |
@@ -33,10 +33,6 @@ over the target or when the pointer leaves the target. |
33
33
  | `onPressChange` | `(isPressed: boolean) => void` | No | Handler that is called when the press state changes. |
34
34
  | `onPressUp` | `(e: PressEvent) => void` | No | Handler that is called when a press is released over the target, regardless of
35
35
  whether it started on the target or not. |
36
- | `slot` | `string` | No | A named part of a component that can be customized. This is implemented by the consuming component.
37
- The exposed slot names of a component are available in the components documentation. |
38
- | `slots` | `Record<string, object \| Function>` | No | An object that contains the customizations for the slots.
39
- The main way you interact with the slot system as a consumer. |
40
36
 
41
37
  For all other properties specified on the `Pressable` primitive, the component will pass them down to the direct child element of the component. Which would be the equivalent of you adding them directly to the child element.
42
38
 
package/dist/index.cjs CHANGED
@@ -1,46 +1,85 @@
1
- 'use strict';
2
-
3
- var reactAria = require('react-aria');
4
- var utils = require('@react-aria/utils');
5
- var useDataAttributes = require('@bento/use-data-attributes');
6
- var useProps = require('@bento/use-props');
7
- var slots = require('@bento/slots');
8
- var React = require('react');
9
- var style = require('./pressable.module-JXZDAJ3U.module.css');
10
-
11
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
-
13
- var React__default = /*#__PURE__*/_interopDefault(React);
14
- var style__default = /*#__PURE__*/_interopDefault(style);
15
-
16
- // src/index.tsx
17
- var Pressable = slots.withSlots("BentoPressable", function Pressable2(args) {
18
- const { props, apply } = useProps.useProps(args);
19
- const ref = React.useRef(null);
20
- const { children, ...restProps } = props;
21
- const child = React__default.default.Children.only(children);
22
- const { focusableProps } = reactAria.useFocusable(restProps, ref);
23
- const { focusProps, isFocused, isFocusVisible } = reactAria.useFocusRing(restProps);
24
- const { hoverProps, isHovered } = reactAria.useHover(restProps);
25
- const { pressProps, isPressed } = reactAria.usePress({ ...restProps, ref });
26
- return React__default.default.cloneElement(child, {
27
- ...apply(
28
- {
29
- ...reactAria.mergeProps(pressProps, focusProps, focusableProps, hoverProps),
30
- className: style__default.default.pressable
31
- },
32
- ["onPress", "onPressStart", "onPressEnd", "onPressUp", "onPressChange", "children"]
33
- ),
34
- ...useDataAttributes.useDataAttributes({
35
- pressed: isPressed,
36
- hovered: isHovered,
37
- focused: isFocused,
38
- focusVisible: isFocusVisible
39
- }),
40
- ref: utils.mergeRefs(child.ref, ref)
41
- });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ let react_aria = require("react-aria");
25
+ let _react_aria_utils = require("@react-aria/utils");
26
+ let _bento_use_data_attributes = require("@bento/use-data-attributes");
27
+ let _bento_use_props = require("@bento/use-props");
28
+ let _bento_slots = require("@bento/slots");
29
+ let react = require("react");
30
+ react = __toESM(react);
31
+ //#region src/pressable.module.css
32
+ var pressable_module_default = { "pressable": "rYyWlq_pressable" };
33
+ //#endregion
34
+ //#region src/index.tsx
35
+ /**
36
+ *
37
+ * A behavioral primitive that can be used to make any element pressable while maintaining
38
+ * consistent behavior across devices (mouse, touch, keyboard). It handles edge cases like
39
+ * touch movement and quick releases, and provides proper ARIA attributes for accessibility.
40
+ *
41
+ * @example
42
+ * ```tsx
43
+ * // Make a div pressable
44
+ * <Pressable onPress={handlePress}>
45
+ * <div>Click here</div>
46
+ * </Pressable>
47
+ * ```
48
+ */
49
+ const Pressable = (0, _bento_slots.withSlots)("BentoPressable", function Pressable(args) {
50
+ const { props, apply } = (0, _bento_use_props.useProps)(args);
51
+ const ref = (0, react.useRef)(null);
52
+ const { children, ...restProps } = props;
53
+ const child = react.default.Children.only(children);
54
+ const { focusableProps } = (0, react_aria.useFocusable)(restProps, ref);
55
+ const { focusProps, isFocused, isFocusVisible } = (0, react_aria.useFocusRing)(restProps);
56
+ const { hoverProps, isHovered } = (0, react_aria.useHover)(restProps);
57
+ const { pressProps, isPressed } = (0, react_aria.usePress)({
58
+ ...restProps,
59
+ ref
60
+ });
61
+ return react.default.cloneElement(child, {
62
+ ...apply({
63
+ ...(0, react_aria.mergeProps)(pressProps, focusProps, focusableProps, hoverProps),
64
+ className: pressable_module_default.pressable
65
+ }, [
66
+ "onPress",
67
+ "onPressStart",
68
+ "onPressEnd",
69
+ "onPressUp",
70
+ "onPressChange",
71
+ "children"
72
+ ]),
73
+ ...(0, _bento_use_data_attributes.useDataAttributes)({
74
+ pressed: isPressed,
75
+ hovered: isHovered,
76
+ focused: isFocused,
77
+ focusVisible: isFocusVisible
78
+ }),
79
+ ref: (0, _react_aria_utils.mergeRefs)(child.ref, ref)
80
+ });
42
81
  });
43
-
82
+ //#endregion
44
83
  exports.Pressable = Pressable;
45
- //# sourceMappingURL=index.cjs.map
84
+
46
85
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.tsx"],"names":["withSlots","Pressable","useProps","useRef","React","useFocusable","useFocusRing","useHover","usePress","mergeProps","style","useDataAttributes","mergeRefs"],"mappings":";;;;;;;;;;;;;;;;AA2DO,IAAM,SAAA,GAAYA,eAAA,CAAU,gBAAA,EAAkB,SAASC,WAAU,IAAA,EAAsB;AAC5F,EAAA,MAAM,EAAE,KAAA,EAAO,KAAA,EAAM,GAAIC,kBAAS,IAAI,CAAA;AACtC,EAAA,MAAM,GAAA,GAAMC,aAA2B,IAAI,CAAA;AAC3C,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,SAAA,EAAU,GAAI,KAAA;AACnC,EAAA,MAAM,KAAA,GAAQC,sBAAA,CAAM,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA;AAC1C,EAAA,MAAM,EAAE,cAAA,EAAe,GAAIC,sBAAA,CAAa,WAAW,GAAG,CAAA;AACtD,EAAA,MAAM,EAAE,UAAA,EAAY,SAAA,EAAW,cAAA,EAAe,GAAIC,uBAAa,SAAS,CAAA;AACxE,EAAA,MAAM,EAAE,UAAA,EAAY,SAAA,EAAU,GAAIC,mBAAS,SAAS,CAAA;AACpD,EAAA,MAAM,EAAE,YAAY,SAAA,EAAU,GAAIC,mBAAS,EAAE,GAAG,SAAA,EAAW,GAAA,EAAK,CAAA;AAEhE,EAAA,OAAOJ,sBAAA,CAAM,aAAa,KAAA,EAAO;AAAA,IAC/B,GAAG,KAAA;AAAA,MACD;AAAA,QACE,GAAGK,oBAAA,CAAW,UAAA,EAAY,UAAA,EAAY,gBAAgB,UAAU,CAAA;AAAA,QAChE,WAAWC,sBAAA,CAAM;AAAA,OACnB;AAAA,MACA,CAAC,SAAA,EAAW,cAAA,EAAgB,YAAA,EAAc,WAAA,EAAa,iBAAiB,UAAU;AAAA,KACpF;AAAA,IACA,GAAGC,mCAAA,CAAkB;AAAA,MACnB,OAAA,EAAS,SAAA;AAAA,MACT,OAAA,EAAS,SAAA;AAAA,MACT,OAAA,EAAS,SAAA;AAAA,MACT,YAAA,EAAc;AAAA,KACf,CAAA;AAAA,IACD,GAAA,EAAKC,eAAA,CAAW,KAAA,CAA2C,GAAA,EAAK,GAAG;AAAA,GACpE,CAAA;AACH,CAAC","file":"index.cjs","sourcesContent":["import {\n usePress,\n useFocusRing,\n useHover,\n mergeProps,\n type PressProps,\n useFocusable,\n type PressEvent\n} from 'react-aria';\nimport { mergeRefs } from '@react-aria/utils';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots } from '@bento/slots';\nimport React, { type HTMLAttributes, useRef } from 'react';\nimport style from './pressable.module.css';\n\nexport interface PressableProps extends PressProps, Omit<HTMLAttributes<HTMLElement>, keyof PressProps> {\n /** A single React element that will be made pressable. */\n children: React.ReactElement;\n\n /**\n * Handler that is called when the pressable is pressed.\n * Similar to the standard `onClick` event, but normalized to handle all interaction methods consistently.\n */\n onPress?: (e: PressEvent) => void;\n\n /** Handler that is called when a press interaction starts. */\n onPressStart?: (e: PressEvent) => void;\n\n /**\n * Handler that is called when a press interaction ends, either\n * over the target or when the pointer leaves the target.\n */\n onPressEnd?: (e: PressEvent) => void;\n\n /** Handler that is called when the press state changes. */\n onPressChange?: (isPressed: boolean) => void;\n\n /**\n * Handler that is called when a press is released over the target, regardless of\n * whether it started on the target or not.\n */\n onPressUp?: (e: PressEvent) => void;\n}\n\n/**\n *\n * A behavioral primitive that can be used to make any element pressable while maintaining\n * consistent behavior across devices (mouse, touch, keyboard). It handles edge cases like\n * touch movement and quick releases, and provides proper ARIA attributes for accessibility.\n *\n * @example\n * ```tsx\n * // Make a div pressable\n * <Pressable onPress={handlePress}>\n * <div>Click here</div>\n * </Pressable>\n * ```\n */\nexport const Pressable = withSlots('BentoPressable', function Pressable(args: PressableProps) {\n const { props, apply } = useProps(args);\n const ref = useRef<HTMLElement | null>(null);\n const { children, ...restProps } = props;\n const child = React.Children.only(children);\n const { focusableProps } = useFocusable(restProps, ref);\n const { focusProps, isFocused, isFocusVisible } = useFocusRing(restProps);\n const { hoverProps, isHovered } = useHover(restProps);\n const { pressProps, isPressed } = usePress({ ...restProps, ref });\n\n return React.cloneElement(child, {\n ...apply(\n {\n ...mergeProps(pressProps, focusProps, focusableProps, hoverProps),\n className: style.pressable\n },\n ['onPress', 'onPressStart', 'onPressEnd', 'onPressUp', 'onPressChange', 'children']\n ),\n ...useDataAttributes({\n pressed: isPressed,\n hovered: isHovered,\n focused: isFocused,\n focusVisible: isFocusVisible\n }),\n ref: mergeRefs((child as { ref?: React.Ref<HTMLElement> }).ref, ref)\n });\n});\n"]}
1
+ {"version":3,"file":"index.cjs","names":["React","style"],"sources":["../src/pressable.module.css","../src/index.tsx"],"sourcesContent":[".pressable {\n display: inline-flex;\n appearance: none;\n}\n","import {\n usePress,\n useFocusRing,\n useHover,\n mergeProps,\n type PressProps,\n useFocusable,\n type PressEvent\n} from 'react-aria';\nimport { mergeRefs } from '@react-aria/utils';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots } from '@bento/slots';\nimport React, { type HTMLAttributes, useRef } from 'react';\nimport style from './pressable.module.css';\n\nexport interface PressableProps extends PressProps, Omit<HTMLAttributes<HTMLElement>, keyof PressProps> {\n /** A single React element that will be made pressable. */\n children: React.ReactElement;\n\n /**\n * Handler that is called when the pressable is pressed.\n * Similar to the standard `onClick` event, but normalized to handle all interaction methods consistently.\n */\n onPress?: (e: PressEvent) => void;\n\n /** Handler that is called when a press interaction starts. */\n onPressStart?: (e: PressEvent) => void;\n\n /**\n * Handler that is called when a press interaction ends, either\n * over the target or when the pointer leaves the target.\n */\n onPressEnd?: (e: PressEvent) => void;\n\n /** Handler that is called when the press state changes. */\n onPressChange?: (isPressed: boolean) => void;\n\n /**\n * Handler that is called when a press is released over the target, regardless of\n * whether it started on the target or not.\n */\n onPressUp?: (e: PressEvent) => void;\n}\n\n/**\n *\n * A behavioral primitive that can be used to make any element pressable while maintaining\n * consistent behavior across devices (mouse, touch, keyboard). It handles edge cases like\n * touch movement and quick releases, and provides proper ARIA attributes for accessibility.\n *\n * @example\n * ```tsx\n * // Make a div pressable\n * <Pressable onPress={handlePress}>\n * <div>Click here</div>\n * </Pressable>\n * ```\n */\nexport const Pressable = withSlots('BentoPressable', function Pressable(args: PressableProps) {\n const { props, apply } = useProps(args);\n const ref = useRef<HTMLElement | null>(null);\n const { children, ...restProps } = props;\n const child = React.Children.only(children);\n const { focusableProps } = useFocusable(restProps, ref);\n const { focusProps, isFocused, isFocusVisible } = useFocusRing(restProps);\n const { hoverProps, isHovered } = useHover(restProps);\n const { pressProps, isPressed } = usePress({ ...restProps, ref });\n\n return React.cloneElement(child, {\n ...apply(\n {\n ...mergeProps(pressProps, focusProps, focusableProps, hoverProps),\n className: style.pressable\n },\n ['onPress', 'onPressStart', 'onPressEnd', 'onPressUp', 'onPressChange', 'children']\n ),\n ...useDataAttributes({\n pressed: isPressed,\n hovered: isHovered,\n focused: isFocused,\n focusVisible: isFocusVisible\n }),\n ref: mergeRefs((child as { ref?: React.Ref<HTMLElement> }).ref, ref)\n });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAA,2BAAE,EAAA,aAAgB,mBAAA;;;;;;;;;;;;;;;;;ACyDlB,MAAa,aAAA,GAAA,aAAA,WAAsB,kBAAkB,SAAS,UAAU,MAAsB;CAC5F,MAAM,EAAE,OAAO,WAAA,GAAA,iBAAA,UAAmB,IAAI;CACtC,MAAM,OAAA,GAAA,MAAA,QAAiC,IAAI;CAC3C,MAAM,EAAE,UAAU,GAAG,cAAc;CACnC,MAAM,QAAQA,MAAAA,QAAM,SAAS,KAAK,QAAQ;CAC1C,MAAM,EAAE,oBAAA,GAAA,WAAA,cAAgC,WAAW,GAAG;CACtD,MAAM,EAAE,YAAY,WAAW,oBAAA,GAAA,WAAA,cAAgC,SAAS;CACxE,MAAM,EAAE,YAAY,eAAA,GAAA,WAAA,UAAuB,SAAS;CACpD,MAAM,EAAE,YAAY,eAAA,GAAA,WAAA,UAAuB;EAAE,GAAG;EAAW;CAAI,CAAC;CAEhE,OAAOA,MAAAA,QAAM,aAAa,OAAO;EAC/B,GAAG,MACD;GACE,IAAA,GAAA,WAAA,YAAc,YAAY,YAAY,gBAAgB,UAAU;GAChE,WAAWC,yBAAM;EACnB,GACA;GAAC;GAAW;GAAgB;GAAc;GAAa;GAAiB;EAAU,CACpF;EACA,IAAA,GAAA,2BAAA,mBAAqB;GACnB,SAAS;GACT,SAAS;GACT,SAAS;GACT,cAAc;EAChB,CAAC;EACD,MAAA,GAAA,kBAAA,WAAgB,MAA2C,KAAK,GAAG;CACrE,CAAC;AACH,CAAC"}
package/dist/index.d.cts CHANGED
@@ -1,29 +1,29 @@
1
- import * as _bento_slots from '@bento/slots';
2
- import { PressProps, PressEvent } from 'react-aria';
3
- import React, { HTMLAttributes } from 'react';
1
+ import { PressEvent, PressProps } from "react-aria";
2
+ import React, { HTMLAttributes } from "react";
4
3
 
4
+ //#region src/index.d.ts
5
5
  interface PressableProps extends PressProps, Omit<HTMLAttributes<HTMLElement>, keyof PressProps> {
6
- /** A single React element that will be made pressable. */
7
- children: React.ReactElement;
8
- /**
9
- * Handler that is called when the pressable is pressed.
10
- * Similar to the standard `onClick` event, but normalized to handle all interaction methods consistently.
11
- */
12
- onPress?: (e: PressEvent) => void;
13
- /** Handler that is called when a press interaction starts. */
14
- onPressStart?: (e: PressEvent) => void;
15
- /**
16
- * Handler that is called when a press interaction ends, either
17
- * over the target or when the pointer leaves the target.
18
- */
19
- onPressEnd?: (e: PressEvent) => void;
20
- /** Handler that is called when the press state changes. */
21
- onPressChange?: (isPressed: boolean) => void;
22
- /**
23
- * Handler that is called when a press is released over the target, regardless of
24
- * whether it started on the target or not.
25
- */
26
- onPressUp?: (e: PressEvent) => void;
6
+ /** A single React element that will be made pressable. */
7
+ children: React.ReactElement;
8
+ /**
9
+ * Handler that is called when the pressable is pressed.
10
+ * Similar to the standard `onClick` event, but normalized to handle all interaction methods consistently.
11
+ */
12
+ onPress?: (e: PressEvent) => void;
13
+ /** Handler that is called when a press interaction starts. */
14
+ onPressStart?: (e: PressEvent) => void;
15
+ /**
16
+ * Handler that is called when a press interaction ends, either
17
+ * over the target or when the pointer leaves the target.
18
+ */
19
+ onPressEnd?: (e: PressEvent) => void;
20
+ /** Handler that is called when the press state changes. */
21
+ onPressChange?: (isPressed: boolean) => void;
22
+ /**
23
+ * Handler that is called when a press is released over the target, regardless of
24
+ * whether it started on the target or not.
25
+ */
26
+ onPressUp?: (e: PressEvent) => void;
27
27
  }
28
28
  /**
29
29
  *
@@ -39,6 +39,7 @@ interface PressableProps extends PressProps, Omit<HTMLAttributes<HTMLElement>, k
39
39
  * </Pressable>
40
40
  * ```
41
41
  */
42
- declare const Pressable: React.MemoExoticComponent<React.ComponentType<PressableProps & _bento_slots.Slots>>;
43
-
44
- export { Pressable, type PressableProps };
42
+ declare const Pressable: React.MemoExoticComponent<React.ComponentType<any>>;
43
+ //#endregion
44
+ export { Pressable, PressableProps };
45
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;UAgBiB,cAAA,SAAuB,UAAA,EAAY,IAAA,CAAK,cAAA,CAAe,WAAA,SAAoB,UAAA;;EAE1F,QAAA,EAAU,KAAA,CAAM,YAAA;EAFc;;;;EAQ9B,OAAA,IAAW,CAAA,EAAG,UAAA;EANJ;EASV,YAAA,IAAgB,CAAA,EAAG,UAAA;EAAA;;;;EAMnB,UAAA,IAAc,CAAA,EAAG,UAAA;EAjBqC;EAoBtD,aAAA,IAAiB,SAAA;EApBqB;;;;EA0BtC,SAAA,IAAa,CAAA,EAAG,UAAA;AAAA;;;;;;;;;;;;;;;cAiBL,SAAA,EAAS,KAAA,CAAA,mBAAA,CAAA,KAAA,CAAA,aAAA"}
@@ -0,0 +1,45 @@
1
+ import { PressEvent, PressProps } from "react-aria";
2
+ import React, { HTMLAttributes } from "react";
3
+
4
+ //#region src/index.d.ts
5
+ interface PressableProps extends PressProps, Omit<HTMLAttributes<HTMLElement>, keyof PressProps> {
6
+ /** A single React element that will be made pressable. */
7
+ children: React.ReactElement;
8
+ /**
9
+ * Handler that is called when the pressable is pressed.
10
+ * Similar to the standard `onClick` event, but normalized to handle all interaction methods consistently.
11
+ */
12
+ onPress?: (e: PressEvent) => void;
13
+ /** Handler that is called when a press interaction starts. */
14
+ onPressStart?: (e: PressEvent) => void;
15
+ /**
16
+ * Handler that is called when a press interaction ends, either
17
+ * over the target or when the pointer leaves the target.
18
+ */
19
+ onPressEnd?: (e: PressEvent) => void;
20
+ /** Handler that is called when the press state changes. */
21
+ onPressChange?: (isPressed: boolean) => void;
22
+ /**
23
+ * Handler that is called when a press is released over the target, regardless of
24
+ * whether it started on the target or not.
25
+ */
26
+ onPressUp?: (e: PressEvent) => void;
27
+ }
28
+ /**
29
+ *
30
+ * A behavioral primitive that can be used to make any element pressable while maintaining
31
+ * consistent behavior across devices (mouse, touch, keyboard). It handles edge cases like
32
+ * touch movement and quick releases, and provides proper ARIA attributes for accessibility.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * // Make a div pressable
37
+ * <Pressable onPress={handlePress}>
38
+ * <div>Click here</div>
39
+ * </Pressable>
40
+ * ```
41
+ */
42
+ declare const Pressable: React.MemoExoticComponent<React.ComponentType<any>>;
43
+ //#endregion
44
+ export { Pressable, PressableProps };
45
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;UAgBiB,cAAA,SAAuB,UAAA,EAAY,IAAA,CAAK,cAAA,CAAe,WAAA,SAAoB,UAAA;;EAE1F,QAAA,EAAU,KAAA,CAAM,YAAA;EAFc;;;;EAQ9B,OAAA,IAAW,CAAA,EAAG,UAAA;EANJ;EASV,YAAA,IAAgB,CAAA,EAAG,UAAA;EAAA;;;;EAMnB,UAAA,IAAc,CAAA,EAAG,UAAA;EAjBqC;EAoBtD,aAAA,IAAiB,SAAA;EApBqB;;;;EA0BtC,SAAA,IAAa,CAAA,EAAG,UAAA;AAAA;;;;;;;;;;;;;;;cAiBL,SAAA,EAAS,KAAA,CAAA,mBAAA,CAAA,KAAA,CAAA,aAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,61 @@
1
+ import { mergeProps, useFocusRing, useFocusable, useHover, usePress } from "react-aria";
2
+ import { mergeRefs } from "@react-aria/utils";
3
+ import { useDataAttributes } from "@bento/use-data-attributes";
4
+ import { useProps } from "@bento/use-props";
5
+ import { withSlots } from "@bento/slots";
6
+ import React, { useRef } from "react";
7
+ //#region src/pressable.module.css
8
+ var pressable_module_default = { "pressable": "rYyWlq_pressable" };
9
+ //#endregion
10
+ //#region src/index.tsx
11
+ /**
12
+ *
13
+ * A behavioral primitive that can be used to make any element pressable while maintaining
14
+ * consistent behavior across devices (mouse, touch, keyboard). It handles edge cases like
15
+ * touch movement and quick releases, and provides proper ARIA attributes for accessibility.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * // Make a div pressable
20
+ * <Pressable onPress={handlePress}>
21
+ * <div>Click here</div>
22
+ * </Pressable>
23
+ * ```
24
+ */
25
+ const Pressable = withSlots("BentoPressable", function Pressable(args) {
26
+ const { props, apply } = useProps(args);
27
+ const ref = useRef(null);
28
+ const { children, ...restProps } = props;
29
+ const child = React.Children.only(children);
30
+ const { focusableProps } = useFocusable(restProps, ref);
31
+ const { focusProps, isFocused, isFocusVisible } = useFocusRing(restProps);
32
+ const { hoverProps, isHovered } = useHover(restProps);
33
+ const { pressProps, isPressed } = usePress({
34
+ ...restProps,
35
+ ref
36
+ });
37
+ return React.cloneElement(child, {
38
+ ...apply({
39
+ ...mergeProps(pressProps, focusProps, focusableProps, hoverProps),
40
+ className: pressable_module_default.pressable
41
+ }, [
42
+ "onPress",
43
+ "onPressStart",
44
+ "onPressEnd",
45
+ "onPressUp",
46
+ "onPressChange",
47
+ "children"
48
+ ]),
49
+ ...useDataAttributes({
50
+ pressed: isPressed,
51
+ hovered: isHovered,
52
+ focused: isFocused,
53
+ focusVisible: isFocusVisible
54
+ }),
55
+ ref: mergeRefs(child.ref, ref)
56
+ });
57
+ });
58
+ //#endregion
59
+ export { Pressable };
60
+
61
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["style"],"sources":["../src/pressable.module.css","../src/index.tsx"],"sourcesContent":[".pressable {\n display: inline-flex;\n appearance: none;\n}\n","import {\n usePress,\n useFocusRing,\n useHover,\n mergeProps,\n type PressProps,\n useFocusable,\n type PressEvent\n} from 'react-aria';\nimport { mergeRefs } from '@react-aria/utils';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots } from '@bento/slots';\nimport React, { type HTMLAttributes, useRef } from 'react';\nimport style from './pressable.module.css';\n\nexport interface PressableProps extends PressProps, Omit<HTMLAttributes<HTMLElement>, keyof PressProps> {\n /** A single React element that will be made pressable. */\n children: React.ReactElement;\n\n /**\n * Handler that is called when the pressable is pressed.\n * Similar to the standard `onClick` event, but normalized to handle all interaction methods consistently.\n */\n onPress?: (e: PressEvent) => void;\n\n /** Handler that is called when a press interaction starts. */\n onPressStart?: (e: PressEvent) => void;\n\n /**\n * Handler that is called when a press interaction ends, either\n * over the target or when the pointer leaves the target.\n */\n onPressEnd?: (e: PressEvent) => void;\n\n /** Handler that is called when the press state changes. */\n onPressChange?: (isPressed: boolean) => void;\n\n /**\n * Handler that is called when a press is released over the target, regardless of\n * whether it started on the target or not.\n */\n onPressUp?: (e: PressEvent) => void;\n}\n\n/**\n *\n * A behavioral primitive that can be used to make any element pressable while maintaining\n * consistent behavior across devices (mouse, touch, keyboard). It handles edge cases like\n * touch movement and quick releases, and provides proper ARIA attributes for accessibility.\n *\n * @example\n * ```tsx\n * // Make a div pressable\n * <Pressable onPress={handlePress}>\n * <div>Click here</div>\n * </Pressable>\n * ```\n */\nexport const Pressable = withSlots('BentoPressable', function Pressable(args: PressableProps) {\n const { props, apply } = useProps(args);\n const ref = useRef<HTMLElement | null>(null);\n const { children, ...restProps } = props;\n const child = React.Children.only(children);\n const { focusableProps } = useFocusable(restProps, ref);\n const { focusProps, isFocused, isFocusVisible } = useFocusRing(restProps);\n const { hoverProps, isHovered } = useHover(restProps);\n const { pressProps, isPressed } = usePress({ ...restProps, ref });\n\n return React.cloneElement(child, {\n ...apply(\n {\n ...mergeProps(pressProps, focusProps, focusableProps, hoverProps),\n className: style.pressable\n },\n ['onPress', 'onPressStart', 'onPressEnd', 'onPressUp', 'onPressChange', 'children']\n ),\n ...useDataAttributes({\n pressed: isPressed,\n hovered: isHovered,\n focused: isFocused,\n focusVisible: isFocusVisible\n }),\n ref: mergeRefs((child as { ref?: React.Ref<HTMLElement> }).ref, ref)\n });\n});\n"],"mappings":";;;;;;;AAEA,IAAA,2BAAE,EAAA,aAAgB,mBAAA;;;;;;;;;;;;;;;;;ACyDlB,MAAa,YAAY,UAAU,kBAAkB,SAAS,UAAU,MAAsB;CAC5F,MAAM,EAAE,OAAO,UAAU,SAAS,IAAI;CACtC,MAAM,MAAM,OAA2B,IAAI;CAC3C,MAAM,EAAE,UAAU,GAAG,cAAc;CACnC,MAAM,QAAQ,MAAM,SAAS,KAAK,QAAQ;CAC1C,MAAM,EAAE,mBAAmB,aAAa,WAAW,GAAG;CACtD,MAAM,EAAE,YAAY,WAAW,mBAAmB,aAAa,SAAS;CACxE,MAAM,EAAE,YAAY,cAAc,SAAS,SAAS;CACpD,MAAM,EAAE,YAAY,cAAc,SAAS;EAAE,GAAG;EAAW;CAAI,CAAC;CAEhE,OAAO,MAAM,aAAa,OAAO;EAC/B,GAAG,MACD;GACE,GAAG,WAAW,YAAY,YAAY,gBAAgB,UAAU;GAChE,WAAWA,yBAAM;EACnB,GACA;GAAC;GAAW;GAAgB;GAAc;GAAa;GAAiB;EAAU,CACpF;EACA,GAAG,kBAAkB;GACnB,SAAS;GACT,SAAS;GACT,SAAS;GACT,cAAc;EAChB,CAAC;EACD,KAAK,UAAW,MAA2C,KAAK,GAAG;CACrE,CAAC;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
- .pressable {
2
- display: inline-flex;
1
+ .rYyWlq_pressable {
3
2
  appearance: none;
3
+ display: inline-flex;
4
4
  }
package/package.json CHANGED
@@ -1,22 +1,21 @@
1
1
  {
2
2
  "name": "@bento/pressable",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Pressable primitive provides consistent press interactions and accessibility features for building interactive components",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
- "module": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
8
  "scripts": {
9
- "build": "tsup-node",
10
- "lint": "biome lint && tsc",
11
- "posttest": "npm run lint",
12
- "prepublishOnly": "node ../../scripts/compile-readme.ts",
13
- "pretest": "npm run build",
9
+ "build": "tsdown",
10
+ "lint": "biome lint && tsgo --noEmit",
11
+ "prepublishOnly": "node ../../../scripts/compile-readme.ts",
14
12
  "test": "vitest --run",
15
- "test:watch": "vitest"
13
+ "test:watch": "vitest",
14
+ "typecheck": "tsgo --noEmit -p tsconfig.json"
16
15
  },
17
16
  "repository": {
18
17
  "type": "git",
19
- "url": "git+https://github.com/godaddy/bento.git"
18
+ "url": "git+https://github.com/godaddy/antares.git"
20
19
  },
21
20
  "keywords": [
22
21
  "accessibility",
@@ -31,20 +30,28 @@
31
30
  "author": "GoDaddy Operating Company, LLC",
32
31
  "license": "MIT",
33
32
  "bugs": {
34
- "url": "https://github.com/godaddy/bento/issues"
33
+ "url": "https://github.com/godaddy/antares/issues"
35
34
  },
36
- "homepage": "https://github.com/godaddy/bento#readme",
35
+ "homepage": "https://github.com/godaddy/antares#readme",
37
36
  "files": [
38
37
  "dist",
39
38
  "src",
40
39
  "package.json"
41
40
  ],
42
41
  "dependencies": {
43
- "@bento/slots": "^0.2.0",
42
+ "@bento/slots": "^0.3.0",
44
43
  "@bento/use-data-attributes": "^0.1.1",
45
- "@bento/use-props": "^0.2.0",
46
- "@react-aria/utils": "^3.30.0",
47
- "react-aria": "^3.44.0"
44
+ "@bento/use-props": "^0.2.3",
45
+ "@react-aria/utils": "^3.34.0",
46
+ "react-aria": "^3.48.0"
47
+ },
48
+ "devDependencies": {
49
+ "@types/react": "^19.2.15",
50
+ "@types/react-dom": "^19.2.3",
51
+ "tsdown": "^0.22.1",
52
+ "typescript": "^6.0.3",
53
+ "vitest": "^4.1.7",
54
+ "vitest-browser-react": "^2.2.0"
48
55
  },
49
56
  "peerDependencies": {
50
57
  "react": "18.x || 19.x",
@@ -53,8 +60,8 @@
53
60
  "exports": {
54
61
  ".": {
55
62
  "import": {
56
- "types": "./dist/index.d.ts",
57
- "default": "./dist/index.js"
63
+ "types": "./dist/index.d.mts",
64
+ "default": "./dist/index.mjs"
58
65
  },
59
66
  "require": {
60
67
  "types": "./dist/index.d.cts",
@@ -0,0 +1,4 @@
1
+ declare module '*.module.css' {
2
+ const classes: { [key: string]: string };
3
+ export default classes;
4
+ }
package/dist/index.d.ts DELETED
@@ -1,44 +0,0 @@
1
- import * as _bento_slots from '@bento/slots';
2
- import { PressProps, PressEvent } from 'react-aria';
3
- import React, { HTMLAttributes } from 'react';
4
-
5
- interface PressableProps extends PressProps, Omit<HTMLAttributes<HTMLElement>, keyof PressProps> {
6
- /** A single React element that will be made pressable. */
7
- children: React.ReactElement;
8
- /**
9
- * Handler that is called when the pressable is pressed.
10
- * Similar to the standard `onClick` event, but normalized to handle all interaction methods consistently.
11
- */
12
- onPress?: (e: PressEvent) => void;
13
- /** Handler that is called when a press interaction starts. */
14
- onPressStart?: (e: PressEvent) => void;
15
- /**
16
- * Handler that is called when a press interaction ends, either
17
- * over the target or when the pointer leaves the target.
18
- */
19
- onPressEnd?: (e: PressEvent) => void;
20
- /** Handler that is called when the press state changes. */
21
- onPressChange?: (isPressed: boolean) => void;
22
- /**
23
- * Handler that is called when a press is released over the target, regardless of
24
- * whether it started on the target or not.
25
- */
26
- onPressUp?: (e: PressEvent) => void;
27
- }
28
- /**
29
- *
30
- * A behavioral primitive that can be used to make any element pressable while maintaining
31
- * consistent behavior across devices (mouse, touch, keyboard). It handles edge cases like
32
- * touch movement and quick releases, and provides proper ARIA attributes for accessibility.
33
- *
34
- * @example
35
- * ```tsx
36
- * // Make a div pressable
37
- * <Pressable onPress={handlePress}>
38
- * <div>Click here</div>
39
- * </Pressable>
40
- * ```
41
- */
42
- declare const Pressable: React.MemoExoticComponent<React.ComponentType<PressableProps & _bento_slots.Slots>>;
43
-
44
- export { Pressable, type PressableProps };
package/dist/index.js DELETED
@@ -1,39 +0,0 @@
1
- import { useFocusable, useFocusRing, useHover, usePress, mergeProps } from 'react-aria';
2
- import { mergeRefs } from '@react-aria/utils';
3
- import { useDataAttributes } from '@bento/use-data-attributes';
4
- import { useProps } from '@bento/use-props';
5
- import { withSlots } from '@bento/slots';
6
- import React, { useRef } from 'react';
7
- import style from './pressable.module-JXZDAJ3U.module.css';
8
-
9
- // src/index.tsx
10
- var Pressable = withSlots("BentoPressable", function Pressable2(args) {
11
- const { props, apply } = useProps(args);
12
- const ref = useRef(null);
13
- const { children, ...restProps } = props;
14
- const child = React.Children.only(children);
15
- const { focusableProps } = useFocusable(restProps, ref);
16
- const { focusProps, isFocused, isFocusVisible } = useFocusRing(restProps);
17
- const { hoverProps, isHovered } = useHover(restProps);
18
- const { pressProps, isPressed } = usePress({ ...restProps, ref });
19
- return React.cloneElement(child, {
20
- ...apply(
21
- {
22
- ...mergeProps(pressProps, focusProps, focusableProps, hoverProps),
23
- className: style.pressable
24
- },
25
- ["onPress", "onPressStart", "onPressEnd", "onPressUp", "onPressChange", "children"]
26
- ),
27
- ...useDataAttributes({
28
- pressed: isPressed,
29
- hovered: isHovered,
30
- focused: isFocused,
31
- focusVisible: isFocusVisible
32
- }),
33
- ref: mergeRefs(child.ref, ref)
34
- });
35
- });
36
-
37
- export { Pressable };
38
- //# sourceMappingURL=index.js.map
39
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.tsx"],"names":["Pressable"],"mappings":";;;;;;;;;AA2DO,IAAM,SAAA,GAAY,SAAA,CAAU,gBAAA,EAAkB,SAASA,WAAU,IAAA,EAAsB;AAC5F,EAAA,MAAM,EAAE,KAAA,EAAO,KAAA,EAAM,GAAI,SAAS,IAAI,CAAA;AACtC,EAAA,MAAM,GAAA,GAAM,OAA2B,IAAI,CAAA;AAC3C,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,SAAA,EAAU,GAAI,KAAA;AACnC,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,QAAA,CAAS,IAAA,CAAK,QAAQ,CAAA;AAC1C,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,YAAA,CAAa,WAAW,GAAG,CAAA;AACtD,EAAA,MAAM,EAAE,UAAA,EAAY,SAAA,EAAW,cAAA,EAAe,GAAI,aAAa,SAAS,CAAA;AACxE,EAAA,MAAM,EAAE,UAAA,EAAY,SAAA,EAAU,GAAI,SAAS,SAAS,CAAA;AACpD,EAAA,MAAM,EAAE,YAAY,SAAA,EAAU,GAAI,SAAS,EAAE,GAAG,SAAA,EAAW,GAAA,EAAK,CAAA;AAEhE,EAAA,OAAO,KAAA,CAAM,aAAa,KAAA,EAAO;AAAA,IAC/B,GAAG,KAAA;AAAA,MACD;AAAA,QACE,GAAG,UAAA,CAAW,UAAA,EAAY,UAAA,EAAY,gBAAgB,UAAU,CAAA;AAAA,QAChE,WAAW,KAAA,CAAM;AAAA,OACnB;AAAA,MACA,CAAC,SAAA,EAAW,cAAA,EAAgB,YAAA,EAAc,WAAA,EAAa,iBAAiB,UAAU;AAAA,KACpF;AAAA,IACA,GAAG,iBAAA,CAAkB;AAAA,MACnB,OAAA,EAAS,SAAA;AAAA,MACT,OAAA,EAAS,SAAA;AAAA,MACT,OAAA,EAAS,SAAA;AAAA,MACT,YAAA,EAAc;AAAA,KACf,CAAA;AAAA,IACD,GAAA,EAAK,SAAA,CAAW,KAAA,CAA2C,GAAA,EAAK,GAAG;AAAA,GACpE,CAAA;AACH,CAAC","file":"index.js","sourcesContent":["import {\n usePress,\n useFocusRing,\n useHover,\n mergeProps,\n type PressProps,\n useFocusable,\n type PressEvent\n} from 'react-aria';\nimport { mergeRefs } from '@react-aria/utils';\nimport { useDataAttributes } from '@bento/use-data-attributes';\nimport { useProps } from '@bento/use-props';\nimport { withSlots } from '@bento/slots';\nimport React, { type HTMLAttributes, useRef } from 'react';\nimport style from './pressable.module.css';\n\nexport interface PressableProps extends PressProps, Omit<HTMLAttributes<HTMLElement>, keyof PressProps> {\n /** A single React element that will be made pressable. */\n children: React.ReactElement;\n\n /**\n * Handler that is called when the pressable is pressed.\n * Similar to the standard `onClick` event, but normalized to handle all interaction methods consistently.\n */\n onPress?: (e: PressEvent) => void;\n\n /** Handler that is called when a press interaction starts. */\n onPressStart?: (e: PressEvent) => void;\n\n /**\n * Handler that is called when a press interaction ends, either\n * over the target or when the pointer leaves the target.\n */\n onPressEnd?: (e: PressEvent) => void;\n\n /** Handler that is called when the press state changes. */\n onPressChange?: (isPressed: boolean) => void;\n\n /**\n * Handler that is called when a press is released over the target, regardless of\n * whether it started on the target or not.\n */\n onPressUp?: (e: PressEvent) => void;\n}\n\n/**\n *\n * A behavioral primitive that can be used to make any element pressable while maintaining\n * consistent behavior across devices (mouse, touch, keyboard). It handles edge cases like\n * touch movement and quick releases, and provides proper ARIA attributes for accessibility.\n *\n * @example\n * ```tsx\n * // Make a div pressable\n * <Pressable onPress={handlePress}>\n * <div>Click here</div>\n * </Pressable>\n * ```\n */\nexport const Pressable = withSlots('BentoPressable', function Pressable(args: PressableProps) {\n const { props, apply } = useProps(args);\n const ref = useRef<HTMLElement | null>(null);\n const { children, ...restProps } = props;\n const child = React.Children.only(children);\n const { focusableProps } = useFocusable(restProps, ref);\n const { focusProps, isFocused, isFocusVisible } = useFocusRing(restProps);\n const { hoverProps, isHovered } = useHover(restProps);\n const { pressProps, isPressed } = usePress({ ...restProps, ref });\n\n return React.cloneElement(child, {\n ...apply(\n {\n ...mergeProps(pressProps, focusProps, focusableProps, hoverProps),\n className: style.pressable\n },\n ['onPress', 'onPressStart', 'onPressEnd', 'onPressUp', 'onPressChange', 'children']\n ),\n ...useDataAttributes({\n pressed: isPressed,\n hovered: isHovered,\n focused: isFocused,\n focusVisible: isFocusVisible\n }),\n ref: mergeRefs((child as { ref?: React.Ref<HTMLElement> }).ref, ref)\n });\n});\n"]}