@omer-x/tailwind-ui-kit 1.0.0-alpha.36 → 1.0.0-alpha.38
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 +182 -3
- 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 +2 -1
- package/dist/components/display/index.js +3 -1
- package/dist/components/form/BaseAutocomplete.d.ts +1 -1
- package/dist/components/menu/BaseContextMenu.d.ts +22 -12
- package/dist/components/menu/BaseMenu.d.ts +171 -0
- package/dist/components/menu/BaseMenu.js +62 -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/BaseMenuInput.d.ts +15 -0
- package/dist/components/menu/BaseMenuInput.js +10 -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 +52 -6
- package/dist/components/menu/BaseMenuPopup.js +6 -1
- package/dist/components/menu/BaseMenuSubmenu.d.ts +3 -18
- package/dist/components/menu/BaseMenuSubmenu.js +16 -4
- 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/createMenuHandle.d.ts +30 -0
- package/dist/components/menu/createMenuHandle.js +27 -0
- package/dist/components/menu/index.d.ts +9 -2
- package/dist/components/menu/index.js +4 -1
- package/dist/components/menu/menuTypes.d.ts +69 -0
- package/dist/components/menu/menuTypes.js +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -671,7 +671,7 @@ import { BaseContextMenu } from "@omer-x/tailwind-ui-kit/menu";
|
|
|
671
671
|
</BaseContextMenu>
|
|
672
672
|
```
|
|
673
673
|
|
|
674
|
-
Like `BaseDialog`, the parts use dot notation, so build menus in a `"use client"` file. Every part except the root and `Trigger` is shared with
|
|
674
|
+
Like `BaseDialog`, the parts use dot notation, so build menus in a `"use client"` file. Every part except the root and `Trigger` is shared with `BaseMenu`, so one set of popup and item styles themes both.
|
|
675
675
|
|
|
676
676
|
| Part | Renders | Description |
|
|
677
677
|
|------|---------|-------------|
|
|
@@ -720,8 +720,12 @@ Items (`Item`, `LinkItem`, `SubmenuTrigger`, `CheckboxItem`, `RadioItem`) share
|
|
|
720
720
|
| Prop | Type | Default | Description |
|
|
721
721
|
|------|------|---------|-------------|
|
|
722
722
|
| `side` / `align` | `MenuSide` / `MenuAlign` | at the pointer | Where the popup sits against its anchor (`"top"`, `"bottom"`, `"left"`, `"right"`, `"inline-start"`, `"inline-end"` / `"start"`, `"center"`, `"end"`). Submenus default to `"inline-end"` / `"start"` |
|
|
723
|
-
| `sideOffset` / `alignOffset` | `number` | | Offsets from the anchor, in pixels |
|
|
724
|
-
| `collisionPadding` | `number` | `5` | Space kept from the viewport edges |
|
|
723
|
+
| `sideOffset` / `alignOffset` | `number \| MenuOffsetFunction` | | Offsets from the anchor, in pixels, or a function of the placement and sizes |
|
|
724
|
+
| `collisionPadding` | `number \| { top, right, bottom, left }` | `5` | Space kept from the viewport edges |
|
|
725
|
+
| `collisionBoundary` / `collisionAvoidance` | | `"clipping-ancestors"` | The area the popup stays inside, and how it avoids its edges (flip or shift) |
|
|
726
|
+
| `anchor` | `Element \| RefObject \| () => Element \| null` | the trigger | The element the popup is placed against |
|
|
727
|
+
| `disableAnchorTracking` | `boolean` | `false` | Stops following the anchor when it moves |
|
|
728
|
+
| `arrowPadding` | `number` | `5` | Minimum distance between an `Arrow` and the popup's corners |
|
|
725
729
|
| `sticky` | `boolean` | `false` | Stays in view while the anchor scrolls away |
|
|
726
730
|
| `positionMethod` | `"absolute" \| "fixed"` | `"absolute"` | Use `"fixed"` when the anchor is inside a fixed container |
|
|
727
731
|
| `positionerClassName` / `renderPositioner` | `string` / `RenderProp<"div", MenuPositionerState>` | | Style or replace the positioner, the `<div>` around the popup that places it (`z-50`) |
|
|
@@ -745,6 +749,120 @@ Data attributes: the popup has `data-open` / `data-closed`, `data-side`, `data-a
|
|
|
745
749
|
</BaseContextMenu.Submenu>
|
|
746
750
|
```
|
|
747
751
|
|
|
752
|
+
|
|
753
|
+
#### `BaseMenu`
|
|
754
|
+
|
|
755
|
+
A Base UI [`Menu`](https://base-ui.com/react/components/menu): a list of actions opened from a button, with keyboard navigation, submenus, checkbox and radio items, and optional filtering. It uses the same `Popup`, `Arrow`, items, groups and submenus as `BaseContextMenu` (see above), so one set of styles themes both. A simple menu needs no more than this:
|
|
756
|
+
|
|
757
|
+
```tsx
|
|
758
|
+
import { BaseMenu } from "@omer-x/tailwind-ui-kit/menu";
|
|
759
|
+
|
|
760
|
+
<BaseMenu>
|
|
761
|
+
<BaseMenu.Trigger render={<Button />}>Actions</BaseMenu.Trigger>
|
|
762
|
+
<BaseMenu.Popup sideOffset={4} className="rounded-md border bg-white shadow-lg">
|
|
763
|
+
<BaseMenu.Item className="data-highlighted:bg-neutral-100" onClick={edit}>Edit</BaseMenu.Item>
|
|
764
|
+
<BaseMenu.Separator className="bg-neutral-200" />
|
|
765
|
+
<BaseMenu.Item className="data-highlighted:bg-neutral-100" onClick={remove}>Delete</BaseMenu.Item>
|
|
766
|
+
</BaseMenu.Popup>
|
|
767
|
+
</BaseMenu>
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
Parts besides the shared ones (`Popup`, `Arrow`, `Item`, `LinkItem`, `Separator`, `Group`, `GroupLabel`, `RadioGroup`, `RadioItem`, `CheckboxItem`, `Submenu`, `SubmenuTrigger`):
|
|
771
|
+
|
|
772
|
+
| Part | Renders | Description |
|
|
773
|
+
|------|---------|-------------|
|
|
774
|
+
| `BaseMenu` | nothing | Groups the parts and holds the open state |
|
|
775
|
+
| `BaseMenu.Trigger` | `<button>` | Opens the menu. `data-popup-open` while its menu is open. Takes `handle`, `payload`, `openOnHover` (also open on hover), `delay` / `closeDelay` (hover delays in ms, default `100` / `0`) and `nativeButton` |
|
|
776
|
+
| `BaseMenu.Input` | `<input>` | The search box of a `filterable` menu (`role="searchbox"`) |
|
|
777
|
+
| `BaseMenu.Clear` | `<button>` | Clears the search box. Only rendered while there's a query. A pointer shortcut: out of the tab order and `aria-hidden` |
|
|
778
|
+
| `BaseMenu.Empty` | `<div>` | Shown only when no item matches (`role="status"`). Not rendered otherwise |
|
|
779
|
+
| `BaseMenu.List` | `<div>` | Holds the items when the popup has other content too (the search box). Scrolls when the popup runs out of space (`min-h-0 flex-1 overflow-y-auto`) |
|
|
780
|
+
| `BaseMenu.Viewport` | `<div>` | Animates the content when one menu is opened by several triggers and its content depends on the trigger. `data-activation-direction`, `data-transitioning` |
|
|
781
|
+
|
|
782
|
+
The popup is placed below the trigger and centered by default (`side="bottom"`, `align="center"`).
|
|
783
|
+
|
|
784
|
+
`BaseMenu` props:
|
|
785
|
+
|
|
786
|
+
| Prop | Type | Default | Description |
|
|
787
|
+
|------|------|---------|-------------|
|
|
788
|
+
| `open` / `defaultOpen` | `boolean` | `false` | Controlled / initial open state |
|
|
789
|
+
| `onOpenChange` | `(open, event) => void` | | Called with the new state and the DOM event that changed it (`undefined` when changed from code) |
|
|
790
|
+
| `onOpenChangeComplete` | `(open) => void` | | Called after the open or close transition ends |
|
|
791
|
+
| `modal` | `boolean` | `true` | Locks page scroll and blocks outside pointer input while open. Menus opened by hover never are |
|
|
792
|
+
| `disabled` | `boolean` | `false` | |
|
|
793
|
+
| `loopFocus` | `boolean` | `true` | Arrow keys wrap from the last item to the first |
|
|
794
|
+
| `highlightItemOnHover` | `boolean` | `true` | Turn it off to style `:hover` apart from `data-highlighted` |
|
|
795
|
+
| `orientation` | `"vertical" \| "horizontal"` | `"vertical"` | Which arrow keys move between items |
|
|
796
|
+
| `onItemHighlighted` | `(item, { reason, label }) => void` | | The highlighted element (or `undefined`). `reason` is `"keyboard"`, `"pointer"` or `"none"` |
|
|
797
|
+
| `actionsRef` | `RefObject<MenuActions>` | | `actionsRef.current?.close()` |
|
|
798
|
+
| `handle` | `MenuHandle<Payload>` | | Connects triggers outside the menu and opens it from code (see below) |
|
|
799
|
+
| `triggerId` / `defaultTriggerId` | `string \| null` | | The trigger a controlled / initially open menu belongs to |
|
|
800
|
+
| `children` | `ReactNode \| ({ payload }) => ReactNode` | | The parts, or a function that gets the payload of the trigger that opened the menu |
|
|
801
|
+
| `filterable` | `boolean` | `false` | Adds filtering (see below) |
|
|
802
|
+
|
|
803
|
+
`Submenu` also takes `orientation`, `onItemHighlighted`, `actionsRef` and the filtering props.
|
|
804
|
+
|
|
805
|
+
**Router links.** `LinkItem` renders an `<a>`. Pass your router's link as `render`, and it gets the item's props and behavior:
|
|
806
|
+
|
|
807
|
+
```tsx
|
|
808
|
+
import Link from "next/link";
|
|
809
|
+
|
|
810
|
+
<BaseMenu.LinkItem render={<Link href="/settings" />}>Settings</BaseMenu.LinkItem>
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
**Filtering.** `filterable` (on `BaseMenu` or a `Submenu`) lets the user filter the items by typing in an `Input`. Put the items in a `List`; items that don't match are removed. The popup becomes a `role="dialog"` holding the search box and the `role="menu"` list. Make the popup a flex column (`flex flex-col`) so only the list scrolls:
|
|
814
|
+
|
|
815
|
+
```tsx
|
|
816
|
+
<BaseMenu filterable>
|
|
817
|
+
<BaseMenu.Trigger render={<Button />}>Labels</BaseMenu.Trigger>
|
|
818
|
+
<BaseMenu.Popup className="flex flex-col">
|
|
819
|
+
<BaseMenu.Input aria-label="Search labels" placeholder="Search labels" />
|
|
820
|
+
<BaseMenu.Empty className="py-1.5">No labels found</BaseMenu.Empty>
|
|
821
|
+
<BaseMenu.List>
|
|
822
|
+
{labels.map(label => <BaseMenu.CheckboxItem key={label}>{label}</BaseMenu.CheckboxItem>)}
|
|
823
|
+
</BaseMenu.List>
|
|
824
|
+
</BaseMenu.Popup>
|
|
825
|
+
</BaseMenu>
|
|
826
|
+
```
|
|
827
|
+
|
|
828
|
+
| Prop | Type | Description |
|
|
829
|
+
|------|------|-------------|
|
|
830
|
+
| `filter` | `(text, query) => boolean \| null` | Decides what matches, from the item's `label` (or text) and the trimmed query. Defaults to "contains", ignoring case, accents and punctuation. `null` shows every item (filter them yourself) |
|
|
831
|
+
| `autoHighlight` | `boolean \| "always"` | Highlights the first match while there's a query (`"always"`: also without one) |
|
|
832
|
+
| `locale` | `Intl.LocalesArgument` | Locale of the default filter |
|
|
833
|
+
| `query` / `defaultQuery` | `string` | The query, controlled / uncontrolled. It's cleared when the menu closes |
|
|
834
|
+
| `onQueryChange` | `(query, event) => void` | Called with the new query and the DOM event |
|
|
835
|
+
|
|
836
|
+
#### `createMenuHandle`
|
|
837
|
+
|
|
838
|
+
Opens one menu from triggers anywhere on the page, or from code. Each trigger can pass a `payload`, which the menu's function children receive:
|
|
839
|
+
|
|
840
|
+
```tsx
|
|
841
|
+
import { BaseMenu, createMenuHandle } from "@omer-x/tailwind-ui-kit/menu";
|
|
842
|
+
|
|
843
|
+
const rowMenu = createMenuHandle<{ id: string, name: string }>();
|
|
844
|
+
|
|
845
|
+
// triggers anywhere on the page
|
|
846
|
+
<BaseMenu.Trigger id={`row-${row.id}`} handle={rowMenu} payload={row} render={<Button />}>Options</BaseMenu.Trigger>
|
|
847
|
+
|
|
848
|
+
// one menu on the page
|
|
849
|
+
<BaseMenu handle={rowMenu}>
|
|
850
|
+
{({ payload }) => payload && (
|
|
851
|
+
<BaseMenu.Popup>
|
|
852
|
+
<BaseMenu.Item onClick={() => rename(payload.id)}>Rename {payload.name}</BaseMenu.Item>
|
|
853
|
+
</BaseMenu.Popup>
|
|
854
|
+
)}
|
|
855
|
+
</BaseMenu>
|
|
856
|
+
|
|
857
|
+
// from code
|
|
858
|
+
rowMenu.open(`row-${id}`);
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
A `MenuHandle<Payload>` has `open(triggerId)`, `close()` and `isOpen`. Unlike the dialog handles, it has no `openWithPayload`: a menu is placed against its trigger, so `open` needs the `id` of a trigger with the same handle (it throws when there's none).
|
|
862
|
+
|
|
863
|
+
- Calls are **ignored while the menu isn't mounted**. Keep the `BaseMenu` with the handle rendered.
|
|
864
|
+
- Call them **from event handlers or effects, never during render**.
|
|
865
|
+
|
|
748
866
|
### `@omer-x/tailwind-ui-kit/disclosure`
|
|
749
867
|
|
|
750
868
|
#### `BaseAccordion`
|
|
@@ -917,6 +1035,67 @@ Every part takes `className` and `render`.
|
|
|
917
1035
|
|
|
918
1036
|
Data attributes: the image has `data-starting-style` / `data-ending-style` while it appears and disappears, so it can fade in (`transition-opacity data-starting-style:opacity-0`). With `keepMounted`, it has `data-loading` while loading and `data-error` when it failed.
|
|
919
1037
|
|
|
1038
|
+
#### `BaseMeter`
|
|
1039
|
+
|
|
1040
|
+
A Base UI [`Meter`](https://base-ui.com/react/components/meter): a graphical display of a numeric value within a known range, like disk usage or battery level. It renders a `<div role="meter">` with the label and the value on top and the track below (`flex flex-wrap`). For a task's completion, use a progress bar instead.
|
|
1041
|
+
|
|
1042
|
+
```tsx
|
|
1043
|
+
import { BaseMeter } from "@omer-x/tailwind-ui-kit/display";
|
|
1044
|
+
|
|
1045
|
+
<BaseMeter
|
|
1046
|
+
value={usedGb}
|
|
1047
|
+
max={quotaGb}
|
|
1048
|
+
label="Storage used"
|
|
1049
|
+
showValue
|
|
1050
|
+
trackClassName="bg-neutral-200"
|
|
1051
|
+
indicatorClassName="bg-blue-600"
|
|
1052
|
+
/>
|
|
1053
|
+
```
|
|
1054
|
+
|
|
1055
|
+
| Prop | Type | Default | Description |
|
|
1056
|
+
|------|------|---------|-------------|
|
|
1057
|
+
| `value` | `number` | | The current value, clamped to `min`…`max` |
|
|
1058
|
+
| `min` / `max` | `number` | `0` / `100` | The range |
|
|
1059
|
+
| `format` | `Intl.NumberFormatOptions` | | How the value is formatted. Without it, it is shown as a percentage of the range |
|
|
1060
|
+
| `locale` | `Intl.LocalesArgument` | runtime locale | The locale used to format the value |
|
|
1061
|
+
| `getAriaValueText` | `(formattedValue, value) => string` | | What screen readers announce for the value |
|
|
1062
|
+
| `label` | `ReactNode` | | The visible name. It labels the meter. Without it, nothing is rendered for it: use `aria-label` |
|
|
1063
|
+
| `labelClassName` | `string` | | Classes for the label `<span>` (default `grow`) |
|
|
1064
|
+
| `renderLabel` | `RenderProp<"span", MeterState>` | | Render another element for the label |
|
|
1065
|
+
| `showValue` | `boolean \| (formattedValue, value) => ReactNode` | `false` | Shows the value as text next to the label. A function shows something else, e.g. `` (f) => `${f} of 5 kWh` `` |
|
|
1066
|
+
| `valueClassName` | `string` | | Classes for the value `<span>` (default `ms-auto tabular-nums`). It is `aria-hidden`: screen readers read the meter's value |
|
|
1067
|
+
| `renderValue` | `RenderProp<"span", MeterState>` | | Render another element for the value |
|
|
1068
|
+
| `size` | `"lg" \| "md" \| "sm" \| "xs"` | `"md"` | The track's height: `h-3` / `h-2` / `h-1.5` / `h-1` |
|
|
1069
|
+
| `trackClassName` | `string` | | Classes for the track `<div>` (default `relative block w-full overflow-hidden rounded-full`) |
|
|
1070
|
+
| `renderTrack` | `RenderProp<"div", MeterState>` | | Render another element for the track |
|
|
1071
|
+
| `indicatorClassName` | `string` | | Classes for the indicator `<div>`, the filled part. Its width is set inline and transitions (`transition-[width] duration-500`) |
|
|
1072
|
+
| `renderIndicator` | `RenderProp<"div", MeterState>` | | Render another element for the indicator |
|
|
1073
|
+
| `children` | `ReactNode` | | Lays out the parts yourself (see below). The built-in label, value and track aren't rendered then |
|
|
1074
|
+
| `className` | `string` | | Classes for the root `<div>` |
|
|
1075
|
+
| `render` | `RenderProp<"div", MeterState>` | | Render another element for the root |
|
|
1076
|
+
| …rest | | | `<div>` props |
|
|
1077
|
+
|
|
1078
|
+
To place the parts yourself, e.g. the value inside the track, pass them as children. Dot notation only works in client components.
|
|
1079
|
+
|
|
1080
|
+
```tsx
|
|
1081
|
+
<BaseMeter value={24}>
|
|
1082
|
+
<BaseMeter.Label className="sr-only">Upload quota</BaseMeter.Label>
|
|
1083
|
+
<BaseMeter.Track className="h-5 bg-neutral-200">
|
|
1084
|
+
<BaseMeter.Indicator className="bg-blue-600" />
|
|
1085
|
+
<BaseMeter.Value className="absolute inset-0 flex items-center justify-center" />
|
|
1086
|
+
</BaseMeter.Track>
|
|
1087
|
+
</BaseMeter>
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
| Part | Renders | Props |
|
|
1091
|
+
|------|---------|-------|
|
|
1092
|
+
| `BaseMeter.Label` | `<span>` | `className`, `render` |
|
|
1093
|
+
| `BaseMeter.Track` | `<div>` | `size`, `className`, `render` |
|
|
1094
|
+
| `BaseMeter.Indicator` | `<div>` | `className`, `render` |
|
|
1095
|
+
| `BaseMeter.Value` | `<span>` | `className`, `render`, `children?: (formattedValue, value) => ReactNode` |
|
|
1096
|
+
|
|
1097
|
+
Render functions get `MeterState`, which is empty for now. The meter sets no data attributes: style value ranges in your wrapper (e.g. pick the indicator color from `value`).
|
|
1098
|
+
|
|
920
1099
|
### `@omer-x/tailwind-ui-kit/layout`
|
|
921
1100
|
|
|
922
1101
|
#### `Container`
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { BarSize } from "./barStyles.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps, ReactNode } from "react";
|
|
4
|
+
/** The meter has no state of its own yet. Render functions get an empty object. */
|
|
5
|
+
export type MeterState = object;
|
|
6
|
+
type BaseMeterProps = Omit<ComponentProps<"div">, "children"> & {
|
|
7
|
+
render?: RenderProp<"div", MeterState>;
|
|
8
|
+
/** The current value. It is clamped to `min`…`max`. */
|
|
9
|
+
value: number;
|
|
10
|
+
/** @default 0 */
|
|
11
|
+
min?: number;
|
|
12
|
+
/** @default 100 */
|
|
13
|
+
max?: number;
|
|
14
|
+
/** How the value is formatted. Without it, the value is shown as a percentage of the range. */
|
|
15
|
+
format?: Intl.NumberFormatOptions;
|
|
16
|
+
/** The locale used to format the value. Defaults to the user's runtime locale. */
|
|
17
|
+
locale?: Intl.LocalesArgument;
|
|
18
|
+
/** Text that screen readers announce for the value, built from the formatted value. */
|
|
19
|
+
getAriaValueText?: (formattedValue: string, value: number) => string;
|
|
20
|
+
/** The meter's visible name. It labels the meter for assistive technology. */
|
|
21
|
+
label?: ReactNode;
|
|
22
|
+
/** Classes for the label `<span>`. */
|
|
23
|
+
labelClassName?: string;
|
|
24
|
+
renderLabel?: RenderProp<"span", MeterState>;
|
|
25
|
+
/** Shows the value as text next to the label. A function shows something else, e.g. `"3 of 10 GB"`. */
|
|
26
|
+
showValue?: boolean | ((formattedValue: string, value: number) => ReactNode);
|
|
27
|
+
/** Classes for the value `<span>`. */
|
|
28
|
+
valueClassName?: string;
|
|
29
|
+
renderValue?: RenderProp<"span", MeterState>;
|
|
30
|
+
/** The track's height. */
|
|
31
|
+
size?: BarSize;
|
|
32
|
+
/** Classes for the track `<div>`. */
|
|
33
|
+
trackClassName?: string;
|
|
34
|
+
renderTrack?: RenderProp<"div", MeterState>;
|
|
35
|
+
/** Classes for the indicator `<div>`, the filled part of the track. */
|
|
36
|
+
indicatorClassName?: string;
|
|
37
|
+
renderIndicator?: RenderProp<"div", MeterState>;
|
|
38
|
+
/**
|
|
39
|
+
* Lays out the meter's parts yourself (`BaseMeter.Label`, `.Track`, `.Indicator`, `.Value`).
|
|
40
|
+
* When given, the built-in label, value and track aren't rendered.
|
|
41
|
+
*/
|
|
42
|
+
children?: ReactNode;
|
|
43
|
+
};
|
|
44
|
+
declare const _default: (({ label, labelClassName, renderLabel, showValue, valueClassName, renderValue, size, trackClassName, renderTrack, indicatorClassName, renderIndicator, className, children, ...otherProps }: BaseMeterProps) => import("react").JSX.Element) & {
|
|
45
|
+
Label: (props: import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & {
|
|
46
|
+
render?: RenderProp<"span", MeterState>;
|
|
47
|
+
}) => import("react").JSX.Element;
|
|
48
|
+
Track: ({ size, className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
49
|
+
render?: RenderProp<"div", MeterState>;
|
|
50
|
+
size?: BarSize;
|
|
51
|
+
}) => import("react").JSX.Element;
|
|
52
|
+
Indicator: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
53
|
+
render?: RenderProp<"div", MeterState>;
|
|
54
|
+
}) => import("react").JSX.Element;
|
|
55
|
+
Value: (props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "children"> & {
|
|
56
|
+
render?: RenderProp<"span", MeterState>;
|
|
57
|
+
children?: (formattedValue: string, value: number) => ReactNode;
|
|
58
|
+
}) => import("react").JSX.Element;
|
|
59
|
+
};
|
|
60
|
+
export { _default as default };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Meter } from "@base-ui/react/meter";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import BaseMeterIndicator from "./BaseMeterIndicator.js";
|
|
5
|
+
import BaseMeterLabel from "./BaseMeterLabel.js";
|
|
6
|
+
import BaseMeterTrack from "./BaseMeterTrack.js";
|
|
7
|
+
import BaseMeterValue from "./BaseMeterValue.js";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
// src/components/display/BaseMeter.tsx
|
|
10
|
+
/**
|
|
11
|
+
* A graphical display of a numeric value within a known range, like disk usage or battery level.
|
|
12
|
+
* Renders a `<div>` with `role="meter"`: the label and the value on top, the track below.
|
|
13
|
+
*/
|
|
14
|
+
const BaseMeter = ({ label, labelClassName, renderLabel, showValue = false, valueClassName, renderValue, size = "md", trackClassName, renderTrack, indicatorClassName, renderIndicator, className, children, ...otherProps }) => /* @__PURE__ */ jsx(Meter.Root, {
|
|
15
|
+
...otherProps,
|
|
16
|
+
className: cn("flex flex-wrap items-center gap-x-2 gap-y-1", className),
|
|
17
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
18
|
+
typeof label !== "undefined" && /* @__PURE__ */ jsx(BaseMeterLabel, {
|
|
19
|
+
render: renderLabel,
|
|
20
|
+
className: cn("grow", labelClassName),
|
|
21
|
+
children: label
|
|
22
|
+
}),
|
|
23
|
+
showValue !== false && /* @__PURE__ */ jsx(BaseMeterValue, {
|
|
24
|
+
render: renderValue,
|
|
25
|
+
className: cn("ms-auto", "tabular-nums", valueClassName),
|
|
26
|
+
children: typeof showValue === "function" ? showValue : void 0
|
|
27
|
+
}),
|
|
28
|
+
/* @__PURE__ */ jsx(BaseMeterTrack, {
|
|
29
|
+
size,
|
|
30
|
+
render: renderTrack,
|
|
31
|
+
className: trackClassName,
|
|
32
|
+
children: /* @__PURE__ */ jsx(BaseMeterIndicator, {
|
|
33
|
+
render: renderIndicator,
|
|
34
|
+
className: indicatorClassName
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
] })
|
|
38
|
+
});
|
|
39
|
+
var BaseMeter_default = Object.assign(BaseMeter, {
|
|
40
|
+
Label: BaseMeterLabel,
|
|
41
|
+
Track: BaseMeterTrack,
|
|
42
|
+
Indicator: BaseMeterIndicator,
|
|
43
|
+
Value: BaseMeterValue
|
|
44
|
+
});
|
|
45
|
+
export { BaseMeter_default as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MeterState } from "./BaseMeter.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
type BaseMeterIndicatorProps = ComponentProps<"div"> & {
|
|
5
|
+
render?: RenderProp<"div", MeterState>;
|
|
6
|
+
};
|
|
7
|
+
/** The filled part of the track. Its width follows the value. Renders a `<div>`. */
|
|
8
|
+
declare const BaseMeterIndicator: ({ className, ...otherProps }: BaseMeterIndicatorProps) => import("react").JSX.Element;
|
|
9
|
+
export { BaseMeterIndicator as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Meter } from "@base-ui/react/meter";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { barIndicatorClassName } from "./barStyles.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/display/BaseMeterIndicator.tsx
|
|
7
|
+
/** The filled part of the track. Its width follows the value. Renders a `<div>`. */
|
|
8
|
+
const BaseMeterIndicator = ({ className, ...otherProps }) => /* @__PURE__ */ jsx(Meter.Indicator, {
|
|
9
|
+
...otherProps,
|
|
10
|
+
className: cn(barIndicatorClassName, className)
|
|
11
|
+
});
|
|
12
|
+
export { BaseMeterIndicator as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MeterState } from "./BaseMeter.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps } from "react";
|
|
4
|
+
type BaseMeterLabelProps = ComponentProps<"span"> & {
|
|
5
|
+
render?: RenderProp<"span", MeterState>;
|
|
6
|
+
};
|
|
7
|
+
/** The meter's visible name. It labels the meter for assistive technology. Renders a `<span>`. */
|
|
8
|
+
declare const BaseMeterLabel: (props: BaseMeterLabelProps) => import("react").JSX.Element;
|
|
9
|
+
export { BaseMeterLabel as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Meter } from "@base-ui/react/meter";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/display/BaseMeterLabel.tsx
|
|
5
|
+
/** The meter's visible name. It labels the meter for assistive technology. Renders a `<span>`. */
|
|
6
|
+
const BaseMeterLabel = (props) => /* @__PURE__ */ jsx(Meter.Label, { ...props });
|
|
7
|
+
export { BaseMeterLabel as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BarSize } from "./barStyles.js";
|
|
2
|
+
import { MeterState } from "./BaseMeter.js";
|
|
3
|
+
import { RenderProp } from "../../utils/render.js";
|
|
4
|
+
import { ComponentProps } from "react";
|
|
5
|
+
type BaseMeterTrackProps = ComponentProps<"div"> & {
|
|
6
|
+
render?: RenderProp<"div", MeterState>;
|
|
7
|
+
/** The track's height. */
|
|
8
|
+
size?: BarSize;
|
|
9
|
+
};
|
|
10
|
+
/** The whole range of the meter. Put a `BaseMeter.Indicator` inside it. Renders a `<div>`. */
|
|
11
|
+
declare const BaseMeterTrack: ({ size, className, ...otherProps }: BaseMeterTrackProps) => import("react").JSX.Element;
|
|
12
|
+
export { BaseMeterTrack as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Meter } from "@base-ui/react/meter";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { barTrackClassName } from "./barStyles.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/display/BaseMeterTrack.tsx
|
|
7
|
+
/** The whole range of the meter. Put a `BaseMeter.Indicator` inside it. Renders a `<div>`. */
|
|
8
|
+
const BaseMeterTrack = ({ size = "md", className, ...otherProps }) => /* @__PURE__ */ jsx(Meter.Track, {
|
|
9
|
+
...otherProps,
|
|
10
|
+
className: cn(barTrackClassName(size), className)
|
|
11
|
+
});
|
|
12
|
+
export { BaseMeterTrack as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MeterState } from "./BaseMeter.js";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
import { ComponentProps, ReactNode } from "react";
|
|
4
|
+
type BaseMeterValueProps = Omit<ComponentProps<"span">, "children"> & {
|
|
5
|
+
render?: RenderProp<"span", MeterState>;
|
|
6
|
+
/** Shows something else than the formatted value, e.g. `(formatted, value) => `${value} GB``. */
|
|
7
|
+
children?: (formattedValue: string, value: number) => ReactNode;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The value as text, formatted with the meter's `format` and `locale` (a percentage by default).
|
|
11
|
+
* Hidden from assistive technology, which reads the meter's own value. Renders a `<span>`.
|
|
12
|
+
*/
|
|
13
|
+
declare const BaseMeterValue: (props: BaseMeterValueProps) => import("react").JSX.Element;
|
|
14
|
+
export { BaseMeterValue as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Meter } from "@base-ui/react/meter";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/display/BaseMeterValue.tsx
|
|
5
|
+
/**
|
|
6
|
+
* The value as text, formatted with the meter's `format` and `locale` (a percentage by default).
|
|
7
|
+
* Hidden from assistive technology, which reads the meter's own value. Renders a `<span>`.
|
|
8
|
+
*/
|
|
9
|
+
const BaseMeterValue = (props) => /* @__PURE__ */ jsx(Meter.Value, { ...props });
|
|
10
|
+
export { BaseMeterValue as default };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type BarSize = "lg" | "md" | "sm" | "xs";
|
|
2
|
+
/** Classes for the track of a horizontal bar (Meter, Progress): the full range. */
|
|
3
|
+
export declare function barTrackClassName(size: BarSize): string;
|
|
4
|
+
/** Classes for the filled part of a bar. Base UI sets its width (and height) inline. */
|
|
5
|
+
export declare const barIndicatorClassName: string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { cn } from "cn";
|
|
2
|
+
// src/components/display/barStyles.ts
|
|
3
|
+
/** Classes for the track of a horizontal bar (Meter, Progress): the full range. */
|
|
4
|
+
function barTrackClassName(size) {
|
|
5
|
+
return cn({
|
|
6
|
+
"h-3": size === "lg",
|
|
7
|
+
"h-2": size === "md",
|
|
8
|
+
"h-1.5": size === "sm",
|
|
9
|
+
"h-1": size === "xs"
|
|
10
|
+
}, [
|
|
11
|
+
"relative",
|
|
12
|
+
"block",
|
|
13
|
+
"w-full",
|
|
14
|
+
"overflow-hidden",
|
|
15
|
+
"rounded-full"
|
|
16
|
+
]);
|
|
17
|
+
}
|
|
18
|
+
/** Classes for the filled part of a bar. Base UI sets its width (and height) inline. */
|
|
19
|
+
const barIndicatorClassName = cn("block", "h-full", "transition-[width]", "duration-500", "ease-out", "motion-reduce:transition-none");
|
|
20
|
+
export { barIndicatorClassName, barTrackClassName };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import _default, { AvatarImageLoadingStatus, AvatarState } from "./BaseAvatar.js";
|
|
2
2
|
import { AvatarImageState } from "./BaseAvatarImage.js";
|
|
3
|
-
|
|
3
|
+
import _default$1, { MeterState } from "./BaseMeter.js";
|
|
4
|
+
export { type AvatarImageLoadingStatus, type AvatarImageState, type AvatarState, _default as BaseAvatar, _default$1 as BaseMeter, type MeterState };
|
|
@@ -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>, "
|
|
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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RenderProp } from "../../utils/render.js";
|
|
2
2
|
import { ContextMenuTriggerState } from "./BaseContextMenuTrigger.js";
|
|
3
3
|
import "../../utils/index.js";
|
|
4
|
-
import { MenuAlign, MenuBackdropState, MenuFocusTarget, MenuPopupState, MenuPositionerState, MenuSide } from "./BaseMenuPopup.js";
|
|
4
|
+
import { MenuAlign, MenuBackdropState, MenuCollisionAvoidance, MenuFocusTarget, MenuOffsetFunction, MenuPopupState, MenuPositionerState, MenuSide } from "./BaseMenuPopup.js";
|
|
5
5
|
import { MenuArrowState } from "./BaseMenuArrow.js";
|
|
6
6
|
import { MenuItemState } from "./BaseMenuItem.js";
|
|
7
7
|
import { MenuLinkItemState } from "./BaseMenuLinkItem.js";
|
|
@@ -9,6 +9,7 @@ import { MenuSeparatorState } from "./BaseMenuSeparator.js";
|
|
|
9
9
|
import { MenuRadioGroupState } from "./BaseMenuRadioGroup.js";
|
|
10
10
|
import { MenuRadioItemState } from "./BaseMenuRadioItem.js";
|
|
11
11
|
import { MenuCheckboxItemState } from "./BaseMenuCheckboxItem.js";
|
|
12
|
+
import { MenuRootSharedProps } from "./menuTypes.js";
|
|
12
13
|
import { MenuSubmenuTriggerState } from "./BaseMenuSubmenuTrigger.js";
|
|
13
14
|
import { ReactNode } from "react";
|
|
14
15
|
type BaseContextMenuProps = {
|
|
@@ -42,13 +43,28 @@ declare const _default: (({ onOpenChange, ...otherProps }: BaseContextMenuProps)
|
|
|
42
43
|
Trigger: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
43
44
|
render?: RenderProp<"div", ContextMenuTriggerState>;
|
|
44
45
|
}) => import("react").JSX.Element;
|
|
45
|
-
Popup: ({ side, align, sideOffset, alignOffset, collisionPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, backdrop, renderBackdrop, className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
46
|
+
Popup: ({ side, align, sideOffset, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, anchor, disableAnchorTracking, arrowPadding, sticky, positionMethod, positionerClassName, renderPositioner, container, keepMounted, backdrop, renderBackdrop, className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
46
47
|
render?: RenderProp<"div", MenuPopupState>;
|
|
47
48
|
side?: MenuSide;
|
|
48
49
|
align?: MenuAlign;
|
|
49
|
-
sideOffset?: number;
|
|
50
|
-
alignOffset?: number;
|
|
51
|
-
collisionPadding?: number
|
|
50
|
+
sideOffset?: number | MenuOffsetFunction;
|
|
51
|
+
alignOffset?: number | MenuOffsetFunction;
|
|
52
|
+
collisionPadding?: number | {
|
|
53
|
+
top?: number;
|
|
54
|
+
right?: number;
|
|
55
|
+
bottom?: number;
|
|
56
|
+
left?: number;
|
|
57
|
+
};
|
|
58
|
+
collisionBoundary?: "clipping-ancestors" | Element | Element[] | {
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
width: number;
|
|
62
|
+
height: number;
|
|
63
|
+
};
|
|
64
|
+
collisionAvoidance?: MenuCollisionAvoidance;
|
|
65
|
+
anchor?: Element | import("react").RefObject<Element | null> | (() => Element | null) | null;
|
|
66
|
+
disableAnchorTracking?: boolean;
|
|
67
|
+
arrowPadding?: number;
|
|
52
68
|
sticky?: boolean;
|
|
53
69
|
positionMethod?: "absolute" | "fixed";
|
|
54
70
|
positionerClassName?: string;
|
|
@@ -114,14 +130,8 @@ declare const _default: (({ onOpenChange, ...otherProps }: BaseContextMenuProps)
|
|
|
114
130
|
closeOnClick?: boolean;
|
|
115
131
|
nativeButton?: boolean;
|
|
116
132
|
}) => import("react").JSX.Element;
|
|
117
|
-
Submenu: (
|
|
118
|
-
open?: boolean;
|
|
119
|
-
defaultOpen?: boolean;
|
|
133
|
+
Submenu: (props: MenuRootSharedProps & {
|
|
120
134
|
onOpenChange?: (open: boolean, event: Event | undefined) => void;
|
|
121
|
-
onOpenChangeComplete?: (open: boolean) => void;
|
|
122
|
-
disabled?: boolean;
|
|
123
|
-
loopFocus?: boolean;
|
|
124
|
-
highlightItemOnHover?: boolean;
|
|
125
135
|
closeParentOnEsc?: boolean;
|
|
126
136
|
children?: ReactNode;
|
|
127
137
|
}) => import("react").JSX.Element;
|