Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ export const Bars = ({ series, horizontal, displayStyle }: BarGroupProps) => {
colorAccessor={(datum: BarChartDataPoint) => {
if (focusedItemLabel === datum.label) {
return hoverColorAccessorByIndex(seriesIndex);
} else {
return colorAccessorByIndex(seriesIndex);
}
return colorAccessorByIndex(seriesIndex);
}}
onPointerMove={isOverlapped ? onPointerMove : undefined}
onPointerOut={isOverlapped ? onPointerOut : undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ export const createBackfilledSeries = (series: LineChartSeries[]): LineChartSeri
dataPoints,
})),
];
} else {
return accumulator;
}
return accumulator;
}, []);
};
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,12 @@ const addDataPointToGroup = (
value: (group.value ?? 0) + (dataPoint.value ?? 0),
groupIds: [...(group.groupIds || []), dataPoint.id],
};
} else {
return {
...dataPoint,
id: groupId,
description: '',
groupIds: [dataPoint.id],
parentId: parentGroup ? `group-${parentGroup.color}` : dataPoint.parentId,
};
}
return {
...dataPoint,
id: groupId,
description: '',
groupIds: [dataPoint.id],
parentId: parentGroup ? `group-${parentGroup.color}` : dataPoint.parentId,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const getFormattedTooltipDate = (timestamp?: Date, locale?: string) => {
day: '2-digit',
year: 'numeric',
}).format(timestamp);
} else {
return '';
}
return '';
};
6 changes: 3 additions & 3 deletions packages/components/scripts/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Converts any given input to kebab-case
*
* @param name String in any case (PascalCase, camelCase, ...)
* @param name - String in any case (PascalCase, camelCase, ...)
* @returns String in kebab-case
*/
export const toKebabCase = (name: string): string =>
Expand All @@ -14,15 +14,15 @@ export const toKebabCase = (name: string): string =>
/**
* Converts any given input to UPPERCASE_SNAKE_CASE
*
* @param name String in any case (PascalCase, camelCase, ...)
* @param name - String in any case (PascalCase, camelCase, ...)
* @returns String in UPPERCASE_SNAKE_CASE
*/
export const toUpperSnakeCase = (name: string): string => name.replaceAll(/([a-z])([A-Z])/g, '$1_$2').toUpperCase();

/**
* Converts any given input to camelCase
*
* @param name String in any case (PascalCase, kebab-case, ...)
* @param name - String in any case (PascalCase, kebab-case, ...)
* @returns String in camelCase
*/
export const toCamelCase = (name: string): string => {
Expand Down
3 changes: 1 addition & 2 deletions packages/components/src/components/Badge/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export const DEFAULT_COLOR = { red: 255, green: 255, blue: 255, alpha: 1, name:

/**
* Converts a color object to a CSS color string.
* @param {RgbaColor} color - The color object to be converted.
* @returns {string}
* @param color - The color object to be converted.
* @example
* colorToCss({ red: 255, green: 255, blue: 255, alpha: 1 }); // 'rgba(255, 255, 255, 1)'
* @example
Expand Down
27 changes: 10 additions & 17 deletions packages/components/src/components/ColorPicker/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export const DEFAULT_FORMAT = 'HEX';

/**
* Converts a color object to a CSS color string.
* @param {RgbaColor} color - The color object to be converted.
* @returns {string}
* @param color - The color object to be converted.
* @example
* colorToCss({ red: 255, green: 255, blue: 255, alpha: 1 }); // 'rgba(255, 255, 255, 1)'
* @example
Expand All @@ -26,8 +25,7 @@ export const colorToCss = (color?: RgbaColor) => {
/**
* Checks if a string is a valid hexadecimal color code. This function accepts
* both three-digit and six-digit hex codes without the '#' symbol.
* @param {string} color - The color code to be checked.
* @returns {boolean}
* @param color - The color code to be checked.
* @example
* isValidHexColor('FFF'); // true
* @example
Expand All @@ -43,8 +41,7 @@ export const isValidHexColor = (color: string): boolean => {
/**
* Converts a hexadecimal color code to an RGBA color object. This function accepts
* both three-digit and six-digit hex codes without the '#' symbol.
* @param {string} hex - The hex code, either 3 or 6 characters long. Characters should be from the set [0-9A-Fa-f].
* @returns {RgbaColor}
* @param hex - The hex code, either 3 or 6 characters long. Characters should be from the set [0-9A-Fa-f].
* @example
* hexColorToRgba('FFF'); // { red: 255, green: 255, blue: 255, alpha: 1 }
* @example
Expand Down Expand Up @@ -83,8 +80,7 @@ export const hexColorToRgba = (hex: string): RgbaColor => {
/**
* Converts an RGBA color object to a hexadecimal color code. This function returns a
* six-digit hex code without the '#' symbol.
* @param {RgbaColor} rgb - The RGBA color object.
* @returns {string}
* @param rgb - The RGBA color object.
* @example
* rgbColorToHex({ red: 255, green: 255, blue: 255, alpha: 1 }); // '#FFFFFF'
* @example
Expand All @@ -99,8 +95,7 @@ export const rgbColorToHex = (rgb: Omit<RgbaColor, 'alpha'>): string => {

/**
* Returns a hex color display name with alpha percentage if alpha < 100%.
* @param {RgbaColor} color - The RGBA color object.
* @returns {string}
* @param color - The RGBA color object.
* @example
* getHexDisplayName({ red: 255, green: 255, blue: 255, alpha: 1 }); // '#FFFFFF'
* @example
Expand All @@ -122,9 +117,8 @@ export const getHexDisplayName = (color: RgbaColor): string => {

/**
* Returns a color object with a name property based on the provided color and format.
* @param {RgbaColor} color - The RGBA color object.
* @param {ColorFormat} currentFormat - The current format of the color.
* @returns {RgbaColor}
* @param color - The RGBA color object.
* @param currentFormat - The current format of the color.
* @example
* getColorWithName({ red: 255, green: 255, blue: 255, alpha: 1 }, 'HEX'); // { red: 255, green: 255, blue: 255, alpha: 1, name: '#FFFFFF' }
* @example
Expand All @@ -149,10 +143,9 @@ export const getColorWithName = (color: RgbaColor, currentFormat: ColorFormat) =

/**
* Returns a number between a minimum and maximum value, inclusive.
* @param {string} value - The value to be limited.
* @param {number} [min=0] - The minimum value (inclusive).
* @param {number} [max=255] - The maximum value (inclusive).
* @returns {number}
* @param value - The value to be limited.
* @param [min=0] - The minimum value (inclusive).
* @param [max=255] - The maximum value (inclusive).
* @example
* getLimitedColorChannelValue('255'); // 255
* @example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ const useAsyncItems = (filterText: string, getAsyncItems?: AsyncItemsFetcher) =>
* Recursively extracts option values from children.
* This function traverses through the React component tree and collects all SelectItem values.
*
* @param {ReactNode} children - The React children to extract values from.
* @returns {SelectItemType[]} An array of SelectItemType objects.
* @param children - The React children to extract values from.
* @returns An array of SelectItemType objects.
*
* @example
* const options = (
Expand Down Expand Up @@ -105,9 +105,9 @@ export const getRecursiveOptionValues = (
/**
* Custom hook for managing select data and filtering.
*
* @param {ReactNode} children - The React children to process, typically SelectItem components.
* @param {AsyncItemsFetcher} [getAsyncItems] - Optional function to fetch items asynchronously based on filter text.
* @returns {Object} An object containing the processed data.
* @param children - The React children to process, typically SelectItem components.
* @param [getAsyncItems] - Optional function to fetch items asynchronously based on filter text.
* @returns An object containing the processed data.
*/
export const useSelectData = (children: ReactNode, getAsyncItems?: AsyncItemsFetcher) => {
const [filterText, setFilterText] = useState('');
Expand Down
20 changes: 10 additions & 10 deletions packages/components/src/components/Select/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { ForwardedRefSelectItem, ForwardedRefSelectItemGroup, type SelectItemPro
* Extracts and returns an object containing `value` and `label` from a given SelectItemProps object.
* It prioritizes explicit `value` and `label` properties but will fall back to using `children` as the value or label if necessary.
*
* @param {SelectItemProps} props - The properties of a select item, which include potential children, value, and label.
* @returns {{ value: string; label: string, children?: ReactNode }} An object containing `value` and `label` as strings.
* @param props - The properties of a select item, which include potential children, value, and label.
* @returns An object containing `value` and `label` as strings.
*
* @example
* // Returns { value: 'option1', label: 'Option 1' }
Expand Down Expand Up @@ -52,9 +52,9 @@ export const getSelectOptionValue = ({
/**
* Determines if the child is a leaf node of React, meaning it has one final child of a native type;
*
* @param {ReactNode} child - The React child node to check.
* @param {JSXElementConstructor<never>} Component - The React component constructor used for comparison.
* @returns {boolean} Returns true if the `child` is a valid React element of the specified `Component` type.
* @param child - The React child node to check.
* @param Component - The React component constructor used for comparison.
* @returns Returns true if the `child` is a valid React element of the specified `Component` type.
*
* @example
* // Assuming ForwardedRefSelectItem is a component that renders an <input> element
Expand All @@ -72,11 +72,11 @@ export const isReactLeaf = (child: ReactNode, Component: JSXElementConstructor<n
* Recursively maps through React children, applying a callback to each child that meets the specified conditions.
* This function is useful for deeply nested structures where modifications or checks are needed at multiple levels.
*
* @param {ReactNode} children - The children to be recursively processed.
* @param {function(ReactNode, number): ReactNode} callback - A function that is called for each child that meets the condition. It receives the child and its index, and returns a React node.
* @param {string} [filterText=''] - Optional text used to filter children based on their properties.
* @param {number} [nextIndex=0] - The starting index for numbering children, defaults to 0.
* @returns {{ parsedChildren: ReactNode[], subElementCount: number }} An object containing the transformed children array and the count of all processed sub-elements.
* @param children - The children to be recursively processed.
* @param callback - A function that is called for each child that meets the condition. It receives the child and its index, and returns a React node.
* @param [filterText=''] - Optional text used to filter children based on their properties.
* @param [nextIndex=0] - The starting index for numbering children, defaults to 0.
* @returns An object containing the transformed children array and the count of all processed sub-elements.
*
* @example
* // Example usage in a select component where only items containing a certain text are modified
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/hooks/useSyncRefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { syncRefs } from '#/utilities/domUtilities';
* and allow external access through a forwarded ref.
*
* @template TElement - The type of the DOM element being referenced. Defaults to HTMLElement.
* @param {RefObject<TElement>} localRef - The local ref object used internally by the component.
* @param {ForwardedRef<TElement>} forwardedRef - The ref forwarded from a parent component.
* @param localRef - The local ref object used internally by the component.
* @param forwardedRef - The ref forwarded from a parent component.
*
* @example
* ```tsx
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/hooks/useTextTruncation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useEffect, type RefObject } from 'react';
* It observes the element's size and adds a title attribute with the full text
* when the content is truncated.
*
* @param {RefObject<HTMLElement>} ref - Reference to the HTML element to observe for truncation.
* @param ref - Reference to the HTML element to observe for truncation.
*
* @example
* ```tsx
Expand Down
10 changes: 5 additions & 5 deletions packages/components/src/utilities/domUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const MAX_HEIGHT_MARGIN = 8;
* The function calculates the space below the dialog up to the bottom of the viewport window,
* subtracting a default margin, and sets this value as the max-height style of the dialog.
*
* @param {HTMLElement} dialog - The dialog element whose maximum height is to be set.
* @param dialog - The dialog element whose maximum height is to be set.
*
* @example
* // Suppose you have a dialog element with id 'my-dialog'.
Expand Down Expand Up @@ -41,8 +41,8 @@ export function setMaxHeightToAvailableSpace(dialog: HTMLElement) {
* - The element's computed style must not be `display: none`, `visibility: hidden`, or `opacity: 0`.
* - The element must be within the bounds of the current viewport.
*
* @param {HTMLElement} element - The HTML element to check for visibility.
* @returns {boolean} Returns true if the element is visible according to the criteria specified, otherwise returns false.
* @param element - The HTML element to check for visibility.
* @returns Returns true if the element is visible according to the criteria specified, otherwise returns false.
*/
export function isElementVisible(element: HTMLElement) {
const rect = element.getBoundingClientRect();
Expand All @@ -61,8 +61,8 @@ export function isElementVisible(element: HTMLElement) {
/**
* Assigns a local DOM ref to a forwarded ref.
*
* @param {RefObject<HTMLDivElement>} localRef - The local React reference to an HTMLDivElement.
* @param {ForwardedRef<HTMLDivElement>} forwardedRef - The ref forwarded from a parent component.
* @param localRef - The local React reference to an HTMLDivElement.
* @param forwardedRef - The ref forwarded from a parent component.
*/
export function syncRefs<TElement = HTMLElement>(
localRef: RefObject<TElement | null>,
Expand Down
13 changes: 6 additions & 7 deletions packages/fondue/src/components/Badge/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,13 @@ export const getSizeClasses = (
hasMaximumTwoComponents && 'tw-gap-x-1.5',
isDismissable && 'tw-pr-5',
]);
} else {
return merge([
'tw-h-6',
'tw-px-2.5 tw-gap-x-1',
hasMaximumTwoComponents && 'tw-gap-x-2',
isDismissable && 'tw-pr-6',
]);
}
return merge([
'tw-h-6',
'tw-px-2.5 tw-gap-x-1',
hasMaximumTwoComponents && 'tw-gap-x-2',
isDismissable && 'tw-pr-6',
]);
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,11 @@ const getMovementAnnouncement = ({
overId === currentPosition.overId
) {
return;
} else {
setCurrentPosition({
parentId: projected.parentId,
overId,
});
}
setCurrentPosition({
parentId: projected.parentId,
overId,
});
}

const announcementNodes: AnnouncementItem[] = treeState.nodes.map(({ props }) => ({
Expand Down
6 changes: 2 additions & 4 deletions packages/fondue/src/components/Tree/helpers/projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,17 @@ const calculateMaxDepth = (previousNode: ReactElement, nextNode: ReactElement) =
if (previousNode?.props.accepts) {
const nextNodeDepth = getNodeDepth(nextNode);
return previousNodeDepth >= nextNodeDepth ? previousNodeDepth + 1 : nextNodeDepth;
} else {
return previousNodeDepth;
}
return previousNodeDepth;
};

const calculateMinDepth = (previousNode: ReactElement, nextNode: ReactElement) => {
const nextNodeDepth = getNodeDepth(nextNode);

if (previousNode?.props.accepts) {
return nextNodeDepth;
} else {
return Math.min(getNodeDepth(previousNode), nextNodeDepth);
}
return Math.min(getNodeDepth(previousNode), nextNodeDepth);
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ type EnrichedProps = {
/**
* Recursively removes React Fragments and enriches the remaining child elements passed in with additional properties.
*
* @param children The child elements to remove React Fragments from and enrich.
* @param enrichedProps Additional properties to add to each child element.
* @param children - The child elements to remove React Fragments from and enrich.
* @param enrichedProps - Additional properties to add to each child element.
* @returns An array of ReactElements with enriched props.
*
* @example
Expand All @@ -32,7 +32,7 @@ type EnrichedProps = {
*
* const flattenedAndEnriched = flattenAndEnrichChildren(children, enrichedProps);
*
* @returns {ReactElement[]} Array with the three child elements from the example, each with the `parentId` and `level` props added.
* @returns Array with the three child elements from the example, each with the `parentId` and `level` props added.
*
* @deprecated Please use updated Tree component from `@frontify/fondue/components` instead. Also check {@link https://github.com/Frontify/fondue/blob/main/packages/components/MIGRATING.md#tree the migration guide}.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/fondue/src/utilities/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { type MutableRefObject, type Ref, type RefCallback } from 'react';
/**
* Cleans and joins an array of inputs with possible undefined or boolean values.
*
* @param classNames Array of class names
* @param classNames - Array of class names
* @returns Clean string to be used for class name
* @deprecated This function is deprecated and will be removed in the next major version.
*/
Expand Down
3 changes: 1 addition & 2 deletions packages/fondue/tools/codemod/findDeprecatedImports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ const getImports = (pathToAnalyze: string, selectedImports: string[] = []) => {
.map((line) => JSON.parse(line) as { path: string; imports: string[] });
rmSync(join(tempDir), { recursive: true });
return detectedImports;
} else {
return [];
}
return [];
});
};

Expand Down
4 changes: 2 additions & 2 deletions packages/rte/cypress/support/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ declare global {
interface Chainable {
/**
* Mounts a React node
* @param component React Node to mount
* @param options Additional options to pass into mount
* @param component - React Node to mount
* @param options - Additional options to pass into mount
*/
mount(...parameters: Parameters<typeof mount>): ReturnType<typeof mount>;
}
Expand Down
Loading