-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
fix: refactor wds menu and related components, widgets #33703
Changes from all commits
b6044ac
5403d4b
ed89743
c2fee12
ef509fb
b11c002
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,21 +1,36 @@ | ||||||||||||||
import type { Ref } from "react"; | ||||||||||||||
import type { ReactNode, Ref } from "react"; | ||||||||||||||
import React, { forwardRef } from "react"; | ||||||||||||||
import type { SpectrumFieldProps } from "@react-types/label"; | ||||||||||||||
|
||||||||||||||
import { Label } from "./Label"; | ||||||||||||||
import { HelpText } from "./HelpText"; | ||||||||||||||
import type { StyleProps, ValidationState } from "@react-types/shared"; | ||||||||||||||
|
||||||||||||||
export type FieldProps = Omit< | ||||||||||||||
export type FieldProps = Pick< | ||||||||||||||
SpectrumFieldProps, | ||||||||||||||
"showErrorIcon" | "labelPosition" | "labelAlign" | keyof StyleProps | ||||||||||||||
| "contextualHelp" | ||||||||||||||
| "description" | ||||||||||||||
| "descriptionProps" | ||||||||||||||
| "elementType" | ||||||||||||||
| "errorMessage" | ||||||||||||||
| "errorMessageProps" | ||||||||||||||
| "includeNecessityIndicatorInAccessibilityName" | ||||||||||||||
| "isDisabled" | ||||||||||||||
| "isRequired" | ||||||||||||||
| "label" | ||||||||||||||
| "labelProps" | ||||||||||||||
| "necessityIndicator" | ||||||||||||||
| "wrapperClassName" | ||||||||||||||
| "wrapperProps" | ||||||||||||||
> & { | ||||||||||||||
fieldType?: "field" | "field-group"; | ||||||||||||||
labelClassName?: string; | ||||||||||||||
helpTextClassName?: string; | ||||||||||||||
validationState?: ValidationState; | ||||||||||||||
children: ReactNode; | ||||||||||||||
isReadOnly?: boolean; | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
import type { ValidationState } from "@react-types/shared"; | ||||||||||||||
|
||||||||||||||
export type FieldRef = Ref<HTMLDivElement>; | ||||||||||||||
|
||||||||||||||
const _Field = (props: FieldProps, ref: FieldRef) => { | ||||||||||||||
|
@@ -75,7 +90,9 @@ const _Field = (props: FieldProps, ref: FieldRef) => { | |||||||||||||
includeNecessityIndicatorInAccessibilityName | ||||||||||||||
} | ||||||||||||||
isRequired={isRequired} | ||||||||||||||
necessityIndicator={!Boolean(isReadOnly) && necessityIndicator} | ||||||||||||||
necessityIndicator={ | ||||||||||||||
!Boolean(isReadOnly) ? necessityIndicator : undefined | ||||||||||||||
} | ||||||||||||||
> | ||||||||||||||
Comment on lines
+93
to
+95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactor to simplify necessity indicator logic. The current implementation of the necessity indicator is a bit complex. Consider simplifying it as follows: - !Boolean(isReadOnly) ? necessityIndicator : undefined
+ isReadOnly ? undefined : necessityIndicator This change makes the condition more readable by directly checking the Committable suggestion
Suggested change
|
||||||||||||||
<span>{label}</span> | ||||||||||||||
</Label> | ||||||||||||||
|
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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.
Types are broken due to package updates.