@omer-x/tailwind-ui-kit 1.0.0-alpha.4 → 1.0.0-alpha.41
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 +1548 -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/BaseSelect.d.ts +165 -0
- package/dist/components/form/BaseSelect.js +41 -0
- package/dist/components/form/BaseSelectGroup.d.ts +8 -0
- package/dist/components/form/BaseSelectGroup.js +7 -0
- package/dist/components/form/BaseSelectGroupLabel.d.ts +8 -0
- package/dist/components/form/BaseSelectGroupLabel.js +7 -0
- package/dist/components/form/BaseSelectIcon.d.ts +14 -0
- package/dist/components/form/BaseSelectIcon.js +10 -0
- package/dist/components/form/BaseSelectItem.d.ts +24 -0
- package/dist/components/form/BaseSelectItem.js +14 -0
- package/dist/components/form/BaseSelectItemIndicator.d.ts +16 -0
- package/dist/components/form/BaseSelectItemIndicator.js +10 -0
- package/dist/components/form/BaseSelectItemText.d.ts +8 -0
- package/dist/components/form/BaseSelectItemText.js +7 -0
- package/dist/components/form/BaseSelectLabel.d.ts +12 -0
- package/dist/components/form/BaseSelectLabel.js +10 -0
- package/dist/components/form/BaseSelectList.d.ts +8 -0
- package/dist/components/form/BaseSelectList.js +11 -0
- package/dist/components/form/BaseSelectPopup.d.ts +90 -0
- package/dist/components/form/BaseSelectPopup.js +45 -0
- package/dist/components/form/BaseSelectScrollDownArrow.d.ts +15 -0
- package/dist/components/form/BaseSelectScrollDownArrow.js +17 -0
- package/dist/components/form/BaseSelectScrollUpArrow.d.ts +15 -0
- package/dist/components/form/BaseSelectScrollUpArrow.js +17 -0
- package/dist/components/form/BaseSelectSeparator.d.ts +16 -0
- package/dist/components/form/BaseSelectSeparator.js +10 -0
- package/dist/components/form/BaseSelectTrigger.d.ts +17 -0
- package/dist/components/form/BaseSelectTrigger.js +15 -0
- package/dist/components/form/BaseSelectValue.d.ts +21 -0
- package/dist/components/form/BaseSelectValue.js +11 -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 +29 -0
- package/dist/components/form/index.js +14 -0
- package/dist/components/form/inputSizes.d.ts +11 -0
- package/dist/components/form/inputSizes.js +19 -0
- package/dist/components/form/selectTypes.d.ts +27 -0
- package/dist/components/form/selectTypes.js +1 -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
|
+
"use client";
|
|
2
|
+
import { CheckboxGroup } from "@base-ui/react/checkbox-group";
|
|
3
|
+
import { Field } from "@base-ui/react/field";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/components/form/BaseCheckboxGroup.tsx
|
|
7
|
+
const BaseCheckboxGroup = ({ name, onValueChange, className, ...otherProps }) => {
|
|
8
|
+
const group = /* @__PURE__ */ jsx(CheckboxGroup, {
|
|
9
|
+
...otherProps,
|
|
10
|
+
onValueChange: onValueChange && ((value, details) => onValueChange(value, details.event)),
|
|
11
|
+
className: cn("flex flex-col gap-2", className)
|
|
12
|
+
});
|
|
13
|
+
if (!name) return group;
|
|
14
|
+
return /* @__PURE__ */ jsx(Field.Root, {
|
|
15
|
+
name,
|
|
16
|
+
className: "contents",
|
|
17
|
+
children: group
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
export { BaseCheckboxGroup as default };
|
|
@@ -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 };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import { MessageFormatter } from "./FormContext.js";
|
|
3
|
+
import { FormAction, FormActionState } from "@omer-x/next-form-actions";
|
|
4
|
+
type BaseFormProps<Data> = Omit<ComponentPropsWithoutRef<"form">, "action"> & {
|
|
5
|
+
action: FormAction<Data>;
|
|
6
|
+
formatMessage?: MessageFormatter;
|
|
7
|
+
defaultValues?: Record<string, unknown>;
|
|
8
|
+
onlyDirty?: boolean;
|
|
9
|
+
resetOnSuccess?: boolean;
|
|
10
|
+
onResult?: (result: FormActionState<Data>) => void;
|
|
11
|
+
};
|
|
12
|
+
declare const BaseForm: <Data>({ action, formatMessage, defaultValues, onlyDirty, resetOnSuccess, onResult, onSubmit, children, ...otherProps }: BaseFormProps<Data>) => import("react").JSX.Element;
|
|
13
|
+
export { BaseForm as default };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Form } from "@base-ui/react/form";
|
|
3
|
+
import { Fragment, startTransition, useActionState, useRef } from "react";
|
|
4
|
+
import { getDirtyFormData } from "../../utils/dirty-form.js";
|
|
5
|
+
import { FormContext } from "./FormContext.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// src/components/form/BaseForm.tsx
|
|
8
|
+
const INITIAL_STATE = {
|
|
9
|
+
result: { status: "idle" },
|
|
10
|
+
submissionId: 0,
|
|
11
|
+
resetCount: 0
|
|
12
|
+
};
|
|
13
|
+
const NO_FIELD_ERRORS = {};
|
|
14
|
+
const formatAsIs = (code) => code;
|
|
15
|
+
const BaseForm = ({ action, formatMessage = formatAsIs, defaultValues = {}, onlyDirty = false, resetOnSuccess = false, onResult, onSubmit, children, ...otherProps }) => {
|
|
16
|
+
const submit = async (previous, formData) => {
|
|
17
|
+
const result = await action(previous.result, formData);
|
|
18
|
+
onResult?.(result);
|
|
19
|
+
return {
|
|
20
|
+
result,
|
|
21
|
+
submissionId: previous.submissionId + 1,
|
|
22
|
+
resetCount: resetOnSuccess && result.status === "success" ? previous.resetCount + 1 : previous.resetCount
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const [{ result: state, submissionId, resetCount }, formAction, pending] = useActionState(submit, INITIAL_STATE);
|
|
26
|
+
const fieldsRef = useRef(/* @__PURE__ */ new Set());
|
|
27
|
+
const registerField = (fieldName) => {
|
|
28
|
+
fieldsRef.current.add(fieldName);
|
|
29
|
+
};
|
|
30
|
+
const unregisterField = (fieldName) => {
|
|
31
|
+
fieldsRef.current.delete(fieldName);
|
|
32
|
+
};
|
|
33
|
+
const fieldErrors = state.status === "failure" ? state.fieldErrors : NO_FIELD_ERRORS;
|
|
34
|
+
const mountedFieldErrors = {};
|
|
35
|
+
const messages = [];
|
|
36
|
+
if (state.status === "failure" && state.message) messages.push({
|
|
37
|
+
key: "message",
|
|
38
|
+
type: state.message.type,
|
|
39
|
+
text: formatMessage(state.message.text)
|
|
40
|
+
});
|
|
41
|
+
for (const [fieldName, errors] of Object.entries(fieldErrors)) {
|
|
42
|
+
const texts = errors.map((error) => formatMessage(error.code, error.params));
|
|
43
|
+
if (fieldsRef.current.has(fieldName)) mountedFieldErrors[fieldName] = texts;
|
|
44
|
+
else texts.forEach((text, index) => {
|
|
45
|
+
messages.push({
|
|
46
|
+
key: `field:${fieldName}:${index}`,
|
|
47
|
+
type: "error",
|
|
48
|
+
text
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return /* @__PURE__ */ jsx(Form, {
|
|
53
|
+
...otherProps,
|
|
54
|
+
errors: mountedFieldErrors,
|
|
55
|
+
onSubmit: (e) => {
|
|
56
|
+
e.stopPropagation();
|
|
57
|
+
onSubmit?.(e);
|
|
58
|
+
if (e.defaultPrevented) return;
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
const form = e.currentTarget;
|
|
61
|
+
const formData = onlyDirty ? getDirtyFormData(form, defaultValues) : new FormData(form, e.nativeEvent.submitter);
|
|
62
|
+
startTransition(() => formAction(formData));
|
|
63
|
+
},
|
|
64
|
+
children: /* @__PURE__ */ jsx(FormContext, {
|
|
65
|
+
value: {
|
|
66
|
+
fieldErrors,
|
|
67
|
+
messages,
|
|
68
|
+
submissionId,
|
|
69
|
+
formatMessage,
|
|
70
|
+
pending,
|
|
71
|
+
registerField,
|
|
72
|
+
unregisterField
|
|
73
|
+
},
|
|
74
|
+
children: /* @__PURE__ */ jsx(Fragment, { children }, resetCount)
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
export { BaseForm as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
import { ZodType } from "zod";
|
|
4
|
+
export type FieldState = {
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
/** The control has lost focus at least once. */
|
|
7
|
+
touched: boolean;
|
|
8
|
+
/** The value differs from the initial one. */
|
|
9
|
+
dirty: boolean;
|
|
10
|
+
/** `null` until the field is validated. */
|
|
11
|
+
valid: boolean | null;
|
|
12
|
+
filled: boolean;
|
|
13
|
+
focused: boolean;
|
|
14
|
+
};
|
|
15
|
+
/** The native constraints read from the field's schema. */
|
|
16
|
+
export type FieldConstraints = Pick<ComponentProps<"input">, "type" | "required" | "minLength" | "maxLength" | "min" | "max">;
|
|
17
|
+
type BaseFormFieldProps = {
|
|
18
|
+
schema: ZodType;
|
|
19
|
+
name: string;
|
|
20
|
+
label?: string;
|
|
21
|
+
control?: RenderProp<"input", FieldState>;
|
|
22
|
+
/**
|
|
23
|
+
* Renders a control that isn't a single `<input>` (e.g. `BaseAutocomplete`) instead of `control`.
|
|
24
|
+
* Gets the constraints read from `schema`; pass on the ones the control supports.
|
|
25
|
+
* The control takes the field's `name` by itself.
|
|
26
|
+
*/
|
|
27
|
+
children?: (constraints: FieldConstraints) => ReactNode;
|
|
28
|
+
renderLabel?: RenderProp<"label", FieldState>;
|
|
29
|
+
renderErrors?: RenderProp<"div", FieldState>;
|
|
30
|
+
className?: string;
|
|
31
|
+
};
|
|
32
|
+
declare const BaseFormField: ({ schema, name, label, control, children, renderLabel, renderErrors, className }: BaseFormFieldProps) => import("react").JSX.Element;
|
|
33
|
+
export { BaseFormField as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Field } from "@base-ui/react/field";
|
|
3
|
+
import { getFieldConstraints } from "@omer-x/zod-to-form-constraints";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
import ClientSideError from "./ClientSideError.js";
|
|
6
|
+
import FieldRoot from "./FieldRoot.js";
|
|
7
|
+
import ServerSideError from "./ServerSideError.js";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
// src/components/form/BaseFormField.tsx
|
|
10
|
+
const BaseFormField = ({ schema, name, label, control, children, renderLabel, renderErrors, className }) => /* @__PURE__ */ jsxs(FieldRoot, {
|
|
11
|
+
name,
|
|
12
|
+
className: cn("flex w-full flex-col items-start gap-1", className),
|
|
13
|
+
children: [
|
|
14
|
+
typeof label !== "undefined" && /* @__PURE__ */ jsx(Field.Label, {
|
|
15
|
+
render: renderLabel,
|
|
16
|
+
children: label
|
|
17
|
+
}),
|
|
18
|
+
children ? children(getFieldConstraints(schema)) : /* @__PURE__ */ jsx(Field.Control, {
|
|
19
|
+
name,
|
|
20
|
+
render: control,
|
|
21
|
+
...getFieldConstraints(schema)
|
|
22
|
+
}),
|
|
23
|
+
/* @__PURE__ */ jsx(ClientSideError, {
|
|
24
|
+
schema,
|
|
25
|
+
render: renderErrors
|
|
26
|
+
}),
|
|
27
|
+
/* @__PURE__ */ jsx(ServerSideError, {
|
|
28
|
+
name,
|
|
29
|
+
render: renderErrors
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
export { BaseFormField as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import JustInput from "../elements/JustInput.js";
|
|
3
|
+
import { InputSize } from "./inputSizes.js";
|
|
4
|
+
type BaseInputProps = Omit<ComponentProps<typeof JustInput>, "size"> & {
|
|
5
|
+
size?: InputSize;
|
|
6
|
+
};
|
|
7
|
+
declare const BaseInput: ({ size, className, ...otherProps }: BaseInputProps) => import("react").JSX.Element;
|
|
8
|
+
export { BaseInput as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "cn";
|
|
3
|
+
import "react";
|
|
4
|
+
import JustInput from "../elements/JustInput.js";
|
|
5
|
+
import { inputBaseClasses, inputSizeClasses } from "./inputSizes.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// src/components/form/BaseInput.tsx
|
|
8
|
+
const BaseInput = ({ size = "md", className, ...otherProps }) => /* @__PURE__ */ jsx(JustInput, {
|
|
9
|
+
...otherProps,
|
|
10
|
+
className: cn(inputSizeClasses(size), inputBaseClasses, className)
|
|
11
|
+
});
|
|
12
|
+
export { BaseInput as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps, ReactNode, Ref } from "react";
|
|
3
|
+
export type RadioState = {
|
|
4
|
+
checked: boolean;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
readOnly: boolean;
|
|
7
|
+
required: boolean;
|
|
8
|
+
};
|
|
9
|
+
type BaseRadioProps = Omit<ComponentProps<"span">, "onChange" | "defaultValue"> & {
|
|
10
|
+
label: ReactNode;
|
|
11
|
+
/** Submitted under the group's `name` when this radio is selected. */
|
|
12
|
+
value: string;
|
|
13
|
+
render?: RenderProp<"span", RadioState>;
|
|
14
|
+
/** Classes for the `<label>` around the radio and its text. */
|
|
15
|
+
labelClassName?: string;
|
|
16
|
+
/** Shown inside the radio when selected, e.g. a dot. */
|
|
17
|
+
icon?: ReactNode;
|
|
18
|
+
renderIndicator?: RenderProp<"span", RadioState>;
|
|
19
|
+
/** Keep the indicator in the DOM when not selected, e.g. to animate it out with CSS. */
|
|
20
|
+
keepIndicatorMounted?: boolean;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
readOnly?: boolean;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
/** A ref to the hidden `<input>` of this radio. */
|
|
25
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
26
|
+
/** Set to `true` when `render` renders a `<button>`. */
|
|
27
|
+
nativeButton?: boolean;
|
|
28
|
+
};
|
|
29
|
+
declare const BaseRadio: ({ label, labelClassName, icon, renderIndicator, keepIndicatorMounted, className, ...otherProps }: BaseRadioProps) => import("react").JSX.Element;
|
|
30
|
+
export { BaseRadio as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Field } from "@base-ui/react/field";
|
|
3
|
+
import { Radio } from "@base-ui/react/radio";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/components/form/BaseRadio.tsx
|
|
7
|
+
const BaseRadio = ({ label, labelClassName, icon, renderIndicator, keepIndicatorMounted, className, ...otherProps }) => /* @__PURE__ */ jsxs(Field.Item, {
|
|
8
|
+
disabled: otherProps.disabled,
|
|
9
|
+
render: /* @__PURE__ */ jsx("label", {}),
|
|
10
|
+
className: cn("flex items-center gap-2 text-sm font-normal", labelClassName),
|
|
11
|
+
children: [/* @__PURE__ */ jsx(Radio.Root, {
|
|
12
|
+
...otherProps,
|
|
13
|
+
className: cn("flex", "size-4", "shrink-0", "items-center", "justify-center", "rounded-full", "transition-colors", "duration-150", "ease-[ease]", "focus-visible:outline-2", "focus-visible:outline-offset-2", className),
|
|
14
|
+
children: /* @__PURE__ */ jsx(Radio.Indicator, {
|
|
15
|
+
keepMounted: keepIndicatorMounted,
|
|
16
|
+
className: "flex size-full items-center justify-center",
|
|
17
|
+
render: renderIndicator,
|
|
18
|
+
children: icon
|
|
19
|
+
})
|
|
20
|
+
}), label]
|
|
21
|
+
});
|
|
22
|
+
export { BaseRadio as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ComponentProps, Ref } from "react";
|
|
2
|
+
import { RenderProp } from "../../utils/render.js";
|
|
3
|
+
export type RadioGroupState = {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
readOnly: boolean;
|
|
6
|
+
required: boolean;
|
|
7
|
+
};
|
|
8
|
+
type BaseRadioGroupProps = Omit<ComponentProps<"div">, "onChange" | "defaultValue"> & {
|
|
9
|
+
render?: RenderProp<"div", RadioGroupState>;
|
|
10
|
+
/** Submitted name of the group. The selected radio's `value` is sent under it. */
|
|
11
|
+
name?: string;
|
|
12
|
+
/** The `value` of the selected radio, when controlled. */
|
|
13
|
+
value?: string;
|
|
14
|
+
/** The `value` of the radio selected at first. */
|
|
15
|
+
defaultValue?: string;
|
|
16
|
+
/** Called with the selected radio's `value` and the DOM event that changed it. */
|
|
17
|
+
onValueChange?: (value: string, event: Event) => void;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
readOnly?: boolean;
|
|
20
|
+
/** The user must select a radio before the form submits. */
|
|
21
|
+
required?: boolean;
|
|
22
|
+
/** The `id` of a `<form>` to submit with, when the group isn't inside it. */
|
|
23
|
+
form?: string;
|
|
24
|
+
/** A ref to the hidden `<input>` of the selected (or first enabled) radio. */
|
|
25
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
26
|
+
};
|
|
27
|
+
declare const BaseRadioGroup: ({ onValueChange, className, ...otherProps }: BaseRadioGroupProps) => import("react").JSX.Element;
|
|
28
|
+
export { BaseRadioGroup as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Field } from "@base-ui/react/field";
|
|
3
|
+
import { RadioGroup } from "@base-ui/react/radio-group";
|
|
4
|
+
import { cn } from "cn";
|
|
5
|
+
import { use } from "react";
|
|
6
|
+
import { InsideFieldContext } from "./InsideFieldContext.js";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
// src/components/form/BaseRadioGroup.tsx
|
|
9
|
+
const BaseRadioGroup = ({ onValueChange, className, ...otherProps }) => {
|
|
10
|
+
const group = /* @__PURE__ */ jsx(RadioGroup, {
|
|
11
|
+
...otherProps,
|
|
12
|
+
onValueChange: onValueChange && ((value, details) => onValueChange(value, details.event)),
|
|
13
|
+
className: cn("flex flex-col gap-2", className)
|
|
14
|
+
});
|
|
15
|
+
if (use(InsideFieldContext)) return group;
|
|
16
|
+
return /* @__PURE__ */ jsx(Field.Root, {
|
|
17
|
+
className: "contents",
|
|
18
|
+
children: group
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
export { BaseRadioGroup as default };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { FieldState } from "./BaseFormField.js";
|
|
3
|
+
import "../../utils/index.js";
|
|
4
|
+
import { InputSize } from "./inputSizes.js";
|
|
5
|
+
import { SelectAlign, SelectScrollArrowState, SelectSide, SelectTriggerState } from "./selectTypes.js";
|
|
6
|
+
import { SelectValueState } from "./BaseSelectValue.js";
|
|
7
|
+
import { SelectIconState } from "./BaseSelectIcon.js";
|
|
8
|
+
import { SelectArrowState, SelectBackdropState, SelectCollisionAvoidance, SelectFocusTarget, SelectOffsetFunction, SelectPopupState, SelectPositionerState } from "./BaseSelectPopup.js";
|
|
9
|
+
import { SelectItemState } from "./BaseSelectItem.js";
|
|
10
|
+
import { SelectItemIndicatorState } from "./BaseSelectItemIndicator.js";
|
|
11
|
+
import { SelectSeparatorState } from "./BaseSelectSeparator.js";
|
|
12
|
+
import { ReactNode, Ref, RefObject } from "react";
|
|
13
|
+
/** An item in `items`: its value and the label shown for it. */
|
|
14
|
+
export type SelectLabeledItem<Value = unknown> = {
|
|
15
|
+
value: Value;
|
|
16
|
+
label: ReactNode;
|
|
17
|
+
};
|
|
18
|
+
/** A group of items in `items`: any object with an `items` array, e.g. `{ label: "Fruits", items: [...] }`. */
|
|
19
|
+
export type SelectItemGroup<Item = SelectLabeledItem> = {
|
|
20
|
+
items: readonly Item[];
|
|
21
|
+
};
|
|
22
|
+
/** Imperative actions, through `actionsRef`. */
|
|
23
|
+
export type SelectActions = {
|
|
24
|
+
/** Closes the popup. */
|
|
25
|
+
close: () => void;
|
|
26
|
+
};
|
|
27
|
+
type SelectInputValue<Value, Multiple extends boolean | undefined> = Multiple extends true ? readonly Value[] : Value;
|
|
28
|
+
type SelectOutputValue<Value, Multiple extends boolean | undefined> = Multiple extends true ? Value[] : Value | null;
|
|
29
|
+
type BaseSelectProps<Value, Multiple extends boolean | undefined = false> = {
|
|
30
|
+
/** Lets the user select several items. The value is then an array. */
|
|
31
|
+
multiple?: Multiple;
|
|
32
|
+
/** The selected value, controlled. `null` selects nothing. */
|
|
33
|
+
value?: SelectInputValue<Value, Multiple> | null;
|
|
34
|
+
/** The initially selected value, uncontrolled. */
|
|
35
|
+
defaultValue?: SelectInputValue<Value, Multiple> | null;
|
|
36
|
+
/** Called with the new value and the DOM event that changed it (none when it was changed from code). */
|
|
37
|
+
onValueChange?: (value: SelectOutputValue<Value, Multiple>, event: Event | undefined) => void;
|
|
38
|
+
/**
|
|
39
|
+
* The items' labels, so `Value` can show the selected item's label instead of its value before the popup
|
|
40
|
+
* has ever opened. A `{ value: label }` record, `{ value, label }` objects, or groups of them.
|
|
41
|
+
*/
|
|
42
|
+
items?: Record<string, ReactNode> | readonly SelectLabeledItem[] | readonly SelectItemGroup[];
|
|
43
|
+
/** Turns an object value into the text shown by `Value`. `{ value, label }` objects use their `label` without it. */
|
|
44
|
+
itemToStringLabel?: (value: Value) => string;
|
|
45
|
+
/** Turns an object value into the text submitted with the form. `{ value, label }` objects use their `value` without it. */
|
|
46
|
+
itemToStringValue?: (value: Value) => string;
|
|
47
|
+
/** Decides whether an item's value is the selected one, e.g. for objects compared by id. Defaults to `Object.is`. */
|
|
48
|
+
isItemEqualToValue?: (itemValue: Value, value: Value) => boolean;
|
|
49
|
+
open?: boolean;
|
|
50
|
+
defaultOpen?: boolean;
|
|
51
|
+
/** Called with the new state and the DOM event that changed it (none when it was changed from code). */
|
|
52
|
+
onOpenChange?: (open: boolean, event: Event | undefined) => void;
|
|
53
|
+
/** Called after the open or close transition ends. */
|
|
54
|
+
onOpenChangeComplete?: (open: boolean) => void;
|
|
55
|
+
/** Locks page scroll and blocks outside pointer input while open. @default true */
|
|
56
|
+
modal?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Set to `false` to stop the pointer from highlighting items, so `:hover` and `data-highlighted` can differ.
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
highlightItemOnHover?: boolean;
|
|
62
|
+
/** The hidden input's `name`. Inside a `BaseFormField`, the field's name is used. */
|
|
63
|
+
name?: string;
|
|
64
|
+
/** The `id` of a `<form>` to submit with, when the select isn't inside it. */
|
|
65
|
+
form?: string;
|
|
66
|
+
/** A hint for the browser's autofill. */
|
|
67
|
+
autoComplete?: string;
|
|
68
|
+
id?: string;
|
|
69
|
+
required?: boolean;
|
|
70
|
+
disabled?: boolean;
|
|
71
|
+
/** Shows the value but doesn't let the user change it. */
|
|
72
|
+
readOnly?: boolean;
|
|
73
|
+
/** A ref to the hidden `<input>` that holds the value for the form. */
|
|
74
|
+
inputRef?: Ref<HTMLInputElement>;
|
|
75
|
+
/** Imperative actions, e.g. `actionsRef.current?.close()`. */
|
|
76
|
+
actionsRef?: RefObject<SelectActions | null>;
|
|
77
|
+
children?: ReactNode;
|
|
78
|
+
};
|
|
79
|
+
declare const _default: (<Value, Multiple extends boolean | undefined = false>({ onValueChange, onOpenChange, ...otherProps }: BaseSelectProps<Value, Multiple>) => import("react").JSX.Element) & {
|
|
80
|
+
Label: (props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "id"> & {
|
|
81
|
+
render?: RenderProp<"div", FieldState>;
|
|
82
|
+
}) => import("react").JSX.Element;
|
|
83
|
+
Trigger: ({ size, className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "value"> & {
|
|
84
|
+
size?: InputSize;
|
|
85
|
+
render?: RenderProp<"button", SelectTriggerState>;
|
|
86
|
+
nativeButton?: boolean;
|
|
87
|
+
}) => import("react").JSX.Element;
|
|
88
|
+
Value: <Value>({ className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "children"> & {
|
|
89
|
+
render?: RenderProp<"span", SelectValueState>;
|
|
90
|
+
placeholder?: ReactNode;
|
|
91
|
+
children?: ReactNode | ((value: Value) => ReactNode);
|
|
92
|
+
}) => import("react").JSX.Element;
|
|
93
|
+
Icon: (props: import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & {
|
|
94
|
+
render?: RenderProp<"span", SelectIconState>;
|
|
95
|
+
}) => import("react").JSX.Element;
|
|
96
|
+
Popup: ({ container, alignItemWithTrigger, anchor, positionMethod, side, sideOffset, align, alignOffset, collisionBoundary, collisionPadding, collisionAvoidance, sticky, arrowPadding, disableAnchorTracking, renderPositioner, backdrop, renderBackdrop, arrow, renderArrow, className, children, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
97
|
+
render?: RenderProp<"div", SelectPopupState>;
|
|
98
|
+
finalFocus?: SelectFocusTarget;
|
|
99
|
+
container?: HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null;
|
|
100
|
+
alignItemWithTrigger?: boolean;
|
|
101
|
+
anchor?: Element | RefObject<Element | null> | (() => Element | null) | null;
|
|
102
|
+
positionMethod?: "absolute" | "fixed";
|
|
103
|
+
side?: SelectSide;
|
|
104
|
+
sideOffset?: number | SelectOffsetFunction;
|
|
105
|
+
align?: SelectAlign;
|
|
106
|
+
alignOffset?: number | SelectOffsetFunction;
|
|
107
|
+
collisionBoundary?: "clipping-ancestors" | Element | Element[] | {
|
|
108
|
+
x: number;
|
|
109
|
+
y: number;
|
|
110
|
+
width: number;
|
|
111
|
+
height: number;
|
|
112
|
+
};
|
|
113
|
+
collisionPadding?: number | {
|
|
114
|
+
top?: number;
|
|
115
|
+
right?: number;
|
|
116
|
+
bottom?: number;
|
|
117
|
+
left?: number;
|
|
118
|
+
};
|
|
119
|
+
collisionAvoidance?: SelectCollisionAvoidance;
|
|
120
|
+
sticky?: boolean;
|
|
121
|
+
arrowPadding?: number;
|
|
122
|
+
disableAnchorTracking?: boolean;
|
|
123
|
+
renderPositioner?: RenderProp<"div", SelectPositionerState>;
|
|
124
|
+
backdrop?: boolean;
|
|
125
|
+
renderBackdrop?: RenderProp<"div", SelectBackdropState>;
|
|
126
|
+
arrow?: ReactNode;
|
|
127
|
+
renderArrow?: RenderProp<"div", SelectArrowState>;
|
|
128
|
+
}) => import("react").JSX.Element;
|
|
129
|
+
ScrollUpArrow: ({ className, children, render, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
130
|
+
render?: RenderProp<"div", SelectScrollArrowState>;
|
|
131
|
+
keepMounted?: boolean;
|
|
132
|
+
}) => import("react").JSX.Element;
|
|
133
|
+
ScrollDownArrow: ({ className, children, render, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
134
|
+
render?: RenderProp<"div", SelectScrollArrowState>;
|
|
135
|
+
keepMounted?: boolean;
|
|
136
|
+
}) => import("react").JSX.Element;
|
|
137
|
+
List: ({ className, ...otherProps }: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
138
|
+
render?: RenderProp<"div">;
|
|
139
|
+
}) => import("react").JSX.Element;
|
|
140
|
+
Item: ({ className, ...otherProps }: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "id"> & {
|
|
141
|
+
render?: RenderProp<"div", SelectItemState>;
|
|
142
|
+
value?: unknown;
|
|
143
|
+
label?: string;
|
|
144
|
+
disabled?: boolean;
|
|
145
|
+
nativeButton?: boolean;
|
|
146
|
+
}) => import("react").JSX.Element;
|
|
147
|
+
ItemText: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
148
|
+
render?: RenderProp<"div">;
|
|
149
|
+
}) => import("react").JSX.Element;
|
|
150
|
+
ItemIndicator: (props: import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & {
|
|
151
|
+
render?: RenderProp<"span", SelectItemIndicatorState>;
|
|
152
|
+
keepMounted?: boolean;
|
|
153
|
+
}) => import("react").JSX.Element;
|
|
154
|
+
Group: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
155
|
+
render?: RenderProp<"div">;
|
|
156
|
+
}) => import("react").JSX.Element;
|
|
157
|
+
GroupLabel: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
158
|
+
render?: RenderProp<"div">;
|
|
159
|
+
}) => import("react").JSX.Element;
|
|
160
|
+
Separator: (props: import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
161
|
+
render?: RenderProp<"div", SelectSeparatorState>;
|
|
162
|
+
orientation?: "horizontal" | "vertical";
|
|
163
|
+
}) => import("react").JSX.Element;
|
|
164
|
+
};
|
|
165
|
+
export { _default as default };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Select } from "@base-ui/react/select";
|
|
3
|
+
import BaseSelectGroup from "./BaseSelectGroup.js";
|
|
4
|
+
import BaseSelectGroupLabel from "./BaseSelectGroupLabel.js";
|
|
5
|
+
import BaseSelectIcon from "./BaseSelectIcon.js";
|
|
6
|
+
import BaseSelectItem from "./BaseSelectItem.js";
|
|
7
|
+
import BaseSelectItemIndicator from "./BaseSelectItemIndicator.js";
|
|
8
|
+
import BaseSelectItemText from "./BaseSelectItemText.js";
|
|
9
|
+
import BaseSelectLabel from "./BaseSelectLabel.js";
|
|
10
|
+
import BaseSelectList from "./BaseSelectList.js";
|
|
11
|
+
import BaseSelectPopup from "./BaseSelectPopup.js";
|
|
12
|
+
import BaseSelectScrollDownArrow from "./BaseSelectScrollDownArrow.js";
|
|
13
|
+
import BaseSelectScrollUpArrow from "./BaseSelectScrollUpArrow.js";
|
|
14
|
+
import BaseSelectSeparator from "./BaseSelectSeparator.js";
|
|
15
|
+
import BaseSelectTrigger from "./BaseSelectTrigger.js";
|
|
16
|
+
import BaseSelectValue from "./BaseSelectValue.js";
|
|
17
|
+
import { jsx } from "react/jsx-runtime";
|
|
18
|
+
// src/components/form/BaseSelect.tsx
|
|
19
|
+
/** Groups the parts of a select and holds its value. Renders no element (only a hidden input for the form). */
|
|
20
|
+
const BaseSelect = ({ onValueChange, onOpenChange, ...otherProps }) => /* @__PURE__ */ jsx(Select.Root, {
|
|
21
|
+
...otherProps,
|
|
22
|
+
onValueChange: onValueChange && ((value, details) => onValueChange(value, details.event)),
|
|
23
|
+
onOpenChange: onOpenChange && ((open, details) => onOpenChange(open, details.event))
|
|
24
|
+
});
|
|
25
|
+
var BaseSelect_default = Object.assign(BaseSelect, {
|
|
26
|
+
Label: BaseSelectLabel,
|
|
27
|
+
Trigger: BaseSelectTrigger,
|
|
28
|
+
Value: BaseSelectValue,
|
|
29
|
+
Icon: BaseSelectIcon,
|
|
30
|
+
Popup: BaseSelectPopup,
|
|
31
|
+
ScrollUpArrow: BaseSelectScrollUpArrow,
|
|
32
|
+
ScrollDownArrow: BaseSelectScrollDownArrow,
|
|
33
|
+
List: BaseSelectList,
|
|
34
|
+
Item: BaseSelectItem,
|
|
35
|
+
ItemText: BaseSelectItemText,
|
|
36
|
+
ItemIndicator: BaseSelectItemIndicator,
|
|
37
|
+
Group: BaseSelectGroup,
|
|
38
|
+
GroupLabel: BaseSelectGroupLabel,
|
|
39
|
+
Separator: BaseSelectSeparator
|
|
40
|
+
});
|
|
41
|
+
export { BaseSelect_default as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type BaseSelectGroupProps = ComponentProps<"div"> & {
|
|
4
|
+
render?: RenderProp<"div">;
|
|
5
|
+
};
|
|
6
|
+
/** Groups related items under a `GroupLabel`. Renders a `<div>` with `role="group"`. */
|
|
7
|
+
declare const BaseSelectGroup: (props: BaseSelectGroupProps) => import("react").JSX.Element;
|
|
8
|
+
export { BaseSelectGroup as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Select } from "@base-ui/react/select";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/form/BaseSelectGroup.tsx
|
|
5
|
+
/** Groups related items under a `GroupLabel`. Renders a `<div>` with `role="group"`. */
|
|
6
|
+
const BaseSelectGroup = (props) => /* @__PURE__ */ jsx(Select.Group, { ...props });
|
|
7
|
+
export { BaseSelectGroup as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
type BaseSelectGroupLabelProps = ComponentProps<"div"> & {
|
|
4
|
+
render?: RenderProp<"div">;
|
|
5
|
+
};
|
|
6
|
+
/** The heading that names a group. Renders a `<div>`. */
|
|
7
|
+
declare const BaseSelectGroupLabel: (props: BaseSelectGroupLabelProps) => import("react").JSX.Element;
|
|
8
|
+
export { BaseSelectGroupLabel as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Select } from "@base-ui/react/select";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/form/BaseSelectGroupLabel.tsx
|
|
5
|
+
/** The heading that names a group. Renders a `<div>`. */
|
|
6
|
+
const BaseSelectGroupLabel = (props) => /* @__PURE__ */ jsx(Select.GroupLabel, { ...props });
|
|
7
|
+
export { BaseSelectGroupLabel as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type SelectIconState = {
|
|
4
|
+
open: boolean;
|
|
5
|
+
};
|
|
6
|
+
type BaseSelectIconProps = ComponentProps<"span"> & {
|
|
7
|
+
render?: RenderProp<"span", SelectIconState>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A decorative icon in the trigger (e.g. a chevron), hidden from assistive technology. Renders a `<span>`,
|
|
11
|
+
* with `data-popup-open` while the popup is open. Bring your own icon as children.
|
|
12
|
+
*/
|
|
13
|
+
declare const BaseSelectIcon: (props: BaseSelectIconProps) => import("react").JSX.Element;
|
|
14
|
+
export { BaseSelectIcon as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Select } from "@base-ui/react/select";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// src/components/form/BaseSelectIcon.tsx
|
|
5
|
+
/**
|
|
6
|
+
* A decorative icon in the trigger (e.g. a chevron), hidden from assistive technology. Renders a `<span>`,
|
|
7
|
+
* with `data-popup-open` while the popup is open. Bring your own icon as children.
|
|
8
|
+
*/
|
|
9
|
+
const BaseSelectIcon = (props) => /* @__PURE__ */ jsx(Select.Icon, { ...props });
|
|
10
|
+
export { BaseSelectIcon as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RenderProp } from "../../utils/render.js";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
3
|
+
export type SelectItemState = {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
selected: boolean;
|
|
6
|
+
/** Whether the item is highlighted with the keyboard or the pointer. */
|
|
7
|
+
highlighted: boolean;
|
|
8
|
+
};
|
|
9
|
+
type BaseSelectItemProps = Omit<ComponentProps<"div">, "id"> & {
|
|
10
|
+
render?: RenderProp<"div", SelectItemState>;
|
|
11
|
+
/** The value the item selects. `null` makes it a "none" item that clears the selection. */
|
|
12
|
+
value?: unknown;
|
|
13
|
+
/** The item's text for typeahead, when it differs from its text content. */
|
|
14
|
+
label?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** Set to `true` when `render` renders a `<button>`. */
|
|
17
|
+
nativeButton?: boolean;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* An option in the list. Put its text in `ItemText`, so the trigger can show it.
|
|
21
|
+
* Renders a `<div>`, with `data-selected`, `data-highlighted` and `data-disabled`.
|
|
22
|
+
*/
|
|
23
|
+
declare const BaseSelectItem: ({ className, ...otherProps }: BaseSelectItemProps) => import("react").JSX.Element;
|
|
24
|
+
export { BaseSelectItem as default };
|