Skip to content
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

Merged
merged 6 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@opentelemetry/sdk-trace-base": "^1.17.1",
"@opentelemetry/sdk-trace-web": "^1.17.1",
"@opentelemetry/semantic-conventions": "^1.17.1",
"@react-types/shared": "^3.23.0",
"@sentry/react": "^6.2.4",
"@sentry/tracing": "^6.2.4",
"@shared/ast": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion app/client/packages/design-system/headless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@react-types/checkbox": "^3.4.3",
"@react-types/label": "^3.7.3",
"@react-types/menu": "^3.9.5",
"@react-types/shared": "^3.22.0",
"@react-types/shared": "^3.23.1",
"classnames": "*"
},
"peerDependencies": {
Expand Down
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"
Copy link
Collaborator Author

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.

| "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) => {
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The 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 isReadOnly state.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
necessityIndicator={
!Boolean(isReadOnly) ? necessityIndicator : undefined
}
necessityIndicator={
isReadOnly ? undefined : necessityIndicator
}

<span>{label}</span>
</Label>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion app/client/packages/design-system/headless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ export * from "./components/Switch";
export * from "./components/TextInput";
export * from "./components/TextArea";
export * from "./components/Popover";
export * from "./components/Menu";
3 changes: 2 additions & 1 deletion app/client/packages/design-system/widgets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
"@react-aria/utils": "^3.16.0",
"@react-aria/visually-hidden": "^3.8.0",
"@react-types/actiongroup": "^3.4.6",
"@react-types/shared": "^3.23.1",
"@tabler/icons-react": "^2.45.0",
"clsx": "^2.0.0",
"colorjs.io": "^0.4.3",
"lodash": "*",
"react-aria-components": "^1.1.1"
"react-aria-components": "^1.2.1"
},
"devDependencies": {
"@types/fs-extra": "^11.0.4",
Expand Down
Loading
Loading