-
Notifications
You must be signed in to change notification settings - Fork 71
[LG-5504] feat(input-box): add InputBoxContext
#3290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: shaneeza/time-picker-integration
Are you sure you want to change the base?
[LG-5504] feat(input-box): add InputBoxContext
#3290
Conversation
…associated types and tests
|
InputBoxContext InputBoxContext
|
Size Change: +31 B (0%) Total Size: 1.61 MB
ℹ️ View Unchanged
|
| return ( | ||
| segment: SegmentEnum[keyof SegmentEnum], | ||
| value: string, | ||
| allowZero?: boolean, | ||
| ): boolean => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could benefit from an object arg
|
|
||
| import { ExplicitSegmentRule } from '../utils'; | ||
|
|
||
| export const SegmentObjMock = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wondering if this may also benefit from time mocks in addition to the date mocks
| @@ -0,0 +1 @@ | |||
| export { type InputSegmentChangeEventHandler } from './InputSegment.types'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will create a circular import between InputBoxContext and InputSegment. This could be addressed by having a shared.types.ts file for types like this change event handler type
| charsPerSegment: Record<Segment, number>; | ||
| disabled: boolean; | ||
| segmentEnum: SegmentEnumObject<Segment>; | ||
| onChange: InputSegmentChangeEventHandler<Segment, string>; | ||
| onBlur: (event: React.FocusEvent<HTMLInputElement>) => void; | ||
| segmentRefs: Record<Segment, ReturnType<DynamicRefGetter<HTMLInputElement>>>; | ||
| segments: Record<Segment, string>; | ||
| labelledBy?: string; | ||
| size: Size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If any of these will be exposed by InputBox, they can also be shared in the shared.types.ts file
Any tsdocs worth adding?
| expect(result.current.charsPerSegment).toBe(charsPerSegmentMock); | ||
| expect(result.current.segmentEnum).toBe(SegmentObjMock); | ||
| expect(result.current.onChange).toBe(mockOnChange); | ||
| expect(result.current.onBlur).toBe(mockOnBlur); | ||
| expect(result.current.segmentRefs).toBe(segmentRefsMock); | ||
| expect(result.current.segments).toBe(segmentsMock); | ||
| expect(result.current.size).toBe(Size.Default); | ||
| expect(result.current.disabled).toBe(false); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could destructure to DRY this up
…se object parameter format for improved clarity and consistency
…ity by destructuring context values
✍️ Proposed changes
This PR is the first PR in a series of PRs that adds the new
InputBoxpackage and integrates it into the existingDatePickerpackage:InputSegment#3293InputBox#3285This PR adds
InputBoxContext, which will be used internally withinInputBoxandInputSegment.🎟 Jira ticket: LG-5504
✅ Checklist
For new components
🧪 How to test changes