@omer-x/tailwind-ui-kit 1.0.0-alpha.4 → 1.0.0-alpha.40
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/MIGRATION.md +283 -0
- package/README.md +1440 -0
- package/dist/components/button/BaseButton.d.ts +40 -12
- package/dist/components/button/BaseButton.js +35 -51
- package/dist/components/button/BaseToggle.d.ts +35 -0
- package/dist/components/button/BaseToggle.js +23 -0
- package/dist/components/button/BaseToggleGroup.d.ts +26 -0
- package/dist/components/button/BaseToggleGroup.js +12 -0
- package/dist/components/button/buttonStyles.d.ts +3 -0
- package/dist/components/button/buttonStyles.js +29 -0
- package/dist/components/button/index.d.ts +4 -4
- package/dist/components/button/index.js +4 -4
- package/dist/components/dialog/BaseAlertDialog.d.ts +49 -0
- package/dist/components/dialog/BaseAlertDialog.js +27 -0
- package/dist/components/dialog/BaseAlertDialogTrigger.d.ts +16 -0
- package/dist/components/dialog/BaseAlertDialogTrigger.js +11 -0
- package/dist/components/dialog/BaseDialog.d.ts +58 -0
- package/dist/components/dialog/BaseDialog.js +24 -0
- package/dist/components/dialog/BaseDialogClose.d.ts +13 -0
- package/dist/components/dialog/BaseDialogClose.js +7 -0
- package/dist/components/dialog/BaseDialogDescription.d.ts +8 -0
- package/dist/components/dialog/BaseDialogDescription.js +7 -0
- package/dist/components/dialog/BaseDialogPopup.d.ts +41 -0
- package/dist/components/dialog/BaseDialogPopup.js +29 -0
- package/dist/components/dialog/BaseDialogTitle.d.ts +8 -0
- package/dist/components/dialog/BaseDialogTitle.js +11 -0
- package/dist/components/dialog/BaseDialogTrigger.d.ts +20 -0
- package/dist/components/dialog/BaseDialogTrigger.js +11 -0
- package/dist/components/dialog/createAlertDialogHandle.d.ts +14 -0
- package/dist/components/dialog/createAlertDialogHandle.js +11 -0
- package/dist/components/dialog/createDialogHandle.d.ts +36 -0
- package/dist/components/dialog/createDialogHandle.js +31 -0
- package/dist/components/dialog/index.d.ts +8 -5
- package/dist/components/dialog/index.js +5 -8
- package/dist/components/disclosure/BaseAccordion.d.ts +48 -0
- package/dist/components/disclosure/BaseAccordion.js +18 -0
- package/dist/components/disclosure/BaseAccordionItem.d.ts +20 -0
- package/dist/components/disclosure/BaseAccordionItem.js +10 -0
- package/dist/components/disclosure/BaseAccordionPanel.d.ts +20 -0
- package/dist/components/disclosure/BaseAccordionPanel.js +15 -0
- package/dist/components/disclosure/BaseAccordionTrigger.d.ts +22 -0
- package/dist/components/disclosure/BaseAccordionTrigger.js +23 -0
- package/dist/components/disclosure/BaseCollapsible.d.ts +33 -0
- package/dist/components/disclosure/BaseCollapsible.js +16 -0
- package/dist/components/disclosure/BaseCollapsiblePanel.d.ts +20 -0
- package/dist/components/disclosure/BaseCollapsiblePanel.js +15 -0
- package/dist/components/disclosure/BaseCollapsibleTrigger.d.ts +15 -0
- package/dist/components/disclosure/BaseCollapsibleTrigger.js +16 -0
- package/dist/components/disclosure/index.d.ts +6 -0
- package/dist/components/disclosure/index.js +3 -0
- package/dist/components/disclosure/panelTransition.d.ts +7 -0
- package/dist/components/disclosure/panelTransition.js +9 -0
- package/dist/components/display/BaseAvatar.d.ts +24 -0
- package/dist/components/display/BaseAvatar.js +35 -0
- package/dist/components/display/BaseAvatarFallback.d.ts +14 -0
- package/dist/components/display/BaseAvatarFallback.js +14 -0
- package/dist/components/display/BaseAvatarImage.d.ts +23 -0
- package/dist/components/display/BaseAvatarImage.js +14 -0
- package/dist/components/display/BaseMeter.d.ts +60 -0
- package/dist/components/display/BaseMeter.js +45 -0
- package/dist/components/display/BaseMeterIndicator.d.ts +9 -0
- package/dist/components/display/BaseMeterIndicator.js +12 -0
- package/dist/components/display/BaseMeterLabel.d.ts +9 -0
- package/dist/components/display/BaseMeterLabel.js +7 -0
- package/dist/components/display/BaseMeterTrack.d.ts +12 -0
- package/dist/components/display/BaseMeterTrack.js +12 -0
- package/dist/components/display/BaseMeterValue.d.ts +14 -0
- package/dist/components/display/BaseMeterValue.js +10 -0
- package/dist/components/display/barStyles.d.ts +5 -0
- package/dist/components/display/barStyles.js +20 -0
- package/dist/components/display/index.d.ts +4 -0
- package/dist/components/display/index.js +3 -0
- package/dist/components/elements/JustAnchor.d.ts +7 -0
- package/dist/components/elements/JustAnchor.js +11 -0
- package/dist/components/elements/JustButton.d.ts +7 -0
- package/dist/components/elements/JustButton.js +11 -0
- package/dist/components/elements/JustDiv.d.ts +7 -0
- package/dist/components/elements/JustDiv.js +11 -0
- package/dist/components/elements/JustInput.d.ts +7 -0
- package/dist/components/elements/JustInput.js +11 -0
- package/dist/components/elements/JustSpan.d.ts +7 -0
- package/dist/components/elements/JustSpan.js +11 -0
- package/dist/components/elements/index.d.ts +6 -0
- package/dist/components/elements/index.js +6 -0
- package/dist/components/form/BaseAutocomplete.d.ts +198 -0
- package/dist/components/form/BaseAutocomplete.js +49 -0
- package/dist/components/form/BaseAutocompleteClear.d.ts +18 -0
- package/dist/components/form/BaseAutocompleteClear.js +7 -0
- package/dist/components/form/BaseAutocompleteCollection.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteCollection.js +7 -0
- package/dist/components/form/BaseAutocompleteEmpty.d.ts +11 -0
- package/dist/components/form/BaseAutocompleteEmpty.js +10 -0
- package/dist/components/form/BaseAutocompleteGroup.d.ts +10 -0
- package/dist/components/form/BaseAutocompleteGroup.js +7 -0
- package/dist/components/form/BaseAutocompleteGroupLabel.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteGroupLabel.js +7 -0
- package/dist/components/form/BaseAutocompleteIcon.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteIcon.js +7 -0
- package/dist/components/form/BaseAutocompleteInput.d.ts +12 -0
- package/dist/components/form/BaseAutocompleteInput.js +12 -0
- package/dist/components/form/BaseAutocompleteInputGroup.d.ts +9 -0
- package/dist/components/form/BaseAutocompleteInputGroup.js +11 -0
- package/dist/components/form/BaseAutocompleteItem.d.ts +20 -0
- package/dist/components/form/BaseAutocompleteItem.js +11 -0
- package/dist/components/form/BaseAutocompleteList.d.ts +14 -0
- package/dist/components/form/BaseAutocompleteList.js +11 -0
- package/dist/components/form/BaseAutocompletePopup.d.ts +111 -0
- package/dist/components/form/BaseAutocompletePopup.js +45 -0
- package/dist/components/form/BaseAutocompleteRow.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteRow.js +7 -0
- package/dist/components/form/BaseAutocompleteSeparator.d.ts +13 -0
- package/dist/components/form/BaseAutocompleteSeparator.js +7 -0
- package/dist/components/form/BaseAutocompleteStatus.d.ts +11 -0
- package/dist/components/form/BaseAutocompleteStatus.js +10 -0
- package/dist/components/form/BaseAutocompleteTrigger.d.ts +11 -0
- package/dist/components/form/BaseAutocompleteTrigger.js +7 -0
- package/dist/components/form/BaseAutocompleteValue.d.ts +8 -0
- package/dist/components/form/BaseAutocompleteValue.js +7 -0
- package/dist/components/form/BaseCheckbox.d.ts +49 -0
- package/dist/components/form/BaseCheckbox.js +31 -0
- package/dist/components/form/BaseCheckboxGroup.d.ts +24 -0
- package/dist/components/form/BaseCheckboxGroup.js +20 -0
- package/dist/components/form/BaseFieldset.d.ts +21 -0
- package/dist/components/form/BaseFieldset.js +18 -0
- package/dist/components/form/BaseForm.d.ts +13 -0
- package/dist/components/form/BaseForm.js +78 -0
- package/dist/components/form/BaseFormField.d.ts +33 -0
- package/dist/components/form/BaseFormField.js +33 -0
- package/dist/components/form/BaseInput.d.ts +8 -0
- package/dist/components/form/BaseInput.js +12 -0
- package/dist/components/form/BaseRadio.d.ts +30 -0
- package/dist/components/form/BaseRadio.js +22 -0
- package/dist/components/form/BaseRadioGroup.d.ts +28 -0
- package/dist/components/form/BaseRadioGroup.js +21 -0
- package/dist/components/form/BaseSwitch.d.ts +35 -0
- package/dist/components/form/BaseSwitch.js +21 -0
- package/dist/components/form/ClientSideError.d.ts +9 -0
- package/dist/components/form/ClientSideError.js +39 -0
- package/dist/components/form/FieldRoot.d.ts +8 -0
- package/dist/components/form/FieldRoot.js +25 -0
- package/dist/components/form/FormContext.d.ts +28 -0
- package/dist/components/form/FormContext.js +12 -0
- package/dist/components/form/InsideFieldContext.d.ts +2 -0
- package/dist/components/form/InsideFieldContext.js +5 -0
- package/dist/components/form/ServerSideError.d.ts +8 -0
- package/dist/components/form/ServerSideError.js +15 -0
- package/dist/components/form/autocompleteTypes.d.ts +16 -0
- package/dist/components/form/autocompleteTypes.js +1 -0
- package/dist/components/form/index.d.ts +21 -0
- package/dist/components/form/index.js +13 -0
- package/dist/components/form/inputSizes.d.ts +11 -0
- package/dist/components/form/inputSizes.js +19 -0
- package/dist/components/form/useAutocompleteFilter.d.ts +19 -0
- package/dist/components/form/useAutocompleteFilter.js +12 -0
- package/dist/components/form/useFormMessages.d.ts +10 -0
- package/dist/components/form/useFormMessages.js +16 -0
- package/dist/components/layout/Container.d.ts +4 -10
- package/dist/components/layout/Container.js +9 -10
- package/dist/components/layout/index.d.ts +2 -3
- package/dist/components/layout/index.js +1 -4
- package/dist/components/menu/BaseContextMenu.d.ts +150 -0
- package/dist/components/menu/BaseContextMenu.js +38 -0
- package/dist/components/menu/BaseContextMenuTrigger.d.ts +15 -0
- package/dist/components/menu/BaseContextMenuTrigger.js +10 -0
- package/dist/components/menu/BaseMenu.d.ts +171 -0
- package/dist/components/menu/BaseMenu.js +62 -0
- package/dist/components/menu/BaseMenuArrow.d.ts +19 -0
- package/dist/components/menu/BaseMenuArrow.js +10 -0
- package/dist/components/menu/BaseMenuCheckboxItem.d.ts +37 -0
- package/dist/components/menu/BaseMenuCheckboxItem.js +25 -0
- package/dist/components/menu/BaseMenuClear.d.ts +16 -0
- package/dist/components/menu/BaseMenuClear.js +10 -0
- package/dist/components/menu/BaseMenuEmpty.d.ts +8 -0
- package/dist/components/menu/BaseMenuEmpty.js +7 -0
- package/dist/components/menu/BaseMenuGroup.d.ts +8 -0
- package/dist/components/menu/BaseMenuGroup.js +7 -0
- package/dist/components/menu/BaseMenuGroupLabel.d.ts +8 -0
- package/dist/components/menu/BaseMenuGroupLabel.js +11 -0
- package/dist/components/menu/BaseMenuInput.d.ts +15 -0
- package/dist/components/menu/BaseMenuInput.js +10 -0
- package/dist/components/menu/BaseMenuItem.d.ts +24 -0
- package/dist/components/menu/BaseMenuItem.js +12 -0
- package/dist/components/menu/BaseMenuLinkItem.d.ts +20 -0
- package/dist/components/menu/BaseMenuLinkItem.js +12 -0
- package/dist/components/menu/BaseMenuList.d.ts +11 -0
- package/dist/components/menu/BaseMenuList.js +14 -0
- package/dist/components/menu/BaseMenuPopup.d.ts +116 -0
- package/dist/components/menu/BaseMenuPopup.js +42 -0
- package/dist/components/menu/BaseMenuRadioGroup.d.ts +19 -0
- package/dist/components/menu/BaseMenuRadioGroup.js +10 -0
- package/dist/components/menu/BaseMenuRadioItem.d.ts +36 -0
- package/dist/components/menu/BaseMenuRadioItem.js +24 -0
- package/dist/components/menu/BaseMenuSeparator.d.ts +11 -0
- package/dist/components/menu/BaseMenuSeparator.js +11 -0
- package/dist/components/menu/BaseMenuSubmenu.d.ts +13 -0
- package/dist/components/menu/BaseMenuSubmenu.js +22 -0
- package/dist/components/menu/BaseMenuSubmenuTrigger.d.ts +43 -0
- package/dist/components/menu/BaseMenuSubmenuTrigger.js +20 -0
- package/dist/components/menu/BaseMenuTrigger.d.ts +26 -0
- package/dist/components/menu/BaseMenuTrigger.js +11 -0
- package/dist/components/menu/BaseMenuViewport.d.ts +18 -0
- package/dist/components/menu/BaseMenuViewport.js +11 -0
- package/dist/components/menu/BaseMenubar.d.ts +187 -0
- package/dist/components/menu/BaseMenubar.js +18 -0
- package/dist/components/menu/createMenuHandle.d.ts +30 -0
- package/dist/components/menu/createMenuHandle.js +27 -0
- package/dist/components/menu/index.d.ts +20 -0
- package/dist/components/menu/index.js +5 -0
- package/dist/components/menu/menuItemStyles.d.ts +6 -0
- package/dist/components/menu/menuItemStyles.js +27 -0
- package/dist/components/menu/menuTypes.d.ts +69 -0
- package/dist/components/menu/menuTypes.js +16 -0
- package/dist/components/page/Pagination.d.ts +27 -0
- package/dist/components/page/Pagination.js +68 -0
- package/dist/components/page/index.d.ts +3 -0
- package/dist/components/page/index.js +3 -0
- package/dist/components/page/usePagination.d.ts +30 -0
- package/dist/components/page/usePagination.js +41 -0
- package/dist/components/table/TableCell.d.ts +13 -0
- package/dist/components/table/TableCell.js +17 -0
- package/dist/components/table/Tdx.d.ts +6 -10
- package/dist/components/table/Tdx.js +11 -9
- package/dist/components/table/index.d.ts +3 -3
- package/dist/components/table/index.js +3 -4
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useRipples.d.ts +2 -5
- package/dist/hooks/useRipples.js +44 -32
- package/dist/utils/cn.d.ts +6 -5
- package/dist/utils/cn.js +8 -6
- package/dist/utils/dirty-form.d.ts +7 -0
- package/dist/utils/dirty-form.js +40 -0
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/index.js +2 -3
- package/dist/utils/render.d.ts +31 -0
- package/dist/utils/render.js +24 -0
- package/dist/utils/split-class-name.d.ts +15 -0
- package/dist/utils/split-class-name.js +18 -0
- package/package.json +64 -26
- package/typescript-badge.d.ts +4 -0
- package/dist/components/button/PulseButton.d.ts +0 -10
- package/dist/components/button/PulseButton.js +0 -24
- package/dist/components/dialog/AnimatedPopup.d.ts +0 -6
- package/dist/components/dialog/AnimatedPopup.js +0 -34
- package/dist/components/dialog/DialogBackdrop.d.ts +0 -6
- package/dist/components/dialog/DialogBackdrop.js +0 -26
- package/dist/components/dialog/DialogTitle.d.ts +0 -6
- package/dist/components/dialog/DialogTitle.js +0 -19
- package/dist/styles/ripple.module.css +0 -10
- package/dist/styles/ripple.module.d.ts +0 -2
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DialogHandle } from "./createDialogHandle.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
export type DialogTriggerState = {
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
/** Whether the dialog is open and was opened by this trigger. */
|
|
7
|
+
open: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type BaseDialogTriggerProps<Payload = unknown> = ComponentProps<"button"> & {
|
|
10
|
+
render?: RenderProp<"button", DialogTriggerState>;
|
|
11
|
+
/** Connects a trigger placed outside its `BaseDialog`. Create one with `createDialogHandle()`. */
|
|
12
|
+
handle?: DialogHandle<Payload>;
|
|
13
|
+
/** Passed to the dialog's function children when this trigger opens it. */
|
|
14
|
+
payload?: Payload;
|
|
15
|
+
/** Set to `false` when `render` doesn't render a `<button>`. */
|
|
16
|
+
nativeButton?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** A button that opens the dialog. Renders a `<button>`, with `data-popup-open` while its dialog is open. */
|
|
19
|
+
declare const BaseDialogTrigger: <Payload>({ handle, ...otherProps }: BaseDialogTriggerProps<Payload>) => import("react").JSX.Element;
|
|
20
|
+
export { BaseDialogTrigger as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
3
|
+
import { toBaseUIHandle } from "./createDialogHandle.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/dialog/BaseDialogTrigger.tsx
|
|
6
|
+
/** A button that opens the dialog. Renders a `<button>`, with `data-popup-open` while its dialog is open. */
|
|
7
|
+
const BaseDialogTrigger = ({ handle, ...otherProps }) => /* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
8
|
+
...otherProps,
|
|
9
|
+
handle: handle && toBaseUIHandle(handle)
|
|
10
|
+
});
|
|
11
|
+
export { BaseDialogTrigger as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DialogHandle } from "./createDialogHandle.js";
|
|
2
|
+
/**
|
|
3
|
+
* Opens and closes an alert dialog from anywhere: from triggers outside the alert dialog and from code.
|
|
4
|
+
* Create one with `createAlertDialogHandle()` and pass it to `BaseAlertDialog` and its triggers.
|
|
5
|
+
*
|
|
6
|
+
* Calls are ignored while no `BaseAlertDialog` with this handle is mounted.
|
|
7
|
+
* Call the methods from event handlers or effects, never during render.
|
|
8
|
+
*/
|
|
9
|
+
export type AlertDialogHandle<Payload = unknown> = DialogHandle<Payload>;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a handle to open an alert dialog from triggers outside it, or from code.
|
|
12
|
+
* Pass the payload type to type the payload of triggers and `openWithPayload`.
|
|
13
|
+
*/
|
|
14
|
+
export default function createAlertDialogHandle<Payload = unknown>(): AlertDialogHandle<Payload>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AlertDialog } from "@base-ui/react/alert-dialog";
|
|
2
|
+
import { toKitHandle } from "./createDialogHandle.js";
|
|
3
|
+
// src/components/dialog/createAlertDialogHandle.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates a handle to open an alert dialog from triggers outside it, or from code.
|
|
6
|
+
* Pass the payload type to type the payload of triggers and `openWithPayload`.
|
|
7
|
+
*/
|
|
8
|
+
function createAlertDialogHandle() {
|
|
9
|
+
return toKitHandle(AlertDialog.createHandle());
|
|
10
|
+
}
|
|
11
|
+
export { createAlertDialogHandle as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opens and closes a dialog from anywhere: from triggers outside the dialog and from code.
|
|
3
|
+
* Create one with `createDialogHandle()` and pass it to `BaseDialog` and its triggers.
|
|
4
|
+
*
|
|
5
|
+
* Calls are ignored while no `BaseDialog` with this handle is mounted.
|
|
6
|
+
* Call the methods from event handlers or effects, never during render.
|
|
7
|
+
*/
|
|
8
|
+
export type DialogHandle<Payload = unknown> = {
|
|
9
|
+
/** Opens the dialog. Give a trigger's `id` to open it as if that trigger was pressed. */
|
|
10
|
+
open: (triggerId?: string | null) => void;
|
|
11
|
+
/** Opens the dialog with a payload, which `BaseDialog`'s function children receive. */
|
|
12
|
+
openWithPayload: (payload: Payload) => void;
|
|
13
|
+
close: () => void;
|
|
14
|
+
/** Whether the dialog is open. `false` while no `BaseDialog` with this handle is mounted. */
|
|
15
|
+
readonly isOpen: boolean;
|
|
16
|
+
};
|
|
17
|
+
/** The parts of a Base UI handle the kit uses, typed without naming Base UI. */
|
|
18
|
+
type BaseUIHandleLike<Payload> = {
|
|
19
|
+
open: (triggerId: string | null) => void;
|
|
20
|
+
openWithPayload: (payload: Payload) => void;
|
|
21
|
+
close: () => void;
|
|
22
|
+
readonly isOpen: boolean;
|
|
23
|
+
};
|
|
24
|
+
/** Wraps a Base UI dialog or alert dialog handle in a kit handle. Internal: not exported to apps. */
|
|
25
|
+
export declare function toKitHandle<Payload>(baseUIHandle: BaseUIHandleLike<Payload>): DialogHandle<Payload>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the Base UI handle behind a kit handle. Internal: not exported to apps.
|
|
28
|
+
* Its return type doesn't name Base UI so the declaration files don't either. Callers cast it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function toBaseUIHandle(handle: DialogHandle<never>): object | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a handle to open a dialog from triggers outside it, or from code.
|
|
33
|
+
* Pass the payload type to type the payload of triggers and `openWithPayload`.
|
|
34
|
+
*/
|
|
35
|
+
export default function createDialogHandle<Payload = unknown>(): DialogHandle<Payload>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
2
|
+
// src/components/dialog/createDialogHandle.ts
|
|
3
|
+
const baseUIHandles = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
/** Wraps a Base UI dialog or alert dialog handle in a kit handle. Internal: not exported to apps. */
|
|
5
|
+
function toKitHandle(baseUIHandle) {
|
|
6
|
+
const handle = {
|
|
7
|
+
open: (triggerId = null) => baseUIHandle.open(triggerId),
|
|
8
|
+
openWithPayload: (payload) => baseUIHandle.openWithPayload(payload),
|
|
9
|
+
close: () => baseUIHandle.close(),
|
|
10
|
+
get isOpen() {
|
|
11
|
+
return baseUIHandle.isOpen;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
baseUIHandles.set(handle, baseUIHandle);
|
|
15
|
+
return handle;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns the Base UI handle behind a kit handle. Internal: not exported to apps.
|
|
19
|
+
* Its return type doesn't name Base UI so the declaration files don't either. Callers cast it.
|
|
20
|
+
*/
|
|
21
|
+
function toBaseUIHandle(handle) {
|
|
22
|
+
return baseUIHandles.get(handle);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a handle to open a dialog from triggers outside it, or from code.
|
|
26
|
+
* Pass the payload type to type the payload of triggers and `openWithPayload`.
|
|
27
|
+
*/
|
|
28
|
+
function createDialogHandle() {
|
|
29
|
+
return toKitHandle(Dialog.createHandle());
|
|
30
|
+
}
|
|
31
|
+
export { createDialogHandle as default, toBaseUIHandle, toKitHandle };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import _default from "./BaseAlertDialog.js";
|
|
2
|
+
import _default$1 from "./BaseDialog.js";
|
|
3
|
+
import createAlertDialogHandle, { AlertDialogHandle } from "./createAlertDialogHandle.js";
|
|
4
|
+
import createDialogHandle, { DialogHandle } from "./createDialogHandle.js";
|
|
5
|
+
import { DialogBackdropState, DialogFocusTarget, DialogInteractionType, DialogPopupState } from "./BaseDialogPopup.js";
|
|
6
|
+
import { DialogCloseState } from "./BaseDialogClose.js";
|
|
7
|
+
import { DialogTriggerState } from "./BaseDialogTrigger.js";
|
|
8
|
+
export { type AlertDialogHandle, _default as BaseAlertDialog, _default$1 as BaseDialog, type DialogBackdropState, type DialogCloseState, type DialogFocusTarget, type DialogHandle, type DialogInteractionType, type DialogPopupState, type DialogTriggerState, createAlertDialogHandle, createDialogHandle };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
default3 as DialogBackdrop,
|
|
7
|
-
default4 as DialogTitle
|
|
8
|
-
};
|
|
1
|
+
import BaseAlertDialog_default from "./BaseAlertDialog.js";
|
|
2
|
+
import BaseDialog_default from "./BaseDialog.js";
|
|
3
|
+
import createAlertDialogHandle from "./createAlertDialogHandle.js";
|
|
4
|
+
import createDialogHandle from "./createDialogHandle.js";
|
|
5
|
+
export { BaseAlertDialog_default as BaseAlertDialog, BaseDialog_default as BaseDialog, createAlertDialogHandle, createDialogHandle };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AccordionItemState } from "./BaseAccordionItem.js";
|
|
2
|
+
import { AccordionPanelState } from "./BaseAccordionPanel.js";
|
|
3
|
+
import { RenderProp } from "../../utils/render.js";
|
|
4
|
+
import { ComponentProps } from "react";
|
|
5
|
+
export type AccordionState<Value = unknown> = {
|
|
6
|
+
/** The values of the open items. */
|
|
7
|
+
value: Value[];
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
};
|
|
10
|
+
type BaseAccordionProps<Value = unknown> = Omit<ComponentProps<"div">, "defaultValue"> & {
|
|
11
|
+
render?: RenderProp<"div", AccordionState<Value>>;
|
|
12
|
+
/** The values of the open items (controlled). */
|
|
13
|
+
value?: Value[];
|
|
14
|
+
/** The values of the items open at first. */
|
|
15
|
+
defaultValue?: Value[];
|
|
16
|
+
/** Called with the values of the open items and the DOM event that changed them (none when changed from code). */
|
|
17
|
+
onValueChange?: (value: Value[], event: Event | undefined) => void;
|
|
18
|
+
/** Lets several items be open at once. */
|
|
19
|
+
multiple?: boolean;
|
|
20
|
+
/** Ignores user interaction on every item. */
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/** Keeps closed panels in the DOM. */
|
|
23
|
+
keepMounted?: boolean;
|
|
24
|
+
/** Lets the browser's page search find and open closed panels. Overrides `keepMounted`. */
|
|
25
|
+
hiddenUntilFound?: boolean;
|
|
26
|
+
};
|
|
27
|
+
declare const _default: (<Value>({ onValueChange, ...otherProps }: BaseAccordionProps<Value>) => import("react").JSX.Element) & {
|
|
28
|
+
Item: ({ onOpenChange, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
29
|
+
render?: RenderProp<"div", AccordionItemState>;
|
|
30
|
+
value?: unknown;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
onOpenChange?: (open: boolean, event: Event | undefined) => void;
|
|
33
|
+
}) => import("react").JSX.Element;
|
|
34
|
+
Trigger: ({ icon, iconClassName, headerClassName, renderHeader, className, children, ...otherProps }: import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
35
|
+
render?: RenderProp<"button", AccordionItemState>;
|
|
36
|
+
icon?: import("react").ReactNode;
|
|
37
|
+
iconClassName?: string;
|
|
38
|
+
headerClassName?: string;
|
|
39
|
+
renderHeader?: RenderProp<"h3", AccordionItemState>;
|
|
40
|
+
nativeButton?: boolean;
|
|
41
|
+
}) => import("react").JSX.Element;
|
|
42
|
+
Panel: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
43
|
+
render?: RenderProp<"div", AccordionPanelState>;
|
|
44
|
+
keepMounted?: boolean;
|
|
45
|
+
hiddenUntilFound?: boolean;
|
|
46
|
+
}) => import("react").JSX.Element;
|
|
47
|
+
};
|
|
48
|
+
export { _default as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Accordion } from "@base-ui/react/accordion";
|
|
3
|
+
import BaseAccordionItem from "./BaseAccordionItem.js";
|
|
4
|
+
import BaseAccordionPanel from "./BaseAccordionPanel.js";
|
|
5
|
+
import BaseAccordionTrigger from "./BaseAccordionTrigger.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// src/components/disclosure/BaseAccordion.tsx
|
|
8
|
+
/** Groups the items of an accordion. Renders a `<div>`. */
|
|
9
|
+
const BaseAccordion = ({ onValueChange, ...otherProps }) => /* @__PURE__ */ jsx(Accordion.Root, {
|
|
10
|
+
...otherProps,
|
|
11
|
+
onValueChange: onValueChange && ((value, details) => onValueChange(value, details.event))
|
|
12
|
+
});
|
|
13
|
+
var BaseAccordion_default = Object.assign(BaseAccordion, {
|
|
14
|
+
Item: BaseAccordionItem,
|
|
15
|
+
Trigger: BaseAccordionTrigger,
|
|
16
|
+
Panel: BaseAccordionPanel
|
|
17
|
+
});
|
|
18
|
+
export { BaseAccordion_default as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type AccordionItemState = {
|
|
4
|
+
/** Whether the item's panel is open. */
|
|
5
|
+
open: boolean;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
/** The item's position in the accordion. */
|
|
8
|
+
index: number;
|
|
9
|
+
};
|
|
10
|
+
type BaseAccordionItemProps = ComponentProps<"div"> & {
|
|
11
|
+
render?: RenderProp<"div", AccordionItemState>;
|
|
12
|
+
/** Identifies the item in the accordion's `value`. Generated when missing. */
|
|
13
|
+
value?: unknown;
|
|
14
|
+
disabled?: 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
|
+
};
|
|
18
|
+
/** Groups a trigger with its panel. Renders a `<div>`, with `data-open` while its panel is open. */
|
|
19
|
+
declare const BaseAccordionItem: ({ onOpenChange, ...otherProps }: BaseAccordionItemProps) => import("react").JSX.Element;
|
|
20
|
+
export { BaseAccordionItem as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Accordion } from "@base-ui/react/accordion";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/disclosure/BaseAccordionItem.tsx
|
|
5
|
+
/** Groups a trigger with its panel. Renders a `<div>`, with `data-open` while its panel is open. */
|
|
6
|
+
const BaseAccordionItem = ({ onOpenChange, ...otherProps }) => /* @__PURE__ */ jsx(Accordion.Item, {
|
|
7
|
+
...otherProps,
|
|
8
|
+
onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event))
|
|
9
|
+
});
|
|
10
|
+
export { BaseAccordionItem as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AccordionItemState } from "./BaseAccordionItem.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
export type AccordionPanelState = AccordionItemState & {
|
|
5
|
+
/** `"starting"` while opening, `"ending"` while closing. */
|
|
6
|
+
transitionStatus: "starting" | "ending" | "idle" | undefined;
|
|
7
|
+
};
|
|
8
|
+
type BaseAccordionPanelProps = ComponentProps<"div"> & {
|
|
9
|
+
render?: RenderProp<"div", AccordionPanelState>;
|
|
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 item's 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 BaseAccordionPanel: ({ className, ...otherProps }: BaseAccordionPanelProps) => import("react").JSX.Element;
|
|
20
|
+
export { BaseAccordionPanel as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Accordion } from "@base-ui/react/accordion";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import panelTransition from "./panelTransition.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/disclosure/BaseAccordionPanel.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The item's 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 BaseAccordionPanel = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Accordion.Panel, {
|
|
12
|
+
...otherProps,
|
|
13
|
+
className: cn("[--disclosure-panel-height:var(--accordion-panel-height)]", panelTransition, className)
|
|
14
|
+
});
|
|
15
|
+
export { BaseAccordionPanel as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AccordionItemState } from "./BaseAccordionItem.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps, ReactNode } from "react";
|
|
4
|
+
type BaseAccordionTriggerProps = ComponentProps<"button"> & {
|
|
5
|
+
render?: RenderProp<"button", AccordionItemState>;
|
|
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
|
+
/** Classes for the heading around the trigger. */
|
|
11
|
+
headerClassName?: string;
|
|
12
|
+
/** Replaces the heading around the trigger, e.g. `<h2 />` for another level. */
|
|
13
|
+
renderHeader?: RenderProp<"h3", AccordionItemState>;
|
|
14
|
+
/** Set to `false` when `render` doesn't render a `<button>`. */
|
|
15
|
+
nativeButton?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A button that opens and closes its item's panel, inside the heading that labels the panel.
|
|
19
|
+
* Renders an `<h3>` around a `<button>`, with `data-panel-open` while the panel is open.
|
|
20
|
+
*/
|
|
21
|
+
declare const BaseAccordionTrigger: ({ icon, iconClassName, headerClassName, renderHeader, className, children, ...otherProps }: BaseAccordionTriggerProps) => import("react").JSX.Element;
|
|
22
|
+
export { BaseAccordionTrigger as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Accordion } from "@base-ui/react/accordion";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/components/disclosure/BaseAccordionTrigger.tsx
|
|
6
|
+
/**
|
|
7
|
+
* A button that opens and closes its item's panel, inside the heading that labels the panel.
|
|
8
|
+
* Renders an `<h3>` around a `<button>`, with `data-panel-open` while the panel is open.
|
|
9
|
+
*/
|
|
10
|
+
const BaseAccordionTrigger = ({ icon, iconClassName, headerClassName, renderHeader, className, children, ...otherProps }) => /* @__PURE__ */ jsx(Accordion.Header, {
|
|
11
|
+
className: headerClassName,
|
|
12
|
+
render: renderHeader,
|
|
13
|
+
children: /* @__PURE__ */ jsxs(Accordion.Trigger, {
|
|
14
|
+
...otherProps,
|
|
15
|
+
className: cn("flex", "w-full", "items-center", "justify-between", "gap-2", "text-left", "focus-visible:outline-2", "focus-visible:outline-offset-2", "data-disabled:cursor-not-allowed", className),
|
|
16
|
+
children: [children, icon && /* @__PURE__ */ jsx("span", {
|
|
17
|
+
"aria-hidden": "true",
|
|
18
|
+
className: cn("flex", "shrink-0", "transition-transform", "duration-150", iconClassName),
|
|
19
|
+
children: icon
|
|
20
|
+
})]
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
export { BaseAccordionTrigger as default };
|
|
@@ -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 };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import _default, { AccordionState } from "./BaseAccordion.js";
|
|
2
|
+
import { AccordionItemState } from "./BaseAccordionItem.js";
|
|
3
|
+
import { AccordionPanelState } from "./BaseAccordionPanel.js";
|
|
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 };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The open/close transition shared by the disclosure panels (Accordion, Collapsible).
|
|
3
|
+
* Each panel maps Base UI's own height variable onto `--disclosure-panel-height`.
|
|
4
|
+
* The panel animates its height, so padding belongs on an element inside it.
|
|
5
|
+
*/
|
|
6
|
+
declare const panelTransition: string;
|
|
7
|
+
export { panelTransition as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { cn } from "cn";
|
|
2
|
+
// src/components/disclosure/panelTransition.ts
|
|
3
|
+
/**
|
|
4
|
+
* The open/close transition shared by the disclosure panels (Accordion, Collapsible).
|
|
5
|
+
* Each panel maps Base UI's own height variable onto `--disclosure-panel-height`.
|
|
6
|
+
* The panel animates its height, so padding belongs on an element inside it.
|
|
7
|
+
*/
|
|
8
|
+
const panelTransition = cn("h-(--disclosure-panel-height)", "overflow-hidden", "transition-[height]", "duration-150", "ease-out", "data-ending-style:h-0", "data-starting-style:h-0", "[&[hidden]:not([hidden=until-found])]:hidden");
|
|
9
|
+
export { panelTransition as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AvatarImageState } from "./BaseAvatarImage.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
export type AvatarImageLoadingStatus = "idle" | "loading" | "loaded" | "error";
|
|
5
|
+
export type AvatarState = {
|
|
6
|
+
/** Whether the image is loading, shown, or failed (`"idle"` when there is none). */
|
|
7
|
+
imageLoadingStatus: AvatarImageLoadingStatus;
|
|
8
|
+
};
|
|
9
|
+
type BaseAvatarProps = ComponentProps<"span"> & {
|
|
10
|
+
render?: RenderProp<"span", AvatarState>;
|
|
11
|
+
size?: "lg" | "md" | "sm" | "xs";
|
|
12
|
+
};
|
|
13
|
+
declare const _default: (({ size, className, ...otherProps }: BaseAvatarProps) => import("react").JSX.Element) & {
|
|
14
|
+
Image: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLImageElement> & import("react").ImgHTMLAttributes<HTMLImageElement> & {
|
|
15
|
+
render?: RenderProp<"img", AvatarImageState>;
|
|
16
|
+
onLoadingStatusChange?: (status: AvatarImageLoadingStatus) => void;
|
|
17
|
+
keepMounted?: boolean;
|
|
18
|
+
}) => import("react").JSX.Element;
|
|
19
|
+
Fallback: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & {
|
|
20
|
+
render?: RenderProp<"span", AvatarState>;
|
|
21
|
+
delay?: number;
|
|
22
|
+
}) => import("react").JSX.Element;
|
|
23
|
+
};
|
|
24
|
+
export { _default as default };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Avatar } from "@base-ui/react/avatar";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import BaseAvatarFallback from "./BaseAvatarFallback.js";
|
|
5
|
+
import BaseAvatarImage from "./BaseAvatarImage.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// src/components/display/BaseAvatar.tsx
|
|
8
|
+
/**
|
|
9
|
+
* A round box for a profile picture, initials or a fallback icon. Renders a `<span>`.
|
|
10
|
+
* Put a `BaseAvatar.Image` and a `BaseAvatar.Fallback` inside it.
|
|
11
|
+
*/
|
|
12
|
+
const BaseAvatar = ({ size = "md", className, ...otherProps }) => /* @__PURE__ */ jsx(Avatar.Root, {
|
|
13
|
+
...otherProps,
|
|
14
|
+
className: cn({
|
|
15
|
+
"size-12 text-lg": size === "lg",
|
|
16
|
+
"size-10 text-base": size === "md",
|
|
17
|
+
"size-8 text-sm": size === "sm",
|
|
18
|
+
"size-6 text-xs": size === "xs"
|
|
19
|
+
}, [
|
|
20
|
+
"relative",
|
|
21
|
+
"inline-flex",
|
|
22
|
+
"shrink-0",
|
|
23
|
+
"items-center",
|
|
24
|
+
"justify-center",
|
|
25
|
+
"overflow-hidden",
|
|
26
|
+
"rounded-full",
|
|
27
|
+
"align-middle",
|
|
28
|
+
"select-none"
|
|
29
|
+
], className)
|
|
30
|
+
});
|
|
31
|
+
var BaseAvatar_default = Object.assign(BaseAvatar, {
|
|
32
|
+
Image: BaseAvatarImage,
|
|
33
|
+
Fallback: BaseAvatarFallback
|
|
34
|
+
});
|
|
35
|
+
export { BaseAvatar_default as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AvatarState } from "./BaseAvatar.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
type BaseAvatarFallbackProps = ComponentProps<"span"> & {
|
|
5
|
+
render?: RenderProp<"span", AvatarState>;
|
|
6
|
+
/** Waits this many milliseconds before showing, so fast images don't flash it. */
|
|
7
|
+
delay?: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Shown when the image is missing, still loading or failed, e.g. initials or an icon.
|
|
11
|
+
* Renders a `<span>` that fills the avatar and centers its content.
|
|
12
|
+
*/
|
|
13
|
+
declare const BaseAvatarFallback: ({ className, ...otherProps }: BaseAvatarFallbackProps) => import("react").JSX.Element;
|
|
14
|
+
export { BaseAvatarFallback as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Avatar } from "@base-ui/react/avatar";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/components/display/BaseAvatarFallback.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Shown when the image is missing, still loading or failed, e.g. initials or an icon.
|
|
8
|
+
* Renders a `<span>` that fills the avatar and centers its content.
|
|
9
|
+
*/
|
|
10
|
+
const BaseAvatarFallback = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Avatar.Fallback, {
|
|
11
|
+
...otherProps,
|
|
12
|
+
className: cn("flex", "size-full", "items-center", "justify-center", className)
|
|
13
|
+
});
|
|
14
|
+
export { BaseAvatarFallback as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AvatarImageLoadingStatus, AvatarState } from "./BaseAvatar.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
export type AvatarImageState = AvatarState & {
|
|
5
|
+
/** `"starting"` while the image appears, `"ending"` while it disappears. */
|
|
6
|
+
transitionStatus: "starting" | "ending" | "idle" | undefined;
|
|
7
|
+
};
|
|
8
|
+
type BaseAvatarImageProps = ComponentProps<"img"> & {
|
|
9
|
+
render?: RenderProp<"img", AvatarImageState>;
|
|
10
|
+
/** Called when the image starts loading, loads or fails. */
|
|
11
|
+
onLoadingStatusChange?: (status: AvatarImageLoadingStatus) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Keeps the `<img>` in the DOM and loads it in place instead of preloading it,
|
|
14
|
+
* for `loading="lazy"` or an optimized image component such as `next/image`.
|
|
15
|
+
*/
|
|
16
|
+
keepMounted?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The avatar's picture, covering it. Renders an `<img>` once it has loaded,
|
|
20
|
+
* so the fallback shows while it loads or when it fails.
|
|
21
|
+
*/
|
|
22
|
+
declare const BaseAvatarImage: ({ className, ...otherProps }: BaseAvatarImageProps) => import("react").JSX.Element;
|
|
23
|
+
export { BaseAvatarImage as default };
|