@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cn } from "../../lib/ds-utils.js";
|
|
2
|
-
import { useShade } from "../../providers/shade-context.js";
|
|
3
2
|
import { ShadeScope } from "../../shade-scope.js";
|
|
3
|
+
import { hasSafeArea, safeAreaCollision } from "../../lib/safe-area.js";
|
|
4
|
+
import { usePortalContainer } from "../../lib/app-overlay.js";
|
|
4
5
|
import { consumeOverlayEscape } from "../../lib/overlay-escape.js";
|
|
5
6
|
import { selectTriggerVariants } from "./select-variants.js";
|
|
6
7
|
import { inputSurface, inputSurfaceClasses } from "./input-surface.js";
|
|
@@ -13,14 +14,12 @@ var Select = SelectPrimitive.Root;
|
|
|
13
14
|
var SelectGroup = SelectPrimitive.Group;
|
|
14
15
|
var SelectValue = SelectPrimitive.Value;
|
|
15
16
|
var SelectTrigger = React$1.forwardRef(({ className, children, shape, variant, showChevron = variant !== "secondary", ...props }, ref) => {
|
|
16
|
-
const { isAdmin7 } = useShade();
|
|
17
17
|
const resolvedShape = shape ?? "rounded";
|
|
18
18
|
return /* @__PURE__ */ jsxs(SelectPrimitive.Trigger, {
|
|
19
19
|
ref,
|
|
20
20
|
className: cn(inputSurface("self"), inputSurfaceClasses.disabledFieldSelf, selectTriggerVariants({
|
|
21
21
|
shape: resolvedShape,
|
|
22
|
-
variant
|
|
23
|
-
isAdmin7
|
|
22
|
+
variant
|
|
24
23
|
}), showChevron && "pr-2", className),
|
|
25
24
|
"data-control-shape": resolvedShape,
|
|
26
25
|
"data-variant": variant ?? "default",
|
|
@@ -46,21 +45,29 @@ var SelectScrollDownButton = React$1.forwardRef(({ className, ...props }, ref) =
|
|
|
46
45
|
children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-4" })
|
|
47
46
|
}));
|
|
48
47
|
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
49
|
-
var SelectContent = React$1.forwardRef(({ className, children, onEscapeKeyDown, position = "popper", ...props }, ref) =>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
var SelectContent = React$1.forwardRef(({ className, children, onEscapeKeyDown, position: requested = "popper", collisionBoundary, ...props }, ref) => {
|
|
49
|
+
const container = usePortalContainer();
|
|
50
|
+
const position = hasSafeArea(container) ? "popper" : requested;
|
|
51
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Portal, {
|
|
52
|
+
container,
|
|
53
|
+
children: /* @__PURE__ */ jsx(ShadeScope, { children: /* @__PURE__ */ jsxs(SelectPrimitive.Content, {
|
|
54
|
+
ref,
|
|
55
|
+
className: cn("relative z-[9999] max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-menu border border-border/60 bg-surface-elevated-2 text-popover-foreground shadow-md 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", position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className),
|
|
56
|
+
...safeAreaCollision(collisionBoundary, container),
|
|
57
|
+
position,
|
|
58
|
+
onEscapeKeyDown: (event) => consumeOverlayEscape(event, onEscapeKeyDown),
|
|
59
|
+
...props,
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ jsx(SelectScrollUpButton, {}),
|
|
62
|
+
/* @__PURE__ */ jsx(SelectPrimitive.Viewport, {
|
|
63
|
+
className: cn("p-1", position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),
|
|
64
|
+
children
|
|
65
|
+
}),
|
|
66
|
+
/* @__PURE__ */ jsx(SelectScrollDownButton, {})
|
|
67
|
+
]
|
|
68
|
+
}) })
|
|
69
|
+
});
|
|
70
|
+
});
|
|
64
71
|
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
65
72
|
var SelectLabel = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Label, {
|
|
66
73
|
ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","names":[],"sources":["../../../src/components/ui/select.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport { type VariantProps } from 'class-variance-authority';\nimport { Check, ChevronDown, ChevronUp } from 'lucide-react';\n\nimport { selectTriggerVariants } from '@/components/ui/select-variants';\nimport {
|
|
1
|
+
{"version":3,"file":"select.js","names":[],"sources":["../../../src/components/ui/select.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport { type VariantProps } from 'class-variance-authority';\nimport { Check, ChevronDown, ChevronUp } from 'lucide-react';\n\nimport { selectTriggerVariants } from '@/components/ui/select-variants';\nimport { usePortalContainer } from '@/lib/app-overlay';\nimport { cn } from '@/lib/utils';\nimport { ShadeScope } from '@/shade-scope';\nimport { inputSurface, inputSurfaceClasses } from '@/components/ui/input-surface';\nimport { consumeOverlayEscape } from '@/lib/overlay-escape';\nimport { hasSafeArea, safeAreaCollision } from '@/lib/safe-area';\nconst Select = SelectPrimitive.Root;\n\nconst SelectGroup = SelectPrimitive.Group;\n\nconst SelectValue = SelectPrimitive.Value;\n\nexport interface SelectTriggerProps\n extends\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>,\n VariantProps<typeof selectTriggerVariants> {\n /** Show the dropdown chevron. Defaults to hidden for the secondary variant. */\n showChevron?: boolean;\n}\n\nconst SelectTrigger = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Trigger>,\n SelectTriggerProps\n>(\n (\n { className, children, shape, variant, showChevron = variant !== 'secondary', ...props },\n ref,\n ) => {\n const resolvedShape = shape ?? 'rounded';\n return (\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n inputSurface('self'),\n inputSurfaceClasses.disabledFieldSelf,\n selectTriggerVariants({ shape: resolvedShape, variant }),\n showChevron && 'pr-2',\n className,\n )}\n data-control-shape={resolvedShape}\n data-variant={variant ?? 'default'}\n {...props}\n >\n {children}\n {showChevron && (\n <SelectPrimitive.Icon asChild>\n <ChevronDown className=\"-mr-0.5 size-4 opacity-50\" />\n </SelectPrimitive.Icon>\n )}\n </SelectPrimitive.Trigger>\n );\n },\n);\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\n\nconst SelectScrollUpButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollUpButton\n ref={ref}\n className={cn('flex cursor-default items-center justify-center py-1', className)}\n {...props}\n >\n <ChevronUp className=\"size-4\" />\n </SelectPrimitive.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\n\nconst SelectScrollDownButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollDownButton\n ref={ref}\n className={cn('flex cursor-default items-center justify-center py-1', className)}\n {...props}\n >\n <ChevronDown className=\"size-4\" />\n </SelectPrimitive.ScrollDownButton>\n));\nSelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;\n\nconst SelectContent = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>\n>(\n (\n {\n className,\n children,\n onEscapeKeyDown,\n position: requested = 'popper',\n collisionBoundary,\n ...props\n },\n ref,\n ) => {\n const container = usePortalContainer();\n // Radix fits an item-aligned select to the window, ignoring the safe area's boundary.\n const position = hasSafeArea(container) ? 'popper' : requested;\n return (\n <SelectPrimitive.Portal container={container}>\n <ShadeScope>\n <SelectPrimitive.Content\n ref={ref}\n className={cn(\n 'relative z-[9999] max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-menu border border-border/60 bg-surface-elevated-2 text-popover-foreground shadow-md 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 position === 'popper' &&\n 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',\n className,\n )}\n {...safeAreaCollision(collisionBoundary, container)}\n position={position}\n onEscapeKeyDown={(event) => consumeOverlayEscape(event, onEscapeKeyDown)}\n {...props}\n >\n <SelectScrollUpButton />\n <SelectPrimitive.Viewport\n className={cn(\n 'p-1',\n position === 'popper' &&\n 'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]',\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n <SelectScrollDownButton />\n </SelectPrimitive.Content>\n </ShadeScope>\n </SelectPrimitive.Portal>\n );\n },\n);\nSelectContent.displayName = SelectPrimitive.Content.displayName;\n\nconst SelectLabel = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn('px-2 py-1.5 text-control font-semibold', className)}\n {...props}\n />\n));\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\n\nconst SelectItem = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n 'relative flex w-full cursor-default items-center rounded-menu-item py-1.5 pr-8 pl-2 text-control outline-hidden select-none focus:bg-interactive-hover focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n className,\n )}\n {...props}\n >\n <span className=\"absolute right-2 flex size-3.5 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"size-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n));\nSelectItem.displayName = SelectPrimitive.Item.displayName;\n\nconst SelectSeparator = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn('-mx-1 my-1 h-px bg-muted', className)}\n {...props}\n />\n));\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\n\nexport {\n Select,\n SelectGroup,\n SelectValue,\n SelectTrigger,\n SelectContent,\n SelectLabel,\n SelectItem,\n SelectSeparator,\n SelectScrollUpButton,\n SelectScrollDownButton,\n};\n"],"mappings":";;;;;;;;;;;;AAYA,IAAM,SAAS,gBAAgB;AAE/B,IAAM,cAAc,gBAAgB;AAEpC,IAAM,cAAc,gBAAgB;AAUpC,IAAM,gBAAgB,QAAM,YAKxB,EAAE,WAAW,UAAU,OAAO,SAAS,cAAc,YAAY,aAAa,GAAG,SACjF,QACG;CACH,MAAM,gBAAgB,SAAS;CAC/B,OACE,qBAAC,gBAAgB,SAAjB;EACO;EACL,WAAW,GACT,aAAa,MAAM,GACnB,oBAAoB,mBACpB,sBAAsB;GAAE,OAAO;GAAe;EAAQ,CAAC,GACvD,eAAe,QACf,SACF;EACA,sBAAoB;EACpB,gBAAc,WAAW;EACzB,GAAI;YAXN,CAaG,UACA,eACC,oBAAC,gBAAgB,MAAjB;GAAsB,SAAA;aACpB,oBAAC,aAAD,EAAa,WAAU,4BAA6B,CAAA;EAChC,CAAA,CAED;;AAE7B,CACF;AACA,cAAc,cAAc,gBAAgB,QAAQ;AAEpD,IAAM,uBAAuB,QAAM,YAGhC,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,gBAAgB,gBAAjB;CACO;CACL,WAAW,GAAG,wDAAwD,SAAS;CAC/E,GAAI;WAEJ,oBAAC,WAAD,EAAW,WAAU,SAAU,CAAA;AACD,CAAA,CACjC;AACD,qBAAqB,cAAc,gBAAgB,eAAe;AAElE,IAAM,yBAAyB,QAAM,YAGlC,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,gBAAgB,kBAAjB;CACO;CACL,WAAW,GAAG,wDAAwD,SAAS;CAC/E,GAAI;WAEJ,oBAAC,aAAD,EAAa,WAAU,SAAU,CAAA;AACD,CAAA,CACnC;AACD,uBAAuB,cAAc,gBAAgB,iBAAiB;AAEtE,IAAM,gBAAgB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B,WAAjB;CACO;CACL,WAAW,GAAG,4BAA4B,SAAS;CACnD,GAAI;AACL,CAAA,CACF;AACD,gBAAgB,cAAc,gBAAgB,UAAU"}
|
|
@@ -1,43 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../../lib/ds-utils.js";
|
|
3
3
|
import { ShadeScope } from "../../shade-scope.js";
|
|
4
|
+
import { overlayTint, useHostedModal, useModalOpen } from "../../lib/app-overlay.js";
|
|
5
|
+
import { keepOpenOnToast } from "../../lib/toast-press.js";
|
|
4
6
|
import { X } from "lucide-react";
|
|
5
7
|
import * as React$1 from "react";
|
|
6
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
9
|
import { cva } from "class-variance-authority";
|
|
8
10
|
import * as SheetPrimitive from "@radix-ui/react-dialog";
|
|
9
11
|
//#region src/components/ui/sheet.tsx
|
|
10
|
-
var Sheet =
|
|
12
|
+
var Sheet = (props) => {
|
|
13
|
+
const [rootProps, provideOpen] = useModalOpen(props);
|
|
14
|
+
return provideOpen(/* @__PURE__ */ jsx(SheetPrimitive.Root, { ...rootProps }));
|
|
15
|
+
};
|
|
11
16
|
var SheetTrigger = SheetPrimitive.Trigger;
|
|
12
17
|
var SheetClose = SheetPrimitive.Close;
|
|
13
18
|
var SheetPortal = SheetPrimitive.Portal;
|
|
14
19
|
var SheetOverlay = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(SheetPrimitive.Overlay, {
|
|
15
|
-
className: cn("fixed inset-0 z-50
|
|
20
|
+
className: cn("fixed inset-0 z-50 duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0", overlayTint("sheet"), className),
|
|
16
21
|
...props,
|
|
17
22
|
ref
|
|
18
23
|
}));
|
|
19
24
|
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
|
|
20
25
|
var sheetVariants = cva("fixed z-50 gap-4 bg-surface-elevated p-8 shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:animate-in data-[state=open]:duration-500", {
|
|
21
26
|
variants: { side: {
|
|
22
|
-
top: "inset-
|
|
23
|
-
bottom: "inset-
|
|
24
|
-
left: "inset-
|
|
25
|
-
right: "inset-
|
|
27
|
+
top: "top-[var(--ghost-safe-area-inset-top,0px)] right-[var(--ghost-safe-area-inset-right,0px)] left-[var(--ghost-safe-area-inset-left,0px)] border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
|
28
|
+
bottom: "right-[var(--ghost-safe-area-inset-right,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] left-[var(--ghost-safe-area-inset-left,0px)] border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
|
|
29
|
+
left: "top-[var(--ghost-safe-area-inset-top,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] left-[var(--ghost-safe-area-inset-left,0px)] h-[calc(100%_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px))] w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
|
|
30
|
+
right: "top-[var(--ghost-safe-area-inset-top,0px)] right-[var(--ghost-safe-area-inset-right,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] h-[calc(100%_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px))] w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"
|
|
26
31
|
} },
|
|
27
32
|
defaultVariants: { side: "right" }
|
|
28
33
|
});
|
|
29
|
-
var SheetContent = React$1.forwardRef(({ side = "right", className, children, ...props }, ref) =>
|
|
30
|
-
ref,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
var SheetContent = React$1.forwardRef(({ side = "right", className, children, ...props }, ref) => {
|
|
35
|
+
const { container, inApp, overlayStyle, ref: contentRef, wrap } = useHostedModal("sheet", ref);
|
|
36
|
+
return /* @__PURE__ */ jsx(SheetPortal, {
|
|
37
|
+
container,
|
|
38
|
+
children: /* @__PURE__ */ jsxs(ShadeScope, { children: [/* @__PURE__ */ jsx(SheetOverlay, { style: overlayStyle }), wrap(/* @__PURE__ */ jsxs(SheetPrimitive.Content, {
|
|
39
|
+
ref: contentRef,
|
|
40
|
+
className: cn(sheetVariants({ side }), inApp && "overflow-y-auto", inApp && (side === "top" || side === "bottom") && "max-h-[calc(100dvh_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px))]", inApp && (side === "left" || side === "right") && "w-[min(75%,calc(100vw_-_var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px)))]", className),
|
|
41
|
+
...props,
|
|
42
|
+
onInteractOutside: (event) => keepOpenOnToast(event, props.onInteractOutside),
|
|
43
|
+
children: [/* @__PURE__ */ jsxs(SheetPrimitive.Close, {
|
|
44
|
+
className: cn("top-4 right-4 z-50 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 disabled:pointer-events-none data-[state=open]:bg-secondary", inApp || side === "bottom" ? "absolute" : "fixed"),
|
|
45
|
+
onFocus: inApp ? (event) => event.currentTarget.scrollIntoView({ block: "nearest" }) : void 0,
|
|
46
|
+
children: [/* @__PURE__ */ jsx(X, { className: "size-4" }), /* @__PURE__ */ jsx("span", {
|
|
47
|
+
className: "sr-only",
|
|
48
|
+
children: "Close"
|
|
49
|
+
})]
|
|
50
|
+
}), children]
|
|
51
|
+
}))] })
|
|
52
|
+
});
|
|
53
|
+
});
|
|
41
54
|
SheetContent.displayName = SheetPrimitive.Content.displayName;
|
|
42
55
|
var SheetHeader = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
43
56
|
className: cn("flex flex-col space-y-1 text-center sm:text-left", className),
|
|
@@ -51,7 +64,7 @@ var SheetFooter = ({ className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
|
51
64
|
SheetFooter.displayName = "SheetFooter";
|
|
52
65
|
var SheetTitle = React$1.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(SheetPrimitive.Title, {
|
|
53
66
|
ref,
|
|
54
|
-
className: cn("text-xl font-semibold text-foreground", className),
|
|
67
|
+
className: cn("text-xl font-semibold text-foreground in-data-[admin7-design=true]:font-title", className),
|
|
55
68
|
...props
|
|
56
69
|
}));
|
|
57
70
|
SheetTitle.displayName = SheetPrimitive.Title.displayName;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet.js","names":[],"sources":["../../../src/components/ui/sheet.tsx"],"sourcesContent":["'use client';\n\n// Disable sourcemap for this file due to source map resolution errors\nimport * as React from 'react';\nimport * as SheetPrimitive from '@radix-ui/react-dialog';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { X } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\nimport { ShadeScope } from '@/shade-scope';\n\nconst Sheet = SheetPrimitive.Root;\n\nconst SheetTrigger = SheetPrimitive.Trigger;\n\nconst SheetClose = SheetPrimitive.Close;\n\nconst SheetPortal = SheetPrimitive.Portal;\n\nconst SheetOverlay = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Overlay\n className={cn(\n 'fixed inset-0 z-50
|
|
1
|
+
{"version":3,"file":"sheet.js","names":[],"sources":["../../../src/components/ui/sheet.tsx"],"sourcesContent":["'use client';\n\n// Disable sourcemap for this file due to source map resolution errors\nimport * as React from 'react';\nimport * as SheetPrimitive from '@radix-ui/react-dialog';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { X } from 'lucide-react';\n\nimport { overlayTint, useHostedModal, useModalOpen } from '@/lib/app-overlay';\nimport { cn } from '@/lib/utils';\nimport { keepOpenOnToast } from '@/lib/toast-press';\nimport { ShadeScope } from '@/shade-scope';\n\nconst Sheet = (props: React.ComponentProps<typeof SheetPrimitive.Root>) => {\n const [rootProps, provideOpen] = useModalOpen(props);\n return provideOpen(<SheetPrimitive.Root {...rootProps} />);\n};\n\nconst SheetTrigger = SheetPrimitive.Trigger;\n\nconst SheetClose = SheetPrimitive.Close;\n\nconst SheetPortal = SheetPrimitive.Portal;\n\nconst SheetOverlay = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Overlay\n className={cn(\n 'fixed inset-0 z-50 duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0',\n overlayTint('sheet'),\n className,\n )}\n {...props}\n ref={ref}\n />\n));\nSheetOverlay.displayName = SheetPrimitive.Overlay.displayName;\n\n// A side sheet sets a height as well as its top and bottom, so a caller's `top-*`, `bottom-*`\n// or `h-*` still works.\nconst sheetVariants = cva(\n 'fixed z-50 gap-4 bg-surface-elevated p-8 shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-200 data-[state=open]:animate-in data-[state=open]:duration-500',\n {\n variants: {\n side: {\n top: 'top-[var(--ghost-safe-area-inset-top,0px)] right-[var(--ghost-safe-area-inset-right,0px)] left-[var(--ghost-safe-area-inset-left,0px)] border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top',\n bottom:\n 'right-[var(--ghost-safe-area-inset-right,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] left-[var(--ghost-safe-area-inset-left,0px)] border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',\n left: 'top-[var(--ghost-safe-area-inset-top,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] left-[var(--ghost-safe-area-inset-left,0px)] h-[calc(100%_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px))] w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',\n right:\n 'top-[var(--ghost-safe-area-inset-top,0px)] right-[var(--ghost-safe-area-inset-right,0px)] bottom-[var(--ghost-safe-area-inset-bottom,0px)] h-[calc(100%_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px))] w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm',\n },\n },\n defaultVariants: {\n side: 'right',\n },\n },\n);\n\ninterface SheetContentProps\n extends\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,\n VariantProps<typeof sheetVariants> {}\n\nconst SheetContent = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Content>,\n SheetContentProps\n>(({ side = 'right', className, children, ...props }, ref) => {\n const { container, inApp, overlayStyle, ref: contentRef, wrap } = useHostedModal('sheet', ref);\n return (\n <SheetPortal container={container}>\n <ShadeScope>\n <SheetOverlay style={overlayStyle} />\n {wrap(\n <SheetPrimitive.Content\n ref={contentRef}\n className={cn(\n sheetVariants({ side }),\n inApp && 'overflow-y-auto',\n inApp &&\n (side === 'top' || side === 'bottom') &&\n 'max-h-[calc(100dvh_-_var(--ghost-safe-area-inset-top,0px)_-_var(--ghost-safe-area-inset-bottom,0px))]',\n // On the width, not max-width, so a caller's `max-w-*` only narrows it.\n inApp &&\n (side === 'left' || side === 'right') &&\n 'w-[min(75%,calc(100vw_-_var(--ghost-safe-area-inset-left,0px)_-_var(--ghost-safe-area-inset-right,0px)))]',\n className,\n )}\n {...props}\n onInteractOutside={(event) => keepOpenOnToast(event, props.onInteractOutside)}\n >\n <SheetPrimitive.Close\n className={cn(\n 'top-4 right-4 z-50 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 disabled:pointer-events-none data-[state=open]:bg-secondary',\n // In an app, the window's corner is under Admin's chrome, so use the sheet's.\n inApp || side === 'bottom' ? 'absolute' : 'fixed',\n )}\n // Radix's focus loop focuses this without scrolling, which can leave it out of sight\n // in a scrolled sheet.\n onFocus={\n inApp\n ? (event) => event.currentTarget.scrollIntoView({ block: 'nearest' })\n : undefined\n }\n >\n <X className=\"size-4\" />\n <span className=\"sr-only\">Close</span>\n </SheetPrimitive.Close>\n {children}\n </SheetPrimitive.Content>,\n )}\n </ShadeScope>\n </SheetPortal>\n );\n});\nSheetContent.displayName = SheetPrimitive.Content.displayName;\n\nconst SheetHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn('flex flex-col space-y-1 text-center sm:text-left', className)} {...props} />\n);\nSheetHeader.displayName = 'SheetHeader';\n\nconst SheetFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:gap-2', className)}\n {...props}\n />\n);\nSheetFooter.displayName = 'SheetFooter';\n\nconst SheetTitle = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Title\n ref={ref}\n className={cn(\n 'text-xl font-semibold text-foreground in-data-[admin7-design=true]:font-title',\n className,\n )}\n {...props}\n />\n));\nSheetTitle.displayName = SheetPrimitive.Title.displayName;\n\nconst SheetDescription = React.forwardRef<\n React.ElementRef<typeof SheetPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <SheetPrimitive.Description\n ref={ref}\n className={cn('text-sm text-muted-foreground', className)}\n {...props}\n />\n));\nSheetDescription.displayName = SheetPrimitive.Description.displayName;\n\nexport {\n Sheet,\n SheetPortal,\n SheetOverlay,\n SheetTrigger,\n SheetClose,\n SheetContent,\n SheetHeader,\n SheetFooter,\n SheetTitle,\n SheetDescription,\n};\n"],"mappings":";;;;;;;;;;;AAaA,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AAD,EAAG,WAAU,SAAU,CAAA,GACvB,oBAAC,QAAD;KAAM,WAAU;eAAU;IAAW,CAAA,CACjB;OACrB,QACqB;IAC1B,CACU,EAAA,CAAA;CACD,CAAA;AAEjB,CAAC;AACD,aAAa,cAAc,eAAe,QAAQ;AAElD,IAAM,eAAe,EAAE,WAAW,GAAG,YACnC,oBAAC,OAAD;CAAK,WAAW,GAAG,oDAAoD,SAAS;CAAG,GAAI;AAAQ,CAAA;AAEjG,YAAY,cAAc;AAE1B,IAAM,eAAe,EAAE,WAAW,GAAG,YACnC,oBAAC,OAAD;CACE,WAAW,GAAG,6DAA6D,SAAS;CACpF,GAAI;AACL,CAAA;AAEH,YAAY,cAAc;AAE1B,IAAM,aAAa,QAAM,YAGtB,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,eAAe,OAAhB;CACO;CACL,WAAW,GACT,iFACA,SACF;CACA,GAAI;AACL,CAAA,CACF;AACD,WAAW,cAAc,eAAe,MAAM;AAE9C,IAAM,mBAAmB,QAAM,YAG5B,EAAE,WAAW,GAAG,SAAS,QAC1B,oBAAC,eAAe,aAAhB;CACO;CACL,WAAW,GAAG,iCAAiC,SAAS;CACxD,GAAI;AACL,CAAA,CACF;AACD,iBAAiB,cAAc,eAAe,YAAY"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useIsMobile } from "../../hooks/use-mobile.js";
|
|
2
2
|
import { cn } from "../../lib/ds-utils.js";
|
|
3
3
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip.js";
|
|
4
|
-
import { Button } from "./button.js";
|
|
5
|
-
import { Input } from "./input.js";
|
|
6
4
|
import { Skeleton } from "./skeleton.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
7
6
|
import { Separator } from "./separator.js";
|
|
7
|
+
import { Input } from "./input.js";
|
|
8
8
|
import { Sheet, SheetContent } from "./sheet.js";
|
|
9
9
|
import { SidebarContext, useSidebar } from "./sidebar-context.js";
|
|
10
10
|
import { PanelLeft } from "lucide-react";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { cn } from "../../lib/ds-utils.js";
|
|
2
|
-
import { useShade } from "../../providers/shade-context.js";
|
|
3
2
|
import { Button } from "./button.js";
|
|
4
3
|
import { ArrowLeft, ArrowRight } from "lucide-react";
|
|
5
4
|
import React from "react";
|
|
@@ -40,22 +39,20 @@ var SimplePaginationNavigation = React.forwardRef(({ className, children, ...pro
|
|
|
40
39
|
});
|
|
41
40
|
});
|
|
42
41
|
SimplePaginationNavigation.displayName = "SimplePaginationNavigation";
|
|
43
|
-
var SimplePaginationPreviousButton = React.forwardRef(({ variant = "subtle", size, ...props }, ref) => {
|
|
44
|
-
const { isAdmin7 } = useShade();
|
|
42
|
+
var SimplePaginationPreviousButton = React.forwardRef(({ variant = "subtle", size = "icon", ...props }, ref) => {
|
|
45
43
|
return /* @__PURE__ */ jsx(Button, {
|
|
46
44
|
ref,
|
|
47
|
-
size
|
|
45
|
+
size,
|
|
48
46
|
variant,
|
|
49
47
|
...props,
|
|
50
48
|
children: /* @__PURE__ */ jsx(ArrowLeft, {})
|
|
51
49
|
});
|
|
52
50
|
});
|
|
53
51
|
SimplePaginationPreviousButton.displayName = "SimplePaginationPreviousButton";
|
|
54
|
-
var SimplePaginationNextButton = React.forwardRef(({ variant = "subtle", size, ...props }, ref) => {
|
|
55
|
-
const { isAdmin7 } = useShade();
|
|
52
|
+
var SimplePaginationNextButton = React.forwardRef(({ variant = "subtle", size = "icon", ...props }, ref) => {
|
|
56
53
|
return /* @__PURE__ */ jsx(Button, {
|
|
57
54
|
ref,
|
|
58
|
-
size
|
|
55
|
+
size,
|
|
59
56
|
variant,
|
|
60
57
|
...props,
|
|
61
58
|
children: /* @__PURE__ */ jsx(ArrowRight, {})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-pagination.js","names":[],"sources":["../../../src/components/ui/simple-pagination.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"simple-pagination.js","names":[],"sources":["../../../src/components/ui/simple-pagination.tsx"],"sourcesContent":["import { cn } from '@/lib/utils';\nimport React from 'react';\nimport { Button, ButtonProps } from './button';\nimport { ArrowLeft, ArrowRight } from 'lucide-react';\n\n/**\n * Use along with use-simple-pagination hook — see that file for more about how\n */\n\nconst SimplePagination = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, children, ...props }, ref) => {\n return (\n <div\n ref={ref}\n className={cn('flex items-center justify-between gap-4 pb-6 text-sm', className)}\n {...props}\n >\n {children}\n </div>\n );\n },\n);\n\nSimplePagination.displayName = 'SimplePagination';\n\ninterface SimplePaginationPagesProps extends React.HTMLAttributes<HTMLSpanElement> {\n currentPage?: string;\n totalPages?: string;\n}\n\nconst SimplePaginationPages = React.forwardRef<HTMLSpanElement, SimplePaginationPagesProps>(\n ({ className, currentPage, totalPages, ...props }, ref) => {\n return (\n <span ref={ref} className={cn('text-muted-foreground', className)} {...props}>\n Pages {currentPage} of {totalPages}\n </span>\n );\n },\n);\n\nSimplePaginationPages.displayName = 'SimplePaginationPages';\n\nconst SimplePaginationNavigation = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes<HTMLDivElement>\n>(({ className, children, ...props }, ref) => {\n return (\n <div ref={ref} className={cn('flex items-center gap-1.5', className)} {...props}>\n {children}\n </div>\n );\n});\n\nSimplePaginationNavigation.displayName = 'SimplePaginationNavigation';\n\nconst SimplePaginationPreviousButton = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ variant = 'subtle', size = 'icon', ...props }, ref) => {\n return (\n <Button ref={ref} size={size} variant={variant} {...props}>\n <ArrowLeft />\n </Button>\n );\n },\n);\n\nSimplePaginationPreviousButton.displayName = 'SimplePaginationPreviousButton';\n\nconst SimplePaginationNextButton = React.forwardRef<HTMLButtonElement, ButtonProps>(\n ({ variant = 'subtle', size = 'icon', ...props }, ref) => {\n return (\n <Button ref={ref} size={size} variant={variant} {...props}>\n <ArrowRight />\n </Button>\n );\n },\n);\n\nSimplePaginationNextButton.displayName = 'SimplePaginationNextButton';\n\nexport {\n SimplePagination,\n SimplePaginationPages,\n SimplePaginationNavigation,\n SimplePaginationPreviousButton,\n SimplePaginationNextButton,\n};\n"],"mappings":";;;;;;;;;AASA,IAAM,mBAAmB,MAAM,YAC5B,EAAE,WAAW,UAAU,GAAG,SAAS,QAAQ;CAC1C,OACE,oBAAC,OAAD;EACO;EACL,WAAW,GAAG,wDAAwD,SAAS;EAC/E,GAAI;EAEH;CACE,CAAA;AAET,CACF;AAEA,iBAAiB,cAAc;AAO/B,IAAM,wBAAwB,MAAM,YACjC,EAAE,WAAW,aAAa,YAAY,GAAG,SAAS,QAAQ;CACzD,OACE,qBAAC,QAAD;EAAW;EAAK,WAAW,GAAG,yBAAyB,SAAS;EAAG,GAAI;YAAvE;GAA8E;GACrE;GAAY;GAAK;EACpB;;AAEV,CACF;AAEA,sBAAsB,cAAc;AAEpC,IAAM,6BAA6B,MAAM,YAGtC,EAAE,WAAW,UAAU,GAAG,SAAS,QAAQ;CAC5C,OACE,oBAAC,OAAD;EAAU;EAAK,WAAW,GAAG,6BAA6B,SAAS;EAAG,GAAI;EACvE;CACE,CAAA;AAET,CAAC;AAED,2BAA2B,cAAc;AAEzC,IAAM,iCAAiC,MAAM,YAC1C,EAAE,UAAU,UAAU,OAAO,QAAQ,GAAG,SAAS,QAAQ;CACxD,OACE,oBAAC,QAAD;EAAa;EAAW;EAAe;EAAS,GAAI;YAClD,oBAAC,WAAD,CAAY,CAAA;CACN,CAAA;AAEZ,CACF;AAEA,+BAA+B,cAAc;AAE7C,IAAM,6BAA6B,MAAM,YACtC,EAAE,UAAU,UAAU,OAAO,QAAQ,GAAG,SAAS,QAAQ;CACxD,OACE,oBAAC,QAAD;EAAa;EAAW;EAAe;EAAS,GAAI;YAClD,oBAAC,YAAD,CAAa,CAAA;CACP,CAAA;AAEZ,CACF;AAEA,2BAA2B,cAAc"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { cn } from "../../lib/ds-utils.js";
|
|
2
2
|
import { Separator } from "./separator.js";
|
|
3
3
|
import { Menu } from "lucide-react";
|
|
4
|
-
import { Fragment, useState } from "react";
|
|
4
|
+
import { Fragment, useRef, useState } from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { DndContext, DragOverlay, closestCenter } from "@dnd-kit/core";
|
|
7
|
-
import { SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
8
|
-
import { CSS } from "@dnd-kit/utilities";
|
|
6
|
+
import { DndContext, DragOverlay, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
|
|
7
|
+
import { SortableContext, hasSortableData, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
8
|
+
import { CSS, isKeyboardEvent } from "@dnd-kit/utilities";
|
|
9
9
|
//#region src/components/ui/sortable-list.tsx
|
|
10
10
|
var DragIndicator = ({ isDragging, dragHandleAttributes, dragHandleListeners, dragHandleClass, dragHandleLabel, className, ...props }) => /* @__PURE__ */ jsx("button", {
|
|
11
11
|
"aria-label": dragHandleLabel || "Reorder",
|
|
@@ -48,14 +48,101 @@ var SortableItem = ({ id, children, separator, dragHandleClass, dragHandleLabel,
|
|
|
48
48
|
});
|
|
49
49
|
};
|
|
50
50
|
/**
|
|
51
|
+
* Moves the dragged item one place per Up or Down arrow press. dnd-kit's
|
|
52
|
+
* `sortableKeyboardCoordinates` picks the next item by distance, which skips or sticks on rows of
|
|
53
|
+
* different heights. This picks it by index instead, and collision detection follows that pick
|
|
54
|
+
* during a keyboard drag. The dragged item moves to the slot it will drop into.
|
|
55
|
+
*/
|
|
56
|
+
var createKeyboardMoves = () => {
|
|
57
|
+
let targetId = null;
|
|
58
|
+
const coordinateGetter = (event, { currentCoordinates, context: { active, droppableRects, droppableContainers } }) => {
|
|
59
|
+
if (!event.code.startsWith("Arrow")) return;
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
const step = event.code === "ArrowDown" ? 1 : event.code === "ArrowUp" ? -1 : 0;
|
|
62
|
+
if (!step) return;
|
|
63
|
+
const activeContainer = active && droppableContainers.get(active.id);
|
|
64
|
+
const activeRect = active && droppableRects.get(active.id);
|
|
65
|
+
if (!active || !activeRect || !hasSortableData(activeContainer)) return;
|
|
66
|
+
const { items } = activeContainer.data.current.sortable;
|
|
67
|
+
const from = targetId === null ? -1 : items.indexOf(targetId);
|
|
68
|
+
const nextId = items[(from === -1 ? items.indexOf(active.id) : from) + step];
|
|
69
|
+
const nextRect = nextId === void 0 ? void 0 : droppableRects.get(nextId);
|
|
70
|
+
if (nextId === void 0 || !nextRect) return;
|
|
71
|
+
targetId = nextId;
|
|
72
|
+
const offset = items.indexOf(nextId) - items.indexOf(active.id);
|
|
73
|
+
const top = offset > 0 ? nextRect.top + nextRect.height - activeRect.height : offset < 0 ? nextRect.top : activeRect.top;
|
|
74
|
+
return {
|
|
75
|
+
x: currentCoordinates.x,
|
|
76
|
+
y: top
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const collisionDetection = (args) => {
|
|
80
|
+
if (targetId === null || args.pointerCoordinates !== null) return closestCenter(args);
|
|
81
|
+
const pinnedId = targetId;
|
|
82
|
+
return args.droppableContainers.some(({ id }) => id === pinnedId) ? [{ id: pinnedId }] : [{ id: args.active.id }];
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
keyboardSensorOptions: {
|
|
86
|
+
coordinateGetter,
|
|
87
|
+
scrollBehavior: "auto"
|
|
88
|
+
},
|
|
89
|
+
collisionDetection,
|
|
90
|
+
/** Where a keyboard drag will drop, so the drop doesn't wait on a scroll to update `over`. */
|
|
91
|
+
target: () => targetId,
|
|
92
|
+
/** A keyboard drag starts on its own row, so scrolling the list can't move it. */
|
|
93
|
+
reset: (id) => {
|
|
94
|
+
targetId = id;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
var screenReaderInstructions = { draggable: "To pick up an item, press Space or Enter. Use the Up and Down arrow keys to move it. Press Space or Enter again to drop it in its new place, or press Escape to cancel." };
|
|
99
|
+
/**
|
|
51
100
|
* A vertically sortable list. Items must keep stable IDs across renders.
|
|
52
101
|
*/
|
|
53
|
-
var SortableList = ({ title, titleSeparator, hint, items, itemSeparator = true, dragHandleClass, getDragHandleLabel, onMove, renderItem, container = (props) => /* @__PURE__ */ jsx(DefaultContainer, { ...props }), wrapper: Wrapper = Fragment, dragOverlayWrapper, className, ...props }) => {
|
|
102
|
+
var SortableList = ({ title, titleSeparator, hint, items, itemSeparator = true, dragHandleClass, getItemLabel, getDragHandleLabel, onMove, renderItem, container = (props) => /* @__PURE__ */ jsx(DefaultContainer, { ...props }), wrapper: Wrapper = Fragment, dragOverlayWrapper, className, ...props }) => {
|
|
54
103
|
const [draggingId, setDraggingId] = useState(null);
|
|
55
104
|
const draggingItem = items.find(({ id }) => id === draggingId);
|
|
105
|
+
const lastOverId = useRef(null);
|
|
106
|
+
const [keyboardMoves] = useState(createKeyboardMoves);
|
|
107
|
+
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, keyboardMoves.keyboardSensorOptions));
|
|
108
|
+
const handleLabel = (item) => {
|
|
109
|
+
const name = getItemLabel?.(item).trim();
|
|
110
|
+
return getDragHandleLabel?.(item) || (name ? `Reorder ${name}` : void 0);
|
|
111
|
+
};
|
|
112
|
+
const indexOf = (id) => items.findIndex((item) => item.id === String(id));
|
|
113
|
+
const nameOf = (id) => {
|
|
114
|
+
const item = items[indexOf(id)];
|
|
115
|
+
return item && (getItemLabel?.(item).trim() || getDragHandleLabel?.(item).trim()) || String(id);
|
|
116
|
+
};
|
|
117
|
+
const dropId = (active, over) => {
|
|
118
|
+
const target = keyboardMoves.target();
|
|
119
|
+
if (target === null) return over?.id ?? null;
|
|
120
|
+
return indexOf(target) === -1 ? active.id : target;
|
|
121
|
+
};
|
|
122
|
+
const removedMessage = "Moving cancelled. The item is no longer in the list.";
|
|
123
|
+
const positionOf = (id) => `position ${indexOf(id) + 1} of ${items.length}`;
|
|
124
|
+
const announcements = {
|
|
125
|
+
onDragStart: ({ active }) => {
|
|
126
|
+
lastOverId.current = active.id;
|
|
127
|
+
return `Picked up ${nameOf(active.id)}, ${positionOf(active.id)}.`;
|
|
128
|
+
},
|
|
129
|
+
onDragOver: ({ active, over }) => {
|
|
130
|
+
const overId = over?.id ?? null;
|
|
131
|
+
if (overId === lastOverId.current) return;
|
|
132
|
+
lastOverId.current = overId;
|
|
133
|
+
return overId === null ? `${nameOf(active.id)} is no longer over the list.` : `${nameOf(active.id)} moved to ${positionOf(overId)}.`;
|
|
134
|
+
},
|
|
135
|
+
onDragEnd: ({ active, over }) => {
|
|
136
|
+
const overId = dropId(active, over);
|
|
137
|
+
if (indexOf(active.id) === -1) return removedMessage;
|
|
138
|
+
return overId === null ? `${nameOf(active.id)} dropped. It stays at ${positionOf(active.id)}.` : `${nameOf(active.id)} dropped at ${positionOf(overId)}.`;
|
|
139
|
+
},
|
|
140
|
+
onDragCancel: ({ active }) => indexOf(active.id) === -1 ? removedMessage : `Moving cancelled. ${nameOf(active.id)} stays at ${positionOf(active.id)}.`
|
|
141
|
+
};
|
|
56
142
|
if (!items.length) return null;
|
|
57
143
|
return /* @__PURE__ */ jsxs("div", {
|
|
58
144
|
className: cn("w-full", className),
|
|
145
|
+
"data-row-dragging": draggingId !== null ? "true" : void 0,
|
|
59
146
|
...props,
|
|
60
147
|
children: [
|
|
61
148
|
title && /* @__PURE__ */ jsxs("div", {
|
|
@@ -66,20 +153,32 @@ var SortableList = ({ title, titleSeparator, hint, items, itemSeparator = true,
|
|
|
66
153
|
}), titleSeparator && /* @__PURE__ */ jsx(Separator, {})]
|
|
67
154
|
}),
|
|
68
155
|
/* @__PURE__ */ jsxs(DndContext, {
|
|
69
|
-
|
|
156
|
+
accessibility: {
|
|
157
|
+
announcements,
|
|
158
|
+
screenReaderInstructions
|
|
159
|
+
},
|
|
160
|
+
collisionDetection: keyboardMoves.collisionDetection,
|
|
161
|
+
sensors,
|
|
70
162
|
onDragCancel: () => setDraggingId(null),
|
|
71
163
|
onDragEnd: (event) => {
|
|
72
|
-
|
|
73
|
-
|
|
164
|
+
try {
|
|
165
|
+
const overId = dropId(event.active, event.over);
|
|
166
|
+
if (overId !== null && indexOf(event.active.id) !== -1) onMove(String(event.active.id), String(overId));
|
|
167
|
+
} finally {
|
|
168
|
+
setDraggingId(null);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
onDragStart: (event) => {
|
|
172
|
+
keyboardMoves.reset(isKeyboardEvent(event.activatorEvent) ? event.active.id : null);
|
|
173
|
+
setDraggingId(String(event.active.id));
|
|
74
174
|
},
|
|
75
|
-
onDragStart: (event) => setDraggingId(String(event.active.id)),
|
|
76
175
|
children: [/* @__PURE__ */ jsx(Wrapper, { children: /* @__PURE__ */ jsx(SortableContext, {
|
|
77
176
|
items,
|
|
78
177
|
strategy: verticalListSortingStrategy,
|
|
79
178
|
children: items.map((item) => /* @__PURE__ */ jsx(SortableItem, {
|
|
80
179
|
container,
|
|
81
180
|
dragHandleClass,
|
|
82
|
-
dragHandleLabel:
|
|
181
|
+
dragHandleLabel: handleLabel(item),
|
|
83
182
|
id: item.id,
|
|
84
183
|
separator: itemSeparator,
|
|
85
184
|
children: renderItem(item)
|
|
@@ -89,7 +188,7 @@ var SortableList = ({ title, titleSeparator, hint, items, itemSeparator = true,
|
|
|
89
188
|
children: draggingItem ? container({
|
|
90
189
|
id: draggingItem.id,
|
|
91
190
|
isDragging: true,
|
|
92
|
-
dragHandleLabel:
|
|
191
|
+
dragHandleLabel: handleLabel(draggingItem),
|
|
93
192
|
children: renderItem(draggingItem)
|
|
94
193
|
}) : null
|
|
95
194
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortable-list.js","names":[],"sources":["../../../src/components/ui/sortable-list.tsx"],"sourcesContent":["import {\n DndContext,\n DragOverlay,\n type DraggableAttributes,\n type DraggableSyntheticListeners,\n closestCenter,\n} from '@dnd-kit/core';\nimport { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport { Menu } from 'lucide-react';\nimport {\n type CSSProperties,\n type ElementType,\n Fragment,\n type HTMLAttributes,\n type ReactNode,\n useState,\n} from 'react';\nimport { Separator } from './separator';\nimport { cn } from '@/lib/utils';\n\nexport interface SortableItemContainerProps {\n id: string;\n setRef?: (element: HTMLElement | null) => void;\n isDragging: boolean;\n dragHandleAttributes?: DraggableAttributes;\n dragHandleListeners?: DraggableSyntheticListeners;\n dragHandleClass?: string;\n dragHandleLabel?: string;\n style?: CSSProperties;\n children: ReactNode;\n separator?: boolean;\n}\n\nexport type DragIndicatorProps = Pick<\n SortableItemContainerProps,\n | 'isDragging'\n | 'dragHandleAttributes'\n | 'dragHandleListeners'\n | 'dragHandleClass'\n | 'dragHandleLabel'\n> &\n HTMLAttributes<HTMLButtonElement>;\n\nexport const DragIndicator = ({\n isDragging,\n dragHandleAttributes,\n dragHandleListeners,\n dragHandleClass,\n dragHandleLabel,\n className,\n ...props\n}: DragIndicatorProps) => (\n <button\n aria-label={dragHandleLabel || 'Reorder'}\n className={cn(\n 'inline-flex items-center justify-center text-muted-foreground opacity-50 transition-opacity group-hover:opacity-100',\n isDragging ? 'cursor-grabbing' : 'cursor-grab',\n dragHandleClass,\n className,\n )}\n type=\"button\"\n {...dragHandleAttributes}\n {...dragHandleListeners}\n {...props}\n >\n <Menu aria-hidden=\"true\" className=\"size-4\" />\n </button>\n);\n\nconst DefaultContainer = ({\n setRef,\n isDragging,\n style,\n separator,\n children,\n ...props\n}: SortableItemContainerProps) => (\n <div\n ref={setRef}\n className={cn(\n 'group flex w-full items-center gap-3 bg-background py-1',\n separator && 'border-b border-border',\n isDragging && 'opacity-75',\n )}\n style={style}\n >\n <DragIndicator className=\"h-7\" isDragging={isDragging} {...props} />\n {children}\n </div>\n);\n\nconst SortableItem = ({\n id,\n children,\n separator,\n dragHandleClass,\n dragHandleLabel,\n container,\n}: {\n id: string;\n children: ReactNode;\n separator?: boolean;\n dragHandleClass?: string;\n dragHandleLabel?: string;\n container: (props: SortableItemContainerProps) => ReactNode;\n}) => {\n const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id });\n\n return container({\n id,\n setRef: setNodeRef,\n isDragging: false,\n separator,\n dragHandleClass,\n dragHandleLabel,\n dragHandleAttributes: attributes,\n dragHandleListeners: listeners,\n style: {\n transform: CSS.Transform.toString(transform),\n transition,\n },\n children,\n });\n};\n\nexport interface SortableListProps<\n Item extends { id: string },\n> extends HTMLAttributes<HTMLDivElement> {\n title?: string;\n titleSeparator?: boolean;\n hint?: ReactNode;\n items: Item[];\n itemSeparator?: boolean;\n dragHandleClass?: string;\n getDragHandleLabel?: (item: Item) => string;\n onMove: (id: string, overId: string) => void;\n renderItem: (item: Item) => ReactNode;\n container?: (props: SortableItemContainerProps) => ReactNode;\n wrapper?: ElementType;\n dragOverlayWrapper?: keyof JSX.IntrinsicElements;\n}\n\n/**\n * A vertically sortable list. Items must keep stable IDs across renders.\n */\nexport const SortableList = <Item extends { id: string }>({\n title,\n titleSeparator,\n hint,\n items,\n itemSeparator = true,\n dragHandleClass,\n getDragHandleLabel,\n onMove,\n renderItem,\n container = (props) => <DefaultContainer {...props} />,\n wrapper: Wrapper = Fragment,\n dragOverlayWrapper,\n className,\n ...props\n}: SortableListProps<Item>) => {\n const [draggingId, setDraggingId] = useState<string | null>(null);\n const draggingItem = items.find(({ id }) => id === draggingId);\n\n if (!items.length) {\n return null;\n }\n\n return (\n <div className={cn('w-full', className)} {...props}>\n {title && (\n <div className={cn('mb-2', titleSeparator && 'space-y-1')}>\n <h6 className=\"text-base font-semibold text-muted-foreground\">{title}</h6>\n {titleSeparator && <Separator />}\n </div>\n )}\n <DndContext\n collisionDetection={closestCenter}\n onDragCancel={() => setDraggingId(null)}\n onDragEnd={(event) => {\n if (event.over) {\n onMove(String(event.active.id), String(event.over.id));\n }\n setDraggingId(null);\n }}\n onDragStart={(event) => setDraggingId(String(event.active.id))}\n >\n <Wrapper>\n <SortableContext items={items} strategy={verticalListSortingStrategy}>\n {items.map((item) => (\n <SortableItem\n key={item.id}\n container={container}\n dragHandleClass={dragHandleClass}\n dragHandleLabel={getDragHandleLabel?.(item)}\n id={item.id}\n separator={itemSeparator}\n >\n {renderItem(item)}\n </SortableItem>\n ))}\n </SortableContext>\n </Wrapper>\n <DragOverlay wrapperElement={dragOverlayWrapper}>\n {draggingItem\n ? container({\n id: draggingItem.id,\n isDragging: true,\n dragHandleLabel: getDragHandleLabel?.(draggingItem),\n children: renderItem(draggingItem),\n })\n : null}\n </DragOverlay>\n </DndContext>\n {hint && (\n <div className=\"space-y-1 pt-1 text-sm text-muted-foreground\">\n {!itemSeparator && <Separator />}\n {hint}\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;AA4CA,IAAa,iBAAiB,EAC5B,YACA,sBACA,qBACA,iBACA,iBACA,WACA,GAAG,YAEH,oBAAC,UAAD;CACE,cAAY,mBAAmB;CAC/B,WAAW,GACT,uHACA,aAAa,oBAAoB,eACjC,iBACA,SACF;CACA,MAAK;CACL,GAAI;CACJ,GAAI;CACJ,GAAI;WAEJ,oBAAC,MAAD;EAAM,eAAY;EAAO,WAAU;CAAU,CAAA;AACvC,CAAA;AAGV,IAAM,oBAAoB,EACxB,QACA,YACA,OACA,WACA,UACA,GAAG,YAEH,qBAAC,OAAD;CACE,KAAK;CACL,WAAW,GACT,2DACA,aAAa,0BACb,cAAc,YAChB;CACO;WAPT,CASE,oBAAC,eAAD;EAAe,WAAU;EAAkB;EAAY,GAAI;CAAQ,CAAA,GAClE,QACE;;AAGP,IAAM,gBAAgB,EACpB,IACA,UACA,WACA,iBACA,iBACA,gBAQI;CACJ,MAAM,EAAE,YAAY,WAAW,YAAY,WAAW,eAAe,YAAY,EAAE,GAAG,CAAC;CAEvF,OAAO,UAAU;EACf;EACA,QAAQ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eACG,UAAU;MACR,IAAI,aAAa;MACjB,YAAY;MACZ,iBAAiB,qBAAqB,YAAY;MAClD,UAAU,WAAW,YAAY;KACnC,CAAC,IACD;IACO,CAAA,CACH;;GACX,QACC,qBAAC,OAAD;IAAK,WAAU;cAAf,CACG,CAAC,iBAAiB,oBAAC,WAAD,CAAY,CAAA,GAC9B,IACE;;EAEJ;;AAET"}
|
|
1
|
+
{"version":3,"file":"sortable-list.js","names":[],"sources":["../../../src/components/ui/sortable-list.tsx"],"sourcesContent":["import {\n type Announcements,\n type CollisionDetection,\n DndContext,\n DragOverlay,\n type DraggableAttributes,\n type DraggableSyntheticListeners,\n type KeyboardCoordinateGetter,\n KeyboardSensor,\n PointerSensor,\n type ScreenReaderInstructions,\n type UniqueIdentifier,\n closestCenter,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport {\n SortableContext,\n hasSortableData,\n useSortable,\n verticalListSortingStrategy,\n} from '@dnd-kit/sortable';\nimport { CSS, isKeyboardEvent } from '@dnd-kit/utilities';\nimport { Menu } from 'lucide-react';\nimport {\n type CSSProperties,\n type ElementType,\n Fragment,\n type HTMLAttributes,\n type ReactNode,\n useRef,\n useState,\n} from 'react';\nimport { Separator } from './separator';\nimport { cn } from '@/lib/utils';\n\nexport interface SortableItemContainerProps {\n id: string;\n setRef?: (element: HTMLElement | null) => void;\n isDragging: boolean;\n dragHandleAttributes?: DraggableAttributes;\n dragHandleListeners?: DraggableSyntheticListeners;\n dragHandleClass?: string;\n dragHandleLabel?: string;\n style?: CSSProperties;\n children: ReactNode;\n separator?: boolean;\n}\n\nexport type DragIndicatorProps = Pick<\n SortableItemContainerProps,\n | 'isDragging'\n | 'dragHandleAttributes'\n | 'dragHandleListeners'\n | 'dragHandleClass'\n | 'dragHandleLabel'\n> &\n HTMLAttributes<HTMLButtonElement>;\n\nexport const DragIndicator = ({\n isDragging,\n dragHandleAttributes,\n dragHandleListeners,\n dragHandleClass,\n dragHandleLabel,\n className,\n ...props\n}: DragIndicatorProps) => (\n <button\n aria-label={dragHandleLabel || 'Reorder'}\n className={cn(\n 'inline-flex items-center justify-center text-muted-foreground opacity-50 transition-opacity group-hover:opacity-100',\n isDragging ? 'cursor-grabbing' : 'cursor-grab',\n dragHandleClass,\n className,\n )}\n type=\"button\"\n {...dragHandleAttributes}\n {...dragHandleListeners}\n {...props}\n >\n <Menu aria-hidden=\"true\" className=\"size-4\" />\n </button>\n);\n\nconst DefaultContainer = ({\n setRef,\n isDragging,\n style,\n separator,\n children,\n ...props\n}: SortableItemContainerProps) => (\n <div\n ref={setRef}\n className={cn(\n 'group flex w-full items-center gap-3 bg-background py-1',\n separator && 'border-b border-border',\n isDragging && 'opacity-75',\n )}\n style={style}\n >\n <DragIndicator className=\"h-7\" isDragging={isDragging} {...props} />\n {children}\n </div>\n);\n\nconst SortableItem = ({\n id,\n children,\n separator,\n dragHandleClass,\n dragHandleLabel,\n container,\n}: {\n id: string;\n children: ReactNode;\n separator?: boolean;\n dragHandleClass?: string;\n dragHandleLabel?: string;\n container: (props: SortableItemContainerProps) => ReactNode;\n}) => {\n const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id });\n\n return container({\n id,\n setRef: setNodeRef,\n isDragging: false,\n separator,\n dragHandleClass,\n dragHandleLabel,\n dragHandleAttributes: attributes,\n dragHandleListeners: listeners,\n style: {\n transform: CSS.Transform.toString(transform),\n transition,\n },\n children,\n });\n};\n\n/**\n * Moves the dragged item one place per Up or Down arrow press. dnd-kit's\n * `sortableKeyboardCoordinates` picks the next item by distance, which skips or sticks on rows of\n * different heights. This picks it by index instead, and collision detection follows that pick\n * during a keyboard drag. The dragged item moves to the slot it will drop into.\n */\nconst createKeyboardMoves = () => {\n let targetId: UniqueIdentifier | null = null;\n\n const coordinateGetter: KeyboardCoordinateGetter = (\n event,\n { currentCoordinates, context: { active, droppableRects, droppableContainers } },\n ) => {\n if (!event.code.startsWith('Arrow')) {\n return undefined;\n }\n event.preventDefault();\n const step = event.code === 'ArrowDown' ? 1 : event.code === 'ArrowUp' ? -1 : 0;\n if (!step) {\n return undefined;\n }\n\n const activeContainer = active && droppableContainers.get(active.id);\n const activeRect = active && droppableRects.get(active.id);\n if (!active || !activeRect || !hasSortableData(activeContainer)) {\n return undefined;\n }\n const { items } = activeContainer.data.current.sortable;\n // Carry on from the active item if the target has left the list mid-drag.\n const from = targetId === null ? -1 : items.indexOf(targetId);\n const nextId = items[(from === -1 ? items.indexOf(active.id) : from) + step];\n const nextRect = nextId === undefined ? undefined : droppableRects.get(nextId);\n if (nextId === undefined || !nextRect) {\n return undefined;\n }\n targetId = nextId;\n\n const offset = items.indexOf(nextId) - items.indexOf(active.id);\n const top =\n offset > 0\n ? nextRect.top + nextRect.height - activeRect.height\n : offset < 0\n ? nextRect.top\n : activeRect.top;\n return { x: currentCoordinates.x, y: top };\n };\n\n // If the target leaves the list mid-drag, the lifted item stays where it started.\n const collisionDetection: CollisionDetection = (args) => {\n if (targetId === null || args.pointerCoordinates !== null) {\n return closestCenter(args);\n }\n const pinnedId = targetId;\n return args.droppableContainers.some(({ id }) => id === pinnedId)\n ? [{ id: pinnedId }]\n : [{ id: args.active.id }];\n };\n\n return {\n // One options object, so the sensors and handle listeners stay the same across renders.\n // Scrolls instantly, so a key pressed mid-scroll can't leave the lifted item off its slot.\n keyboardSensorOptions: { coordinateGetter, scrollBehavior: 'auto' as const },\n collisionDetection,\n /** Where a keyboard drag will drop, so the drop doesn't wait on a scroll to update `over`. */\n target: () => targetId,\n /** A keyboard drag starts on its own row, so scrolling the list can't move it. */\n reset: (id: UniqueIdentifier | null) => {\n targetId = id;\n },\n };\n};\n\nconst screenReaderInstructions: ScreenReaderInstructions = {\n draggable:\n 'To pick up an item, press Space or Enter. Use the Up and Down arrow keys to move it. Press Space or Enter again to drop it in its new place, or press Escape to cancel.',\n};\n\nexport interface SortableListProps<\n Item extends { id: string },\n> extends HTMLAttributes<HTMLDivElement> {\n title?: string;\n titleSeparator?: boolean;\n hint?: ReactNode;\n items: Item[];\n itemSeparator?: boolean;\n dragHandleClass?: string;\n /** The item's name, which screen readers announce while it's dragged. Defaults to `getDragHandleLabel`, then the id. */\n getItemLabel?: (item: Item) => string;\n /** The drag handle's accessible name. Defaults to `Reorder <item label>` when `getItemLabel` is set. */\n getDragHandleLabel?: (item: Item) => string;\n onMove: (id: string, overId: string) => void;\n renderItem: (item: Item) => ReactNode;\n container?: (props: SortableItemContainerProps) => ReactNode;\n wrapper?: ElementType;\n dragOverlayWrapper?: keyof JSX.IntrinsicElements;\n}\n\n/**\n * A vertically sortable list. Items must keep stable IDs across renders.\n */\nexport const SortableList = <Item extends { id: string }>({\n title,\n titleSeparator,\n hint,\n items,\n itemSeparator = true,\n dragHandleClass,\n getItemLabel,\n getDragHandleLabel,\n onMove,\n renderItem,\n container = (props) => <DefaultContainer {...props} />,\n wrapper: Wrapper = Fragment,\n dragOverlayWrapper,\n className,\n ...props\n}: SortableListProps<Item>) => {\n const [draggingId, setDraggingId] = useState<string | null>(null);\n const draggingItem = items.find(({ id }) => id === draggingId);\n // dnd-kit reports the row over itself as soon as it's picked up; only a change of place is a move.\n const lastOverId = useRef<UniqueIdentifier | null>(null);\n const [keyboardMoves] = useState(createKeyboardMoves);\n // dnd-kit's default keyboard sensor moves 25px per press; this one moves to the next item.\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, keyboardMoves.keyboardSensorOptions),\n );\n\n const handleLabel = (item: Item) => {\n const name = getItemLabel?.(item).trim();\n return getDragHandleLabel?.(item) || (name ? `Reorder ${name}` : undefined);\n };\n const indexOf = (id: UniqueIdentifier) => items.findIndex((item) => item.id === String(id));\n const nameOf = (id: UniqueIdentifier) => {\n const item = items[indexOf(id)];\n return (\n (item && (getItemLabel?.(item).trim() || getDragHandleLabel?.(item).trim())) || String(id)\n );\n };\n const dropId = (active: { id: UniqueIdentifier }, over: { id: UniqueIdentifier } | null) => {\n const target = keyboardMoves.target();\n if (target === null) {\n return over?.id ?? null;\n }\n return indexOf(target) === -1 ? active.id : target;\n };\n const removedMessage = 'Moving cancelled. The item is no longer in the list.';\n const positionOf = (id: UniqueIdentifier) => `position ${indexOf(id) + 1} of ${items.length}`;\n const announcements: Announcements = {\n onDragStart: ({ active }) => {\n lastOverId.current = active.id;\n return `Picked up ${nameOf(active.id)}, ${positionOf(active.id)}.`;\n },\n onDragOver: ({ active, over }) => {\n const overId = over?.id ?? null;\n if (overId === lastOverId.current) {\n return undefined;\n }\n lastOverId.current = overId;\n return overId === null\n ? `${nameOf(active.id)} is no longer over the list.`\n : `${nameOf(active.id)} moved to ${positionOf(overId)}.`;\n },\n onDragEnd: ({ active, over }) => {\n const overId = dropId(active, over);\n if (indexOf(active.id) === -1) {\n return removedMessage;\n }\n return overId === null\n ? `${nameOf(active.id)} dropped. It stays at ${positionOf(active.id)}.`\n : `${nameOf(active.id)} dropped at ${positionOf(overId)}.`;\n },\n onDragCancel: ({ active }) =>\n indexOf(active.id) === -1\n ? removedMessage\n : `Moving cancelled. ${nameOf(active.id)} stays at ${positionOf(active.id)}.`,\n };\n\n if (!items.length) {\n return null;\n }\n\n return (\n <div\n className={cn('w-full', className)}\n data-row-dragging={draggingId !== null ? 'true' : undefined}\n {...props}\n >\n {title && (\n <div className={cn('mb-2', titleSeparator && 'space-y-1')}>\n <h6 className=\"text-base font-semibold text-muted-foreground\">{title}</h6>\n {titleSeparator && <Separator />}\n </div>\n )}\n <DndContext\n accessibility={{ announcements, screenReaderInstructions }}\n collisionDetection={keyboardMoves.collisionDetection}\n sensors={sensors}\n onDragCancel={() => setDraggingId(null)}\n onDragEnd={(event) => {\n try {\n const overId = dropId(event.active, event.over);\n // The lifted item may have been removed from the list during the drag.\n if (overId !== null && indexOf(event.active.id) !== -1) {\n onMove(String(event.active.id), String(overId));\n }\n } finally {\n setDraggingId(null);\n }\n }}\n onDragStart={(event) => {\n // A drag keeps its target until the next one starts, so the drop announcement can read it.\n keyboardMoves.reset(isKeyboardEvent(event.activatorEvent) ? event.active.id : null);\n setDraggingId(String(event.active.id));\n }}\n >\n <Wrapper>\n <SortableContext items={items} strategy={verticalListSortingStrategy}>\n {items.map((item) => (\n <SortableItem\n key={item.id}\n container={container}\n dragHandleClass={dragHandleClass}\n dragHandleLabel={handleLabel(item)}\n id={item.id}\n separator={itemSeparator}\n >\n {renderItem(item)}\n </SortableItem>\n ))}\n </SortableContext>\n </Wrapper>\n <DragOverlay wrapperElement={dragOverlayWrapper}>\n {draggingItem\n ? container({\n id: draggingItem.id,\n isDragging: true,\n dragHandleLabel: handleLabel(draggingItem),\n children: renderItem(draggingItem),\n })\n : null}\n </DragOverlay>\n </DndContext>\n {hint && (\n <div className=\"space-y-1 pt-1 text-sm text-muted-foreground\">\n {!itemSeparator && <Separator />}\n {hint}\n </div>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;AA2DA,IAAa,iBAAiB,EAC5B,YACA,sBACA,qBACA,iBACA,iBACA,WACA,GAAG,YAEH,oBAAC,UAAD;CACE,cAAY,mBAAmB;CAC/B,WAAW,GACT,uHACA,aAAa,oBAAoB,eACjC,iBACA,SACF;CACA,MAAK;CACL,GAAI;CACJ,GAAI;CACJ,GAAI;WAEJ,oBAAC,MAAD;EAAM,eAAY;EAAO,WAAU;CAAU,CAAA;AACvC,CAAA;AAGV,IAAM,oBAAoB,EACxB,QACA,YACA,OACA,WACA,UACA,GAAG,YAEH,qBAAC,OAAD;CACE,KAAK;CACL,WAAW,GACT,2DACA,aAAa,0BACb,cAAc,YAChB;CACO;WAPT,CASE,oBAAC,eAAD;EAAe,WAAU;EAAkB;EAAY,GAAI;CAAQ,CAAA,GAClE,QACE;;AAGP,IAAM,gBAAgB,EACpB,IACA,UACA,WACA,iBACA,iBACA,gBAQI;CACJ,MAAM,EAAE,YAAY,WAAW,YAAY,WAAW,eAAe,YAAY,EAAE,GAAG,CAAC;CAEvF,OAAO,UAAU;EACf;EACA,QAAQ;EACR,YAAY;EACZ;EACA;EACA;EACA,sBAAsB;EACtB,qBAAqB;EACrB,OA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