@ovotech/element-native 4.0.2-canary-e5d087a-257 → 4.0.2-canary-957f338-258

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,16 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
- import { SegmentTypes } from './constants';
3
- type SegmentedControlsProps<T extends keyof SegmentTypes> = {
4
- activeSegment: SegmentTypes[T][number];
5
- segments: SegmentTypes[T];
6
- setActiveSegment: Dispatch<SetStateAction<SegmentTypes[T][number]>>;
2
+ export type Segment = {
3
+ key: string;
4
+ label: string;
5
+ accessibilityLabel?: string;
6
+ };
7
+ type SegmentedControlsProps = {
8
+ activeSegment: Segment[][number];
9
+ segments: Segment[];
10
+ setActiveSegment: Dispatch<SetStateAction<Segment[][number]>>;
7
11
  inline?: boolean;
8
12
  multipleRows?: boolean;
9
13
  size?: 'small' | 'large';
10
14
  };
11
- export declare const SegmentedControls: <T extends keyof SegmentTypes>({ activeSegment, setActiveSegment, segments, inline, multipleRows, size, }: SegmentedControlsProps<T>) => JSX.Element;
15
+ export declare const SegmentedControls: ({ activeSegment, setActiveSegment, segments, inline, multipleRows, size, }: SegmentedControlsProps) => JSX.Element;
12
16
  export {};
@@ -53,7 +53,7 @@ var SegmentedControls = function (_a) {
53
53
  borderRadius: theme.core.radius.max,
54
54
  backgroundColor: theme.semantic.surface.elevated,
55
55
  }); }, [animatedX, animatedY, animatedWidth, animatedHeight]);
56
- return ((0, jsx_runtime_1.jsxs)(SegmentsContainer, { "$inline": inline, "$multipleRows": multipleRows, children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: animatedBackgroundStyle }), segments.map(function (segment) { return ((0, jsx_runtime_1.jsx)(SegmentButton_1.SegmentButton, { isSelected: activeSegment.key === segment.key, label: segment.label, onPress: function (x, y, width) {
56
+ return ((0, jsx_runtime_1.jsxs)(SegmentsContainer, { "$inline": inline, "$multipleRows": multipleRows, children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: animatedBackgroundStyle }), segments.map(function (segment) { return ((0, jsx_runtime_1.jsx)(SegmentButton_1.SegmentButton, { isSelected: activeSegment.key === segment.key, label: segment.label, accessibilityLabel: segment.accessibilityLabel, onPress: function (x, y, width) {
57
57
  setActiveSegment(segment);
58
58
  animatedX.value = (0, react_native_reanimated_1.withSpring)(x, springSettings);
59
59
  animatedY.value = (0, react_native_reanimated_1.withSpring)(y, springSettings);
@@ -1,11 +1,12 @@
1
1
  type SegmentButtonProps = {
2
- onPress: (x: number, y: number, width: number) => void;
3
- onLayout: (width: number, height: number, x: number, y: number) => void;
4
2
  isSelected: boolean;
5
3
  label: string;
6
- multipleRows?: boolean;
4
+ onPress: (x: number, y: number, width: number) => void;
5
+ onLayout: (width: number, height: number, x: number, y: number) => void;
6
+ accessibilityLabel?: string;
7
7
  inline?: boolean;
8
+ multipleRows?: boolean;
8
9
  size?: 'small' | 'large';
9
10
  };
10
- export declare const SegmentButton: ({ onPress, onLayout, inline, isSelected, label, multipleRows, size, }: SegmentButtonProps) => JSX.Element;
11
+ export declare const SegmentButton: ({ accessibilityLabel, inline, isSelected, label, multipleRows, onLayout, onPress, size, }: SegmentButtonProps) => JSX.Element;
11
12
  export {};
@@ -35,7 +35,7 @@ var styled_native_1 = __importDefault(require("../../../styled.native"));
35
35
  var P_1 = require("../../P");
36
36
  var AnimatedP = react_native_reanimated_1.default.createAnimatedComponent(P_1.P);
37
37
  var SegmentButton = function (_a) {
38
- var onPress = _a.onPress, onLayout = _a.onLayout, inline = _a.inline, isSelected = _a.isSelected, label = _a.label, multipleRows = _a.multipleRows, _b = _a.size, size = _b === void 0 ? 'large' : _b;
38
+ var accessibilityLabel = _a.accessibilityLabel, inline = _a.inline, isSelected = _a.isSelected, label = _a.label, multipleRows = _a.multipleRows, onLayout = _a.onLayout, onPress = _a.onPress, _b = _a.size, size = _b === void 0 ? 'large' : _b;
39
39
  var xRef = (0, react_1.useRef)(0);
40
40
  var yRef = (0, react_1.useRef)(0);
41
41
  var widthRef = (0, react_1.useRef)(0);
@@ -73,7 +73,7 @@ var SegmentButton = function (_a) {
73
73
  // and 1.1 for the multiple row ones.
74
74
  yRef.current - heightRef.current / (multipleRows ? 1.1 : 3), widthRef.current);
75
75
  };
76
- return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onLayout: handleLayout, onPress: handlePress, accessibilityRole: "checkbox", accessibilityState: { selected: isSelected }, hitSlop: {
76
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onLayout: handleLayout, onPress: handlePress, accessible: true, accessibilityRole: "checkbox", accessibilityState: { selected: isSelected }, accessibilityLabel: accessibilityLabel, hitSlop: {
77
77
  top: hitslopVal,
78
78
  bottom: hitslopVal,
79
79
  }, style: { flexGrow: inline || multipleRows ? undefined : 1 }, children: (0, jsx_runtime_1.jsxs)(SSegmentsWrapper, { "$isSelected": isSelected, "$size": size, children: [(0, jsx_runtime_1.jsx)(SSegmentText, { style: {
@@ -27,7 +27,7 @@ export var SegmentedControls = function (_a) {
27
27
  borderRadius: theme.core.radius.max,
28
28
  backgroundColor: theme.semantic.surface.elevated,
29
29
  }); }, [animatedX, animatedY, animatedWidth, animatedHeight]);
30
- return (_jsxs(SegmentsContainer, { "$inline": inline, "$multipleRows": multipleRows, children: [_jsx(Animated.View, { style: animatedBackgroundStyle }), segments.map(function (segment) { return (_jsx(SegmentButton, { isSelected: activeSegment.key === segment.key, label: segment.label, onPress: function (x, y, width) {
30
+ return (_jsxs(SegmentsContainer, { "$inline": inline, "$multipleRows": multipleRows, children: [_jsx(Animated.View, { style: animatedBackgroundStyle }), segments.map(function (segment) { return (_jsx(SegmentButton, { isSelected: activeSegment.key === segment.key, label: segment.label, accessibilityLabel: segment.accessibilityLabel, onPress: function (x, y, width) {
31
31
  setActiveSegment(segment);
32
32
  animatedX.value = withSpring(x, springSettings);
33
33
  animatedY.value = withSpring(y, springSettings);
@@ -6,7 +6,7 @@ import styled from '../../../styled.native';
6
6
  import { P } from '../../P';
7
7
  var AnimatedP = Animated.createAnimatedComponent(P);
8
8
  export var SegmentButton = function (_a) {
9
- var onPress = _a.onPress, onLayout = _a.onLayout, inline = _a.inline, isSelected = _a.isSelected, label = _a.label, multipleRows = _a.multipleRows, _b = _a.size, size = _b === void 0 ? 'large' : _b;
9
+ var accessibilityLabel = _a.accessibilityLabel, inline = _a.inline, isSelected = _a.isSelected, label = _a.label, multipleRows = _a.multipleRows, onLayout = _a.onLayout, onPress = _a.onPress, _b = _a.size, size = _b === void 0 ? 'large' : _b;
10
10
  var xRef = useRef(0);
11
11
  var yRef = useRef(0);
12
12
  var widthRef = useRef(0);
@@ -44,7 +44,7 @@ export var SegmentButton = function (_a) {
44
44
  // and 1.1 for the multiple row ones.
45
45
  yRef.current - heightRef.current / (multipleRows ? 1.1 : 3), widthRef.current);
46
46
  };
47
- return (_jsx(Pressable, { onLayout: handleLayout, onPress: handlePress, accessibilityRole: "checkbox", accessibilityState: { selected: isSelected }, hitSlop: {
47
+ return (_jsx(Pressable, { onLayout: handleLayout, onPress: handlePress, accessible: true, accessibilityRole: "checkbox", accessibilityState: { selected: isSelected }, accessibilityLabel: accessibilityLabel, hitSlop: {
48
48
  top: hitslopVal,
49
49
  bottom: hitslopVal,
50
50
  }, style: { flexGrow: inline || multipleRows ? undefined : 1 }, children: _jsxs(SSegmentsWrapper, { "$isSelected": isSelected, "$size": size, children: [_jsx(SSegmentText, { style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovotech/element-native",
3
- "version": "4.0.2-canary-e5d087a-257",
3
+ "version": "4.0.2-canary-957f338-258",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@backpackapp-io/react-native-toast": "^0.10.0",
17
- "@ovotech/element-core": "3.0.1-canary-e5d087a-257",
17
+ "@ovotech/element-core": "3.0.1-canary-957f338-258",
18
18
  "deepmerge": "^4.2.2",
19
19
  "lodash.groupby": "^4.6.0",
20
20
  "react-native-reanimated-carousel": "^3.5.1"
@@ -1,33 +0,0 @@
1
- export type EnergyUseFilters = 'total' | 'electricity' | 'gas';
2
- export type PeriodFilters = 'day' | 'week' | 'month' | 'year';
3
- export type MeasurementFilters = 'consumption' | 'cost';
4
- export type ComparisonFilters = 'similar' | 'previous' | 'none';
5
- export type MeasurementUnit = '£' | 'kWh';
6
- export type SegmentTypes = {
7
- ENERGY_USE: {
8
- key: EnergyUseFilters;
9
- label: string;
10
- mainScreenLabel?: string;
11
- }[];
12
- PERIOD: {
13
- key: PeriodFilters;
14
- label: string;
15
- mainScreenLabel?: string;
16
- }[];
17
- MEASUREMENT: {
18
- key: MeasurementFilters;
19
- label: string;
20
- mainScreenLabel?: string;
21
- unit: MeasurementUnit;
22
- }[];
23
- COMPARISON: {
24
- key: ComparisonFilters;
25
- label: string;
26
- mainScreenLabel?: string;
27
- }[];
28
- CUSTOM: {
29
- key: string;
30
- label: string;
31
- mainScreenLabel?: string;
32
- }[];
33
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export {};