@zvk/ui 0.1.0
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/LICENSE.md +26 -0
- package/README.md +31 -0
- package/dist/components/accordion/accordion.d.ts +43 -0
- package/dist/components/accordion/accordion.js +207 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/accordion/index.js +2 -0
- package/dist/components/alert/alert.d.ts +24 -0
- package/dist/components/alert/alert.js +17 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +1 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +46 -0
- package/dist/components/alert-dialog/alert-dialog.js +112 -0
- package/dist/components/alert-dialog/index.d.ts +2 -0
- package/dist/components/alert-dialog/index.js +2 -0
- package/dist/components/avatar/avatar.d.ts +14 -0
- package/dist/components/avatar/avatar.js +22 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +2 -0
- package/dist/components/badge/badge.d.ts +11 -0
- package/dist/components/badge/badge.js +6 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +24 -0
- package/dist/components/breadcrumbs/breadcrumbs.js +18 -0
- package/dist/components/breadcrumbs/index.d.ts +2 -0
- package/dist/components/breadcrumbs/index.js +1 -0
- package/dist/components/button/button.d.ts +13 -0
- package/dist/components/button/button.js +8 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/card/card.d.ts +31 -0
- package/dist/components/card/card.js +28 -0
- package/dist/components/card/index.d.ts +2 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/checkbox/checkbox.d.ts +11 -0
- package/dist/components/checkbox/checkbox.js +30 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.js +2 -0
- package/dist/components/code-block/code-block.d.ts +10 -0
- package/dist/components/code-block/code-block.js +16 -0
- package/dist/components/code-block/index.d.ts +2 -0
- package/dist/components/code-block/index.js +1 -0
- package/dist/components/collapsible/collapsible.d.ts +23 -0
- package/dist/components/collapsible/collapsible.js +52 -0
- package/dist/components/collapsible/index.d.ts +2 -0
- package/dist/components/collapsible/index.js +2 -0
- package/dist/components/combobox/combobox.d.ts +20 -0
- package/dist/components/combobox/combobox.js +121 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +2 -0
- package/dist/components/command/command-dialog.d.ts +2 -0
- package/dist/components/command/command-dialog.js +1 -0
- package/dist/components/command/command-filter.d.ts +7 -0
- package/dist/components/command/command-filter.js +14 -0
- package/dist/components/command/command.d.ts +55 -0
- package/dist/components/command/command.js +200 -0
- package/dist/components/command/index.d.ts +2 -0
- package/dist/components/command/index.js +2 -0
- package/dist/components/context-menu/context-menu.d.ts +34 -0
- package/dist/components/context-menu/context-menu.js +154 -0
- package/dist/components/context-menu/index.d.ts +2 -0
- package/dist/components/context-menu/index.js +2 -0
- package/dist/components/conversation/conversation.d.ts +60 -0
- package/dist/components/conversation/conversation.js +49 -0
- package/dist/components/conversation/index.d.ts +2 -0
- package/dist/components/conversation/index.js +1 -0
- package/dist/components/copy-button/copy-button.d.ts +23 -0
- package/dist/components/copy-button/copy-button.js +50 -0
- package/dist/components/copy-button/index.d.ts +2 -0
- package/dist/components/copy-button/index.js +2 -0
- package/dist/components/dialog/dialog.d.ts +62 -0
- package/dist/components/dialog/dialog.js +141 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dialog/index.js +2 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +43 -0
- package/dist/components/dropdown-menu/dropdown-menu.js +286 -0
- package/dist/components/dropdown-menu/index.d.ts +2 -0
- package/dist/components/dropdown-menu/index.js +2 -0
- package/dist/components/empty-state/empty-state.d.ts +13 -0
- package/dist/components/empty-state/empty-state.js +34 -0
- package/dist/components/empty-state/index.d.ts +2 -0
- package/dist/components/empty-state/index.js +1 -0
- package/dist/components/error-boundary/error-boundary.d.ts +29 -0
- package/dist/components/error-boundary/error-boundary.js +43 -0
- package/dist/components/error-boundary/index.d.ts +2 -0
- package/dist/components/error-boundary/index.js +2 -0
- package/dist/components/field/field.d.ts +23 -0
- package/dist/components/field/field.js +20 -0
- package/dist/components/field/index.d.ts +2 -0
- package/dist/components/field/index.js +1 -0
- package/dist/components/file-upload-input/file-upload-input.d.ts +13 -0
- package/dist/components/file-upload-input/file-upload-input.js +41 -0
- package/dist/components/file-upload-input/index.d.ts +2 -0
- package/dist/components/file-upload-input/index.js +2 -0
- package/dist/components/form/form.d.ts +30 -0
- package/dist/components/form/form.js +88 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.js +2 -0
- package/dist/components/icon-button/icon-button.d.ts +10 -0
- package/dist/components/icon-button/icon-button.js +8 -0
- package/dist/components/icon-button/index.d.ts +2 -0
- package/dist/components/icon-button/index.js +1 -0
- package/dist/components/index.d.ts +102 -0
- package/dist/components/index.js +51 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/input/input.d.ts +11 -0
- package/dist/components/input/input.js +27 -0
- package/dist/components/label/index.d.ts +2 -0
- package/dist/components/label/index.js +1 -0
- package/dist/components/label/label.d.ts +9 -0
- package/dist/components/label/label.js +6 -0
- package/dist/components/menubar/index.d.ts +2 -0
- package/dist/components/menubar/index.js +2 -0
- package/dist/components/menubar/menubar.d.ts +39 -0
- package/dist/components/menubar/menubar.js +214 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.js +1 -0
- package/dist/components/pagination/pagination.d.ts +21 -0
- package/dist/components/pagination/pagination.js +92 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/index.js +2 -0
- package/dist/components/popover/popover.d.ts +28 -0
- package/dist/components/popover/popover.js +164 -0
- package/dist/components/progress/index.d.ts +2 -0
- package/dist/components/progress/index.js +1 -0
- package/dist/components/progress/progress.d.ts +24 -0
- package/dist/components/progress/progress.js +29 -0
- package/dist/components/radio-group/index.d.ts +2 -0
- package/dist/components/radio-group/index.js +2 -0
- package/dist/components/radio-group/radio-group.d.ts +42 -0
- package/dist/components/radio-group/radio-group.js +69 -0
- package/dist/components/responsive-container/index.d.ts +2 -0
- package/dist/components/responsive-container/index.js +1 -0
- package/dist/components/responsive-container/responsive-container.d.ts +10 -0
- package/dist/components/responsive-container/responsive-container.js +6 -0
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/index.js +2 -0
- package/dist/components/scroll-area/scroll-area.d.ts +21 -0
- package/dist/components/scroll-area/scroll-area.js +23 -0
- package/dist/components/sectioned-sidebar-nav/index.d.ts +2 -0
- package/dist/components/sectioned-sidebar-nav/index.js +1 -0
- package/dist/components/sectioned-sidebar-nav/sectioned-sidebar-nav.d.ts +39 -0
- package/dist/components/sectioned-sidebar-nav/sectioned-sidebar-nav.js +37 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +2 -0
- package/dist/components/select/select.d.ts +46 -0
- package/dist/components/select/select.js +239 -0
- package/dist/components/separator/index.d.ts +2 -0
- package/dist/components/separator/index.js +1 -0
- package/dist/components/separator/separator.d.ts +8 -0
- package/dist/components/separator/separator.js +6 -0
- package/dist/components/sheet/index.d.ts +2 -0
- package/dist/components/sheet/index.js +2 -0
- package/dist/components/sheet/sheet.d.ts +49 -0
- package/dist/components/sheet/sheet.js +116 -0
- package/dist/components/sidebar-shell/index.d.ts +2 -0
- package/dist/components/sidebar-shell/index.js +1 -0
- package/dist/components/sidebar-shell/sidebar-shell.d.ts +35 -0
- package/dist/components/sidebar-shell/sidebar-shell.js +28 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/skeleton/skeleton.d.ts +10 -0
- package/dist/components/skeleton/skeleton.js +16 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +2 -0
- package/dist/components/slider/slider.d.ts +12 -0
- package/dist/components/slider/slider.js +30 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/spinner/index.js +1 -0
- package/dist/components/spinner/spinner.d.ts +10 -0
- package/dist/components/spinner/spinner.js +7 -0
- package/dist/components/stat/index.d.ts +2 -0
- package/dist/components/stat/index.js +1 -0
- package/dist/components/stat/stat.d.ts +13 -0
- package/dist/components/stat/stat.js +8 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +2 -0
- package/dist/components/switch/switch.d.ts +11 -0
- package/dist/components/switch/switch.js +27 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/table/table.d.ts +45 -0
- package/dist/components/table/table.js +36 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/index.js +2 -0
- package/dist/components/tabs/tabs.d.ts +34 -0
- package/dist/components/tabs/tabs.js +233 -0
- package/dist/components/tabs-with-sidebar/index.d.ts +2 -0
- package/dist/components/tabs-with-sidebar/index.js +2 -0
- package/dist/components/tabs-with-sidebar/tabs-with-sidebar.d.ts +21 -0
- package/dist/components/tabs-with-sidebar/tabs-with-sidebar.js +18 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/index.js +2 -0
- package/dist/components/textarea/textarea.d.ts +11 -0
- package/dist/components/textarea/textarea.js +28 -0
- package/dist/components/toast/index.d.ts +2 -0
- package/dist/components/toast/index.js +1 -0
- package/dist/components/toast/toast.d.ts +33 -0
- package/dist/components/toast/toast.js +27 -0
- package/dist/components/toggle/index.d.ts +2 -0
- package/dist/components/toggle/index.js +2 -0
- package/dist/components/toggle/toggle.d.ts +12 -0
- package/dist/components/toggle/toggle.js +18 -0
- package/dist/components/toggle-group/index.d.ts +2 -0
- package/dist/components/toggle-group/index.js +2 -0
- package/dist/components/toggle-group/toggle-group.d.ts +28 -0
- package/dist/components/toggle-group/toggle-group.js +67 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +2 -0
- package/dist/components/tooltip/tooltip.d.ts +10 -0
- package/dist/components/tooltip/tooltip.js +100 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/use-composed-refs.d.ts +3 -0
- package/dist/hooks/use-composed-refs.js +18 -0
- package/dist/hooks/use-controllable-state.d.ts +7 -0
- package/dist/hooks/use-controllable-state.js +30 -0
- package/dist/hooks/use-disclosure.d.ts +13 -0
- package/dist/hooks/use-disclosure.js +20 -0
- package/dist/hooks/use-event.d.ts +1 -0
- package/dist/hooks/use-event.js +11 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/internal/collection/collection.d.ts +18 -0
- package/dist/internal/collection/collection.js +54 -0
- package/dist/internal/collection/index.d.ts +2 -0
- package/dist/internal/collection/index.js +1 -0
- package/dist/internal/dismissable-layer/dismissable-layer.d.ts +13 -0
- package/dist/internal/dismissable-layer/dismissable-layer.js +73 -0
- package/dist/internal/dismissable-layer/index.d.ts +2 -0
- package/dist/internal/dismissable-layer/index.js +1 -0
- package/dist/internal/floating/auto-update.d.ts +9 -0
- package/dist/internal/floating/auto-update.js +48 -0
- package/dist/internal/floating/compute-position.d.ts +2 -0
- package/dist/internal/floating/compute-position.js +96 -0
- package/dist/internal/floating/detect-overflow.d.ts +13 -0
- package/dist/internal/floating/detect-overflow.js +13 -0
- package/dist/internal/floating/floating-types.d.ts +42 -0
- package/dist/internal/floating/floating-types.js +1 -0
- package/dist/internal/floating/index.d.ts +27 -0
- package/dist/internal/floating/index.js +5 -0
- package/dist/internal/floating/middleware.d.ts +11 -0
- package/dist/internal/floating/middleware.js +42 -0
- package/dist/internal/floating/use-floating-position.d.ts +2 -0
- package/dist/internal/floating/use-floating-position.js +113 -0
- package/dist/internal/focus/focus-scope.d.ts +10 -0
- package/dist/internal/focus/focus-scope.js +68 -0
- package/dist/internal/focus/focus-utils.d.ts +9 -0
- package/dist/internal/focus/focus-utils.js +94 -0
- package/dist/internal/focus/index.d.ts +3 -0
- package/dist/internal/focus/index.js +2 -0
- package/dist/internal/overlay-stack/index.d.ts +1 -0
- package/dist/internal/overlay-stack/index.js +1 -0
- package/dist/internal/overlay-stack/overlay-stack.d.ts +12 -0
- package/dist/internal/overlay-stack/overlay-stack.js +41 -0
- package/dist/internal/portal/index.d.ts +2 -0
- package/dist/internal/portal/index.js +1 -0
- package/dist/internal/portal/portal.d.ts +7 -0
- package/dist/internal/portal/portal.js +19 -0
- package/dist/internal/scroll-lock/index.d.ts +1 -0
- package/dist/internal/scroll-lock/index.js +1 -0
- package/dist/internal/scroll-lock/scroll-lock.d.ts +4 -0
- package/dist/internal/scroll-lock/scroll-lock.js +69 -0
- package/dist/styles.css +3852 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +1 -0
- package/dist/tokens/token-types.d.ts +23 -0
- package/dist/tokens/token-types.js +1 -0
- package/dist/tokens/tokens.d.ts +139 -0
- package/dist/tokens/tokens.js +139 -0
- package/dist/utils/cn.d.ts +2 -0
- package/dist/utils/cn.js +3 -0
- package/dist/utils/compose-event-handlers.d.ts +6 -0
- package/dist/utils/compose-event-handlers.js +8 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +2 -0
- package/package.json +282 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
const RadioGroupContext = React.createContext(null);
|
|
6
|
+
function hasRenderableNode(value) {
|
|
7
|
+
return value !== undefined && value !== null && value !== false;
|
|
8
|
+
}
|
|
9
|
+
function joinIds(...ids) {
|
|
10
|
+
const value = ids.filter(Boolean).join(" ");
|
|
11
|
+
return value.length > 0 ? value : undefined;
|
|
12
|
+
}
|
|
13
|
+
function isChecked(optionValue, value) {
|
|
14
|
+
return value === undefined ? undefined : value === optionValue;
|
|
15
|
+
}
|
|
16
|
+
function isDefaultChecked(optionValue, value, defaultValue) {
|
|
17
|
+
return value === undefined && defaultValue !== undefined ? optionValue === defaultValue : undefined;
|
|
18
|
+
}
|
|
19
|
+
function useRadioGroupContext(calledBy) {
|
|
20
|
+
const context = React.useContext(RadioGroupContext);
|
|
21
|
+
if (!context) {
|
|
22
|
+
throw new Error(`"${calledBy}" must be used within a <RadioGroup />`);
|
|
23
|
+
}
|
|
24
|
+
return context;
|
|
25
|
+
}
|
|
26
|
+
function NativeRadioItem({ "aria-describedby": ariaDescribedBy, checked, className, defaultChecked, description, disabled, id, invalid, label, name, onChange, ref, required, value, ...props }) {
|
|
27
|
+
const generatedId = React.useId();
|
|
28
|
+
const inputId = id ?? generatedId;
|
|
29
|
+
const descriptionId = hasRenderableNode(description) ? `${inputId}-description` : undefined;
|
|
30
|
+
const describedBy = joinIds(ariaDescribedBy, descriptionId);
|
|
31
|
+
const input = (_jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalid ? true : undefined, checked: checked, className: "liano-radio-group__input", defaultChecked: defaultChecked, disabled: disabled, id: inputId, name: name, onChange: onChange, required: required, type: "radio", value: value }));
|
|
32
|
+
return (_jsxs("div", { className: cn("liano-radio-group__item", className), children: [_jsxs("label", { className: "liano-radio-group__option", children: [input, _jsx("span", { className: "liano-radio-group__control", "aria-hidden": "true" }), hasRenderableNode(label) ? _jsx("span", { className: "liano-radio-group__label", children: label }) : null] }), hasRenderableNode(description) ? (_jsx("p", { className: "liano-radio-group__option-description", id: descriptionId, children: description })) : null] }));
|
|
33
|
+
}
|
|
34
|
+
export function RadioGroupItem({ disabled, value, ...props }) {
|
|
35
|
+
const context = useRadioGroupContext("RadioGroup.Item");
|
|
36
|
+
const handleChange = (event) => {
|
|
37
|
+
context.onValueChange?.(event.currentTarget.value, event);
|
|
38
|
+
};
|
|
39
|
+
return (_jsx(NativeRadioItem, { ...props, disabled: Boolean(context.disabled) || Boolean(disabled), invalid: context.invalid, name: context.name, onChange: handleChange, value: value, ...(isChecked(value, context.value) !== undefined ? { checked: isChecked(value, context.value) } : {}), ...(isDefaultChecked(value, context.value, context.defaultValue) !== undefined ? { defaultChecked: isDefaultChecked(value, context.value, context.defaultValue) } : {}), ...(context.required !== undefined ? { required: context.required } : {}) }));
|
|
40
|
+
}
|
|
41
|
+
function RadioGroupRoot({ "aria-describedby": ariaDescribedBy, children, className, description, disabled, error, id, invalid, label, name, onValueChange, options, orientation = "vertical", ref, required, size = "md", value, defaultValue, ...props }) {
|
|
42
|
+
const baseId = React.useId();
|
|
43
|
+
const generatedId = id ?? baseId;
|
|
44
|
+
const descriptionId = hasRenderableNode(description) ? `${generatedId}-description` : undefined;
|
|
45
|
+
const errorId = hasRenderableNode(error) ? `${generatedId}-error` : undefined;
|
|
46
|
+
const describedBy = joinIds(ariaDescribedBy, descriptionId, errorId);
|
|
47
|
+
const invalidState = invalid || Boolean(error);
|
|
48
|
+
const handleChange = (event) => {
|
|
49
|
+
onValueChange?.(event.currentTarget.value, event);
|
|
50
|
+
};
|
|
51
|
+
const optionItems = options?.map((option, index) => {
|
|
52
|
+
const optionId = `${baseId}-option-${index}`;
|
|
53
|
+
return (_jsx(NativeRadioItem, { disabled: Boolean(disabled) || Boolean(option.disabled), id: optionId, invalid: invalidState, label: option.label, name: name, onChange: handleChange, value: option.value, ...(isChecked(option.value, value) !== undefined ? { checked: isChecked(option.value, value) } : {}), ...(isDefaultChecked(option.value, value, defaultValue) !== undefined ? { defaultChecked: isDefaultChecked(option.value, value, defaultValue) } : {}), ...(option.description !== undefined ? { description: option.description } : {}), ...(required !== undefined ? { required } : {}) }, `${option.value}-${index}`));
|
|
54
|
+
});
|
|
55
|
+
const context = React.useMemo(() => ({
|
|
56
|
+
baseId,
|
|
57
|
+
...(defaultValue !== undefined ? { defaultValue } : {}),
|
|
58
|
+
...(disabled !== undefined ? { disabled } : {}),
|
|
59
|
+
invalid: invalidState,
|
|
60
|
+
name,
|
|
61
|
+
...(onValueChange ? { onValueChange } : {}),
|
|
62
|
+
...(required !== undefined ? { required } : {}),
|
|
63
|
+
...(value !== undefined ? { value } : {})
|
|
64
|
+
}), [baseId, defaultValue, disabled, invalidState, name, onValueChange, required, value]);
|
|
65
|
+
return (_jsx(RadioGroupContext.Provider, { value: context, children: _jsxs("fieldset", { ...props, ref: ref, "aria-describedby": describedBy, className: cn("liano-radio-group", className), "data-disabled": disabled ? "true" : undefined, "data-invalid": invalidState ? "true" : undefined, "data-orientation": orientation, "data-required": required ? "true" : undefined, "data-size": size, id: id, disabled: disabled, children: [_jsx("legend", { className: "liano-radio-group__legend", children: label }), _jsxs("div", { className: "liano-radio-group__items", children: [optionItems, children] }), hasRenderableNode(description) ? _jsx("p", { className: "liano-radio-group__description", id: descriptionId, children: description }) : null, hasRenderableNode(error) ? _jsx("p", { className: "liano-radio-group__error", id: errorId, children: error }) : null] }) }));
|
|
66
|
+
}
|
|
67
|
+
export const RadioGroup = Object.assign(RadioGroupRoot, {
|
|
68
|
+
Item: RadioGroupItem
|
|
69
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ResponsiveContainer } from "./responsive-container.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type ResponsiveContainerSize = "sm" | "md" | "lg" | "xl" | "full";
|
|
3
|
+
export type ResponsiveContainerGutter = "none" | "sm" | "md" | "lg";
|
|
4
|
+
export interface ResponsiveContainerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
size?: ResponsiveContainerSize;
|
|
6
|
+
gutter?: ResponsiveContainerGutter;
|
|
7
|
+
center?: boolean;
|
|
8
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
9
|
+
}
|
|
10
|
+
export declare function ResponsiveContainer({ center, className, gutter, ref, size, ...props }: ResponsiveContainerProps): React.JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
export function ResponsiveContainer({ center = true, className, gutter = "md", ref, size = "lg", ...props }) {
|
|
5
|
+
return (_jsx("div", { ...props, ref: ref, className: cn("liano-responsive-container", className), "data-center": center ? "true" : "false", "data-gutter": gutter, "data-size": size }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type ScrollAreaType = "auto" | "always";
|
|
3
|
+
export type ScrollAreaOrientation = "vertical" | "horizontal" | "both";
|
|
4
|
+
export interface ScrollAreaProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
type?: ScrollAreaType;
|
|
6
|
+
orientation?: ScrollAreaOrientation;
|
|
7
|
+
maxHeight?: number | string;
|
|
8
|
+
maxWidth?: number | string;
|
|
9
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
10
|
+
}
|
|
11
|
+
export interface ScrollBarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
12
|
+
orientation?: "vertical" | "horizontal";
|
|
13
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
14
|
+
}
|
|
15
|
+
declare function ScrollAreaRoot({ className, maxHeight, maxWidth, orientation, ref, style, tabIndex, type, ...props }: ScrollAreaProps): React.JSX.Element;
|
|
16
|
+
declare function ScrollBar({ className, orientation, ref, ...props }: ScrollBarProps): React.JSX.Element;
|
|
17
|
+
type ScrollAreaComponent = typeof ScrollAreaRoot & {
|
|
18
|
+
ScrollBar: typeof ScrollBar;
|
|
19
|
+
};
|
|
20
|
+
export declare const ScrollArea: ScrollAreaComponent;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
function sizeValue(value) {
|
|
5
|
+
if (typeof value === "number") {
|
|
6
|
+
return `${value}px`;
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
function ScrollAreaRoot({ className, maxHeight, maxWidth, orientation = "vertical", ref, style, tabIndex = 0, type = "auto", ...props }) {
|
|
11
|
+
const resolvedStyle = {
|
|
12
|
+
...style,
|
|
13
|
+
...(maxHeight !== undefined ? { "--liano-scroll-area-max-height": sizeValue(maxHeight) } : {}),
|
|
14
|
+
...(maxWidth !== undefined ? { "--liano-scroll-area-max-width": sizeValue(maxWidth) } : {})
|
|
15
|
+
};
|
|
16
|
+
return (_jsx("div", { ...props, ref: ref, className: cn("liano-scroll-area", className), "data-orientation": orientation, "data-type": type, style: resolvedStyle, tabIndex: tabIndex }));
|
|
17
|
+
}
|
|
18
|
+
function ScrollBar({ className, orientation = "vertical", ref, ...props }) {
|
|
19
|
+
return (_jsx("div", { ...props, ref: ref, "aria-hidden": "true", className: cn("liano-scroll-area__scrollbar", className), "data-orientation": orientation }));
|
|
20
|
+
}
|
|
21
|
+
export const ScrollArea = Object.assign(ScrollAreaRoot, {
|
|
22
|
+
ScrollBar
|
|
23
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { SectionedSidebarNav } from "./sectioned-sidebar-nav.js";
|
|
2
|
+
export type { SectionedSidebarNavItemBaseProps, SectionedSidebarNavItemProps, SectionedSidebarNavListProps, SectionedSidebarNavProps, SectionedSidebarNavSectionProps, SectionedSidebarNavSectionTitleProps } from "./sectioned-sidebar-nav.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SectionedSidebarNav } from "./sectioned-sidebar-nav.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface SectionedSidebarNavProps extends React.HTMLAttributes<HTMLElement> {
|
|
3
|
+
label?: string;
|
|
4
|
+
ref?: React.Ref<HTMLElement>;
|
|
5
|
+
}
|
|
6
|
+
export interface SectionedSidebarNavSectionProps extends React.HTMLAttributes<HTMLElement> {
|
|
7
|
+
ref?: React.Ref<HTMLElement>;
|
|
8
|
+
}
|
|
9
|
+
export interface SectionedSidebarNavSectionTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {
|
|
10
|
+
ref?: React.Ref<HTMLHeadingElement>;
|
|
11
|
+
}
|
|
12
|
+
export interface SectionedSidebarNavListProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
13
|
+
ref?: React.Ref<HTMLUListElement>;
|
|
14
|
+
}
|
|
15
|
+
export interface SectionedSidebarNavItemBaseProps {
|
|
16
|
+
active?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
icon?: React.ReactNode;
|
|
19
|
+
badge?: React.ReactNode;
|
|
20
|
+
}
|
|
21
|
+
export type SectionedSidebarNavItemProps = (SectionedSidebarNavItemBaseProps & {
|
|
22
|
+
href: string;
|
|
23
|
+
ref?: React.Ref<HTMLAnchorElement>;
|
|
24
|
+
} & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "href">) | (SectionedSidebarNavItemBaseProps & {
|
|
25
|
+
href?: never;
|
|
26
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
27
|
+
} & React.ButtonHTMLAttributes<HTMLButtonElement>);
|
|
28
|
+
declare function SectionedSidebarNavRoot({ className, label, ref, ...props }: SectionedSidebarNavProps): React.JSX.Element;
|
|
29
|
+
declare function SectionedSidebarNavSection({ className, ref, ...props }: SectionedSidebarNavSectionProps): React.JSX.Element;
|
|
30
|
+
declare function SectionedSidebarNavSectionTitle({ className, ref, ...props }: SectionedSidebarNavSectionTitleProps): React.JSX.Element;
|
|
31
|
+
declare function SectionedSidebarNavList({ className, ref, ...props }: SectionedSidebarNavListProps): React.JSX.Element;
|
|
32
|
+
declare function SectionedSidebarNavItem(props: SectionedSidebarNavItemProps): React.JSX.Element;
|
|
33
|
+
export declare const SectionedSidebarNav: typeof SectionedSidebarNavRoot & {
|
|
34
|
+
Section: typeof SectionedSidebarNavSection;
|
|
35
|
+
SectionTitle: typeof SectionedSidebarNavSectionTitle;
|
|
36
|
+
List: typeof SectionedSidebarNavList;
|
|
37
|
+
Item: typeof SectionedSidebarNavItem;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
function SectionedSidebarNavRoot({ className, label = "Sidebar navigation", ref, ...props }) {
|
|
5
|
+
return (_jsx("nav", { ...props, ref: ref, "aria-label": props["aria-label"] ?? label, className: cn("liano-sectioned-sidebar-nav", className) }));
|
|
6
|
+
}
|
|
7
|
+
function SectionedSidebarNavSection({ className, ref, ...props }) {
|
|
8
|
+
return _jsx("section", { ...props, ref: ref, className: cn("liano-sectioned-sidebar-nav__section", className) });
|
|
9
|
+
}
|
|
10
|
+
function SectionedSidebarNavSectionTitle({ className, ref, ...props }) {
|
|
11
|
+
return _jsx("h2", { ...props, ref: ref, className: cn("liano-sectioned-sidebar-nav__section-title", className) });
|
|
12
|
+
}
|
|
13
|
+
function SectionedSidebarNavList({ className, ref, ...props }) {
|
|
14
|
+
return _jsx("ul", { ...props, ref: ref, className: cn("liano-sectioned-sidebar-nav__list", className) });
|
|
15
|
+
}
|
|
16
|
+
function SectionedSidebarNavItem(props) {
|
|
17
|
+
const { active = false, badge, className, disabled = false, icon, ...itemProps } = props;
|
|
18
|
+
const content = (_jsxs(_Fragment, { children: [icon ? (_jsx("span", { "aria-hidden": "true", className: "liano-sectioned-sidebar-nav__item-icon", children: icon })) : null, _jsx("span", { className: "liano-sectioned-sidebar-nav__item-label", children: props.children }), badge ? _jsx("span", { className: "liano-sectioned-sidebar-nav__item-badge", children: badge }) : null] }));
|
|
19
|
+
if ("href" in itemProps && typeof itemProps.href === "string") {
|
|
20
|
+
const { onClick, ref, ...anchorProps } = itemProps;
|
|
21
|
+
return (_jsx("li", { className: "liano-sectioned-sidebar-nav__item", children: _jsx("a", { ...anchorProps, ref: ref, "aria-current": active ? "page" : undefined, "aria-disabled": disabled ? true : undefined, className: cn("liano-sectioned-sidebar-nav__item-control", className), "data-disabled": disabled ? "true" : undefined, "data-state": active ? "active" : "inactive", onClick: (event) => {
|
|
22
|
+
if (disabled) {
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
onClick?.(event);
|
|
27
|
+
}, tabIndex: disabled ? -1 : anchorProps.tabIndex, children: content }) }));
|
|
28
|
+
}
|
|
29
|
+
const { ref, type = "button", ...buttonProps } = itemProps;
|
|
30
|
+
return (_jsx("li", { className: "liano-sectioned-sidebar-nav__item", children: _jsx("button", { ...buttonProps, ref: ref, className: cn("liano-sectioned-sidebar-nav__item-control", className), "data-disabled": disabled ? "true" : undefined, "data-state": active ? "active" : "inactive", disabled: disabled, type: type, children: content }) }));
|
|
31
|
+
}
|
|
32
|
+
export const SectionedSidebarNav = Object.assign(SectionedSidebarNavRoot, {
|
|
33
|
+
Section: SectionedSidebarNavSection,
|
|
34
|
+
SectionTitle: SectionedSidebarNavSectionTitle,
|
|
35
|
+
List: SectionedSidebarNavList,
|
|
36
|
+
Item: SectionedSidebarNavItem
|
|
37
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { FloatingPlacement } from "../../internal/floating/floating-types.js";
|
|
3
|
+
export type SelectSize = "sm" | "md" | "lg";
|
|
4
|
+
export interface SelectProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
name?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
onValueChange?: (value: string) => void;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
invalid?: boolean;
|
|
12
|
+
placeholder?: React.ReactNode;
|
|
13
|
+
placement?: FloatingPlacement;
|
|
14
|
+
size?: SelectSize;
|
|
15
|
+
}
|
|
16
|
+
export interface SelectTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
17
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
18
|
+
}
|
|
19
|
+
export interface SelectContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
20
|
+
sideOffset?: number;
|
|
21
|
+
collisionPadding?: number;
|
|
22
|
+
matchTriggerWidth?: boolean;
|
|
23
|
+
forceMount?: boolean;
|
|
24
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
25
|
+
}
|
|
26
|
+
export interface SelectItemProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
27
|
+
value: string;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
30
|
+
}
|
|
31
|
+
export interface SelectValueProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
32
|
+
placeholder?: React.ReactNode;
|
|
33
|
+
ref?: React.Ref<HTMLSpanElement>;
|
|
34
|
+
}
|
|
35
|
+
declare function SelectRoot({ children, className, defaultValue, disabled, invalid, name, onValueChange, placeholder, placement, required, size, value, ...props }: SelectProps): React.JSX.Element;
|
|
36
|
+
declare function SelectTrigger({ children, className, disabled, onClick, onKeyDown, ref, type, ...props }: SelectTriggerProps): React.JSX.Element;
|
|
37
|
+
declare function SelectValue({ className, placeholder, ref, ...props }: SelectValueProps): React.JSX.Element;
|
|
38
|
+
declare function SelectContent({ children, className, collisionPadding, forceMount, matchTriggerWidth, onKeyDown, ref, sideOffset, style, ...props }: SelectContentProps): React.JSX.Element | null;
|
|
39
|
+
declare function SelectItem({ children, className, disabled, onClick, onKeyDown, ref, value, ...props }: SelectItemProps): React.JSX.Element;
|
|
40
|
+
export declare const Select: typeof SelectRoot & {
|
|
41
|
+
Content: typeof SelectContent;
|
|
42
|
+
Item: typeof SelectItem;
|
|
43
|
+
Trigger: typeof SelectTrigger;
|
|
44
|
+
Value: typeof SelectValue;
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useControllableState } from "../../hooks/use-controllable-state.js";
|
|
5
|
+
import { composeEventHandlers } from "../../utils/compose-event-handlers.js";
|
|
6
|
+
import { cn } from "../../utils/cn.js";
|
|
7
|
+
import { Portal } from "../../internal/portal/index.js";
|
|
8
|
+
import { DismissableLayer } from "../../internal/dismissable-layer/index.js";
|
|
9
|
+
import { useFloatingPosition } from "../../internal/floating/index.js";
|
|
10
|
+
const defaultContentPositioning = {
|
|
11
|
+
sideOffset: 4,
|
|
12
|
+
collisionPadding: 0,
|
|
13
|
+
matchTriggerWidth: true
|
|
14
|
+
};
|
|
15
|
+
const SelectContext = React.createContext(null);
|
|
16
|
+
function useSelectContext(calledBy) {
|
|
17
|
+
const context = React.useContext(SelectContext);
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error(`"${calledBy}" must be used within a <Select />`);
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
}
|
|
23
|
+
function composeRefs(...refs) {
|
|
24
|
+
return (node) => {
|
|
25
|
+
for (const ref of refs) {
|
|
26
|
+
if (typeof ref === "function") {
|
|
27
|
+
ref(node);
|
|
28
|
+
}
|
|
29
|
+
else if (ref && "current" in ref) {
|
|
30
|
+
ref.current = node;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function getTextLabel(node) {
|
|
36
|
+
return node;
|
|
37
|
+
}
|
|
38
|
+
function SelectRoot({ children, className, defaultValue = "", disabled, invalid, name, onValueChange, placeholder, placement = "bottom-start", required, size = "md", value, ...props }) {
|
|
39
|
+
const instanceId = React.useId();
|
|
40
|
+
const triggerId = `${instanceId}-trigger`;
|
|
41
|
+
const contentId = `${instanceId}-content`;
|
|
42
|
+
const triggerRef = React.useRef(null);
|
|
43
|
+
const itemRegistry = React.useRef(new Map());
|
|
44
|
+
const itemOrder = React.useRef([]);
|
|
45
|
+
const wasOpenRef = React.useRef(false);
|
|
46
|
+
const [open, setOpen] = React.useState(false);
|
|
47
|
+
const [itemsVersion, setItemsVersion] = React.useState(0);
|
|
48
|
+
const [currentValue, setCurrentValue] = useControllableState({
|
|
49
|
+
...(value !== undefined ? { value } : {}),
|
|
50
|
+
defaultValue,
|
|
51
|
+
...(onValueChange ? { onChange: onValueChange } : {})
|
|
52
|
+
});
|
|
53
|
+
const [contentPositioning, setContentPositioning] = React.useState(defaultContentPositioning);
|
|
54
|
+
const floating = useFloatingPosition({
|
|
55
|
+
open,
|
|
56
|
+
placement,
|
|
57
|
+
strategy: "absolute",
|
|
58
|
+
offset: contentPositioning.sideOffset,
|
|
59
|
+
collisionPadding: contentPositioning.collisionPadding,
|
|
60
|
+
matchReferenceWidth: contentPositioning.matchTriggerWidth
|
|
61
|
+
});
|
|
62
|
+
const getOrderedItems = React.useCallback(() => {
|
|
63
|
+
return itemOrder.current
|
|
64
|
+
.map((id) => itemRegistry.current.get(id))
|
|
65
|
+
.filter((item) => item !== undefined);
|
|
66
|
+
}, []);
|
|
67
|
+
const getEnabledItems = React.useCallback(() => getOrderedItems().filter((item) => !item.disabled && item.element !== null), [getOrderedItems]);
|
|
68
|
+
const registerItem = React.useCallback((item) => {
|
|
69
|
+
if (!itemOrder.current.includes(item.id)) {
|
|
70
|
+
itemOrder.current.push(item.id);
|
|
71
|
+
}
|
|
72
|
+
itemRegistry.current.set(item.id, item);
|
|
73
|
+
setItemsVersion((version) => version + 1);
|
|
74
|
+
}, []);
|
|
75
|
+
const unregisterItem = React.useCallback((id) => {
|
|
76
|
+
itemRegistry.current.delete(id);
|
|
77
|
+
itemOrder.current = itemOrder.current.filter((entry) => entry !== id);
|
|
78
|
+
setItemsVersion((version) => version + 1);
|
|
79
|
+
}, []);
|
|
80
|
+
const selectValue = React.useCallback((nextValue) => {
|
|
81
|
+
setCurrentValue(nextValue);
|
|
82
|
+
setOpen(false);
|
|
83
|
+
}, [setCurrentValue]);
|
|
84
|
+
const selectedLabel = React.useMemo(() => getOrderedItems().find((item) => item.value === currentValue)?.label, [currentValue, getOrderedItems, itemsVersion]);
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
if (wasOpenRef.current && !open) {
|
|
87
|
+
triggerRef.current?.focus();
|
|
88
|
+
}
|
|
89
|
+
wasOpenRef.current = open;
|
|
90
|
+
}, [open]);
|
|
91
|
+
const context = React.useMemo(() => ({
|
|
92
|
+
contentId,
|
|
93
|
+
...(disabled !== undefined ? { disabled } : {}),
|
|
94
|
+
getEnabledItems,
|
|
95
|
+
...(invalid !== undefined ? { invalid } : {}),
|
|
96
|
+
open,
|
|
97
|
+
...(placeholder !== undefined ? { placeholder } : {}),
|
|
98
|
+
registerItem,
|
|
99
|
+
...(required !== undefined ? { required } : {}),
|
|
100
|
+
selectValue,
|
|
101
|
+
...(selectedLabel !== undefined ? { selectedLabel } : {}),
|
|
102
|
+
triggerId,
|
|
103
|
+
triggerRef,
|
|
104
|
+
unregisterItem,
|
|
105
|
+
updateContentPositioning: setContentPositioning,
|
|
106
|
+
value: currentValue,
|
|
107
|
+
setOpen,
|
|
108
|
+
referenceRef: floating.referenceRef,
|
|
109
|
+
floatingRef: floating.floatingRef,
|
|
110
|
+
floatingStyle: floating.floatingStyle
|
|
111
|
+
}), [contentId, currentValue, disabled, floating.floatingRef, floating.floatingStyle, floating.referenceRef, getEnabledItems, invalid, open, placeholder, registerItem, required, selectValue, selectedLabel, triggerId, unregisterItem]);
|
|
112
|
+
return (_jsx(SelectContext.Provider, { value: context, children: _jsxs("div", { ...props, className: cn("liano-select", className), "data-disabled": disabled ? "true" : undefined, "data-invalid": invalid ? "true" : undefined, "data-required": required ? "true" : undefined, "data-size": size, "data-state": open ? "open" : "closed", children: [name ? _jsx("input", { type: "hidden", name: name, value: currentValue }) : null, children] }) }));
|
|
113
|
+
}
|
|
114
|
+
function focusItem(items, index) {
|
|
115
|
+
if (items.length === 0) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const clamped = ((index % items.length) + items.length) % items.length;
|
|
119
|
+
items[clamped]?.element?.focus();
|
|
120
|
+
}
|
|
121
|
+
function SelectTrigger({ children, className, disabled, onClick, onKeyDown, ref, type = "button", ...props }) {
|
|
122
|
+
const context = useSelectContext("Select.Trigger");
|
|
123
|
+
const isDisabled = Boolean(context.disabled) || Boolean(disabled);
|
|
124
|
+
const openAndFocus = React.useCallback((boundary = "first") => {
|
|
125
|
+
context.setOpen(true);
|
|
126
|
+
queueMicrotask(() => {
|
|
127
|
+
const items = context.getEnabledItems();
|
|
128
|
+
if (boundary === "last") {
|
|
129
|
+
focusItem(items, items.length - 1);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const selectedIndex = items.findIndex((item) => item.value === context.value);
|
|
133
|
+
focusItem(items, selectedIndex >= 0 ? selectedIndex : 0);
|
|
134
|
+
});
|
|
135
|
+
}, [context]);
|
|
136
|
+
return (_jsx("button", { ...props, ref: composeRefs(ref, context.triggerRef, context.referenceRef), "aria-controls": context.contentId, "aria-expanded": context.open ? "true" : "false", "aria-haspopup": "listbox", "aria-invalid": context.invalid ? "true" : undefined, "aria-required": context.required ? "true" : undefined, className: cn("liano-select__trigger", className), "data-disabled": isDisabled ? "true" : undefined, "data-invalid": context.invalid ? "true" : undefined, "data-state": context.open ? "open" : "closed", disabled: isDisabled, id: context.triggerId, onClick: composeEventHandlers(onClick, () => {
|
|
137
|
+
if (!isDisabled) {
|
|
138
|
+
context.setOpen(!context.open);
|
|
139
|
+
}
|
|
140
|
+
}), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
141
|
+
if (isDisabled) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (event.key === "Enter" || event.key === " " || event.key === "Space" || event.key === "Spacebar" || event.key === "ArrowDown") {
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
openAndFocus("first");
|
|
147
|
+
}
|
|
148
|
+
if (event.key === "ArrowUp") {
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
openAndFocus("last");
|
|
151
|
+
}
|
|
152
|
+
}), type: type, children: children }));
|
|
153
|
+
}
|
|
154
|
+
function SelectValue({ className, placeholder, ref, ...props }) {
|
|
155
|
+
const context = useSelectContext("Select.Value");
|
|
156
|
+
const displayPlaceholder = context.selectedLabel === undefined;
|
|
157
|
+
return (_jsx("span", { ...props, ref: ref, className: cn("liano-select__value", className), "data-placeholder": displayPlaceholder ? "true" : undefined, children: displayPlaceholder ? placeholder ?? context.placeholder : context.selectedLabel }));
|
|
158
|
+
}
|
|
159
|
+
function SelectContent({ children, className, collisionPadding = defaultContentPositioning.collisionPadding, forceMount = false, matchTriggerWidth = defaultContentPositioning.matchTriggerWidth, onKeyDown, ref, sideOffset = defaultContentPositioning.sideOffset, style, ...props }) {
|
|
160
|
+
const context = useSelectContext("Select.Content");
|
|
161
|
+
React.useEffect(() => {
|
|
162
|
+
context.updateContentPositioning({
|
|
163
|
+
sideOffset,
|
|
164
|
+
collisionPadding,
|
|
165
|
+
matchTriggerWidth
|
|
166
|
+
});
|
|
167
|
+
return () => context.updateContentPositioning(defaultContentPositioning);
|
|
168
|
+
}, [collisionPadding, context, matchTriggerWidth, sideOffset]);
|
|
169
|
+
const moveFocus = React.useCallback((direction) => {
|
|
170
|
+
const items = context.getEnabledItems();
|
|
171
|
+
const currentIndex = items.findIndex((item) => item.element === document.activeElement);
|
|
172
|
+
focusItem(items, direction === "next" ? currentIndex + 1 : currentIndex - 1);
|
|
173
|
+
}, [context]);
|
|
174
|
+
const moveToBoundary = React.useCallback((end) => {
|
|
175
|
+
const items = context.getEnabledItems();
|
|
176
|
+
focusItem(items, end ? items.length - 1 : 0);
|
|
177
|
+
}, [context]);
|
|
178
|
+
if (!context.open && !forceMount) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
const content = (_jsx("div", { ...props, ref: composeRefs(ref, context.floatingRef), "aria-labelledby": context.triggerId, className: cn("liano-select__content", className), "data-state": context.open ? "open" : "closed", hidden: context.open ? undefined : true, id: context.contentId, onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
182
|
+
if (event.key === "ArrowDown") {
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
moveFocus("next");
|
|
185
|
+
}
|
|
186
|
+
if (event.key === "ArrowUp") {
|
|
187
|
+
event.preventDefault();
|
|
188
|
+
moveFocus("previous");
|
|
189
|
+
}
|
|
190
|
+
if (event.key === "Home") {
|
|
191
|
+
event.preventDefault();
|
|
192
|
+
moveToBoundary(false);
|
|
193
|
+
}
|
|
194
|
+
if (event.key === "End") {
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
moveToBoundary(true);
|
|
197
|
+
}
|
|
198
|
+
if (event.key === "Escape") {
|
|
199
|
+
context.setOpen(false);
|
|
200
|
+
}
|
|
201
|
+
}), role: "listbox", style: { ...context.floatingStyle, ...style }, tabIndex: -1, children: children }));
|
|
202
|
+
if (!context.open) {
|
|
203
|
+
return _jsx(Portal, { children: content });
|
|
204
|
+
}
|
|
205
|
+
return (_jsx(Portal, { children: _jsx(DismissableLayer, { open: true, onDismiss: () => context.setOpen(false), children: content }) }));
|
|
206
|
+
}
|
|
207
|
+
function SelectItem({ children, className, disabled = false, onClick, onKeyDown, ref, value, ...props }) {
|
|
208
|
+
const context = useSelectContext("Select.Item");
|
|
209
|
+
const itemId = React.useId();
|
|
210
|
+
const itemRef = React.useRef(null);
|
|
211
|
+
const selected = context.value === value;
|
|
212
|
+
React.useLayoutEffect(() => {
|
|
213
|
+
context.registerItem({
|
|
214
|
+
disabled,
|
|
215
|
+
element: itemRef.current,
|
|
216
|
+
id: itemId,
|
|
217
|
+
label: getTextLabel(children),
|
|
218
|
+
value
|
|
219
|
+
});
|
|
220
|
+
return () => context.unregisterItem(itemId);
|
|
221
|
+
}, [children, context, disabled, itemId, value]);
|
|
222
|
+
const select = () => {
|
|
223
|
+
if (!disabled) {
|
|
224
|
+
context.selectValue(value);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
return (_jsxs("div", { ...props, ref: composeRefs(ref, itemRef), "aria-disabled": disabled ? "true" : undefined, "aria-selected": selected ? "true" : "false", className: cn("liano-select__item", className), "data-disabled": disabled ? "true" : undefined, "data-state": selected ? "checked" : "unchecked", id: itemId, onClick: composeEventHandlers(onClick, select), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
228
|
+
if (event.key === "Enter" || event.key === " " || event.key === "Space" || event.key === "Spacebar") {
|
|
229
|
+
event.preventDefault();
|
|
230
|
+
select();
|
|
231
|
+
}
|
|
232
|
+
}), role: "option", tabIndex: disabled ? undefined : -1, children: [_jsx("span", { className: "liano-select__item-indicator", "aria-hidden": "true", children: selected ? "✓" : "" }), _jsx("span", { className: "liano-select__item-label", children: children })] }));
|
|
233
|
+
}
|
|
234
|
+
export const Select = Object.assign(SelectRoot, {
|
|
235
|
+
Content: SelectContent,
|
|
236
|
+
Item: SelectItem,
|
|
237
|
+
Trigger: SelectTrigger,
|
|
238
|
+
Value: SelectValue
|
|
239
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Separator } from "./separator.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type SeparatorOrientation = "horizontal" | "vertical";
|
|
3
|
+
export interface SeparatorProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
orientation?: SeparatorOrientation;
|
|
5
|
+
decorative?: boolean;
|
|
6
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
7
|
+
}
|
|
8
|
+
export declare function Separator({ className, decorative, orientation, ref, ...props }: SeparatorProps): React.JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
export function Separator({ className, decorative = true, orientation = "horizontal", ref, ...props }) {
|
|
5
|
+
return (_jsx("div", { ...props, ref: ref, "aria-orientation": decorative ? undefined : orientation, className: cn("liano-separator", className), "data-orientation": orientation, role: decorative ? "none" : "separator" }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type SheetSide = "left" | "right" | "top" | "bottom";
|
|
3
|
+
export interface SheetProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
defaultOpen?: boolean;
|
|
5
|
+
onOpenChange?: (open: boolean) => void;
|
|
6
|
+
open?: boolean;
|
|
7
|
+
side?: SheetSide;
|
|
8
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
9
|
+
}
|
|
10
|
+
export interface SheetTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
11
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
12
|
+
}
|
|
13
|
+
export interface SheetContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
15
|
+
}
|
|
16
|
+
export interface SheetHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
17
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
18
|
+
}
|
|
19
|
+
export interface SheetTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {
|
|
20
|
+
ref?: React.Ref<HTMLHeadingElement>;
|
|
21
|
+
}
|
|
22
|
+
export interface SheetDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {
|
|
23
|
+
ref?: React.Ref<HTMLParagraphElement>;
|
|
24
|
+
}
|
|
25
|
+
export interface SheetFooterProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
26
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
27
|
+
}
|
|
28
|
+
export interface SheetCloseProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
29
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
30
|
+
}
|
|
31
|
+
declare function SheetRoot({ children, className, defaultOpen, onOpenChange, open: openProp, ref, side, ...props }: SheetProps): React.JSX.Element;
|
|
32
|
+
declare function SheetTrigger({ className, disabled, onClick, ref, type, ...props }: SheetTriggerProps): React.JSX.Element;
|
|
33
|
+
declare function SheetContent({ children, className, ref, ...props }: SheetContentProps): React.JSX.Element | null;
|
|
34
|
+
declare function SheetHeader({ className, ref, ...props }: SheetHeaderProps): React.JSX.Element;
|
|
35
|
+
declare function SheetTitle({ className, ref, ...props }: SheetTitleProps): React.JSX.Element;
|
|
36
|
+
declare function SheetDescription({ className, ref, ...props }: SheetDescriptionProps): React.JSX.Element;
|
|
37
|
+
declare function SheetFooter({ className, ref, ...props }: SheetFooterProps): React.JSX.Element;
|
|
38
|
+
declare function SheetClose({ className, onClick, ref, type, ...props }: SheetCloseProps): React.JSX.Element;
|
|
39
|
+
type SheetComponent = typeof SheetRoot & {
|
|
40
|
+
Close: typeof SheetClose;
|
|
41
|
+
Content: typeof SheetContent;
|
|
42
|
+
Description: typeof SheetDescription;
|
|
43
|
+
Footer: typeof SheetFooter;
|
|
44
|
+
Header: typeof SheetHeader;
|
|
45
|
+
Title: typeof SheetTitle;
|
|
46
|
+
Trigger: typeof SheetTrigger;
|
|
47
|
+
};
|
|
48
|
+
export declare const Sheet: SheetComponent;
|
|
49
|
+
export {};
|