@utilitywarehouse/hearth-react-native 0.16.0 → 0.16.2

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 (96) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-lint.log +67 -4
  3. package/CHANGELOG.md +30 -0
  4. package/build/components/Avatar/Avatar.js +0 -2
  5. package/build/components/Banner/Banner.d.ts +1 -1
  6. package/build/components/Banner/Banner.js +3 -1
  7. package/build/components/Carousel/Carousel.js +1 -1
  8. package/build/components/DateInput/DateInput.d.ts +1 -1
  9. package/build/components/DateInput/DateInput.js +2 -2
  10. package/build/components/DateInput/DateInput.props.d.ts +22 -1
  11. package/build/components/DateInput/DateInputSegment.d.ts +2 -16
  12. package/build/components/DateInput/DateInputSegment.js +2 -5
  13. package/build/components/DatePicker/DatePicker.js +8 -4
  14. package/build/components/DatePicker/DatePickerHeader/DatePickerHeader.props.d.ts +0 -1
  15. package/build/components/DatePicker/DatePickerHeader/index.js +1 -1
  16. package/build/components/DatePicker/index.d.ts +1 -0
  17. package/build/components/DatePicker/polyfill.js +3 -3
  18. package/build/components/DatePicker/time-picker/wheel-web.js +1 -3
  19. package/build/components/DatePickerInput/DatePickerInput.js +1 -2
  20. package/build/components/DescriptionList/DescriptionList.d.ts +1 -1
  21. package/build/components/DescriptionList/DescriptionList.js +2 -2
  22. package/build/components/DescriptionList/DescriptionList.props.d.ts +1 -0
  23. package/build/components/DescriptionList/DescriptionListItem.d.ts +1 -1
  24. package/build/components/DescriptionList/DescriptionListItem.js +3 -2
  25. package/build/components/DescriptionList/DescriptionListItem.props.d.ts +1 -0
  26. package/build/components/Input/Input.js +1 -1
  27. package/build/components/Switch/Switch.js +1 -1
  28. package/build/components/Tabs/Tabs.d.ts +1 -1
  29. package/build/components/Tabs/Tabs.js +1 -1
  30. package/build/components/Textarea/Textarea.js +3 -0
  31. package/build/components/Toast/ToastItem.js +1 -1
  32. package/build/components/ToggleButton/ToggleButtonIcon.js +1 -1
  33. package/build/components/ToggleButton/ToggleButtonRoot.js +0 -2
  34. package/build/components/UnstyledIconButton/UnstyledIconButtonIcon.js +1 -1
  35. package/build/utils/coloursAsArray.js +1 -1
  36. package/docs/components/AllComponents.web.tsx +16 -18
  37. package/docs/components/UsageWrap.tsx +17 -20
  38. package/eslint.config.js +5 -1
  39. package/package.json +11 -11
  40. package/src/components/Accordion/Accordion.figma.tsx +15 -17
  41. package/src/components/Accordion/AccordionItem.figma.tsx +27 -0
  42. package/src/components/Avatar/Avatar.figma.tsx +11 -21
  43. package/src/components/Avatar/Avatar.tsx +0 -2
  44. package/src/components/Badge/Badge.figma.tsx +45 -54
  45. package/src/components/Banner/Banner.figma.tsx +21 -13
  46. package/src/components/Banner/Banner.stories.tsx +4 -4
  47. package/src/components/Banner/Banner.tsx +2 -1
  48. package/src/components/Button/Button.figma.tsx +118 -46
  49. package/src/components/Card/Card.figma.tsx +27 -43
  50. package/src/components/Card/Card.stories.tsx +1 -1
  51. package/src/components/Carousel/Carousel.figma.tsx +20 -17
  52. package/src/components/Carousel/Carousel.tsx +1 -1
  53. package/src/components/Checkbox/Checkbox.figma.tsx +15 -18
  54. package/src/components/Checkbox/Checkbox.stories.tsx +2 -2
  55. package/src/components/Checkbox/CheckboxGroup.figma.tsx +48 -15
  56. package/src/components/Checkbox/CheckboxTileRoot.figma.tsx +24 -27
  57. package/src/components/CurrencyInput/CurrencyInput.figma.tsx +65 -49
  58. package/src/components/DateInput/DateInput.docs.mdx +47 -29
  59. package/src/components/DateInput/DateInput.figma.tsx +58 -45
  60. package/src/components/DateInput/DateInput.props.ts +32 -1
  61. package/src/components/DateInput/DateInput.stories.tsx +10 -0
  62. package/src/components/DateInput/DateInput.tsx +12 -0
  63. package/src/components/DateInput/DateInputSegment.tsx +7 -22
  64. package/src/components/DatePicker/DatePicker.figma.tsx +47 -0
  65. package/src/components/DatePicker/DatePicker.tsx +8 -4
  66. package/src/components/DatePicker/DatePickerHeader/DatePickerHeader.props.ts +0 -2
  67. package/src/components/DatePicker/DatePickerHeader/index.tsx +2 -2
  68. package/src/components/DatePicker/index.ts +2 -0
  69. package/src/components/DatePicker/polyfill.ts +3 -3
  70. package/src/components/DatePicker/time-picker/wheel-web.tsx +0 -1
  71. package/src/components/DatePickerInput/DatePickerInput.figma.tsx +18 -46
  72. package/src/components/DatePickerInput/DatePickerInput.tsx +0 -2
  73. package/src/components/DescriptionList/DescriptionList.docs.mdx +16 -14
  74. package/src/components/DescriptionList/DescriptionList.figma.tsx +41 -17
  75. package/src/components/DescriptionList/DescriptionList.props.ts +1 -0
  76. package/src/components/DescriptionList/DescriptionList.stories.tsx +24 -0
  77. package/src/components/DescriptionList/DescriptionList.tsx +2 -0
  78. package/src/components/DescriptionList/DescriptionListItem.figma.tsx +42 -0
  79. package/src/components/DescriptionList/DescriptionListItem.props.ts +1 -0
  80. package/src/components/DescriptionList/DescriptionListItem.tsx +7 -0
  81. package/src/components/Divider/Divider.figma.tsx +10 -23
  82. package/src/components/Input/Input.tsx +0 -1
  83. package/src/components/List/List.stories.tsx +1 -4
  84. package/src/components/Radio/Radio.stories.tsx +1 -1
  85. package/src/components/Switch/Switch.tsx +1 -1
  86. package/src/components/Tabs/Tabs.tsx +0 -1
  87. package/src/components/Textarea/Textarea.tsx +3 -0
  88. package/src/components/ThemedImage/ThemedImage.stories.tsx +14 -14
  89. package/src/components/Toast/ToastItem.tsx +1 -1
  90. package/src/components/ToggleButton/ToggleButtonIcon.tsx +1 -1
  91. package/src/components/ToggleButton/ToggleButtonRoot.tsx +0 -2
  92. package/src/components/UnstyledIconButton/UnstyledIconButtonIcon.tsx +1 -1
  93. package/src/utils/coloursAsArray.ts +1 -1
  94. package/tsconfig.eslint.json +13 -0
  95. package/src/components/Accordion/AccordionItemRoot.figma.tsx +0 -47
  96. package/src/components/DatePicker/DatePickerCalendar.figma.tsx +0 -34
@@ -26,6 +26,7 @@ The `DateInput` component allows users to enter dates manually using separate in
26
26
  - [Flexible Segments](#flexible-segments)
27
27
  - [Grouping Inputs](#grouping-inputs)
28
28
  - [With State](#with-state)
29
+ - [Overriding Styles](#overriding-styles)
29
30
  - [Accessibility](#accessibility)
30
31
 
31
32
  ## Playground
@@ -65,35 +66,38 @@ const MyComponent = () => {
65
66
 
66
67
  ### DateInputProps
67
68
 
68
- | Prop | Type | Default | Description |
69
- | ------------------ | ----------------------------------- | ----------- | ----------------------------------------------------- |
70
- | `label` | `string` | - | Label text displayed above the inputs |
71
- | `helperText` | `string` | - | Helper text displayed below the inputs |
72
- | `helperIcon` | `ComponentType` | - | Icon component to display with helper/validation text |
73
- | `validationStatus` | `'initial' \| 'valid' \| 'invalid'` | `'initial'` | Validation status of the input |
74
- | `validText` | `string` | - | Text to display when validation status is valid |
75
- | `invalidText` | `string` | - | Text to display when validation status is invalid |
76
- | `required` | `boolean` | `false` | Whether the input is required |
77
- | `disabled` | `boolean` | `false` | Whether the input is disabled |
78
- | `readonly` | `boolean` | `false` | Whether the input is read-only |
79
- | `hideDay` | `boolean` | `false` | Whether to hide the day segment |
80
- | `hideMonth` | `boolean` | `false` | Whether to hide the month segment |
81
- | `hideYear` | `boolean` | `false` | Whether to hide the year segment |
82
- | `dayPlaceholder` | `string` | `'DD'` | Placeholder text for the day segment |
83
- | `monthPlaceholder` | `string` | `'MM'` | Placeholder text for the month segment |
84
- | `yearPlaceholder` | `string` | `'YYYY'` | Placeholder text for the year segment |
85
- | `dayValue` | `string` | - | Controlled value for the day segment |
86
- | `monthValue` | `string` | - | Controlled value for the month segment |
87
- | `yearValue` | `string` | - | Controlled value for the year segment |
88
- | `onDayChange` | `(text: string) => void` | - | Callback fired when the day value changes |
89
- | `onMonthChange` | `(text: string) => void` | - | Callback fired when the month value changes |
90
- | `onYearChange` | `(text: string) => void` | - | Callback fired when the year value changes |
91
- | `onDayFocus` | `(e: NativeSyntheticEvent) => void` | - | Callback fired when the day segment receives focus |
92
- | `onMonthFocus` | `(e: NativeSyntheticEvent) => void` | - | Callback fired when the month segment receives focus |
93
- | `onYearFocus` | `(e: NativeSyntheticEvent) => void` | - | Callback fired when the year segment receives focus |
94
- | `onDayBlur` | `(e: NativeSyntheticEvent) => void` | - | Callback fired when the day segment loses focus |
95
- | `onMonthBlur` | `(e: NativeSyntheticEvent) => void` | - | Callback fired when the month segment loses focus |
96
- | `onYearBlur` | `(e: NativeSyntheticEvent) => void` | - | Callback fired when the year segment loses focus |
69
+ | Prop | Type | Default | Description |
70
+ | --------------------- | ----------------------------------- | ----------- | ----------------------------------------------------- |
71
+ | `label` | `string` | - | Label text displayed above the inputs |
72
+ | `helperText` | `string` | - | Helper text displayed below the inputs |
73
+ | `helperIcon` | `ComponentType` | - | Icon component to display with helper/validation text |
74
+ | `validationStatus` | `'initial' \| 'valid' \| 'invalid'` | `'initial'` | Validation status of the input |
75
+ | `validText` | `string` | - | Text to display when validation status is valid |
76
+ | `invalidText` | `string` | - | Text to display when validation status is invalid |
77
+ | `required` | `boolean` | `false` | Whether the input is required |
78
+ | `disabled` | `boolean` | `false` | Whether the input is disabled |
79
+ | `readonly` | `boolean` | `false` | Whether the input is read-only |
80
+ | `hideDay` | `boolean` | `false` | Whether to hide the day segment |
81
+ | `hideMonth` | `boolean` | `false` | Whether to hide the month segment |
82
+ | `hideYear` | `boolean` | `false` | Whether to hide the year segment |
83
+ | `dayPlaceholder` | `string` | `'DD'` | Placeholder text for the day segment |
84
+ | `monthPlaceholder` | `string` | `'MM'` | Placeholder text for the month segment |
85
+ | `yearPlaceholder` | `string` | `'YYYY'` | Placeholder text for the year segment |
86
+ | `dayValue` | `string` | - | Controlled value for the day segment |
87
+ | `monthValue` | `string` | - | Controlled value for the month segment |
88
+ | `yearValue` | `string` | - | Controlled value for the year segment |
89
+ | `onDayChange` | `(text: string) => void` | - | Callback fired when the day value changes |
90
+ | `onMonthChange` | `(text: string) => void` | - | Callback fired when the month value changes |
91
+ | `onYearChange` | `(text: string) => void` | - | Callback fired when the year value changes |
92
+ | `onDayFocus` | `(e: NativeSyntheticEvent) => void` | - | Callback fired when the day segment receives focus |
93
+ | `onMonthFocus` | `(e: NativeSyntheticEvent) => void` | - | Callback fired when the month segment receives focus |
94
+ | `onYearFocus` | `(e: NativeSyntheticEvent) => void` | - | Callback fired when the year segment receives focus |
95
+ | `onDayBlur` | `(e: NativeSyntheticEvent) => void` | - | Callback fired when the day segment loses focus |
96
+ | `onMonthBlur` | `(e: NativeSyntheticEvent) => void` | - | Callback fired when the month segment loses focus |
97
+ | `onYearBlur` | `(e: NativeSyntheticEvent) => void` | - | Callback fired when the year segment loses focus |
98
+ | `inputContainerStyle` | `ViewStyle` | - | Custom style for each input container |
99
+ | `inputStyle` | `ViewStyle` | - | Custom style for each input field |
100
+ | `inputLabelStyle` | `TextStyle` | - | Custom style for each input label |
97
101
 
98
102
  ## Examples
99
103
 
@@ -155,6 +159,20 @@ Programmatically control date values:
155
159
 
156
160
  <Canvas of={Stories.WithState} />
157
161
 
162
+ ### Overriding Styles
163
+
164
+ You can override the styles of the input containers, input fields, and input labels using the `inputContainerStyle`, `inputStyle`, and `inputLabelStyle` props respectively:
165
+
166
+ <Canvas of={Stories.CustomWidth} />
167
+
168
+ ```tsx
169
+ <DateInput
170
+ label="Custom width date input"
171
+ helperText="Date input with custom width"
172
+ inputContainerStyle={{ maxWidth: 'auto' }}
173
+ />
174
+ ```
175
+
158
176
  ## Accessibility
159
177
 
160
178
  - Each segment has a descriptive label ("Day", "Month", "Year") for screen readers
@@ -1,60 +1,72 @@
1
- import React from "react"
2
- import DateInput from "./DateInput"
3
- import figma from "@figma/code-connect"
4
-
5
- /**
6
- * -- This file was auto-generated by Code Connect --
7
- * `props` includes a mapping from your code props to Figma properties.
8
- * You should check this is correct, and update the `example` function
9
- * to return the code example you'd like to see in Figma
10
- */
1
+ import figma from '@figma/code-connect';
2
+ import { DateInput } from '../';
11
3
 
12
4
  figma.connect(
13
5
  DateInput,
14
- "https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=2277%3A14708",
6
+ 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=2277%3A14708',
15
7
  {
16
8
  props: {
17
- // These props were automatically mapped based on your linked code:
18
- hideDay: figma.boolean("Day?"),
19
- hideMonth: figma.boolean("Month?"),
20
- monthPlaceholder: figma.string("Month value"),
21
- yearPlaceholder: figma.string("Year value"),
22
- dayValue: figma.string("Day value"),
23
- monthValue: figma.string("Month value"),
24
- yearValue: figma.string("Year value"),
25
- disabled: figma.enum("State", {
9
+ hideDay: figma.boolean('Day?', {
10
+ true: false,
11
+ false: true,
12
+ }),
13
+ hideMonth: figma.boolean('Month?', {
14
+ true: false,
15
+ false: true,
16
+ }),
17
+ // hideYear: figma.boolean('Year?'),
18
+ monthPlaceholder: figma.enum('Value type', {
19
+ Placeholder: figma.boolean('Month?', {
20
+ true: figma.string('Month value'),
21
+ }),
22
+ }),
23
+ yearPlaceholder: figma.enum('Value type', {
24
+ Placeholder: figma.string('Year value'),
25
+ }),
26
+ dayPlaceholder: figma.enum('Value type', {
27
+ Placeholder: figma.boolean('Day?', {
28
+ true: figma.string('Day value'),
29
+ }),
30
+ }),
31
+ dayValue: figma.enum('Value type', {
32
+ Filled: figma.boolean('Day?', {
33
+ true: figma.string('Day value'),
34
+ }),
35
+ }),
36
+ monthValue: figma.enum('Value type', {
37
+ Filled: figma.boolean('Month?', {
38
+ true: figma.string('Month value'),
39
+ }),
40
+ }),
41
+ yearValue: figma.enum('Value type', {
42
+ Filled: figma.string('Year value'),
43
+ }),
44
+ disabled: figma.enum('State', {
26
45
  Disabled: true,
27
46
  }),
28
- readonly: figma.enum("State", {
29
- "Read-only": true,
47
+ readonly: figma.enum('State', {
48
+ 'Read-only': true,
49
+ }),
50
+ label: figma.string('Label'),
51
+ helperText: figma.string('Helper text'),
52
+ validText: figma.enum('State', {
53
+ Valid: figma.string('Validation'),
54
+ }),
55
+ invalidText: figma.enum('State', {
56
+ Invalid: figma.string('Validation'),
57
+ }),
58
+ validationStatus: figma.enum('State', {
59
+ Default: undefined,
60
+ Valid: 'valid',
61
+ Invalid: 'invalid',
30
62
  }),
31
- label: figma.string("Label"),
32
- helperText: figma.string("Helper text"),
33
- validText: figma.string("Validation"),
34
- invalidText: figma.string("Helper text"),
35
63
  // No matching props could be found for these Figma properties:
36
- // "helperText": figma.boolean('Helper text?'),
37
- // "label": figma.string('Label'),
38
- // "validation": figma.string('Validation'),
39
- // "helperText": figma.string('Helper text'),
40
- // "dayValue": figma.string('Day value'),
41
- // "day": figma.boolean('Day?'),
42
- // "month": figma.boolean('Month?'),
43
- // "monthValue": figma.string('Month value'),
44
- // "yearValue": figma.string('Year value'),
45
- // "optional": figma.boolean('Optional?'),
46
- // "valueType": figma.enum('Value type', {
47
- // "Empty": "empty",
48
- // "Placeholder": "placeholder",
49
- // "Filled": "filled"
50
- // }),
51
- // "focus": figma.boolean('Focus?'),
52
64
  // "labelVariant": figma.enum('Label variant', {
53
65
  // "Body": "body",
54
66
  // "Heading": "heading"
55
67
  // })
56
68
  },
57
- example: (props) => (
69
+ example: props => (
58
70
  <DateInput
59
71
  hideDay={props.hideDay}
60
72
  hideMonth={props.hideMonth}
@@ -69,7 +81,8 @@ figma.connect(
69
81
  helperText={props.helperText}
70
82
  validText={props.validText}
71
83
  invalidText={props.invalidText}
84
+ validationStatus={props.validationStatus}
72
85
  />
73
86
  ),
74
- },
75
- )
87
+ }
88
+ );
@@ -1,5 +1,6 @@
1
- import type { TextInputProps } from 'react-native';
1
+ import type { TextInputProps, ViewProps } from 'react-native';
2
2
  import type { FormFieldBaseProps } from '../FormField/FormField.props';
3
+ import LabelProps from '../Label/Label.props';
3
4
 
4
5
  export interface DateInputProps extends FormFieldBaseProps {
5
6
  /**
@@ -77,4 +78,34 @@ export interface DateInputProps extends FormFieldBaseProps {
77
78
  * Callback fired when the year segment loses focus.
78
79
  */
79
80
  onYearBlur?: TextInputProps['onBlur'];
81
+ /*
82
+ * Style for all the input segment's container.
83
+ */
84
+ inputContainerStyle?: ViewProps['style'];
85
+ /*
86
+ * Style for all the input segment's TextInput.
87
+ */
88
+ inputStyle?: ViewProps['style'];
89
+ /*
90
+ * Style for all the input segment's label.
91
+ */
92
+ inputLabelStyle?: LabelProps['style'];
93
+ }
94
+
95
+ export interface DateInputSegmentProps {
96
+ label: string;
97
+ placeholder?: string;
98
+ value?: string;
99
+ onChange?: (text: string) => void;
100
+ onFocus?: DateInputProps['onDayFocus'];
101
+ onBlur?: DateInputProps['onDayBlur'];
102
+ disabled?: boolean;
103
+ required?: boolean;
104
+ validationStatus?: DateInputProps['validationStatus'];
105
+ maxLength?: number;
106
+ readonly?: boolean;
107
+ testID?: string;
108
+ inputContainerStyle?: ViewProps['style'];
109
+ inputStyle?: ViewProps['style'];
110
+ inputLabelStyle?: LabelProps['style'];
80
111
  }
@@ -267,3 +267,13 @@ export const WithState: Story = {
267
267
  );
268
268
  },
269
269
  };
270
+
271
+ export const CustomWidth: Story = {
272
+ render: () => (
273
+ <DateInput
274
+ label="Custom width date input"
275
+ helperText="Date input with custom width"
276
+ inputContainerStyle={{ maxWidth: 'auto' }}
277
+ />
278
+ ),
279
+ };
@@ -32,6 +32,9 @@ const DateInput = ({
32
32
  onDayBlur,
33
33
  onMonthBlur,
34
34
  onYearBlur,
35
+ inputLabelStyle,
36
+ inputContainerStyle,
37
+ inputStyle,
35
38
  ...props
36
39
  }: DateInputProps) => {
37
40
  return (
@@ -63,6 +66,9 @@ const DateInput = ({
63
66
  validationStatus={validationStatus}
64
67
  maxLength={2}
65
68
  testID="date-input-day"
69
+ inputContainerStyle={inputContainerStyle}
70
+ inputStyle={inputStyle}
71
+ inputLabelStyle={inputLabelStyle}
66
72
  />
67
73
  )}
68
74
  {!hideMonth && (
@@ -79,6 +85,9 @@ const DateInput = ({
79
85
  validationStatus={validationStatus}
80
86
  maxLength={2}
81
87
  testID="date-input-month"
88
+ inputContainerStyle={inputContainerStyle}
89
+ inputStyle={inputStyle}
90
+ inputLabelStyle={inputLabelStyle}
82
91
  />
83
92
  )}
84
93
  {!hideYear && (
@@ -95,6 +104,9 @@ const DateInput = ({
95
104
  validationStatus={validationStatus}
96
105
  maxLength={4}
97
106
  testID="date-input-year"
107
+ inputContainerStyle={inputContainerStyle}
108
+ inputStyle={inputStyle}
109
+ inputLabelStyle={inputLabelStyle}
98
110
  />
99
111
  )}
100
112
  </View>
@@ -2,22 +2,7 @@ import { View } from 'react-native';
2
2
  import { StyleSheet } from 'react-native-unistyles';
3
3
  import { BodyText } from '../BodyText';
4
4
  import { Input } from '../Input';
5
- import type { DateInputProps } from './DateInput.props';
6
-
7
- interface DateInputSegmentProps {
8
- label: string;
9
- placeholder?: string;
10
- value?: string;
11
- onChange?: (text: string) => void;
12
- onFocus?: DateInputProps['onDayFocus'];
13
- onBlur?: DateInputProps['onDayBlur'];
14
- disabled?: boolean;
15
- required?: boolean;
16
- validationStatus?: DateInputProps['validationStatus'];
17
- maxLength?: number;
18
- readonly?: boolean;
19
- testID?: string;
20
- }
5
+ import type { DateInputSegmentProps } from './DateInput.props';
21
6
 
22
7
  const DateInputSegment = ({
23
8
  label,
@@ -31,11 +16,14 @@ const DateInputSegment = ({
31
16
  maxLength,
32
17
  readonly,
33
18
  testID,
19
+ inputContainerStyle,
20
+ inputStyle,
21
+ inputLabelStyle,
34
22
  }: DateInputSegmentProps) => {
35
23
  styles.useVariants({ disabled });
36
24
  return (
37
- <View style={styles.container}>
38
- <BodyText size="md" style={styles.label}>
25
+ <View style={[styles.container, inputContainerStyle]}>
26
+ <BodyText size="md" style={[styles.label, inputLabelStyle]}>
39
27
  {label}
40
28
  </BodyText>
41
29
  <Input
@@ -51,7 +39,7 @@ const DateInputSegment = ({
51
39
  disabled={disabled}
52
40
  validationStatus={validationStatus}
53
41
  readonly={readonly}
54
- style={styles.input}
42
+ style={inputStyle}
55
43
  />
56
44
  </View>
57
45
  );
@@ -74,9 +62,6 @@ const styles = StyleSheet.create(theme => ({
74
62
  },
75
63
  },
76
64
  },
77
- input: {
78
- maxWidth: 96,
79
- },
80
65
  }));
81
66
 
82
67
  export default DateInputSegment;
@@ -0,0 +1,47 @@
1
+ import figma from '@figma/code-connect';
2
+ import { DatePicker } from '../';
3
+
4
+ const selectedDate = '';
5
+ const handlePickerChange = () => {
6
+ // Placeholder for onChange handler
7
+ };
8
+ const handleCancel = () => {
9
+ // Placeholder for onCancel handler
10
+ };
11
+
12
+ const pickerRef = () => null;
13
+
14
+ figma.connect(
15
+ DatePicker,
16
+ 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR/Hearth-Components---Tokens?node-id=3797-6383&m=dev',
17
+ {
18
+ props: {
19
+ // "grabber": figma.boolean('Grabber?'),
20
+ header: figma.boolean('Header?', {
21
+ true: false,
22
+ false: true,
23
+ }),
24
+ footer: figma.boolean('Footer?', {
25
+ true: false,
26
+ false: true,
27
+ }),
28
+ initialView: figma.enum('Type', {
29
+ Day: undefined,
30
+ Month: 'month',
31
+ Year: 'year',
32
+ }),
33
+ },
34
+ example: props => (
35
+ <DatePicker
36
+ ref={pickerRef}
37
+ mode="single"
38
+ date={selectedDate}
39
+ hideFooter={props.footer}
40
+ hideHeader={props.header}
41
+ initialView={props.initialView}
42
+ onChange={handlePickerChange}
43
+ onCancel={handleCancel}
44
+ />
45
+ ),
46
+ }
47
+ );
@@ -52,6 +52,7 @@ export interface DatePickerMultipleProps extends DatePickerBaseProps {
52
52
  const DateTimePicker = (
53
53
  props: DatePickerSingleProps | DatePickerRangeProps | DatePickerMultipleProps
54
54
  ) => {
55
+ // eslint-disable-next-line @typescript-eslint/prefer-as-const
55
56
  const numerals: 'latn' = 'latn';
56
57
  const {
57
58
  mode = 'single',
@@ -216,26 +217,29 @@ const DateTimePicker = (
216
217
  ...prevState,
217
218
  currentYear: action.payload,
218
219
  };
219
- case CalendarActionKind.CHANGE_SELECTED_DATE:
220
+ case CalendarActionKind.CHANGE_SELECTED_DATE: {
220
221
  const { date: selectedDate } = action.payload;
221
222
  return {
222
223
  ...prevState,
223
224
  date: selectedDate,
224
225
  currentDate: selectedDate,
225
226
  };
226
- case CalendarActionKind.CHANGE_SELECTED_RANGE:
227
+ }
228
+ case CalendarActionKind.CHANGE_SELECTED_RANGE: {
227
229
  const { startDate: start, endDate: end } = action.payload;
228
230
  return {
229
231
  ...prevState,
230
232
  startDate: start,
231
233
  endDate: end,
232
234
  };
233
- case CalendarActionKind.CHANGE_SELECTED_MULTIPLE:
235
+ }
236
+ case CalendarActionKind.CHANGE_SELECTED_MULTIPLE: {
234
237
  const { dates: selectedDates } = action.payload;
235
238
  return {
236
239
  ...prevState,
237
240
  dates: selectedDates,
238
241
  };
242
+ }
239
243
  case CalendarActionKind.RESET_STATE:
240
244
  return action.payload;
241
245
  default:
@@ -363,7 +367,7 @@ const DateTimePicker = (
363
367
  });
364
368
  } else if (mode === 'range') {
365
369
  // set time to 00:00:00
366
- let start = removeTime(stateRef.current.startDate, timeZone);
370
+ const start = removeTime(stateRef.current.startDate, timeZone);
367
371
  let end = removeTime(stateRef.current.endDate, timeZone);
368
372
  const selected = removeTime(selectedDate, timeZone);
369
373
  let isStart: boolean = true;
@@ -6,5 +6,3 @@ export type HeaderProps = {
6
6
  NextIcon?: React.ReactNode;
7
7
  navigationPosition?: NavigationPosition;
8
8
  };
9
-
10
- export type NavigationProps = {};
@@ -1,12 +1,12 @@
1
1
  import { memo } from 'react';
2
2
  import { View } from 'react-native';
3
3
  import { StyleSheet } from 'react-native-unistyles';
4
- import type { HeaderProps, NavigationProps } from './DatePickerHeader.props';
4
+ import type { HeaderProps } from './DatePickerHeader.props';
5
5
  import NextButton from './DatePickerNextButton';
6
6
  import PrevButton from './DatePickerPrevButton';
7
7
  import Selectors from './DatePickerSelectors';
8
8
 
9
- const NavigationButtons = ({}: NavigationProps) => (
9
+ const NavigationButtons = () => (
10
10
  <View style={styles.navigation}>
11
11
  <PrevButton />
12
12
  <NextButton />
@@ -1,6 +1,8 @@
1
1
  import 'dayjs/locale/en';
2
2
  import './polyfill';
3
3
 
4
+ export type { BottomSheetMethods as DatePickerMethods } from '@gorhom/bottom-sheet/lib/typescript/types';
5
+
4
6
  export type {
5
7
  CalendarDay,
6
8
  CalendarMode,
@@ -1,6 +1,6 @@
1
- // @ts-ignore
1
+ // @ts-expect-error - Polyfill for Date.toLocaleString to support timeZone option in React Native environment.
2
2
  Date.prototype._toLocaleString = Date.prototype.toLocaleString;
3
- // @ts-ignore
3
+ // @ts-expect-error - Polyfill for Date.toLocaleString to support timeZone option in React Native environment.
4
4
  Date.prototype.toLocaleString = function (a, b) {
5
5
  if (b && Object.keys(b).length === 1 && 'timeZone' in b && a === 'en-US') {
6
6
  return Intl.DateTimeFormat('en-us', {
@@ -16,6 +16,6 @@ Date.prototype.toLocaleString = function (a, b) {
16
16
  .format(this)
17
17
  .replace(/(\d{2})\/(\d{2})\/(\d{4}),/g, '$3-$1-$2');
18
18
  }
19
- // @ts-ignore
19
+ // @ts-expect-error - Polyfill for Date.toLocaleString to support timeZone option in React Native environment.
20
20
  return this._toLocaleString(a, b);
21
21
  };
@@ -121,7 +121,6 @@ const WheelWeb = ({ value, setValue = () => {}, items }: WheelProps) => {
121
121
  return (
122
122
  <Animated.View
123
123
  key={`${displayValue?.text}-${index}`}
124
- // eslint-disable-next-line react-native/no-inline-styles
125
124
  style={{
126
125
  position: 'absolute',
127
126
  height: ITEM_HEIGHT - 10,
@@ -1,62 +1,34 @@
1
1
  import figma from '@figma/code-connect';
2
- import DatePickerInput from './DatePickerInput';
3
-
4
- /**
5
- * -- This file was auto-generated by Code Connect --
6
- * `props` includes a mapping from your code props to Figma properties.
7
- * You should check this is correct, and update the `example` function
8
- * to return the code example you'd like to see in Figma
9
- */
2
+ import { DatePickerInput } from '../';
10
3
 
11
4
  figma.connect(
12
5
  DatePickerInput,
13
6
  'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=3917%3A7057',
14
7
  {
15
8
  props: {
16
- // These props were automatically mapped based on your linked code:
17
9
  disabled: figma.enum('Variant', {
18
10
  Disabled: true,
19
11
  }),
20
- readonly: figma.enum('Variant', {
21
- 'Read-only': true,
12
+ validationStatus: figma.enum('Variant', {
13
+ Default: undefined,
14
+ Valid: 'valid',
15
+ Invalid: 'invalid',
22
16
  }),
23
- focused: figma.boolean('Focus?'),
24
- placeholder: figma.string('Label'),
25
- autoFocus: figma.boolean('Focus?'),
26
- defaultValue: figma.string('Value'),
27
- readOnly: figma.enum('Variant', {
28
- 'Read-only': true,
17
+ readonly: figma.enum('Variant', { Readonly: true }),
18
+ label: figma.string('Label'),
19
+ validText: figma.enum('Variant', {
20
+ Valid: figma.string('Validation'),
29
21
  }),
30
- focusable: figma.boolean('Focus?'),
31
- hasTVPreferredFocus: figma.boolean('Focus?'),
32
- 'aria-disabled': figma.enum('Variant', {
33
- Disabled: true,
22
+ invalidText: figma.enum('Variant', {
23
+ Invalid: figma.string('Validation'),
24
+ }),
25
+ placeholder: figma.enum('Value type', {
26
+ Placeholder: figma.string('Value'),
27
+ }),
28
+ value: figma.enum('Value type', {
29
+ Filled: figma.string('Value'),
34
30
  }),
35
- // No matching props could be found for these Figma properties:
36
- // "helperText": figma.boolean('Helper text?'),
37
- // "label": figma.string('Label'),
38
- // "validation": figma.string('Validation'),
39
- // "helperText": figma.string('Helper text'),
40
- // "value": figma.string('Value'),
41
- // "icon": figma.boolean('Icon?'),
42
- // "calendar": figma.boolean('Calendar?'),
43
- // "valueType": figma.enum('Value type', {
44
- // "Empty": "empty",
45
- // "Placeholder": "placeholder",
46
- // "Filled": "filled"
47
- // })
48
31
  },
49
- example: props => (
50
- <DatePickerInput
51
- disabled={props.disabled}
52
- readonly={props.readonly}
53
- focused={props.focused}
54
- placeholder={props.placeholder}
55
- autoFocus={props.autoFocus}
56
- defaultValue={props.defaultValue}
57
- readOnly={props.readOnly}
58
- focusable={props.focusable}
59
- />
60
- ),
32
+ example: props => <DatePickerInput {...props} />,
61
33
  }
62
34
  );
@@ -53,7 +53,6 @@ const DatePickerInput = ({
53
53
  ...rest
54
54
  }: DatePickerInputProps) => {
55
55
  const formFieldContext = useFormFieldContext();
56
- const validationStatusFromContext = formFieldContext?.validationStatus ?? validationStatus;
57
56
  const isDisabled = formFieldContext?.disabled ?? disabled;
58
57
  const isReadonly = formFieldContext?.readonly ?? readonly;
59
58
 
@@ -168,7 +167,6 @@ const DatePickerInput = ({
168
167
  accessibilityHint: accessibilityHintProp,
169
168
  accessibilityLabel: accessibilityLabelProp,
170
169
  accessible: accessibleProp,
171
- accessibilityRole: accessibilityRoleProp,
172
170
  importantForAccessibility: importantForAccessibilityProp,
173
171
  ...textInputProps
174
172
  } = rest;