@ankhorage/surface 6.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 (209) hide show
  1. package/CHANGELOG.md +12 -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/{components/field → features/form/field/adapters/inbound}/Field.d.ts +2 -2
  16. package/dist/features/form/field/adapters/inbound/Field.d.ts.map +1 -0
  17. package/dist/features/form/field/adapters/inbound/Field.js +40 -0
  18. package/dist/features/form/field/adapters/inbound/Field.js.map +1 -0
  19. package/dist/features/form/field/public.d.ts +3 -0
  20. package/dist/features/form/field/public.d.ts.map +1 -0
  21. package/dist/features/form/field/public.js +2 -0
  22. package/dist/features/form/field/public.js.map +1 -0
  23. package/dist/features/form/radio/adapters/inbound/Radio.d.ts.map +1 -1
  24. package/dist/features/form/radio/adapters/inbound/Radio.js +3 -3
  25. package/dist/features/form/radio/adapters/inbound/Radio.js.map +1 -1
  26. package/dist/{components/switch → features/form/switch/adapters/inbound}/Switch.d.ts +1 -1
  27. package/dist/features/form/switch/adapters/inbound/Switch.d.ts.map +1 -0
  28. package/dist/features/form/switch/adapters/inbound/Switch.js +52 -0
  29. package/dist/features/form/switch/adapters/inbound/Switch.js.map +1 -0
  30. package/dist/features/form/switch/public.d.ts +3 -0
  31. package/dist/features/form/switch/public.d.ts.map +1 -0
  32. package/dist/features/form/switch/public.js +2 -0
  33. package/dist/features/form/switch/public.js.map +1 -0
  34. package/dist/features/form/text-input/adapters/inbound/TextInput.d.ts.map +1 -1
  35. package/dist/features/form/text-input/adapters/inbound/TextInput.js +8 -4
  36. package/dist/features/form/text-input/adapters/inbound/TextInput.js.map +1 -1
  37. package/dist/features/list/adapters/inbound/List.d.ts +5 -0
  38. package/dist/features/list/adapters/inbound/List.d.ts.map +1 -0
  39. package/dist/features/list/adapters/inbound/List.js +7 -0
  40. package/dist/features/list/adapters/inbound/List.js.map +1 -0
  41. package/dist/features/list/adapters/inbound/ListItem.d.ts +5 -0
  42. package/dist/features/list/adapters/inbound/ListItem.d.ts.map +1 -0
  43. package/dist/features/list/adapters/inbound/ListItem.js +59 -0
  44. package/dist/features/list/adapters/inbound/ListItem.js.map +1 -0
  45. package/dist/features/list/public.d.ts +4 -0
  46. package/dist/features/list/public.d.ts.map +1 -0
  47. package/dist/features/list/public.js +3 -0
  48. package/dist/features/list/public.js.map +1 -0
  49. package/dist/features/pressable/adapters/inbound/Pressable.d.ts +5 -0
  50. package/dist/features/pressable/adapters/inbound/Pressable.d.ts.map +1 -0
  51. package/dist/features/pressable/adapters/inbound/Pressable.js +48 -0
  52. package/dist/features/pressable/adapters/inbound/Pressable.js.map +1 -0
  53. package/dist/features/pressable/public.d.ts +3 -0
  54. package/dist/features/pressable/public.d.ts.map +1 -0
  55. package/dist/features/pressable/public.js +2 -0
  56. package/dist/features/pressable/public.js.map +1 -0
  57. package/dist/index.d.ts +8 -14
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +4 -7
  60. package/dist/index.js.map +1 -1
  61. package/dist/types/button.d.ts +3 -3
  62. package/dist/types/button.d.ts.map +1 -1
  63. package/dist/types/button.js.map +1 -1
  64. package/dist/types/checkbox.d.ts +2 -2
  65. package/dist/types/checkbox.d.ts.map +1 -1
  66. package/dist/types/checkbox.js.map +1 -1
  67. package/dist/{components/field/types.d.ts → types/field.d.ts} +1 -1
  68. package/dist/types/field.d.ts.map +1 -0
  69. package/dist/types/field.js +2 -0
  70. package/dist/types/field.js.map +1 -0
  71. package/dist/types/list.d.ts +20 -0
  72. package/dist/types/list.d.ts.map +1 -0
  73. package/dist/types/list.js +2 -0
  74. package/dist/types/list.js.map +1 -0
  75. package/dist/{primitives/button-base/types.d.ts → types/pressable.d.ts} +5 -5
  76. package/dist/types/pressable.d.ts.map +1 -0
  77. package/dist/types/pressable.js +2 -0
  78. package/dist/types/pressable.js.map +1 -0
  79. package/dist/types/radio.d.ts +2 -2
  80. package/dist/types/radio.d.ts.map +1 -1
  81. package/dist/types/radio.js.map +1 -1
  82. package/dist/types/switch.d.ts +15 -0
  83. package/dist/types/switch.d.ts.map +1 -0
  84. package/dist/types/switch.js +2 -0
  85. package/dist/types/switch.js.map +1 -0
  86. package/package.json +1 -1
  87. package/src/features/button/adapters/inbound/Button.tsx +6 -6
  88. package/src/features/button/adapters/inbound/IconButton.tsx +3 -3
  89. package/src/features/card/adapters/inbound/Card.tsx +3 -3
  90. package/src/features/form/checkbox/adapters/inbound/Checkbox.tsx +5 -5
  91. package/src/features/form/field/adapters/inbound/Field.tsx +82 -0
  92. package/src/features/form/field/public.ts +2 -0
  93. package/src/features/form/radio/adapters/inbound/Radio.tsx +5 -5
  94. package/src/features/form/switch/adapters/inbound/Switch.tsx +123 -0
  95. package/src/features/form/switch/public.ts +2 -0
  96. package/src/features/form/text-input/adapters/inbound/TextInput.tsx +21 -5
  97. package/src/features/list/adapters/inbound/List.tsx +9 -0
  98. package/src/features/list/adapters/inbound/ListItem.tsx +128 -0
  99. package/src/features/list/public.test.ts +13 -0
  100. package/src/features/list/public.ts +3 -0
  101. package/src/{primitives/button-base/ButtonBase.tsx → features/pressable/adapters/inbound/Pressable.tsx} +45 -31
  102. package/src/features/pressable/public.ts +2 -0
  103. package/src/index.test.ts +17 -11
  104. package/src/index.ts +8 -14
  105. package/src/interactionPolicy.test.ts +4 -4
  106. package/src/types/button.ts +3 -3
  107. package/src/types/checkbox.ts +2 -2
  108. package/src/types/list.ts +22 -0
  109. package/src/{primitives/button-base/types.ts → types/pressable.ts} +4 -4
  110. package/src/types/radio.ts +2 -2
  111. package/src/{components/switch/types.ts → types/switch.ts} +4 -4
  112. package/dist/components/field/Field.d.ts.map +0 -1
  113. package/dist/components/field/Field.js +0 -27
  114. package/dist/components/field/Field.js.map +0 -1
  115. package/dist/components/field/index.d.ts +0 -3
  116. package/dist/components/field/index.d.ts.map +0 -1
  117. package/dist/components/field/index.js +0 -2
  118. package/dist/components/field/index.js.map +0 -1
  119. package/dist/components/field/types.d.ts.map +0 -1
  120. package/dist/components/field/types.js +0 -2
  121. package/dist/components/field/types.js.map +0 -1
  122. package/dist/components/helper-text/HelperText.d.ts +0 -4
  123. package/dist/components/helper-text/HelperText.d.ts.map +0 -1
  124. package/dist/components/helper-text/HelperText.js +0 -8
  125. package/dist/components/helper-text/HelperText.js.map +0 -1
  126. package/dist/components/helper-text/index.d.ts +0 -3
  127. package/dist/components/helper-text/index.d.ts.map +0 -1
  128. package/dist/components/helper-text/index.js +0 -2
  129. package/dist/components/helper-text/index.js.map +0 -1
  130. package/dist/components/helper-text/types.d.ts +0 -9
  131. package/dist/components/helper-text/types.d.ts.map +0 -1
  132. package/dist/components/helper-text/types.js +0 -2
  133. package/dist/components/helper-text/types.js.map +0 -1
  134. package/dist/components/label/Label.d.ts +0 -4
  135. package/dist/components/label/Label.d.ts.map +0 -1
  136. package/dist/components/label/Label.js +0 -11
  137. package/dist/components/label/Label.js.map +0 -1
  138. package/dist/components/label/index.d.ts +0 -3
  139. package/dist/components/label/index.d.ts.map +0 -1
  140. package/dist/components/label/index.js +0 -2
  141. package/dist/components/label/index.js.map +0 -1
  142. package/dist/components/label/types.d.ts +0 -10
  143. package/dist/components/label/types.d.ts.map +0 -1
  144. package/dist/components/label/types.js +0 -2
  145. package/dist/components/label/types.js.map +0 -1
  146. package/dist/components/list-item/ListItem.d.ts +0 -5
  147. package/dist/components/list-item/ListItem.d.ts.map +0 -1
  148. package/dist/components/list-item/ListItem.js +0 -44
  149. package/dist/components/list-item/ListItem.js.map +0 -1
  150. package/dist/components/list-item/index.d.ts +0 -3
  151. package/dist/components/list-item/index.d.ts.map +0 -1
  152. package/dist/components/list-item/index.js +0 -2
  153. package/dist/components/list-item/index.js.map +0 -1
  154. package/dist/components/list-item/types.d.ts +0 -11
  155. package/dist/components/list-item/types.d.ts.map +0 -1
  156. package/dist/components/list-item/types.js +0 -2
  157. package/dist/components/list-item/types.js.map +0 -1
  158. package/dist/components/switch/Switch.d.ts.map +0 -1
  159. package/dist/components/switch/Switch.js +0 -68
  160. package/dist/components/switch/Switch.js.map +0 -1
  161. package/dist/components/switch/index.d.ts +0 -3
  162. package/dist/components/switch/index.d.ts.map +0 -1
  163. package/dist/components/switch/index.js +0 -2
  164. package/dist/components/switch/index.js.map +0 -1
  165. package/dist/components/switch/types.d.ts +0 -15
  166. package/dist/components/switch/types.d.ts.map +0 -1
  167. package/dist/components/switch/types.js +0 -2
  168. package/dist/components/switch/types.js.map +0 -1
  169. package/dist/components/textarea/Textarea.d.ts +0 -4
  170. package/dist/components/textarea/Textarea.d.ts.map +0 -1
  171. package/dist/components/textarea/Textarea.js +0 -6
  172. package/dist/components/textarea/Textarea.js.map +0 -1
  173. package/dist/components/textarea/index.d.ts +0 -3
  174. package/dist/components/textarea/index.d.ts.map +0 -1
  175. package/dist/components/textarea/index.js +0 -2
  176. package/dist/components/textarea/index.js.map +0 -1
  177. package/dist/components/textarea/types.d.ts +0 -5
  178. package/dist/components/textarea/types.d.ts.map +0 -1
  179. package/dist/components/textarea/types.js +0 -2
  180. package/dist/components/textarea/types.js.map +0 -1
  181. package/dist/primitives/button-base/ButtonBase.d.ts +0 -5
  182. package/dist/primitives/button-base/ButtonBase.d.ts.map +0 -1
  183. package/dist/primitives/button-base/ButtonBase.js +0 -42
  184. package/dist/primitives/button-base/ButtonBase.js.map +0 -1
  185. package/dist/primitives/button-base/index.d.ts +0 -3
  186. package/dist/primitives/button-base/index.d.ts.map +0 -1
  187. package/dist/primitives/button-base/index.js +0 -2
  188. package/dist/primitives/button-base/index.js.map +0 -1
  189. package/dist/primitives/button-base/types.d.ts.map +0 -1
  190. package/dist/primitives/button-base/types.js +0 -2
  191. package/dist/primitives/button-base/types.js.map +0 -1
  192. package/src/components/field/Field.tsx +0 -52
  193. package/src/components/field/index.ts +0 -2
  194. package/src/components/helper-text/HelperText.tsx +0 -12
  195. package/src/components/helper-text/index.ts +0 -2
  196. package/src/components/helper-text/types.ts +0 -10
  197. package/src/components/label/Label.tsx +0 -23
  198. package/src/components/label/index.ts +0 -2
  199. package/src/components/label/types.ts +0 -11
  200. package/src/components/list-item/ListItem.tsx +0 -76
  201. package/src/components/list-item/index.ts +0 -2
  202. package/src/components/list-item/types.ts +0 -11
  203. package/src/components/switch/Switch.tsx +0 -113
  204. package/src/components/switch/index.ts +0 -2
  205. package/src/components/textarea/Textarea.tsx +0 -15
  206. package/src/components/textarea/index.ts +0 -2
  207. package/src/components/textarea/types.ts +0 -5
  208. package/src/primitives/button-base/index.ts +0 -2
  209. /package/src/{components/field/types.ts → types/field.ts} +0 -0
@@ -1,9 +1,9 @@
1
1
  import type React from 'react';
2
2
  import type { AccessibilityRole, AccessibilityState, GestureResponderEvent } from 'react-native';
3
- import type { InteractionPolicyProps } from '../../interactionPolicy';
4
- import type { InteractionState } from '../../internal/resolvers/resolveInteractiveState';
5
- import type { ViewProps } from '../../types/layout';
6
- export interface ButtonBaseProps extends Omit<ViewProps, 'children' | 'pointerEvents'>, InteractionPolicyProps {
3
+ import type { InteractionPolicyProps } from '../interactionPolicy';
4
+ import type { InteractionState } from '../internal/resolvers/resolveInteractiveState';
5
+ import type { ViewProps } from './layout';
6
+ export interface PressableProps extends Omit<ViewProps, 'children' | 'pointerEvents'>, InteractionPolicyProps {
7
7
  children?: React.ReactNode | ((state: InteractionState) => React.ReactNode);
8
8
  disabled?: boolean;
9
9
  onPress?: ((event: GestureResponderEvent) => void) | undefined;
@@ -13,4 +13,4 @@ export interface ButtonBaseProps extends Omit<ViewProps, 'children' | 'pointerEv
13
13
  accessibilityState?: AccessibilityState;
14
14
  testID?: string;
15
15
  }
16
- //# sourceMappingURL=types.d.ts.map
16
+ //# sourceMappingURL=pressable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pressable.d.ts","sourceRoot":"","sources":["../../src/types/pressable.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,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,WAAW,cACf,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"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pressable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pressable.js","sourceRoot":"","sources":["../../src/types/pressable.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 './layout';\n\nexport interface PressableProps\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,8 +1,8 @@
1
1
  import type React from 'react';
2
2
  import type { ControlSize } from '../internal/resolvers/resolveControlSize';
3
- import type { ButtonBaseProps } from '../primitives/button-base';
4
3
  import type { SurfaceColor } from '../surfaceColor';
5
- export interface RadioProps extends Omit<ButtonBaseProps, 'accessibilityRole' | 'accessibilityState' | 'children' | 'onPress' | 'style'> {
4
+ import type { PressableProps } from './pressable';
5
+ export interface RadioProps extends Omit<PressableProps, 'accessibilityRole' | 'accessibilityState' | 'children' | 'onPress' | 'style'> {
6
6
  children?: React.ReactNode;
7
7
  checked?: boolean;
8
8
  defaultChecked?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../src/types/radio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,WAAW,UAAW,SAAQ,IAAI,CACtC,eAAe,EACf,mBAAmB,GAAG,oBAAoB,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,CAC9E;IACC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC3D,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
1
+ {"version":3,"file":"radio.d.ts","sourceRoot":"","sources":["../../src/types/radio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,WAAW,UAAW,SAAQ,IAAI,CACtC,cAAc,EACd,mBAAmB,GAAG,oBAAoB,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,CAC9E;IACC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC3D,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"radio.js","sourceRoot":"","sources":["../../src/types/radio.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nimport type { ControlSize } from '../internal/resolvers/resolveControlSize';\nimport type { ButtonBaseProps } from '../primitives/button-base';\nimport type { SurfaceColor } from '../surfaceColor';\n\nexport interface RadioProps extends Omit<\n ButtonBaseProps,\n 'accessibilityRole' | 'accessibilityState' | 'children' | 'onPress' | 'style'\n> {\n children?: React.ReactNode;\n checked?: boolean;\n defaultChecked?: boolean;\n onCheckedChange?: ((checked: boolean) => void) | undefined;\n color?: SurfaceColor;\n size?: ControlSize;\n invalid?: boolean;\n readOnly?: boolean;\n}\n"]}
1
+ {"version":3,"file":"radio.js","sourceRoot":"","sources":["../../src/types/radio.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nimport type { ControlSize } from '../internal/resolvers/resolveControlSize';\nimport type { SurfaceColor } from '../surfaceColor';\nimport type { PressableProps } from './pressable';\n\nexport interface RadioProps extends Omit<\n PressableProps,\n 'accessibilityRole' | 'accessibilityState' | 'children' | 'onPress' | 'style'\n> {\n children?: React.ReactNode;\n checked?: boolean;\n defaultChecked?: boolean;\n onCheckedChange?: ((checked: boolean) => void) | undefined;\n color?: SurfaceColor;\n size?: ControlSize;\n invalid?: boolean;\n readOnly?: boolean;\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import type React from 'react';
2
+ import type { ControlSize } from '../internal/resolvers/resolveControlSize';
3
+ import type { SurfaceColor } from '../surfaceColor';
4
+ import type { PressableProps } from './pressable';
5
+ export interface SwitchProps extends Omit<PressableProps, 'accessibilityRole' | 'accessibilityState' | 'children' | 'onPress' | 'style'> {
6
+ children?: React.ReactNode;
7
+ checked?: boolean;
8
+ defaultChecked?: boolean;
9
+ onCheckedChange?: ((checked: boolean) => void) | undefined;
10
+ color?: SurfaceColor;
11
+ size?: ControlSize;
12
+ invalid?: boolean;
13
+ readOnly?: boolean;
14
+ }
15
+ //# sourceMappingURL=switch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../src/types/switch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,cAAc,EACd,mBAAmB,GAAG,oBAAoB,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,CAC9E;IACC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC3D,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.js","sourceRoot":"","sources":["../../src/types/switch.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nimport type { ControlSize } from '../internal/resolvers/resolveControlSize';\nimport type { SurfaceColor } from '../surfaceColor';\nimport type { PressableProps } from './pressable';\n\nexport interface SwitchProps extends Omit<\n PressableProps,\n 'accessibilityRole' | 'accessibilityState' | 'children' | 'onPress' | 'style'\n> {\n children?: React.ReactNode;\n checked?: boolean;\n defaultChecked?: boolean;\n onCheckedChange?: ((checked: boolean) => void) | undefined;\n color?: SurfaceColor;\n size?: ControlSize;\n invalid?: boolean;\n readOnly?: boolean;\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ankhorage/surface",
3
3
  "type": "module",
4
- "version": "6.0.0",
4
+ "version": "8.0.0",
5
5
  "description": "Stable UI foundation for React Native and React Native Web.",
6
6
  "homepage": "https://github.com/ankhorage/surface#readme",
7
7
  "bugs": {
@@ -7,12 +7,12 @@ import {
7
7
  resolveControlSize,
8
8
  resolveIconSize,
9
9
  } from '../../../../internal/resolvers';
10
- import { ButtonBase } from '../../../../primitives/button-base';
11
10
  import { useTheme } from '../../../../theme/ThemeContext';
12
11
  import type { SurfaceTheme } from '../../../../theme/types';
13
12
  import type { ButtonProps } from '../../../../types/button';
14
13
  import { Icon } from '../../../icon/public';
15
14
  import { View } from '../../../layout/public';
15
+ import { Pressable } from '../../../pressable/public';
16
16
  import { Text } from '../../../typography/public';
17
17
 
18
18
  /*** Renders the primary Surface action control with semantic visual states. */
@@ -34,11 +34,11 @@ export function Button({
34
34
  const controlSize = resolveControlSize(theme, size);
35
35
 
36
36
  return (
37
- <ButtonBase
37
+ <Pressable
38
38
  {...props}
39
39
  disabled={disabled || loading}
40
40
  onPress={onPress}
41
- style={resolveButtonBaseStyle(fullWidth)}
41
+ style={resolvePressableStyle(fullWidth)}
42
42
  testID={testID}
43
43
  >
44
44
  {(state) => (
@@ -57,7 +57,7 @@ export function Button({
57
57
  {children}
58
58
  </ButtonContent>
59
59
  )}
60
- </ButtonBase>
60
+ </Pressable>
61
61
  );
62
62
  }
63
63
 
@@ -114,8 +114,8 @@ function ButtonContent({
114
114
  );
115
115
  }
116
116
 
117
- /*** Resolves the outer ButtonBase layout style. */
118
- function resolveButtonBaseStyle(fullWidth: boolean): ViewStyle {
117
+ /*** Resolves the outer Pressable layout style. */
118
+ function resolvePressableStyle(fullWidth: boolean): ViewStyle {
119
119
  return { alignSelf: fullWidth ? 'stretch' : 'flex-start' };
120
120
  }
121
121
 
@@ -6,11 +6,11 @@ import {
6
6
  resolveControlSize,
7
7
  resolveIconSize,
8
8
  } from '../../../../internal/resolvers';
9
- import { ButtonBase } from '../../../../primitives/button-base';
10
9
  import { useTheme } from '../../../../theme/ThemeContext';
11
10
  import type { IconButtonProps } from '../../../../types/button';
12
11
  import { Icon } from '../../../icon/public';
13
12
  import { View } from '../../../layout/public';
13
+ import { Pressable } from '../../../pressable/public';
14
14
 
15
15
  /*** Renders a compact accessible icon-only action control. */
16
16
  export function IconButton({
@@ -28,7 +28,7 @@ export function IconButton({
28
28
  const controlSize = resolveControlSize(theme, size);
29
29
 
30
30
  return (
31
- <ButtonBase
31
+ <Pressable
32
32
  {...props}
33
33
  accessibilityLabel={accessibilityLabel}
34
34
  disabled={disabled}
@@ -46,7 +46,7 @@ export function IconButton({
46
46
  </View>
47
47
  );
48
48
  }}
49
- </ButtonBase>
49
+ </Pressable>
50
50
  );
51
51
  }
52
52
 
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import type { ViewStyle } from 'react-native';
3
3
 
4
- import { ButtonBase } from '../../../../primitives/button-base';
5
4
  import { useTheme } from '../../../../theme/ThemeContext';
6
5
  import type { CardProps } from '../../../../types/card';
7
6
  import type { SurfaceVariant } from '../../../../types/surface';
7
+ import { Pressable } from '../../../pressable/public';
8
8
  import { Surface } from '../../../surface/public';
9
9
 
10
10
  /*** Renders a themed content card with optional interactive press states. */
@@ -28,7 +28,7 @@ export function Card({
28
28
  }
29
29
 
30
30
  return (
31
- <ButtonBase accessibilityRole="button" disabled={disabled} onPress={onPress} testID={testID}>
31
+ <Pressable accessibilityRole="button" disabled={disabled} onPress={onPress} testID={testID}>
32
32
  {(state) => (
33
33
  <Surface
34
34
  {...props}
@@ -46,7 +46,7 @@ export function Card({
46
46
  {children}
47
47
  </Surface>
48
48
  )}
49
- </ButtonBase>
49
+ </Pressable>
50
50
  );
51
51
  }
52
52
 
@@ -9,12 +9,12 @@ import {
9
9
  resolveSelectionControlNextChecked,
10
10
  } from '../../../../../internal/resolvers';
11
11
  import { useControllableState } from '../../../../../internal/useControllableState';
12
- import { ButtonBase } from '../../../../../primitives/button-base';
13
- import type { ButtonBaseProps } from '../../../../../primitives/button-base/types';
14
12
  import { useTheme } from '../../../../../theme/ThemeContext';
15
13
  import type { SurfaceTheme } from '../../../../../theme/types';
16
14
  import type { CheckboxProps } from '../../../../../types/checkbox';
17
15
  import { View } from '../../../../layout/public';
16
+ import type { PressableProps } from '../../../../pressable/public';
17
+ import { Pressable } from '../../../../pressable/public';
18
18
  import { Text } from '../../../../typography/public';
19
19
 
20
20
  /*** Renders a controlled or uncontrolled accessible checkbox. */
@@ -81,7 +81,7 @@ function CheckboxControl({
81
81
  });
82
82
 
83
83
  return (
84
- <ButtonBase
84
+ <Pressable
85
85
  {...buttonProps}
86
86
  accessibilityLabel={accessibilityLabel}
87
87
  accessibilityRole="checkbox"
@@ -103,7 +103,7 @@ function CheckboxControl({
103
103
  theme,
104
104
  })
105
105
  }
106
- </ButtonBase>
106
+ </Pressable>
107
107
  );
108
108
  }
109
109
 
@@ -181,7 +181,7 @@ function resolveCheckboxIndicatorStyle(
181
181
 
182
182
  interface CheckboxControlProps {
183
183
  accessibilityLabel: CheckboxProps['accessibilityLabel'];
184
- buttonProps: ButtonBaseProps;
184
+ buttonProps: PressableProps;
185
185
  children: CheckboxProps['children'];
186
186
  color: NonNullable<CheckboxProps['color']>;
187
187
  disabled: boolean;
@@ -0,0 +1,82 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ type ResolvedFieldPresentation,
5
+ resolveFieldPresentation,
6
+ resolveFieldState,
7
+ } from '../../../../../internal/resolvers';
8
+ import type { FieldProps } from '../../../../../types/field';
9
+ import { View } from '../../../../layout/public';
10
+ import { Text } from '../../../../typography/public';
11
+
12
+ /*** Composes a control with its label and helper or error message. */
13
+ export function Field({
14
+ children,
15
+ label,
16
+ helperText,
17
+ errorText,
18
+ required = false,
19
+ disabled = false,
20
+ invalid = false,
21
+ readOnly = false,
22
+ testID,
23
+ }: FieldProps) {
24
+ const hasErrorText = Boolean(errorText);
25
+ const presentation = resolveFieldPresentation(
26
+ resolveFieldState({ disabled, invalid: invalid || hasErrorText, readOnly }),
27
+ );
28
+ const message = hasErrorText ? errorText : helperText;
29
+
30
+ return (
31
+ <View gap="xs" testID={testID}>
32
+ {renderFieldLabel(label, required, presentation)}
33
+ <View>{children}</View>
34
+ {renderFieldMessage(message, presentation)}
35
+ </View>
36
+ );
37
+ }
38
+
39
+ /*** Renders an optional field label and required indicator. */
40
+ function renderFieldLabel(
41
+ label: React.ReactNode,
42
+ required: boolean,
43
+ presentation: ResolvedFieldPresentation,
44
+ ) {
45
+ if (label === undefined || label === null) return null;
46
+ const labelContent =
47
+ typeof label === 'string' || typeof label === 'number' ? (
48
+ <Text
49
+ color={presentation.labelColor}
50
+ emphasis={presentation.labelEmphasis}
51
+ variant="label"
52
+ weight="medium"
53
+ >
54
+ {label}
55
+ </Text>
56
+ ) : (
57
+ label
58
+ );
59
+
60
+ return (
61
+ <View align="center" direction="row" gap="xs">
62
+ <View flex={1}>{labelContent}</View>
63
+ {required ? (
64
+ <Text color="error" variant="label" weight="medium">
65
+ *
66
+ </Text>
67
+ ) : null}
68
+ </View>
69
+ );
70
+ }
71
+
72
+ /*** Renders an optional helper or error message using field presentation semantics. */
73
+ function renderFieldMessage(message: React.ReactNode, presentation: ResolvedFieldPresentation) {
74
+ if (message === undefined || message === null || message === '') return null;
75
+ if (typeof message !== 'string' && typeof message !== 'number') return message;
76
+
77
+ return (
78
+ <Text color={presentation.helperColor} emphasis={presentation.helperEmphasis} variant="caption">
79
+ {message}
80
+ </Text>
81
+ );
82
+ }
@@ -0,0 +1,2 @@
1
+ export type { FieldProps } from '../../../types/field';
2
+ export { Field } from './adapters/inbound/Field';
@@ -9,12 +9,12 @@ import {
9
9
  resolveSelectionControlNextChecked,
10
10
  } from '../../../../../internal/resolvers';
11
11
  import { useControllableState } from '../../../../../internal/useControllableState';
12
- import { ButtonBase } from '../../../../../primitives/button-base';
13
- import type { ButtonBaseProps } from '../../../../../primitives/button-base/types';
14
12
  import { useTheme } from '../../../../../theme/ThemeContext';
15
13
  import type { SurfaceTheme } from '../../../../../theme/types';
16
14
  import type { RadioProps } from '../../../../../types/radio';
17
15
  import { View } from '../../../../layout/public';
16
+ import type { PressableProps } from '../../../../pressable/public';
17
+ import { Pressable } from '../../../../pressable/public';
18
18
  import { Text } from '../../../../typography/public';
19
19
  import { isRadioTextContent } from '../../utils/isRadioTextContent';
20
20
 
@@ -82,7 +82,7 @@ function RadioControl({
82
82
  });
83
83
 
84
84
  return (
85
- <ButtonBase
85
+ <Pressable
86
86
  {...buttonProps}
87
87
  accessibilityLabel={accessibilityLabel}
88
88
  accessibilityRole="radio"
@@ -104,7 +104,7 @@ function RadioControl({
104
104
  theme,
105
105
  })
106
106
  }
107
- </ButtonBase>
107
+ </Pressable>
108
108
  );
109
109
  }
110
110
 
@@ -188,7 +188,7 @@ function resolveRadioDotStyle(backgroundColor: string, size: number): ViewStyle
188
188
 
189
189
  interface RadioControlProps {
190
190
  accessibilityLabel: RadioProps['accessibilityLabel'];
191
- buttonProps: ButtonBaseProps;
191
+ buttonProps: PressableProps;
192
192
  children: RadioProps['children'];
193
193
  color: NonNullable<RadioProps['color']>;
194
194
  disabled: boolean;
@@ -0,0 +1,123 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ type InteractionState,
5
+ resolveFieldState,
6
+ resolveIndicatorSize,
7
+ resolveSelectionControlColors,
8
+ resolveSelectionControlNextChecked,
9
+ } from '../../../../../internal/resolvers';
10
+ import { useControllableState } from '../../../../../internal/useControllableState';
11
+ import { useTheme } from '../../../../../theme/ThemeContext';
12
+ import type { SwitchProps } from '../../../../../types/switch';
13
+ import { View } from '../../../../layout/public';
14
+ import { Pressable } from '../../../../pressable/public';
15
+ import { Text } from '../../../../typography/public';
16
+
17
+ /*** Renders a controlled or uncontrolled accessible switch. */
18
+ export function Switch({
19
+ children,
20
+ checked,
21
+ defaultChecked = false,
22
+ onCheckedChange,
23
+ color = 'primary',
24
+ size = 'm',
25
+ disabled = false,
26
+ invalid = false,
27
+ readOnly = false,
28
+ accessibilityLabel,
29
+ testID,
30
+ ...props
31
+ }: SwitchProps) {
32
+ const { theme } = useTheme();
33
+ const [isChecked, setChecked] = useControllableState<boolean>({
34
+ value: checked,
35
+ defaultValue: defaultChecked,
36
+ onChange: onCheckedChange,
37
+ });
38
+ const nextChecked = resolveSelectionControlNextChecked({
39
+ checked: isChecked,
40
+ disabled,
41
+ kind: 'switch',
42
+ readOnly,
43
+ });
44
+
45
+ return (
46
+ <Pressable
47
+ {...props}
48
+ accessibilityLabel={accessibilityLabel}
49
+ accessibilityRole="switch"
50
+ accessibilityState={{ checked: isChecked }}
51
+ disabled={disabled}
52
+ onPress={nextChecked === null ? undefined : () => setChecked(nextChecked)}
53
+ testID={testID}
54
+ >
55
+ {(interactionState) =>
56
+ renderSwitchContent(
57
+ { children, color, disabled, invalid, isChecked, readOnly, size, theme },
58
+ interactionState,
59
+ )
60
+ }
61
+ </Pressable>
62
+ );
63
+ }
64
+
65
+ interface SwitchContentInput {
66
+ children: React.ReactNode;
67
+ color: NonNullable<SwitchProps['color']>;
68
+ disabled: boolean;
69
+ invalid: boolean;
70
+ isChecked: boolean;
71
+ readOnly: boolean;
72
+ size: NonNullable<SwitchProps['size']>;
73
+ theme: ReturnType<typeof useTheme>['theme'];
74
+ }
75
+
76
+ /*** Resolves switch presentation for one interaction state and renders the visual control. */
77
+ function renderSwitchContent(input: SwitchContentInput, interactionState: InteractionState) {
78
+ const fieldState = resolveFieldState({
79
+ disabled: input.disabled,
80
+ focused: interactionState.focused,
81
+ invalid: input.invalid,
82
+ readOnly: input.readOnly,
83
+ });
84
+ const colors = resolveSelectionControlColors(input.theme, {
85
+ checked: input.isChecked,
86
+ fieldState,
87
+ hovered: interactionState.hovered,
88
+ pressed: interactionState.pressed,
89
+ color: input.color,
90
+ });
91
+ const indicatorSize = resolveIndicatorSize(input.size);
92
+ const labelEmphasis =
93
+ colors.labelColor === input.theme.semantics.content.muted ? 'muted' : 'default';
94
+
95
+ return (
96
+ <View align="center" direction="row" opacity={colors.opacity}>
97
+ <View
98
+ bg={colors.trackColor}
99
+ borderColor={colors.borderColor}
100
+ borderWidth={1}
101
+ height={indicatorSize.switchHeight}
102
+ justify="center"
103
+ minWidth={indicatorSize.switchWidth}
104
+ px={2}
105
+ radius="full"
106
+ width={indicatorSize.switchWidth}
107
+ >
108
+ <View
109
+ alignSelf={input.isChecked ? 'flex-end' : 'flex-start'}
110
+ bg={colors.thumbColor}
111
+ height={indicatorSize.switchThumb}
112
+ radius="full"
113
+ width={indicatorSize.switchThumb}
114
+ />
115
+ </View>
116
+ {input.children ? (
117
+ <View ml="s">
118
+ <Text emphasis={labelEmphasis}>{input.children}</Text>
119
+ </View>
120
+ ) : null}
121
+ </View>
122
+ );
123
+ }
@@ -0,0 +1,2 @@
1
+ export type { SwitchProps } from '../../../types/switch';
2
+ export { Switch } from './adapters/inbound/Switch';
@@ -1,5 +1,12 @@
1
1
  import React from 'react';
2
- import { Platform, TextInput as ReactNativeTextInput, View, type ViewStyle } from 'react-native';
2
+ import {
3
+ Platform,
4
+ type StyleProp,
5
+ TextInput as ReactNativeTextInput,
6
+ type TextStyle,
7
+ View,
8
+ type ViewStyle,
9
+ } from 'react-native';
3
10
 
4
11
  import { resolveFocusRingStyles } from '../../../../../internal/resolvers';
5
12
  import { useTheme } from '../../../../../theme/ThemeContext';
@@ -39,9 +46,7 @@ export function TextInput(props: TextInputProps) {
39
46
  nativeProps.onBlur?.(event);
40
47
  }}
41
48
  onChangeText={(nextValue) => {
42
- if (interactionPolicy !== 'passive') {
43
- nativeProps.onChangeText?.(nextValue);
44
- }
49
+ if (interactionPolicy !== 'passive') nativeProps.onChangeText?.(nextValue);
45
50
  }}
46
51
  onFocus={(event) => {
47
52
  setFocused(true);
@@ -49,13 +54,24 @@ export function TextInput(props: TextInputProps) {
49
54
  }}
50
55
  placeholderTextColor={presentation.placeholderColor}
51
56
  readOnly={readOnly}
52
- style={[presentation.inputStyle, nativeProps.style]}
57
+ style={resolveInputStyle(presentation.inputStyle, nativeProps.multiline, nativeProps.style)}
53
58
  />
54
59
  {renderAccessory(trailingAccessory, presentation.accessorySpacing, 'trailing')}
55
60
  </View>
56
61
  );
57
62
  }
58
63
 
64
+ const multilineInputStyle: TextStyle = { textAlignVertical: 'top' };
65
+
66
+ /*** Resolves TextInput style composition including canonical multiline alignment. */
67
+ function resolveInputStyle(
68
+ presentationStyle: StyleProp<TextStyle>,
69
+ multiline: boolean | undefined,
70
+ style: StyleProp<TextStyle>,
71
+ ): StyleProp<TextStyle> {
72
+ return [presentationStyle, multiline ? multilineInputStyle : undefined, style];
73
+ }
74
+
59
75
  /*** Renders one optional TextInput accessory with directional spacing. */
60
76
  function renderAccessory(
61
77
  accessory: React.ReactNode,
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+
3
+ import type { ListProps } from '../../../../types/list';
4
+ import { View } from '../../../layout/public';
5
+
6
+ /*** Groups list items under one neutral Surface list boundary. */
7
+ export function List({ children, testID }: ListProps) {
8
+ return <View testID={testID}>{children}</View>;
9
+ }