@utilitywarehouse/hearth-react-native 0.3.0 → 0.4.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/.storybook/preview.tsx +3 -0
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +3 -1
- package/CHANGELOG.md +22 -0
- package/build/components/Alert/AlertCloseButton.js +25 -3
- package/build/components/Alert/AlertIcon.js +17 -1
- package/build/components/Alert/AlertIconButton.js +27 -1
- package/build/components/Alert/AlertLink.js +47 -1
- package/build/components/Alert/AlertText.d.ts +1 -1
- package/build/components/Alert/AlertText.js +26 -2
- package/build/components/Alert/AlertTitle.d.ts +1 -1
- package/build/components/Alert/AlertTitle.js +26 -2
- package/build/components/Badge/BadgeIcon.js +72 -0
- package/build/components/Badge/BadgeText.js +72 -0
- package/build/components/Button/ButtonRoot.js +1 -0
- package/build/components/Checkbox/Checkbox.d.ts +2 -2
- package/build/components/Checkbox/Checkbox.js +11 -10
- package/build/components/Checkbox/Checkbox.props.d.ts +3 -1
- package/build/components/Checkbox/CheckboxIcon.js +1 -1
- package/build/components/Checkbox/CheckboxImage.d.ts +6 -0
- package/build/components/Checkbox/CheckboxImage.js +5 -0
- package/build/components/Checkbox/CheckboxTileRoot.js +1 -1
- package/build/components/Checkbox/index.d.ts +3 -2
- package/build/components/Checkbox/index.js +2 -1
- package/build/components/CurrencyInput/CurrencyInput.js +1 -1
- package/build/components/DatePicker/DatePicker.context.d.ts +19 -0
- package/build/components/DatePicker/DatePicker.context.js +3 -0
- package/build/components/DatePicker/DatePicker.d.ts +19 -0
- package/build/components/DatePicker/DatePicker.js +479 -0
- package/build/components/DatePicker/DatePicker.props.d.ts +125 -0
- package/build/components/DatePicker/DatePicker.props.js +1 -0
- package/build/components/DatePicker/DatePickerCalendar.d.ts +2 -0
- package/build/components/DatePicker/DatePickerCalendar.js +28 -0
- package/build/components/DatePicker/DatePickerDay.d.ts +11 -0
- package/build/components/DatePicker/DatePickerDay.js +242 -0
- package/build/components/DatePicker/DatePickerDays.d.ts +2 -0
- package/build/components/DatePicker/DatePickerDays.js +157 -0
- package/build/components/DatePicker/DatePickerFooter.d.ts +2 -0
- package/build/components/DatePicker/DatePickerFooter.js +23 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerHeader.props.d.ts +8 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerHeader.props.js +1 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerMonthButton.d.ts +2 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerMonthButton.js +14 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerNextButton.d.ts +2 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerNextButton.js +32 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerPrevButton.d.ts +2 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerPrevButton.js +32 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerSelectors.d.ts +6 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerSelectors.js +64 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerTimeButton.d.ts +1 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerTimeButton.js +22 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerYearButton.d.ts +2 -0
- package/build/components/DatePicker/DatePickerHeader/DatePickerYearButton.js +25 -0
- package/build/components/DatePicker/DatePickerHeader/index.d.ts +3 -0
- package/build/components/DatePicker/DatePickerHeader/index.js +30 -0
- package/build/components/DatePicker/DatePickerMonths.d.ts +2 -0
- package/build/components/DatePicker/DatePickerMonths.js +69 -0
- package/build/components/DatePicker/DatePickerWeekdays.d.ts +8 -0
- package/build/components/DatePicker/DatePickerWeekdays.js +26 -0
- package/build/components/DatePicker/DatePickerYears.d.ts +2 -0
- package/build/components/DatePicker/DatePickerYears.js +83 -0
- package/build/components/DatePicker/TimePicker.d.ts +3 -0
- package/build/components/DatePicker/TimePicker.js +84 -0
- package/build/components/DatePicker/enums.d.ts +12 -0
- package/build/components/DatePicker/enums.js +12 -0
- package/build/components/DatePicker/index.d.ts +4 -0
- package/build/components/DatePicker/index.js +3 -0
- package/build/components/DatePicker/polyfill.d.ts +0 -0
- package/build/components/DatePicker/polyfill.js +22 -0
- package/build/components/DatePicker/time-picker/animated-math.d.ts +4 -0
- package/build/components/DatePicker/time-picker/animated-math.js +19 -0
- package/build/components/DatePicker/time-picker/period-native.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-native.js +17 -0
- package/build/components/DatePicker/time-picker/period-picker.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-picker.js +10 -0
- package/build/components/DatePicker/time-picker/period-web.d.ts +6 -0
- package/build/components/DatePicker/time-picker/period-web.js +21 -0
- package/build/components/DatePicker/time-picker/wheel-native.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel-native.js +19 -0
- package/build/components/DatePicker/time-picker/wheel-picker/index.d.ts +2 -0
- package/build/components/DatePicker/time-picker/wheel-picker/index.js +2 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.d.ts +16 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.js +97 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.d.ts +21 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.js +88 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.d.ts +23 -0
- package/build/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.js +21 -0
- package/build/components/DatePicker/time-picker/wheel-web.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel-web.js +148 -0
- package/build/components/DatePicker/time-picker/wheel.d.ts +8 -0
- package/build/components/DatePicker/time-picker/wheel.js +10 -0
- package/build/components/DatePicker/utils.d.ts +212 -0
- package/build/components/DatePicker/utils.js +391 -0
- package/build/components/DatePickerInput/DatePickerInput.d.ts +6 -0
- package/build/components/DatePickerInput/DatePickerInput.js +126 -0
- package/build/components/DatePickerInput/DatePickerInput.props.d.ts +47 -0
- package/build/components/DatePickerInput/DatePickerInput.props.js +1 -0
- package/build/components/DatePickerInput/DatePickerInputDoneButton.d.ts +8 -0
- package/build/components/DatePickerInput/DatePickerInputDoneButton.js +19 -0
- package/build/components/DatePickerInput/DatePickerInputDoneButton.web.d.ts +5 -0
- package/build/components/DatePickerInput/DatePickerInputDoneButton.web.js +5 -0
- package/build/components/DatePickerInput/index.d.ts +2 -0
- package/build/components/DatePickerInput/index.js +1 -0
- package/build/components/Input/InputField.d.ts +1 -1
- package/build/components/Input/InputField.js +1 -1
- package/build/components/Input/InputSlot.d.ts +1 -1
- package/build/components/Input/InputSlot.js +3 -3
- package/build/components/Link/Link.d.ts +1 -1
- package/build/components/Link/Link.js +4 -4
- package/build/components/Link/Link.props.d.ts +3 -0
- package/build/components/Radio/Radio.d.ts +2 -2
- package/build/components/Radio/Radio.js +9 -8
- package/build/components/Radio/Radio.props.d.ts +3 -1
- package/build/components/Radio/RadioImage.d.ts +6 -0
- package/build/components/Radio/RadioImage.js +5 -0
- package/build/components/Radio/RadioTileRoot.js +1 -1
- package/build/components/Radio/index.d.ts +3 -2
- package/build/components/Radio/index.js +2 -1
- package/build/components/Select/SelectOption.js +1 -7
- package/build/components/UnstyledIconButton/UnstyledIconButton.d.ts +1 -1
- package/build/components/UnstyledIconButton/UnstyledIconButton.js +5 -5
- package/build/components/UnstyledIconButton/UnstyledIconButton.props.d.ts +2 -1
- package/build/components/UnstyledIconButton/UnstyledIconButtonRoot.js +1 -1
- package/build/components/index.d.ts +2 -0
- package/build/components/index.js +2 -0
- package/build/core/themes.d.ts +12 -12
- package/build/hooks/index.d.ts +4 -3
- package/build/hooks/index.js +4 -3
- package/build/hooks/usePrevious.d.ts +1 -0
- package/build/hooks/usePrevious.js +8 -0
- package/build/hooks/useTheme.d.ts +2 -1
- package/build/hooks/useTheme.js +2 -2
- package/build/tokens/color.d.ts +12 -12
- package/build/tokens/color.js +6 -6
- package/build/tokens/components/dark/alert.d.ts +13 -0
- package/build/tokens/components/dark/alert.js +13 -0
- package/build/tokens/components/dark/checkbox.d.ts +3 -0
- package/build/tokens/components/dark/checkbox.js +3 -0
- package/build/tokens/components/dark/date-picker.d.ts +1 -0
- package/build/tokens/components/dark/date-picker.js +1 -0
- package/build/tokens/components/dark/icon-button.d.ts +7 -0
- package/build/tokens/components/dark/icon-button.js +7 -0
- package/build/tokens/components/dark/illustrations.d.ts +7 -0
- package/build/tokens/components/dark/illustrations.js +6 -0
- package/build/tokens/components/dark/index.d.ts +2 -0
- package/build/tokens/components/dark/index.js +2 -0
- package/build/tokens/components/dark/link.d.ts +5 -0
- package/build/tokens/components/dark/link.js +5 -0
- package/build/tokens/components/dark/progress-bar.d.ts +41 -0
- package/build/tokens/components/dark/progress-bar.js +40 -0
- package/build/tokens/components/dark/segmented-control.d.ts +2 -2
- package/build/tokens/components/dark/segmented-control.js +2 -2
- package/build/tokens/components/dark/table.d.ts +3 -0
- package/build/tokens/components/dark/table.js +3 -0
- package/build/tokens/components/light/alert.d.ts +13 -0
- package/build/tokens/components/light/alert.js +13 -0
- package/build/tokens/components/light/checkbox.d.ts +3 -0
- package/build/tokens/components/light/checkbox.js +3 -0
- package/build/tokens/components/light/date-picker.d.ts +1 -0
- package/build/tokens/components/light/date-picker.js +1 -0
- package/build/tokens/components/light/icon-button.d.ts +7 -0
- package/build/tokens/components/light/icon-button.js +7 -0
- package/build/tokens/components/light/illustrations.d.ts +7 -0
- package/build/tokens/components/light/illustrations.js +6 -0
- package/build/tokens/components/light/index.d.ts +2 -0
- package/build/tokens/components/light/index.js +2 -0
- package/build/tokens/components/light/link.d.ts +5 -0
- package/build/tokens/components/light/link.js +5 -0
- package/build/tokens/components/light/progress-bar.d.ts +41 -0
- package/build/tokens/components/light/progress-bar.js +40 -0
- package/build/tokens/components/light/segmented-control.d.ts +2 -2
- package/build/tokens/components/light/segmented-control.js +2 -2
- package/build/tokens/components/light/table.d.ts +3 -0
- package/build/tokens/components/light/table.js +3 -0
- package/build/tokens/index.d.ts +1 -0
- package/build/tokens/index.js +1 -0
- package/build/tokens/motion.d.ts +23 -0
- package/build/tokens/motion.js +22 -0
- package/build/tokens/primitive.d.ts +19 -0
- package/build/tokens/primitive.js +19 -0
- package/build/tokens/semantic-dark.d.ts +5 -5
- package/build/tokens/semantic-dark.js +5 -5
- package/build/tokens/semantic-light.d.ts +1 -1
- package/build/tokens/semantic-light.js +1 -1
- package/build/utils/index.d.ts +1 -0
- package/build/utils/index.js +1 -0
- package/build/utils/isEqual.d.ts +2 -0
- package/build/utils/isEqual.js +29 -0
- package/chromatic.config.json +6 -0
- package/docs/assets/bank-logo.png +0 -0
- package/docs/assets/bank-logo1.png +0 -0
- package/docs/components/AllComponents.web.tsx +43 -1
- package/docs/components/ViewWrap.tsx +32 -0
- package/docs/components/index.ts +7 -7
- package/docs/getting-started.mdx +6 -6
- package/docs/introduction.mdx +3 -3
- package/package.json +16 -12
- package/src/components/Alert/AlertCloseButton.tsx +33 -5
- package/src/components/Alert/AlertIcon.tsx +17 -1
- package/src/components/Alert/AlertIconButton.tsx +37 -4
- package/src/components/Alert/AlertLink.tsx +52 -1
- package/src/components/Alert/AlertText.tsx +28 -3
- package/src/components/Alert/AlertTitle.tsx +28 -3
- package/src/components/Badge/BadgeIcon.tsx +72 -0
- package/src/components/Badge/BadgeText.tsx +72 -0
- package/src/components/Button/ButtonRoot.tsx +1 -0
- package/src/components/Checkbox/Checkbox.docs.mdx +45 -7
- package/src/components/Checkbox/Checkbox.props.ts +3 -1
- package/src/components/Checkbox/Checkbox.stories.tsx +37 -1
- package/src/components/Checkbox/Checkbox.tsx +12 -9
- package/src/components/Checkbox/CheckboxIcon.tsx +1 -1
- package/src/components/Checkbox/CheckboxImage.tsx +9 -0
- package/src/components/Checkbox/CheckboxTileRoot.tsx +1 -1
- package/src/components/Checkbox/index.ts +3 -2
- package/src/components/CurrencyInput/CurrencyInput.tsx +2 -1
- package/src/components/DatePicker/DatePicker.context.ts +23 -0
- package/src/components/DatePicker/DatePicker.docs.mdx +239 -0
- package/src/components/DatePicker/DatePicker.props.ts +139 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +98 -0
- package/src/components/DatePicker/DatePicker.tsx +669 -0
- package/src/components/DatePicker/DatePickerCalendar.tsx +41 -0
- package/src/components/DatePicker/DatePickerDay.tsx +302 -0
- package/src/components/DatePicker/DatePickerDays.tsx +241 -0
- package/src/components/DatePicker/DatePickerFooter.tsx +35 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerHeader.props.ts +10 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerMonthButton.tsx +29 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerNextButton.tsx +46 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerPrevButton.tsx +46 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerSelectors.tsx +96 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerTimeButton.tsx +48 -0
- package/src/components/DatePicker/DatePickerHeader/DatePickerYearButton.tsx +50 -0
- package/src/components/DatePicker/DatePickerHeader/index.tsx +64 -0
- package/src/components/DatePicker/DatePickerMonths.tsx +101 -0
- package/src/components/DatePicker/DatePickerWeekdays.tsx +49 -0
- package/src/components/DatePicker/DatePickerYears.tsx +119 -0
- package/src/components/DatePicker/TimePicker.tsx +141 -0
- package/src/components/DatePicker/enums.ts +14 -0
- package/src/components/DatePicker/index.ts +13 -0
- package/src/components/DatePicker/polyfill.ts +21 -0
- package/src/components/DatePicker/time-picker/animated-math.ts +33 -0
- package/src/components/DatePicker/time-picker/period-native.tsx +34 -0
- package/src/components/DatePicker/time-picker/period-picker.tsx +16 -0
- package/src/components/DatePicker/time-picker/period-web.tsx +36 -0
- package/src/components/DatePicker/time-picker/wheel-native.tsx +37 -0
- package/src/components/DatePicker/time-picker/wheel-picker/index.ts +3 -0
- package/src/components/DatePicker/time-picker/wheel-picker/wheel-picker-item.tsx +132 -0
- package/src/components/DatePicker/time-picker/wheel-picker/wheel-picker.style.ts +22 -0
- package/src/components/DatePicker/time-picker/wheel-picker/wheel-picker.tsx +200 -0
- package/src/components/DatePicker/time-picker/wheel-web.tsx +181 -0
- package/src/components/DatePicker/time-picker/wheel.tsx +18 -0
- package/src/components/DatePicker/utils.ts +549 -0
- package/src/components/DatePickerInput/DatePickerInput.docs.mdx +237 -0
- package/src/components/DatePickerInput/DatePickerInput.props.ts +50 -0
- package/src/components/DatePickerInput/DatePickerInput.stories.tsx +178 -0
- package/src/components/DatePickerInput/DatePickerInput.tsx +265 -0
- package/src/components/DatePickerInput/DatePickerInputDoneButton.tsx +42 -0
- package/src/components/DatePickerInput/DatePickerInputDoneButton.web.tsx +7 -0
- package/src/components/DatePickerInput/index.ts +2 -0
- package/src/components/Icon/Icon.stories.tsx +4 -3
- package/src/components/IconContainer/IconContainer.docs.mdx +4 -4
- package/src/components/Input/InputField.tsx +0 -2
- package/src/components/Input/InputSlot.tsx +14 -3
- package/src/components/Link/Link.props.ts +3 -0
- package/src/components/Link/Link.tsx +12 -6
- package/src/components/List/List.docs.mdx +24 -23
- package/src/components/Modal/Modal.stories.tsx +2 -30
- package/src/components/Radio/Radio.docs.mdx +96 -124
- package/src/components/Radio/Radio.props.ts +3 -1
- package/src/components/Radio/Radio.stories.tsx +47 -0
- package/src/components/Radio/Radio.tsx +10 -7
- package/src/components/Radio/RadioImage.tsx +9 -0
- package/src/components/Radio/RadioTileRoot.tsx +1 -1
- package/src/components/Radio/index.ts +3 -2
- package/src/components/Select/Select.docs.mdx +6 -6
- package/src/components/Select/Select.stories.tsx +7 -7
- package/src/components/Select/SelectOption.tsx +4 -10
- package/src/components/UnstyledIconButton/UnstyledIconButton.props.ts +2 -1
- package/src/components/UnstyledIconButton/UnstyledIconButton.tsx +23 -5
- package/src/components/UnstyledIconButton/UnstyledIconButtonRoot.tsx +7 -3
- package/src/components/index.ts +2 -0
- package/src/hooks/index.ts +4 -3
- package/src/hooks/usePrevious.ts +9 -0
- package/src/hooks/useTheme.ts +4 -3
- package/src/tokens/color.ts +6 -6
- package/src/tokens/components/dark/alert.ts +13 -0
- package/src/tokens/components/dark/checkbox.ts +3 -0
- package/src/tokens/components/dark/date-picker.ts +1 -0
- package/src/tokens/components/dark/icon-button.ts +7 -0
- package/src/tokens/components/dark/illustrations.ts +7 -0
- package/src/tokens/components/dark/index.ts +2 -0
- package/src/tokens/components/dark/link.ts +5 -0
- package/src/tokens/components/dark/progress-bar.ts +41 -0
- package/src/tokens/components/dark/segmented-control.ts +2 -2
- package/src/tokens/components/dark/table.ts +3 -0
- package/src/tokens/components/light/alert.ts +13 -0
- package/src/tokens/components/light/checkbox.ts +3 -0
- package/src/tokens/components/light/date-picker.ts +1 -0
- package/src/tokens/components/light/icon-button.ts +7 -0
- package/src/tokens/components/light/illustrations.ts +7 -0
- package/src/tokens/components/light/index.ts +2 -0
- package/src/tokens/components/light/link.ts +5 -0
- package/src/tokens/components/light/progress-bar.ts +41 -0
- package/src/tokens/components/light/segmented-control.ts +2 -2
- package/src/tokens/components/light/table.ts +3 -0
- package/src/tokens/index.ts +1 -0
- package/src/tokens/motion.ts +23 -0
- package/src/tokens/primitive.ts +19 -0
- package/src/tokens/semantic-dark.ts +5 -5
- package/src/tokens/semantic-light.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/isEqual.ts +30 -0
- package/docs/assets/react-native-pig.png +0 -0
- package/docs/components/AdvancedRadioExample.tsx +0 -126
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import type { BottomSheetModalMethods } from '@gorhom/bottom-sheet/lib/typescript/types';
|
|
2
|
+
import { CalendarSmallIcon, CloseSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { Keyboard, Platform, TextInputFocusEvent } from 'react-native';
|
|
7
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
8
|
+
import { DatePicker } from '../DatePicker';
|
|
9
|
+
import type { DateType } from '../DatePicker/DatePicker.props';
|
|
10
|
+
import { useFormFieldContext } from '../FormField';
|
|
11
|
+
import { Input, InputField, InputSlot } from '../Input';
|
|
12
|
+
import { UnstyledIconButton } from '../UnstyledIconButton';
|
|
13
|
+
import type DatePickerInputProps from './DatePickerInput.props';
|
|
14
|
+
import DatePickerInputDoneButton from './DatePickerInputDoneButton';
|
|
15
|
+
|
|
16
|
+
dayjs.extend(customParseFormat);
|
|
17
|
+
|
|
18
|
+
const DEFAULT_FORMAT = 'DD/MM/YYYY';
|
|
19
|
+
|
|
20
|
+
const maskDefaultFormat = (value: string) => {
|
|
21
|
+
const digitsOnly = value.replace(/\D/g, '').slice(0, 8);
|
|
22
|
+
const day = digitsOnly.slice(0, 2);
|
|
23
|
+
const month = digitsOnly.slice(2, 4);
|
|
24
|
+
const year = digitsOnly.slice(4, 8);
|
|
25
|
+
|
|
26
|
+
return [day, month, year].filter(Boolean).join('/');
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const DatePickerInput = ({
|
|
30
|
+
validationStatus = 'initial',
|
|
31
|
+
disabled,
|
|
32
|
+
focused,
|
|
33
|
+
readonly,
|
|
34
|
+
placeholder,
|
|
35
|
+
inBottomSheet = false,
|
|
36
|
+
format = DEFAULT_FORMAT,
|
|
37
|
+
openButtonLabel = 'Open date picker',
|
|
38
|
+
autoCloseOnSelect = true,
|
|
39
|
+
onChange,
|
|
40
|
+
onChangeText,
|
|
41
|
+
onBlur,
|
|
42
|
+
onFocus,
|
|
43
|
+
value,
|
|
44
|
+
datePickerProps,
|
|
45
|
+
onClear,
|
|
46
|
+
...rest
|
|
47
|
+
}: DatePickerInputProps) => {
|
|
48
|
+
const formFieldContext = useFormFieldContext();
|
|
49
|
+
const validationStatusFromContext = formFieldContext?.validationStatus ?? validationStatus;
|
|
50
|
+
const isDisabled = formFieldContext?.disabled ?? disabled;
|
|
51
|
+
const isReadonly = formFieldContext?.readonly ?? readonly;
|
|
52
|
+
|
|
53
|
+
const pickerRef = useRef<BottomSheetModalMethods | null>(null);
|
|
54
|
+
const accessoryViewID = useMemo(() => {
|
|
55
|
+
if (Platform.OS !== 'ios') return undefined;
|
|
56
|
+
return `datepicker-input-${Math.random().toString(36).slice(2)}`;
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
const formatDate = useCallback(
|
|
60
|
+
(dateValue?: DateType) => {
|
|
61
|
+
if (!dateValue) return '';
|
|
62
|
+
const parsed = dayjs(dateValue);
|
|
63
|
+
return parsed.isValid() ? parsed.format(format) : '';
|
|
64
|
+
},
|
|
65
|
+
[format]
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const isDefaultFormat = format === DEFAULT_FORMAT;
|
|
69
|
+
|
|
70
|
+
const [inputValue, setInputValue] = useState(() => formatDate(value));
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
setInputValue(formatDate(value));
|
|
74
|
+
}, [value, formatDate]);
|
|
75
|
+
|
|
76
|
+
const handleTextChange = useCallback(
|
|
77
|
+
(text: string) => {
|
|
78
|
+
const nextValue = isDefaultFormat ? maskDefaultFormat(text) : text;
|
|
79
|
+
|
|
80
|
+
setInputValue(nextValue);
|
|
81
|
+
onChangeText?.(nextValue);
|
|
82
|
+
|
|
83
|
+
if (!nextValue) {
|
|
84
|
+
onChange?.({ date: undefined });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const parsed = dayjs(nextValue, format, true);
|
|
89
|
+
|
|
90
|
+
if (parsed.isValid()) {
|
|
91
|
+
onChange?.({ date: parsed.toDate() });
|
|
92
|
+
} else {
|
|
93
|
+
onChange?.({ date: undefined });
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
[format, isDefaultFormat, onChange, onChangeText]
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const handleClear = useCallback(() => {
|
|
100
|
+
setInputValue('');
|
|
101
|
+
onChange?.({ date: undefined });
|
|
102
|
+
onClear?.();
|
|
103
|
+
}, [onChange, onClear]);
|
|
104
|
+
|
|
105
|
+
const closeKeyboard = useCallback(() => {
|
|
106
|
+
Keyboard.dismiss();
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
const openPicker = useCallback(() => {
|
|
110
|
+
if (isDisabled || isReadonly) return;
|
|
111
|
+
closeKeyboard();
|
|
112
|
+
pickerRef.current?.present();
|
|
113
|
+
}, [closeKeyboard, isDisabled, isReadonly]);
|
|
114
|
+
|
|
115
|
+
const selectedDate = useMemo(() => {
|
|
116
|
+
if (value) {
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const parsed = dayjs(inputValue, format, true);
|
|
121
|
+
return parsed.isValid() ? parsed.toDate() : undefined;
|
|
122
|
+
}, [value, inputValue, format]);
|
|
123
|
+
|
|
124
|
+
const handlePickerChange = useCallback(
|
|
125
|
+
({ date }: { date: DateType }) => {
|
|
126
|
+
if (!date) {
|
|
127
|
+
handleClear();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const formatted = formatDate(date);
|
|
132
|
+
setInputValue(formatted);
|
|
133
|
+
onChange?.({ date });
|
|
134
|
+
|
|
135
|
+
if (autoCloseOnSelect) {
|
|
136
|
+
pickerRef.current?.close?.();
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
[autoCloseOnSelect, formatDate, handleClear, onChange]
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
const handleBlur = useCallback(
|
|
143
|
+
(event: TextInputFocusEvent) => {
|
|
144
|
+
onBlur?.(event);
|
|
145
|
+
},
|
|
146
|
+
[onBlur]
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const handleFocus = useCallback(
|
|
150
|
+
(event: TextInputFocusEvent) => {
|
|
151
|
+
onFocus?.(event);
|
|
152
|
+
},
|
|
153
|
+
[onFocus]
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const { onCancel: pickerOnCancel, ...restDatePickerProps } = datePickerProps ?? {};
|
|
157
|
+
const {
|
|
158
|
+
style: inputStyle,
|
|
159
|
+
keyboardType: keyboardTypeProp,
|
|
160
|
+
inputMode: inputModeProp,
|
|
161
|
+
accessibilityHint: accessibilityHintProp,
|
|
162
|
+
accessibilityLabel: accessibilityLabelProp,
|
|
163
|
+
accessible: accessibleProp,
|
|
164
|
+
accessibilityRole: accessibilityRoleProp,
|
|
165
|
+
importantForAccessibility: importantForAccessibilityProp,
|
|
166
|
+
...textInputProps
|
|
167
|
+
} = rest;
|
|
168
|
+
|
|
169
|
+
const resolvedKeyboardType = keyboardTypeProp ?? (isDefaultFormat ? 'number-pad' : undefined);
|
|
170
|
+
const resolvedInputMode = inputModeProp ?? (isDefaultFormat ? 'numeric' : undefined);
|
|
171
|
+
const resolvedAccessibilityHint = accessibilityHintProp ?? `Enter the date in ${format} format`;
|
|
172
|
+
const resolvedAccessibilityLabel = accessibilityLabelProp ?? 'Date input';
|
|
173
|
+
const resolvedAccessible = accessibleProp ?? true;
|
|
174
|
+
const resolvedImportantForAccessibility = importantForAccessibilityProp ?? 'yes';
|
|
175
|
+
|
|
176
|
+
const handleCancel = useCallback(() => {
|
|
177
|
+
pickerOnCancel?.();
|
|
178
|
+
pickerRef.current?.close?.();
|
|
179
|
+
}, [pickerOnCancel]);
|
|
180
|
+
|
|
181
|
+
const placeholderValue = placeholder ?? format;
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<>
|
|
185
|
+
<Input
|
|
186
|
+
validationStatus={validationStatusFromContext}
|
|
187
|
+
disabled={isDisabled}
|
|
188
|
+
readonly={isReadonly}
|
|
189
|
+
focused={focused}
|
|
190
|
+
style={styles.wrap}
|
|
191
|
+
accessible={false}
|
|
192
|
+
>
|
|
193
|
+
<InputField
|
|
194
|
+
editable={!isReadonly && !isDisabled}
|
|
195
|
+
value={inputValue}
|
|
196
|
+
placeholder={placeholderValue}
|
|
197
|
+
onChangeText={handleTextChange}
|
|
198
|
+
onBlur={handleBlur}
|
|
199
|
+
onFocus={handleFocus}
|
|
200
|
+
inBottomSheet={inBottomSheet}
|
|
201
|
+
keyboardType={resolvedKeyboardType}
|
|
202
|
+
inputMode={resolvedInputMode}
|
|
203
|
+
accessibilityHint={resolvedAccessibilityHint}
|
|
204
|
+
aria-label="Date input"
|
|
205
|
+
accessibilityLabel={resolvedAccessibilityLabel}
|
|
206
|
+
accessible={resolvedAccessible}
|
|
207
|
+
accessibilityState={{
|
|
208
|
+
disabled: isDisabled || isReadonly,
|
|
209
|
+
}}
|
|
210
|
+
importantForAccessibility={resolvedImportantForAccessibility}
|
|
211
|
+
inputAccessoryViewID={Platform.OS === 'ios' ? accessoryViewID : undefined}
|
|
212
|
+
{...textInputProps}
|
|
213
|
+
style={[styles.input, inputStyle]}
|
|
214
|
+
/>
|
|
215
|
+
{!!inputValue && onClear && !isReadonly && !isDisabled && (
|
|
216
|
+
<InputSlot accessibilityElementsHidden={false}>
|
|
217
|
+
<UnstyledIconButton
|
|
218
|
+
accessibilityLabel="Clear date"
|
|
219
|
+
accessibilityHint="Removes the current date"
|
|
220
|
+
icon={CloseSmallIcon}
|
|
221
|
+
onPress={handleClear}
|
|
222
|
+
/>
|
|
223
|
+
</InputSlot>
|
|
224
|
+
)}
|
|
225
|
+
<InputSlot accessibilityElementsHidden={false}>
|
|
226
|
+
<UnstyledIconButton
|
|
227
|
+
accessibilityLabel={openButtonLabel}
|
|
228
|
+
accessibilityHint="Opens the date picker calendar"
|
|
229
|
+
icon={CalendarSmallIcon}
|
|
230
|
+
onPress={openPicker}
|
|
231
|
+
disabled={isDisabled || isReadonly}
|
|
232
|
+
/>
|
|
233
|
+
</InputSlot>
|
|
234
|
+
</Input>
|
|
235
|
+
<DatePicker
|
|
236
|
+
ref={pickerRef}
|
|
237
|
+
mode="single"
|
|
238
|
+
date={selectedDate}
|
|
239
|
+
onChange={handlePickerChange}
|
|
240
|
+
onCancel={handleCancel}
|
|
241
|
+
{...restDatePickerProps}
|
|
242
|
+
/>
|
|
243
|
+
{Platform.OS === 'ios' && accessoryViewID && (
|
|
244
|
+
<DatePickerInputDoneButton
|
|
245
|
+
accessoryViewID={accessoryViewID}
|
|
246
|
+
closeKeyboard={closeKeyboard}
|
|
247
|
+
/>
|
|
248
|
+
)}
|
|
249
|
+
</>
|
|
250
|
+
);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
DatePickerInput.displayName = 'DatePickerInput';
|
|
254
|
+
|
|
255
|
+
const styles = StyleSheet.create(theme => ({
|
|
256
|
+
wrap: {
|
|
257
|
+
gap: theme.components.input.date.gap,
|
|
258
|
+
},
|
|
259
|
+
input: {
|
|
260
|
+
paddingLeft: 0,
|
|
261
|
+
paddingRight: 0,
|
|
262
|
+
},
|
|
263
|
+
}));
|
|
264
|
+
|
|
265
|
+
export default DatePickerInput;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { InputAccessoryView, View } from 'react-native';
|
|
2
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
3
|
+
import { Button } from '../Button';
|
|
4
|
+
|
|
5
|
+
const DatePickerInputDoneButton = ({
|
|
6
|
+
accessoryViewID,
|
|
7
|
+
closeKeyboard,
|
|
8
|
+
}: {
|
|
9
|
+
accessoryViewID: string;
|
|
10
|
+
closeKeyboard: () => void;
|
|
11
|
+
}) => {
|
|
12
|
+
return (
|
|
13
|
+
<InputAccessoryView nativeID={accessoryViewID}>
|
|
14
|
+
<View style={styles.accessory}>
|
|
15
|
+
<Button
|
|
16
|
+
accessibilityRole="button"
|
|
17
|
+
accessibilityLabel="Done"
|
|
18
|
+
onPress={closeKeyboard}
|
|
19
|
+
variant="ghost"
|
|
20
|
+
colorScheme="functional"
|
|
21
|
+
>
|
|
22
|
+
Done
|
|
23
|
+
</Button>
|
|
24
|
+
</View>
|
|
25
|
+
</InputAccessoryView>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const styles = StyleSheet.create(theme => ({
|
|
30
|
+
accessory: {
|
|
31
|
+
paddingHorizontal: 16,
|
|
32
|
+
paddingVertical: 2,
|
|
33
|
+
alignItems: 'flex-end',
|
|
34
|
+
backgroundColor: theme.color.surface.neutral.strong,
|
|
35
|
+
borderTopWidth: theme.borderWidth[1],
|
|
36
|
+
borderTopColor: theme.color.border.subtle,
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
DatePickerInputDoneButton.DisplayName = 'DatePickerInputDoneButton';
|
|
41
|
+
|
|
42
|
+
export default DatePickerInputDoneButton;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import * as Icons from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
|
-
import { ComponentType } from 'react';
|
|
4
3
|
import { Icon } from '.';
|
|
5
4
|
import { ColorValue } from '../../types';
|
|
6
5
|
import { coloursAsArray } from '../../utils';
|
|
@@ -25,7 +24,8 @@ const meta = {
|
|
|
25
24
|
},
|
|
26
25
|
},
|
|
27
26
|
args: {
|
|
28
|
-
|
|
27
|
+
// @ts-expect-error - This is a playground
|
|
28
|
+
as: Object.keys(Icons)[0],
|
|
29
29
|
color: 'grey1000' as ColorValue,
|
|
30
30
|
},
|
|
31
31
|
} satisfies Meta<typeof Icon>;
|
|
@@ -37,7 +37,8 @@ type Story = StoryObj<typeof meta>;
|
|
|
37
37
|
export const Playground: Story = {
|
|
38
38
|
// @ts-expect-error - This is a playground
|
|
39
39
|
render: ({ as: icon, color }) => {
|
|
40
|
+
// @ts-expect-error - This is a playground
|
|
40
41
|
const as = icon === 'none' ? undefined : Icons[icon];
|
|
41
|
-
return <Icon as={as} color={
|
|
42
|
+
return <Icon as={as} color={color} />;
|
|
42
43
|
},
|
|
43
44
|
};
|
|
@@ -2,8 +2,8 @@ import { Canvas, Controls, Meta, Story } from '@storybook/addon-docs/blocks';
|
|
|
2
2
|
import {
|
|
3
3
|
BroadbandMediumIcon,
|
|
4
4
|
CashbackCardMediumIcon,
|
|
5
|
-
ConfettiMediumIcon,
|
|
6
5
|
ElectricityMediumIcon,
|
|
6
|
+
EmailMediumIcon,
|
|
7
7
|
InsuranceMediumIcon,
|
|
8
8
|
MobileMediumIcon,
|
|
9
9
|
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
@@ -42,7 +42,7 @@ Wrap an icon with the `IconContainer` to apply sizing + background styles withou
|
|
|
42
42
|
<IconContainer icon={MobileMediumIcon} size="md" variant="emphasis" color="mobile" />
|
|
43
43
|
<IconContainer icon={InsuranceMediumIcon} size="md" variant="emphasis" color="insurance" />
|
|
44
44
|
<IconContainer icon={CashbackCardMediumIcon} size="md" variant="emphasis" color="cashback" />
|
|
45
|
-
<IconContainer icon={
|
|
45
|
+
<IconContainer icon={EmailMediumIcon} size="md" variant="emphasis" color="pig" />
|
|
46
46
|
</Flex>
|
|
47
47
|
</Center>
|
|
48
48
|
</UsageWrap>
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
MobileMediumIcon,
|
|
56
56
|
InsuranceMediumIcon,
|
|
57
57
|
CashbackCardMediumIcon,
|
|
58
|
-
|
|
58
|
+
,
|
|
59
59
|
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
60
60
|
|
|
61
61
|
const MyComponent = () => (
|
|
@@ -65,7 +65,7 @@ const MyComponent = () => (
|
|
|
65
65
|
<IconContainer icon={MobileMediumIcon} size="md" variant="emphasis" color="mobile" />
|
|
66
66
|
<IconContainer icon={InsuranceMediumIcon} size="md" variant="emphasis" color="insurance" />
|
|
67
67
|
<IconContainer icon={CashbackCardMediumIcon} size="md" variant="emphasis" color="cashback" />
|
|
68
|
-
<IconContainer icon={
|
|
68
|
+
<IconContainer icon={EmailMediumIcon} size="md" variant="emphasis" color="pig" />
|
|
69
69
|
</>
|
|
70
70
|
);
|
|
71
71
|
```
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
1
|
import { View, ViewProps } from 'react-native';
|
|
2
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
3
3
|
|
|
4
|
-
const InputSlot = ({
|
|
4
|
+
const InputSlot = ({
|
|
5
|
+
children,
|
|
6
|
+
style,
|
|
7
|
+
accessible,
|
|
8
|
+
importantForAccessibility,
|
|
9
|
+
...props
|
|
10
|
+
}: ViewProps) => {
|
|
5
11
|
return (
|
|
6
|
-
<View
|
|
12
|
+
<View
|
|
13
|
+
{...props}
|
|
14
|
+
accessible={accessible ?? false}
|
|
15
|
+
importantForAccessibility={importantForAccessibility ?? 'auto'}
|
|
16
|
+
style={[styles.container, style]}
|
|
17
|
+
>
|
|
7
18
|
{children}
|
|
8
19
|
</View>
|
|
9
20
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import { PressableProps, TextProps } from 'react-native';
|
|
3
|
+
import { IconProps } from '../Icon';
|
|
3
4
|
|
|
4
5
|
export interface LinkProps extends Omit<PressableProps, 'children'> {
|
|
5
6
|
children: TextProps['children'];
|
|
@@ -10,6 +11,8 @@ export interface LinkProps extends Omit<PressableProps, 'children'> {
|
|
|
10
11
|
icon?: ComponentType;
|
|
11
12
|
iconPosition?: 'left' | 'right';
|
|
12
13
|
showIcon?: boolean;
|
|
14
|
+
textStyle?: TextProps['style'];
|
|
15
|
+
iconStyle?: IconProps['style'];
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
export default LinkProps;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { LinkProps } from './Link.props';
|
|
2
1
|
import { createLink } from '@gluestack-ui/link';
|
|
2
|
+
import { ChevronRightSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
|
+
import type { LinkProps } from './Link.props';
|
|
4
|
+
import LinkIcon from './LinkIcon';
|
|
3
5
|
import LinkRoot from './LinkRoot';
|
|
4
6
|
import LinkTextComponent from './LinkText';
|
|
5
|
-
import LinkIcon from './LinkIcon';
|
|
6
|
-
import { ChevronRightSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
7
7
|
|
|
8
8
|
const LinkComponent = createLink({
|
|
9
9
|
Root: LinkRoot,
|
|
@@ -21,14 +21,20 @@ const Link = ({
|
|
|
21
21
|
target = '_self',
|
|
22
22
|
iconPosition = 'right',
|
|
23
23
|
showIcon = true,
|
|
24
|
+
textStyle,
|
|
25
|
+
iconStyle,
|
|
24
26
|
...props
|
|
25
27
|
}: LinkProps) => {
|
|
26
28
|
const LinkAny = LinkComponent as any;
|
|
27
29
|
return (
|
|
28
30
|
<LinkAny {...props} isDisabled={disabled} isExternal={target === '_blank'}>
|
|
29
|
-
{showIcon && icon && iconPosition === 'left' ?
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
{showIcon && icon && iconPosition === 'left' ? (
|
|
32
|
+
<LinkIcon as={icon} style={iconStyle} />
|
|
33
|
+
) : null}
|
|
34
|
+
<LinkText style={textStyle}>{children}</LinkText>
|
|
35
|
+
{showIcon && icon && iconPosition === 'right' ? (
|
|
36
|
+
<LinkIcon as={icon} style={iconStyle} />
|
|
37
|
+
) : null}
|
|
32
38
|
</LinkAny>
|
|
33
39
|
);
|
|
34
40
|
};
|
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
ChevronRightSmallIcon,
|
|
5
5
|
ElectricityMediumIcon,
|
|
6
6
|
GasMediumIcon,
|
|
7
|
-
|
|
7
|
+
InfoMediumIcon as HomeMediumIcon,
|
|
8
|
+
// HomeMediumIcon,
|
|
8
9
|
PaymentMediumIcon,
|
|
9
10
|
UserMediumIcon,
|
|
10
11
|
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
@@ -15,7 +16,6 @@ import {
|
|
|
15
16
|
FlatList,
|
|
16
17
|
Image,
|
|
17
18
|
List,
|
|
18
|
-
SectionHeader,
|
|
19
19
|
ListItem,
|
|
20
20
|
ListItemContent,
|
|
21
21
|
ListItemHelperText,
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
ListItemText,
|
|
25
25
|
ListItemTrailingContent,
|
|
26
26
|
ListItemTrailingIcon,
|
|
27
|
+
SectionHeader,
|
|
27
28
|
} from '../../';
|
|
28
29
|
import { BackToTopButton, BadgeList, UsageWrap, ViewFigmaButton } from '../../../docs/components';
|
|
29
30
|
import * as Stories from './List.stories';
|
|
@@ -87,21 +88,21 @@ const MyComponent = () => (
|
|
|
87
88
|
|
|
88
89
|
### `List`
|
|
89
90
|
|
|
90
|
-
| Name
|
|
91
|
-
|
|
|
92
|
-
| container
|
|
93
|
-
| heading
|
|
94
|
-
| helperText
|
|
95
|
-
| linkText
|
|
96
|
-
| linkHref
|
|
97
|
-
| linkOnPress
|
|
98
|
-
| linkTarget
|
|
99
|
-
| linkIcon
|
|
100
|
-
| linkIconPosition
|
|
101
|
-
| linkShowIcon
|
|
102
|
-
| divider
|
|
103
|
-
| loading
|
|
104
|
-
| disabled
|
|
91
|
+
| Name | Type | Default | Description |
|
|
92
|
+
| ---------------- | ------------------------------------------------------------------------------------------------- | --------- | ---------------------------------------------------------- | --- |
|
|
93
|
+
| container | `'none' \| 'subtleWhite' \| 'emphasisWhite' \|` <br /> `'subtleWarmWhite' \| 'emphasisWarmWhite'` | `'none'` | The container style of the list. |
|
|
94
|
+
| heading | `string` | | The text to display in the heading of the list. |
|
|
95
|
+
| helperText | `string` | | The supporting text to display in the heading of the list. |
|
|
96
|
+
| linkText | `string` | | The text for the link in the heading. |
|
|
97
|
+
| linkHref | `string` | | The href for the link in the heading. |
|
|
98
|
+
| linkOnPress | `() => void` | | Callback function when the heading link is pressed. |
|
|
99
|
+
| linkTarget | `'_blank' \| '_self' \| '_parent' \| '_top'` | | Target for the link in the heading. | |
|
|
100
|
+
| linkIcon | `ComponentType` | | Icon for the heading link. |
|
|
101
|
+
| linkIconPosition | `'left' \| 'right'` | `'right'` | Position of the icon in the heading link. |
|
|
102
|
+
| linkShowIcon | `boolean` | `true` | Whether to show the icon in the heading link. |
|
|
103
|
+
| divider | `boolean` | `false` | Whether to display a divider below the list items. |
|
|
104
|
+
| loading | `boolean` | `false` | Whether to show the list items in loading state. |
|
|
105
|
+
| disabled | `boolean` | `false` | Whether to disable the list. |
|
|
105
106
|
|
|
106
107
|
### `ListItem`
|
|
107
108
|
|
|
@@ -172,7 +173,7 @@ If you need to use the List component in a more advanced way, you can use the pa
|
|
|
172
173
|
</ListItem>
|
|
173
174
|
<ListItem onPress={() => console.log('pressed')}>
|
|
174
175
|
<ListItemLeadingContent>
|
|
175
|
-
<ListItemIcon as={
|
|
176
|
+
<ListItemIcon as={HomeMediumIcon} />
|
|
176
177
|
</ListItemLeadingContent>
|
|
177
178
|
<ListItemContent>
|
|
178
179
|
<ListItemText>Moving home</ListItemText>
|
|
@@ -214,7 +215,7 @@ import {
|
|
|
214
215
|
BillMediumIcon,
|
|
215
216
|
ChevronRightSmallIcon,
|
|
216
217
|
PaymentMediumIcon,
|
|
217
|
-
|
|
218
|
+
HomeMediumIcon,
|
|
218
219
|
UserMediumIcon,
|
|
219
220
|
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
220
221
|
|
|
@@ -247,7 +248,7 @@ const MyComponent = () => (
|
|
|
247
248
|
</ListItem>
|
|
248
249
|
<ListItem onPress={() => console.log('pressed')}>
|
|
249
250
|
<ListItemLeadingContent>
|
|
250
|
-
<ListItemIcon as={
|
|
251
|
+
<ListItemIcon as={HomeMediumIcon} />
|
|
251
252
|
</ListItemLeadingContent>
|
|
252
253
|
<ListItemContent>
|
|
253
254
|
<ListItemText>Moving home</ListItemText>
|
|
@@ -302,7 +303,7 @@ the `Card` and child `ListItem` components.
|
|
|
302
303
|
onPress={() => console.log('item pressed')}
|
|
303
304
|
/>
|
|
304
305
|
<ListItem
|
|
305
|
-
leadingContent={<
|
|
306
|
+
leadingContent={<HomeMediumIcon />}
|
|
306
307
|
text="Moving Home"
|
|
307
308
|
onPress={() => console.log('item pressed')}
|
|
308
309
|
/>
|
|
@@ -314,7 +315,7 @@ import { List, ListItem, Card } from '@utilitywarehouse/hearth-react-native';
|
|
|
314
315
|
import {
|
|
315
316
|
BillMediumIcon,
|
|
316
317
|
PaymentMediumIcon,
|
|
317
|
-
|
|
318
|
+
HomeMediumIcon,
|
|
318
319
|
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
319
320
|
|
|
320
321
|
const MyComponent = () => (
|
|
@@ -332,7 +333,7 @@ const MyComponent = () => (
|
|
|
332
333
|
onPress={() => console.log('item pressed')}
|
|
333
334
|
/>
|
|
334
335
|
<ListItem
|
|
335
|
-
leadingContent={<
|
|
336
|
+
leadingContent={<HomeMediumIcon />}
|
|
336
337
|
text="Moving Home"
|
|
337
338
|
onPress={() => console.log('item pressed')}
|
|
338
339
|
/>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { useRef } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
import { UnistylesRuntime } from 'react-native-unistyles';
|
|
3
|
+
import { ImageSourcePropType, Platform, View } from 'react-native';
|
|
5
4
|
import { Modal } from '.';
|
|
6
5
|
import pigs from '../../../docs/assets/pigs.png';
|
|
6
|
+
import { ViewWrap } from '../../../docs/components';
|
|
7
7
|
import { BodyText } from '../BodyText';
|
|
8
8
|
import { BottomSheetModal } from '../BottomSheet';
|
|
9
9
|
import { Box } from '../Box';
|
|
@@ -61,34 +61,6 @@ const meta = {
|
|
|
61
61
|
export default meta;
|
|
62
62
|
type Story = StoryObj<typeof meta>;
|
|
63
63
|
|
|
64
|
-
const ViewWrap = ({ children }: { children: ViewProps['children'] }) => (
|
|
65
|
-
<View
|
|
66
|
-
style={{
|
|
67
|
-
width: Platform.OS === 'web' ? '100%' : Dimensions.get('window').width,
|
|
68
|
-
height:
|
|
69
|
-
Platform.OS === 'web'
|
|
70
|
-
? '100%'
|
|
71
|
-
: Dimensions.get('window').height -
|
|
72
|
-
UnistylesRuntime.insets.top -
|
|
73
|
-
UnistylesRuntime.insets.bottom -
|
|
74
|
-
33,
|
|
75
|
-
|
|
76
|
-
position: 'absolute',
|
|
77
|
-
top: 0,
|
|
78
|
-
left: 0,
|
|
79
|
-
right: 0,
|
|
80
|
-
bottom: 0,
|
|
81
|
-
flex: 1,
|
|
82
|
-
marginVertical: Platform.OS === 'web' ? 0 : -8,
|
|
83
|
-
justifyContent: 'center',
|
|
84
|
-
alignItems: 'center',
|
|
85
|
-
padding: 16,
|
|
86
|
-
}}
|
|
87
|
-
>
|
|
88
|
-
{children}
|
|
89
|
-
</View>
|
|
90
|
-
);
|
|
91
|
-
|
|
92
64
|
export const Playground: Story = {
|
|
93
65
|
args: {
|
|
94
66
|
children: [],
|