@tryghost/shade 0.1.0-alpha.5 → 0.1.0-alpha.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -67
- package/es/app.js +2 -1
- package/es/assets/images/index.js +2 -2
- package/es/components/page-templates/list-page.js +3 -2
- package/es/components/page-templates/list-page.js.map +1 -1
- package/es/components/patterns/color-picker.js +79 -56
- package/es/components/patterns/color-picker.js.map +1 -1
- package/es/components/patterns/filter-bar.js +4 -6
- package/es/components/patterns/filter-bar.js.map +1 -1
- package/es/components/patterns/filters-sheet.js +178 -0
- package/es/components/patterns/filters-sheet.js.map +1 -0
- package/es/components/patterns/filters.js +195 -80
- package/es/components/patterns/filters.js.map +1 -1
- package/es/components/patterns/gh-chart.js +6 -3
- package/es/components/patterns/gh-chart.js.map +1 -1
- package/es/components/patterns/image-upload.js +21 -16
- package/es/components/patterns/image-upload.js.map +1 -1
- package/es/components/patterns/kpi-tabs.js +4 -1
- package/es/components/patterns/kpi-tabs.js.map +1 -1
- package/es/components/patterns/page-header.js +21 -45
- package/es/components/patterns/page-header.js.map +1 -1
- package/es/components/patterns/setting-group-variants.js +1 -1
- package/es/components/patterns/setting-group-variants.js.map +1 -1
- package/es/components/patterns/setting-group.js +2 -2
- package/es/components/patterns/setting-group.js.map +1 -1
- package/es/components/patterns/settings-modal-variants.js +3 -0
- package/es/components/patterns/settings-modal-variants.js.map +1 -1
- package/es/components/patterns/settings-modal.js +10 -3
- package/es/components/patterns/settings-modal.js.map +1 -1
- package/es/components/patterns/share-modal.js +5 -17
- package/es/components/patterns/share-modal.js.map +1 -1
- package/es/components/patterns/use-mobile-filters.js +20 -0
- package/es/components/patterns/use-mobile-filters.js.map +1 -0
- package/es/components/ui/alert-dialog.js +25 -15
- package/es/components/ui/alert-dialog.js.map +1 -1
- package/es/components/ui/avatar.js +8 -4
- package/es/components/ui/avatar.js.map +1 -1
- package/es/components/ui/badge-variants.js +2 -1
- package/es/components/ui/badge-variants.js.map +1 -1
- package/es/components/ui/banner-variants.js +13 -5
- package/es/components/ui/banner-variants.js.map +1 -1
- package/es/components/ui/banner.js +9 -3
- package/es/components/ui/banner.js.map +1 -1
- package/es/components/ui/button-variants.js +2 -33
- package/es/components/ui/button-variants.js.map +1 -1
- package/es/components/ui/button.js +17 -5
- package/es/components/ui/button.js.map +1 -1
- package/es/components/ui/calendar.js +5 -6
- package/es/components/ui/calendar.js.map +1 -1
- package/es/components/ui/card-variants.js +3 -2
- package/es/components/ui/card-variants.js.map +1 -1
- package/es/components/ui/card.js +7 -4
- package/es/components/ui/card.js.map +1 -1
- package/es/components/ui/chart.js +2 -29
- package/es/components/ui/chart.js.map +1 -1
- package/es/components/ui/checkbox.js +1 -1
- package/es/components/ui/checkbox.js.map +1 -1
- package/es/components/ui/code-editor-view.js +1 -1
- package/es/components/ui/code-editor-view.js.map +1 -1
- package/es/components/ui/combobox.js +1 -1
- package/es/components/ui/combobox.js.map +1 -1
- package/es/components/ui/command.js +1 -14
- package/es/components/ui/command.js.map +1 -1
- package/es/components/ui/context-menu.js +18 -8
- package/es/components/ui/context-menu.js.map +1 -1
- package/es/components/ui/copy-field.js +2 -4
- package/es/components/ui/copy-field.js.map +1 -1
- package/es/components/ui/data-list.js +2 -4
- package/es/components/ui/data-list.js.map +1 -1
- package/es/components/ui/dialog.js +53 -11
- package/es/components/ui/dialog.js.map +1 -1
- package/es/components/ui/dropdown-menu.js +20 -10
- package/es/components/ui/dropdown-menu.js.map +1 -1
- package/es/components/ui/dropzone-variants.js +26 -10
- package/es/components/ui/dropzone-variants.js.map +1 -1
- package/es/components/ui/dropzone.js +2 -2
- package/es/components/ui/dropzone.js.map +1 -1
- package/es/components/ui/field.js +4 -4
- package/es/components/ui/field.js.map +1 -1
- package/es/components/ui/floating-sidebar.js +69 -18
- package/es/components/ui/floating-sidebar.js.map +1 -1
- package/es/components/ui/hover-card.js +13 -7
- package/es/components/ui/hover-card.js.map +1 -1
- package/es/components/ui/icon.js +1 -1
- package/es/components/ui/image-overlay-button.js +2 -2
- package/es/components/ui/image-overlay-button.js.map +1 -1
- package/es/components/ui/indicator-variants.js +2 -2
- package/es/components/ui/indicator-variants.js.map +1 -1
- package/es/components/ui/input-group-variants.js +5 -5
- package/es/components/ui/input-group-variants.js.map +1 -1
- package/es/components/ui/input-group.js +4 -7
- package/es/components/ui/input-group.js.map +1 -1
- package/es/components/ui/input-surface.js +5 -4
- package/es/components/ui/input-surface.js.map +1 -1
- package/es/components/ui/input.js +1 -1
- package/es/components/ui/input.js.map +1 -1
- package/es/components/ui/list.js +94 -0
- package/es/components/ui/list.js.map +1 -0
- package/es/components/ui/navbar.js +1 -3
- package/es/components/ui/navbar.js.map +1 -1
- package/es/components/ui/pagemenu.js +51 -15
- package/es/components/ui/pagemenu.js.map +1 -1
- package/es/components/ui/popover.js +14 -8
- package/es/components/ui/popover.js.map +1 -1
- package/es/components/ui/radio-group-variants.js +1 -1
- package/es/components/ui/radio-group-variants.js.map +1 -1
- package/es/components/ui/row-primary-action.js +48 -0
- package/es/components/ui/row-primary-action.js.map +1 -0
- package/es/components/ui/row-surface.js +18 -0
- package/es/components/ui/row-surface.js.map +1 -0
- package/es/components/ui/select-variants.js +6 -14
- package/es/components/ui/select-variants.js.map +1 -1
- package/es/components/ui/select.js +26 -19
- package/es/components/ui/select.js.map +1 -1
- package/es/components/ui/sheet.js +32 -19
- package/es/components/ui/sheet.js.map +1 -1
- package/es/components/ui/sidebar.js +2 -2
- package/es/components/ui/simple-pagination.js +4 -7
- package/es/components/ui/simple-pagination.js.map +1 -1
- package/es/components/ui/sortable-list.js +110 -11
- package/es/components/ui/sortable-list.js.map +1 -1
- package/es/components/ui/sticky-footer.js +62 -22
- package/es/components/ui/sticky-footer.js.map +1 -1
- package/es/components/ui/table.js +20 -9
- package/es/components/ui/table.js.map +1 -1
- package/es/components/ui/tabs-variants.js +23 -1
- package/es/components/ui/tabs-variants.js.map +1 -1
- package/es/components/ui/tabs.js +102 -21
- package/es/components/ui/tabs.js.map +1 -1
- package/es/components/ui/textarea.js +1 -1
- package/es/components/ui/textarea.js.map +1 -1
- package/es/components/ui/toast.js +2 -0
- package/es/components/ui/toggle-group.js +1 -3
- package/es/components/ui/toggle-group.js.map +1 -1
- package/es/components/ui/toggle-variants.js +1 -7
- package/es/components/ui/toggle-variants.js.map +1 -1
- package/es/components/ui/toggle.js +1 -2
- package/es/components/ui/toggle.js.map +1 -1
- package/es/components/ui/token-field.js +3 -3
- package/es/components/ui/token-field.js.map +1 -1
- package/es/components/ui/tooltip.js +81 -40
- package/es/components/ui/tooltip.js.map +1 -1
- package/es/components/ui/trend-badge.js +46 -12
- package/es/components/ui/trend-badge.js.map +1 -1
- package/es/components.js +24 -21
- package/es/hooks/use-row-behavior.js +94 -0
- package/es/hooks/use-row-behavior.js.map +1 -0
- package/es/hooks/use-row-press.js +63 -0
- package/es/hooks/use-row-press.js.map +1 -0
- package/es/{icon-BJcGsQ4b.js → icon--CakqPdG.js} +15 -19
- package/es/icon--CakqPdG.js.map +1 -0
- package/es/{images-CUcakpOD.js → images-F6slcZrB.js} +16 -42
- package/es/images-F6slcZrB.js.map +1 -0
- package/es/index.js +43 -39
- package/es/lib/app-overlay.js +184 -0
- package/es/lib/app-overlay.js.map +1 -0
- package/es/lib/date-utils.js +151 -0
- package/es/lib/date-utils.js.map +1 -0
- package/es/lib/ds-utils.js +16 -72
- package/es/lib/ds-utils.js.map +1 -1
- package/es/lib/safe-area.js +168 -0
- package/es/lib/safe-area.js.map +1 -0
- package/es/lib/svg-graphic.js +32 -0
- package/es/lib/svg-graphic.js.map +1 -0
- package/es/lib/toast-press.js +11 -0
- package/es/lib/toast-press.js.map +1 -0
- package/es/lib/utils.js +3 -2
- package/es/patterns.js +2 -1
- package/es/providers/header-tooltip-provider.js +1 -4
- package/es/providers/header-tooltip-provider.js.map +1 -1
- package/es/providers/shade-context.js +2 -1
- package/es/providers/shade-context.js.map +1 -1
- package/es/providers/shade-provider.js +28 -13
- package/es/providers/shade-provider.js.map +1 -1
- package/es/shade-app.js +22 -6
- package/es/shade-app.js.map +1 -1
- package/es/shade-scope.js +3 -2
- package/es/shade-scope.js.map +1 -1
- package/es/tokens.js +56 -8
- package/es/tokens.js.map +1 -1
- package/es/utils.js +3 -2
- package/package.json +7 -7
- package/preflight.css +0 -10
- package/styles.css +469 -12
- package/tailwind.theme.css +237 -187
- package/theme-variables.css +412 -44
- package/types/app.d.ts +7 -5
- package/types/app.d.ts.map +1 -1
- package/types/assets/images/index.d.ts +3 -3
- package/types/assets/images/index.d.ts.map +1 -1
- package/types/components/page-templates/list-page.d.ts +2 -1
- package/types/components/page-templates/list-page.d.ts.map +1 -1
- package/types/components/page-templates/modal-page.d.ts +1 -1
- package/types/components/patterns/color-picker.d.ts +7 -2
- package/types/components/patterns/color-picker.d.ts.map +1 -1
- package/types/components/patterns/filter-bar.d.ts +2 -2
- package/types/components/patterns/filter-bar.d.ts.map +1 -1
- package/types/components/patterns/filters-helpers.d.ts +1 -1
- package/types/components/patterns/filters-sheet.d.ts +19 -0
- package/types/components/patterns/filters-sheet.d.ts.map +1 -0
- package/types/components/patterns/filters.d.ts +13 -6
- package/types/components/patterns/filters.d.ts.map +1 -1
- package/types/components/patterns/gh-chart.d.ts.map +1 -1
- package/types/components/patterns/image-upload.d.ts +3 -3
- package/types/components/patterns/image-upload.d.ts.map +1 -1
- package/types/components/patterns/kpi-tabs.d.ts +5 -2
- package/types/components/patterns/kpi-tabs.d.ts.map +1 -1
- package/types/components/patterns/page-header.d.ts +17 -14
- package/types/components/patterns/page-header.d.ts.map +1 -1
- package/types/components/patterns/setting-group.d.ts +8 -8
- package/types/components/patterns/settings-modal-variants.d.ts +3 -0
- package/types/components/patterns/settings-modal-variants.d.ts.map +1 -1
- package/types/components/patterns/settings-modal.d.ts +12 -3
- package/types/components/patterns/settings-modal.d.ts.map +1 -1
- package/types/components/patterns/share-modal.d.ts +3 -3
- package/types/components/patterns/share-modal.d.ts.map +1 -1
- package/types/components/patterns/use-dirty-confirmation.d.ts +1 -1
- package/types/components/patterns/use-mobile-filters.d.ts +2 -0
- package/types/components/patterns/use-mobile-filters.d.ts.map +1 -0
- package/types/components/ui/alert-dialog.d.ts +2 -2
- package/types/components/ui/alert-dialog.d.ts.map +1 -1
- package/types/components/ui/avatar.d.ts.map +1 -1
- package/types/components/ui/badge-variants.d.ts +1 -1
- package/types/components/ui/badge-variants.d.ts.map +1 -1
- package/types/components/ui/badge.d.ts +1 -1
- package/types/components/ui/banner-variants.d.ts +1 -1
- package/types/components/ui/banner-variants.d.ts.map +1 -1
- package/types/components/ui/banner.d.ts +3 -1
- package/types/components/ui/banner.d.ts.map +1 -1
- package/types/components/ui/button-variants.d.ts +0 -1
- package/types/components/ui/button-variants.d.ts.map +1 -1
- package/types/components/ui/button.d.ts +7 -2
- package/types/components/ui/button.d.ts.map +1 -1
- package/types/components/ui/calendar.d.ts +1 -1
- package/types/components/ui/calendar.d.ts.map +1 -1
- package/types/components/ui/card-variants.d.ts +1 -1
- package/types/components/ui/card-variants.d.ts.map +1 -1
- package/types/components/ui/card.d.ts +1 -1
- package/types/components/ui/card.d.ts.map +1 -1
- package/types/components/ui/chart.d.ts +1 -17
- package/types/components/ui/chart.d.ts.map +1 -1
- package/types/components/ui/code-editor.d.ts +1 -1
- package/types/components/ui/command.d.ts +1 -6
- package/types/components/ui/command.d.ts.map +1 -1
- package/types/components/ui/context-menu.d.ts +1 -1
- package/types/components/ui/context-menu.d.ts.map +1 -1
- package/types/components/ui/copy-field.d.ts +1 -1
- package/types/components/ui/copy-field.d.ts.map +1 -1
- package/types/components/ui/data-list.d.ts.map +1 -1
- package/types/components/ui/dialog.d.ts +11 -2
- package/types/components/ui/dialog.d.ts.map +1 -1
- package/types/components/ui/dropdown-menu.d.ts +1 -1
- package/types/components/ui/dropdown-menu.d.ts.map +1 -1
- package/types/components/ui/dropzone-variants.d.ts +3 -2
- package/types/components/ui/dropzone-variants.d.ts.map +1 -1
- package/types/components/ui/dropzone.d.ts +1 -1
- package/types/components/ui/field.d.ts +1 -1
- package/types/components/ui/field.d.ts.map +1 -1
- package/types/components/ui/floating-sidebar.d.ts +12 -3
- package/types/components/ui/floating-sidebar.d.ts.map +1 -1
- package/types/components/ui/hover-card.d.ts.map +1 -1
- package/types/components/ui/icon.d.ts +2 -1
- package/types/components/ui/icon.d.ts.map +1 -1
- package/types/components/ui/image-overlay-button.d.ts +1 -1
- package/types/components/ui/image-overlay-button.d.ts.map +1 -1
- package/types/components/ui/indicator.d.ts +1 -1
- package/types/components/ui/input-group-variants.d.ts.map +1 -1
- package/types/components/ui/input-group.d.ts +2 -2
- package/types/components/ui/input-group.d.ts.map +1 -1
- package/types/components/ui/input-surface.d.ts +4 -3
- package/types/components/ui/input-surface.d.ts.map +1 -1
- package/types/components/ui/list.d.ts +28 -0
- package/types/components/ui/list.d.ts.map +1 -0
- package/types/components/ui/multi-select-combobox.d.ts +1 -1
- package/types/components/ui/navbar.d.ts.map +1 -1
- package/types/components/ui/pagemenu.d.ts +3 -0
- package/types/components/ui/pagemenu.d.ts.map +1 -1
- package/types/components/ui/popover.d.ts.map +1 -1
- package/types/components/ui/preview-chrome.d.ts +1 -1
- package/types/components/ui/row-primary-action.d.ts +8 -0
- package/types/components/ui/row-primary-action.d.ts.map +1 -0
- package/types/components/ui/row-surface.d.ts +11 -0
- package/types/components/ui/row-surface.d.ts.map +1 -0
- package/types/components/ui/select-variants.d.ts +0 -1
- package/types/components/ui/select-variants.d.ts.map +1 -1
- package/types/components/ui/select.d.ts +2 -2
- package/types/components/ui/select.d.ts.map +1 -1
- package/types/components/ui/sheet.d.ts +1 -1
- package/types/components/ui/sheet.d.ts.map +1 -1
- package/types/components/ui/sidebar.d.ts +2 -2
- package/types/components/ui/simple-pagination.d.ts.map +1 -1
- package/types/components/ui/sortable-list.d.ts +4 -1
- package/types/components/ui/sortable-list.d.ts.map +1 -1
- package/types/components/ui/sticky-footer.d.ts +9 -2
- package/types/components/ui/sticky-footer.d.ts.map +1 -1
- package/types/components/ui/table.d.ts +4 -1
- package/types/components/ui/table.d.ts.map +1 -1
- package/types/components/ui/tabs-variants.d.ts +5 -1
- package/types/components/ui/tabs-variants.d.ts.map +1 -1
- package/types/components/ui/tabs.d.ts.map +1 -1
- package/types/components/ui/toast.d.ts +2 -0
- package/types/components/ui/toast.d.ts.map +1 -0
- package/types/components/ui/toggle-group.d.ts +4 -6
- package/types/components/ui/toggle-group.d.ts.map +1 -1
- package/types/components/ui/toggle-variants.d.ts +0 -1
- package/types/components/ui/toggle-variants.d.ts.map +1 -1
- package/types/components/ui/toggle.d.ts +2 -3
- package/types/components/ui/toggle.d.ts.map +1 -1
- package/types/components/ui/token-field.d.ts +2 -2
- package/types/components/ui/token-field.d.ts.map +1 -1
- package/types/components/ui/tooltip.d.ts.map +1 -1
- package/types/components/ui/trend-badge.d.ts +1 -0
- package/types/components/ui/trend-badge.d.ts.map +1 -1
- package/types/components.d.ts +5 -2
- package/types/components.d.ts.map +1 -1
- package/types/hooks/use-row-behavior.d.ts +24 -0
- package/types/hooks/use-row-behavior.d.ts.map +1 -0
- package/types/hooks/use-row-press.d.ts +11 -0
- package/types/hooks/use-row-press.d.ts.map +1 -0
- package/types/lib/app-overlay.d.ts +63 -0
- package/types/lib/app-overlay.d.ts.map +1 -0
- package/types/lib/date-utils.d.ts +17 -0
- package/types/lib/date-utils.d.ts.map +1 -0
- package/types/lib/ds-utils.d.ts +2 -16
- package/types/lib/ds-utils.d.ts.map +1 -1
- package/types/lib/safe-area.d.ts +27 -0
- package/types/lib/safe-area.d.ts.map +1 -0
- package/types/lib/svg-graphic.d.ts +22 -0
- package/types/lib/svg-graphic.d.ts.map +1 -0
- package/types/lib/toast-press.d.ts +4 -0
- package/types/lib/toast-press.d.ts.map +1 -0
- package/types/lib/utils.d.ts +1 -0
- package/types/lib/utils.d.ts.map +1 -1
- package/types/patterns.d.ts +1 -0
- package/types/patterns.d.ts.map +1 -1
- package/types/providers/header-tooltip-provider.d.ts.map +1 -1
- package/types/providers/shade-context.d.ts +4 -1
- package/types/providers/shade-context.d.ts.map +1 -1
- package/types/providers/shade-provider.d.ts +5 -2
- package/types/providers/shade-provider.d.ts.map +1 -1
- package/types/shade-app.d.ts +11 -3
- package/types/shade-app.d.ts.map +1 -1
- package/types/shade-scope.d.ts.map +1 -1
- package/types/tokens.d.ts +1 -1
- package/types/tokens.d.ts.map +1 -1
- package/types/utils.d.ts +2 -1
- package/types/utils.d.ts.map +1 -1
- package/es/components/ui/action-list.js +0 -56
- package/es/components/ui/action-list.js.map +0 -1
- package/es/icon-BJcGsQ4b.js.map +0 -1
- package/es/images-CUcakpOD.js.map +0 -1
- package/types/components/ui/action-list.d.ts +0 -21
- package/types/components/ui/action-list.d.ts.map +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { cn } from "../../lib/ds-utils.js";
|
|
2
|
+
import { rowSurface, rowSurfaceClasses } from "./row-surface.js";
|
|
3
|
+
import { useRowBehavior } from "../../hooks/use-row-behavior.js";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
8
|
+
//#region src/components/ui/list.tsx
|
|
9
|
+
var List = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", {
|
|
10
|
+
ref,
|
|
11
|
+
className: cn("flex flex-col", className),
|
|
12
|
+
...props
|
|
13
|
+
}));
|
|
14
|
+
List.displayName = "List";
|
|
15
|
+
var rowEvents = [
|
|
16
|
+
"onClick",
|
|
17
|
+
"onClickCapture",
|
|
18
|
+
"onAuxClick",
|
|
19
|
+
"onPointerDown",
|
|
20
|
+
"onPointerMove",
|
|
21
|
+
"onPointerUp",
|
|
22
|
+
"onPointerCancel",
|
|
23
|
+
"onPointerLeave"
|
|
24
|
+
];
|
|
25
|
+
var ListItem = React$1.forwardRef(({ asChild = false, className, hover, children, ...props }, ref) => {
|
|
26
|
+
const child = asChild && React$1.isValidElement(children) ? children : void 0;
|
|
27
|
+
const rowProps = { ...props };
|
|
28
|
+
if (child) for (const name of rowEvents) {
|
|
29
|
+
const childHandler = child.props[name];
|
|
30
|
+
const ownHandler = props[name];
|
|
31
|
+
if (childHandler) rowProps[name] = ((event) => {
|
|
32
|
+
childHandler(event);
|
|
33
|
+
ownHandler?.(event);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const behavior = useRowBehavior(rowProps, hover === null ? false : hover);
|
|
37
|
+
const Component = asChild ? Slot : "div";
|
|
38
|
+
const slotChild = child ? React$1.cloneElement(child, Object.fromEntries(rowEvents.map((name) => [name, void 0]))) : children;
|
|
39
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
40
|
+
ref,
|
|
41
|
+
className: cn(!asChild && "relative flex min-w-0 items-stretch border-b border-border last:border-b-transparent", "group/action-list-item", rowSurface(hover === false || hover === null ? "static" : hover || rowProps.onClick ? "interactive" : "auto"), className),
|
|
42
|
+
...rowProps,
|
|
43
|
+
...behavior,
|
|
44
|
+
children: slotChild
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
ListItem.displayName = "ListItem";
|
|
48
|
+
var ListItemContent = React$1.forwardRef(({ asChild = false, className, children, ...props }, ref) => {
|
|
49
|
+
const [nativeControl, setNativeControl] = React$1.useState(false);
|
|
50
|
+
const setRef = React$1.useCallback((element) => {
|
|
51
|
+
setNativeControl(Boolean(asChild && element?.matches("a[href], button, input[type=\"submit\"], input[type=\"button\"], [role=\"button\"], [role=\"link\"]")));
|
|
52
|
+
if (typeof ref === "function") ref(element);
|
|
53
|
+
else if (ref) ref.current = element;
|
|
54
|
+
}, [asChild, ref]);
|
|
55
|
+
const child = asChild && React$1.isValidElement(children) ? children : void 0;
|
|
56
|
+
const isAction = child && (nativeControl || typeof child.type === "string" && ["a", "button"].includes(child.type) || child.props.href !== void 0 || child.props.onClick || props.onClick);
|
|
57
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "div", {
|
|
58
|
+
ref: setRef,
|
|
59
|
+
className: cn("min-w-0 grow", isAction && rowSurfaceClasses.primaryAction, className),
|
|
60
|
+
...props,
|
|
61
|
+
children
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
ListItemContent.displayName = "ListItemContent";
|
|
65
|
+
var listItemActionsVariants = cva("flex shrink-0 items-center py-3 pl-2 [&>*]:relative [&>*]:z-10", {
|
|
66
|
+
variants: { visibility: {
|
|
67
|
+
always: "",
|
|
68
|
+
hover: "md:opacity-0 md:transition-opacity md:group-focus-within/action-list-item:opacity-100 md:group-hover/action-list-item:opacity-100"
|
|
69
|
+
} },
|
|
70
|
+
defaultVariants: { visibility: "always" }
|
|
71
|
+
});
|
|
72
|
+
var ListItemActions = React$1.forwardRef(({ className, visibility, ...props }, ref) => {
|
|
73
|
+
return /* @__PURE__ */ jsx("div", {
|
|
74
|
+
ref,
|
|
75
|
+
className: cn(listItemActionsVariants({
|
|
76
|
+
visibility,
|
|
77
|
+
className
|
|
78
|
+
})),
|
|
79
|
+
...props
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
ListItemActions.displayName = "ListItemActions";
|
|
83
|
+
/** @deprecated Use List instead. */
|
|
84
|
+
var ActionList = List;
|
|
85
|
+
/** @deprecated Use ListItem instead. */
|
|
86
|
+
var ActionListItem = ListItem;
|
|
87
|
+
/** @deprecated Use ListItemActions instead. */
|
|
88
|
+
var ActionListItemActions = ListItemActions;
|
|
89
|
+
/** @deprecated Use ListItemContent instead. */
|
|
90
|
+
var ActionListItemContent = ListItemContent;
|
|
91
|
+
//#endregion
|
|
92
|
+
export { ActionList, ActionListItem, ActionListItemActions, ActionListItemContent, List, ListItem, ListItemActions, ListItemContent };
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","names":[],"sources":["../../../src/components/ui/list.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport { type VariantProps, cva } from 'class-variance-authority';\nimport * as React from 'react';\n\nimport { cn } from '@/lib/utils';\nimport { rowSurface, rowSurfaceClasses } from '@/components/ui/row-surface';\nimport { useRowBehavior } from '@/hooks/use-row-behavior';\n\nconst List = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => (\n <div ref={ref} className={cn('flex flex-col', className)} {...props} />\n ),\n);\nList.displayName = 'List';\n\ninterface ListItemProps extends React.HTMLAttributes<HTMLDivElement> {\n asChild?: boolean;\n hover?: boolean | null;\n}\n\nconst rowEvents = [\n 'onClick',\n 'onClickCapture',\n 'onAuxClick',\n 'onPointerDown',\n 'onPointerMove',\n 'onPointerUp',\n 'onPointerCancel',\n 'onPointerLeave',\n] as const;\n\nconst ListItem = React.forwardRef<HTMLDivElement, ListItemProps>(\n ({ asChild = false, className, hover, children, ...props }, ref) => {\n const child =\n asChild && React.isValidElement<React.HTMLAttributes<HTMLDivElement>>(children)\n ? children\n : undefined;\n const rowProps = { ...props };\n if (child) {\n for (const name of rowEvents) {\n const childHandler = child.props[name];\n const ownHandler = props[name];\n if (childHandler) {\n // The Slot would otherwise call the child's handler a second time.\n rowProps[name] = ((event: never) => {\n childHandler(event);\n ownHandler?.(event);\n }) as typeof childHandler;\n }\n }\n }\n const behavior = useRowBehavior(rowProps, hover === null ? false : hover);\n const Component = asChild ? Slot : 'div';\n const slotChild = child\n ? React.cloneElement(child, Object.fromEntries(rowEvents.map((name) => [name, undefined])))\n : children;\n return (\n <Component\n ref={ref}\n className={cn(\n !asChild &&\n 'relative flex min-w-0 items-stretch border-b border-border last:border-b-transparent',\n 'group/action-list-item',\n rowSurface(\n hover === false || hover === null\n ? 'static'\n : hover || rowProps.onClick\n ? 'interactive'\n : 'auto',\n ),\n className,\n )}\n {...rowProps}\n {...behavior}\n >\n {slotChild}\n </Component>\n );\n },\n);\nListItem.displayName = 'ListItem';\n\ninterface ListItemContentProps extends React.HTMLAttributes<HTMLDivElement> {\n asChild?: boolean;\n}\n\nconst ListItemContent = React.forwardRef<HTMLDivElement, ListItemContentProps>(\n ({ asChild = false, className, children, ...props }, ref) => {\n // Composed links render controls; layout components do not.\n const [nativeControl, setNativeControl] = React.useState(false);\n const setRef = React.useCallback(\n (element: HTMLDivElement | null) => {\n setNativeControl(\n Boolean(\n asChild &&\n element?.matches(\n 'a[href], button, input[type=\"submit\"], input[type=\"button\"], [role=\"button\"], [role=\"link\"]',\n ),\n ),\n );\n if (typeof ref === 'function') {\n ref(element);\n } else if (ref) {\n ref.current = element;\n }\n },\n [asChild, ref],\n );\n const child =\n asChild && React.isValidElement<React.AnchorHTMLAttributes<HTMLElement>>(children)\n ? children\n : undefined;\n const isAction =\n child &&\n (nativeControl ||\n (typeof child.type === 'string' && ['a', 'button'].includes(child.type)) ||\n child.props.href !== undefined ||\n child.props.onClick ||\n props.onClick);\n const Component = asChild ? Slot : 'div';\n\n return (\n <Component\n ref={setRef}\n className={cn('min-w-0 grow', isAction && rowSurfaceClasses.primaryAction, className)}\n {...props}\n >\n {children}\n </Component>\n );\n },\n);\nListItemContent.displayName = 'ListItemContent';\n\nconst listItemActionsVariants = cva(\n 'flex shrink-0 items-center py-3 pl-2 [&>*]:relative [&>*]:z-10',\n {\n variants: {\n visibility: {\n always: '',\n hover:\n 'md:opacity-0 md:transition-opacity md:group-focus-within/action-list-item:opacity-100 md:group-hover/action-list-item:opacity-100',\n },\n },\n defaultVariants: {\n visibility: 'always',\n },\n },\n);\n\ninterface ListItemActionsProps\n extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof listItemActionsVariants> {}\n\nconst ListItemActions = React.forwardRef<HTMLDivElement, ListItemActionsProps>(\n ({ className, visibility, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn(listItemActionsVariants({ visibility, className }))}\n {...props}\n />\n );\n },\n);\nListItemActions.displayName = 'ListItemActions';\n\n/** @deprecated Use List instead. */\nconst ActionList = List;\n/** @deprecated Use ListItem instead. */\nconst ActionListItem = ListItem;\n/** @deprecated Use ListItemActions instead. */\nconst ActionListItemActions = ListItemActions;\n/** @deprecated Use ListItemContent instead. */\nconst ActionListItemContent = ListItemContent;\n\nexport {\n List,\n ListItem,\n ListItemActions,\n ListItemContent,\n ActionList,\n ActionListItem,\n ActionListItemActions,\n ActionListItemContent,\n};\n"],"mappings":";;;;;;;;AAQA,IAAM,OAAO,QAAM,YAChB,EAAE,WAAW,GAAG,SAAS,QACxB,oBAAC,OAAD;CAAU;CAAK,WAAW,GAAG,iBAAiB,SAAS;CAAG,GAAI;AAAQ,CAAA,CAE1E;AACA,KAAK,cAAc;AAOnB,IAAM,YAAY;CAChB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAM,WAAW,QAAM,YACpB,EAAE,UAAU,OAAO,WAAW,OAAO,UAAU,GAAG,SAAS,QAAQ;CAClE,MAAM,QACJ,WAAW,QAAM,eAAqD,QAAQ,IAC1E,WACA,KAAA;CACN,MAAM,WAAW,EAAE,GAAG,MAAM;CAC5B,IAAI,OACF,KAAK,MAAM,QAAQ,WAAW;EAC5B,MAAM,eAAe,MAAM,MAAM;EACjC,MAAM,aAAa,MAAM;EACzB,IAAI,cAEF,SAAS,UAAU,UAAiB;GAClC,aAAa,KAAK;GAClB,aAAa,KAAK;EACpB;CAEJ;CAEF,MAAM,WAAW,eAAe,UAAU,UAAU,OAAO,QAAQ,KAAK;CACxE,MAAM,YAAY,UAAU,OAAO;CACnC,MAAM,YAAY,QACd,QAAM,aAAa,OAAO,OAAO,YAAY,UAAU,KAAK,SAAS,CAAC,MAAM,KAAA,CAAS,CAAC,CAAC,CAAC,IACxF;CACJ,OACE,oBAAC,WAAD;EACO;EACL,WAAW,GACT,CAAC,WACC,wFACF,0BACA,WACE,UAAU,SAAS,UAAU,OACzB,WACA,SAAS,SAAS,UAChB,gBACA,MACR,GACA,SACF;EACA,GAAI;EACJ,GAAI;YAEH;CACQ,CAAA;AAEf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|
-
import { useShade } from "../../providers/shade-context.js";
|
|
3
2
|
import { HeaderTooltipProvider } from "../../providers/header-tooltip-provider.js";
|
|
4
3
|
import React from "react";
|
|
5
4
|
import { jsx } from "react/jsx-runtime";
|
|
6
5
|
//#region src/components/ui/navbar.tsx
|
|
7
6
|
var NavbarActions = React.forwardRef(({ children, className, ...props }, ref) => {
|
|
8
|
-
const { isAdmin7 } = useShade();
|
|
9
7
|
return /* @__PURE__ */ jsx(HeaderTooltipProvider, { children: /* @__PURE__ */ jsx("div", {
|
|
10
8
|
ref,
|
|
11
|
-
className: cn("mt-3 flex items-center [grid-area:actions] lg:mt-0",
|
|
9
|
+
className: cn("mt-3 flex items-center gap-1 [grid-area:actions] lg:mt-0", className),
|
|
12
10
|
"data-navbar": "navbar-actions",
|
|
13
11
|
...props,
|
|
14
12
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navbar.js","names":[],"sources":["../../../src/components/ui/navbar.tsx"],"sourcesContent":["import { HeaderTooltipProvider } from '@/providers/header-tooltip-provider';\nimport {
|
|
1
|
+
{"version":3,"file":"navbar.js","names":[],"sources":["../../../src/components/ui/navbar.tsx"],"sourcesContent":["import { HeaderTooltipProvider } from '@/providers/header-tooltip-provider';\nimport { cn } from '@/lib/utils';\nimport React from 'react';\n\ninterface NavbarActionsProps {\n children?: React.ReactNode;\n className?: string;\n}\n\nconst NavbarActions = React.forwardRef<HTMLDivElement, NavbarActionsProps>(\n ({ children, className, ...props }, ref) => {\n return (\n <HeaderTooltipProvider>\n <div\n ref={ref}\n className={cn('mt-3 flex items-center gap-1 [grid-area:actions] lg:mt-0', className)}\n data-navbar=\"navbar-actions\"\n {...props}\n >\n {children}\n </div>\n </HeaderTooltipProvider>\n );\n },\n);\n\nNavbarActions.displayName = 'NavbarActions';\n\ninterface NavbarNavigationProps {\n children?: React.ReactNode;\n className?: string;\n}\n\nconst NavbarNavigation = React.forwardRef<HTMLDivElement, NavbarNavigationProps>(\n ({ children, className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn('[grid-area:navigation]', className)}\n data-navbar=\"navbar-navigation\"\n {...props}\n >\n {children}\n </div>\n );\n },\n);\n\nNavbarNavigation.displayName = 'NavbarNavigation';\n\ninterface NavbarProps {\n children?: React.ReactNode;\n className?: string;\n}\n\nconst Navbar = React.forwardRef<HTMLDivElement, NavbarProps>(\n ({ children, className, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn(\n `grid grid-cols-[1fr] justify-between gap-x-5 gap-y-2 border-b [grid-template-areas:'navigation''actions''subactions'] lg:grid-cols-[1fr_auto] lg:[grid-template-areas:'navigation_actions''subactions_subactions']`,\n className,\n )}\n data-navbar=\"navbar\"\n {...props}\n >\n {children}\n </div>\n );\n },\n);\n\nNavbar.displayName = 'Navbar';\n\nexport { NavbarActions, NavbarNavigation, Navbar };\n"],"mappings":";;;;;AASA,IAAM,gBAAgB,MAAM,YACzB,EAAE,UAAU,WAAW,GAAG,SAAS,QAAQ;CAC1C,OACE,oBAAC,uBAAD,EAAA,UACE,oBAAC,OAAD;EACO;EACL,WAAW,GAAG,4DAA4D,SAAS;EACnF,eAAY;EACZ,GAAI;EAEH;CACE,CAAA,EACgB,CAAA;AAE3B,CACF;AAEA,cAAc,cAAc;AAO5B,IAAM,mBAAmB,MAAM,YAC5B,EAAE,UAAU,WAAW,GAAG,SAAS,QAAQ;CAC1C,OACE,oBAAC,OAAD;EACO;EACL,WAAW,GAAG,0BAA0B,SAAS;EACjD,eAAY;EACZ,GAAI;EAEH;CACE,CAAA;AAET,CACF;AAEA,iBAAiB,cAAc;AAO/B,IAAM,SAAS,MAAM,YAClB,EAAE,UAAU,WAAW,GAAG,SAAS,QAAQ;CAC1C,OACE,oBAAC,OAAD;EACO;EACL,WAAW,GACT,sNACA,SACF;EACA,eAAY;EACZ,GAAI;EAEH;CACE,CAAA;AAET,CACF;AAEA,OAAO,cAAc"}
|
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
import { cn } from "../../lib/ds-utils.js";
|
|
2
|
+
import { useShade } from "../../providers/shade-context.js";
|
|
2
3
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "./dropdown-menu.js";
|
|
3
4
|
import { Button } from "./button.js";
|
|
5
|
+
import { tabSurfaceVariants } from "./tabs-variants.js";
|
|
4
6
|
import { MoreHorizontal } from "lucide-react";
|
|
5
7
|
import * as React$1 from "react";
|
|
6
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
9
|
//#region src/components/ui/pagemenu.tsx
|
|
8
10
|
var PageMenuContext = React$1.createContext(null);
|
|
9
11
|
var PageMenu = React$1.forwardRef(({ children, responsive = false, value, defaultValue, onValueChange, className, ...props }, ref) => {
|
|
12
|
+
const { admin7Design } = useShade();
|
|
10
13
|
const [visibleCount, setVisibleCount] = React$1.useState(React$1.Children.count(children));
|
|
11
14
|
const [resizeKey, setResizeKey] = React$1.useState(0);
|
|
12
15
|
const containerRef = React$1.useRef(null);
|
|
13
16
|
const measureRef = React$1.useRef(null);
|
|
17
|
+
const overflowTriggerRef = React$1.useRef(null);
|
|
18
|
+
const [uncontrolledValue, setUncontrolledValue] = React$1.useState(defaultValue);
|
|
19
|
+
const isControlled = value !== void 0;
|
|
20
|
+
const activeValue = isControlled ? value : uncontrolledValue;
|
|
21
|
+
const measuredActiveValue = admin7Design ? activeValue : void 0;
|
|
22
|
+
const measuredVisibleCount = admin7Design ? visibleCount : void 0;
|
|
23
|
+
const handleSelect = React$1.useCallback((nextValue) => {
|
|
24
|
+
if (nextValue === activeValue) return;
|
|
25
|
+
if (!isControlled) setUncontrolledValue(nextValue);
|
|
26
|
+
onValueChange?.(nextValue);
|
|
27
|
+
}, [
|
|
28
|
+
activeValue,
|
|
29
|
+
isControlled,
|
|
30
|
+
onValueChange
|
|
31
|
+
]);
|
|
32
|
+
const contextValue = React$1.useMemo(() => ({
|
|
33
|
+
value: activeValue,
|
|
34
|
+
onSelect: handleSelect
|
|
35
|
+
}), [activeValue, handleSelect]);
|
|
14
36
|
React$1.useLayoutEffect(() => {
|
|
15
37
|
if (!responsive || !containerRef.current || !measureRef.current) {
|
|
16
38
|
setVisibleCount(React$1.Children.count(children));
|
|
@@ -21,8 +43,8 @@ var PageMenu = React$1.forwardRef(({ children, responsive = false, value, defaul
|
|
|
21
43
|
const container = containerRef.current;
|
|
22
44
|
const measureContainer = measureRef.current;
|
|
23
45
|
const containerWidth = container.clientWidth;
|
|
24
|
-
const dropdownWidth = 60;
|
|
25
|
-
const gap = 6;
|
|
46
|
+
const dropdownWidth = admin7Design ? overflowTriggerRef.current?.getBoundingClientRect().width || 60 : 60;
|
|
47
|
+
const gap = admin7Design ? Number.parseFloat(getComputedStyle(container).columnGap) || 0 : 6;
|
|
26
48
|
const items = Array.from(measureContainer.children);
|
|
27
49
|
let totalWidth = 0;
|
|
28
50
|
for (let i = 0; i < items.length; i++) {
|
|
@@ -38,7 +60,7 @@ var PageMenu = React$1.forwardRef(({ children, responsive = false, value, defaul
|
|
|
38
60
|
for (let i = 0; i < items.length; i++) {
|
|
39
61
|
const itemWidth = items[i].getBoundingClientRect().width;
|
|
40
62
|
const newWidth = currentWidth + (i > 0 ? gap : 0) + itemWidth;
|
|
41
|
-
if (newWidth + dropdownWidth <= containerWidth) {
|
|
63
|
+
if (newWidth + (admin7Design ? gap : 0) + dropdownWidth <= containerWidth) {
|
|
42
64
|
currentWidth = newWidth;
|
|
43
65
|
count += 1;
|
|
44
66
|
} else break;
|
|
@@ -49,7 +71,10 @@ var PageMenu = React$1.forwardRef(({ children, responsive = false, value, defaul
|
|
|
49
71
|
}, [
|
|
50
72
|
responsive,
|
|
51
73
|
children,
|
|
52
|
-
resizeKey
|
|
74
|
+
resizeKey,
|
|
75
|
+
admin7Design,
|
|
76
|
+
measuredActiveValue,
|
|
77
|
+
measuredVisibleCount
|
|
53
78
|
]);
|
|
54
79
|
React$1.useLayoutEffect(() => {
|
|
55
80
|
if (!responsive || !containerRef.current) return;
|
|
@@ -63,9 +88,9 @@ var PageMenu = React$1.forwardRef(({ children, responsive = false, value, defaul
|
|
|
63
88
|
const visibleItems = childrenArray.slice(0, visibleCount);
|
|
64
89
|
const hiddenItems = childrenArray.slice(visibleCount);
|
|
65
90
|
const hasOverflow = hiddenItems.length > 0;
|
|
66
|
-
const selectedHiddenItem = hiddenItems.find((child) => React$1.isValidElement(child) && child.props?.value ===
|
|
91
|
+
const selectedHiddenItem = hiddenItems.find((child) => React$1.isValidElement(child) && child.props?.value === activeValue);
|
|
67
92
|
if (!responsive) return /* @__PURE__ */ jsx(PageMenuContext.Provider, {
|
|
68
|
-
value:
|
|
93
|
+
value: contextValue,
|
|
69
94
|
children: /* @__PURE__ */ jsx("div", {
|
|
70
95
|
ref,
|
|
71
96
|
className: cn("flex items-center gap-2", className),
|
|
@@ -74,7 +99,7 @@ var PageMenu = React$1.forwardRef(({ children, responsive = false, value, defaul
|
|
|
74
99
|
})
|
|
75
100
|
});
|
|
76
101
|
return /* @__PURE__ */ jsxs(PageMenuContext.Provider, {
|
|
77
|
-
value:
|
|
102
|
+
value: contextValue,
|
|
78
103
|
children: [/* @__PURE__ */ jsx("div", {
|
|
79
104
|
ref: measureRef,
|
|
80
105
|
"aria-hidden": "true",
|
|
@@ -95,7 +120,9 @@ var PageMenu = React$1.forwardRef(({ children, responsive = false, value, defaul
|
|
|
95
120
|
}), hasOverflow && /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
96
121
|
asChild: true,
|
|
97
122
|
children: /* @__PURE__ */ jsx(Button, {
|
|
98
|
-
|
|
123
|
+
ref: overflowTriggerRef,
|
|
124
|
+
className: cn("h-[30px] flex-shrink-0 px-3 py-2", admin7Design ? tabSurfaceVariants({ admin7Design }) : selectedHiddenItem && "bg-accent text-accent-foreground"),
|
|
125
|
+
...admin7Design ? { "data-state": selectedHiddenItem ? "active" : void 0 } : {},
|
|
99
126
|
variant: "ghost",
|
|
100
127
|
children: selectedHiddenItem ? /* @__PURE__ */ jsx("span", {
|
|
101
128
|
className: "max-w-[100px] truncate",
|
|
@@ -107,10 +134,12 @@ var PageMenu = React$1.forwardRef(({ children, responsive = false, value, defaul
|
|
|
107
134
|
children: hiddenItems.map((item, index) => {
|
|
108
135
|
if (!React$1.isValidElement(item) || !item.props?.value) return null;
|
|
109
136
|
return /* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
110
|
-
className: cn(item.props.value ===
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
item.props.
|
|
137
|
+
className: cn(item.props.value === activeValue && "bg-accent text-accent-foreground"),
|
|
138
|
+
disabled: item.props.disabled,
|
|
139
|
+
onClick: (event) => {
|
|
140
|
+
if (item.props.disabled) return;
|
|
141
|
+
item.props.onClick?.(event);
|
|
142
|
+
if (!event.defaultPrevented) handleSelect(item.props.value);
|
|
114
143
|
},
|
|
115
144
|
children: item.props.children
|
|
116
145
|
}, item.props.value || index);
|
|
@@ -120,13 +149,20 @@ var PageMenu = React$1.forwardRef(({ children, responsive = false, value, defaul
|
|
|
120
149
|
});
|
|
121
150
|
});
|
|
122
151
|
PageMenu.displayName = "PageMenu";
|
|
123
|
-
var PageMenuItem = React$1.forwardRef(({ children, value, className, ...props }, ref) => {
|
|
124
|
-
const
|
|
152
|
+
var PageMenuItem = React$1.forwardRef(({ children, value, className, onClick, ...props }, ref) => {
|
|
153
|
+
const pageMenu = React$1.useContext(PageMenuContext);
|
|
154
|
+
const { admin7Design } = useShade();
|
|
155
|
+
const isActive = pageMenu?.value === value;
|
|
125
156
|
return /* @__PURE__ */ jsx(Button, {
|
|
126
157
|
ref,
|
|
127
|
-
|
|
158
|
+
"aria-current": isActive ? "page" : void 0,
|
|
159
|
+
className: cn("relative gap-1.5 px-3 text-control font-medium", admin7Design ? tabSurfaceVariants({ admin7Design }) : "text-text-secondary hover:text-foreground focus-visible:ring-0 data-[state=active]:bg-muted-foreground/10 data-[state=active]:text-foreground dark:hover:bg-tab-hover dark:data-[state=active]:bg-tab-active dark:data-[state=active]:hover:bg-tab-active", className),
|
|
128
160
|
"data-state": isActive ? "active" : void 0,
|
|
129
161
|
variant: "ghost",
|
|
162
|
+
onClick: (event) => {
|
|
163
|
+
onClick?.(event);
|
|
164
|
+
if (!event.defaultPrevented) pageMenu?.onSelect(value);
|
|
165
|
+
},
|
|
130
166
|
...props,
|
|
131
167
|
children
|
|
132
168
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagemenu.js","names":[],"sources":["../../../src/components/ui/pagemenu.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '@/lib/utils';\nimport { MoreHorizontal } from 'lucide-react';\nimport { Button, type ButtonProps } from './button';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from './dropdown-menu';\n\nconst PageMenuContext = React.createContext<{ defaultValue?: string } | null>(null);\n\nexport interface PageMenuProps {\n children: React.ReactNode;\n responsive?: boolean;\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n className?: string;\n}\n\nexport interface PageMenuItemProps extends Omit<ButtonProps, 'children'> {\n value: string;\n children: React.ReactNode;\n}\n\nconst PageMenu = React.forwardRef<HTMLDivElement, PageMenuProps>(\n (\n { children, responsive = false, value, defaultValue, onValueChange, className, ...props },\n ref,\n ) => {\n const [visibleCount, setVisibleCount] = React.useState(React.Children.count(children));\n const [resizeKey, setResizeKey] = React.useState(0);\n const containerRef = React.useRef<HTMLDivElement>(null);\n const measureRef = React.useRef<HTMLDivElement>(null);\n\n React.useLayoutEffect(() => {\n if (!responsive || !containerRef.current || !measureRef.current) {\n setVisibleCount(React.Children.count(children));\n return;\n }\n\n // Use requestAnimationFrame to ensure DOM is fully rendered\n const calculateSizes = () => {\n if (!containerRef.current || !measureRef.current) {\n return;\n }\n\n const container = containerRef.current;\n const measureContainer = measureRef.current;\n const containerWidth = container.clientWidth;\n const dropdownWidth = 60; // Space needed for dropdown button\n const gap = 6; // Gap between items (gap-1.5)\n\n // Get all child elements from the measure container\n const items = Array.from(measureContainer.children) as HTMLElement[];\n\n // First, check if ALL items fit without any dropdown\n let totalWidth = 0;\n for (let i = 0; i < items.length; i++) {\n const itemWidth = items[i].getBoundingClientRect().width;\n const gapWidth = i > 0 ? gap : 0;\n totalWidth += gapWidth + itemWidth;\n }\n\n // If all items fit with some buffer space, show them all\n const safetyBuffer = 8; // Add 8px buffer for safe rendering\n if (totalWidth <= containerWidth - safetyBuffer) {\n setVisibleCount(items.length);\n return;\n }\n\n // Otherwise, calculate how many fit with dropdown space reserved\n let currentWidth = 0;\n let count = 0;\n\n for (let i = 0; i < items.length; i++) {\n const itemWidth = items[i].getBoundingClientRect().width;\n const gapWidth = i > 0 ? gap : 0;\n const newWidth = currentWidth + gapWidth + itemWidth;\n\n // Reserve space for dropdown (since we know not all items fit)\n const totalNeededWidth = newWidth + dropdownWidth;\n\n if (totalNeededWidth <= containerWidth) {\n currentWidth = newWidth;\n count += 1;\n } else {\n break;\n }\n }\n\n setVisibleCount(count);\n };\n\n requestAnimationFrame(calculateSizes);\n }, [responsive, children, resizeKey]);\n\n React.useLayoutEffect(() => {\n if (!responsive || !containerRef.current) {\n return;\n }\n\n const resizeObserver = new ResizeObserver(() => {\n // Trigger re-calculation by updating the resize key\n setResizeKey((prev) => prev + 1);\n });\n\n resizeObserver.observe(containerRef.current);\n return () => resizeObserver.disconnect();\n }, [responsive]);\n\n const childrenArray = React.Children.toArray(children);\n const visibleItems = childrenArray.slice(0, visibleCount);\n const hiddenItems = childrenArray.slice(visibleCount);\n const hasOverflow = hiddenItems.length > 0;\n\n // Find selected hidden item\n const selectedHiddenItem = hiddenItems.find(\n (child) => React.isValidElement(child) && child.props?.value === value,\n ) as React.ReactElement | undefined;\n\n if (!responsive) {\n return (\n <PageMenuContext.Provider value={{ defaultValue }}>\n <div ref={ref} className={cn('flex items-center gap-2', className)} {...props}>\n {children}\n </div>\n </PageMenuContext.Provider>\n );\n }\n\n return (\n <PageMenuContext.Provider value={{ defaultValue }}>\n {/* Hidden container to measure all items */}\n <div\n ref={measureRef}\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute flex items-center gap-2 opacity-0\"\n style={{ top: -9999, left: -9999 }}\n >\n {children}\n </div>\n\n {/* Visible container */}\n <div ref={containerRef} className=\"flex w-full min-w-0 flex-1 items-center gap-2\">\n <div ref={ref} className={cn('flex min-w-0 items-center gap-2', className)} {...props}>\n {visibleItems}\n </div>\n\n {hasOverflow && (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n className={cn(\n 'h-[30px] flex-shrink-0 px-3 py-2',\n selectedHiddenItem && 'bg-accent text-accent-foreground',\n )}\n variant=\"ghost\"\n >\n {selectedHiddenItem ? (\n <span className=\"max-w-[100px] truncate\">\n {selectedHiddenItem.props.children}\n </span>\n ) : (\n <MoreHorizontal className=\"size-6\" />\n )}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {hiddenItems.map((item, index) => {\n if (!React.isValidElement(item) || !item.props?.value) {\n return null;\n }\n\n return (\n <DropdownMenuItem\n key={item.props.value || index}\n className={cn(\n item.props.value === value && 'bg-accent text-accent-foreground',\n )}\n onClick={() => {\n onValueChange?.(item.props.value);\n item.props.onClick?.();\n }}\n >\n {item.props.children}\n </DropdownMenuItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n </div>\n </PageMenuContext.Provider>\n );\n },\n);\n\nPageMenu.displayName = 'PageMenu';\n\nconst PageMenuItem = React.forwardRef<HTMLButtonElement, PageMenuItemProps>(\n ({ children, value, className, ...props }, ref) => {\n const pageMenuProps = React.useContext(PageMenuContext);\n const isActive = pageMenuProps?.defaultValue === value;\n\n return (\n <Button\n ref={ref}\n className={cn(\n 'relative gap-1.5 px-3 text-control font-medium text-text-secondary hover:text-foreground focus-visible:ring-0',\n 'data-[state=active]:bg-muted-foreground/10 data-[state=active]:text-foreground',\n 'dark:hover:bg-tab-hover dark:data-[state=active]:bg-tab-active dark:data-[state=active]:hover:bg-tab-active',\n className,\n )}\n data-state={isActive ? 'active' : undefined}\n variant=\"ghost\"\n {...props}\n >\n {children}\n </Button>\n );\n },\n);\n\nPageMenuItem.displayName = 'PageMenuItem';\n\nexport { PageMenu, PageMenuItem };\n"],"mappings":";;;;;;;AAWA,IAAM,kBAAkB,QAAM,cAAgD,IAAI;AAgBlF,IAAM,WAAW,QAAM,YAEnB,EAAE,UAAU,aAAa,OAAO,OAAO,cAAc,eAAe,WAAW,GAAG,SAClF,QACG;CACH,MAAM,CAAC,cAAc,mBAAmB,QAAM,SAAS,QAAM,SAAS,MAAM,QAAQ,CAAC;CACrF,MAAM,CAAC,WAAW,gBAAgB,QAAM,SAAS,CAAC;CAClD,MAAM,eAAe,QAAM,OAAuB,IAAI;CACtD,MAAM,aAAa,QAAM,OAAuB,IAAI;CAEpD,QAAM,sBAAsB;EAC1B,IAAI,CAAC,cAAc,CAAC,aAAa,WAAW,CAAC,WAAW,SAAS;GAC/D,gBAAgB,QAAM,SAAS,MAAM,QAAQ,CAAC;GAC9C;EACF;EAGA,MAAM,uBAAuB;GAC3B,IAAI,CAAC,aAAa,WAAW,CAAC,WAAW,SACvC;GAGF,MAAM,YAAY,aAAa;GAC/B,MAAM,mBAAmB,WAAW;GACpC,MAAM,iBAAiB,UAAU;GACjC,MAAM,gBAAgB;GACtB,MAAM,MAAM;GAGZ,MAAM,QAAQ,MAAM,KAAK,iBAAiB,QAAQ;GAGlD,IAAI,aAAa;GACjB,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;IACrC,MAAM,YAAY,MAAM,EAAE,CAAC,sBAAsB,CAAC,CAAC;IAEnD,eADiB,IAAI,IAAI,MAAM,KACN;GAC3B;GAIA,IAAI,cAAc,iBAAiB,GAAc;IAC/C,gBAAgB,MAAM,MAAM;IAC5B;GACF;GAGA,IAAI,eAAe;GACnB,IAAI,QAAQ;GAEZ,KAAK,IAAI,IAAI,GAAG,IAAI,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AAI;cAC7E;GACE,CAAA,GAEJ,eACC,qBAAC,cAAD,EAAA,UAAA,CACE,oBAAC,qBAAD;IAAqB,SAAA;cACnB,oBAAC,QAAD;KACE,WAAW,GACT,oCACA,sBAAsB,kCACxB;KACA,SAAQ;eAEP,qBACC,oBAAC,QAAD;MAAM,WAAU;gBACb,mBAAmB,MAAM;KACtB,CAAA,IAEN,oBAAC,gBAAD,EAAgB,WAAU,SAAU,CAAA;IAEhC,CAAA;GACW,CAAA,GACrB,oBAAC,qBAAD;IAAqB,OAAM;cACxB,YAAY,KAAK,MAAM,UAAU;KAChC,IAAI,CAAC,QAAM,eAAe,IAAI,KAAK,CAAC,KAAK,OAAO,OAC9C,OAAO;KAGT,OACE,oBAAC,kBAAD;MAEE,WAAW,GACT,KAAK,MAAM,UAAU,SAAS,kCAChC;MACA,eAAe;OACb,gBAAgB,KAAK,MAAM,KAAK;OAChC,KAAK,MAAM,UAAU;MACvB;gBAEC,KAAK,MAAM;KACI,GAVX,KAAK,MAAM,SAAS,KAUT;IAEtB,CAAC;GACkB,CAAA,CACT,EAAA,CAAA,CAEb;IACmB;;AAE9B,CACF;AAEA,SAAS,cAAc;AAEvB,IAAM,eAAe,QAAM,YACxB,EAAE,UAAU,OAAO,WAAW,GAAG,SAAS,QAAQ;CAEjD,MAAM,WADgB,QAAM,WAAW,eACtB,CAAA,EAAe,iBAAiB;CAEjD,OACE,oBAAC,QAAD;EACO;EACL,WAAW,GACT,iHACA,kFACA,+GACA,SACF;EACA,cAAY,WAAW,WAAW,KAAA;EAClC,SAAQ;EACR,GAAI;EAEH;CACK,CAAA;AAEZ,CACF;AAEA,aAAa,cAAc"}
|
|
1
|
+
{"version":3,"file":"pagemenu.js","names":[],"sources":["../../../src/components/ui/pagemenu.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '@/lib/utils';\nimport { MoreHorizontal } from 'lucide-react';\nimport { useShade } from '@/providers/shade-context';\nimport { tabSurfaceVariants } from '@/components/ui/tabs-variants';\nimport { Button, type ButtonProps } from './button';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from './dropdown-menu';\n\ninterface PageMenuContextValue {\n value?: string;\n onSelect: (value: string) => void;\n}\n\nconst PageMenuContext = React.createContext<PageMenuContextValue | null>(null);\n\nexport interface PageMenuProps {\n children: React.ReactNode;\n responsive?: boolean;\n /** The active item's value. Pass with `onValueChange` to control the menu, e.g. from the current route. */\n value?: string;\n /** The item active on first render when the menu manages its own selection. */\n defaultValue?: string;\n /** Called with the item's value when the user picks a different item. */\n onValueChange?: (value: string) => void;\n className?: string;\n}\n\nexport interface PageMenuItemProps extends Omit<ButtonProps, 'children'> {\n value: string;\n children: React.ReactNode;\n}\n\nconst PageMenu = React.forwardRef<HTMLDivElement, PageMenuProps>(\n (\n { children, responsive = false, value, defaultValue, onValueChange, className, ...props },\n ref,\n ) => {\n const { admin7Design } = useShade();\n const [visibleCount, setVisibleCount] = React.useState(React.Children.count(children));\n const [resizeKey, setResizeKey] = React.useState(0);\n const containerRef = React.useRef<HTMLDivElement>(null);\n const measureRef = React.useRef<HTMLDivElement>(null);\n const overflowTriggerRef = React.useRef<HTMLButtonElement>(null);\n\n // Controlled when `value` is passed, otherwise tracks its own selection\n // starting from `defaultValue` (same contract as Radix Tabs).\n const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);\n const isControlled = value !== undefined;\n const activeValue = isControlled ? value : uncontrolledValue;\n const measuredActiveValue = admin7Design ? activeValue : undefined;\n const measuredVisibleCount = admin7Design ? visibleCount : undefined;\n\n const handleSelect = React.useCallback(\n (nextValue: string) => {\n if (nextValue === activeValue) {\n return;\n }\n if (!isControlled) {\n setUncontrolledValue(nextValue);\n }\n onValueChange?.(nextValue);\n },\n [activeValue, isControlled, onValueChange],\n );\n\n const contextValue = React.useMemo(\n () => ({ value: activeValue, onSelect: handleSelect }),\n [activeValue, handleSelect],\n );\n\n React.useLayoutEffect(() => {\n if (!responsive || !containerRef.current || !measureRef.current) {\n setVisibleCount(React.Children.count(children));\n return;\n }\n\n // Use requestAnimationFrame to ensure DOM is fully rendered\n const calculateSizes = () => {\n if (!containerRef.current || !measureRef.current) {\n return;\n }\n\n const container = containerRef.current;\n const measureContainer = measureRef.current;\n const containerWidth = container.clientWidth;\n const dropdownWidth = admin7Design\n ? overflowTriggerRef.current?.getBoundingClientRect().width || 60\n : 60;\n const gap = admin7Design\n ? Number.parseFloat(getComputedStyle(container).columnGap) || 0\n : 6;\n\n // Get all child elements from the measure container\n const items = Array.from(measureContainer.children) as HTMLElement[];\n\n // First, check if ALL items fit without any dropdown\n let totalWidth = 0;\n for (let i = 0; i < items.length; i++) {\n const itemWidth = items[i].getBoundingClientRect().width;\n const gapWidth = i > 0 ? gap : 0;\n totalWidth += gapWidth + itemWidth;\n }\n\n // If all items fit with some buffer space, show them all\n const safetyBuffer = 8; // Add 8px buffer for safe rendering\n if (totalWidth <= containerWidth - safetyBuffer) {\n setVisibleCount(items.length);\n return;\n }\n\n // Otherwise, calculate how many fit with dropdown space reserved\n let currentWidth = 0;\n let count = 0;\n\n for (let i = 0; i < items.length; i++) {\n const itemWidth = items[i].getBoundingClientRect().width;\n const gapWidth = i > 0 ? gap : 0;\n const newWidth = currentWidth + gapWidth + itemWidth;\n\n // Reserve space for dropdown (since we know not all items fit)\n const totalNeededWidth = newWidth + (admin7Design ? gap : 0) + dropdownWidth;\n\n if (totalNeededWidth <= containerWidth) {\n currentWidth = newWidth;\n count += 1;\n } else {\n break;\n }\n }\n\n setVisibleCount(count);\n };\n\n requestAnimationFrame(calculateSizes);\n }, [responsive, children, resizeKey, admin7Design, measuredActiveValue, measuredVisibleCount]);\n\n React.useLayoutEffect(() => {\n if (!responsive || !containerRef.current) {\n return;\n }\n\n const resizeObserver = new ResizeObserver(() => {\n // Trigger re-calculation by updating the resize key\n setResizeKey((prev) => prev + 1);\n });\n\n resizeObserver.observe(containerRef.current);\n return () => resizeObserver.disconnect();\n }, [responsive]);\n\n const childrenArray = React.Children.toArray(children);\n const visibleItems = childrenArray.slice(0, visibleCount);\n const hiddenItems = childrenArray.slice(visibleCount);\n const hasOverflow = hiddenItems.length > 0;\n\n // Find selected hidden item\n const selectedHiddenItem = hiddenItems.find(\n (child) => React.isValidElement(child) && child.props?.value === activeValue,\n ) as React.ReactElement | undefined;\n\n if (!responsive) {\n return (\n <PageMenuContext.Provider value={contextValue}>\n <div ref={ref} className={cn('flex items-center gap-2', className)} {...props}>\n {children}\n </div>\n </PageMenuContext.Provider>\n );\n }\n\n return (\n <PageMenuContext.Provider value={contextValue}>\n {/* Hidden container to measure all items */}\n <div\n ref={measureRef}\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute flex items-center gap-2 opacity-0\"\n style={{ top: -9999, left: -9999 }}\n >\n {children}\n </div>\n\n {/* Visible container */}\n <div ref={containerRef} className=\"flex w-full min-w-0 flex-1 items-center gap-2\">\n <div ref={ref} className={cn('flex min-w-0 items-center gap-2', className)} {...props}>\n {visibleItems}\n </div>\n\n {hasOverflow && (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n ref={overflowTriggerRef}\n className={cn(\n 'h-[30px] flex-shrink-0 px-3 py-2',\n admin7Design\n ? tabSurfaceVariants({ admin7Design })\n : selectedHiddenItem && 'bg-accent text-accent-foreground',\n )}\n {...(admin7Design\n ? { 'data-state': selectedHiddenItem ? 'active' : undefined }\n : {})}\n variant=\"ghost\"\n >\n {selectedHiddenItem ? (\n <span className=\"max-w-[100px] truncate\">\n {selectedHiddenItem.props.children}\n </span>\n ) : (\n <MoreHorizontal className=\"size-6\" />\n )}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {hiddenItems.map((item, index) => {\n if (!React.isValidElement(item) || !item.props?.value) {\n return null;\n }\n\n return (\n <DropdownMenuItem\n key={item.props.value || index}\n className={cn(\n item.props.value === activeValue && 'bg-accent text-accent-foreground',\n )}\n disabled={item.props.disabled}\n onClick={(event) => {\n // Radix still fires onClick on disabled items and relies on CSS to block pointer clicks\n if (item.props.disabled) {\n return;\n }\n item.props.onClick?.(event);\n if (!event.defaultPrevented) {\n handleSelect(item.props.value);\n }\n }}\n >\n {item.props.children}\n </DropdownMenuItem>\n );\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n )}\n </div>\n </PageMenuContext.Provider>\n );\n },\n);\n\nPageMenu.displayName = 'PageMenu';\n\nconst PageMenuItem = React.forwardRef<HTMLButtonElement, PageMenuItemProps>(\n ({ children, value, className, onClick, ...props }, ref) => {\n const pageMenu = React.useContext(PageMenuContext);\n const { admin7Design } = useShade();\n const isActive = pageMenu?.value === value;\n\n return (\n <Button\n ref={ref}\n aria-current={isActive ? 'page' : undefined}\n className={cn(\n 'relative gap-1.5 px-3 text-control font-medium',\n admin7Design\n ? tabSurfaceVariants({ admin7Design })\n : 'text-text-secondary hover:text-foreground focus-visible:ring-0 data-[state=active]:bg-muted-foreground/10 data-[state=active]:text-foreground dark:hover:bg-tab-hover dark:data-[state=active]:bg-tab-active dark:data-[state=active]:hover:bg-tab-active',\n className,\n )}\n data-state={isActive ? 'active' : undefined}\n variant=\"ghost\"\n onClick={(event) => {\n onClick?.(event);\n if (!event.defaultPrevented) {\n pageMenu?.onSelect(value);\n }\n }}\n {...props}\n >\n {children}\n </Button>\n );\n },\n);\n\nPageMenuItem.displayName = 'PageMenuItem';\n\nexport { PageMenu, PageMenuItem };\n"],"mappings":";;;;;;;;;AAkBA,IAAM,kBAAkB,QAAM,cAA2C,IAAI;AAmB7E,IAAM,WAAW,QAAM,YAEnB,EAAE,UAAU,aAAa,OAAO,OAAO,cAAc,eAAe,WAAW,GAAG,SAClF,QACG;CACH,MAAM,EAAE,iBAAiB,SAAS;CAClC,MAAM,CAAC,cAAc,mBAAmB,QAAM,SAAS,QAAM,SAAS,MAAM,QAAQ,CAAC;CACrF,MAAM,CAAC,WAAW,gBAAgB,QAAM,SAAS,CAAC;CAClD,MAAM,eAAe,QAAM,OAAuB,IAAI;CACt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U;CAErC,OACE,oBAAC,QAAD;EACO;EACL,gBAAc,WAAW,SAAS,KAAA;EAClC,WAAW,GACT,kDACA,eACI,mBAAmB,EAAE,aAAa,CAAC,IACnC,6PACJ,SACF;EACA,cAAY,WAAW,WAAW,KAAA;EAClC,SAAQ;EACR,UAAU,UAAU;GAClB,UAAU,KAAK;GACf,IAAI,CAAC,MAAM,kBACT,UAAU,SAAS,KAAK;EAE5B;EACA,GAAI;EAEH;CACK,CAAA;AAEZ,CACF;AAEA,aAAa,cAAc"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { cn } from "../../lib/ds-utils.js";
|
|
2
2
|
import { ShadeScope } from "../../shade-scope.js";
|
|
3
|
+
import { safeAreaCollision } from "../../lib/safe-area.js";
|
|
4
|
+
import { usePortalContainer } from "../../lib/app-overlay.js";
|
|
3
5
|
import { consumeOverlayEscape } from "../../lib/overlay-escape.js";
|
|
4
6
|
import * as React$1 from "react";
|
|
5
7
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -9,14 +11,18 @@ var Popover = PopoverPrimitive.Root;
|
|
|
9
11
|
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
10
12
|
var PopoverAnchor = PopoverPrimitive.Anchor;
|
|
11
13
|
var PopoverClose = PopoverPrimitive.Close;
|
|
12
|
-
var PopoverContent = React$1.forwardRef(({ className, align = "center", onEscapeKeyDown, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
var PopoverContent = React$1.forwardRef(({ className, align = "center", onEscapeKeyDown, sideOffset = 4, collisionBoundary, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, {
|
|
15
|
+
container: usePortalContainer(),
|
|
16
|
+
children: /* @__PURE__ */ jsx(ShadeScope, { children: /* @__PURE__ */ jsx(PopoverPrimitive.Content, {
|
|
17
|
+
ref,
|
|
18
|
+
align,
|
|
19
|
+
className: cn("data-[safe-area]:max-h-(--radix-popover-content-available-height) data-[safe-area]:max-w-(--radix-popover-content-available-width) data-[safe-area]:overflow-y-auto", "z-50 origin-(--radix-popover-content-transform-origin) rounded-menu border border-border/60 bg-surface-elevated-2 p-5 text-popover-foreground shadow-md outline-hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 dark:border-border/30", className),
|
|
20
|
+
...safeAreaCollision(collisionBoundary, usePortalContainer()),
|
|
21
|
+
sideOffset,
|
|
22
|
+
onEscapeKeyDown: (event) => consumeOverlayEscape(event, onEscapeKeyDown),
|
|
23
|
+
...props
|
|
24
|
+
}) })
|
|
25
|
+
}));
|
|
20
26
|
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
21
27
|
//#endregion
|
|
22
28
|
export { Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","names":[],"sources":["../../../src/components/ui/popover.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { ShadeScope } from '@/shade-scope';\n\nimport { cn } from '@/lib/utils';\nimport { consumeOverlayEscape } from '@/lib/overlay-escape';\nconst Popover = PopoverPrimitive.Root;\n\nconst PopoverTrigger = PopoverPrimitive.Trigger;\n\nconst PopoverAnchor = PopoverPrimitive.Anchor;\n\nconst PopoverClose = PopoverPrimitive.Close;\n\nconst PopoverContent = React.forwardRef<\n React.ElementRef<typeof PopoverPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>\n>(({ className, align = 'center', onEscapeKeyDown, sideOffset = 4, ...props }
|
|
1
|
+
{"version":3,"file":"popover.js","names":[],"sources":["../../../src/components/ui/popover.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { ShadeScope } from '@/shade-scope';\n\nimport { usePortalContainer } from '@/lib/app-overlay';\nimport { cn } from '@/lib/utils';\nimport { consumeOverlayEscape } from '@/lib/overlay-escape';\nimport { safeAreaCollision } from '@/lib/safe-area';\nconst Popover = PopoverPrimitive.Root;\n\nconst PopoverTrigger = PopoverPrimitive.Trigger;\n\nconst PopoverAnchor = PopoverPrimitive.Anchor;\n\nconst PopoverClose = PopoverPrimitive.Close;\n\nconst PopoverContent = React.forwardRef<\n React.ElementRef<typeof PopoverPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>\n>(\n (\n { className, align = 'center', onEscapeKeyDown, sideOffset = 4, collisionBoundary, ...props },\n ref,\n ) => (\n <PopoverPrimitive.Portal container={usePortalContainer()}>\n <ShadeScope>\n <PopoverPrimitive.Content\n ref={ref}\n align={align}\n className={cn(\n 'data-[safe-area]:max-h-(--radix-popover-content-available-height) data-[safe-area]:max-w-(--radix-popover-content-available-width) data-[safe-area]:overflow-y-auto',\n 'z-50 origin-(--radix-popover-content-transform-origin) rounded-menu border border-border/60 bg-surface-elevated-2 p-5 text-popover-foreground shadow-md outline-hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 dark:border-border/30',\n className,\n )}\n {...safeAreaCollision(collisionBoundary, usePortalContainer())}\n sideOffset={sideOffset}\n onEscapeKeyDown={(event) => consumeOverlayEscape(event, onEscapeKeyDown)}\n {...props}\n />\n </ShadeScope>\n </PopoverPrimitive.Portal>\n ),\n);\nPopoverContent.displayName = PopoverPrimitive.Content.displayName;\n\nexport { Popover, PopoverTrigger, PopoverContent, PopoverAnchor, PopoverClose };\n"],"mappings":";;;;;;;;;AAQA,IAAM,UAAU,iBAAiB;AAEjC,IAAM,iBAAiB,iBAAiB;AAExC,IAAM,gBAAgB,iBAAiB;AAEvC,IAAM,eAAe,iBAAiB;AAEtC,IAAM,iBAAiB,QAAM,YAKzB,EAAE,WAAW,QAAQ,UAAU,iBAAiB,aAAa,GAAG,mBAAmB,GAAG,SACtF,QAEA,oBAAC,iBAAiB,QAAlB;CAAyB,WAAW,mBAAmB;WACrD,oBAAC,YAAD,EAAA,UACE,oBAAC,iBAAiB,SAAlB;EACO;EACE;EACP,WAAW,GACT,uKACA,ihBACA,SACF;EACA,GAAI,kBAAkB,mBAAmB,mBAAmB,CAAC;EACjD;EACZ,kBAAkB,UAAU,qBAAqB,OAAO,eAAe;EACvE,GAAI;CACL,CAAA,EACS,CAAA;AACW,CAAA,CAE7B;AACA,eAAe,cAAc,iBAAiB,QAAQ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { inputSurface } from "./input-surface.js";
|
|
2
2
|
import { cva } from "class-variance-authority";
|
|
3
3
|
//#region src/components/ui/radio-group-variants.ts
|
|
4
|
-
var radioGroupItemVariants = cva([inputSurface("self"), "peer grid size-4 shrink-0 place-content-center rounded-full border-border-strong p-0 text-primary enabled:hover:bg-interactive-hover data-[state=checked]:border-primary"], {
|
|
4
|
+
var radioGroupItemVariants = cva([inputSurface("self"), "peer grid size-4 shrink-0 place-content-center rounded-full border-border-strong bg-control-surface p-0 text-primary enabled:hover:bg-interactive-hover data-[state=checked]:border-primary"], {
|
|
5
5
|
variants: { indicator: {
|
|
6
6
|
dot: "",
|
|
7
7
|
check: "data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground enabled:data-[state=checked]:hover:bg-primary"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-group-variants.js","names":[],"sources":["../../../src/components/ui/radio-group-variants.ts"],"sourcesContent":["import { cva } from 'class-variance-authority';\nimport { inputSurface } from '@/components/ui/input-surface';\n\nconst radioGroupItemVariants = cva(\n [\n inputSurface('self'),\n 'peer grid size-4 shrink-0 place-content-center rounded-full border-border-strong p-0 text-primary enabled:hover:bg-interactive-hover data-[state=checked]:border-primary',\n ],\n {\n variants: {\n indicator: {\n dot: '',\n check:\n 'data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground enabled:data-[state=checked]:hover:bg-primary',\n },\n },\n defaultVariants: {\n indicator: 'dot',\n },\n },\n);\n\nexport { radioGroupItemVariants };\n"],"mappings":";;;AAGA,IAAM,yBAAyB,IAC7B,CACE,aAAa,MAAM,GACnB,
|
|
1
|
+
{"version":3,"file":"radio-group-variants.js","names":[],"sources":["../../../src/components/ui/radio-group-variants.ts"],"sourcesContent":["import { cva } from 'class-variance-authority';\nimport { inputSurface } from '@/components/ui/input-surface';\n\nconst radioGroupItemVariants = cva(\n [\n inputSurface('self'),\n 'peer grid size-4 shrink-0 place-content-center rounded-full border-border-strong bg-control-surface p-0 text-primary enabled:hover:bg-interactive-hover data-[state=checked]:border-primary',\n ],\n {\n variants: {\n indicator: {\n dot: '',\n check:\n 'data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground enabled:data-[state=checked]:hover:bg-primary',\n },\n },\n defaultVariants: {\n indicator: 'dot',\n },\n },\n);\n\nexport { radioGroupItemVariants };\n"],"mappings":";;;AAGA,IAAM,yBAAyB,IAC7B,CACE,aAAa,MAAM,GACnB,6LACF,GACA;CACE,UAAU,EACR,WAAW;EACT,KAAK;EACL,OACE;CACJ,EACF;CACA,iBAAiB,EACf,WAAW,MACb;AACF,CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { cn } from "../../lib/ds-utils.js";
|
|
2
|
+
import { rowSurfaceClasses } from "./row-surface.js";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
6
|
+
//#region src/components/ui/row-primary-action.tsx
|
|
7
|
+
/** Makes the whole row activate its main link or button. */
|
|
8
|
+
var RowPrimaryAction = React$1.forwardRef(({ asChild = false, className, children, onKeyDown, onKeyUp, ...props }, ref) => {
|
|
9
|
+
const Component = asChild ? Slot : "button";
|
|
10
|
+
const child = asChild && React$1.isValidElement(children) ? children : void 0;
|
|
11
|
+
const legacyAction = child && typeof child.type === "string" && ![
|
|
12
|
+
"a",
|
|
13
|
+
"button",
|
|
14
|
+
"input",
|
|
15
|
+
"select",
|
|
16
|
+
"textarea"
|
|
17
|
+
].includes(child.type) && Boolean(child.props.onClick || props.onClick) && !props.disabled && (child.props["aria-disabled"] ?? props["aria-disabled"]) !== true && (child.props["aria-disabled"] ?? props["aria-disabled"]) !== "true";
|
|
18
|
+
const childContent = child ? React$1.cloneElement(child, { className: void 0 }) : children;
|
|
19
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
20
|
+
ref,
|
|
21
|
+
className: cn(rowSurfaceClasses.primaryAction, "focus-visible:ring-1 focus-visible:ring-focus-ring focus-visible:outline-hidden", child?.props.className, className),
|
|
22
|
+
...!asChild ? { type: "button" } : {},
|
|
23
|
+
...props,
|
|
24
|
+
role: legacyAction ? child.props.role ?? "button" : props.role,
|
|
25
|
+
tabIndex: legacyAction ? child.props.tabIndex ?? 0 : props.tabIndex,
|
|
26
|
+
onKeyDown: (event) => {
|
|
27
|
+
onKeyDown?.(event);
|
|
28
|
+
if (!legacyAction || event.defaultPrevented || event.target !== event.currentTarget) return;
|
|
29
|
+
if (event.key === "Enter") {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
event.currentTarget.click();
|
|
32
|
+
} else if (event.key === " ") event.preventDefault();
|
|
33
|
+
},
|
|
34
|
+
onKeyUp: (event) => {
|
|
35
|
+
onKeyUp?.(event);
|
|
36
|
+
if (legacyAction && !event.defaultPrevented && event.target === event.currentTarget && event.key === " ") {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
event.currentTarget.click();
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
children: childContent
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
RowPrimaryAction.displayName = "RowPrimaryAction";
|
|
45
|
+
//#endregion
|
|
46
|
+
export { RowPrimaryAction, RowPrimaryAction as TableRowAction };
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=row-primary-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-primary-action.js","names":[],"sources":["../../../src/components/ui/row-primary-action.tsx"],"sourcesContent":["import { Slot } from '@radix-ui/react-slot';\nimport * as React from 'react';\nimport { cn } from '@/lib/utils';\nimport { rowSurfaceClasses } from '@/components/ui/row-surface';\n\ninterface RowPrimaryActionProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n asChild?: boolean;\n}\n\n/** Makes the whole row activate its main link or button. */\nconst RowPrimaryAction = React.forwardRef<HTMLButtonElement, RowPrimaryActionProps>(\n ({ asChild = false, className, children, onKeyDown, onKeyUp, ...props }, ref) => {\n const Component = asChild ? Slot : 'button';\n const child =\n asChild && React.isValidElement<React.HTMLAttributes<HTMLElement>>(children)\n ? children\n : undefined;\n const legacyAction =\n child &&\n typeof child.type === 'string' &&\n !['a', 'button', 'input', 'select', 'textarea'].includes(child.type) &&\n Boolean(child.props.onClick || props.onClick) &&\n !props.disabled &&\n (child.props['aria-disabled'] ?? props['aria-disabled']) !== true &&\n (child.props['aria-disabled'] ?? props['aria-disabled']) !== 'true';\n const childContent = child ? React.cloneElement(child, { className: undefined }) : children;\n return (\n <Component\n ref={ref}\n className={cn(\n rowSurfaceClasses.primaryAction,\n 'focus-visible:ring-1 focus-visible:ring-focus-ring focus-visible:outline-hidden',\n child?.props.className,\n className,\n )}\n {...(!asChild ? { type: 'button' as const } : {})}\n {...props}\n role={legacyAction ? (child.props.role ?? 'button') : props.role}\n tabIndex={legacyAction ? (child.props.tabIndex ?? 0) : props.tabIndex}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (!legacyAction || event.defaultPrevented || event.target !== event.currentTarget) {\n return;\n }\n if (event.key === 'Enter') {\n event.preventDefault();\n event.currentTarget.click();\n } else if (event.key === ' ') {\n event.preventDefault();\n }\n }}\n onKeyUp={(event) => {\n onKeyUp?.(event);\n if (\n legacyAction &&\n !event.defaultPrevented &&\n event.target === event.currentTarget &&\n event.key === ' '\n ) {\n event.preventDefault();\n event.currentTarget.click();\n }\n }}\n >\n {childContent}\n </Component>\n );\n },\n);\nRowPrimaryAction.displayName = 'RowPrimaryAction';\n\nexport { RowPrimaryAction, RowPrimaryAction as TableRowAction };\n"],"mappings":";;;;;;;AAUA,IAAM,mBAAmB,QAAM,YAC5B,EAAE,UAAU,OAAO,WAAW,UAAU,WAAW,SAAS,GAAG,SAAS,QAAQ;CAC/E,MAAM,YAAY,UAAU,OAAO;CACnC,MAAM,QACJ,WAAW,QAAM,eAAkD,QAAQ,IACvE,WACA,KAAA;CACN,MAAM,eACJ,SACA,OAAO,MAAM,SAAS,YACtB,CAAC;EAAC;EAAK;EAAU;EAAS;EAAU;CAAU,CAAC,CAAC,SAAS,MAAM,IAAI,KACnE,QAAQ,MAAM,MAAM,WAAW,MAAM,OAAO,KAC5C,CAAC,MAAM,aACN,MAAM,MAAM,oBAAoB,MAAM,sBAAsB,SAC5D,MAAM,MAAM,oBAAoB,MAAM,sBAAsB;CAC/D,MAAM,eAAe,QAAQ,QAAM,aAAa,OAAO,EAAE,WAAW,KAAA,EAAU,CAAC,IAAI;CACnF,OACE,oBAAC,WAAD;EACO;EACL,WAAW,GACT,kBAAkB,eAClB,mFACA,OAAO,MAAM,WACb,SACF;EACA,GAAK,CAAC,UAAU,EAAE,MAAM,SAAkB,IAAI,CAAC;EAC/C,GAAI;EACJ,MAAM,eAAgB,MAAM,MAAM,QAAQ,WAAY,MAAM;EAC5D,UAAU,eAAgB,MAAM,MAAM,YAAY,IAAK,MAAM;EAC7D,YAAY,UAAU;GACpB,YAAY,KAAK;GACjB,IAAI,CAAC,gBAAgB,MAAM,oBAAoB,MAAM,WAAW,MAAM,eACpE;GAEF,IAAI,MAAM,QAAQ,SAAS;IACzB,MAAM,eAAe;IACrB,MAAM,cAAc,MAAM;GAC5B,OAAO,IAAI,MAAM,QAAQ,KACvB,MAAM,eAAe;EAEzB;EACA,UAAU,UAAU;GAClB,UAAU,KAAK;GACf,IACE,gBACA,CAAC,MAAM,oBACP,MAAM,WAAW,MAAM,iBACvB,MAAM,QAAQ,KACd;IACA,MAAM,eAAe;IACrB,MAAM,cAAc,MAAM;GAC5B;EACF;YAEC;CACQ,CAAA;AAEf,CACF;AACA,iBAAiB,cAAc"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { cn } from "../../lib/ds-utils.js";
|
|
2
|
+
//#region src/components/ui/row-surface.ts
|
|
3
|
+
/** Background and spacing classes for custom list and table rows. */
|
|
4
|
+
var rowSurfaceClasses = {
|
|
5
|
+
base: "shade-row",
|
|
6
|
+
interactive: "shade-row-interactive",
|
|
7
|
+
auto: "shade-row-auto",
|
|
8
|
+
inset: "shade-row-inset",
|
|
9
|
+
end: "shade-row-end",
|
|
10
|
+
primaryAction: "shade-row-primary"
|
|
11
|
+
};
|
|
12
|
+
function rowSurface(mode = "interactive") {
|
|
13
|
+
return cn(rowSurfaceClasses.base, mode === "interactive" && rowSurfaceClasses.interactive, mode === "auto" && rowSurfaceClasses.auto);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { rowSurface, rowSurfaceClasses };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=row-surface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-surface.js","names":[],"sources":["../../../src/components/ui/row-surface.ts"],"sourcesContent":["import { cn } from '@/lib/utils';\n\n/** Background and spacing classes for custom list and table rows. */\nexport const rowSurfaceClasses = {\n base: 'shade-row',\n interactive: 'shade-row-interactive',\n auto: 'shade-row-auto',\n inset: 'shade-row-inset',\n end: 'shade-row-end',\n primaryAction: 'shade-row-primary',\n} as const;\n\nexport function rowSurface(mode: 'interactive' | 'static' | 'auto' = 'interactive') {\n return cn(\n rowSurfaceClasses.base,\n mode === 'interactive' && rowSurfaceClasses.interactive,\n mode === 'auto' && rowSurfaceClasses.auto,\n );\n}\n"],"mappings":";;;AAGA,IAAa,oBAAoB;CAC/B,MAAM;CACN,aAAa;CACb,MAAM;CACN,OAAO;CACP,KAAK;CACL,eAAe;AACjB;AAEA,SAAgB,WAAW,OAA0C,eAAe;CAClF,OAAO,GACL,kBAAkB,MAClB,SAAS,iBAAiB,kBAAkB,aAC5C,SAAS,UAAU,kBAAkB,IACvC;AACF"}
|
|
@@ -1,42 +1,34 @@
|
|
|
1
1
|
import { cva } from "class-variance-authority";
|
|
2
2
|
//#region src/components/ui/select-variants.ts
|
|
3
|
-
var selectTriggerVariants = cva("flex h-(--control-height) w-full items-center justify-between px-3 py-2 text-
|
|
3
|
+
var selectTriggerVariants = cva("flex h-(--control-height) w-full items-center justify-between px-3 py-2 text-(length:--text-field) whitespace-nowrap hover:bg-button-hover data-[placeholder]:text-muted-foreground [&>span]:line-clamp-1", {
|
|
4
4
|
variants: {
|
|
5
5
|
variant: {
|
|
6
6
|
default: "",
|
|
7
|
-
ghost: "border-transparent bg-transparent shadow-none",
|
|
8
|
-
secondary: "border-transparent bg-tab-active text-secondary-foreground shadow-none hover:bg-secondary"
|
|
9
|
-
},
|
|
10
|
-
isAdmin7: {
|
|
11
|
-
true: "",
|
|
12
|
-
false: ""
|
|
7
|
+
ghost: "border-transparent bg-transparent shadow-none [--radius-field:var(--radius-control)] [--text-field:var(--text-control)]",
|
|
8
|
+
secondary: "border-transparent bg-tab-active text-secondary-foreground shadow-none [--radius-field:var(--radius-control)] [--text-field:var(--text-control)] hover:bg-secondary"
|
|
13
9
|
},
|
|
14
10
|
shape: {
|
|
15
|
-
rounded: "rounded-
|
|
11
|
+
rounded: "rounded-field",
|
|
16
12
|
pill: "rounded-full"
|
|
17
13
|
}
|
|
18
14
|
},
|
|
19
15
|
compoundVariants: [
|
|
20
16
|
{
|
|
21
|
-
isAdmin7: true,
|
|
22
17
|
variant: ["secondary", "ghost"],
|
|
23
18
|
className: "enabled:active:shadow-control-pressed enabled:aria-expanded:shadow-control-pressed"
|
|
24
19
|
},
|
|
25
20
|
{
|
|
26
|
-
isAdmin7: true,
|
|
27
21
|
variant: "ghost",
|
|
28
|
-
className: "enabled:active:bg-button-
|
|
22
|
+
className: "enabled:active:bg-button-pressed enabled:aria-expanded:bg-button-pressed"
|
|
29
23
|
},
|
|
30
24
|
{
|
|
31
|
-
isAdmin7: true,
|
|
32
25
|
variant: "secondary",
|
|
33
26
|
className: "enabled:active:bg-secondary enabled:aria-expanded:bg-secondary"
|
|
34
27
|
}
|
|
35
28
|
],
|
|
36
29
|
defaultVariants: {
|
|
37
30
|
variant: "default",
|
|
38
|
-
shape: "rounded"
|
|
39
|
-
isAdmin7: true
|
|
31
|
+
shape: "rounded"
|
|
40
32
|
}
|
|
41
33
|
});
|
|
42
34
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-variants.js","names":[],"sources":["../../../src/components/ui/select-variants.ts"],"sourcesContent":["import { cva } from 'class-variance-authority';\n\nconst selectTriggerVariants = cva(\n 'flex h-(--control-height) w-full items-center justify-between px-3 py-2 text-
|
|
1
|
+
{"version":3,"file":"select-variants.js","names":[],"sources":["../../../src/components/ui/select-variants.ts"],"sourcesContent":["import { cva } from 'class-variance-authority';\n\nconst selectTriggerVariants = cva(\n 'flex h-(--control-height) w-full items-center justify-between px-3 py-2 text-(length:--text-field) whitespace-nowrap hover:bg-button-hover data-[placeholder]:text-muted-foreground [&>span]:line-clamp-1',\n {\n variants: {\n variant: {\n default: '',\n // Ghost and secondary triggers read as buttons, so they keep a button's corners.\n ghost:\n 'border-transparent bg-transparent shadow-none [--radius-field:var(--radius-control)] [--text-field:var(--text-control)]',\n secondary:\n 'border-transparent bg-tab-active text-secondary-foreground shadow-none [--radius-field:var(--radius-control)] [--text-field:var(--text-control)] hover:bg-secondary',\n },\n shape: {\n rounded: 'rounded-field',\n pill: 'rounded-full',\n },\n },\n compoundVariants: [\n {\n variant: ['secondary', 'ghost'],\n className:\n 'enabled:active:shadow-control-pressed enabled:aria-expanded:shadow-control-pressed',\n },\n {\n variant: 'ghost',\n className: 'enabled:active:bg-button-pressed enabled:aria-expanded:bg-button-pressed',\n },\n {\n variant: 'secondary',\n className: 'enabled:active:bg-secondary enabled:aria-expanded:bg-secondary',\n },\n ],\n defaultVariants: {\n variant: 'default',\n shape: 'rounded',\n },\n },\n);\n\nexport { selectTriggerVariants };\n"],"mappings":";;AAEA,IAAM,wBAAwB,IAC5B,6MACA;CACE,UAAU;EACR,SAAS;GACP,SAAS;GAET,OACE;GACF,WACE;EACJ;EACA,OAAO;GACL,SAAS;GACT,MAAM;EACR;CACF;CACA,kBAAkB;EAChB;GACE,SAAS,CAAC,aAAa,OAAO;GAC9B,WACE;EACJ;EACA;GACE,SAAS;GACT,WAAW;EACb;EACA;GACE,SAAS;GACT,WAAW;EACb;CACF;CACA,iBAAiB;EACf,SAAS;EACT,OAAO;CACT;AACF,CACF"}
|