@vitinnczk/onyx-ui 0.0.0-stage → 0.2.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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +330 -2
- package/dist/components/Accordion/Accordion.d.ts +42 -0
- package/dist/components/Accordion/Accordion.js +105 -0
- package/dist/components/Accordion/Accordion.js.map +1 -0
- package/dist/components/Accordion/Accordion.module.js +14 -0
- package/dist/components/Accordion/Accordion.module.js.map +1 -0
- package/dist/components/Accordion/index.d.ts +2 -0
- package/dist/components/Alert/Alert.d.ts +26 -0
- package/dist/components/Alert/Alert.js +58 -0
- package/dist/components/Alert/Alert.js.map +1 -0
- package/dist/components/Alert/Alert.module.js +19 -0
- package/dist/components/Alert/Alert.module.js.map +1 -0
- package/dist/components/Alert/index.d.ts +2 -0
- package/dist/components/Avatar/Avatar.d.ts +16 -0
- package/dist/components/Avatar/Avatar.js +33 -0
- package/dist/components/Avatar/Avatar.js.map +1 -0
- package/dist/components/Avatar/Avatar.module.js +15 -0
- package/dist/components/Avatar/Avatar.module.js.map +1 -0
- package/dist/components/Avatar/index.d.ts +2 -0
- package/dist/components/Badge/Badge.d.ts +15 -0
- package/dist/components/Badge/Badge.js +17 -0
- package/dist/components/Badge/Badge.js.map +1 -0
- package/dist/components/Badge/Badge.module.js +18 -0
- package/dist/components/Badge/Badge.module.js.map +1 -0
- package/dist/components/Badge/index.d.ts +2 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +26 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +44 -0
- package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.module.js +11 -0
- package/dist/components/Breadcrumb/Breadcrumb.module.js.map +1 -0
- package/dist/components/Breadcrumb/index.d.ts +2 -0
- package/dist/components/Button/Button.d.ts +29 -0
- package/dist/components/Button/Button.js +40 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Button/Button.module.js +18 -0
- package/dist/components/Button/Button.module.js.map +1 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Card/Card.d.ts +24 -0
- package/dist/components/Card/Card.js +34 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/Card/Card.module.js +17 -0
- package/dist/components/Card/Card.module.js.map +1 -0
- package/dist/components/Card/index.d.ts +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +21 -0
- package/dist/components/Checkbox/Checkbox.js +52 -0
- package/dist/components/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.module.js +9 -0
- package/dist/components/Checkbox/Checkbox.module.js.map +1 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/Divider/Divider.d.ts +18 -0
- package/dist/components/Divider/Divider.js +24 -0
- package/dist/components/Divider/Divider.js.map +1 -0
- package/dist/components/Divider/Divider.module.js +12 -0
- package/dist/components/Divider/Divider.module.js.map +1 -0
- package/dist/components/Divider/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.d.ts +18 -0
- package/dist/components/Drawer/Drawer.js +27 -0
- package/dist/components/Drawer/Drawer.js.map +1 -0
- package/dist/components/Drawer/Drawer.module.js +17 -0
- package/dist/components/Drawer/Drawer.module.js.map +1 -0
- package/dist/components/Drawer/index.d.ts +2 -0
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +65 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +159 -0
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenu.module.js +16 -0
- package/dist/components/DropdownMenu/DropdownMenu.module.js.map +1 -0
- package/dist/components/DropdownMenu/index.d.ts +2 -0
- package/dist/components/EmptyState/EmptyState.d.ts +20 -0
- package/dist/components/EmptyState/EmptyState.js +36 -0
- package/dist/components/EmptyState/EmptyState.js.map +1 -0
- package/dist/components/EmptyState/EmptyState.module.js +12 -0
- package/dist/components/EmptyState/EmptyState.module.js.map +1 -0
- package/dist/components/EmptyState/index.d.ts +2 -0
- package/dist/components/FormField/FormField.d.ts +24 -0
- package/dist/components/FormField/FormField.js +49 -0
- package/dist/components/FormField/FormField.js.map +1 -0
- package/dist/components/FormField/FormField.module.js +10 -0
- package/dist/components/FormField/FormField.module.js.map +1 -0
- package/dist/components/FormField/formFieldContext.d.ts +24 -0
- package/dist/components/FormField/formFieldContext.js +18 -0
- package/dist/components/FormField/formFieldContext.js.map +1 -0
- package/dist/components/FormField/index.d.ts +2 -0
- package/dist/components/Heading/Heading.d.ts +14 -0
- package/dist/components/Heading/Heading.js +32 -0
- package/dist/components/Heading/Heading.js.map +1 -0
- package/dist/components/Heading/Heading.module.js +14 -0
- package/dist/components/Heading/Heading.module.js.map +1 -0
- package/dist/components/Heading/index.d.ts +2 -0
- package/dist/components/Icon/Icon.d.ts +16 -0
- package/dist/components/Icon/Icon.js +28 -0
- package/dist/components/Icon/Icon.js.map +1 -0
- package/dist/components/Icon/Icon.module.js +13 -0
- package/dist/components/Icon/Icon.module.js.map +1 -0
- package/dist/components/Icon/icons.d.ts +17 -0
- package/dist/components/Icon/icons.js +47 -0
- package/dist/components/Icon/icons.js.map +1 -0
- package/dist/components/Icon/index.d.ts +3 -0
- package/dist/components/IconButton/IconButton.d.ts +12 -0
- package/dist/components/IconButton/IconButton.js +25 -0
- package/dist/components/IconButton/IconButton.js.map +1 -0
- package/dist/components/IconButton/IconButton.module.js +11 -0
- package/dist/components/IconButton/IconButton.module.js.map +1 -0
- package/dist/components/IconButton/index.d.ts +2 -0
- package/dist/components/Input/Input.d.ts +18 -0
- package/dist/components/Input/Input.js +47 -0
- package/dist/components/Input/Input.js.map +1 -0
- package/dist/components/Input/Input.module.js +5 -0
- package/dist/components/Input/Input.module.js.map +1 -0
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/Label/Label.d.ts +15 -0
- package/dist/components/Label/Label.js +22 -0
- package/dist/components/Label/Label.js.map +1 -0
- package/dist/components/Label/Label.module.js +10 -0
- package/dist/components/Label/Label.module.js.map +1 -0
- package/dist/components/Label/index.d.ts +2 -0
- package/dist/components/Link/Link.d.ts +23 -0
- package/dist/components/Link/Link.js +27 -0
- package/dist/components/Link/Link.js.map +1 -0
- package/dist/components/Link/Link.module.js +11 -0
- package/dist/components/Link/Link.module.js.map +1 -0
- package/dist/components/Link/index.d.ts +2 -0
- package/dist/components/Modal/DialogSurface.d.ts +39 -0
- package/dist/components/Modal/DialogSurface.js +69 -0
- package/dist/components/Modal/DialogSurface.js.map +1 -0
- package/dist/components/Modal/DialogSurface.module.js +16 -0
- package/dist/components/Modal/DialogSurface.module.js.map +1 -0
- package/dist/components/Modal/Modal.d.ts +34 -0
- package/dist/components/Modal/Modal.js +44 -0
- package/dist/components/Modal/Modal.js.map +1 -0
- package/dist/components/Modal/Modal.module.js +13 -0
- package/dist/components/Modal/Modal.module.js.map +1 -0
- package/dist/components/Modal/index.d.ts +3 -0
- package/dist/components/Pagination/Pagination.d.ts +46 -0
- package/dist/components/Pagination/Pagination.js +71 -0
- package/dist/components/Pagination/Pagination.js.map +1 -0
- package/dist/components/Pagination/Pagination.module.js +13 -0
- package/dist/components/Pagination/Pagination.module.js.map +1 -0
- package/dist/components/Pagination/index.d.ts +2 -0
- package/dist/components/Popover/Popover.d.ts +46 -0
- package/dist/components/Popover/Popover.js +89 -0
- package/dist/components/Popover/Popover.js.map +1 -0
- package/dist/components/Popover/Popover.module.js +12 -0
- package/dist/components/Popover/Popover.module.js.map +1 -0
- package/dist/components/Popover/index.d.ts +2 -0
- package/dist/components/Portal/Portal.d.ts +10 -0
- package/dist/components/Portal/Portal.js +13 -0
- package/dist/components/Portal/Portal.js.map +1 -0
- package/dist/components/Portal/index.d.ts +2 -0
- package/dist/components/Progress/Progress.d.ts +28 -0
- package/dist/components/Progress/Progress.js +42 -0
- package/dist/components/Progress/Progress.js.map +1 -0
- package/dist/components/Progress/Progress.module.js +18 -0
- package/dist/components/Progress/Progress.module.js.map +1 -0
- package/dist/components/Progress/index.d.ts +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +41 -0
- package/dist/components/RadioGroup/RadioGroup.js +112 -0
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -0
- package/dist/components/RadioGroup/RadioGroup.module.js +16 -0
- package/dist/components/RadioGroup/RadioGroup.module.js.map +1 -0
- package/dist/components/RadioGroup/index.d.ts +2 -0
- package/dist/components/Select/Select.d.ts +19 -0
- package/dist/components/Select/Select.js +44 -0
- package/dist/components/Select/Select.js.map +1 -0
- package/dist/components/Select/Select.module.js +10 -0
- package/dist/components/Select/Select.module.js.map +1 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Skeleton/Skeleton.d.ts +22 -0
- package/dist/components/Skeleton/Skeleton.js +33 -0
- package/dist/components/Skeleton/Skeleton.js.map +1 -0
- package/dist/components/Skeleton/Skeleton.module.js +12 -0
- package/dist/components/Skeleton/Skeleton.module.js.map +1 -0
- package/dist/components/Skeleton/index.d.ts +2 -0
- package/dist/components/Slider/Slider.d.ts +38 -0
- package/dist/components/Slider/Slider.js +55 -0
- package/dist/components/Slider/Slider.js.map +1 -0
- package/dist/components/Slider/Slider.module.js +11 -0
- package/dist/components/Slider/Slider.module.js.map +1 -0
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Spinner/Spinner.d.ts +22 -0
- package/dist/components/Spinner/Spinner.js +34 -0
- package/dist/components/Spinner/Spinner.js.map +1 -0
- package/dist/components/Spinner/Spinner.module.js +17 -0
- package/dist/components/Spinner/Spinner.module.js.map +1 -0
- package/dist/components/Spinner/index.d.ts +2 -0
- package/dist/components/Switch/Switch.d.ts +17 -0
- package/dist/components/Switch/Switch.js +48 -0
- package/dist/components/Switch/Switch.js.map +1 -0
- package/dist/components/Switch/Switch.module.js +9 -0
- package/dist/components/Switch/Switch.module.js.map +1 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Table/Table.d.ts +84 -0
- package/dist/components/Table/Table.js +105 -0
- package/dist/components/Table/Table.js.map +1 -0
- package/dist/components/Table/Table.module.js +23 -0
- package/dist/components/Table/Table.module.js.map +1 -0
- package/dist/components/Table/index.d.ts +2 -0
- package/dist/components/Tabs/Tabs.d.ts +41 -0
- package/dist/components/Tabs/Tabs.js +86 -0
- package/dist/components/Tabs/Tabs.js.map +1 -0
- package/dist/components/Tabs/Tabs.module.js +14 -0
- package/dist/components/Tabs/Tabs.module.js.map +1 -0
- package/dist/components/Tabs/index.d.ts +2 -0
- package/dist/components/Text/Text.d.ts +22 -0
- package/dist/components/Text/Text.js +37 -0
- package/dist/components/Text/Text.js.map +1 -0
- package/dist/components/Text/Text.module.js +30 -0
- package/dist/components/Text/Text.module.js.map +1 -0
- package/dist/components/Text/index.d.ts +2 -0
- package/dist/components/Textarea/Textarea.d.ts +17 -0
- package/dist/components/Textarea/Textarea.js +36 -0
- package/dist/components/Textarea/Textarea.js.map +1 -0
- package/dist/components/Textarea/Textarea.module.js +11 -0
- package/dist/components/Textarea/Textarea.module.js.map +1 -0
- package/dist/components/Textarea/index.d.ts +2 -0
- package/dist/components/ThemeProvider/ThemeProvider.d.ts +39 -0
- package/dist/components/ThemeProvider/ThemeProvider.js +36 -0
- package/dist/components/ThemeProvider/ThemeProvider.js.map +1 -0
- package/dist/components/ThemeProvider/index.d.ts +2 -0
- package/dist/components/ThemeProvider/themeStore.d.ts +8 -0
- package/dist/components/ThemeProvider/themeStore.js +36 -0
- package/dist/components/ThemeProvider/themeStore.js.map +1 -0
- package/dist/components/Toast/Toast.d.ts +66 -0
- package/dist/components/Toast/Toast.js +166 -0
- package/dist/components/Toast/Toast.js.map +1 -0
- package/dist/components/Toast/Toast.module.js +27 -0
- package/dist/components/Toast/Toast.module.js.map +1 -0
- package/dist/components/Toast/index.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.d.ts +40 -0
- package/dist/components/Tooltip/Tooltip.js +63 -0
- package/dist/components/Tooltip/Tooltip.js.map +1 -0
- package/dist/components/Tooltip/Tooltip.module.js +8 -0
- package/dist/components/Tooltip/Tooltip.module.js.map +1 -0
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +4 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js +16 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.js.map +1 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.module.js +5 -0
- package/dist/components/VisuallyHidden/VisuallyHidden.module.js.map +1 -0
- package/dist/components/VisuallyHidden/index.d.ts +2 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/useClickOutside.d.ts +10 -0
- package/dist/hooks/useClickOutside.js +21 -0
- package/dist/hooks/useClickOutside.js.map +1 -0
- package/dist/hooks/useControllableState.d.ts +10 -0
- package/dist/hooks/useControllableState.js +16 -0
- package/dist/hooks/useControllableState.js.map +1 -0
- package/dist/hooks/useEscapeKey.d.ts +9 -0
- package/dist/hooks/useEscapeKey.js +21 -0
- package/dist/hooks/useEscapeKey.js.map +1 -0
- package/dist/hooks/useFocusTrap.d.ts +19 -0
- package/dist/hooks/useFocusTrap.js +42 -0
- package/dist/hooks/useFocusTrap.js.map +1 -0
- package/dist/hooks/useLatestRef.d.ts +1 -0
- package/dist/hooks/useLatestRef.js +12 -0
- package/dist/hooks/useLatestRef.js.map +1 -0
- package/dist/hooks/useScrollLock.d.ts +10 -0
- package/dist/hooks/useScrollLock.js +19 -0
- package/dist/hooks/useScrollLock.js.map +1 -0
- package/dist/hooks/useTimeout.d.ts +5 -0
- package/dist/hooks/useTimeout.js +16 -0
- package/dist/hooks/useTimeout.js.map +1 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +59 -0
- package/dist/styles/choice.module.js +15 -0
- package/dist/styles/choice.module.js.map +1 -0
- package/dist/styles/field.module.js +11 -0
- package/dist/styles/field.module.js.map +1 -0
- package/dist/styles.css +2 -0
- package/dist/tokens/breakpoints.d.ts +12 -0
- package/dist/tokens/breakpoints.js +11 -0
- package/dist/tokens/breakpoints.js.map +1 -0
- package/dist/tokens/colors.d.ts +82 -0
- package/dist/tokens/colors.js +92 -0
- package/dist/tokens/colors.js.map +1 -0
- package/dist/tokens/focus.d.ts +4 -0
- package/dist/tokens/focus.js +8 -0
- package/dist/tokens/focus.js.map +1 -0
- package/dist/tokens/index.d.ts +22 -0
- package/dist/tokens/index.js +37 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/motion.d.ts +21 -0
- package/dist/tokens/motion.js +16 -0
- package/dist/tokens/motion.js.map +1 -0
- package/dist/tokens/radius.d.ts +9 -0
- package/dist/tokens/radius.js +13 -0
- package/dist/tokens/radius.js.map +1 -0
- package/dist/tokens/shadows.d.ts +12 -0
- package/dist/tokens/shadows.js +12 -0
- package/dist/tokens/shadows.js.map +1 -0
- package/dist/tokens/sizes.d.ts +22 -0
- package/dist/tokens/sizes.js +23 -0
- package/dist/tokens/sizes.js.map +1 -0
- package/dist/tokens/spacing.d.ts +19 -0
- package/dist/tokens/spacing.js +19 -0
- package/dist/tokens/spacing.js.map +1 -0
- package/dist/tokens/themes.d.ts +256 -0
- package/dist/tokens/themes.js +120 -0
- package/dist/tokens/themes.js.map +1 -0
- package/dist/tokens/typography.d.ts +37 -0
- package/dist/tokens/typography.js +35 -0
- package/dist/tokens/typography.js.map +1 -0
- package/dist/tokens/z-index.d.ts +8 -0
- package/dist/tokens/z-index.js +11 -0
- package/dist/tokens/z-index.js.map +1 -0
- package/dist/utils/cn.d.ts +8 -0
- package/dist/utils/cn.js +14 -0
- package/dist/utils/cn.js.map +1 -0
- package/dist/utils/floating.d.ts +20 -0
- package/dist/utils/floating.js +31 -0
- package/dist/utils/floating.js.map +1 -0
- package/dist/utils/getElementRef.d.ts +3 -0
- package/dist/utils/getElementRef.js +8 -0
- package/dist/utils/getElementRef.js.map +1 -0
- package/dist/utils/mergeRefs.d.ts +2 -0
- package/dist/utils/mergeRefs.js +9 -0
- package/dist/utils/mergeRefs.js.map +1 -0
- package/dist/utils/polymorphic.d.ts +13 -0
- package/dist/utils/refocusIfLost.d.ts +6 -0
- package/dist/utils/refocusIfLost.js +10 -0
- package/dist/utils/refocusIfLost.js.map +1 -0
- package/package.json +106 -4
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/components/Checkbox/Checkbox.module.css
|
|
2
|
+
var e = "onyx-box-OCPee", t = "onyx-check-4HYWn", n = "onyx-dash-5Dkdl", r = {
|
|
3
|
+
box: e,
|
|
4
|
+
check: t,
|
|
5
|
+
dash: n
|
|
6
|
+
};
|
|
7
|
+
export { e as box, t as check, n as dash, r as default };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=Checkbox.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.module.js","names":["box","check","dash","Checkbox_module_default"],"sources":["../../../src/components/Checkbox/Checkbox.module.css"],"sourcesContent":[".box {\n border-radius: var(--radius-sm);\n}\n\n.check,\n.dash {\n grid-area: 1 / 1;\n width: 80%;\n height: 80%;\n stroke-width: 3;\n visibility: hidden;\n}\n\n:checked:not(:indeterminate) + .box .check,\n:indeterminate + .box .dash {\n visibility: visible;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export interface DividerProps extends HTMLAttributes<HTMLElement> {
|
|
3
|
+
/** @default 'horizontal' */
|
|
4
|
+
orientation?: 'horizontal' | 'vertical';
|
|
5
|
+
/**
|
|
6
|
+
* Space around the line, along its cross axis.
|
|
7
|
+
* @default 'md'
|
|
8
|
+
*/
|
|
9
|
+
spacing?: 'none' | 'sm' | 'md' | 'lg';
|
|
10
|
+
/**
|
|
11
|
+
* Hides the line from assistive technology when it only decorates and does not separate
|
|
12
|
+
* sections of content.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
decorative?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Line that separates content, announced as a separator unless decorative. */
|
|
18
|
+
export declare const Divider: import('react').ForwardRefExoticComponent<DividerProps & import('react').RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../utils/cn.js";
|
|
3
|
+
import t from "./Divider.module.js";
|
|
4
|
+
import { forwardRef as n } from "react";
|
|
5
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
6
|
+
// src/components/Divider/Divider.tsx
|
|
7
|
+
var i = n(function({ orientation: n = "horizontal", spacing: i = "md", decorative: a = !1, className: o, ...s }, c) {
|
|
8
|
+
let l = e(t.divider, t[n], t[i], o);
|
|
9
|
+
return n === "horizontal" ? /* @__PURE__ */ r("hr", {
|
|
10
|
+
ref: c,
|
|
11
|
+
role: a ? "none" : void 0,
|
|
12
|
+
className: l,
|
|
13
|
+
...s
|
|
14
|
+
}) : /* @__PURE__ */ r("div", {
|
|
15
|
+
ref: c,
|
|
16
|
+
role: a ? "none" : "separator",
|
|
17
|
+
"aria-orientation": a ? void 0 : "vertical",
|
|
18
|
+
className: l,
|
|
19
|
+
...s
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
export { i as Divider };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=Divider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Divider.js","names":["styles","Divider_module_default","Divider","forwardRef","props","classes","cn","orientation","spacing","className","decorative"],"sources":["../../../src/components/Divider/Divider.tsx"],"sourcesContent":["import { forwardRef, type HTMLAttributes, type Ref } from 'react';\nimport { cn } from '@/utils/cn';\nimport styles from './Divider.module.css';\n\nexport interface DividerProps extends HTMLAttributes<HTMLElement> {\n /** @default 'horizontal' */\n orientation?: 'horizontal' | 'vertical';\n /**\n * Space around the line, along its cross axis.\n * @default 'md'\n */\n spacing?: 'none' | 'sm' | 'md' | 'lg';\n /**\n * Hides the line from assistive technology when it only decorates and does not separate\n * sections of content.\n * @default false\n */\n decorative?: boolean;\n}\n\n/** Line that separates content, announced as a separator unless decorative. */\nexport const Divider = forwardRef<HTMLElement, DividerProps>(function Divider(\n { orientation = 'horizontal', spacing = 'md', decorative = false, className, ...props },\n ref,\n) {\n const classes = cn(styles.divider, styles[orientation], styles[spacing], className);\n\n if (orientation === 'horizontal') {\n return (\n <hr\n ref={ref as Ref<HTMLHRElement>}\n role={decorative ? 'none' : undefined}\n className={classes}\n {...props}\n />\n );\n }\n\n return (\n <div\n ref={ref as Ref<HTMLDivElement>}\n role={decorative ? 'none' : 'separator'}\n aria-orientation={decorative ? undefined : 'vertical'}\n className={classes}\n {...props}\n />\n );\n});\n"],"mappings":";;;;;;AAqBA,IAAaE,IAAUC,EAAsC,SAC3D,EAAE,iBAAc,cAAc,aAAU,MAAM,gBAAa,IAAO,cAAW,GAAGC,KAChF,GACA;CACA,IAAMC,IAAUC,EAAGN,EAAO,SAASA,EAAOO,IAAcP,EAAOQ,IAAUC,CAAS;CAalF,OAXIF,MAAgB,eAEhB,kBAAC,MAAD;EACO;EACL,MAAMG,IAAa,SAAS,KAAA;EAC5B,WAAWL;EACX,GAAID;CACL,CAAA,IAKH,kBAAC,OAAD;EACO;EACL,MAAMM,IAAa,SAAS;EAC5B,oBAAkBA,IAAa,KAAA,IAAY;EAC3C,WAAWL;EACX,GAAID;CACL,CAAA;AAEL,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/components/Divider/Divider.module.css
|
|
2
|
+
var e = "onyx-divider-KSGsi", t = "onyx-horizontal-pZ05Y", n = "onyx-vertical-p-jD4", r = "onyx-sm-6hSBB", i = "onyx-md-qfZah", a = "onyx-lg-Azo4z", o = {
|
|
3
|
+
divider: e,
|
|
4
|
+
horizontal: t,
|
|
5
|
+
vertical: n,
|
|
6
|
+
sm: r,
|
|
7
|
+
md: i,
|
|
8
|
+
lg: a
|
|
9
|
+
};
|
|
10
|
+
export { o as default, e as divider, t as horizontal, a as lg, i as md, r as sm, n as vertical };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=Divider.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Divider.module.js","names":["divider","horizontal","vertical","sm","md","lg","Divider_module_default"],"sources":["../../../src/components/Divider/Divider.module.css"],"sourcesContent":[".divider {\n flex-shrink: 0;\n margin: 0;\n background-color: var(--color-border);\n border: 0;\n}\n\n.horizontal {\n align-self: stretch;\n height: var(--border-width-thin);\n}\n\n.vertical {\n align-self: stretch;\n width: var(--border-width-thin);\n min-height: 1em;\n}\n\n.horizontal.sm {\n margin-block: var(--space-2);\n}\n\n.horizontal.md {\n margin-block: var(--space-4);\n}\n\n.horizontal.lg {\n margin-block: var(--space-8);\n}\n\n.vertical.sm {\n margin-inline: var(--space-2);\n}\n\n.vertical.md {\n margin-inline: var(--space-4);\n}\n\n.vertical.lg {\n margin-inline: var(--space-8);\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DialogOptions } from '../Modal/DialogSurface.js';
|
|
2
|
+
import { DialogStateProps } from '../Modal/Modal.js';
|
|
3
|
+
export type DrawerPlacement = 'start' | 'end' | 'top' | 'bottom';
|
|
4
|
+
export type DrawerSize = 'sm' | 'md' | 'lg' | 'full';
|
|
5
|
+
export interface DrawerProps extends DialogOptions, DialogStateProps {
|
|
6
|
+
/**
|
|
7
|
+
* Edge the drawer slides in from. `start` and `end` follow the writing direction.
|
|
8
|
+
* @default 'end'
|
|
9
|
+
*/
|
|
10
|
+
placement?: DrawerPlacement;
|
|
11
|
+
/** Width, or height for `top` and `bottom`. @default 'sm' */
|
|
12
|
+
size?: DrawerSize;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Dialog attached to an edge of the screen, for navigation, filters or details. Behaves like
|
|
16
|
+
* `Modal`: focus is trapped, the page stops scrolling and focus returns on close.
|
|
17
|
+
*/
|
|
18
|
+
export declare const Drawer: import('react').ForwardRefExoticComponent<DrawerProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../utils/cn.js";
|
|
3
|
+
import { DialogSurface as t } from "../Modal/DialogSurface.js";
|
|
4
|
+
import { useDialogState as n } from "../Modal/Modal.js";
|
|
5
|
+
import r from "./Drawer.module.js";
|
|
6
|
+
import { forwardRef as i } from "react";
|
|
7
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
|
+
// src/components/Drawer/Drawer.tsx
|
|
9
|
+
var c = i(function({ open: i, defaultOpen: c, onOpenChange: l, trigger: u, placement: d = "end", size: f = "sm", ...p }, m) {
|
|
10
|
+
let { isOpen: h, close: g, triggerElement: _ } = n({
|
|
11
|
+
open: i,
|
|
12
|
+
defaultOpen: c,
|
|
13
|
+
onOpenChange: l,
|
|
14
|
+
trigger: u
|
|
15
|
+
});
|
|
16
|
+
return /* @__PURE__ */ s(a, { children: [_, /* @__PURE__ */ o(t, {
|
|
17
|
+
ref: m,
|
|
18
|
+
open: h,
|
|
19
|
+
onClose: g,
|
|
20
|
+
rootClassName: e(r.root, r[d]),
|
|
21
|
+
panelClassName: e(r.panel, r[f]),
|
|
22
|
+
...p
|
|
23
|
+
})] });
|
|
24
|
+
});
|
|
25
|
+
export { c as Drawer };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=Drawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.js","names":["_Fragment","styles","Drawer_module_default","Drawer","forwardRef","props","useDialogState","Fragment","triggerElement","DialogSurface","isOpen","close","cn","placement","size"],"sources":["../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport { cn } from '@/utils/cn';\nimport { DialogSurface, type DialogOptions } from '../Modal/DialogSurface';\nimport { useDialogState, type DialogStateProps } from '../Modal/Modal';\nimport styles from './Drawer.module.css';\n\nexport type DrawerPlacement = 'start' | 'end' | 'top' | 'bottom';\nexport type DrawerSize = 'sm' | 'md' | 'lg' | 'full';\n\nexport interface DrawerProps extends DialogOptions, DialogStateProps {\n /**\n * Edge the drawer slides in from. `start` and `end` follow the writing direction.\n * @default 'end'\n */\n placement?: DrawerPlacement;\n /** Width, or height for `top` and `bottom`. @default 'sm' */\n size?: DrawerSize;\n}\n\n/**\n * Dialog attached to an edge of the screen, for navigation, filters or details. Behaves like\n * `Modal`: focus is trapped, the page stops scrolling and focus returns on close.\n */\nexport const Drawer = forwardRef<HTMLDivElement, DrawerProps>(function Drawer(\n { open, defaultOpen, onOpenChange, trigger, placement = 'end', size = 'sm', ...props },\n ref,\n) {\n const { isOpen, close, triggerElement } = useDialogState({\n open,\n defaultOpen,\n onOpenChange,\n trigger,\n });\n\n return (\n <>\n {triggerElement}\n <DialogSurface\n ref={ref}\n open={isOpen}\n onClose={close}\n rootClassName={cn(styles.root, styles[placement])}\n panelClassName={cn(styles.panel, styles[size])}\n {...props}\n />\n </>\n );\n});\n"],"mappings":";;;;;;;;AAuBA,IAAaG,IAASC,EAAwC,SAC5D,EAAE,SAAM,gBAAa,iBAAc,YAAS,eAAY,OAAO,UAAO,MAAM,GAAGC,KAC/E,GACA;CACA,IAAM,EAAE,WAAQ,UAAO,sBAAmBC,EAAe;EACvD;EACA;EACA;EACA;CACF,CAAC;CAED,OACE,kBAAAN,GAAA,EAAA,UAAA,CACGQ,GACD,kBAACC,GAAD;EACO;EACL,MAAMC;EACN,SAASC;EACT,eAAeC,EAAGX,EAAO,MAAMA,EAAOY,EAAU;EAChD,gBAAgBD,EAAGX,EAAO,OAAOA,EAAOa,EAAK;EAC7C,GAAIT;CACL,CAAA,CACD,EAAA,CAAA;AAEN,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/components/Drawer/Drawer.module.css
|
|
2
|
+
var e = "onyx-root-guW1o", t = "onyx-panel-wUX0N", n = "onyx-drawer-in-2TCEt", r = "onyx-start-MS4bt", i = "onyx-end-aJxa5", a = "onyx-top-7rGCn", o = "onyx-bottom-zd-25", s = "onyx-sm-AQ96e", c = "onyx-md--2Ihw", l = "onyx-lg-gWSe1", u = "onyx-full-Dbag5", d = {
|
|
3
|
+
root: e,
|
|
4
|
+
panel: t,
|
|
5
|
+
drawerIn: n,
|
|
6
|
+
start: r,
|
|
7
|
+
end: i,
|
|
8
|
+
top: a,
|
|
9
|
+
bottom: o,
|
|
10
|
+
sm: s,
|
|
11
|
+
md: c,
|
|
12
|
+
lg: l,
|
|
13
|
+
full: u
|
|
14
|
+
};
|
|
15
|
+
export { o as bottom, d as default, n as drawerIn, i as end, u as full, l as lg, c as md, t as panel, e as root, s as sm, r as start, a as top };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=Drawer.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.module.js","names":["root","panel","drawerIn","start","end","top","bottom","sm","md","lg","full","Drawer_module_default"],"sources":["../../../src/components/Drawer/Drawer.module.css"],"sourcesContent":[".root {\n --drawer-size: var(--size-overlay-sm);\n --drawer-from: translate(100%, 0);\n}\n\n.panel {\n animation: drawer-in var(--duration-slow) var(--easing-enter);\n}\n\n.start {\n justify-content: flex-start;\n --drawer-from: translate(-100%, 0);\n}\n\n.end {\n justify-content: flex-end;\n}\n\n.top {\n flex-direction: column;\n justify-content: flex-start;\n --drawer-from: translate(0, -100%);\n}\n\n.bottom {\n flex-direction: column;\n justify-content: flex-end;\n --drawer-from: translate(0, 100%);\n}\n\n:dir(rtl) .start {\n --drawer-from: translate(100%, 0);\n}\n\n:dir(rtl) .end {\n --drawer-from: translate(-100%, 0);\n}\n\n:is(.start, .end) .panel {\n width: min(var(--drawer-size), 100%);\n height: 100%;\n}\n\n:is(.top, .bottom) .panel {\n width: 100%;\n height: min(var(--drawer-size), 100%);\n}\n\n.start .panel {\n border-start-end-radius: var(--radius-xl);\n border-end-end-radius: var(--radius-xl);\n}\n\n.end .panel {\n border-start-start-radius: var(--radius-xl);\n border-end-start-radius: var(--radius-xl);\n}\n\n.top .panel {\n border-end-start-radius: var(--radius-xl);\n border-end-end-radius: var(--radius-xl);\n}\n\n.bottom .panel {\n border-start-start-radius: var(--radius-xl);\n border-start-end-radius: var(--radius-xl);\n}\n\n.sm {\n --drawer-size: var(--size-overlay-sm);\n}\n\n.md {\n --drawer-size: var(--size-overlay-md);\n}\n\n.lg {\n --drawer-size: var(--size-overlay-lg);\n}\n\n.full {\n --drawer-size: 100%;\n}\n\n.full.panel {\n border-radius: 0;\n}\n\n@keyframes drawer-in {\n from {\n transform: var(--drawer-from);\n }\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, HTMLAttributes, KeyboardEvent, MouseEvent, ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { Placement } from '../../utils/floating.js';
|
|
3
|
+
type TriggerProps = {
|
|
4
|
+
id?: string;
|
|
5
|
+
onClick?: (event: MouseEvent<HTMLElement>) => void;
|
|
6
|
+
onKeyDown?: (event: KeyboardEvent<HTMLElement>) => void;
|
|
7
|
+
};
|
|
8
|
+
export type DropdownMenuPlacement = Placement;
|
|
9
|
+
export interface DropdownMenuProps {
|
|
10
|
+
/** Button that opens the menu. It must accept a ref. */
|
|
11
|
+
trigger: ReactElement<TriggerProps>;
|
|
12
|
+
/** `DropdownMenuItem`, `DropdownMenuGroup` and `DropdownMenuSeparator` elements. */
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
/** @default 'bottom-start' */
|
|
15
|
+
placement?: DropdownMenuPlacement;
|
|
16
|
+
/** Open state, for a controlled menu. */
|
|
17
|
+
open?: boolean;
|
|
18
|
+
/** @default false */
|
|
19
|
+
defaultOpen?: boolean;
|
|
20
|
+
onOpenChange?: (open: boolean) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Gap between the trigger and the menu, in pixels.
|
|
23
|
+
* @default 4
|
|
24
|
+
*/
|
|
25
|
+
offset?: number;
|
|
26
|
+
/** Class of the menu panel. */
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Menu of actions opened by a button, following the ARIA menu button pattern: arrow keys,
|
|
31
|
+
* Home/End and typing a label move between items, Enter or Space runs one, Escape closes and
|
|
32
|
+
* returns focus to the button.
|
|
33
|
+
*/
|
|
34
|
+
export declare function DropdownMenu({ trigger, children, placement, open: openProp, defaultOpen, onOpenChange, offset, className, }: DropdownMenuProps): import('react').JSX.Element;
|
|
35
|
+
export interface DropdownMenuItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
36
|
+
/** Called when the item is chosen with a click, Enter or Space. */
|
|
37
|
+
onSelect?: () => void;
|
|
38
|
+
/** Icon shown before the label. */
|
|
39
|
+
icon?: ReactNode;
|
|
40
|
+
/** Keyboard shortcut shown after the label, for reference only. */
|
|
41
|
+
shortcut?: string;
|
|
42
|
+
/** Styles the item as a destructive action. @default false */
|
|
43
|
+
destructive?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Keeps the item focusable but prevents choosing it, as the menu pattern recommends.
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Closes the menu after the item is chosen.
|
|
51
|
+
* @default true
|
|
52
|
+
*/
|
|
53
|
+
closeOnSelect?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** Action inside a `DropdownMenu`. */
|
|
56
|
+
export declare const DropdownMenuItem: import('react').ForwardRefExoticComponent<DropdownMenuItemProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
57
|
+
export interface DropdownMenuGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
58
|
+
/** Visible heading of the group, which also names it. */
|
|
59
|
+
label: ReactNode;
|
|
60
|
+
}
|
|
61
|
+
/** Labelled set of related items. */
|
|
62
|
+
export declare const DropdownMenuGroup: import('react').ForwardRefExoticComponent<DropdownMenuGroupProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
63
|
+
/** Line between groups of items. */
|
|
64
|
+
export declare const DropdownMenuSeparator: import('react').ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & import('react').RefAttributes<HTMLDivElement>>;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useControllableState as e } from "../../hooks/useControllableState.js";
|
|
3
|
+
import { cn as t } from "../../utils/cn.js";
|
|
4
|
+
import { mergeRefs as n } from "../../utils/mergeRefs.js";
|
|
5
|
+
import { useClickOutside as r } from "../../hooks/useClickOutside.js";
|
|
6
|
+
import { useEscapeKey as i } from "../../hooks/useEscapeKey.js";
|
|
7
|
+
import { refocusIfLost as a } from "../../utils/refocusIfLost.js";
|
|
8
|
+
import { Portal as o } from "../Portal/Portal.js";
|
|
9
|
+
import { useTimeout as s } from "../../hooks/useTimeout.js";
|
|
10
|
+
import { useFloatingLayer as c } from "../../utils/floating.js";
|
|
11
|
+
import { getElementRef as l } from "../../utils/getElementRef.js";
|
|
12
|
+
import u from "./DropdownMenu.module.js";
|
|
13
|
+
import { cloneElement as d, createContext as f, forwardRef as p, isValidElement as m, useContext as h, useEffect as g, useId as _, useMemo as v, useRef as y, useState as b } from "react";
|
|
14
|
+
import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
15
|
+
// src/components/DropdownMenu/DropdownMenu.tsx
|
|
16
|
+
var w = f(null), T = "[role=\"menuitem\"]";
|
|
17
|
+
function E(e) {
|
|
18
|
+
return e ? [...e.querySelectorAll(T)] : [];
|
|
19
|
+
}
|
|
20
|
+
function D(e, t, n) {
|
|
21
|
+
let r = [...e.slice(t + 1), ...e.slice(0, t + 1)], i = (e) => (t) => t.textContent?.trim().toLowerCase().startsWith(e), a = [...n].every((e) => e === n[0]);
|
|
22
|
+
return r.find(i(n)) ?? (a ? r.find(i(n[0])) : void 0);
|
|
23
|
+
}
|
|
24
|
+
function O({ trigger: f, children: p, placement: h = "bottom-start", open: T, defaultOpen: O = !1, onOpenChange: k, offset: A = 4, className: j }) {
|
|
25
|
+
let M = _(), N = f.props.id ?? `${M}-trigger`, P = `${M}-menu`, [F, I] = b(null), L = y(null), R = y(""), z = s(), [B, V] = b("first"), [H, U] = e({
|
|
26
|
+
value: T,
|
|
27
|
+
defaultValue: O,
|
|
28
|
+
onChange: k
|
|
29
|
+
}), { setReference: W, setFloating: G, floatingStyles: K } = c({
|
|
30
|
+
open: H,
|
|
31
|
+
placement: h,
|
|
32
|
+
gap: A
|
|
33
|
+
}), q = l(f), J = v(() => n(W, q, I), [W, q]), Y = v(() => n(G, L), [G]);
|
|
34
|
+
g(() => {
|
|
35
|
+
if (!H) return;
|
|
36
|
+
let e = E(L.current);
|
|
37
|
+
(B === "first" ? e[0] : e.at(-1))?.focus({ preventScroll: !0 });
|
|
38
|
+
}, [H, B]);
|
|
39
|
+
let X = (e = !0) => {
|
|
40
|
+
U(!1), e && F?.focus();
|
|
41
|
+
};
|
|
42
|
+
i(() => X(), { enabled: H }), r([L, { current: F }], () => {
|
|
43
|
+
X(!1), a(F);
|
|
44
|
+
}, { enabled: H });
|
|
45
|
+
let Z = (e) => {
|
|
46
|
+
V(e), U(!0);
|
|
47
|
+
}, Q = m(f) ? d(f, {
|
|
48
|
+
ref: J,
|
|
49
|
+
id: N,
|
|
50
|
+
"aria-haspopup": "menu",
|
|
51
|
+
"aria-expanded": H,
|
|
52
|
+
"aria-controls": H ? P : void 0,
|
|
53
|
+
onClick: (e) => {
|
|
54
|
+
f.props.onClick?.(e), !e.defaultPrevented && (H ? U(!1) : Z("first"));
|
|
55
|
+
},
|
|
56
|
+
onKeyDown: (e) => {
|
|
57
|
+
f.props.onKeyDown?.(e), (e.key === "ArrowDown" || e.key === "ArrowUp") && (e.preventDefault(), Z(e.key === "ArrowDown" ? "first" : "last"));
|
|
58
|
+
}
|
|
59
|
+
}) : f;
|
|
60
|
+
return /* @__PURE__ */ C(x, { children: [Q, H && /* @__PURE__ */ S(o, { children: /* @__PURE__ */ S("div", {
|
|
61
|
+
ref: Y,
|
|
62
|
+
id: P,
|
|
63
|
+
role: "menu",
|
|
64
|
+
"aria-labelledby": N,
|
|
65
|
+
"aria-orientation": "vertical",
|
|
66
|
+
tabIndex: -1,
|
|
67
|
+
className: t(u.menu, j),
|
|
68
|
+
style: K,
|
|
69
|
+
onKeyDown: (e) => {
|
|
70
|
+
let t = E(L.current), n = t.indexOf(document.activeElement), r = (e) => t.at(e % t.length)?.focus();
|
|
71
|
+
switch (e.key) {
|
|
72
|
+
case "ArrowDown":
|
|
73
|
+
e.preventDefault(), r(n + 1);
|
|
74
|
+
break;
|
|
75
|
+
case "ArrowUp":
|
|
76
|
+
e.preventDefault(), r(n <= 0 ? -1 : n - 1);
|
|
77
|
+
break;
|
|
78
|
+
case "Home":
|
|
79
|
+
e.preventDefault(), r(0);
|
|
80
|
+
break;
|
|
81
|
+
case "End":
|
|
82
|
+
e.preventDefault(), r(-1);
|
|
83
|
+
break;
|
|
84
|
+
case "Tab":
|
|
85
|
+
X();
|
|
86
|
+
break;
|
|
87
|
+
default:
|
|
88
|
+
if (e.key.length !== 1 || e.ctrlKey || e.metaKey || e.altKey || e.key === " " && R.current === "") return;
|
|
89
|
+
e.preventDefault(), R.current += e.key.toLowerCase(), z.set(() => {
|
|
90
|
+
R.current = "";
|
|
91
|
+
}, 500), D(t, n, R.current)?.focus();
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
children: /* @__PURE__ */ S(w.Provider, {
|
|
95
|
+
value: { close: X },
|
|
96
|
+
children: p
|
|
97
|
+
})
|
|
98
|
+
}) })] });
|
|
99
|
+
}
|
|
100
|
+
var k = p(function({ onSelect: e, icon: n, shortcut: r, destructive: i = !1, disabled: a = !1, closeOnSelect: o = !0, className: s, children: c, onClick: l, onPointerMove: d, ...f }, p) {
|
|
101
|
+
let m = h(w);
|
|
102
|
+
if (!m) throw Error("DropdownMenuItem must be rendered inside a DropdownMenu.");
|
|
103
|
+
return /* @__PURE__ */ C("button", {
|
|
104
|
+
ref: p,
|
|
105
|
+
type: "button",
|
|
106
|
+
role: "menuitem",
|
|
107
|
+
tabIndex: -1,
|
|
108
|
+
"aria-disabled": a || void 0,
|
|
109
|
+
className: t(u.item, i && u.destructive, s),
|
|
110
|
+
onClick: (t) => {
|
|
111
|
+
l?.(t), !(a || t.defaultPrevented) && (e?.(), o && m.close());
|
|
112
|
+
},
|
|
113
|
+
onPointerMove: (e) => {
|
|
114
|
+
d?.(e), e.pointerType !== "touch" && e.currentTarget.focus();
|
|
115
|
+
},
|
|
116
|
+
...f,
|
|
117
|
+
children: [
|
|
118
|
+
n && /* @__PURE__ */ S("span", {
|
|
119
|
+
className: u.icon,
|
|
120
|
+
"aria-hidden": "true",
|
|
121
|
+
children: n
|
|
122
|
+
}),
|
|
123
|
+
/* @__PURE__ */ S("span", {
|
|
124
|
+
className: u.label,
|
|
125
|
+
children: c
|
|
126
|
+
}),
|
|
127
|
+
r && /* @__PURE__ */ S("kbd", {
|
|
128
|
+
className: u.shortcut,
|
|
129
|
+
"aria-hidden": "true",
|
|
130
|
+
children: r
|
|
131
|
+
})
|
|
132
|
+
]
|
|
133
|
+
});
|
|
134
|
+
}), A = p(function({ label: e, className: n, children: r, ...i }, a) {
|
|
135
|
+
let o = _();
|
|
136
|
+
return /* @__PURE__ */ C("div", {
|
|
137
|
+
ref: a,
|
|
138
|
+
role: "group",
|
|
139
|
+
"aria-labelledby": o,
|
|
140
|
+
className: t(u.group, n),
|
|
141
|
+
...i,
|
|
142
|
+
children: [/* @__PURE__ */ S("div", {
|
|
143
|
+
id: o,
|
|
144
|
+
role: "presentation",
|
|
145
|
+
className: u.groupLabel,
|
|
146
|
+
children: e
|
|
147
|
+
}), r]
|
|
148
|
+
});
|
|
149
|
+
}), j = p(function({ className: e, ...n }, r) {
|
|
150
|
+
return /* @__PURE__ */ S("div", {
|
|
151
|
+
ref: r,
|
|
152
|
+
role: "separator",
|
|
153
|
+
className: t(u.separator, e),
|
|
154
|
+
...n
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
export { O as DropdownMenu, A as DropdownMenuGroup, k as DropdownMenuItem, j as DropdownMenuSeparator };
|
|
158
|
+
|
|
159
|
+
//# sourceMappingURL=DropdownMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownMenu.js","names":["_Fragment","styles","DropdownMenu_module_default","MenuContext","createContext","itemSelector","getItems","menu","findByText","ordered","items","from","startsWith","item","text","repeated","search","char","DropdownMenu","openProp","id","useId","triggerId","trigger","menuId","triggerNode","setTriggerNode","useState","useRef","typeahead","clearTypeahead","useTimeout","focusOnOpen","setFocusOnOpen","open","setOpen","useControllableState","defaultOpen","onOpenChange","useFloatingLayer","offset","triggerElementRef","getElementRef","attachTrigger","useMemo","mergeRefs","setReference","attachMenu","setFloating","close","returnFocus","useEscapeKey","useClickOutside","refocusIfLost","openWith","target","triggerElement","isValidElement","cloneElement","event","Fragment","Portal","cn","className","floatingStyles","index","focusAt","next","DropdownMenuItem","forwardRef","props","useContext","disabled","destructive","onClick","onSelect","closeOnSelect","onPointerMove","icon","shortcut","DropdownMenuGroup","labelId","label","children","DropdownMenuSeparator"],"sources":["../../../src/components/DropdownMenu/DropdownMenu.tsx"],"sourcesContent":["import {\n cloneElement,\n createContext,\n forwardRef,\n isValidElement,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type KeyboardEvent,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n} from 'react';\nimport { useClickOutside } from '@/hooks/useClickOutside';\nimport { useControllableState } from '@/hooks/useControllableState';\nimport { useEscapeKey } from '@/hooks/useEscapeKey';\nimport { useTimeout } from '@/hooks/useTimeout';\nimport { cn } from '@/utils/cn';\nimport { useFloatingLayer, type Placement } from '@/utils/floating';\nimport { getElementRef } from '@/utils/getElementRef';\nimport { mergeRefs } from '@/utils/mergeRefs';\nimport { refocusIfLost } from '@/utils/refocusIfLost';\nimport { Portal } from '../Portal';\nimport styles from './DropdownMenu.module.css';\n\ninterface MenuContextValue {\n close: () => void;\n}\n\nconst MenuContext = createContext<MenuContextValue | null>(null);\n\ntype TriggerProps = {\n id?: string;\n onClick?: (event: MouseEvent<HTMLElement>) => void;\n onKeyDown?: (event: KeyboardEvent<HTMLElement>) => void;\n};\n\nexport type DropdownMenuPlacement = Placement;\n\nexport interface DropdownMenuProps {\n /** Button that opens the menu. It must accept a ref. */\n trigger: ReactElement<TriggerProps>;\n /** `DropdownMenuItem`, `DropdownMenuGroup` and `DropdownMenuSeparator` elements. */\n children: ReactNode;\n /** @default 'bottom-start' */\n placement?: DropdownMenuPlacement;\n /** Open state, for a controlled menu. */\n open?: boolean;\n /** @default false */\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /**\n * Gap between the trigger and the menu, in pixels.\n * @default 4\n */\n offset?: number;\n /** Class of the menu panel. */\n className?: string;\n}\n\nconst itemSelector = '[role=\"menuitem\"]';\n\nfunction getItems(menu: HTMLElement | null) {\n return menu ? [...menu.querySelectorAll<HTMLElement>(itemSelector)] : [];\n}\n\nfunction findByText(items: HTMLElement[], from: number, search: string) {\n const ordered = [...items.slice(from + 1), ...items.slice(0, from + 1)];\n const startsWith = (text: string) => (item: HTMLElement) =>\n item.textContent?.trim().toLowerCase().startsWith(text);\n const repeated = [...search].every((char) => char === search[0]);\n\n return (\n ordered.find(startsWith(search)) ??\n (repeated ? ordered.find(startsWith(search[0]!)) : undefined)\n );\n}\n\n/**\n * Menu of actions opened by a button, following the ARIA menu button pattern: arrow keys,\n * Home/End and typing a label move between items, Enter or Space runs one, Escape closes and\n * returns focus to the button.\n */\nexport function DropdownMenu({\n trigger,\n children,\n placement = 'bottom-start',\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n offset = 4,\n className,\n}: DropdownMenuProps) {\n const id = useId();\n const triggerId = trigger.props.id ?? `${id}-trigger`;\n const menuId = `${id}-menu`;\n const [triggerNode, setTriggerNode] = useState<HTMLElement | null>(null);\n const menu = useRef<HTMLDivElement>(null);\n const typeahead = useRef('');\n const clearTypeahead = useTimeout();\n const [focusOnOpen, setFocusOnOpen] = useState<'first' | 'last'>('first');\n const [open, setOpen] = useControllableState({\n value: openProp,\n defaultValue: defaultOpen,\n onChange: onOpenChange,\n });\n const { setReference, setFloating, floatingStyles } = useFloatingLayer({\n open,\n placement,\n gap: offset,\n });\n const triggerElementRef = getElementRef<HTMLElement>(trigger);\n const attachTrigger = useMemo(\n () => mergeRefs<HTMLElement>(setReference, triggerElementRef, setTriggerNode),\n [setReference, triggerElementRef],\n );\n const attachMenu = useMemo(() => mergeRefs(setFloating, menu), [setFloating]);\n\n useEffect(() => {\n if (!open) return;\n const items = getItems(menu.current);\n (focusOnOpen === 'first' ? items[0] : items.at(-1))?.focus({ preventScroll: true });\n }, [open, focusOnOpen]);\n\n const close = (returnFocus = true) => {\n setOpen(false);\n if (returnFocus) triggerNode?.focus();\n };\n\n useEscapeKey(() => close(), { enabled: open });\n useClickOutside(\n [menu, { current: triggerNode }],\n () => {\n close(false);\n refocusIfLost(triggerNode);\n },\n { enabled: open },\n );\n\n const openWith = (target: 'first' | 'last') => {\n setFocusOnOpen(target);\n setOpen(true);\n };\n\n const triggerElement = isValidElement(trigger)\n ? cloneElement(trigger, {\n ref: attachTrigger,\n id: triggerId,\n 'aria-haspopup': 'menu',\n 'aria-expanded': open,\n 'aria-controls': open ? menuId : undefined,\n onClick: (event: MouseEvent<HTMLElement>) => {\n trigger.props.onClick?.(event);\n if (event.defaultPrevented) return;\n if (open) setOpen(false);\n else openWith('first');\n },\n onKeyDown: (event: KeyboardEvent<HTMLElement>) => {\n trigger.props.onKeyDown?.(event);\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault();\n openWith(event.key === 'ArrowDown' ? 'first' : 'last');\n }\n },\n } as object)\n : trigger;\n\n const onMenuKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const items = getItems(menu.current);\n const index = items.indexOf(document.activeElement as HTMLElement);\n const focusAt = (next: number) => items.at(next % items.length)?.focus();\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n focusAt(index + 1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n focusAt(index <= 0 ? -1 : index - 1);\n break;\n case 'Home':\n event.preventDefault();\n focusAt(0);\n break;\n case 'End':\n event.preventDefault();\n focusAt(-1);\n break;\n case 'Tab':\n close();\n break;\n default:\n if (event.key.length !== 1 || event.ctrlKey || event.metaKey || event.altKey) return;\n if (event.key === ' ' && typeahead.current === '') return;\n event.preventDefault();\n typeahead.current += event.key.toLowerCase();\n clearTypeahead.set(() => {\n typeahead.current = '';\n }, 500);\n findByText(items, index, typeahead.current)?.focus();\n }\n };\n\n return (\n <>\n {triggerElement}\n {open && (\n <Portal>\n <div\n ref={attachMenu}\n id={menuId}\n role=\"menu\"\n aria-labelledby={triggerId}\n aria-orientation=\"vertical\"\n tabIndex={-1}\n className={cn(styles.menu, className)}\n style={floatingStyles}\n onKeyDown={onMenuKeyDown}\n >\n <MenuContext.Provider value={{ close }}>{children}</MenuContext.Provider>\n </div>\n </Portal>\n )}\n </>\n );\n}\n\nexport interface DropdownMenuItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /** Called when the item is chosen with a click, Enter or Space. */\n onSelect?: () => void;\n /** Icon shown before the label. */\n icon?: ReactNode;\n /** Keyboard shortcut shown after the label, for reference only. */\n shortcut?: string;\n /** Styles the item as a destructive action. @default false */\n destructive?: boolean;\n /**\n * Keeps the item focusable but prevents choosing it, as the menu pattern recommends.\n * @default false\n */\n disabled?: boolean;\n /**\n * Closes the menu after the item is chosen.\n * @default true\n */\n closeOnSelect?: boolean;\n}\n\n/** Action inside a `DropdownMenu`. */\nexport const DropdownMenuItem = forwardRef<HTMLButtonElement, DropdownMenuItemProps>(\n function DropdownMenuItem(\n {\n onSelect,\n icon,\n shortcut,\n destructive = false,\n disabled = false,\n closeOnSelect = true,\n className,\n children,\n onClick,\n onPointerMove,\n ...props\n },\n ref,\n ) {\n const menu = useContext(MenuContext);\n if (!menu) throw new Error('DropdownMenuItem must be rendered inside a DropdownMenu.');\n\n return (\n <button\n ref={ref}\n type=\"button\"\n role=\"menuitem\"\n tabIndex={-1}\n aria-disabled={disabled || undefined}\n className={cn(styles.item, destructive && styles.destructive, className)}\n onClick={(event) => {\n onClick?.(event);\n if (disabled || event.defaultPrevented) return;\n onSelect?.();\n if (closeOnSelect) menu.close();\n }}\n onPointerMove={(event) => {\n onPointerMove?.(event);\n if (event.pointerType !== 'touch') event.currentTarget.focus();\n }}\n {...props}\n >\n {icon && (\n <span className={styles.icon} aria-hidden=\"true\">\n {icon}\n </span>\n )}\n <span className={styles.label}>{children}</span>\n {shortcut && (\n <kbd className={styles.shortcut} aria-hidden=\"true\">\n {shortcut}\n </kbd>\n )}\n </button>\n );\n },\n);\n\nexport interface DropdownMenuGroupProps extends HTMLAttributes<HTMLDivElement> {\n /** Visible heading of the group, which also names it. */\n label: ReactNode;\n}\n\n/** Labelled set of related items. */\nexport const DropdownMenuGroup = forwardRef<HTMLDivElement, DropdownMenuGroupProps>(\n function DropdownMenuGroup({ label, className, children, ...props }, ref) {\n const labelId = useId();\n\n return (\n <div\n ref={ref}\n role=\"group\"\n aria-labelledby={labelId}\n className={cn(styles.group, className)}\n {...props}\n >\n <div id={labelId} role=\"presentation\" className={styles.groupLabel}>\n {label}\n </div>\n {children}\n </div>\n );\n },\n);\n\n/** Line between groups of items. */\nexport const DropdownMenuSeparator = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(\n function DropdownMenuSeparator({ className, ...props }, ref) {\n return (\n <div ref={ref} role=\"separator\" className={cn(styles.separator, className)} {...props} />\n );\n },\n);\n"],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/components/DropdownMenu/DropdownMenu.module.css
|
|
2
|
+
var e = "onyx-menu--RiRW", t = "onyx-menu-in-1KJYp", n = "onyx-item-T-QPZ", r = "onyx-destructive-3XWwH", i = "onyx-icon-zOP3d", a = "onyx-label-6yP76", o = "onyx-shortcut-NBjlt", s = "onyx-group-CHr24", c = "onyx-groupLabel-FVGET", l = "onyx-separator-RimQa", u = {
|
|
3
|
+
menu: e,
|
|
4
|
+
menuIn: t,
|
|
5
|
+
item: n,
|
|
6
|
+
destructive: r,
|
|
7
|
+
icon: i,
|
|
8
|
+
label: a,
|
|
9
|
+
shortcut: o,
|
|
10
|
+
group: s,
|
|
11
|
+
groupLabel: c,
|
|
12
|
+
separator: l
|
|
13
|
+
};
|
|
14
|
+
export { u as default, r as destructive, s as group, c as groupLabel, i as icon, n as item, a as label, e as menu, t as menuIn, l as separator, o as shortcut };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=DropdownMenu.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropdownMenu.module.js","names":["menu","menuIn","item","destructive","icon","label","shortcut","group","groupLabel","separator","DropdownMenu_module_default"],"sources":["../../../src/components/DropdownMenu/DropdownMenu.module.css"],"sourcesContent":[".menu {\n z-index: var(--z-index-dropdown);\n display: flex;\n flex-direction: column;\n min-width: var(--size-menu);\n max-width: var(--size-overlay-sm);\n padding: var(--space-1);\n overflow-y: auto;\n font-size: var(--font-size-sm);\n color: var(--color-text);\n background-color: var(--color-surface-raised);\n border: var(--border-width-thin) solid var(--color-border);\n border-radius: var(--radius-lg);\n box-shadow: var(--shadow-lg);\n outline: none;\n animation: menu-in var(--duration-fast) var(--easing-enter);\n}\n\n.item {\n display: flex;\n gap: var(--space-2);\n align-items: center;\n width: 100%;\n min-height: var(--size-control-sm);\n padding: var(--space-1) var(--space-2);\n font: inherit;\n color: inherit;\n text-align: start;\n cursor: pointer;\n background: transparent;\n border: 0;\n border-radius: var(--radius-md);\n outline: none;\n}\n\n.item:focus {\n background-color: var(--color-state-hover);\n}\n\n.item:focus-visible {\n outline: var(--focus-ring-width) solid var(--color-focus);\n outline-offset: calc(var(--focus-ring-width) * -1);\n}\n\n.item:active:not([aria-disabled='true']) {\n background-color: var(--color-state-active);\n}\n\n.item[aria-disabled='true'] {\n color: var(--color-text-disabled);\n cursor: not-allowed;\n}\n\n.destructive:not([aria-disabled='true']) {\n color: var(--color-danger-text);\n}\n\n.icon {\n display: inline-flex;\n flex-shrink: 0;\n font-size: var(--size-icon-sm);\n color: var(--color-text-muted);\n}\n\n.destructive .icon {\n color: inherit;\n}\n\n.label {\n flex: 1;\n min-width: 0;\n}\n\n.shortcut {\n margin-inline-start: var(--space-4);\n font-family: inherit;\n font-size: var(--font-size-xs);\n color: var(--color-text-muted);\n letter-spacing: var(--letter-spacing-wide);\n}\n\n.group {\n display: flex;\n flex-direction: column;\n}\n\n.groupLabel {\n padding: var(--space-2) var(--space-2) var(--space-1);\n font-size: var(--font-size-xs);\n font-weight: var(--font-weight-semibold);\n color: var(--color-text-muted);\n}\n\n.separator {\n height: var(--border-width-thin);\n margin: var(--space-1) calc(var(--space-1) * -1);\n background-color: var(--color-border);\n}\n\n@keyframes menu-in {\n from {\n opacity: 0;\n scale: 0.96;\n }\n}\n\n@media (pointer: coarse) {\n .item {\n min-height: var(--size-touch-target);\n }\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface EmptyStateProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
3
|
+
/** Short statement of what is missing, such as "No projects yet". */
|
|
4
|
+
title: ReactNode;
|
|
5
|
+
/** What the user can do about it. */
|
|
6
|
+
description?: ReactNode;
|
|
7
|
+
/** Illustration or icon shown above the title. It is decorative. */
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
/** Primary way forward, usually a `Button`. */
|
|
10
|
+
action?: ReactNode;
|
|
11
|
+
/** @default 'md' */
|
|
12
|
+
size?: 'sm' | 'md';
|
|
13
|
+
/**
|
|
14
|
+
* Level of the title heading. Match it to the outline of the page.
|
|
15
|
+
* @default 3
|
|
16
|
+
*/
|
|
17
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
18
|
+
}
|
|
19
|
+
/** Placeholder for a list, table or page that has no content yet or no results. */
|
|
20
|
+
export declare const EmptyState: import('react').ForwardRefExoticComponent<EmptyStateProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../utils/cn.js";
|
|
3
|
+
import t from "./EmptyState.module.js";
|
|
4
|
+
import { forwardRef as n } from "react";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
// src/components/EmptyState/EmptyState.tsx
|
|
7
|
+
var a = n(function({ title: n, description: a, icon: o, action: s, size: c = "md", headingLevel: l = 3, className: u, ...d }, f) {
|
|
8
|
+
let p = `h${l}`;
|
|
9
|
+
return /* @__PURE__ */ i("div", {
|
|
10
|
+
ref: f,
|
|
11
|
+
className: e(t.emptyState, t[c], u),
|
|
12
|
+
...d,
|
|
13
|
+
children: [
|
|
14
|
+
o && /* @__PURE__ */ r("div", {
|
|
15
|
+
className: t.icon,
|
|
16
|
+
"aria-hidden": "true",
|
|
17
|
+
children: o
|
|
18
|
+
}),
|
|
19
|
+
/* @__PURE__ */ r(p, {
|
|
20
|
+
className: t.title,
|
|
21
|
+
children: n
|
|
22
|
+
}),
|
|
23
|
+
a && /* @__PURE__ */ r("p", {
|
|
24
|
+
className: t.description,
|
|
25
|
+
children: a
|
|
26
|
+
}),
|
|
27
|
+
s && /* @__PURE__ */ r("div", {
|
|
28
|
+
className: t.action,
|
|
29
|
+
children: s
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
export { a as EmptyState };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=EmptyState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmptyState.js","names":["styles","EmptyState_module_default","EmptyState","forwardRef","props","Title","headingLevel","cn","size","className","icon","title","description","action"],"sources":["../../../src/components/EmptyState/EmptyState.tsx"],"sourcesContent":["import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';\nimport { cn } from '@/utils/cn';\nimport styles from './EmptyState.module.css';\n\nexport interface EmptyStateProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /** Short statement of what is missing, such as \"No projects yet\". */\n title: ReactNode;\n /** What the user can do about it. */\n description?: ReactNode;\n /** Illustration or icon shown above the title. It is decorative. */\n icon?: ReactNode;\n /** Primary way forward, usually a `Button`. */\n action?: ReactNode;\n /** @default 'md' */\n size?: 'sm' | 'md';\n /**\n * Level of the title heading. Match it to the outline of the page.\n * @default 3\n */\n headingLevel?: 2 | 3 | 4 | 5 | 6;\n}\n\n/** Placeholder for a list, table or page that has no content yet or no results. */\nexport const EmptyState = forwardRef<HTMLDivElement, EmptyStateProps>(function EmptyState(\n { title, description, icon, action, size = 'md', headingLevel = 3, className, ...props },\n ref,\n) {\n const Title = `h${headingLevel}` as const;\n\n return (\n <div ref={ref} className={cn(styles.emptyState, styles[size], className)} {...props}>\n {icon && (\n <div className={styles.icon} aria-hidden=\"true\">\n {icon}\n </div>\n )}\n <Title className={styles.title}>{title}</Title>\n {description && <p className={styles.description}>{description}</p>}\n {action && <div className={styles.action}>{action}</div>}\n </div>\n );\n});\n"],"mappings":";;;;;;AAuBA,IAAaE,IAAaC,EAA4C,SACpE,EAAE,UAAO,gBAAa,SAAM,WAAQ,UAAO,MAAM,kBAAe,GAAG,cAAW,GAAGC,KACjF,GACA;CACA,IAAMC,IAAQ,IAAIC;CAElB,OACE,kBAAC,OAAD;EAAU;EAAK,WAAWC,EAAGP,EAAO,YAAYA,EAAOQ,IAAOC,CAAS;EAAG,GAAIL;EAA9E,UAAA;GACGM,KACC,kBAAC,OAAD;IAAK,WAAWV,EAAO;IAAM,eAAY;IACtC,UAAAU;GACE,CAAA;GAEP,kBAACL,GAAD;IAAO,WAAWL,EAAO;IAAQ,UAAAW;GAAa,CAAA;GAC7CC,KAAe,kBAAC,KAAD;IAAG,WAAWZ,EAAO;IAAc,UAAAY;GAAe,CAAA;GACjEC,KAAU,kBAAC,OAAD;IAAK,WAAWb,EAAO;IAAS,UAAAa;GAAY,CAAA;EACpD;;AAET,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/components/EmptyState/EmptyState.module.css
|
|
2
|
+
var e = "onyx-emptyState-OlmHA", t = "onyx-sm-bnLtD", n = "onyx-icon-qVCyh", r = "onyx-title-xPfUf", i = "onyx-description-oWwH1", a = "onyx-action-dqxw1", o = {
|
|
3
|
+
emptyState: e,
|
|
4
|
+
sm: t,
|
|
5
|
+
icon: n,
|
|
6
|
+
title: r,
|
|
7
|
+
description: i,
|
|
8
|
+
action: a
|
|
9
|
+
};
|
|
10
|
+
export { a as action, o as default, i as description, e as emptyState, n as icon, t as sm, r as title };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=EmptyState.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmptyState.module.js","names":["emptyState","sm","icon","title","description","action","EmptyState_module_default"],"sources":["../../../src/components/EmptyState/EmptyState.module.css"],"sourcesContent":[".emptyState {\n display: flex;\n flex-direction: column;\n gap: var(--space-2);\n align-items: center;\n margin-inline: auto;\n max-width: var(--size-overlay-md);\n padding: var(--space-12) var(--space-6);\n text-align: center;\n}\n\n.sm {\n padding: var(--space-6) var(--space-4);\n}\n\n.icon {\n display: grid;\n place-items: center;\n width: var(--space-12);\n height: var(--space-12);\n margin-bottom: var(--space-2);\n font-size: var(--size-icon-lg);\n color: var(--color-text-muted);\n background-color: var(--color-bg-muted);\n border-radius: var(--radius-full);\n}\n\n.sm .icon {\n width: var(--size-control-md);\n height: var(--size-control-md);\n font-size: var(--size-icon-md);\n}\n\n.title {\n margin: 0;\n font-size: var(--font-size-lg);\n font-weight: var(--font-weight-semibold);\n line-height: var(--line-height-snug);\n color: var(--color-text);\n}\n\n.sm .title {\n font-size: var(--font-size-md);\n}\n\n.description {\n margin: 0;\n font-size: var(--font-size-sm);\n line-height: var(--line-height-normal);\n color: var(--color-text-muted);\n text-wrap: pretty;\n}\n\n.action {\n display: flex;\n flex-wrap: wrap;\n gap: var(--space-3);\n justify-content: center;\n margin-top: var(--space-4);\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export interface FormFieldProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** Visible caption, rendered as the `<label>` of the control. */
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
/** Hint shown below the control and linked with `aria-describedby`. */
|
|
6
|
+
helperText?: ReactNode;
|
|
7
|
+
/** Error message. Marks the control as invalid and is linked with `aria-describedby`. */
|
|
8
|
+
error?: ReactNode;
|
|
9
|
+
/** Marks the control as required and shows a marker next to the label. */
|
|
10
|
+
required?: boolean;
|
|
11
|
+
/** Disables the control. */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Keeps the label for assistive technology only. */
|
|
14
|
+
hideLabel?: boolean;
|
|
15
|
+
/** Id of the control. Generated when omitted. */
|
|
16
|
+
controlId?: string;
|
|
17
|
+
/** One `Input`, `Textarea`, `Select` or `Slider`, which picks up the field's id and state. */
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Wraps a form control with its label, helper text and error message, and wires them up with
|
|
22
|
+
* `htmlFor`, `aria-describedby` and `aria-invalid`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const FormField: import('react').ForwardRefExoticComponent<FormFieldProps & import('react').RefAttributes<HTMLDivElement>>;
|