@ovotech/element-native 4.0.2-canary-e8705c2-255 → 4.0.2-canary-e5d087a-257

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 (23) hide show
  1. package/dist/components/SegmentedControls/SegmentedControls.d.ts +12 -0
  2. package/dist/components/SegmentedControls/SegmentedControls.js +78 -0
  3. package/dist/components/SegmentedControls/components/SegmentButton.d.ts +11 -0
  4. package/dist/components/{FilterSection/components/FilterButton.js → SegmentedControls/components/SegmentButton.js} +22 -21
  5. package/dist/components/{FilterSection → SegmentedControls}/constants.d.ts +8 -3
  6. package/dist/components/SegmentedControls/index.d.ts +2 -0
  7. package/dist/components/SegmentedControls/index.js +5 -0
  8. package/dist/components/index.d.ts +1 -0
  9. package/dist/components/index.js +1 -0
  10. package/dist/esm/components/SegmentedControls/SegmentedControls.js +51 -0
  11. package/dist/esm/components/{FilterSection/components/FilterButton.js → SegmentedControls/components/SegmentButton.js} +17 -19
  12. package/dist/esm/components/SegmentedControls/index.js +2 -0
  13. package/dist/esm/components/index.js +1 -0
  14. package/package.json +2 -2
  15. package/dist/components/FilterSection/FilterSection.d.ts +0 -498
  16. package/dist/components/FilterSection/FilterSection.js +0 -95
  17. package/dist/components/FilterSection/components/FilterButton.d.ts +0 -9
  18. package/dist/components/FilterSection/index.d.ts +0 -2
  19. package/dist/components/FilterSection/index.js +0 -5
  20. package/dist/esm/components/FilterSection/FilterSection.js +0 -65
  21. package/dist/esm/components/FilterSection/index.js +0 -2
  22. /package/dist/components/{FilterSection → SegmentedControls}/constants.js +0 -0
  23. /package/dist/esm/components/{FilterSection → SegmentedControls}/constants.js +0 -0
@@ -0,0 +1,12 @@
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]>>;
7
+ inline?: boolean;
8
+ multipleRows?: boolean;
9
+ size?: 'small' | 'large';
10
+ };
11
+ export declare const SegmentedControls: <T extends keyof SegmentTypes>({ activeSegment, setActiveSegment, segments, inline, multipleRows, size, }: SegmentedControlsProps<T>) => JSX.Element;
12
+ export {};
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.SegmentedControls = void 0;
27
+ var jsx_runtime_1 = require("react/jsx-runtime");
28
+ var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
29
+ var styled_native_1 = __importStar(require("../../styled.native"));
30
+ var SegmentButton_1 = require("./components/SegmentButton");
31
+ var springSettings = {
32
+ damping: 15,
33
+ };
34
+ var SegmentedControls = function (_a) {
35
+ var activeSegment = _a.activeSegment, setActiveSegment = _a.setActiveSegment, segments = _a.segments, _b = _a.inline, inline = _b === void 0 ? false : _b, multipleRows = _a.multipleRows, _c = _a.size, size = _c === void 0 ? 'large' : _c;
36
+ var animatedX = (0, react_native_reanimated_1.useSharedValue)(0);
37
+ var animatedY = (0, react_native_reanimated_1.useSharedValue)(0);
38
+ var animatedHeight = (0, react_native_reanimated_1.useSharedValue)(0);
39
+ var animatedWidth = (0, react_native_reanimated_1.useSharedValue)(0);
40
+ var theme = (0, styled_native_1.useTheme)();
41
+ var animatedBackgroundStyle = (0, react_native_reanimated_1.useAnimatedStyle)(function () { return ({
42
+ transform: [
43
+ {
44
+ translateX: animatedX.value,
45
+ },
46
+ {
47
+ translateY: animatedY.value + theme.core.space[size === 'small' ? 1 : 2],
48
+ } /* accounting for margin from top & bottom */,
49
+ ],
50
+ width: animatedWidth.value,
51
+ height: animatedHeight.value,
52
+ position: 'absolute',
53
+ borderRadius: theme.core.radius.max,
54
+ backgroundColor: theme.semantic.surface.elevated,
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) {
57
+ setActiveSegment(segment);
58
+ animatedX.value = (0, react_native_reanimated_1.withSpring)(x, springSettings);
59
+ animatedY.value = (0, react_native_reanimated_1.withSpring)(y, springSettings);
60
+ animatedWidth.value = width;
61
+ }, onLayout: function (width, height, x, y) {
62
+ if (activeSegment.key === segment.key) {
63
+ animatedX.value = x;
64
+ // (adrian.pop) - I couldn't figure out how to make the positioning work once the
65
+ // choices go on the second row. The only way I could get it to work
66
+ // was to hardcode the denominator to 3 for the single row ones
67
+ // and 1.1 for the multiple row ones.
68
+ animatedY.value = y - height / (multipleRows ? 1.1 : 3);
69
+ animatedHeight.value = height;
70
+ animatedWidth.value = width;
71
+ }
72
+ }, multipleRows: multipleRows, size: size, inline: inline }, segment.key)); })] }));
73
+ };
74
+ exports.SegmentedControls = SegmentedControls;
75
+ var SegmentsContainer = styled_native_1.default.View(function (_a) {
76
+ var _b = _a.theme, core = _b.core, semantic = _b.semantic, $inline = _a.$inline, $multipleRows = _a.$multipleRows;
77
+ return "\n flex-direction: row;\n flex-wrap: ".concat($multipleRows ? '' : 'no-', "wrap;\n justify-content: ").concat($multipleRows ? 'space-between' : 'space-apart', ";\n align-items: center;\n gap: ").concat($inline ? 0 : core.space[1], "px;\n width: ").concat($inline ? 'auto' : '100%', ";\n align-self: ").concat($inline ? 'flex-start' : 'stretch', ";\n padding: ").concat(core.space[1], "px;\n background-color: ").concat(semantic.surface.cutout, ";\n border-radius: ").concat(core.radius.max, "px;\n");
78
+ });
@@ -0,0 +1,11 @@
1
+ type SegmentButtonProps = {
2
+ onPress: (x: number, y: number, width: number) => void;
3
+ onLayout: (width: number, height: number, x: number, y: number) => void;
4
+ isSelected: boolean;
5
+ label: string;
6
+ multipleRows?: boolean;
7
+ inline?: boolean;
8
+ size?: 'small' | 'large';
9
+ };
10
+ export declare const SegmentButton: ({ onPress, onLayout, inline, isSelected, label, multipleRows, size, }: SegmentButtonProps) => JSX.Element;
11
+ export {};
@@ -1,8 +1,4 @@
1
1
  "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
3
  if (k2 === undefined) k2 = k;
8
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -26,21 +22,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
22
  __setModuleDefault(result, mod);
27
23
  return result;
28
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
29
28
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.FilterButton = void 0;
29
+ exports.SegmentButton = void 0;
31
30
  var jsx_runtime_1 = require("react/jsx-runtime");
32
31
  var react_1 = require("react");
33
32
  var react_native_1 = require("react-native");
34
33
  var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
35
- var styled_native_1 = __importStar(require("../../../styled.native"));
34
+ var styled_native_1 = __importDefault(require("../../../styled.native"));
36
35
  var P_1 = require("../../P");
37
36
  var AnimatedP = react_native_reanimated_1.default.createAnimatedComponent(P_1.P);
38
- var FilterButton = function (_a) {
39
- var onPress = _a.onPress, onLayout = _a.onLayout, isSelected = _a.isSelected, label = _a.label, multipleRows = _a.multipleRows;
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;
40
39
  var xRef = (0, react_1.useRef)(0);
41
40
  var yRef = (0, react_1.useRef)(0);
42
41
  var widthRef = (0, react_1.useRef)(0);
43
42
  var heightRef = (0, react_1.useRef)(0);
43
+ var hitslopVal = size === 'small' ? 8 : 4;
44
44
  var fontWeightAnim = (0, react_native_reanimated_1.useSharedValue)(isSelected ? 1 : 0);
45
45
  var animatedStyleNormal = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
46
46
  return {
@@ -61,8 +61,8 @@ var FilterButton = function (_a) {
61
61
  var _a = event.nativeEvent.layout, width = _a.width, height = _a.height, x = _a.x, y = _a.y;
62
62
  xRef.current = x;
63
63
  yRef.current = y;
64
- widthRef.current = width;
65
64
  heightRef.current = height;
65
+ widthRef.current = width;
66
66
  onLayout(width, height, x, y);
67
67
  };
68
68
  var handlePress = function () {
@@ -73,21 +73,22 @@ var FilterButton = 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 }, children: (0, jsx_runtime_1.jsxs)(SFilterSelector, { "$isSelected": isSelected, children: [(0, jsx_runtime_1.jsx)(SFilterText, { style: {
76
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { onLayout: handleLayout, onPress: handlePress, accessibilityRole: "checkbox", accessibilityState: { selected: isSelected }, hitSlop: {
77
+ top: hitslopVal,
78
+ bottom: hitslopVal,
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: {
77
80
  opacity: 0,
78
81
  fontWeight: '900',
79
- }, "$isSelected": false, children: label }), (0, jsx_runtime_1.jsx)(SFilterText, { style: animatedStyleNormal, "$isSelected": false, numberOfLines: 1, adjustsFontSizeToFit: true, children: label }), (0, jsx_runtime_1.jsx)(SFilterText, { style: animatedStyleBold, "$isSelected": true, numberOfLines: 1, adjustsFontSizeToFit: true, children: label })] }) }));
82
+ }, "$isSelected": false, children: label }), (0, jsx_runtime_1.jsx)(SSegmentText, { style: animatedStyleNormal, "$isSelected": false, numberOfLines: 1, adjustsFontSizeToFit: true, children: label }), (0, jsx_runtime_1.jsx)(SSegmentText, { style: animatedStyleBold, "$isSelected": true, numberOfLines: 1, adjustsFontSizeToFit: true, children: label })] }) }));
80
83
  };
81
- exports.FilterButton = FilterButton;
82
- var SFilterSelector = styled_native_1.default.View(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 0 ", "px;\n border-radius: ", "px;\n align-items: center;\n justify-content: center;\n"], ["\n padding: 0 ", "px;\n border-radius: ", "px;\n align-items: center;\n justify-content: center;\n"])), function (_a) {
83
- var theme = _a.theme;
84
- return theme.core.space[4];
85
- }, function (_a) {
86
- var theme = _a.theme;
87
- return theme.core.radius.large;
84
+ exports.SegmentButton = SegmentButton;
85
+ var SSegmentsWrapper = styled_native_1.default.View(function (_a) {
86
+ var theme = _a.theme, $size = _a.$size;
87
+ return "\n padding: ".concat($size === 'small' ? 0 : 6, "px ").concat(theme.core.space[$size === 'small' ? 3 : 4], "px;\n align-items: center;\n justify-content: center;\n");
88
88
  });
89
- var SFilterText = (0, styled_native_1.default)(AnimatedP)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (_a) {
89
+ var SSegmentText = (0, styled_native_1.default)(AnimatedP)(function (_a) {
90
90
  var $isSelected = _a.$isSelected, theme = _a.theme;
91
- return $isSelected && (0, styled_native_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n font-weight: ", ";\n "], ["\n color: ", ";\n font-weight: ", ";\n "])), theme.core.color.brand.white, theme.core.fontWeight.bold);
91
+ return "\n font-family: ".concat($isSelected
92
+ ? theme.core.fontFamily.bodyBold.native
93
+ : theme.core.fontFamily.body.native, ";\n color: ").concat(theme.semantic.message.base, ";\n ");
92
94
  });
93
- var templateObject_1, templateObject_2, templateObject_3;
@@ -1,9 +1,9 @@
1
- export type EnergyUseFilters = 'electricity' | 'gas' | 'combined';
2
- export type PeriodFilters = 'week' | 'month' | 'year';
1
+ export type EnergyUseFilters = 'total' | 'electricity' | 'gas';
2
+ export type PeriodFilters = 'day' | 'week' | 'month' | 'year';
3
3
  export type MeasurementFilters = 'consumption' | 'cost';
4
4
  export type ComparisonFilters = 'similar' | 'previous' | 'none';
5
5
  export type MeasurementUnit = '£' | 'kWh';
6
- export type Filters = {
6
+ export type SegmentTypes = {
7
7
  ENERGY_USE: {
8
8
  key: EnergyUseFilters;
9
9
  label: string;
@@ -25,4 +25,9 @@ export type Filters = {
25
25
  label: string;
26
26
  mainScreenLabel?: string;
27
27
  }[];
28
+ CUSTOM: {
29
+ key: string;
30
+ label: string;
31
+ mainScreenLabel?: string;
32
+ }[];
28
33
  };
@@ -0,0 +1,2 @@
1
+ import { SegmentedControls } from './SegmentedControls';
2
+ export { SegmentedControls };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SegmentedControls = void 0;
4
+ var SegmentedControls_1 = require("./SegmentedControls");
5
+ Object.defineProperty(exports, "SegmentedControls", { enumerable: true, get: function () { return SegmentedControls_1.SegmentedControls; } });
@@ -40,6 +40,7 @@ export * from './PasswordInput';
40
40
  export * from './PhoneField';
41
41
  export * from './PhoneInput';
42
42
  export * from './Radio';
43
+ export * from './SegmentedControls';
43
44
  export * from './SelectField';
44
45
  export * from './SkeletonCircle';
45
46
  export * from './SkeletonCTA';
@@ -56,6 +56,7 @@ __exportStar(require("./PasswordInput"), exports);
56
56
  __exportStar(require("./PhoneField"), exports);
57
57
  __exportStar(require("./PhoneInput"), exports);
58
58
  __exportStar(require("./Radio"), exports);
59
+ __exportStar(require("./SegmentedControls"), exports);
59
60
  __exportStar(require("./SelectField"), exports);
60
61
  __exportStar(require("./SkeletonCircle"), exports);
61
62
  __exportStar(require("./SkeletonCTA"), exports);
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Animated, { useAnimatedStyle, useSharedValue, withSpring, } from 'react-native-reanimated';
3
+ import styled, { useTheme } from '../../styled.native';
4
+ import { SegmentButton } from './components/SegmentButton';
5
+ var springSettings = {
6
+ damping: 15,
7
+ };
8
+ export var SegmentedControls = function (_a) {
9
+ var activeSegment = _a.activeSegment, setActiveSegment = _a.setActiveSegment, segments = _a.segments, _b = _a.inline, inline = _b === void 0 ? false : _b, multipleRows = _a.multipleRows, _c = _a.size, size = _c === void 0 ? 'large' : _c;
10
+ var animatedX = useSharedValue(0);
11
+ var animatedY = useSharedValue(0);
12
+ var animatedHeight = useSharedValue(0);
13
+ var animatedWidth = useSharedValue(0);
14
+ var theme = useTheme();
15
+ var animatedBackgroundStyle = useAnimatedStyle(function () { return ({
16
+ transform: [
17
+ {
18
+ translateX: animatedX.value,
19
+ },
20
+ {
21
+ translateY: animatedY.value + theme.core.space[size === 'small' ? 1 : 2],
22
+ } /* accounting for margin from top & bottom */,
23
+ ],
24
+ width: animatedWidth.value,
25
+ height: animatedHeight.value,
26
+ position: 'absolute',
27
+ borderRadius: theme.core.radius.max,
28
+ backgroundColor: theme.semantic.surface.elevated,
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) {
31
+ setActiveSegment(segment);
32
+ animatedX.value = withSpring(x, springSettings);
33
+ animatedY.value = withSpring(y, springSettings);
34
+ animatedWidth.value = width;
35
+ }, onLayout: function (width, height, x, y) {
36
+ if (activeSegment.key === segment.key) {
37
+ animatedX.value = x;
38
+ // (adrian.pop) - I couldn't figure out how to make the positioning work once the
39
+ // choices go on the second row. The only way I could get it to work
40
+ // was to hardcode the denominator to 3 for the single row ones
41
+ // and 1.1 for the multiple row ones.
42
+ animatedY.value = y - height / (multipleRows ? 1.1 : 3);
43
+ animatedHeight.value = height;
44
+ animatedWidth.value = width;
45
+ }
46
+ }, multipleRows: multipleRows, size: size, inline: inline }, segment.key)); })] }));
47
+ };
48
+ var SegmentsContainer = styled.View(function (_a) {
49
+ var _b = _a.theme, core = _b.core, semantic = _b.semantic, $inline = _a.$inline, $multipleRows = _a.$multipleRows;
50
+ return "\n flex-direction: row;\n flex-wrap: ".concat($multipleRows ? '' : 'no-', "wrap;\n justify-content: ").concat($multipleRows ? 'space-between' : 'space-apart', ";\n align-items: center;\n gap: ").concat($inline ? 0 : core.space[1], "px;\n width: ").concat($inline ? 'auto' : '100%', ";\n align-self: ").concat($inline ? 'flex-start' : 'stretch', ";\n padding: ").concat(core.space[1], "px;\n background-color: ").concat(semantic.surface.cutout, ";\n border-radius: ").concat(core.radius.max, "px;\n");
51
+ });
@@ -1,20 +1,17 @@
1
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
- return cooked;
4
- };
5
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
2
  import { useEffect, useRef } from 'react';
7
3
  import { Pressable } from 'react-native';
8
4
  import Animated, { useAnimatedStyle, useSharedValue, withTiming, } from 'react-native-reanimated';
9
- import styled, { css } from '../../../styled.native';
5
+ import styled from '../../../styled.native';
10
6
  import { P } from '../../P';
11
7
  var AnimatedP = Animated.createAnimatedComponent(P);
12
- export var FilterButton = function (_a) {
13
- var onPress = _a.onPress, onLayout = _a.onLayout, isSelected = _a.isSelected, label = _a.label, multipleRows = _a.multipleRows;
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;
14
10
  var xRef = useRef(0);
15
11
  var yRef = useRef(0);
16
12
  var widthRef = useRef(0);
17
13
  var heightRef = useRef(0);
14
+ var hitslopVal = size === 'small' ? 8 : 4;
18
15
  var fontWeightAnim = useSharedValue(isSelected ? 1 : 0);
19
16
  var animatedStyleNormal = useAnimatedStyle(function () {
20
17
  return {
@@ -35,8 +32,8 @@ export var FilterButton = function (_a) {
35
32
  var _a = event.nativeEvent.layout, width = _a.width, height = _a.height, x = _a.x, y = _a.y;
36
33
  xRef.current = x;
37
34
  yRef.current = y;
38
- widthRef.current = width;
39
35
  heightRef.current = height;
36
+ widthRef.current = width;
40
37
  onLayout(width, height, x, y);
41
38
  };
42
39
  var handlePress = function () {
@@ -47,20 +44,21 @@ export var FilterButton = function (_a) {
47
44
  // and 1.1 for the multiple row ones.
48
45
  yRef.current - heightRef.current / (multipleRows ? 1.1 : 3), widthRef.current);
49
46
  };
50
- return (_jsx(Pressable, { onLayout: handleLayout, onPress: handlePress, accessibilityRole: "checkbox", accessibilityState: { selected: isSelected }, children: _jsxs(SFilterSelector, { "$isSelected": isSelected, children: [_jsx(SFilterText, { style: {
47
+ return (_jsx(Pressable, { onLayout: handleLayout, onPress: handlePress, accessibilityRole: "checkbox", accessibilityState: { selected: isSelected }, hitSlop: {
48
+ top: hitslopVal,
49
+ bottom: hitslopVal,
50
+ }, style: { flexGrow: inline || multipleRows ? undefined : 1 }, children: _jsxs(SSegmentsWrapper, { "$isSelected": isSelected, "$size": size, children: [_jsx(SSegmentText, { style: {
51
51
  opacity: 0,
52
52
  fontWeight: '900',
53
- }, "$isSelected": false, children: label }), _jsx(SFilterText, { style: animatedStyleNormal, "$isSelected": false, numberOfLines: 1, adjustsFontSizeToFit: true, children: label }), _jsx(SFilterText, { style: animatedStyleBold, "$isSelected": true, numberOfLines: 1, adjustsFontSizeToFit: true, children: label })] }) }));
53
+ }, "$isSelected": false, children: label }), _jsx(SSegmentText, { style: animatedStyleNormal, "$isSelected": false, numberOfLines: 1, adjustsFontSizeToFit: true, children: label }), _jsx(SSegmentText, { style: animatedStyleBold, "$isSelected": true, numberOfLines: 1, adjustsFontSizeToFit: true, children: label })] }) }));
54
54
  };
55
- var SFilterSelector = styled.View(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 0 ", "px;\n border-radius: ", "px;\n align-items: center;\n justify-content: center;\n"], ["\n padding: 0 ", "px;\n border-radius: ", "px;\n align-items: center;\n justify-content: center;\n"])), function (_a) {
56
- var theme = _a.theme;
57
- return theme.core.space[4];
58
- }, function (_a) {
59
- var theme = _a.theme;
60
- return theme.core.radius.large;
55
+ var SSegmentsWrapper = styled.View(function (_a) {
56
+ var theme = _a.theme, $size = _a.$size;
57
+ return "\n padding: ".concat($size === 'small' ? 0 : 6, "px ").concat(theme.core.space[$size === 'small' ? 3 : 4], "px;\n align-items: center;\n justify-content: center;\n");
61
58
  });
62
- var SFilterText = styled(AnimatedP)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), function (_a) {
59
+ var SSegmentText = styled(AnimatedP)(function (_a) {
63
60
  var $isSelected = _a.$isSelected, theme = _a.theme;
64
- return $isSelected && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n font-weight: ", ";\n "], ["\n color: ", ";\n font-weight: ", ";\n "])), theme.core.color.brand.white, theme.core.fontWeight.bold);
61
+ return "\n font-family: ".concat($isSelected
62
+ ? theme.core.fontFamily.bodyBold.native
63
+ : theme.core.fontFamily.body.native, ";\n color: ").concat(theme.semantic.message.base, ";\n ");
65
64
  });
66
- var templateObject_1, templateObject_2, templateObject_3;
@@ -0,0 +1,2 @@
1
+ import { SegmentedControls } from './SegmentedControls';
2
+ export { SegmentedControls };
@@ -40,6 +40,7 @@ export * from './PasswordInput';
40
40
  export * from './PhoneField';
41
41
  export * from './PhoneInput';
42
42
  export * from './Radio';
43
+ export * from './SegmentedControls';
43
44
  export * from './SelectField';
44
45
  export * from './SkeletonCircle';
45
46
  export * from './SkeletonCTA';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovotech/element-native",
3
- "version": "4.0.2-canary-e8705c2-255",
3
+ "version": "4.0.2-canary-e5d087a-257",
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-e8705c2-255",
17
+ "@ovotech/element-core": "3.0.1-canary-e5d087a-257",
18
18
  "deepmerge": "^4.2.2",
19
19
  "lodash.groupby": "^4.6.0",
20
20
  "react-native-reanimated-carousel": "^3.5.1"
@@ -1,498 +0,0 @@
1
- import { Dispatch, SetStateAction } from 'react';
2
- import { Filters } from './constants';
3
- type FilterSectionProps<T extends keyof Filters> = {
4
- filterTitle: string;
5
- localFilter: Filters[T][number];
6
- setLocalFilter: Dispatch<SetStateAction<Filters[T][number]>>;
7
- filters: Filters[T];
8
- multipleRows?: boolean;
9
- };
10
- export declare const FilterSection: <T extends keyof Filters>({ filterTitle, localFilter, setLocalFilter, filters, multipleRows, }: FilterSectionProps<T>) => JSX.Element;
11
- export declare const BlackHeading4: import("styled-components").StyledComponent<({ accessibilityRole, ...rest }: import("react").PropsWithChildren<import("react-native").TextProps & {
12
- inverted?: boolean | undefined;
13
- }>) => JSX.Element, {
14
- core: {
15
- color: {
16
- brand: {
17
- midnight: string;
18
- midnightTint: string;
19
- forest: string;
20
- forestTint: string;
21
- ovo: string;
22
- ovoTint: string;
23
- leaf: string;
24
- leafTint: string;
25
- energised: string;
26
- energisedTint: string;
27
- offwhite: string;
28
- white: string;
29
- black: string;
30
- };
31
- neutral: {
32
- darkest: string;
33
- darker: string;
34
- dark: string;
35
- base: string;
36
- light: string;
37
- lighter: string;
38
- lightest: string;
39
- };
40
- red: {
41
- darkest: string;
42
- darker: string;
43
- dark: string;
44
- base: string;
45
- light: string;
46
- lighter: string;
47
- lightest: string;
48
- };
49
- orange: {
50
- darkest: string;
51
- darker: string;
52
- dark: string;
53
- base: string;
54
- light: string;
55
- lighter: string;
56
- lightest: string;
57
- };
58
- yellow: {
59
- darkest: string;
60
- darker: string;
61
- dark: string;
62
- base: string;
63
- light: string;
64
- lighter: string;
65
- lightest: string;
66
- };
67
- green: {
68
- darkest: string;
69
- darker: string;
70
- dark: string;
71
- base: string;
72
- light: string;
73
- lighter: string;
74
- lightest: string;
75
- };
76
- blue: {
77
- darkest: string;
78
- darker: string;
79
- dark: string;
80
- base: string;
81
- light: string;
82
- lighter: string;
83
- lightest: string;
84
- };
85
- };
86
- fontFamily: {
87
- mono: {
88
- native: string;
89
- web: string;
90
- };
91
- heading: {
92
- native: string;
93
- web: string;
94
- };
95
- body: {
96
- native: string;
97
- web: string;
98
- };
99
- bodyBold: {
100
- native: string;
101
- web: string;
102
- };
103
- };
104
- fontWeight: {
105
- book: number;
106
- bold: number;
107
- black: number;
108
- };
109
- fontSize: {
110
- heading1: {
111
- small: number;
112
- large: number;
113
- };
114
- heading2: {
115
- small: number;
116
- large: number;
117
- };
118
- heading3: {
119
- small: number;
120
- large: number;
121
- };
122
- heading4: {
123
- small: number;
124
- large: number;
125
- };
126
- lead: {
127
- small: number;
128
- large: number;
129
- };
130
- body: {
131
- small: number;
132
- large: number;
133
- };
134
- small: {
135
- small: number;
136
- large: number;
137
- };
138
- label: {
139
- small: number;
140
- large: number;
141
- };
142
- };
143
- letterSpacing: {
144
- base: number;
145
- compressed: number;
146
- extraCompressed: number;
147
- };
148
- lineHeight: {
149
- heading1: {
150
- small: number;
151
- large: number;
152
- };
153
- heading2: {
154
- small: number;
155
- large: number;
156
- };
157
- heading3: {
158
- small: number;
159
- large: number;
160
- };
161
- heading4: {
162
- small: number;
163
- large: number;
164
- };
165
- lead: {
166
- small: number;
167
- large: number;
168
- };
169
- body: {
170
- small: number;
171
- large: number;
172
- };
173
- small: {
174
- small: number;
175
- large: number;
176
- };
177
- label: {
178
- small: number;
179
- large: number;
180
- };
181
- };
182
- borderWidth: {
183
- small: number;
184
- medium: number;
185
- large: number;
186
- };
187
- breakpoint: {
188
- small: number;
189
- medium: number;
190
- large: number;
191
- };
192
- mediaQuery: {
193
- small: number;
194
- medium: number;
195
- large: number;
196
- };
197
- customMediaQuery: {
198
- 'small-and-up': number;
199
- 'medium-and-up': number;
200
- 'large-and-up': number;
201
- };
202
- opacity: {
203
- solid: number;
204
- translucent: number;
205
- transparent: number;
206
- };
207
- radius: {
208
- small: number;
209
- medium: number;
210
- large: number;
211
- max: number;
212
- };
213
- space: {
214
- '0': number;
215
- '1': number;
216
- '2': number;
217
- '3': number;
218
- '4': number;
219
- '5': number;
220
- '6': number;
221
- '7': number;
222
- '8': number;
223
- '9': number;
224
- '10': number;
225
- '11': number;
226
- '12': number;
227
- '13': number;
228
- '14': number;
229
- '15': number;
230
- };
231
- transition: {
232
- slow: number;
233
- medium: number;
234
- fast: number;
235
- };
236
- };
237
- semantic: {
238
- border: {
239
- graphic: string;
240
- differentiated: string;
241
- functional: string;
242
- };
243
- branded: {
244
- surface: string;
245
- message: string;
246
- heading: string;
247
- };
248
- neutral: {
249
- surface: string;
250
- message: string;
251
- surfaceEmphasis: string;
252
- messageOnEmphasis: string;
253
- border: string;
254
- };
255
- success: {
256
- surface: string;
257
- message: string;
258
- surfaceEmphasis: string;
259
- messageOnEmphasis: string;
260
- border: string;
261
- };
262
- warning: {
263
- surface: string;
264
- message: string;
265
- surfaceEmphasis: string;
266
- messageOnEmphasis: string;
267
- border: string;
268
- };
269
- error: {
270
- surface: string;
271
- message: string;
272
- surfaceEmphasis: string;
273
- messageOnEmphasis: string;
274
- border: string;
275
- };
276
- info: {
277
- surface: string;
278
- message: string;
279
- surfaceEmphasis: string;
280
- messageOnEmphasis: string;
281
- border: string;
282
- };
283
- data: {
284
- branded: {
285
- '1': string;
286
- '2': string;
287
- '3': string;
288
- '4': string;
289
- };
290
- electric: {
291
- '1': string;
292
- '2': string;
293
- '3': string;
294
- '4': string;
295
- };
296
- gas: {
297
- '1': string;
298
- '2': string;
299
- '3': string;
300
- '4': string;
301
- };
302
- };
303
- focus: {
304
- outline: string;
305
- hover: string;
306
- surface: string;
307
- };
308
- inverted: {
309
- surface: string;
310
- surfaceAlt: string;
311
- border: string;
312
- borderAlt: string;
313
- message: {
314
- branded: string;
315
- base: string;
316
- secondary: string;
317
- link: string;
318
- };
319
- };
320
- message: {
321
- base: string;
322
- secondary: string;
323
- link: string;
324
- error: string;
325
- branded: string;
326
- };
327
- surface: {
328
- base: string;
329
- cutout: string;
330
- elevated: string;
331
- };
332
- };
333
- component: {
334
- badge: {
335
- variants: {
336
- neutral: {
337
- background: string;
338
- foreground: string;
339
- };
340
- red: {
341
- background: string;
342
- foreground: string;
343
- };
344
- orange: {
345
- background: string;
346
- foreground: string;
347
- };
348
- yellow: {
349
- background: string;
350
- foreground: string;
351
- };
352
- green: {
353
- background: string;
354
- foreground: string;
355
- };
356
- blue: {
357
- background: string;
358
- foreground: string;
359
- };
360
- };
361
- };
362
- cta: {
363
- primary: {
364
- message: string;
365
- surface: string;
366
- messageHover: string;
367
- surfaceHover: string;
368
- messageFocused: string;
369
- surfaceFocused: string;
370
- outlineFocused: string;
371
- backgroundFocused: string;
372
- messageInverted: string;
373
- surfaceInverted: string;
374
- };
375
- secondary: {
376
- message: string;
377
- surface: string;
378
- messageHover: string;
379
- surfaceHover: string;
380
- messageFocused: string;
381
- surfaceFocused: string;
382
- outlineFocused: string;
383
- backgroundFocused: string;
384
- messageInverted: string;
385
- surfaceInverted: string;
386
- };
387
- destructive: {
388
- message: string;
389
- surface: string;
390
- messageHover: string;
391
- surfaceHover: string;
392
- messageFocused: string;
393
- surfaceFocused: string;
394
- outlineFocused: string;
395
- backgroundFocused: string;
396
- messageInverted: string;
397
- surfaceInverted: string;
398
- };
399
- };
400
- heading1: {
401
- fontFamily: string;
402
- fontWeight: number;
403
- lineHeight: {
404
- small: number;
405
- large: number;
406
- };
407
- fontSize: {
408
- small: number;
409
- large: number;
410
- };
411
- };
412
- heading2: {
413
- fontFamily: string;
414
- fontWeight: number;
415
- lineHeight: {
416
- small: number;
417
- large: number;
418
- };
419
- fontSize: {
420
- small: number;
421
- large: number;
422
- };
423
- };
424
- heading3: {
425
- fontFamily: string;
426
- fontWeight: number;
427
- lineHeight: {
428
- small: number;
429
- large: number;
430
- };
431
- fontSize: {
432
- small: number;
433
- large: number;
434
- };
435
- };
436
- heading4: {
437
- fontFamily: string;
438
- fontWeight: number;
439
- lineHeight: {
440
- small: number;
441
- large: number;
442
- };
443
- fontSize: {
444
- small: number;
445
- large: number;
446
- };
447
- };
448
- lead: {
449
- fontFamily: string;
450
- fontWeight: number;
451
- lineHeight: {
452
- small: number;
453
- large: number;
454
- };
455
- fontSize: {
456
- small: number;
457
- large: number;
458
- };
459
- };
460
- body: {
461
- fontFamily: string;
462
- fontWeight: number;
463
- lineHeight: {
464
- small: number;
465
- large: number;
466
- };
467
- fontSize: {
468
- small: number;
469
- large: number;
470
- };
471
- };
472
- small: {
473
- fontFamily: string;
474
- fontWeight: number;
475
- lineHeight: {
476
- small: number;
477
- large: number;
478
- };
479
- fontSize: {
480
- small: number;
481
- large: number;
482
- };
483
- };
484
- label: {
485
- fontFamily: string;
486
- fontWeight: number;
487
- lineHeight: {
488
- small: number;
489
- large: number;
490
- };
491
- fontSize: {
492
- small: number;
493
- large: number;
494
- };
495
- };
496
- };
497
- }, {}, never>;
498
- export {};
@@ -1,95 +0,0 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
- Object.defineProperty(o, "default", { enumerable: true, value: v });
19
- }) : function(o, v) {
20
- o["default"] = v;
21
- });
22
- var __importStar = (this && this.__importStar) || function (mod) {
23
- if (mod && mod.__esModule) return mod;
24
- var result = {};
25
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26
- __setModuleDefault(result, mod);
27
- return result;
28
- };
29
- var __importDefault = (this && this.__importDefault) || function (mod) {
30
- return (mod && mod.__esModule) ? mod : { "default": mod };
31
- };
32
- Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.BlackHeading4 = exports.FilterSection = void 0;
34
- var jsx_runtime_1 = require("react/jsx-runtime");
35
- var react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
36
- var styled_native_1 = __importDefault(require("../../styled.native"));
37
- var Heading4_1 = require("../Heading4");
38
- var FilterButton_1 = require("./components/FilterButton");
39
- var springSettings = {
40
- damping: 15,
41
- };
42
- var FilterSection = function (_a) {
43
- var filterTitle = _a.filterTitle, localFilter = _a.localFilter, setLocalFilter = _a.setLocalFilter, filters = _a.filters, multipleRows = _a.multipleRows;
44
- var animatedX = (0, react_native_reanimated_1.useSharedValue)(0);
45
- var animatedY = (0, react_native_reanimated_1.useSharedValue)(0);
46
- var animatedWidth = (0, react_native_reanimated_1.useSharedValue)(0);
47
- var animatedHeight = (0, react_native_reanimated_1.useSharedValue)(0);
48
- var animatedBackgroundStyle = (0, react_native_reanimated_1.useAnimatedStyle)(function () {
49
- return {
50
- transform: [
51
- { translateX: animatedX.value },
52
- { translateY: animatedY.value },
53
- ],
54
- width: animatedWidth.value,
55
- height: animatedHeight.value,
56
- position: 'absolute',
57
- borderRadius: 22,
58
- backgroundColor: '#0a9828',
59
- };
60
- }, [animatedX, animatedY, animatedWidth, animatedHeight]);
61
- return ((0, jsx_runtime_1.jsxs)(SectionContainer, { children: [(0, jsx_runtime_1.jsx)(exports.BlackHeading4, { children: filterTitle }), (0, jsx_runtime_1.jsxs)(FilterSelectorContainer, { children: [(0, jsx_runtime_1.jsx)(react_native_reanimated_1.default.View, { style: animatedBackgroundStyle }), filters.map(function (filter) { return ((0, jsx_runtime_1.jsx)(FilterButton_1.FilterButton, { isSelected: localFilter.key === filter.key, label: filter.label, onPress: function (x, y, width) {
62
- setLocalFilter(filter);
63
- animatedX.value = (0, react_native_reanimated_1.withSpring)(x, springSettings);
64
- animatedY.value = (0, react_native_reanimated_1.withSpring)(y, springSettings);
65
- animatedWidth.value = (0, react_native_reanimated_1.withSpring)(width, springSettings);
66
- }, onLayout: function (width, height, x, y) {
67
- if (localFilter.key === filter.key) {
68
- animatedX.value = x;
69
- // (adrian.pop) - I couldn't figure out how to make the positioning work once the
70
- // choices go on the second row. The only way I could get it to work
71
- // was to hardcode the denominator to 3 for the single row ones
72
- // and 1.1 for the multiple row ones.
73
- animatedY.value = y - height / (multipleRows ? 1.1 : 3);
74
- animatedWidth.value = width;
75
- animatedHeight.value = height;
76
- }
77
- }, multipleRows: multipleRows }, filter.key)); })] })] }));
78
- };
79
- exports.FilterSection = FilterSection;
80
- var SectionContainer = styled_native_1.default.View(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n gap: ", "px;\n align-items: flex-start;\n"], ["\n gap: ", "px;\n align-items: flex-start;\n"])), function (_a) {
81
- var theme = _a.theme;
82
- return theme.core.space[2];
83
- });
84
- var FilterSelectorContainer = styled_native_1.default.View(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", ";\n padding: ", "px;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n gap: ", "px;\n border-radius: 22px;\n width: 100%;\n"], ["\n background-color: ", ";\n padding: ", "px;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n gap: ", "px;\n border-radius: 22px;\n width: 100%;\n"])), function (_a) {
85
- var theme = _a.theme;
86
- return theme.core.color.neutral.lighter;
87
- }, function (_a) {
88
- var theme = _a.theme;
89
- return theme.core.space[2];
90
- }, function (_a) {
91
- var theme = _a.theme;
92
- return theme.core.space[1];
93
- });
94
- exports.BlackHeading4 = (0, styled_native_1.default)(Heading4_1.Heading4)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n color: black;\n"], ["\n color: black;\n"])));
95
- var templateObject_1, templateObject_2, templateObject_3;
@@ -1,9 +0,0 @@
1
- type FilterButtonProps = {
2
- onPress: (x: number, y: number, width: number) => void;
3
- onLayout: (width: number, height: number, x: number, y: number) => void;
4
- isSelected: boolean;
5
- label: string;
6
- multipleRows?: boolean;
7
- };
8
- export declare const FilterButton: ({ onPress, onLayout, isSelected, label, multipleRows, }: FilterButtonProps) => JSX.Element;
9
- export {};
@@ -1,2 +0,0 @@
1
- import { FilterSelect } from '../FilterSelect';
2
- export { FilterSelect };
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FilterSelect = void 0;
4
- var FilterSelect_1 = require("../FilterSelect");
5
- Object.defineProperty(exports, "FilterSelect", { enumerable: true, get: function () { return FilterSelect_1.FilterSelect; } });
@@ -1,65 +0,0 @@
1
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
- return cooked;
4
- };
5
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
- import Animated, { useAnimatedStyle, useSharedValue, withSpring, } from 'react-native-reanimated';
7
- import styled from '../../styled.native';
8
- import { Heading4 } from '../Heading4';
9
- import { FilterButton } from './components/FilterButton';
10
- var springSettings = {
11
- damping: 15,
12
- };
13
- export var FilterSection = function (_a) {
14
- var filterTitle = _a.filterTitle, localFilter = _a.localFilter, setLocalFilter = _a.setLocalFilter, filters = _a.filters, multipleRows = _a.multipleRows;
15
- var animatedX = useSharedValue(0);
16
- var animatedY = useSharedValue(0);
17
- var animatedWidth = useSharedValue(0);
18
- var animatedHeight = useSharedValue(0);
19
- var animatedBackgroundStyle = useAnimatedStyle(function () {
20
- return {
21
- transform: [
22
- { translateX: animatedX.value },
23
- { translateY: animatedY.value },
24
- ],
25
- width: animatedWidth.value,
26
- height: animatedHeight.value,
27
- position: 'absolute',
28
- borderRadius: 22,
29
- backgroundColor: '#0a9828',
30
- };
31
- }, [animatedX, animatedY, animatedWidth, animatedHeight]);
32
- return (_jsxs(SectionContainer, { children: [_jsx(BlackHeading4, { children: filterTitle }), _jsxs(FilterSelectorContainer, { children: [_jsx(Animated.View, { style: animatedBackgroundStyle }), filters.map(function (filter) { return (_jsx(FilterButton, { isSelected: localFilter.key === filter.key, label: filter.label, onPress: function (x, y, width) {
33
- setLocalFilter(filter);
34
- animatedX.value = withSpring(x, springSettings);
35
- animatedY.value = withSpring(y, springSettings);
36
- animatedWidth.value = withSpring(width, springSettings);
37
- }, onLayout: function (width, height, x, y) {
38
- if (localFilter.key === filter.key) {
39
- animatedX.value = x;
40
- // (adrian.pop) - I couldn't figure out how to make the positioning work once the
41
- // choices go on the second row. The only way I could get it to work
42
- // was to hardcode the denominator to 3 for the single row ones
43
- // and 1.1 for the multiple row ones.
44
- animatedY.value = y - height / (multipleRows ? 1.1 : 3);
45
- animatedWidth.value = width;
46
- animatedHeight.value = height;
47
- }
48
- }, multipleRows: multipleRows }, filter.key)); })] })] }));
49
- };
50
- var SectionContainer = styled.View(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n gap: ", "px;\n align-items: flex-start;\n"], ["\n gap: ", "px;\n align-items: flex-start;\n"])), function (_a) {
51
- var theme = _a.theme;
52
- return theme.core.space[2];
53
- });
54
- var FilterSelectorContainer = styled.View(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n background-color: ", ";\n padding: ", "px;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n gap: ", "px;\n border-radius: 22px;\n width: 100%;\n"], ["\n background-color: ", ";\n padding: ", "px;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-wrap: wrap;\n gap: ", "px;\n border-radius: 22px;\n width: 100%;\n"])), function (_a) {
55
- var theme = _a.theme;
56
- return theme.core.color.neutral.lighter;
57
- }, function (_a) {
58
- var theme = _a.theme;
59
- return theme.core.space[2];
60
- }, function (_a) {
61
- var theme = _a.theme;
62
- return theme.core.space[1];
63
- });
64
- export var BlackHeading4 = styled(Heading4)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n color: black;\n"], ["\n color: black;\n"])));
65
- var templateObject_1, templateObject_2, templateObject_3;
@@ -1,2 +0,0 @@
1
- import { FilterSelect } from '../FilterSelect';
2
- export { FilterSelect };