Skip to content

[♻️]: Refactor to cleanup apis #97

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

Merged
merged 4 commits into from
May 5, 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 lib/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type OwnProps = {
/**
* Used to keep mounting when more control is needed.\
* Useful when controlling animation with React animation libraries.
*
* @default false
*/
keepMounted?: boolean;
Expand Down
1 change: 1 addition & 0 deletions lib/Portal/Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type Props = {
children: React.ReactNode;
/**
* If `true`, the `children` will be under the DOM hierarchy of the parent component.
*
* @default false
*/
disabled?: boolean;
Expand Down
1 change: 1 addition & 0 deletions lib/RadioGroup/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type OwnProps = {
};
/**
* The orientation of the group.
*
* @default "vertical"
*/
orientation?: "horizontal" | "vertical";
Expand Down
20 changes: 4 additions & 16 deletions lib/TabGroup/TabGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as React from "react";
import { SystemError, logger } from "../internals";
import { SystemError } from "../internals";
import type { MergeElementProps } from "../types";
import {
componentWithForwardedRef,
isFragment,
useControlledProp,
useForkedRefs,
useIsMounted,
Expand Down Expand Up @@ -35,12 +34,14 @@ type OwnProps = {
/**
* Indicates whether the element's orientation is horizontal or vertical.
* This effects the keyboard interactions.
*
* @default "horizontal"
*/
orientation?: "horizontal" | "vertical";
/**
* If `automatic`, tabs are automatically activated and their panel is displayed when they receive focus.
* If `manual`, users activate a tab and display its panel by focusing them and pressing `Space` or `Enter`.
*
* @default "manual"
*/
keyboardActivationBehavior?: "manual" | "automatic";
Expand All @@ -53,7 +54,7 @@ export type Props = Omit<

const TabGroupBase = (props: Props, ref: React.Ref<HTMLDivElement>) => {
const {
children: childrenProp,
children,
className,
onActiveTabChange,
defaultActiveTab,
Expand All @@ -78,19 +79,6 @@ const TabGroupBase = (props: Props, ref: React.Ref<HTMLDivElement>) => {
null,
);

const children = React.Children.map(childrenProp, child => {
if (!React.isValidElement(child) || isFragment(child)) {
logger(
"The <TabGroup.Root> component doesn't accept `Fragment` or any invalid element as children.",
{ scope: "TabGroup", type: "error" },
);

return null;
}

return child as React.ReactElement;
});

const handleChange = (tabValue: string) => {
if (!isMounted()) return;

Expand Down
4 changes: 4 additions & 0 deletions lib/Toggle/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,25 @@ type OwnProps = {
value?: string;
/**
* If `true`, the toggle will be focused automatically.
*
* @default false
*/
autoFocus?: boolean;
/**
* If `true`, the toggle will be pressed.
*
* @default false
*/
pressed?: boolean;
/**
* The default state of `pressed`. Use when the component is not controlled.
*
* @default false
*/
defaultPressed?: boolean;
/**
* If `true`, the toggle will be disabled.
*
* @default false
*/
disabled?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion lib/ToggleGroup/ToggleGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export type Props = Omit<
| {
multiple: true;
/**
* The value of the active toggle.
* The value of the active toggles.
*/
value?: string[];
/**
Expand Down
1 change: 1 addition & 0 deletions lib/internals/FocusRedirect/FocusRedirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type Props = {
children: JSX.Element;
/**
* If `true`, the focus will be redirected here (once!).
*
* @default false
*/
enabled?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@styleless-ui/react",
"version": "1.0.0-rc.5",
"version": "1.0.0-rc.6",
"description": "Completely unstyled, headless and accessible React UI components.",
"author": "mimshins <mostafa.sh.coderino@gmail.com>",
"license": "MIT",
Expand Down