@tactics/toddle-styleguide 2.0.3 → 3.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/App.tsx +0 -12
- package/app.json +1 -0
- package/babel.config.js +14 -1
- package/index.d.ts +2 -5
- package/index.tsx +0 -8
- package/metro.config.js +11 -0
- package/package.json +1 -1
- package/src/components/atoms/animated-wave/animated-wave.styles.d.ts +19 -19
- package/src/components/atoms/backdrop/backdrop.styles.d.ts +9 -9
- package/src/components/atoms/background-gradient/background-gradient.styles.d.ts +6 -6
- package/src/components/atoms/count/count.component.d.ts +1 -1
- package/src/components/atoms/count/count.component.tsx +12 -13
- package/src/components/atoms/count/count.preview.tsx +5 -5
- package/src/components/atoms/count/count.styles.d.ts +23 -20
- package/src/components/atoms/count/count.styles.js +25 -17
- package/src/components/atoms/footer/footer.component.d.ts +1 -4
- package/src/components/atoms/footer/footer.component.tsx +9 -13
- package/src/components/atoms/footer/footer.preview.tsx +0 -17
- package/src/components/atoms/footer/footer.styles.d.ts +16 -13
- package/src/components/atoms/footer/footer.styles.js +1 -1
- package/src/components/atoms/increment-input/increment-input.styles.d.ts +33 -33
- package/src/components/atoms/quick-message/quick-message.styles.d.ts +16 -13
- package/src/components/atoms/split-container/split-container.styles.d.ts +12 -12
- package/src/components/molecules/amount/amount.component.d.ts +3 -3
- package/src/components/molecules/amount/amount.component.tsx +125 -100
- package/src/components/molecules/amount/amount.preview.tsx +59 -11
- package/src/components/molecules/amount/amount.styles.d.ts +34 -34
- package/src/components/molecules/amount/amount.styles.js +7 -7
- package/src/components/molecules/avatar/avatar.component.d.ts +1 -1
- package/src/components/molecules/avatar/avatar.component.tsx +8 -6
- package/src/components/molecules/avatar/avatar.styles.d.ts +96 -78
- package/src/components/molecules/avatar/avatar.styles.js +18 -16
- package/src/components/molecules/bare-time-picker/bare-time-picker.component.d.ts +1 -1
- package/src/components/molecules/bare-time-picker/bare-time-picker.component.native.tsx +78 -0
- package/src/components/molecules/bare-time-picker/bare-time-picker.component.tsx +39 -67
- package/src/components/molecules/bare-time-picker/bare-time-picker.preview.tsx +1 -1
- package/src/components/molecules/bare-time-picker/bare-time-picker.styles.d.ts +6 -0
- package/src/components/molecules/bare-time-picker/bare-time-picker.styles.js +14 -8
- package/src/components/molecules/calendar-select/calendar-select.component.d.ts +2 -1
- package/src/components/molecules/calendar-select/calendar-select.component.tsx +76 -73
- package/src/components/molecules/calendar-select/calendar-select.styles.d.ts +31 -31
- package/src/components/molecules/calendar-select/calendar-select.styles.js +33 -33
- package/src/components/molecules/context-label/context-label.component.tsx +21 -23
- package/src/components/molecules/context-label/context-label.preview.tsx +45 -30
- package/src/components/molecules/context-label/context-label.styles.d.ts +7 -5
- package/src/components/molecules/date-input/date-input.styles.d.ts +16 -16
- package/src/components/molecules/day/day.component.d.ts +10 -6
- package/src/components/molecules/default-select/default-select.styles.d.ts +11 -11
- package/src/components/molecules/filter-range/filter-range.styles.d.ts +20 -20
- package/src/components/molecules/filter-tab/filter-tab.styles.d.ts +58 -53
- package/src/components/molecules/info/info.component.tsx +13 -5
- package/src/components/molecules/info/info.preview.tsx +4 -5
- package/src/components/molecules/info/info.styles.d.ts +14 -14
- package/src/components/molecules/inline-error/inline-error.component.tsx +10 -3
- package/src/components/molecules/inline-error/inline-error.preview.tsx +4 -2
- package/src/components/molecules/inline-error/inline-error.styles.d.ts +16 -16
- package/src/components/molecules/inline-error/inline-error.styles.js +2 -2
- package/src/components/molecules/inline-notice/inline-notice.component.tsx +16 -12
- package/src/components/molecules/inline-notice/inline-notice.preview.tsx +4 -2
- package/src/components/molecules/inline-notice/inline-notice.styles.d.ts +16 -16
- package/src/components/molecules/inline-notice/inline-notice.styles.js +18 -18
- package/src/components/molecules/message-input/message-input.styles.d.ts +31 -31
- package/src/components/molecules/password-input/password-input.component.tsx +1 -1
- package/src/components/molecules/password-input/password-input.styles.d.ts +27 -27
- package/src/components/molecules/quick-filter/quick-filter.component.tsx +1 -1
- package/src/components/molecules/quick-filter/quick-filter.preview.tsx +1 -1
- package/src/components/molecules/quick-filter/quick-filter.styles.js +1 -1
- package/src/components/molecules/search-input/search.styles.d.ts +31 -31
- package/src/components/molecules/select-list-item/select-list-item.component.d.ts +1 -1
- package/src/components/molecules/select-list-item/select-list-item.component.tsx +13 -9
- package/src/components/molecules/select-list-item/select-list-item.styles.d.ts +27 -22
- package/src/components/molecules/select-picker/select-picker.styles.d.ts +30 -30
- package/src/components/molecules/selectable-list-item/selectable-list-item-preview.tsx +1 -1
- package/src/components/molecules/selectable-list-item/selectable-list-item.component.d.ts +1 -1
- package/src/components/molecules/selectable-list-item/selectable-list-item.component.tsx +17 -5
- package/src/components/molecules/selectable-list-item/selectable-list-item.styles.d.ts +31 -27
- package/src/components/molecules/swipe/swipe.component.native.tsx +78 -0
- package/src/components/molecules/swipe/swipe.component.tsx +5 -63
- package/src/components/molecules/time-picker/time-picker.component.tsx +8 -2
- package/src/components/molecules/time-picker/time-picker.styles.d.ts +25 -25
- package/src/components/molecules/wide-button/wide-button.styles.d.ts +14 -10
- package/src/components/organisms/child-list-item/child-list-item.component.d.ts +1 -1
- package/src/components/organisms/child-list-item/child-list-item.component.tsx +29 -26
- package/src/components/organisms/child-list-item/child-list-item.styles.d.ts +56 -53
- package/src/components/organisms/child-list-item/child-list-item.styles.js +5 -5
- package/src/components/organisms/contact-item/contact-item.styles.d.ts +13 -13
- package/src/components/organisms/journal-entry/components/journal-entry-type/journal-entry-type.component.d.ts +1 -1
- package/src/components/organisms/journal-entry/components/journal-entry-type/journal-entry-type.component.tsx +5 -4
- package/src/components/organisms/journal-entry/journal-entry.component.d.ts +1 -1
- package/src/components/organisms/journal-entry/journal-entry.styles.d.ts +25 -22
- package/src/components/organisms/my-child-list-item/my-child-list-item.styles.d.ts +31 -31
- package/src/components/organisms/text-bubble/text-bubble.styles.d.ts +14 -14
- package/src/components/organisms/timetable-edit/timetable-edit.component.d.ts +1 -1
- package/src/components/organisms/timetable-edit/timetable-edit.component.tsx +58 -56
- package/src/components/organisms/timetable-edit/timetable-edit.preview.tsx +20 -18
- package/src/components/organisms/timetable-edit/timetable-edit.styles.d.ts +19 -19
- package/src/components/organisms/timetable-edit/timetable-edit.styles.js +21 -21
- package/src/components/organisms/timetable-editor/components/timetable-edit-wrapper.d.ts +4 -4
- package/src/components/organisms/timetable-editor/components/timetable-edit-wrapper.tsx +65 -58
- package/src/components/organisms/timetable-editor/timetable-editor-staff.component.d.ts +8 -0
- package/src/components/organisms/timetable-editor/timetable-editor-staff.component.tsx +66 -47
- package/src/components/organisms/timetable-editor/timetable-editor.component.d.ts +2 -2
- package/src/components/organisms/timetable-editor/timetable-editor.component.tsx +76 -53
- package/src/components/organisms/timetable-editor/timetable-editor.preview.tsx +7 -7
- package/src/components/organisms/timetable-editor/timetable-editor.styles.d.ts +6 -6
- package/src/components/organisms/timetable-editor/timetable-editor.styles.js +8 -8
- package/src/components/templates/modal/components/fade-panel.styles.d.ts +17 -13
- package/src/components/templates/modal/modal.styles.d.ts +21 -21
- package/src/components/templates/popover/components/foreground/foreground.styles.d.ts +10 -10
- package/src/components/templates/popover/components/modal/heading/heading.styles.d.ts +12 -12
- package/src/components/templates/popover/components/modal/modal.styles.d.ts +17 -17
- package/src/components/templates/popover/popover.styles.d.ts +9 -9
- package/src/components/templates/popover-action/popover-action.component.d.ts +8 -4
- package/src/components/templates/popover-action/popover-action.component.tsx +7 -4
- package/src/components/templates/popover-action/popover-action.styles.d.ts +26 -26
- package/src/context/theme.context.ts +4 -4
- package/src/hooks/use-debounce.ts +8 -8
- package/src/icons/crown.icon.tsx +18 -5
- package/src/icons/outline/outline-default.preview.tsx +2 -2
- package/src/icons/outline/outline.tsx +4 -4
- package/src/icons/outline/photograph/photograph.icon.tsx +3 -6
- package/src/icons/solid/photograph/photograph-solid.icon.tsx +4 -4
- package/src/icons/solid/share/share.icon.tsx +1 -3
- package/src/icons/solid/solid.tsx +4 -4
- package/src/models/time-slot-sequence.ts +13 -9
- package/src/theme/provider/parent.theme.ts +4 -4
- package/src/theme/provider/staff-member.theme.ts +4 -4
- package/src/types/state.enum.ts +5 -5
- package/src/utilities/color-handler/color-handler.ts +2 -3
- package/tsconfig.json +2 -1
- package/src/components/organisms/day-select/day-select.component.d.ts +0 -9
- package/src/components/organisms/day-select/day-select.component.tsx +0 -108
- package/src/components/organisms/day-select/day-select.preview.d.ts +0 -2
- package/src/components/organisms/day-select/day-select.preview.tsx +0 -23
- package/src/components/organisms/day-select/day-select.styles.d.ts +0 -18
- package/src/components/organisms/day-select/day-select.styles.js +0 -22
- package/src/components/organisms/tab-view/__snapshots__/tab-view.test.js.snap +0 -421
- package/src/components/organisms/tab-view/tab-view.component.d.ts +0 -12
- package/src/components/organisms/tab-view/tab-view.component.tsx +0 -49
- package/src/components/organisms/tab-view/tab-view.preview.d.ts +0 -2
- package/src/components/organisms/tab-view/tab-view.preview.tsx +0 -37
- package/src/components/organisms/tab-view/tab-view.styles.d.ts +0 -10
- package/src/components/organisms/tab-view/tab-view.styles.js +0 -14
- package/src/components/organisms/tab-view/tab-view.test.js +0 -37
|
@@ -1,84 +1,102 @@
|
|
|
1
|
-
export function Stylesheet(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
backgroundColor: string;
|
|
21
|
-
shadowColor?: undefined;
|
|
22
|
-
shadowOpacity?: undefined;
|
|
23
|
-
shadowRadius?: undefined;
|
|
24
|
-
shadowOffset?: undefined;
|
|
25
|
-
elevation?: undefined;
|
|
26
|
-
width?: undefined;
|
|
27
|
-
height?: undefined;
|
|
28
|
-
borderRadius?: undefined;
|
|
29
|
-
} | {
|
|
30
|
-
shadowColor: any;
|
|
31
|
-
shadowOpacity: number;
|
|
32
|
-
shadowRadius: number;
|
|
33
|
-
shadowOffset: {
|
|
1
|
+
export function Stylesheet(
|
|
2
|
+
context: any,
|
|
3
|
+
size: any,
|
|
4
|
+
isBlocked: any,
|
|
5
|
+
isActive: any
|
|
6
|
+
):
|
|
7
|
+
| StyleSheet.NamedStyles<any>
|
|
8
|
+
| StyleSheet.NamedStyles<{
|
|
9
|
+
container: (
|
|
10
|
+
| {
|
|
11
|
+
overflow: string;
|
|
12
|
+
backgroundColor: any;
|
|
13
|
+
justifyContent: string;
|
|
14
|
+
alignItems: string;
|
|
15
|
+
width?: undefined;
|
|
16
|
+
height?: undefined;
|
|
17
|
+
borderRadius?: undefined;
|
|
18
|
+
}
|
|
19
|
+
| {
|
|
34
20
|
width: number;
|
|
35
21
|
height: number;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
22
|
+
borderRadius: number;
|
|
23
|
+
overflow?: undefined;
|
|
24
|
+
backgroundColor?: undefined;
|
|
25
|
+
justifyContent?: undefined;
|
|
26
|
+
alignItems?: undefined;
|
|
27
|
+
}
|
|
28
|
+
)[];
|
|
29
|
+
shadow: (
|
|
30
|
+
| {
|
|
31
|
+
backgroundColor: string;
|
|
32
|
+
shadowColor?: undefined;
|
|
33
|
+
shadowOpacity?: undefined;
|
|
34
|
+
shadowRadius?: undefined;
|
|
35
|
+
shadowOffset?: undefined;
|
|
36
|
+
elevation?: undefined;
|
|
37
|
+
width?: undefined;
|
|
38
|
+
height?: undefined;
|
|
39
|
+
borderRadius?: undefined;
|
|
40
|
+
}
|
|
41
|
+
| {
|
|
42
|
+
shadowColor: any;
|
|
43
|
+
shadowOpacity: number;
|
|
44
|
+
shadowRadius: number;
|
|
45
|
+
shadowOffset: {
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
};
|
|
49
|
+
backgroundColor?: undefined;
|
|
50
|
+
elevation?: undefined;
|
|
51
|
+
width?: undefined;
|
|
52
|
+
height?: undefined;
|
|
53
|
+
borderRadius?: undefined;
|
|
54
|
+
}
|
|
55
|
+
| {
|
|
56
|
+
elevation: number;
|
|
57
|
+
shadowColor: any;
|
|
58
|
+
backgroundColor?: undefined;
|
|
59
|
+
shadowOpacity?: undefined;
|
|
60
|
+
shadowRadius?: undefined;
|
|
61
|
+
shadowOffset?: undefined;
|
|
62
|
+
width?: undefined;
|
|
63
|
+
height?: undefined;
|
|
64
|
+
borderRadius?: undefined;
|
|
65
|
+
}
|
|
66
|
+
| {
|
|
67
|
+
width: number;
|
|
68
|
+
height: number;
|
|
69
|
+
borderRadius: number;
|
|
70
|
+
backgroundColor?: undefined;
|
|
71
|
+
shadowColor?: undefined;
|
|
72
|
+
shadowOpacity?: undefined;
|
|
73
|
+
shadowRadius?: undefined;
|
|
74
|
+
shadowOffset?: undefined;
|
|
75
|
+
elevation?: undefined;
|
|
76
|
+
}
|
|
77
|
+
)[];
|
|
78
|
+
image: {
|
|
64
79
|
position: string;
|
|
65
80
|
width: string;
|
|
66
81
|
height: string;
|
|
67
82
|
borderRadius: number;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
textTransform:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
}[];
|
|
84
|
+
text: {
|
|
85
|
+
textTransform: 'uppercase';
|
|
86
|
+
};
|
|
87
|
+
crownContainer: (
|
|
88
|
+
| {
|
|
89
|
+
position: string;
|
|
90
|
+
zIndex: number;
|
|
91
|
+
top?: undefined;
|
|
92
|
+
left?: undefined;
|
|
93
|
+
}
|
|
94
|
+
| {
|
|
95
|
+
top: number;
|
|
96
|
+
left: number;
|
|
97
|
+
position?: undefined;
|
|
98
|
+
zIndex?: undefined;
|
|
99
|
+
}
|
|
100
|
+
)[];
|
|
101
|
+
}>;
|
|
102
|
+
import {StyleSheet} from 'react-native';
|
|
@@ -69,20 +69,22 @@ export const Stylesheet = (context, size, isBlocked, isActive) =>
|
|
|
69
69
|
text: {
|
|
70
70
|
textTransform: 'uppercase',
|
|
71
71
|
},
|
|
72
|
-
crownContainer:[
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
72
|
+
crownContainer: [
|
|
73
|
+
{
|
|
74
|
+
position: 'absolute',
|
|
75
|
+
zIndex: 999,
|
|
76
|
+
},
|
|
77
|
+
size === Size.SMALL && {
|
|
78
|
+
top: -10,
|
|
79
|
+
left: -5,
|
|
80
|
+
},
|
|
81
|
+
size === Size.MEDIUM && {
|
|
82
|
+
top: -6,
|
|
83
|
+
left: 0,
|
|
84
|
+
},
|
|
85
|
+
size === Size.LARGE && {
|
|
86
|
+
top: -2,
|
|
87
|
+
left: 10,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
88
90
|
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {useContext} from 'react';
|
|
2
|
+
import {ThemeCtx} from '../../../context/theme.context';
|
|
3
|
+
import {Stylesheet} from './bare-time-picker.styles';
|
|
4
|
+
import {View} from 'react-native';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import WheelPicker from 'react-native-wheely';
|
|
7
|
+
import {Scale} from '../../../theme/scale';
|
|
8
|
+
|
|
9
|
+
interface BareTimePickerProps {
|
|
10
|
+
initialHours: string;
|
|
11
|
+
initialMinutes: string;
|
|
12
|
+
onChangeHours: (value: string) => void;
|
|
13
|
+
onChangeMinutes: (value: string) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const HOURS: string[] = [
|
|
17
|
+
'',
|
|
18
|
+
...Array.from({length: 24}, (_, i) => i.toString().padStart(2, '0')),
|
|
19
|
+
];
|
|
20
|
+
const MINUTES: string[] = [
|
|
21
|
+
'',
|
|
22
|
+
...Array.from({length: 60}, (_, i) => i.toString().padStart(2, '0')),
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export const BareTimePicker = ({
|
|
26
|
+
initialHours,
|
|
27
|
+
initialMinutes,
|
|
28
|
+
onChangeHours,
|
|
29
|
+
onChangeMinutes,
|
|
30
|
+
}: BareTimePickerProps) => {
|
|
31
|
+
const context = useContext(ThemeCtx);
|
|
32
|
+
const styles = Stylesheet(context);
|
|
33
|
+
|
|
34
|
+
const initialIndexHandler = (dataArray: string[], value: string): number => {
|
|
35
|
+
return dataArray.findIndex((element) => element === value);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<View style={styles.rootContainer}>
|
|
40
|
+
<WheelPicker
|
|
41
|
+
options={HOURS.map((value) => (value == '' ? '--' : value))}
|
|
42
|
+
onChange={(index) => onChangeHours(HOURS[index])}
|
|
43
|
+
selectedIndex={initialIndexHandler(HOURS, initialHours)}
|
|
44
|
+
visibleRest={1}
|
|
45
|
+
selectedIndicatorStyle={{
|
|
46
|
+
borderRadius: 0,
|
|
47
|
+
backgroundColor: context.colors.main[9],
|
|
48
|
+
}}
|
|
49
|
+
containerStyle={{
|
|
50
|
+
backgroundColor: context.colors.ui.xlightgrey,
|
|
51
|
+
width: '50%',
|
|
52
|
+
borderTopLeftRadius: Scale.xxs,
|
|
53
|
+
borderBottomLeftRadius: Scale.xxs,
|
|
54
|
+
}}
|
|
55
|
+
itemTextStyle={{fontSize: Scale.l}}
|
|
56
|
+
scaleFunction={(x) => x / 1.5}
|
|
57
|
+
/>
|
|
58
|
+
<WheelPicker
|
|
59
|
+
options={MINUTES.map((value) => (value == '' ? '--' : value))}
|
|
60
|
+
onChange={(index) => onChangeMinutes(MINUTES[index])}
|
|
61
|
+
selectedIndex={initialIndexHandler(MINUTES, initialMinutes)}
|
|
62
|
+
visibleRest={1}
|
|
63
|
+
selectedIndicatorStyle={{
|
|
64
|
+
borderRadius: 0,
|
|
65
|
+
backgroundColor: context.colors.main[9],
|
|
66
|
+
}}
|
|
67
|
+
containerStyle={{
|
|
68
|
+
backgroundColor: context.colors.ui.xlightgrey,
|
|
69
|
+
width: '50%',
|
|
70
|
+
borderTopRightRadius: Scale.xxs,
|
|
71
|
+
borderBottomRightRadius: Scale.xxs,
|
|
72
|
+
}}
|
|
73
|
+
itemTextStyle={{fontSize: Scale.l}}
|
|
74
|
+
scaleFunction={(x) => x / 1.5}
|
|
75
|
+
/>
|
|
76
|
+
</View>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
@@ -1,80 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import React from
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
1
|
+
import {useContext} from 'react';
|
|
2
|
+
import {ThemeCtx} from '../../../context/theme.context';
|
|
3
|
+
import {Stylesheet} from './bare-time-picker.styles';
|
|
4
|
+
import {View} from 'react-native';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { SelectPicker } from '../select-picker/select-picker.component';
|
|
7
|
+
import { Paragraph } from '../../atoms/paragraph-components';
|
|
8
|
+
import { Scale } from '../../../theme/scale';
|
|
9
9
|
|
|
10
10
|
interface BareTimePickerProps {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
initialHours: string;
|
|
12
|
+
initialMinutes: string;
|
|
13
|
+
onChangeHours: (value: string) => void;
|
|
14
|
+
onChangeMinutes: (value: string) => void;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const HOURS: string[] = [
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
'',
|
|
19
|
+
...Array.from({length: 24}, (_, i) => i.toString().padStart(2, '0')),
|
|
20
20
|
];
|
|
21
21
|
const MINUTES: string[] = [
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
'',
|
|
23
|
+
...Array.from({length: 60}, (_, i) => i.toString().padStart(2, '0')),
|
|
24
24
|
];
|
|
25
25
|
|
|
26
|
-
|
|
27
26
|
export const BareTimePicker = ({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
initialHours,
|
|
28
|
+
initialMinutes,
|
|
29
|
+
onChangeHours,
|
|
30
|
+
onChangeMinutes,
|
|
32
31
|
}: BareTimePickerProps) => {
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const context = useContext(ThemeCtx);
|
|
33
|
+
const styles = Stylesheet(context);
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const hourItems = HOURS.map((el) => {
|
|
36
|
+
return {value: el, label: el}
|
|
37
|
+
});
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
borderTopLeftRadius:Scale.xxs,
|
|
55
|
-
borderBottomLeftRadius:Scale.xxs,
|
|
56
|
-
}}
|
|
57
|
-
itemTextStyle={{fontSize: Scale.l}}
|
|
58
|
-
scaleFunction={(x) => x/1.5}
|
|
59
|
-
/>
|
|
60
|
-
<WheelPicker
|
|
61
|
-
options={MINUTES.map((value) => (value == '' ? '--' : value))}
|
|
62
|
-
onChange={(index) => onChangeMinutes(MINUTES[index])}
|
|
63
|
-
selectedIndex={initialIndexHandler(MINUTES, initialMinutes)}
|
|
64
|
-
visibleRest={1}
|
|
65
|
-
selectedIndicatorStyle={{
|
|
66
|
-
borderRadius: 0,
|
|
67
|
-
backgroundColor: context.colors.main[9]
|
|
68
|
-
}}
|
|
69
|
-
containerStyle={{
|
|
70
|
-
backgroundColor: context.colors.ui.xlightgrey,
|
|
71
|
-
width: '50%',
|
|
72
|
-
borderTopRightRadius:Scale.xxs,
|
|
73
|
-
borderBottomRightRadius:Scale.xxs,
|
|
74
|
-
}}
|
|
75
|
-
itemTextStyle={{fontSize: Scale.l}}
|
|
76
|
-
scaleFunction={(x) => x/1.5}
|
|
77
|
-
/>
|
|
78
|
-
</View>
|
|
79
|
-
)
|
|
80
|
-
}
|
|
39
|
+
const minuteItems = MINUTES.map((el) => {
|
|
40
|
+
return {value: el, label: el}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<View style={styles.webRootContainer}>
|
|
45
|
+
<View style={{flexDirection: 'row', alignItems: 'center', justifyContent: 'center'}}>
|
|
46
|
+
<SelectPicker data={hourItems} onChange={onChangeHours} defaultValue={initialHours} />
|
|
47
|
+
<Paragraph addStyle={{paddingHorizontal: Scale.s}}>:</Paragraph>
|
|
48
|
+
<SelectPicker data={minuteItems} onChange={onChangeMinutes} defaultValue={initialMinutes} />
|
|
49
|
+
</View>
|
|
50
|
+
</View>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -6,7 +6,7 @@ import {Avatar} from '../avatar/avatar.component';
|
|
|
6
6
|
import {Initials} from '../../../models/initials.model';
|
|
7
7
|
import {Size} from '../../../types/size.enum';
|
|
8
8
|
import {Modal} from '../../templates/modal/modal.component';
|
|
9
|
-
import {
|
|
9
|
+
import {BareTimePicker} from './bare-time-picker.component';
|
|
10
10
|
|
|
11
11
|
export const BareTimePickerPreview = ({}: {}) => {
|
|
12
12
|
const [popoverIsVisible, setPopoverIsVisible] = useState(false);
|
|
@@ -2,11 +2,17 @@ import {StyleSheet} from 'react-native';
|
|
|
2
2
|
import {Scale} from '../../../theme/scale/index';
|
|
3
3
|
|
|
4
4
|
export const Stylesheet = (context) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
StyleSheet.create({
|
|
6
|
+
rootContainer: {
|
|
7
|
+
flexDirection: 'row',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
width: '100%',
|
|
10
|
+
maxWidth: 200,
|
|
11
|
+
},
|
|
12
|
+
webRootContainer: {
|
|
13
|
+
flexDirection: 'row',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
justifyContent: 'center',
|
|
16
|
+
width: '100%',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
@@ -4,6 +4,7 @@ type CalendarSelectProps = {
|
|
|
4
4
|
onPressDate: (date: ToddleDateTime) => void;
|
|
5
5
|
startDate: ToddleDateTime;
|
|
6
6
|
onUpdateDate: (date: ToddleDateTime) => void;
|
|
7
|
+
labelForToday?: string | undefined;
|
|
7
8
|
};
|
|
8
|
-
declare const CalendarSelect: ({ onPressDate, startDate, onUpdateDate, }: CalendarSelectProps) => React.JSX.Element;
|
|
9
|
+
declare const CalendarSelect: ({ onPressDate, startDate, onUpdateDate, labelForToday, }: CalendarSelectProps) => React.JSX.Element;
|
|
9
10
|
export { CalendarSelect as CalendarSelect };
|
|
@@ -6,90 +6,93 @@ import {Stylesheet} from './calendar-select.styles';
|
|
|
6
6
|
import {Pressable, View} from 'react-native';
|
|
7
7
|
import {Paragraph} from '../../atoms/paragraph-components';
|
|
8
8
|
import {Icon} from '../../../icons/index';
|
|
9
|
-
import {
|
|
9
|
+
import {useDebounce} from '../../../hooks/use-debounce';
|
|
10
10
|
|
|
11
11
|
type CalendarSelectProps = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
onPressDate: (date: ToddleDateTime) => void;
|
|
13
|
+
startDate: ToddleDateTime;
|
|
14
|
+
onUpdateDate: (date: ToddleDateTime) => void;
|
|
15
|
+
labelForToday?: string | undefined;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const CalendarSelect = ({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
onPressDate,
|
|
20
|
+
startDate,
|
|
21
|
+
onUpdateDate,
|
|
22
|
+
labelForToday,
|
|
23
|
+
}: CalendarSelectProps) => {
|
|
24
|
+
const context = useContext(ThemeCtx);
|
|
25
|
+
const styles = Stylesheet(context);
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const [visibleDate, setVisibleDate] = useState(startDate);
|
|
28
|
+
const debouncedVisibleDate = useDebounce<ToddleDateTime>(visibleDate, 500);
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const today = ToddleDateTime.now();
|
|
31
|
+
const format = 'yyyy-LL-dd';
|
|
32
|
+
const isToday = today.toFormat(format) == visibleDate.toFormat(format);
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
setVisibleDate(startDate);
|
|
36
|
+
}, [startDate]);
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
// If they are the same dont trigger event again.
|
|
40
|
+
if (visibleDate !== startDate) {
|
|
41
|
+
onUpdateDate(debouncedVisibleDate);
|
|
42
|
+
}
|
|
43
|
+
}, [debouncedVisibleDate]);
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
45
|
+
return (
|
|
46
|
+
<View style={styles.container}>
|
|
47
|
+
<Pressable
|
|
48
|
+
onPress={() => {
|
|
49
|
+
setVisibleDate(visibleDate.minus({days: 1}));
|
|
50
|
+
}}
|
|
51
|
+
style={styles.arrowContainer}
|
|
52
|
+
>
|
|
53
|
+
<Icon
|
|
54
|
+
style={'regular'}
|
|
55
|
+
name={'chevron-left'}
|
|
56
|
+
color={context.colors.main['9']}
|
|
57
|
+
/>
|
|
58
|
+
</Pressable>
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
</View>
|
|
71
|
-
<Paragraph textColor={context.colors.main['9']} textAlign={'center'} >
|
|
72
|
-
{
|
|
73
|
-
isToday && labelForToday ?
|
|
74
|
-
labelForToday :
|
|
75
|
-
visibleDate.toLocaleString({weekday: 'short', day: 'numeric', month: 'short', year: 'numeric'})
|
|
76
|
-
}
|
|
77
|
-
</Paragraph>
|
|
78
|
-
</Pressable>
|
|
79
|
-
|
|
80
|
-
<Pressable
|
|
81
|
-
onPress={() => {
|
|
82
|
-
setVisibleDate(visibleDate.plus({days: 1}));
|
|
83
|
-
}}
|
|
84
|
-
style={styles.arrowContainer}
|
|
85
|
-
>
|
|
86
|
-
<Icon
|
|
87
|
-
style={'regular'}
|
|
88
|
-
name={'chevron-right'}
|
|
89
|
-
color={context.colors.main['9']}
|
|
90
|
-
/>
|
|
91
|
-
</Pressable>
|
|
60
|
+
<Pressable
|
|
61
|
+
onPress={() => onPressDate(visibleDate)}
|
|
62
|
+
style={styles.dateContainer}
|
|
63
|
+
>
|
|
64
|
+
<View style={styles.icon}>
|
|
65
|
+
<Icon
|
|
66
|
+
style={'regular'}
|
|
67
|
+
name={'calendar'}
|
|
68
|
+
color={context.colors.main['9']}
|
|
69
|
+
/>
|
|
92
70
|
</View>
|
|
93
|
-
|
|
71
|
+
<Paragraph textColor={context.colors.main['9']} textAlign={'center'}>
|
|
72
|
+
{isToday && labelForToday
|
|
73
|
+
? labelForToday
|
|
74
|
+
: visibleDate.toLocaleString({
|
|
75
|
+
weekday: 'short',
|
|
76
|
+
day: 'numeric',
|
|
77
|
+
month: 'short',
|
|
78
|
+
year: 'numeric',
|
|
79
|
+
})}
|
|
80
|
+
</Paragraph>
|
|
81
|
+
</Pressable>
|
|
82
|
+
|
|
83
|
+
<Pressable
|
|
84
|
+
onPress={() => {
|
|
85
|
+
setVisibleDate(visibleDate.plus({days: 1}));
|
|
86
|
+
}}
|
|
87
|
+
style={styles.arrowContainer}
|
|
88
|
+
>
|
|
89
|
+
<Icon
|
|
90
|
+
style={'regular'}
|
|
91
|
+
name={'chevron-right'}
|
|
92
|
+
color={context.colors.main['9']}
|
|
93
|
+
/>
|
|
94
|
+
</Pressable>
|
|
95
|
+
</View>
|
|
96
|
+
);
|
|
94
97
|
};
|
|
95
98
|
export {CalendarSelect as CalendarSelect};
|