@ankhorage/surface 7.0.0 → 8.0.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/features/button/adapters/inbound/Button.d.ts.map +1 -1
  4. package/dist/features/button/adapters/inbound/Button.js +5 -5
  5. package/dist/features/button/adapters/inbound/Button.js.map +1 -1
  6. package/dist/features/button/adapters/inbound/IconButton.d.ts.map +1 -1
  7. package/dist/features/button/adapters/inbound/IconButton.js +3 -3
  8. package/dist/features/button/adapters/inbound/IconButton.js.map +1 -1
  9. package/dist/features/card/adapters/inbound/Card.d.ts.map +1 -1
  10. package/dist/features/card/adapters/inbound/Card.js +3 -3
  11. package/dist/features/card/adapters/inbound/Card.js.map +1 -1
  12. package/dist/features/form/checkbox/adapters/inbound/Checkbox.d.ts.map +1 -1
  13. package/dist/features/form/checkbox/adapters/inbound/Checkbox.js +3 -3
  14. package/dist/features/form/checkbox/adapters/inbound/Checkbox.js.map +1 -1
  15. package/dist/features/form/radio/adapters/inbound/Radio.d.ts.map +1 -1
  16. package/dist/features/form/radio/adapters/inbound/Radio.js +3 -3
  17. package/dist/features/form/radio/adapters/inbound/Radio.js.map +1 -1
  18. package/dist/features/form/switch/adapters/inbound/Switch.d.ts.map +1 -1
  19. package/dist/features/form/switch/adapters/inbound/Switch.js +3 -3
  20. package/dist/features/form/switch/adapters/inbound/Switch.js.map +1 -1
  21. package/dist/features/list/adapters/inbound/ListItem.d.ts.map +1 -1
  22. package/dist/features/list/adapters/inbound/ListItem.js +3 -3
  23. package/dist/features/list/adapters/inbound/ListItem.js.map +1 -1
  24. package/dist/features/pressable/adapters/inbound/Pressable.d.ts +5 -0
  25. package/dist/features/pressable/adapters/inbound/Pressable.d.ts.map +1 -0
  26. package/dist/features/pressable/adapters/inbound/Pressable.js +48 -0
  27. package/dist/features/pressable/adapters/inbound/Pressable.js.map +1 -0
  28. package/dist/features/pressable/public.d.ts +3 -0
  29. package/dist/features/pressable/public.d.ts.map +1 -0
  30. package/dist/features/pressable/public.js +2 -0
  31. package/dist/features/pressable/public.js.map +1 -0
  32. package/dist/index.d.ts +2 -2
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/types/button.d.ts +3 -3
  37. package/dist/types/button.d.ts.map +1 -1
  38. package/dist/types/button.js.map +1 -1
  39. package/dist/types/checkbox.d.ts +2 -2
  40. package/dist/types/checkbox.d.ts.map +1 -1
  41. package/dist/types/checkbox.js.map +1 -1
  42. package/dist/{primitives/button-base/types.d.ts → types/pressable.d.ts} +5 -5
  43. package/dist/types/pressable.d.ts.map +1 -0
  44. package/dist/types/pressable.js +2 -0
  45. package/dist/types/pressable.js.map +1 -0
  46. package/dist/types/radio.d.ts +2 -2
  47. package/dist/types/radio.d.ts.map +1 -1
  48. package/dist/types/radio.js.map +1 -1
  49. package/dist/types/switch.d.ts +2 -2
  50. package/dist/types/switch.d.ts.map +1 -1
  51. package/dist/types/switch.js.map +1 -1
  52. package/package.json +1 -1
  53. package/src/features/button/adapters/inbound/Button.tsx +6 -6
  54. package/src/features/button/adapters/inbound/IconButton.tsx +3 -3
  55. package/src/features/card/adapters/inbound/Card.tsx +3 -3
  56. package/src/features/form/checkbox/adapters/inbound/Checkbox.tsx +5 -5
  57. package/src/features/form/radio/adapters/inbound/Radio.tsx +5 -5
  58. package/src/features/form/switch/adapters/inbound/Switch.tsx +3 -3
  59. package/src/features/list/adapters/inbound/ListItem.tsx +3 -3
  60. package/src/{primitives/button-base/ButtonBase.tsx → features/pressable/adapters/inbound/Pressable.tsx} +45 -31
  61. package/src/features/pressable/public.ts +2 -0
  62. package/src/index.test.ts +2 -0
  63. package/src/index.ts +2 -2
  64. package/src/interactionPolicy.test.ts +4 -4
  65. package/src/types/button.ts +3 -3
  66. package/src/types/checkbox.ts +2 -2
  67. package/src/{primitives/button-base/types.ts → types/pressable.ts} +4 -4
  68. package/src/types/radio.ts +2 -2
  69. package/src/types/switch.ts +2 -2
  70. package/dist/primitives/button-base/ButtonBase.d.ts +0 -5
  71. package/dist/primitives/button-base/ButtonBase.d.ts.map +0 -1
  72. package/dist/primitives/button-base/ButtonBase.js +0 -42
  73. package/dist/primitives/button-base/ButtonBase.js.map +0 -1
  74. package/dist/primitives/button-base/index.d.ts +0 -3
  75. package/dist/primitives/button-base/index.d.ts.map +0 -1
  76. package/dist/primitives/button-base/index.js +0 -2
  77. package/dist/primitives/button-base/index.js.map +0 -1
  78. package/dist/primitives/button-base/types.d.ts.map +0 -1
  79. package/dist/primitives/button-base/types.js +0 -2
  80. package/dist/primitives/button-base/types.js.map +0 -1
  81. package/src/primitives/button-base/index.ts +0 -2
@@ -1,33 +1,22 @@
1
1
  import React from 'react';
2
- import { Platform, Pressable, type PressableStateCallbackType } from 'react-native';
2
+ import {
3
+ Platform,
4
+ Pressable as ReactNativePressable,
5
+ type PressableStateCallbackType,
6
+ } from 'react-native';
3
7
 
4
- import { useResponsiveRuntime } from '../../core/responsive';
8
+ import { useResponsiveRuntime } from '../../../../core/responsive';
5
9
  import {
6
10
  type InteractionState,
7
11
  resolveFocusRingStyles,
8
12
  resolveInteractiveState,
9
- } from '../../internal/resolvers';
10
- import { useTheme } from '../../theme/ThemeContext';
11
- import { resolveViewStyles } from '../../utils/resolveViewStyles';
12
- import type { ButtonBaseProps } from './types';
13
+ } from '../../../../internal/resolvers';
14
+ import { useTheme } from '../../../../theme/ThemeContext';
15
+ import type { PressableProps } from '../../../../types/pressable';
16
+ import { resolveViewStyles } from '../../../../utils/resolveViewStyles';
13
17
 
14
- /*** Resolves one Pressable state into the canonical Surface interaction state. */
15
- function getInteractionState(
16
- pressableState: PressableStateCallbackType,
17
- hovered: boolean,
18
- focused: boolean,
19
- disabled: boolean,
20
- ): InteractionState {
21
- return resolveInteractiveState({
22
- pressed: pressableState.pressed,
23
- hovered,
24
- focused,
25
- disabled,
26
- });
27
- }
28
-
29
- /*** Renders the low-level token-aware Pressable boundary shared by Surface controls. */
30
- export function ButtonBase({
18
+ /*** Renders the token-aware Surface adapter for React Native Pressable. */
19
+ export function Pressable({
31
20
  children,
32
21
  disabled = false,
33
22
  interactionPolicy = 'enabled',
@@ -39,17 +28,18 @@ export function ButtonBase({
39
28
  style,
40
29
  testID,
41
30
  ...props
42
- }: ButtonBaseProps) {
31
+ }: PressableProps) {
43
32
  const { theme } = useTheme();
44
33
  const { breakpoint } = useResponsiveRuntime();
45
34
  const [hovered, setHovered] = React.useState(false);
46
35
  const [focused, setFocused] = React.useState(false);
47
36
  const isWeb = Platform.OS === 'web';
48
37
  const resolvedViewStyles = resolveViewStyles(theme, breakpoint, props);
49
- const passive = interactionPolicy === 'passive';
38
+ const pressHandlers = resolvePressHandlers(interactionPolicy, onPress, onLongPress);
50
39
 
51
40
  return (
52
- <Pressable
41
+ <ReactNativePressable
42
+ {...pressHandlers}
53
43
  accessibilityLabel={accessibilityLabel}
54
44
  accessibilityRole={accessibilityRole}
55
45
  accessibilityState={{ ...accessibilityState, disabled }}
@@ -60,10 +50,8 @@ export function ButtonBase({
60
50
  }}
61
51
  onHoverIn={isWeb ? () => setHovered(true) : undefined}
62
52
  onHoverOut={isWeb ? () => setHovered(false) : undefined}
63
- onLongPress={passive ? undefined : onLongPress}
64
- onPress={passive ? undefined : onPress}
65
53
  style={(pressableState) => {
66
- const state = getInteractionState(pressableState, hovered, focused, disabled);
54
+ const state = resolveInteractionState(pressableState, hovered, focused, disabled);
67
55
  return [
68
56
  resolvedViewStyles,
69
57
  resolveFocusRingStyles(theme.semantics.border.focus, state.focused, isWeb),
@@ -73,9 +61,35 @@ export function ButtonBase({
73
61
  testID={testID}
74
62
  >
75
63
  {(pressableState) => {
76
- const state = getInteractionState(pressableState, hovered, focused, disabled);
64
+ const state = resolveInteractionState(pressableState, hovered, focused, disabled);
77
65
  return typeof children === 'function' ? children(state) : children;
78
66
  }}
79
- </Pressable>
67
+ </ReactNativePressable>
80
68
  );
81
69
  }
70
+
71
+ /*** Resolves press handlers according to the shared interaction policy. */
72
+ function resolvePressHandlers(
73
+ interactionPolicy: PressableProps['interactionPolicy'],
74
+ onPress: PressableProps['onPress'],
75
+ onLongPress: PressableProps['onLongPress'],
76
+ ) {
77
+ return interactionPolicy === 'passive'
78
+ ? { onLongPress: undefined, onPress: undefined }
79
+ : { onLongPress, onPress };
80
+ }
81
+
82
+ /*** Resolves one native Pressable state into the canonical Surface interaction state. */
83
+ function resolveInteractionState(
84
+ pressableState: PressableStateCallbackType,
85
+ hovered: boolean,
86
+ focused: boolean,
87
+ disabled: boolean,
88
+ ): InteractionState {
89
+ return resolveInteractiveState({
90
+ pressed: pressableState.pressed,
91
+ hovered,
92
+ focused,
93
+ disabled,
94
+ });
95
+ }
@@ -0,0 +1,2 @@
1
+ export type { PressableProps } from '../../types/pressable';
2
+ export { Pressable } from './adapters/inbound/Pressable';
package/src/index.test.ts CHANGED
@@ -34,6 +34,7 @@ const expectedFeatureRootExports = [
34
34
  "export { Modal } from './features/modal/public';",
35
35
  "export { PopoverMenu } from './features/popover-menu/public';",
36
36
  "export { Popover } from './features/popover/public';",
37
+ "export { Pressable } from './features/pressable/public';",
37
38
  "export { Surface } from './features/surface/public';",
38
39
  "export { Tab, TabList, TabPanel, Tabs } from './features/tabs/public';",
39
40
  "export { Tooltip } from './features/tooltip/public';",
@@ -54,6 +55,7 @@ describe('feature-owned root barrel contract', () => {
54
55
  it('does not retain removed component or layout facades and aliases', () => {
55
56
  expect(indexSource).not.toContain("'./components/");
56
57
  expect(indexSource).not.toContain("'./layout");
58
+ expect(indexSource).not.toContain("'./primitives/");
57
59
  expect(indexSource).not.toMatch(/\bBoxProps\b/u);
58
60
  expect(indexSource).not.toMatch(/\bContainerProps\b/u);
59
61
  expect(indexSource).not.toMatch(/\bStackProps\b/u);
package/src/index.ts CHANGED
@@ -70,6 +70,8 @@ export type {
70
70
  PopoverMenuProps,
71
71
  } from './features/popover-menu/public';
72
72
  export { PopoverMenu } from './features/popover-menu/public';
73
+ export type { PressableProps } from './features/pressable/public';
74
+ export { Pressable } from './features/pressable/public';
73
75
  export type { SurfaceProps, SurfaceVariant } from './features/surface/public';
74
76
  export { Surface } from './features/surface/public';
75
77
  export type { TabListProps, TabPanelProps, TabProps, TabsProps } from './features/tabs/public';
@@ -87,8 +89,6 @@ export { Tooltip } from './features/tooltip/public';
87
89
  export type { HeadingLevel, HeadingProps, TextProps } from './features/typography/public';
88
90
  export { Heading, Text } from './features/typography/public';
89
91
  export type { InteractionPolicy, InteractionPolicyProps } from './interactionPolicy';
90
- export type { ButtonBaseProps } from './primitives/button-base';
91
- export { ButtonBase } from './primitives/button-base';
92
92
  export type {
93
93
  SurfaceColor,
94
94
  SurfaceEmphasis,
@@ -19,7 +19,7 @@ describe('InteractionPolicy public export', () => {
19
19
 
20
20
  it('does not export InteractionPolicy from button-base', () => {
21
21
  expect(indexSource).not.toContain(
22
- "export type { InteractionPolicy, InteractionPolicyProps } from './primitives/button-base';",
22
+ "export type { InteractionPolicy, InteractionPolicyProps } from './features/pressable/public';",
23
23
  );
24
24
  });
25
25
  });
@@ -57,10 +57,10 @@ describe('InteractionPolicyProps', () => {
57
57
  });
58
58
  });
59
59
 
60
- describe('ButtonBaseProps includes interactionPolicy', () => {
61
- it('has interactionPolicy in ButtonBaseProps', () => {
60
+ describe('PressableProps includes interactionPolicy', () => {
61
+ it('has interactionPolicy in PressableProps', () => {
62
62
  expect(indexSource).toContain(
63
- "export type { ButtonBaseProps } from './primitives/button-base';",
63
+ "export type { PressableProps } from './features/pressable/public';",
64
64
  );
65
65
  });
66
66
  });
@@ -2,14 +2,14 @@ import type React from 'react';
2
2
 
3
3
  import type { ControlSize } from '../internal/resolvers/resolveControlSize';
4
4
  import type { ButtonVariant } from '../internal/resolvers/resolveInteractiveColors';
5
- import type { ButtonBaseProps } from '../primitives/button-base';
6
5
  import type { SurfaceColor } from '../surfaceColor';
7
6
  import type { IconSource } from './icon';
7
+ import type { PressableProps } from './pressable';
8
8
 
9
9
  export type ButtonIconSpec = IconSource;
10
10
 
11
11
  export interface ButtonProps extends Omit<
12
- ButtonBaseProps,
12
+ PressableProps,
13
13
  'accessibilityLabel' | 'children' | 'style'
14
14
  > {
15
15
  children?: React.ReactNode;
@@ -23,7 +23,7 @@ export interface ButtonProps extends Omit<
23
23
  }
24
24
 
25
25
  export interface IconButtonProps extends Omit<
26
- ButtonBaseProps,
26
+ PressableProps,
27
27
  'children' | 'style' | 'accessibilityLabel'
28
28
  > {
29
29
  icon: IconSource;
@@ -1,11 +1,11 @@
1
1
  import type React from 'react';
2
2
 
3
3
  import type { ControlSize } from '../internal/resolvers/resolveControlSize';
4
- import type { ButtonBaseProps } from '../primitives/button-base';
5
4
  import type { SurfaceColor } from '../surfaceColor';
5
+ import type { PressableProps } from './pressable';
6
6
 
7
7
  export interface CheckboxProps extends Omit<
8
- ButtonBaseProps,
8
+ PressableProps,
9
9
  'accessibilityRole' | 'accessibilityState' | 'children' | 'onPress' | 'style'
10
10
  > {
11
11
  children?: React.ReactNode;
@@ -1,11 +1,11 @@
1
1
  import type React from 'react';
2
2
  import type { AccessibilityRole, AccessibilityState, GestureResponderEvent } from 'react-native';
3
3
 
4
- import type { InteractionPolicyProps } from '../../interactionPolicy';
5
- import type { InteractionState } from '../../internal/resolvers/resolveInteractiveState';
6
- import type { ViewProps } from '../../types/layout';
4
+ import type { InteractionPolicyProps } from '../interactionPolicy';
5
+ import type { InteractionState } from '../internal/resolvers/resolveInteractiveState';
6
+ import type { ViewProps } from './layout';
7
7
 
8
- export interface ButtonBaseProps
8
+ export interface PressableProps
9
9
  extends Omit<ViewProps, 'children' | 'pointerEvents'>, InteractionPolicyProps {
10
10
  children?: React.ReactNode | ((state: InteractionState) => React.ReactNode);
11
11
  disabled?: boolean;
@@ -1,11 +1,11 @@
1
1
  import type React from 'react';
2
2
 
3
3
  import type { ControlSize } from '../internal/resolvers/resolveControlSize';
4
- import type { ButtonBaseProps } from '../primitives/button-base';
5
4
  import type { SurfaceColor } from '../surfaceColor';
5
+ import type { PressableProps } from './pressable';
6
6
 
7
7
  export interface RadioProps extends Omit<
8
- ButtonBaseProps,
8
+ PressableProps,
9
9
  'accessibilityRole' | 'accessibilityState' | 'children' | 'onPress' | 'style'
10
10
  > {
11
11
  children?: React.ReactNode;
@@ -1,11 +1,11 @@
1
1
  import type React from 'react';
2
2
 
3
3
  import type { ControlSize } from '../internal/resolvers/resolveControlSize';
4
- import type { ButtonBaseProps } from '../primitives/button-base';
5
4
  import type { SurfaceColor } from '../surfaceColor';
5
+ import type { PressableProps } from './pressable';
6
6
 
7
7
  export interface SwitchProps extends Omit<
8
- ButtonBaseProps,
8
+ PressableProps,
9
9
  'accessibilityRole' | 'accessibilityState' | 'children' | 'onPress' | 'style'
10
10
  > {
11
11
  children?: React.ReactNode;
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import type { ButtonBaseProps } from './types';
3
- /*** Renders the low-level token-aware Pressable boundary shared by Surface controls. */
4
- export declare function ButtonBase({ children, disabled, interactionPolicy, onPress, onLongPress, accessibilityLabel, accessibilityRole, accessibilityState, style, testID, ...props }: ButtonBaseProps): React.JSX.Element;
5
- //# sourceMappingURL=ButtonBase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ButtonBase.d.ts","sourceRoot":"","sources":["../../../src/primitives/button-base/ButtonBase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAiB/C,wFAAwF;AACxF,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,QAAgB,EAChB,iBAA6B,EAC7B,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,iBAA4B,EAC5B,kBAAkB,EAClB,KAAK,EACL,MAAM,EACN,GAAG,KAAK,EACT,EAAE,eAAe,qBAuCjB"}
@@ -1,42 +0,0 @@
1
- import React from 'react';
2
- import { Platform, Pressable } from 'react-native';
3
- import { useResponsiveRuntime } from '../../core/responsive';
4
- import { resolveFocusRingStyles, resolveInteractiveState, } from '../../internal/resolvers';
5
- import { useTheme } from '../../theme/ThemeContext';
6
- import { resolveViewStyles } from '../../utils/resolveViewStyles';
7
- /*** Resolves one Pressable state into the canonical Surface interaction state. */
8
- function getInteractionState(pressableState, hovered, focused, disabled) {
9
- return resolveInteractiveState({
10
- pressed: pressableState.pressed,
11
- hovered,
12
- focused,
13
- disabled,
14
- });
15
- }
16
- /*** Renders the low-level token-aware Pressable boundary shared by Surface controls. */
17
- export function ButtonBase({ children, disabled = false, interactionPolicy = 'enabled', onPress, onLongPress, accessibilityLabel, accessibilityRole = 'button', accessibilityState, style, testID, ...props }) {
18
- const { theme } = useTheme();
19
- const { breakpoint } = useResponsiveRuntime();
20
- const [hovered, setHovered] = React.useState(false);
21
- const [focused, setFocused] = React.useState(false);
22
- const isWeb = Platform.OS === 'web';
23
- const resolvedViewStyles = resolveViewStyles(theme, breakpoint, props);
24
- const passive = interactionPolicy === 'passive';
25
- return (<Pressable accessibilityLabel={accessibilityLabel} accessibilityRole={accessibilityRole} accessibilityState={{ ...accessibilityState, disabled }} disabled={disabled} onBlur={() => setFocused(false)} onFocus={() => {
26
- if (isWeb)
27
- setFocused(true);
28
- }} onHoverIn={isWeb ? () => setHovered(true) : undefined} onHoverOut={isWeb ? () => setHovered(false) : undefined} onLongPress={passive ? undefined : onLongPress} onPress={passive ? undefined : onPress} style={(pressableState) => {
29
- const state = getInteractionState(pressableState, hovered, focused, disabled);
30
- return [
31
- resolvedViewStyles,
32
- resolveFocusRingStyles(theme.semantics.border.focus, state.focused, isWeb),
33
- style,
34
- ];
35
- }} testID={testID}>
36
- {(pressableState) => {
37
- const state = getInteractionState(pressableState, hovered, focused, disabled);
38
- return typeof children === 'function' ? children(state) : children;
39
- }}
40
- </Pressable>);
41
- }
42
- //# sourceMappingURL=ButtonBase.js.map
@@ -1 +0,0 @@
1
- {"version":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QACJ,CAAC,CAAC,CACF,MAAM,CAAC,CAAC,MAAM,CAAC,CAEf;MAAA,CAAC,CAAC,cAAc,EAAE,EAAE;YAClB,MAAM,KAAK,GAAG,mBAAmB,CAAC,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC9E,OAAO,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACrE,CAAC,CACH;IAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { Platform, Pressable, type PressableStateCallbackType } from 'react-native';\n\nimport { useResponsiveRuntime } from '../../core/responsive';\nimport {\n type InteractionState,\n resolveFocusRingStyles,\n resolveInteractiveState,\n} from '../../internal/resolvers';\nimport { useTheme } from '../../theme/ThemeContext';\nimport { resolveViewStyles } from '../../utils/resolveViewStyles';\nimport type { ButtonBaseProps } from './types';\n\n/*** Resolves one Pressable state into the canonical Surface interaction state. */\nfunction getInteractionState(\n pressableState: PressableStateCallbackType,\n hovered: boolean,\n focused: boolean,\n disabled: boolean,\n): InteractionState {\n return resolveInteractiveState({\n pressed: pressableState.pressed,\n hovered,\n focused,\n disabled,\n });\n}\n\n/*** Renders the low-level token-aware Pressable boundary shared by Surface controls. */\nexport function ButtonBase({\n children,\n disabled = false,\n interactionPolicy = 'enabled',\n onPress,\n onLongPress,\n accessibilityLabel,\n accessibilityRole = 'button',\n accessibilityState,\n style,\n testID,\n ...props\n}: ButtonBaseProps) {\n const { theme } = useTheme();\n const { breakpoint } = useResponsiveRuntime();\n const [hovered, setHovered] = React.useState(false);\n const [focused, setFocused] = React.useState(false);\n const isWeb = Platform.OS === 'web';\n const resolvedViewStyles = resolveViewStyles(theme, breakpoint, props);\n const passive = interactionPolicy === 'passive';\n\n return (\n <Pressable\n accessibilityLabel={accessibilityLabel}\n accessibilityRole={accessibilityRole}\n accessibilityState={{ ...accessibilityState, disabled }}\n disabled={disabled}\n onBlur={() => setFocused(false)}\n onFocus={() => {\n if (isWeb) setFocused(true);\n }}\n onHoverIn={isWeb ? () => setHovered(true) : undefined}\n onHoverOut={isWeb ? () => setHovered(false) : undefined}\n onLongPress={passive ? undefined : onLongPress}\n onPress={passive ? undefined : onPress}\n style={(pressableState) => {\n const state = getInteractionState(pressableState, hovered, focused, disabled);\n return [\n resolvedViewStyles,\n resolveFocusRingStyles(theme.semantics.border.focus, state.focused, isWeb),\n style,\n ];\n }}\n testID={testID}\n >\n {(pressableState) => {\n const state = getInteractionState(pressableState, hovered, focused, disabled);\n return typeof children === 'function' ? children(state) : children;\n }}\n </Pressable>\n );\n}\n"]}
@@ -1,3 +0,0 @@
1
- export { ButtonBase } from './ButtonBase';
2
- export type { ButtonBaseProps } from './types';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/button-base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
@@ -1,2 +0,0 @@
1
- export { ButtonBase } from './ButtonBase';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/primitives/button-base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { ButtonBase } from './ButtonBase';\nexport type { ButtonBaseProps } from './types';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/primitives/button-base/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAEjG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,SAAS,EAAE,UAAU,GAAG,eAAe,CAAC,EAAE,sBAAsB;IAC7E,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC/D,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACnE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/primitives/button-base/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\nimport type { AccessibilityRole, AccessibilityState, GestureResponderEvent } from 'react-native';\n\nimport type { InteractionPolicyProps } from '../../interactionPolicy';\nimport type { InteractionState } from '../../internal/resolvers/resolveInteractiveState';\nimport type { ViewProps } from '../../types/layout';\n\nexport interface ButtonBaseProps\n extends Omit<ViewProps, 'children' | 'pointerEvents'>, InteractionPolicyProps {\n children?: React.ReactNode | ((state: InteractionState) => React.ReactNode);\n disabled?: boolean;\n onPress?: ((event: GestureResponderEvent) => void) | undefined;\n onLongPress?: ((event: GestureResponderEvent) => void) | undefined;\n accessibilityLabel?: string;\n accessibilityRole?: AccessibilityRole;\n accessibilityState?: AccessibilityState;\n testID?: string;\n}\n"]}
@@ -1,2 +0,0 @@
1
- export { ButtonBase } from './ButtonBase';
2
- export type { ButtonBaseProps } from './types';