@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.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/features/button/adapters/inbound/Button.d.ts.map +1 -1
- package/dist/features/button/adapters/inbound/Button.js +5 -5
- package/dist/features/button/adapters/inbound/Button.js.map +1 -1
- package/dist/features/button/adapters/inbound/IconButton.d.ts.map +1 -1
- package/dist/features/button/adapters/inbound/IconButton.js +3 -3
- package/dist/features/button/adapters/inbound/IconButton.js.map +1 -1
- package/dist/features/card/adapters/inbound/Card.d.ts.map +1 -1
- package/dist/features/card/adapters/inbound/Card.js +3 -3
- package/dist/features/card/adapters/inbound/Card.js.map +1 -1
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.d.ts.map +1 -1
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.js +3 -3
- package/dist/features/form/checkbox/adapters/inbound/Checkbox.js.map +1 -1
- package/dist/{components/field → features/form/field/adapters/inbound}/Field.d.ts +2 -2
- package/dist/features/form/field/adapters/inbound/Field.d.ts.map +1 -0
- package/dist/features/form/field/adapters/inbound/Field.js +40 -0
- package/dist/features/form/field/adapters/inbound/Field.js.map +1 -0
- package/dist/features/form/field/public.d.ts +3 -0
- package/dist/features/form/field/public.d.ts.map +1 -0
- package/dist/features/form/field/public.js +2 -0
- package/dist/features/form/field/public.js.map +1 -0
- package/dist/features/form/radio/adapters/inbound/Radio.d.ts.map +1 -1
- package/dist/features/form/radio/adapters/inbound/Radio.js +3 -3
- package/dist/features/form/radio/adapters/inbound/Radio.js.map +1 -1
- package/dist/{components/switch → features/form/switch/adapters/inbound}/Switch.d.ts +1 -1
- package/dist/features/form/switch/adapters/inbound/Switch.d.ts.map +1 -0
- package/dist/features/form/switch/adapters/inbound/Switch.js +52 -0
- package/dist/features/form/switch/adapters/inbound/Switch.js.map +1 -0
- package/dist/features/form/switch/public.d.ts +3 -0
- package/dist/features/form/switch/public.d.ts.map +1 -0
- package/dist/features/form/switch/public.js +2 -0
- package/dist/features/form/switch/public.js.map +1 -0
- package/dist/features/form/text-input/adapters/inbound/TextInput.d.ts.map +1 -1
- package/dist/features/form/text-input/adapters/inbound/TextInput.js +8 -4
- package/dist/features/form/text-input/adapters/inbound/TextInput.js.map +1 -1
- package/dist/features/list/adapters/inbound/List.d.ts +5 -0
- package/dist/features/list/adapters/inbound/List.d.ts.map +1 -0
- package/dist/features/list/adapters/inbound/List.js +7 -0
- package/dist/features/list/adapters/inbound/List.js.map +1 -0
- package/dist/features/list/adapters/inbound/ListItem.d.ts +5 -0
- package/dist/features/list/adapters/inbound/ListItem.d.ts.map +1 -0
- package/dist/features/list/adapters/inbound/ListItem.js +59 -0
- package/dist/features/list/adapters/inbound/ListItem.js.map +1 -0
- package/dist/features/list/public.d.ts +4 -0
- package/dist/features/list/public.d.ts.map +1 -0
- package/dist/features/list/public.js +3 -0
- package/dist/features/list/public.js.map +1 -0
- package/dist/features/pressable/adapters/inbound/Pressable.d.ts +5 -0
- package/dist/features/pressable/adapters/inbound/Pressable.d.ts.map +1 -0
- package/dist/features/pressable/adapters/inbound/Pressable.js +48 -0
- package/dist/features/pressable/adapters/inbound/Pressable.js.map +1 -0
- package/dist/features/pressable/public.d.ts +3 -0
- package/dist/features/pressable/public.d.ts.map +1 -0
- package/dist/features/pressable/public.js +2 -0
- package/dist/features/pressable/public.js.map +1 -0
- package/dist/index.d.ts +8 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -7
- package/dist/index.js.map +1 -1
- package/dist/types/button.d.ts +3 -3
- package/dist/types/button.d.ts.map +1 -1
- package/dist/types/button.js.map +1 -1
- package/dist/types/checkbox.d.ts +2 -2
- package/dist/types/checkbox.d.ts.map +1 -1
- package/dist/types/checkbox.js.map +1 -1
- package/dist/{components/field/types.d.ts → types/field.d.ts} +1 -1
- package/dist/types/field.d.ts.map +1 -0
- package/dist/types/field.js +2 -0
- package/dist/types/field.js.map +1 -0
- package/dist/types/list.d.ts +20 -0
- package/dist/types/list.d.ts.map +1 -0
- package/dist/types/list.js +2 -0
- package/dist/types/list.js.map +1 -0
- package/dist/{primitives/button-base/types.d.ts → types/pressable.d.ts} +5 -5
- package/dist/types/pressable.d.ts.map +1 -0
- package/dist/types/pressable.js +2 -0
- package/dist/types/pressable.js.map +1 -0
- package/dist/types/radio.d.ts +2 -2
- package/dist/types/radio.d.ts.map +1 -1
- package/dist/types/radio.js.map +1 -1
- package/dist/types/switch.d.ts +15 -0
- package/dist/types/switch.d.ts.map +1 -0
- package/dist/types/switch.js +2 -0
- package/dist/types/switch.js.map +1 -0
- package/package.json +1 -1
- package/src/features/button/adapters/inbound/Button.tsx +6 -6
- package/src/features/button/adapters/inbound/IconButton.tsx +3 -3
- package/src/features/card/adapters/inbound/Card.tsx +3 -3
- package/src/features/form/checkbox/adapters/inbound/Checkbox.tsx +5 -5
- package/src/features/form/field/adapters/inbound/Field.tsx +82 -0
- package/src/features/form/field/public.ts +2 -0
- package/src/features/form/radio/adapters/inbound/Radio.tsx +5 -5
- package/src/features/form/switch/adapters/inbound/Switch.tsx +123 -0
- package/src/features/form/switch/public.ts +2 -0
- package/src/features/form/text-input/adapters/inbound/TextInput.tsx +21 -5
- package/src/features/list/adapters/inbound/List.tsx +9 -0
- package/src/features/list/adapters/inbound/ListItem.tsx +128 -0
- package/src/features/list/public.test.ts +13 -0
- package/src/features/list/public.ts +3 -0
- package/src/{primitives/button-base/ButtonBase.tsx → features/pressable/adapters/inbound/Pressable.tsx} +45 -31
- package/src/features/pressable/public.ts +2 -0
- package/src/index.test.ts +17 -11
- package/src/index.ts +8 -14
- package/src/interactionPolicy.test.ts +4 -4
- package/src/types/button.ts +3 -3
- package/src/types/checkbox.ts +2 -2
- package/src/types/list.ts +22 -0
- package/src/{primitives/button-base/types.ts → types/pressable.ts} +4 -4
- package/src/types/radio.ts +2 -2
- package/src/{components/switch/types.ts → types/switch.ts} +4 -4
- package/dist/components/field/Field.d.ts.map +0 -1
- package/dist/components/field/Field.js +0 -27
- package/dist/components/field/Field.js.map +0 -1
- package/dist/components/field/index.d.ts +0 -3
- package/dist/components/field/index.d.ts.map +0 -1
- package/dist/components/field/index.js +0 -2
- package/dist/components/field/index.js.map +0 -1
- package/dist/components/field/types.d.ts.map +0 -1
- package/dist/components/field/types.js +0 -2
- package/dist/components/field/types.js.map +0 -1
- package/dist/components/helper-text/HelperText.d.ts +0 -4
- package/dist/components/helper-text/HelperText.d.ts.map +0 -1
- package/dist/components/helper-text/HelperText.js +0 -8
- package/dist/components/helper-text/HelperText.js.map +0 -1
- package/dist/components/helper-text/index.d.ts +0 -3
- package/dist/components/helper-text/index.d.ts.map +0 -1
- package/dist/components/helper-text/index.js +0 -2
- package/dist/components/helper-text/index.js.map +0 -1
- package/dist/components/helper-text/types.d.ts +0 -9
- package/dist/components/helper-text/types.d.ts.map +0 -1
- package/dist/components/helper-text/types.js +0 -2
- package/dist/components/helper-text/types.js.map +0 -1
- package/dist/components/label/Label.d.ts +0 -4
- package/dist/components/label/Label.d.ts.map +0 -1
- package/dist/components/label/Label.js +0 -11
- package/dist/components/label/Label.js.map +0 -1
- package/dist/components/label/index.d.ts +0 -3
- package/dist/components/label/index.d.ts.map +0 -1
- package/dist/components/label/index.js +0 -2
- package/dist/components/label/index.js.map +0 -1
- package/dist/components/label/types.d.ts +0 -10
- package/dist/components/label/types.d.ts.map +0 -1
- package/dist/components/label/types.js +0 -2
- package/dist/components/label/types.js.map +0 -1
- package/dist/components/list-item/ListItem.d.ts +0 -5
- package/dist/components/list-item/ListItem.d.ts.map +0 -1
- package/dist/components/list-item/ListItem.js +0 -44
- package/dist/components/list-item/ListItem.js.map +0 -1
- package/dist/components/list-item/index.d.ts +0 -3
- package/dist/components/list-item/index.d.ts.map +0 -1
- package/dist/components/list-item/index.js +0 -2
- package/dist/components/list-item/index.js.map +0 -1
- package/dist/components/list-item/types.d.ts +0 -11
- package/dist/components/list-item/types.d.ts.map +0 -1
- package/dist/components/list-item/types.js +0 -2
- package/dist/components/list-item/types.js.map +0 -1
- package/dist/components/switch/Switch.d.ts.map +0 -1
- package/dist/components/switch/Switch.js +0 -68
- package/dist/components/switch/Switch.js.map +0 -1
- package/dist/components/switch/index.d.ts +0 -3
- package/dist/components/switch/index.d.ts.map +0 -1
- package/dist/components/switch/index.js +0 -2
- package/dist/components/switch/index.js.map +0 -1
- package/dist/components/switch/types.d.ts +0 -15
- package/dist/components/switch/types.d.ts.map +0 -1
- package/dist/components/switch/types.js +0 -2
- package/dist/components/switch/types.js.map +0 -1
- package/dist/components/textarea/Textarea.d.ts +0 -4
- package/dist/components/textarea/Textarea.d.ts.map +0 -1
- package/dist/components/textarea/Textarea.js +0 -6
- package/dist/components/textarea/Textarea.js.map +0 -1
- package/dist/components/textarea/index.d.ts +0 -3
- package/dist/components/textarea/index.d.ts.map +0 -1
- package/dist/components/textarea/index.js +0 -2
- package/dist/components/textarea/index.js.map +0 -1
- package/dist/components/textarea/types.d.ts +0 -5
- package/dist/components/textarea/types.d.ts.map +0 -1
- package/dist/components/textarea/types.js +0 -2
- package/dist/components/textarea/types.js.map +0 -1
- package/dist/primitives/button-base/ButtonBase.d.ts +0 -5
- package/dist/primitives/button-base/ButtonBase.d.ts.map +0 -1
- package/dist/primitives/button-base/ButtonBase.js +0 -42
- package/dist/primitives/button-base/ButtonBase.js.map +0 -1
- package/dist/primitives/button-base/index.d.ts +0 -3
- package/dist/primitives/button-base/index.d.ts.map +0 -1
- package/dist/primitives/button-base/index.js +0 -2
- package/dist/primitives/button-base/index.js.map +0 -1
- package/dist/primitives/button-base/types.d.ts.map +0 -1
- package/dist/primitives/button-base/types.js +0 -2
- package/dist/primitives/button-base/types.js.map +0 -1
- package/src/components/field/Field.tsx +0 -52
- package/src/components/field/index.ts +0 -2
- package/src/components/helper-text/HelperText.tsx +0 -12
- package/src/components/helper-text/index.ts +0 -2
- package/src/components/helper-text/types.ts +0 -10
- package/src/components/label/Label.tsx +0 -23
- package/src/components/label/index.ts +0 -2
- package/src/components/label/types.ts +0 -11
- package/src/components/list-item/ListItem.tsx +0 -76
- package/src/components/list-item/index.ts +0 -2
- package/src/components/list-item/types.ts +0 -11
- package/src/components/switch/Switch.tsx +0 -113
- package/src/components/switch/index.ts +0 -2
- package/src/components/textarea/Textarea.tsx +0 -15
- package/src/components/textarea/index.ts +0 -2
- package/src/components/textarea/types.ts +0 -5
- package/src/primitives/button-base/index.ts +0 -2
- /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 '
|
|
4
|
-
import type { InteractionState } from '
|
|
5
|
-
import type { ViewProps } from '
|
|
6
|
-
export interface
|
|
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=
|
|
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 @@
|
|
|
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"]}
|
package/dist/types/radio.d.ts
CHANGED
|
@@ -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
|
-
|
|
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,
|
|
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"}
|
package/dist/types/radio.js.map
CHANGED
|
@@ -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 {
|
|
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 @@
|
|
|
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
|
@@ -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
|
-
<
|
|
37
|
+
<Pressable
|
|
38
38
|
{...props}
|
|
39
39
|
disabled={disabled || loading}
|
|
40
40
|
onPress={onPress}
|
|
41
|
-
style={
|
|
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
|
-
</
|
|
60
|
+
</Pressable>
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -114,8 +114,8 @@ function ButtonContent({
|
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
/*** Resolves the outer
|
|
118
|
-
function
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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
|
-
<
|
|
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
|
-
</
|
|
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:
|
|
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
|
+
}
|
|
@@ -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
|
-
<
|
|
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
|
-
</
|
|
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:
|
|
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
|
+
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
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={
|
|
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
|
+
}
|