@omer-x/tailwind-ui-kit 1.0.0-alpha.33 → 1.0.0-alpha.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -697,6 +697,61 @@ Every part takes `className` and `render`.
697
697
 
698
698
  Data attributes: the item, heading and panel have `data-open` and `data-index`. The trigger has `data-panel-open`. Disabled parts have `data-disabled`. The panel has `data-starting-style` / `data-ending-style` during its transition.
699
699
 
700
+ #### `BaseCollapsible`
701
+
702
+ A Base UI [`Collapsible`](https://base-ui.com/react/components/collapsible): a panel shown or hidden by a button.
703
+
704
+ ```tsx
705
+ import { BaseCollapsible } from "@omer-x/tailwind-ui-kit/disclosure";
706
+
707
+ <BaseCollapsible>
708
+ <BaseCollapsible.Trigger className="rounded-md px-3 py-1.5" icon={<ChevronDown />} iconClassName="in-data-panel-open:rotate-180">
709
+ Recovery keys
710
+ </BaseCollapsible.Trigger>
711
+ <BaseCollapsible.Panel>
712
+ <div className="p-4">alien-bean-pasta</div>
713
+ </BaseCollapsible.Panel>
714
+ </BaseCollapsible>
715
+ ```
716
+
717
+ Like `BaseAccordion`, the parts use dot notation, so build collapsibles in a `"use client"` file.
718
+
719
+ | Part | Renders | Description |
720
+ |------|---------|-------------|
721
+ | `BaseCollapsible` | `<div>` | Groups the trigger with the panel and holds whether it is open |
722
+ | `BaseCollapsible.Trigger` | `<button>` | Opens and closes the panel. An inline flex row with a focus outline |
723
+ | `BaseCollapsible.Panel` | `<div>` | The content, with a height transition (shared with Accordion). **Put padding on an element inside it**, so it can shrink to zero |
724
+
725
+ Every part takes `className` and `render`.
726
+
727
+ `BaseCollapsible` props:
728
+
729
+ | Prop | Type | Default | Description |
730
+ |------|------|---------|-------------|
731
+ | `open` / `defaultOpen` | `boolean` | `false` | Controlled / initial state of the panel |
732
+ | `onOpenChange` | `(open, event) => void` | | Called with the new state and the DOM event that changed it (`undefined` when changed from code) |
733
+ | `disabled` | `boolean` | `false` | Ignores user interaction |
734
+ | `render` | `RenderProp<"div", CollapsibleState>` | | The state is `{ open, disabled }` |
735
+
736
+ `BaseCollapsible.Trigger` props:
737
+
738
+ | Prop | Type | Default | Description |
739
+ |------|------|---------|-------------|
740
+ | `icon` | `ReactNode` | | Shown after the text, in a `<span>` with a transform transition. Nothing is rendered without it |
741
+ | `iconClassName` | `string` | | Classes for the icon's `<span>`, e.g. `in-data-panel-open:rotate-180` |
742
+ | `render` | `RenderProp<"button", CollapsibleState>` | | Replaces the button |
743
+ | `nativeButton` | `boolean` | `true` | Set to `false` when `render` doesn't render a `<button>` |
744
+
745
+ `BaseCollapsible.Panel` props:
746
+
747
+ | Prop | Type | Default | Description |
748
+ |------|------|---------|-------------|
749
+ | `keepMounted` | `boolean` | `false` | Keeps the closed panel in the DOM |
750
+ | `hiddenUntilFound` | `boolean` | `false` | Keeps the closed panel hidden with `hidden="until-found"`, so the browser's page search finds and opens it. Overrides `keepMounted` |
751
+ | `render` | `RenderProp<"div", CollapsiblePanelState>` | | The state is `{ open, disabled, transitionStatus }` |
752
+
753
+ Data attributes: the root and panel have `data-open` / `data-closed`. The trigger has `data-panel-open`. Disabled parts have `data-disabled`. The panel has `data-starting-style` / `data-ending-style` during its transition.
754
+
700
755
  ### `@omer-x/tailwind-ui-kit/display`
701
756
 
702
757
  #### `BaseAvatar`
@@ -0,0 +1,33 @@
1
+ import { CollapsiblePanelState } from "./BaseCollapsiblePanel.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ export type CollapsibleState = {
5
+ /** Whether the panel is open. */
6
+ open: boolean;
7
+ disabled: boolean;
8
+ };
9
+ type BaseCollapsibleProps = ComponentProps<"div"> & {
10
+ render?: RenderProp<"div", CollapsibleState>;
11
+ /** Whether the panel is open (controlled). */
12
+ open?: boolean;
13
+ /** Whether the panel is open at first. */
14
+ defaultOpen?: boolean;
15
+ /** Called with the new state and the DOM event that changed it (none when changed from code). */
16
+ onOpenChange?: (open: boolean, event: Event | undefined) => void;
17
+ /** Ignores user interaction. */
18
+ disabled?: boolean;
19
+ };
20
+ declare const _default: (({ onOpenChange, ...otherProps }: BaseCollapsibleProps) => import("react").JSX.Element) & {
21
+ Trigger: ({ icon, iconClassName, className, children, ...otherProps }: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
22
+ render?: RenderProp<"button", CollapsibleState>;
23
+ icon?: import("react").ReactNode;
24
+ iconClassName?: string;
25
+ nativeButton?: boolean;
26
+ }) => import("react").JSX.Element;
27
+ Panel: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
28
+ render?: RenderProp<"div", CollapsiblePanelState>;
29
+ keepMounted?: boolean;
30
+ hiddenUntilFound?: boolean;
31
+ }) => import("react").JSX.Element;
32
+ };
33
+ export { _default as default };
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { Collapsible } from "@base-ui/react/collapsible";
3
+ import BaseCollapsiblePanel from "./BaseCollapsiblePanel.js";
4
+ import BaseCollapsibleTrigger from "./BaseCollapsibleTrigger.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ // src/components/disclosure/BaseCollapsible.tsx
7
+ /** Groups a trigger with its panel. Renders a `<div>`, with `data-open` while the panel is open. */
8
+ const BaseCollapsible = ({ onOpenChange, ...otherProps }) => /* @__PURE__ */ jsx(Collapsible.Root, {
9
+ ...otherProps,
10
+ onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event))
11
+ });
12
+ var BaseCollapsible_default = Object.assign(BaseCollapsible, {
13
+ Trigger: BaseCollapsibleTrigger,
14
+ Panel: BaseCollapsiblePanel
15
+ });
16
+ export { BaseCollapsible_default as default };
@@ -0,0 +1,20 @@
1
+ import { CollapsibleState } from "./BaseCollapsible.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps } from "react";
4
+ export type CollapsiblePanelState = CollapsibleState & {
5
+ /** `"starting"` while opening, `"ending"` while closing. */
6
+ transitionStatus: "starting" | "ending" | "idle" | undefined;
7
+ };
8
+ type BaseCollapsiblePanelProps = ComponentProps<"div"> & {
9
+ render?: RenderProp<"div", CollapsiblePanelState>;
10
+ /** Keeps the panel in the DOM while closed. */
11
+ keepMounted?: boolean;
12
+ /** Lets the browser's page search find and open the panel. Overrides `keepMounted`. */
13
+ hiddenUntilFound?: boolean;
14
+ };
15
+ /**
16
+ * The collapsible content, with a height transition. Renders a `<div>`.
17
+ * Put padding on an element inside it, so the panel can shrink to zero.
18
+ */
19
+ declare const BaseCollapsiblePanel: ({ className, ...otherProps }: BaseCollapsiblePanelProps) => import("react").JSX.Element;
20
+ export { BaseCollapsiblePanel as default };
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { Collapsible } from "@base-ui/react/collapsible";
3
+ import { cn } from "cn";
4
+ import panelTransition from "./panelTransition.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ // src/components/disclosure/BaseCollapsiblePanel.tsx
7
+ /**
8
+ * The collapsible content, with a height transition. Renders a `<div>`.
9
+ * Put padding on an element inside it, so the panel can shrink to zero.
10
+ */
11
+ const BaseCollapsiblePanel = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Collapsible.Panel, {
12
+ ...otherProps,
13
+ className: cn("[--disclosure-panel-height:var(--collapsible-panel-height)]", panelTransition, className)
14
+ });
15
+ export { BaseCollapsiblePanel as default };
@@ -0,0 +1,15 @@
1
+ import { CollapsibleState } from "./BaseCollapsible.js";
2
+ import { RenderProp } from "../../utils/render.js";
3
+ import { ComponentProps, ReactNode } from "react";
4
+ type BaseCollapsibleTriggerProps = ComponentProps<"button"> & {
5
+ render?: RenderProp<"button", CollapsibleState>;
6
+ /** Shown after the text, e.g. a chevron. Rotate it with `iconClassName="in-data-panel-open:rotate-180"`. */
7
+ icon?: ReactNode;
8
+ /** Classes for the `<span>` around the icon. */
9
+ iconClassName?: string;
10
+ /** Set to `false` when `render` doesn't render a `<button>`. */
11
+ nativeButton?: boolean;
12
+ };
13
+ /** A button that opens and closes the panel. Renders a `<button>`, with `data-panel-open` while the panel is open. */
14
+ declare const BaseCollapsibleTrigger: ({ icon, iconClassName, className, children, ...otherProps }: BaseCollapsibleTriggerProps) => import("react").JSX.Element;
15
+ export { BaseCollapsibleTrigger as default };
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { Collapsible } from "@base-ui/react/collapsible";
3
+ import { cn } from "cn";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ // src/components/disclosure/BaseCollapsibleTrigger.tsx
6
+ /** A button that opens and closes the panel. Renders a `<button>`, with `data-panel-open` while the panel is open. */
7
+ const BaseCollapsibleTrigger = ({ icon, iconClassName, className, children, ...otherProps }) => /* @__PURE__ */ jsxs(Collapsible.Trigger, {
8
+ ...otherProps,
9
+ className: cn("inline-flex", "items-center", "gap-2", "text-left", "focus-visible:outline-2", "focus-visible:outline-offset-2", "data-disabled:cursor-not-allowed", className),
10
+ children: [children, icon && /* @__PURE__ */ jsx("span", {
11
+ "aria-hidden": "true",
12
+ className: cn("flex", "shrink-0", "transition-transform", "duration-150", iconClassName),
13
+ children: icon
14
+ })]
15
+ });
16
+ export { BaseCollapsibleTrigger as default };
@@ -1,4 +1,6 @@
1
1
  import _default, { AccordionState } from "./BaseAccordion.js";
2
2
  import { AccordionItemState } from "./BaseAccordionItem.js";
3
3
  import { AccordionPanelState } from "./BaseAccordionPanel.js";
4
- export { type AccordionItemState, type AccordionPanelState, type AccordionState, _default as BaseAccordion };
4
+ import _default$1, { CollapsibleState } from "./BaseCollapsible.js";
5
+ import { CollapsiblePanelState } from "./BaseCollapsiblePanel.js";
6
+ export { type AccordionItemState, type AccordionPanelState, type AccordionState, _default as BaseAccordion, _default$1 as BaseCollapsible, type CollapsiblePanelState, type CollapsibleState };
@@ -1 +1,3 @@
1
- export { default as BaseAccordion } from "./BaseAccordion.js";
1
+ import BaseAccordion_default from "./BaseAccordion.js";
2
+ import BaseCollapsible_default from "./BaseCollapsible.js";
3
+ export { BaseAccordion_default as BaseAccordion, BaseCollapsible_default as BaseCollapsible };
@@ -108,7 +108,7 @@ declare const _default: (<Item>({ onValueChange, onOpenChange, onItemHighlighted
108
108
  InputGroup: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
109
109
  render?: RenderProp<"div", AutocompleteInputState>;
110
110
  }) => import("react").JSX.Element;
111
- Input: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "defaultValue" | "value" | "size"> & {
111
+ Input: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "value" | "defaultValue" | "size"> & {
112
112
  size?: InputSize;
113
113
  render?: RenderProp<"input", AutocompleteInputState>;
114
114
  }) => import("react").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omer-x/tailwind-ui-kit",
3
- "version": "1.0.0-alpha.33",
3
+ "version": "1.0.0-alpha.34",
4
4
  "description": "Tailwind CSS-based React component library for building user interfaces",
5
5
  "keywords": [
6
6
  "tailwind",