@omer-x/tailwind-ui-kit 1.0.0-alpha.44 → 1.0.0-alpha.46
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 +52 -1707
- package/dist/components/form/BaseAutocomplete.d.ts +1 -1
- package/dist/components/form/BaseSlider.d.ts +136 -0
- package/dist/components/form/BaseSlider.js +66 -0
- package/dist/components/form/BaseSliderControl.d.ts +12 -0
- package/dist/components/form/BaseSliderControl.js +14 -0
- package/dist/components/form/BaseSliderIndicator.d.ts +12 -0
- package/dist/components/form/BaseSliderIndicator.js +14 -0
- package/dist/components/form/BaseSliderLabel.d.ts +9 -0
- package/dist/components/form/BaseSliderLabel.js +7 -0
- package/dist/components/form/BaseSliderThumb.d.ts +30 -0
- package/dist/components/form/BaseSliderThumb.js +15 -0
- package/dist/components/form/BaseSliderTrack.d.ts +12 -0
- package/dist/components/form/BaseSliderTrack.js +12 -0
- package/dist/components/form/BaseSliderValue.d.ts +14 -0
- package/dist/components/form/BaseSliderValue.js +10 -0
- package/dist/components/form/index.d.ts +3 -1
- package/dist/components/form/index.js +2 -1
- package/dist/components/form/sliderStyles.d.ts +5 -0
- package/dist/components/form/sliderStyles.js +32 -0
- package/dist/components/menu/BaseMenu.d.ts +1 -1
- package/dist/components/menu/BaseMenubar.d.ts +1 -1
- package/dist/components/navigation/BaseTabs.d.ts +44 -0
- package/dist/components/navigation/BaseTabs.js +24 -0
- package/dist/components/navigation/BaseTabsIndicator.d.ts +30 -0
- package/dist/components/navigation/BaseTabsIndicator.js +16 -0
- package/dist/components/navigation/BaseTabsList.d.ts +19 -0
- package/dist/components/navigation/BaseTabsList.js +14 -0
- package/dist/components/navigation/BaseTabsPanel.d.ts +19 -0
- package/dist/components/navigation/BaseTabsPanel.js +11 -0
- package/dist/components/navigation/BaseTabsTab.d.ts +20 -0
- package/dist/components/navigation/BaseTabsTab.js +11 -0
- package/dist/components/navigation/index.d.ts +6 -0
- package/dist/components/navigation/index.js +1 -0
- package/dist/components/navigation/tabsTypes.d.ts +8 -0
- package/dist/components/navigation/tabsTypes.js +1 -0
- package/docs/button/BaseButton.md +32 -0
- package/docs/button/BaseToggle.md +29 -0
- package/docs/button/BaseToggleGroup.md +28 -0
- package/docs/dialog/BaseAlertDialog.md +36 -0
- package/docs/dialog/BaseDialog.md +61 -0
- package/docs/dialog/createAlertDialogHandle.md +21 -0
- package/docs/dialog/createDialogHandle.md +31 -0
- package/docs/disclosure/BaseAccordion.md +67 -0
- package/docs/disclosure/BaseCollapsible.md +56 -0
- package/docs/display/BaseAvatar.md +48 -0
- package/docs/display/BaseMeter.md +62 -0
- package/docs/elements/README.md +9 -0
- package/docs/feedback/BaseToast.md +91 -0
- package/docs/feedback/createToastManager.md +19 -0
- package/docs/feedback/useToast.md +37 -0
- package/docs/form/BaseAutocomplete.md +110 -0
- package/docs/form/BaseCheckbox.md +33 -0
- package/docs/form/BaseCheckboxGroup.md +28 -0
- package/docs/form/BaseFieldset.md +24 -0
- package/docs/form/BaseForm.md +89 -0
- package/docs/form/BaseFormField.md +47 -0
- package/docs/form/BaseInput.md +13 -0
- package/docs/form/BaseRadio.md +28 -0
- package/docs/form/BaseRadioGroup.md +35 -0
- package/docs/form/BaseSelect.md +109 -0
- package/docs/form/BaseSlider.md +93 -0
- package/docs/form/BaseSwitch.md +27 -0
- package/docs/form/useFormMessages.md +29 -0
- package/docs/hooks/useRipples.md +26 -0
- package/docs/layout/BaseSeparator.md +24 -0
- package/docs/layout/Container.md +5 -0
- package/docs/menu/BaseContextMenu.md +96 -0
- package/docs/menu/BaseMenu.md +84 -0
- package/docs/menu/BaseMenubar.md +45 -0
- package/docs/menu/createMenuHandle.md +31 -0
- package/docs/navigation/BaseTabs.md +69 -0
- package/docs/overlay/BaseTooltip.md +74 -0
- package/docs/overlay/createTooltipHandle.md +29 -0
- package/docs/page/Pagination.md +37 -0
- package/docs/page/usePagination.md +17 -0
- package/docs/providers/ToastProvider.md +11 -0
- package/docs/providers/TooltipProvider.md +17 -0
- package/docs/table/TableCell.md +16 -0
- package/docs/table/Tdx.md +5 -0
- package/docs/utils/RenderProp.md +5 -0
- package/docs/utils/cn.md +9 -0
- package/docs/utils/mergeProps.md +9 -0
- package/docs/utils/useRender.md +26 -0
- package/package.json +6 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# `BaseTabs`
|
|
2
|
+
|
|
3
|
+
Import from `@omer-x/tailwind-ui-kit/navigation`. See the [README](../../README.md) for setup, theming and the other components.
|
|
4
|
+
|
|
5
|
+
A Base UI [`Tabs`](https://base-ui.com/react/components/tabs): switch between related panels on one page. A tab and its panel share a `value`:
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { BaseTabs } from "@omer-x/tailwind-ui-kit/navigation";
|
|
9
|
+
|
|
10
|
+
<BaseTabs defaultValue="overview">
|
|
11
|
+
<BaseTabs.List className="gap-1">
|
|
12
|
+
<BaseTabs.Tab value="overview" className="rounded-md px-4 py-2 data-active:text-white">Overview</BaseTabs.Tab>
|
|
13
|
+
<BaseTabs.Tab value="details" className="rounded-md px-4 py-2 data-active:text-white">Details</BaseTabs.Tab>
|
|
14
|
+
<BaseTabs.Indicator className="rounded-md bg-blue-600" />
|
|
15
|
+
</BaseTabs.List>
|
|
16
|
+
<BaseTabs.Panel value="overview" className="p-4">The overview.</BaseTabs.Panel>
|
|
17
|
+
<BaseTabs.Panel value="details" className="p-4">The details.</BaseTabs.Panel>
|
|
18
|
+
</BaseTabs>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The parts are reached with dot notation (`BaseTabs.Tab`), which only works in client components. Build tabs in a `"use client"` file, e.g. your app's themed wrapper.
|
|
22
|
+
|
|
23
|
+
| Part | Renders | Description |
|
|
24
|
+
|------|---------|-------------|
|
|
25
|
+
| `BaseTabs` | `<div>` | Groups the list and the panels and holds the active tab. A flex row while vertical |
|
|
26
|
+
| `BaseTabs.List` | `<div role="tablist">` | Groups the tabs. A `relative`, `isolate` flex row (a column while vertical), so the indicator is placed inside it |
|
|
27
|
+
| `BaseTabs.Tab` | `<button role="tab">` | Activates its panel. An `inline-flex` row with a focus outline |
|
|
28
|
+
| `BaseTabs.Indicator` | `<span>` | Optional. Put it inside the list: it covers the active tab, behind the tabs (`-z-10`), and moves with a transition. Make it an underline with `top-auto bottom-0 h-0.5`. Hidden until the active tab is measured |
|
|
29
|
+
| `BaseTabs.Panel` | `<div role="tabpanel">` | The content shown while the tab with the same `value` is active. Focusable, with a focus outline |
|
|
30
|
+
|
|
31
|
+
Every part takes `className` and `render`.
|
|
32
|
+
|
|
33
|
+
`BaseTabs` props:
|
|
34
|
+
|
|
35
|
+
| Prop | Type | Default | Description |
|
|
36
|
+
|------|------|---------|-------------|
|
|
37
|
+
| `value` / `defaultValue` | `Value \| null` | the first enabled tab | Controlled / initial value of the active tab. `null` activates none |
|
|
38
|
+
| `onValueChange` | `(value, event) => void` | | Called with the active tab's value and the DOM event that activated it. Uncontrolled tabs also call it with no event when they pick a tab themselves: at first without `defaultValue`, or when the active tab is disabled or removed (`null` when no enabled tab is left) |
|
|
39
|
+
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | The direction of the list and of the arrow keys |
|
|
40
|
+
| `render` | `RenderProp<"div", TabsState>` | | The state is `{ orientation, tabActivationDirection }` |
|
|
41
|
+
|
|
42
|
+
`BaseTabs.List` props:
|
|
43
|
+
|
|
44
|
+
| Prop | Type | Default | Description |
|
|
45
|
+
|------|------|---------|-------------|
|
|
46
|
+
| `activateOnFocus` | `boolean` | `false` | Activates a tab as soon as the arrow keys focus it. Otherwise <kbd>Enter</kbd> or <kbd>Space</kbd> activates it |
|
|
47
|
+
| `loopFocus` | `boolean` | `true` | Moves focus from the last tab back to the first with the arrow keys (and the other way) |
|
|
48
|
+
| `render` | `RenderProp<"div", TabsState>` | | |
|
|
49
|
+
|
|
50
|
+
`BaseTabs.Tab` props:
|
|
51
|
+
|
|
52
|
+
| Prop | Type | Default | Description |
|
|
53
|
+
|------|------|---------|-------------|
|
|
54
|
+
| `value` | `unknown` | required | Identifies the tab and links it to its panel |
|
|
55
|
+
| `disabled` | `boolean` | `false` | Ignores user interaction. Without `defaultValue`, a disabled first tab isn't picked (set `defaultValue` when you render on the server) |
|
|
56
|
+
| `render` | `RenderProp<"button", TabsTabState>` | | The state adds `active` and `disabled` |
|
|
57
|
+
| `nativeButton` | `boolean` | `true` | Set to `false` when `render` doesn't render a `<button>` |
|
|
58
|
+
|
|
59
|
+
`BaseTabs.Indicator` takes `renderBeforeHydration` (shows it before React hydrates, after server rendering) and `render` (`RenderProp<"span", TabsIndicatorState>`, adding `activeTabPosition` and `activeTabSize`). The active tab's box is in the CSS variables `--active-tab-left`, `--active-tab-right`, `--active-tab-top`, `--active-tab-bottom`, `--active-tab-width` and `--active-tab-height`.
|
|
60
|
+
|
|
61
|
+
`BaseTabs.Panel` props:
|
|
62
|
+
|
|
63
|
+
| Prop | Type | Default | Description |
|
|
64
|
+
|------|------|---------|-------------|
|
|
65
|
+
| `value` | `unknown` | required | Shows the panel while the tab with the same `value` is active |
|
|
66
|
+
| `keepMounted` | `boolean` | `false` | Keeps the panel in the DOM, hidden, while its tab is inactive |
|
|
67
|
+
| `render` | `RenderProp<"div", TabsPanelState>` | | The state adds `hidden` and `transitionStatus` |
|
|
68
|
+
|
|
69
|
+
Data attributes: every part has `data-orientation` and `data-activation-direction` (`left`, `right`, `up`, `down` or `none`: where the active tab moved). The active tab has `data-active`, a disabled one `data-disabled`. Panels have `data-index`, `data-hidden` while inactive (with `keepMounted`), and `data-starting-style` / `data-ending-style` during their transition.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# `BaseTooltip`
|
|
2
|
+
|
|
3
|
+
Import from `@omer-x/tailwind-ui-kit/overlay`. See the [README](../../README.md) for setup, theming and the other components.
|
|
4
|
+
|
|
5
|
+
A Base UI [`Tooltip`](https://base-ui.com/react/components/tooltip): a popup that shows a hint when its trigger is hovered or focused. `Popup` brings its portal and positioner, so a tooltip needs no more than this:
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { BaseTooltip } from "@omer-x/tailwind-ui-kit/overlay";
|
|
9
|
+
|
|
10
|
+
<BaseTooltip>
|
|
11
|
+
<BaseTooltip.Trigger render={<Button />}>Save</BaseTooltip.Trigger>
|
|
12
|
+
<BaseTooltip.Popup className="rounded bg-neutral-900 px-2 py-1 text-xs text-white" sideOffset={8}>
|
|
13
|
+
Saves your changes
|
|
14
|
+
<BaseTooltip.Arrow className="size-2 rotate-45 bg-neutral-900 data-[side=top]:-bottom-1 data-[side=bottom]:-top-1" />
|
|
15
|
+
</BaseTooltip.Popup>
|
|
16
|
+
</BaseTooltip>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The parts use dot notation, so build tooltips in a `"use client"` file. A tooltip is only a visual hint: it isn't announced to screen readers, so keep the trigger's accessible name (text or `aria-label`) meaningful without it.
|
|
20
|
+
|
|
21
|
+
| Part | Renders | Description |
|
|
22
|
+
|------|---------|-------------|
|
|
23
|
+
| `BaseTooltip` | nothing | Groups the parts and holds the open state |
|
|
24
|
+
| `BaseTooltip.Trigger` | `<button>` | Opens the tooltip on hover (after `delay`) or keyboard focus. `data-popup-open` while its tooltip is open, `data-trigger-disabled` when `disabled` |
|
|
25
|
+
| `BaseTooltip.Popup` | `<div>` | The tooltip, portaled and placed against the trigger, with scale and fade transitions (skipped while `data-instant`) |
|
|
26
|
+
| `BaseTooltip.Arrow` | `<div>` | An arrow pointing at the trigger, inside `Popup`. `data-side`, `data-align`, `data-uncentered`. Draw it yourself |
|
|
27
|
+
| `BaseTooltip.Viewport` | `<div>` | Animates the content when one tooltip is opened by several triggers and its content depends on the trigger. `data-activation-direction`, `data-transitioning` |
|
|
28
|
+
| `BaseTooltip.Provider` | nothing | The same component as [`TooltipProvider`](../providers/TooltipProvider.md) |
|
|
29
|
+
|
|
30
|
+
`BaseTooltip` props:
|
|
31
|
+
|
|
32
|
+
| Prop | Type | Default | Description |
|
|
33
|
+
|------|------|---------|-------------|
|
|
34
|
+
| `open` / `defaultOpen` | `boolean` | `false` | Controlled / initial open state |
|
|
35
|
+
| `onOpenChange` | `(open, event) => void` | | Called with the new state and the DOM event that changed it (`undefined` when changed from code) |
|
|
36
|
+
| `onOpenChangeComplete` | `(open) => void` | | Called after the open or close transition ends |
|
|
37
|
+
| `disableHoverablePopup` | `boolean` | `false` | Closes the tooltip as soon as the pointer leaves the trigger, even onto the popup |
|
|
38
|
+
| `trackCursorAxis` | `"none" \| "x" \| "y" \| "both"` | `"none"` | Makes the popup follow the pointer along this axis |
|
|
39
|
+
| `disabled` | `boolean` | `false` | No trigger opens the tooltip |
|
|
40
|
+
| `actionsRef` | `RefObject<TooltipActions>` | | `actionsRef.current?.close()` |
|
|
41
|
+
| `handle` | `TooltipHandle<Payload>` | | Connects triggers outside the tooltip and opens it from code (see below) |
|
|
42
|
+
| `triggerId` / `defaultTriggerId` | `string \| null` | | The trigger a controlled / initially open tooltip belongs to |
|
|
43
|
+
| `children` | `ReactNode \| ({ payload }) => ReactNode` | | The parts, or a function that gets the payload of the trigger that opened the tooltip |
|
|
44
|
+
|
|
45
|
+
`BaseTooltip.Trigger` props:
|
|
46
|
+
|
|
47
|
+
| Prop | Type | Default | Description |
|
|
48
|
+
|------|------|---------|-------------|
|
|
49
|
+
| `delay` | `number` | `600` | The wait before opening on hover, in ms. Overrides `TooltipProvider`'s |
|
|
50
|
+
| `closeDelay` | `number` | `0` | The wait before closing, in ms. Overrides `TooltipProvider`'s |
|
|
51
|
+
| `closeOnClick` | `boolean` | `true` | Closes the tooltip when the trigger is clicked |
|
|
52
|
+
| `disabled` | `boolean` | `false` | Stops this trigger from opening the tooltip. The element stays enabled: to disable the button too, pass `disabled` to the `render` element |
|
|
53
|
+
| `handle` / `payload` | `TooltipHandle<Payload>` / `Payload` | | Connects a trigger outside its `BaseTooltip`, and the payload it passes (see below) |
|
|
54
|
+
| `render` | `RenderProp<"button", TooltipTriggerState>` | | The state is `{ open }`. Use it to render your themed button, or any other element |
|
|
55
|
+
|
|
56
|
+
`BaseTooltip.Popup` props:
|
|
57
|
+
|
|
58
|
+
| Prop | Type | Default | Description |
|
|
59
|
+
|------|------|---------|-------------|
|
|
60
|
+
| `side` / `align` | `TooltipSide` / `TooltipAlign` | `"top"` / `"center"` | Where the popup sits against the trigger (`"top"`, `"bottom"`, `"left"`, `"right"`, `"inline-start"`, `"inline-end"` / `"start"`, `"center"`, `"end"`). It flips when there's no room |
|
|
61
|
+
| `sideOffset` / `alignOffset` | `number \| TooltipOffsetFunction` | | Offsets from the anchor, in pixels, or a function of the placement and sizes |
|
|
62
|
+
| `collisionPadding` | `number \| { top, right, bottom, left }` | `5` | Space kept from the viewport edges |
|
|
63
|
+
| `collisionBoundary` / `collisionAvoidance` | | `"clipping-ancestors"` | The area the popup stays inside, and how it avoids its edges (flip or shift) |
|
|
64
|
+
| `anchor` | `Element \| RefObject \| () => Element \| null` | the trigger | The element the popup is placed against |
|
|
65
|
+
| `disableAnchorTracking` | `boolean` | `false` | Stops following the anchor when it moves |
|
|
66
|
+
| `arrowPadding` | `number` | `5` | Minimum distance between an `Arrow` and the popup's corners |
|
|
67
|
+
| `sticky` | `boolean` | `false` | Stays in view while the anchor scrolls away |
|
|
68
|
+
| `positionMethod` | `"absolute" \| "fixed"` | `"absolute"` | Use `"fixed"` when the anchor is inside a fixed container |
|
|
69
|
+
| `positionerClassName` / `renderPositioner` | `string` / `RenderProp<"div", TooltipPositionerState>` | | Style or replace the positioner, the `<div>` around the popup that places it (`z-50`) |
|
|
70
|
+
| `container` | `HTMLElement \| ShadowRoot \| RefObject \| null` | `<body>` | Where the popup is portaled to |
|
|
71
|
+
| `keepMounted` | `boolean` | `false` | Keeps the popup in the DOM while closed |
|
|
72
|
+
| `render` | `RenderProp<"div", TooltipPopupState>` | | The state is `{ open, side, align, instant }` |
|
|
73
|
+
|
|
74
|
+
Data attributes: the popup has `data-open` / `data-closed`, `data-side`, `data-align` and `data-starting-style` / `data-ending-style` during transitions. `data-instant` is set when the transition should be skipped: `"delay"` (another tooltip was just open), `"focus"` (opened by keyboard focus) or `"dismiss"` (closed by Escape or a click). The popup's own transition is turned off then (`data-instant:transition-none`).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# `createTooltipHandle`
|
|
2
|
+
|
|
3
|
+
Import from `@omer-x/tailwind-ui-kit/overlay`. See the [README](../../README.md) for setup, theming and the other components.
|
|
4
|
+
|
|
5
|
+
Opens one tooltip from triggers anywhere on the page, or from code. Each trigger can pass a `payload`, which the tooltip's function children receive:
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { BaseTooltip, createTooltipHandle } from "@omer-x/tailwind-ui-kit/overlay";
|
|
9
|
+
|
|
10
|
+
const shortcutTooltip = createTooltipHandle<{ id: string, keys: string }>();
|
|
11
|
+
|
|
12
|
+
// triggers anywhere on the page
|
|
13
|
+
<BaseTooltip.Trigger id={`shortcut-${s.id}`} handle={shortcutTooltip} payload={s} render={<Button />}>{s.label}</BaseTooltip.Trigger>
|
|
14
|
+
|
|
15
|
+
// one tooltip on the page
|
|
16
|
+
<BaseTooltip handle={shortcutTooltip}>
|
|
17
|
+
{({ payload }) => payload && (
|
|
18
|
+
<BaseTooltip.Popup>{payload.keys}</BaseTooltip.Popup>
|
|
19
|
+
)}
|
|
20
|
+
</BaseTooltip>
|
|
21
|
+
|
|
22
|
+
// from code
|
|
23
|
+
shortcutTooltip.open("shortcut-copy");
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
A `TooltipHandle<Payload>` has `open(triggerId)`, `close()` and `isOpen`. Like `MenuHandle`, it has no `openWithPayload`: a tooltip is placed against its trigger, so `open` needs the `id` of a trigger with the same handle.
|
|
27
|
+
|
|
28
|
+
- Calls are **ignored while the tooltip isn't mounted**. Keep the `BaseTooltip` with the handle rendered.
|
|
29
|
+
- Call them **from event handlers or effects, never during render**.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# `Pagination`
|
|
2
|
+
|
|
3
|
+
Import from `@omer-x/tailwind-ui-kit/page`. See the [README](../../README.md) for setup, theming and the other components.
|
|
4
|
+
|
|
5
|
+
Pagination inside a `<nav>`. It shows previous/next arrows, the first and last pages, `siblings` pages on each side of the current one, and ellipses for gaps. It only decides which pages to show: **your app builds each link**, so typed routes stay type-safe.
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Description |
|
|
8
|
+
|------|------|-------------|
|
|
9
|
+
| `totalItems` | `number` | Total number of items |
|
|
10
|
+
| `itemsPerPage` | `number` | Items per page |
|
|
11
|
+
| `currentPage` | `number` | Current page, starting at 1 |
|
|
12
|
+
| `siblings` | `number` | Pages shown on each side of the current one. Default `2`. `0` gives `« 1 … [50] … 100 »` |
|
|
13
|
+
| `renderLink` | `(page: number, props: PaginationLinkProps) => ReactElement` | Builds the link to `page`. Spread `props` (`children`, `aria-current="page"` on the current page, `aria-label` on the arrows) onto it. It can also be a `<button onClick>` for pagination without URLs |
|
|
14
|
+
| `renderButton` | render prop | Renders a disabled arrow (a disabled `<button>`) |
|
|
15
|
+
| `renderEllipsis` | render prop | Renders an ellipsis (a `<span aria-hidden>`) |
|
|
16
|
+
| `aria-label` | `string` | The navigation's label. Default `"Pagination"` |
|
|
17
|
+
| `previousLabel` / `nextLabel` | `string` | The arrows' accessible names. Default `"Previous page"` / `"Next page"` |
|
|
18
|
+
| `previousContent` / `nextContent` | `ReactNode` | The arrows' content, e.g. icons. Default `«` / `»` |
|
|
19
|
+
| `className` | `string` | Classes for the `<nav>`. Default `flex gap-3` |
|
|
20
|
+
| …rest | `<nav>` props | |
|
|
21
|
+
|
|
22
|
+
Style the current page with `aria-[current=page]:`.
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { Link } from "@/i18n/navigation";
|
|
26
|
+
|
|
27
|
+
<Pagination
|
|
28
|
+
totalItems={total}
|
|
29
|
+
itemsPerPage={20}
|
|
30
|
+
currentPage={page}
|
|
31
|
+
renderLink={(page, props) => (
|
|
32
|
+
<Link {...props} href={{ pathname: "/products", query: { ...searchParams, page } }} className="px-3 py-1 aria-[current=page]:font-bold" />
|
|
33
|
+
)}
|
|
34
|
+
renderButton={<button className="px-3 py-1 disabled:opacity-50" />}
|
|
35
|
+
renderEllipsis={<span className="px-3 py-1" />}
|
|
36
|
+
/>
|
|
37
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# `usePagination`
|
|
2
|
+
|
|
3
|
+
Import from `@omer-x/tailwind-ui-kit/page`. See the [README](../../README.md) for setup, theming and the other components.
|
|
4
|
+
|
|
5
|
+
The logic behind `Pagination`, for a completely custom layout. It holds no state, so it also works in server components.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
const items = usePagination({ totalItems, itemsPerPage, currentPage, siblings: 1 });
|
|
9
|
+
// [
|
|
10
|
+
// { type: "previous", page: 9, disabled: false },
|
|
11
|
+
// { type: "page", page: 1, current: false },
|
|
12
|
+
// { type: "ellipsis" },
|
|
13
|
+
// { type: "page", page: 10, current: true },
|
|
14
|
+
// …
|
|
15
|
+
// { type: "next", page: 11, disabled: false },
|
|
16
|
+
// ]
|
|
17
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# `ToastProvider`
|
|
2
|
+
|
|
3
|
+
Import from `@omer-x/tailwind-ui-kit/providers`. See the [README](../../README.md) for setup, theming and the other components.
|
|
4
|
+
|
|
5
|
+
Holds the toasts of the app (or a part of it). [`useToast`](../feedback/useToast.md) and [`BaseToast.Viewport`](../feedback/BaseToast.md) work inside it. Renders no element and is also available as `BaseToast.Provider`.
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Default | Description |
|
|
8
|
+
|------|------|---------|-------------|
|
|
9
|
+
| `timeout` | `number` | `5000` | Milliseconds before a toast closes by itself. `0` keeps toasts open until they are closed |
|
|
10
|
+
| `limit` | `number` | `3` | The most toasts shown at once. Older ones get `data-limited`, and the kit hides them |
|
|
11
|
+
| `manager` | `ToastManager` | | Shows the toasts of a [`createToastManager`](../feedback/createToastManager.md) manager |
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# `TooltipProvider`
|
|
2
|
+
|
|
3
|
+
Import from `@omer-x/tailwind-ui-kit/providers`. See the [README](../../README.md) for setup, theming and the other components.
|
|
4
|
+
|
|
5
|
+
Shares the hover delay between the tooltips inside it: once one tooltip is shown, the next one opens instantly. Place it once around your app (or a toolbar) in a `"use client"` file. It renders no element and is also available as `BaseTooltip.Provider`.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { TooltipProvider } from "@omer-x/tailwind-ui-kit/providers";
|
|
9
|
+
|
|
10
|
+
<TooltipProvider delay={300}>{children}</TooltipProvider>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
|------|------|---------|-------------|
|
|
15
|
+
| `delay` | `number` | `600` | The wait before opening a tooltip on hover, in ms. A trigger's own `delay` wins |
|
|
16
|
+
| `closeDelay` | `number` | `0` | The wait before closing a tooltip, in ms. A trigger's own `closeDelay` wins |
|
|
17
|
+
| `timeout` | `number` | `400` | A tooltip opened within this time after another one closed opens without a delay, in ms |
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# `TableCell`
|
|
2
|
+
|
|
3
|
+
Import from `@omer-x/tailwind-ui-kit/table`. See the [README](../../README.md) for setup, theming and the other components.
|
|
4
|
+
|
|
5
|
+
A `<td>` that accepts all `<td>` props (`colSpan`, `rowSpan`, `title`, event handlers, …).
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Description |
|
|
8
|
+
|------|------|-------------|
|
|
9
|
+
| `overflow` | `"wrap" \| "truncate"` | `"wrap"` (default) is a normal `<td>`. `"truncate"` keeps the content on one line and cuts it with an ellipsis instead of widening the column. Exposed as `data-overflow`. |
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
<tr>
|
|
13
|
+
<TableCell overflow="truncate" className="max-w-48">{product.description}</TableCell>
|
|
14
|
+
<TableCell overflow={expanded ? "wrap" : "truncate"}>{product.notes}</TableCell>
|
|
15
|
+
</tr>
|
|
16
|
+
```
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# `RenderProp`
|
|
2
|
+
|
|
3
|
+
Import from `@omer-x/tailwind-ui-kit/utils`. See the [README](../../README.md) for setup, theming and the other components.
|
|
4
|
+
|
|
5
|
+
The type of every `render` and `render*` prop: `RenderProp<Tag, State>` is an element, or a function `(props, state) => ReactElement`. `props` are the props of `Tag` (spread them onto your element) and `state` is the component's state (`object` when it has none).
|
package/docs/utils/cn.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# `cn` (deprecated)
|
|
2
|
+
|
|
3
|
+
Import from `@omer-x/tailwind-ui-kit/utils`. See the [README](../../README.md) for setup, theming and the other components.
|
|
4
|
+
|
|
5
|
+
Kept for backward compatibility. Import from the [`cn`](https://www.npmjs.com/package/cn) package directly instead:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { cn } from "cn";
|
|
9
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# `mergeProps`
|
|
2
|
+
|
|
3
|
+
Import from `@omer-x/tailwind-ui-kit/utils`. See the [README](../../README.md) for setup, theming and the other components.
|
|
4
|
+
|
|
5
|
+
Merges props for one element, later ones winning. Event handlers are all called (later ones first), `className`s are joined and `style`s are merged. `ref` is not merged.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
useRender({ defaultTagName: "div", render, props: mergeProps<"div">({ className: "p-4", onClick: track }, props) });
|
|
9
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# `useRender`
|
|
2
|
+
|
|
3
|
+
Import from `@omer-x/tailwind-ui-kit/utils`. See the [README](../../README.md) for setup, theming and the other components.
|
|
4
|
+
|
|
5
|
+
Renders an element that can be replaced through a `render` prop, with your props merged into it.
|
|
6
|
+
|
|
7
|
+
| Option | Type | Description |
|
|
8
|
+
|--------|------|-------------|
|
|
9
|
+
| `defaultTagName` | `keyof JSX.IntrinsicElements` | The element rendered when `render` is missing |
|
|
10
|
+
| `render` | `RenderProp<Tag, State>` | The `render` prop of your component |
|
|
11
|
+
| `props` | props of `Tag` | Merged into the rendered element |
|
|
12
|
+
| `state` | `State` | Passed to a `render` function, and set as data attributes (`{ active: true }` becomes `data-active`) |
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { type RenderProp, useRender } from "@omer-x/tailwind-ui-kit/utils";
|
|
16
|
+
|
|
17
|
+
type BadgeProps = ComponentProps<"span"> & {
|
|
18
|
+
render?: RenderProp<"span">,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const Badge = ({ render, className, ...props }: BadgeProps) => useRender({
|
|
22
|
+
defaultTagName: "span",
|
|
23
|
+
render,
|
|
24
|
+
props: { ...props, className: cn("rounded px-2 text-xs", className) },
|
|
25
|
+
});
|
|
26
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omer-x/tailwind-ui-kit",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.46",
|
|
4
4
|
"description": "Tailwind CSS-based React component library for building user interfaces",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tailwind",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"types": "./typescript-badge.d.ts",
|
|
30
30
|
"files": [
|
|
31
31
|
"dist/",
|
|
32
|
+
"docs/",
|
|
32
33
|
"MIGRATION.md",
|
|
33
34
|
"typescript-badge.d.ts"
|
|
34
35
|
],
|
|
@@ -50,6 +51,10 @@
|
|
|
50
51
|
"types": "./dist/components/menu/index.d.ts",
|
|
51
52
|
"import": "./dist/components/menu/index.js"
|
|
52
53
|
},
|
|
54
|
+
"./navigation": {
|
|
55
|
+
"types": "./dist/components/navigation/index.d.ts",
|
|
56
|
+
"import": "./dist/components/navigation/index.js"
|
|
57
|
+
},
|
|
53
58
|
"./disclosure": {
|
|
54
59
|
"types": "./dist/components/disclosure/index.d.ts",
|
|
55
60
|
"import": "./dist/components/disclosure/index.js"
|