@omer-x/tailwind-ui-kit 1.0.0-alpha.34 → 1.0.0-alpha.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -212,6 +212,29 @@ With `BaseForm`'s `onlyDirty`, give the group an array default (`defaultValues={
|
|
|
212
212
|
</BaseCheckboxGroup>
|
|
213
213
|
```
|
|
214
214
|
|
|
215
|
+
#### `BaseFieldset`
|
|
216
|
+
|
|
217
|
+
A Base UI [`Fieldset`](https://base-ui.com/react/components/fieldset): a native `<fieldset>` that groups related controls under a stylable legend. The legend is linked to the fieldset (`aria-labelledby`), so screen readers announce it as the group's name.
|
|
218
|
+
|
|
219
|
+
| Prop | Type | Default | Description |
|
|
220
|
+
|------|------|---------|-------------|
|
|
221
|
+
| `legend` | `ReactNode` | | The caption, rendered before the children. Without it, no legend is rendered |
|
|
222
|
+
| `legendClassName` | `string` | | Classes for the legend `<div>` (default `font-semibold`) |
|
|
223
|
+
| `renderLegend` | `RenderProp<"div", FieldsetState>` | | Render another element for the legend (e.g. a heading) |
|
|
224
|
+
| `disabled` | `boolean` | | Disables every control inside, `BaseFormField`s included |
|
|
225
|
+
| `className` | `string` | | Classes for the `<fieldset>` (default `flex min-w-0 flex-col gap-3`) |
|
|
226
|
+
| `render` | `RenderProp<"fieldset", FieldsetState>` | | Render another element for the fieldset |
|
|
227
|
+
| …rest | | | `<fieldset>` props |
|
|
228
|
+
|
|
229
|
+
Render functions get `FieldsetState`: `{ disabled }`. The fieldset and the legend set `data-disabled` when disabled.
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
<BaseFieldset legend="Billing address" className="rounded border p-4" legendClassName="border-b pb-2">
|
|
233
|
+
<BaseFormField name="street" label="Street" schema={Schema.shape.street} />
|
|
234
|
+
<BaseFormField name="city" label="City" schema={Schema.shape.city} />
|
|
235
|
+
</BaseFieldset>
|
|
236
|
+
```
|
|
237
|
+
|
|
215
238
|
#### `BaseForm`
|
|
216
239
|
|
|
217
240
|
A Base UI [`Form`](https://base-ui.com/react/components/form) connected to an action through React's `useActionState`. Actions are made with [`@omer-x/next-form-actions`](https://github.com/omermecitoglu/next-form-actions) (v2), which defines the result shape. Install it next to the kit:
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
export type FieldsetState = {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
};
|
|
6
|
+
type BaseFieldsetProps = ComponentProps<"fieldset"> & {
|
|
7
|
+
render?: RenderProp<"fieldset", FieldsetState>;
|
|
8
|
+
/** The fieldset's caption, rendered before the children. It labels the fieldset for assistive technology. */
|
|
9
|
+
legend?: ReactNode;
|
|
10
|
+
/** Classes for the legend. */
|
|
11
|
+
legendClassName?: string;
|
|
12
|
+
/** Render another element for the legend. It stays linked to the fieldset through `aria-labelledby`. */
|
|
13
|
+
renderLegend?: RenderProp<"div", FieldsetState>;
|
|
14
|
+
/** Disables every control inside, including the ones in a `BaseFormField`. */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A `<fieldset>` that groups related controls under a stylable legend.
|
|
19
|
+
*/
|
|
20
|
+
declare const BaseFieldset: ({ legend, legendClassName, renderLegend, className, children, ...otherProps }: BaseFieldsetProps) => import("react").JSX.Element;
|
|
21
|
+
export { BaseFieldset as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fieldset } from "@base-ui/react/fieldset";
|
|
3
|
+
import { cn } from "cn";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/components/form/BaseFieldset.tsx
|
|
6
|
+
/**
|
|
7
|
+
* A `<fieldset>` that groups related controls under a stylable legend.
|
|
8
|
+
*/
|
|
9
|
+
const BaseFieldset = ({ legend, legendClassName, renderLegend, className, children, ...otherProps }) => /* @__PURE__ */ jsxs(Fieldset.Root, {
|
|
10
|
+
...otherProps,
|
|
11
|
+
className: cn("flex min-w-0 flex-col gap-3", className),
|
|
12
|
+
children: [typeof legend !== "undefined" && /* @__PURE__ */ jsx(Fieldset.Legend, {
|
|
13
|
+
render: renderLegend,
|
|
14
|
+
className: cn("font-semibold", legendClassName),
|
|
15
|
+
children: legend
|
|
16
|
+
}), children]
|
|
17
|
+
});
|
|
18
|
+
export { BaseFieldset as default };
|
|
@@ -15,4 +15,5 @@ import { AutocompleteListState } from "./BaseAutocompleteList.js";
|
|
|
15
15
|
import { AutocompleteArrowState, AutocompleteBackdropState, AutocompleteCollisionAvoidance, AutocompleteFocusTarget, AutocompleteOffsetFunction, AutocompletePopupState, AutocompletePositionerState } from "./BaseAutocompletePopup.js";
|
|
16
16
|
import { AutocompleteSeparatorState } from "./BaseAutocompleteSeparator.js";
|
|
17
17
|
import { InputSize } from "./inputSizes.js";
|
|
18
|
-
|
|
18
|
+
import BaseFieldset, { FieldsetState } from "./BaseFieldset.js";
|
|
19
|
+
export { type AutocompleteActions, type AutocompleteAlign, type AutocompleteArrowState, type AutocompleteBackdropState, type AutocompleteClearState, type AutocompleteCollisionAvoidance, type AutocompleteFilter, type AutocompleteFocusTarget, type AutocompleteHighlightReason, type AutocompleteInputState, type AutocompleteInteractionType, type AutocompleteItemGroup, type AutocompleteItemState, type AutocompleteListState, type AutocompleteOffsetFunction, type AutocompletePopupState, type AutocompletePositionerState, type AutocompleteSeparatorState, type AutocompleteSide, _default as BaseAutocomplete, BaseCheckbox, BaseCheckboxGroup, BaseFieldset, BaseForm, BaseFormField, BaseInput, BaseSwitch, type CheckboxGroupState, type CheckboxState, type DisplayedFormMessage, type FieldConstraints, type FieldState, type FieldsetState, type InputSize, type MessageFormatter, type SwitchState, type UseAutocompleteFilterOptions, useAutocompleteFilter, useFormMessages };
|
|
@@ -7,4 +7,5 @@ import BaseFormField from "./BaseFormField.js";
|
|
|
7
7
|
import useFormMessages from "./useFormMessages.js";
|
|
8
8
|
import BaseAutocomplete_default from "./BaseAutocomplete.js";
|
|
9
9
|
import useAutocompleteFilter from "./useAutocompleteFilter.js";
|
|
10
|
-
|
|
10
|
+
import BaseFieldset from "./BaseFieldset.js";
|
|
11
|
+
export { BaseAutocomplete_default as BaseAutocomplete, BaseCheckbox, BaseCheckboxGroup, BaseFieldset, BaseForm, BaseFormField, BaseInput, BaseSwitch, useAutocompleteFilter, useFormMessages };
|