@42-central/ui-react 0.17.1 → 0.18.1
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/biome/no-gray-color.grit +18 -0
- package/dist/{chunk-FD6P6PLQ.js → chunk-5JHDSVEZ.js} +3 -3
- package/dist/{chunk-FD6P6PLQ.js.map → chunk-5JHDSVEZ.js.map} +1 -1
- package/dist/{chunk-QMW7D5GU.js → chunk-5OQLFX47.js} +4 -3
- package/dist/chunk-5OQLFX47.js.map +1 -0
- package/dist/{chunk-VZ2TPU4B.js → chunk-6GDMSENK.js} +3 -2
- package/dist/chunk-6GDMSENK.js.map +1 -0
- package/dist/{chunk-TNNH3FVQ.js → chunk-6OLTJYSX.js} +24 -8
- package/dist/chunk-6OLTJYSX.js.map +1 -0
- package/dist/{chunk-POKDSVQT.js → chunk-AE7QTLJ5.js} +5 -4
- package/dist/chunk-AE7QTLJ5.js.map +1 -0
- package/dist/{chunk-44OV3PNH.js → chunk-B2YJKRNQ.js} +3 -3
- package/dist/{chunk-44OV3PNH.js.map → chunk-B2YJKRNQ.js.map} +1 -1
- package/dist/{chunk-YIQI2CF3.js → chunk-CTSO6V72.js} +3 -2
- package/dist/chunk-CTSO6V72.js.map +1 -0
- package/dist/{chunk-EVVMHTCL.js → chunk-EBREIC3L.js} +4 -3
- package/dist/chunk-EBREIC3L.js.map +1 -0
- package/dist/{chunk-UNSAA7YG.js → chunk-FHG54IT5.js} +3 -2
- package/dist/chunk-FHG54IT5.js.map +1 -0
- package/dist/{chunk-3GYOIQW7.js → chunk-FZIHZT5R.js} +5 -5
- package/dist/{chunk-3GYOIQW7.js.map → chunk-FZIHZT5R.js.map} +1 -1
- package/dist/{chunk-2H46IXW4.js → chunk-HAQJQFE6.js} +28 -8
- package/dist/chunk-HAQJQFE6.js.map +1 -0
- package/dist/{chunk-IHYFYMHJ.js → chunk-HT5JAHR3.js} +6 -6
- package/dist/{chunk-IHYFYMHJ.js.map → chunk-HT5JAHR3.js.map} +1 -1
- package/dist/chunk-I4SQQIP5.js +12 -0
- package/dist/chunk-I4SQQIP5.js.map +1 -0
- package/dist/{chunk-J3PELDH3.js → chunk-JITF6I7N.js} +22 -6
- package/dist/chunk-JITF6I7N.js.map +1 -0
- package/dist/{chunk-IFWCCAQV.js → chunk-KHMFNH3X.js} +3 -2
- package/dist/chunk-KHMFNH3X.js.map +1 -0
- package/dist/{chunk-SIG4DMNZ.js → chunk-MI2WZRK3.js} +4 -4
- package/dist/{chunk-SIG4DMNZ.js.map → chunk-MI2WZRK3.js.map} +1 -1
- package/dist/{chunk-YON5Y336.js → chunk-O23Y5ML4.js} +8 -8
- package/dist/{chunk-YON5Y336.js.map → chunk-O23Y5ML4.js.map} +1 -1
- package/dist/{chunk-P7A3BCAC.js → chunk-OWG4BCQR.js} +3 -3
- package/dist/{chunk-P7A3BCAC.js.map → chunk-OWG4BCQR.js.map} +1 -1
- package/dist/{chunk-FUWSTUDM.js → chunk-PH354ECN.js} +4 -4
- package/dist/{chunk-FUWSTUDM.js.map → chunk-PH354ECN.js.map} +1 -1
- package/dist/{chunk-U5GW5EBR.js → chunk-RAUOFTUH.js} +12 -20
- package/dist/chunk-RAUOFTUH.js.map +1 -0
- package/dist/{chunk-6I4R3HR6.js → chunk-RQL7FVCS.js} +3 -3
- package/dist/{chunk-6I4R3HR6.js.map → chunk-RQL7FVCS.js.map} +1 -1
- package/dist/{chunk-2762HZYX.js → chunk-S2HWWR2H.js} +47 -25
- package/dist/chunk-S2HWWR2H.js.map +1 -0
- package/dist/{chunk-VLUKI3HL.js → chunk-S7N4LGLZ.js} +6 -13
- package/dist/chunk-S7N4LGLZ.js.map +1 -0
- package/dist/{chunk-NSOA3GMZ.js → chunk-UHNRAI6V.js} +3 -3
- package/dist/{chunk-NSOA3GMZ.js.map → chunk-UHNRAI6V.js.map} +1 -1
- package/dist/{chunk-JBVFWSRQ.js → chunk-VIYVN4WF.js} +6 -4
- package/dist/chunk-VIYVN4WF.js.map +1 -0
- package/dist/{chunk-3NZXWCGF.js → chunk-WHKKN3ZK.js} +6 -6
- package/dist/{chunk-3NZXWCGF.js.map → chunk-WHKKN3ZK.js.map} +1 -1
- package/dist/{chunk-MOI7B3KH.js → chunk-WQN64ZHG.js} +5 -5
- package/dist/{chunk-MOI7B3KH.js.map → chunk-WQN64ZHG.js.map} +1 -1
- package/dist/chunk-WSIVRDRB.js +34 -0
- package/dist/chunk-WSIVRDRB.js.map +1 -0
- package/dist/{chunk-S53FHWNG.js → chunk-YWRBG23W.js} +3 -3
- package/dist/chunk-YWRBG23W.js.map +1 -0
- package/dist/{chunk-6SWK4XG5.js → chunk-YXE4B6X3.js} +2 -2
- package/dist/chunk-YXE4B6X3.js.map +1 -0
- package/dist/{chunk-NGAQITWP.js → chunk-Z2Z5EXVT.js} +10 -7
- package/dist/chunk-Z2Z5EXVT.js.map +1 -0
- package/dist/{chunk-IXKELBJA.js → chunk-ZDXQ64A7.js} +63 -44
- package/dist/chunk-ZDXQ64A7.js.map +1 -0
- package/dist/colors.css +12 -26
- package/dist/components/accordion/accordion-data.d.ts +3 -2
- package/dist/components/accordion/accordion-data.d.ts.map +1 -1
- package/dist/components/accordion/accordion.d.ts +2 -2
- package/dist/components/accordion/accordion.d.ts.map +1 -1
- package/dist/components/accordion/index.js +20 -8
- package/dist/components/accordion/index.js.map +1 -1
- package/dist/components/action-icon/action-icon.d.ts +3 -4
- package/dist/components/action-icon/action-icon.d.ts.map +1 -1
- package/dist/components/action-icon/index.js +2 -1
- package/dist/components/alert/alert.d.ts +1 -1
- package/dist/components/alert/alert.d.ts.map +1 -1
- package/dist/components/alert/index.js +16 -4
- package/dist/components/alert/index.js.map +1 -1
- package/dist/components/app-shell/app-shell.d.ts +3 -2
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/index.js +4 -2
- package/dist/components/app-shell/index.js.map +1 -1
- package/dist/components/autocomplete/index.js +5 -4
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/avatar/avatar.d.ts +3 -3
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.d.ts +3 -2
- package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
- package/dist/components/breadcrumb/index.js +11 -5
- package/dist/components/breadcrumb/index.js.map +1 -1
- package/dist/components/button/button.d.ts +4 -4
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/index.js +2 -1
- package/dist/components/button-multi-select/index.js +4 -3
- package/dist/components/button-multi-select/index.js.map +1 -1
- package/dist/components/button-select/index.js +4 -3
- package/dist/components/button-select/index.js.map +1 -1
- package/dist/components/calendar/index.js +3 -2
- package/dist/components/chart/chart.d.ts +1 -1
- package/dist/components/chart/index.js +1 -1
- package/dist/components/chart/index.js.map +1 -1
- package/dist/components/checkbox/index.js +2 -2
- package/dist/components/choice-card-group/index.js +1 -1
- package/dist/components/circular-progress/circular-progress.d.ts +3 -2
- package/dist/components/circular-progress/circular-progress.d.ts.map +1 -1
- package/dist/components/circular-progress/index.js +1 -0
- package/dist/components/circular-progress/index.js.map +1 -1
- package/dist/components/clipboard/clipboard.d.ts +1 -1
- package/dist/components/clipboard/clipboard.d.ts.map +1 -1
- package/dist/components/clipboard/index.js +9 -5
- package/dist/components/clipboard/index.js.map +1 -1
- package/dist/components/code/index.js +1 -1
- package/dist/components/code-block/chrome.d.ts +4 -1
- package/dist/components/code-block/chrome.d.ts.map +1 -1
- package/dist/components/code-block/chrome.js +5 -4
- package/dist/components/code-block/code-block.d.ts +7 -1
- package/dist/components/code-block/code-block.d.ts.map +1 -1
- package/dist/components/code-block/index.d.ts +1 -1
- package/dist/components/code-block/index.js +12 -10
- package/dist/components/code-block/index.js.map +1 -1
- package/dist/components/code-block/notation.d.ts +5 -2
- package/dist/components/code-block/notation.d.ts.map +1 -1
- package/dist/components/code-block/static.d.ts +4 -1
- package/dist/components/code-block/static.d.ts.map +1 -1
- package/dist/components/code-block/static.js +5 -4
- package/dist/components/code-block/static.js.map +1 -1
- package/dist/components/collapse/collapse.d.ts +7 -3
- package/dist/components/collapse/collapse.d.ts.map +1 -1
- package/dist/components/collapse/index.js +2 -1
- package/dist/components/combobox/combobox.d.ts +11 -10
- package/dist/components/combobox/combobox.d.ts.map +1 -1
- package/dist/components/combobox/index.js +5 -4
- package/dist/components/combobox-list/index.js +6 -5
- package/dist/components/data-table/index.js +21 -20
- package/dist/components/data-table/index.js.map +1 -1
- package/dist/components/date-picker/index.js +12 -11
- package/dist/components/date-picker/index.js.map +1 -1
- package/dist/components/divider/divider.d.ts +3 -2
- package/dist/components/divider/divider.d.ts.map +1 -1
- package/dist/components/divider/index.js +1 -1
- package/dist/components/drawer/drawer.d.ts +6 -5
- package/dist/components/drawer/drawer.d.ts.map +1 -1
- package/dist/components/drawer/index.js +3 -2
- package/dist/components/field/field.d.ts +7 -4
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/index.js +1 -1
- package/dist/components/file-upload/index.js +3 -2
- package/dist/components/file-upload/index.js.map +1 -1
- package/dist/components/hover-card/index.js +1 -1
- package/dist/components/input/index.js +2 -2
- package/dist/components/input/input.d.ts +3 -2
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/mark/index.js +1 -1
- package/dist/components/mark/mark.d.ts +2 -2
- package/dist/components/menu/index.js +3 -2
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/menu/menu-data.d.ts +6 -1
- package/dist/components/menu/menu-data.d.ts.map +1 -1
- package/dist/components/menu/menu.d.ts +5 -5
- package/dist/components/menu/menu.d.ts.map +1 -1
- package/dist/components/modal/index.js +3 -2
- package/dist/components/modal/modal.d.ts +4 -3
- package/dist/components/modal/modal.d.ts.map +1 -1
- package/dist/components/multi-combobox-list/index.js +6 -5
- package/dist/components/multi-select/index.js +7 -6
- package/dist/components/multi-select/index.js.map +1 -1
- package/dist/components/nav-link/index.js +3 -2
- package/dist/components/nav-link/tanstack.js +3 -2
- package/dist/components/nav-link/tanstack.js.map +1 -1
- package/dist/components/notification/index.js +4 -3
- package/dist/components/notification/index.js.map +1 -1
- package/dist/components/notification/notification.d.ts +3 -2
- package/dist/components/notification/notification.d.ts.map +1 -1
- package/dist/components/number-input/index.js +4 -4
- package/dist/components/overlays/index.js +5 -4
- package/dist/components/overlays/index.js.map +1 -1
- package/dist/components/password-input/index.js +2 -2
- package/dist/components/pill/index.js +2 -1
- package/dist/components/pill/pill.d.ts +4 -2
- package/dist/components/pill/pill.d.ts.map +1 -1
- package/dist/components/pills-input/index.js +5 -4
- package/dist/components/pills-input/pills-input.d.ts +3 -2
- package/dist/components/pills-input/pills-input.d.ts.map +1 -1
- package/dist/components/pin-input/index.js +2 -2
- package/dist/components/popover/index.js +1 -1
- package/dist/components/popover/popover.d.ts +3 -2
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/progress/index.js +1 -0
- package/dist/components/progress/index.js.map +1 -1
- package/dist/components/progress/progress.d.ts +3 -2
- package/dist/components/progress/progress.d.ts.map +1 -1
- package/dist/components/radio-group/index.js +1 -1
- package/dist/components/rating/index.js +2 -1
- package/dist/components/rating/index.js.map +1 -1
- package/dist/components/rating/rating.d.ts +3 -2
- package/dist/components/rating/rating.d.ts.map +1 -1
- package/dist/components/schedule/index.d.ts +2 -2
- package/dist/components/schedule/index.js +50 -23
- package/dist/components/schedule/index.js.map +1 -1
- package/dist/components/schedule/schedule-agenda-list.d.ts +6 -7
- package/dist/components/schedule/schedule-agenda-list.d.ts.map +1 -1
- package/dist/components/schedule/schedule-agenda-view.d.ts +19 -16
- package/dist/components/schedule/schedule-agenda-view.d.ts.map +1 -1
- package/dist/components/schedule/schedule-dates.d.ts.map +1 -1
- package/dist/components/schedule/schedule-days-view.d.ts +3 -2
- package/dist/components/schedule/schedule-days-view.d.ts.map +1 -1
- package/dist/components/schedule/schedule-month-view.d.ts +3 -2
- package/dist/components/schedule/schedule-month-view.d.ts.map +1 -1
- package/dist/components/schedule/schedule-next-up.d.ts +4 -3
- package/dist/components/schedule/schedule-next-up.d.ts.map +1 -1
- package/dist/components/schedule/schedule-toolbar.d.ts +1 -1
- package/dist/components/schedule/schedule-toolbar.d.ts.map +1 -1
- package/dist/components/schedule/schedule-types.d.ts +6 -4
- package/dist/components/schedule/schedule-types.d.ts.map +1 -1
- package/dist/components/schedule/schedule-views.d.ts +2 -2
- package/dist/components/schedule/schedule-views.d.ts.map +1 -1
- package/dist/components/schedule/schedule-year-view.d.ts +3 -2
- package/dist/components/schedule/schedule-year-view.d.ts.map +1 -1
- package/dist/components/schedule/schedule.d.ts +9 -6
- package/dist/components/schedule/schedule.d.ts.map +1 -1
- package/dist/components/segment-group/index.js +2 -2
- package/dist/components/select/index.js +4 -4
- package/dist/components/slider/index.js +2 -1
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/slider/slider.d.ts +3 -2
- package/dist/components/slider/slider.d.ts.map +1 -1
- package/dist/components/switch/index.js +1 -1
- package/dist/components/tabs/index.js +1 -1
- package/dist/components/tabs/tabs-data.d.ts +3 -2
- package/dist/components/tabs/tabs-data.d.ts.map +1 -1
- package/dist/components/tags-input/index.js +6 -5
- package/dist/components/tags-input/index.js.map +1 -1
- package/dist/components/text-input/index.js +2 -2
- package/dist/components/textarea/index.js +2 -2
- package/dist/components/theme-icon/index.js +1 -1
- package/dist/components/time-input/index.js +6 -6
- package/dist/components/timeline/index.js +8 -5
- package/dist/components/timeline/index.js.map +1 -1
- package/dist/components/timeline/timeline.d.ts +1 -1
- package/dist/components/timeline/timeline.d.ts.map +1 -1
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/tooltip/tooltip.d.ts +2 -1
- package/dist/components/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/tree-multi-select/index.js +6 -5
- package/dist/components/tree-multi-select/index.js.map +1 -1
- package/dist/components/tree-select/index.js +3 -3
- package/dist/index.js +1 -1
- package/dist/lib/as-child.d.ts +104 -0
- package/dist/lib/as-child.d.ts.map +1 -0
- package/dist/lib/colors.d.ts +1 -1
- package/dist/lib/colors.d.ts.map +1 -1
- package/dist/theme.css +0 -33
- package/package.json +2 -1
- package/src/as-child.contract.test.tsx +809 -0
- package/src/biome-plugins.test.ts +61 -0
- package/src/colors.css +12 -26
- package/src/components/accordion/accordion-data.tsx +8 -5
- package/src/components/accordion/accordion.test.tsx +40 -0
- package/src/components/accordion/accordion.tsx +23 -6
- package/src/components/action-icon/action-icon.tsx +9 -24
- package/src/components/alert/alert.test.tsx +17 -0
- package/src/components/alert/alert.tsx +21 -2
- package/src/components/app-shell/app-shell.tsx +3 -1
- package/src/components/avatar/avatar.tsx +3 -3
- package/src/components/breadcrumb/breadcrumb.test.tsx +30 -0
- package/src/components/breadcrumb/breadcrumb.tsx +21 -12
- package/src/components/button/button.tsx +21 -50
- package/src/components/chart/chart.test.tsx +1 -2
- package/src/components/chart/chart.tsx +1 -1
- package/src/components/circular-progress/circular-progress.tsx +4 -1
- package/src/components/clipboard/clipboard.test.tsx +18 -0
- package/src/components/clipboard/clipboard.tsx +8 -2
- package/src/components/code-block/chrome.tsx +60 -36
- package/src/components/code-block/code-block.test.tsx +27 -0
- package/src/components/code-block/code-block.tsx +13 -3
- package/src/components/code-block/gutters.test.ts +2 -2
- package/src/components/code-block/notation.test.ts +8 -0
- package/src/components/code-block/notation.ts +6 -3
- package/src/components/code-block/static.tsx +8 -2
- package/src/components/collapse/collapse.tsx +33 -15
- package/src/components/combobox/combobox.test.tsx +38 -0
- package/src/components/combobox/combobox.tsx +24 -10
- package/src/components/divider/divider.tsx +3 -1
- package/src/components/drawer/drawer.tsx +37 -16
- package/src/components/field/field.tsx +7 -3
- package/src/components/input/input.tsx +3 -1
- package/src/components/mark/mark.test.tsx +4 -4
- package/src/components/mark/mark.tsx +3 -3
- package/src/components/menu/menu-data.tsx +8 -1
- package/src/components/menu/menu.test.tsx +52 -0
- package/src/components/menu/menu.tsx +83 -35
- package/src/components/modal/close-trigger.test.tsx +38 -0
- package/src/components/modal/modal.tsx +29 -13
- package/src/components/notification/notification.tsx +4 -1
- package/src/components/pill/pill.tsx +29 -20
- package/src/components/pills-input/pills-input.tsx +3 -1
- package/src/components/popover/popover.tsx +3 -1
- package/src/components/progress/progress.tsx +4 -1
- package/src/components/rating/rating.tsx +27 -23
- package/src/components/schedule/index.ts +1 -1
- package/src/components/schedule/schedule-agenda-list.tsx +6 -7
- package/src/components/schedule/schedule-agenda-view.test.tsx +105 -28
- package/src/components/schedule/schedule-agenda-view.tsx +41 -28
- package/src/components/schedule/schedule-dates.test.ts +37 -52
- package/src/components/schedule/schedule-dates.ts +22 -25
- package/src/components/schedule/schedule-days-view.tsx +3 -1
- package/src/components/schedule/schedule-month-view.tsx +3 -1
- package/src/components/schedule/schedule-next-up.tsx +6 -2
- package/src/components/schedule/schedule-toolbar.test.tsx +26 -0
- package/src/components/schedule/schedule-toolbar.tsx +13 -1
- package/src/components/schedule/schedule-types.ts +6 -4
- package/src/components/schedule/schedule-views.ts +4 -5
- package/src/components/schedule/schedule-year-view.tsx +3 -1
- package/src/components/schedule/schedule.test.tsx +66 -22
- package/src/components/schedule/schedule.tsx +22 -13
- package/src/components/slider/slider.tsx +4 -0
- package/src/components/tabs/tabs-data.tsx +17 -14
- package/src/components/theme-icon/theme-icon.tsx +1 -1
- package/src/components/timeline/timeline.tsx +102 -95
- package/src/components/tooltip/tooltip.tsx +2 -1
- package/src/lib/as-child.test.tsx +70 -0
- package/src/lib/as-child.ts +119 -0
- package/src/lib/colors.ts +4 -2
- package/src/theme.css +0 -33
- package/dist/chunk-2762HZYX.js.map +0 -1
- package/dist/chunk-2H46IXW4.js.map +0 -1
- package/dist/chunk-6SWK4XG5.js.map +0 -1
- package/dist/chunk-EVVMHTCL.js.map +0 -1
- package/dist/chunk-HWNPXAEN.js +0 -31
- package/dist/chunk-HWNPXAEN.js.map +0 -1
- package/dist/chunk-IFWCCAQV.js.map +0 -1
- package/dist/chunk-IXKELBJA.js.map +0 -1
- package/dist/chunk-J3PELDH3.js.map +0 -1
- package/dist/chunk-JBVFWSRQ.js.map +0 -1
- package/dist/chunk-NGAQITWP.js.map +0 -1
- package/dist/chunk-POKDSVQT.js.map +0 -1
- package/dist/chunk-QMW7D5GU.js.map +0 -1
- package/dist/chunk-S53FHWNG.js.map +0 -1
- package/dist/chunk-TNNH3FVQ.js.map +0 -1
- package/dist/chunk-U5GW5EBR.js.map +0 -1
- package/dist/chunk-UNSAA7YG.js.map +0 -1
- package/dist/chunk-VLUKI3HL.js.map +0 -1
- package/dist/chunk-VZ2TPU4B.js.map +0 -1
- package/dist/chunk-YIQI2CF3.js.map +0 -1
|
@@ -5,6 +5,7 @@ import { Portal } from "@ark-ui/react/portal"
|
|
|
5
5
|
import { cva } from "class-variance-authority"
|
|
6
6
|
import { X } from "lucide-react"
|
|
7
7
|
import { type ComponentPropsWithoutRef, type ReactNode, useRef } from "react"
|
|
8
|
+
import type { NoAsChild } from "../../lib/as-child"
|
|
8
9
|
import { cn } from "../../lib/cn"
|
|
9
10
|
import { OverlayContainerProvider } from "../../lib/overlay-container"
|
|
10
11
|
import { OverlayLayerProvider, useLayerGuard } from "../../lib/overlay-layer"
|
|
@@ -83,12 +84,12 @@ const drawerPositioner = cva(
|
|
|
83
84
|
},
|
|
84
85
|
)
|
|
85
86
|
|
|
86
|
-
export type DrawerPositionerProps = ComponentPropsWithoutRef<typeof Ark.Positioner
|
|
87
|
+
export type DrawerPositionerProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.Positioner>>
|
|
87
88
|
|
|
88
89
|
/** Publishes itself as the portal target for any overlay opened inside the
|
|
89
90
|
* drawer, so a Menu/Select/DatePicker in a drawer body stays above the panel
|
|
90
91
|
* instead of behind it. See `lib/overlay-container.tsx`. */
|
|
91
|
-
const DrawerPositioner = ({ children, ...rest }: DrawerPositionerProps) => {
|
|
92
|
+
const DrawerPositioner = ({ children, asChild: _asChild, ...rest }: DrawerPositionerProps) => {
|
|
92
93
|
const positioner = useRef<HTMLDivElement>(null)
|
|
93
94
|
return (
|
|
94
95
|
<Ark.Positioner ref={positioner} {...rest}>
|
|
@@ -167,27 +168,47 @@ export type DrawerCloseTriggerProps = ComponentPropsWithoutRef<typeof Ark.CloseT
|
|
|
167
168
|
export const DrawerCloseTrigger = ({
|
|
168
169
|
children,
|
|
169
170
|
className,
|
|
170
|
-
"aria-label": ariaLabel
|
|
171
|
+
"aria-label": ariaLabel,
|
|
171
172
|
testId,
|
|
173
|
+
asChild,
|
|
172
174
|
...rest
|
|
173
|
-
}: DrawerCloseTriggerProps) =>
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
}: DrawerCloseTriggerProps) =>
|
|
176
|
+
asChild ? (
|
|
177
|
+
// The consumer's element (a "Cancel" button, say) replaces the kit's icon
|
|
178
|
+
// button outright, rather than nesting inside it.
|
|
179
|
+
<Ark.CloseTrigger
|
|
180
|
+
asChild
|
|
179
181
|
aria-label={ariaLabel}
|
|
180
182
|
className={className}
|
|
181
|
-
|
|
183
|
+
{...props({ "data-testid": testId })}
|
|
184
|
+
{...rest}
|
|
182
185
|
>
|
|
183
|
-
{children
|
|
184
|
-
</
|
|
185
|
-
|
|
186
|
-
|
|
186
|
+
{children}
|
|
187
|
+
</Ark.CloseTrigger>
|
|
188
|
+
) : (
|
|
189
|
+
<Ark.CloseTrigger asChild {...rest}>
|
|
190
|
+
<ActionIcon
|
|
191
|
+
variant="subtle"
|
|
192
|
+
color="neutral"
|
|
193
|
+
size="sm"
|
|
194
|
+
aria-label={ariaLabel ?? "Close"}
|
|
195
|
+
className={className}
|
|
196
|
+
testId={testId}
|
|
197
|
+
>
|
|
198
|
+
{children ?? <X />}
|
|
199
|
+
</ActionIcon>
|
|
200
|
+
</Ark.CloseTrigger>
|
|
201
|
+
)
|
|
187
202
|
|
|
188
|
-
export type DrawerGrabberProps = ComponentPropsWithoutRef<typeof Ark.Grabber
|
|
203
|
+
export type DrawerGrabberProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.Grabber>> &
|
|
204
|
+
WithTestId
|
|
189
205
|
|
|
190
|
-
export const DrawerGrabber = ({
|
|
206
|
+
export const DrawerGrabber = ({
|
|
207
|
+
className,
|
|
208
|
+
testId,
|
|
209
|
+
asChild: _asChild,
|
|
210
|
+
...rest
|
|
211
|
+
}: DrawerGrabberProps) => (
|
|
191
212
|
<Ark.Grabber
|
|
192
213
|
className={cn(
|
|
193
214
|
"flex shrink-0 cursor-grab touch-none items-center justify-center py-2",
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Field as Ark, type UseFieldContext } from "@ark-ui/react/field"
|
|
4
4
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
5
|
import type { ComponentPropsWithoutRef, ReactNode } from "react"
|
|
6
|
+
import type { NoAsChild } from "../../lib/as-child"
|
|
6
7
|
import { cn } from "../../lib/cn"
|
|
7
8
|
import { props } from "../../lib/props"
|
|
8
9
|
import type { WithTestId } from "../../lib/test-id"
|
|
@@ -24,8 +25,10 @@ import type { WithTestId } from "../../lib/test-id"
|
|
|
24
25
|
* - `size` scales only the field's own typography; set the control's `size`
|
|
25
26
|
* separately (the family components forward both).
|
|
26
27
|
*
|
|
27
|
-
* Every other prop (incl. `disabled`, `readOnly`, `id
|
|
28
|
-
*
|
|
28
|
+
* Every other prop (incl. `disabled`, `readOnly`, `id`) forwards to Ark's
|
|
29
|
+
* `Field.Root`. `asChild` is a compile error: the field renders its label,
|
|
30
|
+
* helper and error rows around the control, which can't live inside one
|
|
31
|
+
* element.
|
|
29
32
|
*/
|
|
30
33
|
|
|
31
34
|
// `relative` contains a `sr-only` label (and any hidden input rendered inside
|
|
@@ -112,7 +115,7 @@ type FieldClassNames = {
|
|
|
112
115
|
requiredIndicator?: string
|
|
113
116
|
}
|
|
114
117
|
|
|
115
|
-
export type FieldProps = Omit<ComponentPropsWithoutRef<typeof Ark.Root>, "className"
|
|
118
|
+
export type FieldProps = NoAsChild<Omit<ComponentPropsWithoutRef<typeof Ark.Root>, "className">> &
|
|
116
119
|
VariantProps<typeof fieldRoot> &
|
|
117
120
|
WithTestId & {
|
|
118
121
|
/** Accessible name, rendered as a `<label>` bound to the control. */
|
|
@@ -186,6 +189,7 @@ export const Field = ({
|
|
|
186
189
|
className,
|
|
187
190
|
classNames,
|
|
188
191
|
testId,
|
|
192
|
+
asChild: _asChild,
|
|
189
193
|
...rest
|
|
190
194
|
}: FieldProps) => {
|
|
191
195
|
const isInvalid = invalid ?? error != null
|
|
@@ -4,6 +4,7 @@ import { ark, type HTMLArkProps } from "@ark-ui/react"
|
|
|
4
4
|
import { useFieldContext } from "@ark-ui/react/field"
|
|
5
5
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
6
6
|
import type { ReactNode, Ref } from "react"
|
|
7
|
+
import type { NoAsChild } from "../../lib/as-child"
|
|
7
8
|
import { cn } from "../../lib/cn"
|
|
8
9
|
import { props } from "../../lib/props"
|
|
9
10
|
import type { WithTestId } from "../../lib/test-id"
|
|
@@ -196,7 +197,7 @@ type ShellOwnProps = VariantProps<typeof inputShell> & {
|
|
|
196
197
|
endSlot?: ReactNode
|
|
197
198
|
}
|
|
198
199
|
|
|
199
|
-
export type InputBaseProps = Omit<HTMLArkProps<"div">, "color"
|
|
200
|
+
export type InputBaseProps = NoAsChild<Omit<HTMLArkProps<"div">, "color">> &
|
|
200
201
|
ShellOwnProps &
|
|
201
202
|
WithTestId & {
|
|
202
203
|
classNames?: ShellClassNames
|
|
@@ -215,6 +216,7 @@ export const InputBase = ({
|
|
|
215
216
|
className,
|
|
216
217
|
classNames,
|
|
217
218
|
testId,
|
|
219
|
+
asChild: _asChild,
|
|
218
220
|
...rest
|
|
219
221
|
}: InputBaseProps) => (
|
|
220
222
|
<ark.div
|
|
@@ -17,12 +17,12 @@ describe("Mark", () => {
|
|
|
17
17
|
expect(screen.getByTestId("note")).toBeTruthy()
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
-
it("defaults background to yellow and text to neutral
|
|
20
|
+
it("defaults background to yellow and text to neutral when neither is set", () => {
|
|
21
21
|
const { container } = render(<Mark>hi</Mark>)
|
|
22
22
|
const root = container.firstElementChild as HTMLElement
|
|
23
23
|
const inner = root.firstElementChild as HTMLElement
|
|
24
24
|
expect(root.getAttribute("data-color")).toBe("yellow")
|
|
25
|
-
expect(inner.getAttribute("data-color")).toBe("
|
|
25
|
+
expect(inner.getAttribute("data-color")).toBe("neutral")
|
|
26
26
|
})
|
|
27
27
|
|
|
28
28
|
it("the inner span always contains text-(--c-text), unconditionally", () => {
|
|
@@ -68,12 +68,12 @@ describe("Mark", () => {
|
|
|
68
68
|
expect(root.className).toContain("bg-transparent")
|
|
69
69
|
})
|
|
70
70
|
|
|
71
|
-
it("background alone tints only the highlight — text stays neutral
|
|
71
|
+
it("background alone tints only the highlight — text stays neutral, not matching background", () => {
|
|
72
72
|
const { container } = render(<Mark background="red">hi</Mark>)
|
|
73
73
|
const root = container.firstElementChild as HTMLElement
|
|
74
74
|
const inner = root.firstElementChild as HTMLElement
|
|
75
75
|
expect(root.getAttribute("data-color")).toBe("red")
|
|
76
|
-
expect(inner.getAttribute("data-color")).toBe("
|
|
76
|
+
expect(inner.getAttribute("data-color")).toBe("neutral")
|
|
77
77
|
})
|
|
78
78
|
|
|
79
79
|
it("root className carries the translucent soft background, never a text color", () => {
|
|
@@ -10,7 +10,7 @@ import type { WithTestId } from "../../lib/test-id"
|
|
|
10
10
|
* `background` and `color` are fully independent — `background` only ever
|
|
11
11
|
* changes the highlight, `color` only ever changes the text, neither leaks
|
|
12
12
|
* into the other: `background` alone (no `color`) tints the highlight with
|
|
13
|
-
* *neutral*
|
|
13
|
+
* *neutral* text, not text matching the highlight; `color` alone (no
|
|
14
14
|
* `background`) renders as tinted text with no highlight at all —
|
|
15
15
|
* `background` only defaults to `"yellow"` when it's unset, regardless of
|
|
16
16
|
* `color`. This needs two DOM nodes rather than one: `--c-soft`/`--c-text`
|
|
@@ -41,7 +41,7 @@ export type MarkProps = ComponentPropsWithoutRef<"mark"> &
|
|
|
41
41
|
WithTestId & {
|
|
42
42
|
/**
|
|
43
43
|
* Text color. Independent of `background` — never falls back to it.
|
|
44
|
-
* @default "
|
|
44
|
+
* @default "neutral"
|
|
45
45
|
*/
|
|
46
46
|
color?: Color
|
|
47
47
|
/**
|
|
@@ -71,7 +71,7 @@ export const Mark = ({ className, color, background, children, testId, ...rest }
|
|
|
71
71
|
className,
|
|
72
72
|
)}
|
|
73
73
|
>
|
|
74
|
-
<span data-color={color ?? "
|
|
74
|
+
<span data-color={color ?? "neutral"} className="text-(--c-text)">
|
|
75
75
|
{children}
|
|
76
76
|
</span>
|
|
77
77
|
</mark>
|
|
@@ -98,8 +98,15 @@ export type MenuItemsData = ReadonlyArray<MenuEntry>
|
|
|
98
98
|
* dividers and value-less actions contribute `never`. Checked structurally by
|
|
99
99
|
* key (submenu / group carry `items`, so they must be matched before the action
|
|
100
100
|
* branch, which any labelled object would otherwise satisfy).
|
|
101
|
+
*
|
|
102
|
+
* The un-narrowed `MenuItemsData` itself resolves to `string` up front:
|
|
103
|
+
* `MenuSubItem.items` is `MenuItemsData` again, so recursing into the wide
|
|
104
|
+
* type never bottoms out. tsc gave up and typed the value `any`, and any
|
|
105
|
+
* type-level probe of `MenuProps` hit "excessively deep".
|
|
101
106
|
*/
|
|
102
|
-
export type MenuValue<Data extends MenuItemsData> =
|
|
107
|
+
export type MenuValue<Data extends MenuItemsData> = MenuItemsData extends Data
|
|
108
|
+
? string
|
|
109
|
+
: ExtractValue<Data[number]>
|
|
103
110
|
|
|
104
111
|
type ExtractValue<E> = E extends string
|
|
105
112
|
? E
|
|
@@ -346,6 +346,58 @@ describe("Menu (interaction)", () => {
|
|
|
346
346
|
})
|
|
347
347
|
})
|
|
348
348
|
|
|
349
|
+
/**
|
|
350
|
+
* #281 — an item that navigates renders as the consumer's own link (a plain
|
|
351
|
+
* `<a>` or a router `Link`) through `asChild`, so middle-click, "open in new
|
|
352
|
+
* tab" and the link role all work. The row's sections fold into the link.
|
|
353
|
+
*/
|
|
354
|
+
describe("Menu (link items)", () => {
|
|
355
|
+
it("renders the asChild link as the menuitem, sections and row styling included", () => {
|
|
356
|
+
render(
|
|
357
|
+
<Menu.Root defaultOpen withinPortal={false}>
|
|
358
|
+
<Menu.Trigger>Open</Menu.Trigger>
|
|
359
|
+
<Menu.Content>
|
|
360
|
+
<Menu.Item
|
|
361
|
+
asChild
|
|
362
|
+
color="red"
|
|
363
|
+
startSection={<svg data-testid="start" aria-hidden="true" />}
|
|
364
|
+
endSection={<kbd>⌘O</kbd>}
|
|
365
|
+
>
|
|
366
|
+
<a href="/entities/libft">Open the entity page</a>
|
|
367
|
+
</Menu.Item>
|
|
368
|
+
</Menu.Content>
|
|
369
|
+
</Menu.Root>,
|
|
370
|
+
)
|
|
371
|
+
const link = screen.getByRole("menuitem", { name: /Open the entity page/ })
|
|
372
|
+
expect(link.tagName).toBe("A")
|
|
373
|
+
expect(link.getAttribute("href")).toBe("/entities/libft")
|
|
374
|
+
expect(link.getAttribute("data-color")).toBe("red")
|
|
375
|
+
expect(link.className).toContain("rounded-xs")
|
|
376
|
+
expect(link.contains(screen.getByTestId("start"))).toBe(true)
|
|
377
|
+
expect(link.textContent).toContain("⌘O")
|
|
378
|
+
})
|
|
379
|
+
|
|
380
|
+
// zag's own keyboard "click" doesn't bubble, so a React onClick (where a
|
|
381
|
+
// router Link does its client-side navigation) never ran.
|
|
382
|
+
it("reaches the link's React onClick when selected from the keyboard", async () => {
|
|
383
|
+
const onLinkClick = vi.fn((event: { preventDefault: () => void }) => event.preventDefault())
|
|
384
|
+
render(
|
|
385
|
+
<Menu.Root defaultOpen defaultHighlightedValue="open" withinPortal={false}>
|
|
386
|
+
<Menu.Trigger>Open</Menu.Trigger>
|
|
387
|
+
<Menu.Content>
|
|
388
|
+
<Menu.Item asChild value="open">
|
|
389
|
+
<a href="/entities/libft" onClick={onLinkClick}>
|
|
390
|
+
Open the entity page
|
|
391
|
+
</a>
|
|
392
|
+
</Menu.Item>
|
|
393
|
+
</Menu.Content>
|
|
394
|
+
</Menu.Root>,
|
|
395
|
+
)
|
|
396
|
+
fireEvent.keyDown(screen.getByRole("menu"), { key: "Enter" })
|
|
397
|
+
await waitFor(() => expect(onLinkClick).toHaveBeenCalledTimes(1))
|
|
398
|
+
})
|
|
399
|
+
})
|
|
400
|
+
|
|
349
401
|
/**
|
|
350
402
|
* #227 — Zag's trigger cancels `pointerdown`, which stops the browser from
|
|
351
403
|
* focusing the button on a mouse press. Chromium then treats Zag's later
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
useContext,
|
|
17
17
|
useId,
|
|
18
18
|
} from "react"
|
|
19
|
+
import { composeChildren } from "../../lib/as-child"
|
|
19
20
|
import { cn } from "../../lib/cn"
|
|
20
21
|
import type { Color } from "../../lib/colors"
|
|
21
22
|
import { useOverlayContainer } from "../../lib/overlay-container"
|
|
@@ -131,6 +132,19 @@ export type MenuRootProps = Omit<ArkMenu.RootProps, "positioning" | "onOpenChang
|
|
|
131
132
|
onClose?: () => void
|
|
132
133
|
}
|
|
133
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Selects a link item (`<Menu.Item asChild><Link/></Menu.Item>`) from the
|
|
137
|
+
* keyboard. zag's default `navigate` dispatches `new MouseEvent("click")`,
|
|
138
|
+
* which doesn't bubble, so React's delegated `onClick` never sees it and a
|
|
139
|
+
* router `Link` falls back to a full page load. `node.click()` dispatches a
|
|
140
|
+
* bubbling click instead, which reaches the router. Deferred like zag's own,
|
|
141
|
+
* so the menu settles before the navigation starts. A `navigate` prop still
|
|
142
|
+
* overrides it.
|
|
143
|
+
*/
|
|
144
|
+
const clickLink: NonNullable<ArkMenu.RootProps["navigate"]> = ({ node }) => {
|
|
145
|
+
queueMicrotask(() => node.click())
|
|
146
|
+
}
|
|
147
|
+
|
|
134
148
|
const Root = ({
|
|
135
149
|
position = "bottom",
|
|
136
150
|
offset,
|
|
@@ -146,6 +160,7 @@ const Root = ({
|
|
|
146
160
|
<MenuContext.Provider value={{ withinPortal, container }}>
|
|
147
161
|
<ArkMenu.Root
|
|
148
162
|
positioning={{ placement: resolveLogicalPlacement(position, dir), gutter: offset }}
|
|
163
|
+
navigate={clickLink}
|
|
149
164
|
onOpenChange={({ open }) => {
|
|
150
165
|
onOpenChange?.(open)
|
|
151
166
|
if (!open) onClose?.()
|
|
@@ -225,11 +240,13 @@ const Item = ({
|
|
|
225
240
|
className,
|
|
226
241
|
children,
|
|
227
242
|
testId,
|
|
243
|
+
asChild,
|
|
228
244
|
...rest
|
|
229
245
|
}: MenuItemProps) => {
|
|
230
246
|
const autoId = useId()
|
|
231
247
|
return (
|
|
232
248
|
<ArkMenu.Item
|
|
249
|
+
asChild={asChild}
|
|
233
250
|
value={value ?? autoId}
|
|
234
251
|
onSelect={onClick}
|
|
235
252
|
data-color={color}
|
|
@@ -237,9 +254,13 @@ const Item = ({
|
|
|
237
254
|
{...props({ "data-testid": testId })}
|
|
238
255
|
{...rest}
|
|
239
256
|
>
|
|
240
|
-
{
|
|
241
|
-
|
|
242
|
-
|
|
257
|
+
{composeChildren(asChild, children, (own) => (
|
|
258
|
+
<>
|
|
259
|
+
{startSection != null && <StartSection>{startSection}</StartSection>}
|
|
260
|
+
{own}
|
|
261
|
+
{endSection != null && <EndSection>{endSection}</EndSection>}
|
|
262
|
+
</>
|
|
263
|
+
))}
|
|
243
264
|
</ArkMenu.Item>
|
|
244
265
|
)
|
|
245
266
|
}
|
|
@@ -282,15 +303,21 @@ const ItemGroupLabel = ({
|
|
|
282
303
|
prefix,
|
|
283
304
|
children,
|
|
284
305
|
testId,
|
|
306
|
+
asChild,
|
|
285
307
|
...rest
|
|
286
308
|
}: MenuItemGroupLabelProps) => (
|
|
287
309
|
<ArkMenu.ItemGroupLabel
|
|
310
|
+
asChild={asChild}
|
|
288
311
|
className={cn(popoverGroupLabel, className)}
|
|
289
312
|
{...props({ "data-testid": testId })}
|
|
290
313
|
{...rest}
|
|
291
314
|
>
|
|
292
|
-
|
|
293
|
-
|
|
315
|
+
{composeChildren(asChild, children, (own) => (
|
|
316
|
+
<>
|
|
317
|
+
<HeadingPrefix prefix={prefix} />
|
|
318
|
+
{own}
|
|
319
|
+
</>
|
|
320
|
+
))}
|
|
294
321
|
</ArkMenu.ItemGroupLabel>
|
|
295
322
|
)
|
|
296
323
|
|
|
@@ -314,19 +341,25 @@ const CheckboxItem = ({
|
|
|
314
341
|
className,
|
|
315
342
|
children,
|
|
316
343
|
testId,
|
|
344
|
+
asChild,
|
|
317
345
|
...rest
|
|
318
346
|
}: MenuCheckboxItemProps) => (
|
|
319
347
|
<ArkMenu.CheckboxItem
|
|
348
|
+
asChild={asChild}
|
|
320
349
|
data-color={color}
|
|
321
350
|
className={cn(menuItem({ colored: color != null }), className)}
|
|
322
351
|
{...props({ "data-testid": testId })}
|
|
323
352
|
{...rest}
|
|
324
353
|
>
|
|
325
|
-
{
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
354
|
+
{composeChildren(asChild, children, (own) => (
|
|
355
|
+
<>
|
|
356
|
+
{startSection != null && <StartSection>{startSection}</StartSection>}
|
|
357
|
+
{own}
|
|
358
|
+
<ArkMenu.ItemIndicator className={popoverIndicator}>
|
|
359
|
+
<CheckIcon />
|
|
360
|
+
</ArkMenu.ItemIndicator>
|
|
361
|
+
</>
|
|
362
|
+
))}
|
|
330
363
|
</ArkMenu.CheckboxItem>
|
|
331
364
|
)
|
|
332
365
|
|
|
@@ -357,34 +390,40 @@ const RadioItem = ({
|
|
|
357
390
|
className,
|
|
358
391
|
children,
|
|
359
392
|
testId,
|
|
393
|
+
asChild,
|
|
360
394
|
...rest
|
|
361
395
|
}: MenuRadioItemProps) => (
|
|
362
396
|
<ArkMenu.RadioItem
|
|
397
|
+
asChild={asChild}
|
|
363
398
|
data-color={color}
|
|
364
399
|
className={cn(menuItem({ colored: color != null }), className)}
|
|
365
400
|
{...props({ "data-testid": testId })}
|
|
366
401
|
{...rest}
|
|
367
402
|
>
|
|
368
|
-
{
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
403
|
+
{composeChildren(asChild, children, (own) => (
|
|
404
|
+
<>
|
|
405
|
+
{startSection != null && <StartSection>{startSection}</StartSection>}
|
|
406
|
+
{own}
|
|
407
|
+
<ArkMenu.ItemIndicator className={popoverIndicator}>
|
|
408
|
+
<svg
|
|
409
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
410
|
+
width="24"
|
|
411
|
+
height="24"
|
|
412
|
+
viewBox="0 0 24 24"
|
|
413
|
+
fill="currentColor"
|
|
414
|
+
stroke="currentColor"
|
|
415
|
+
strokeWidth="2"
|
|
416
|
+
strokeLinecap="round"
|
|
417
|
+
strokeLinejoin="round"
|
|
418
|
+
className="lucide lucide-dot-big"
|
|
419
|
+
aria-hidden="true"
|
|
420
|
+
>
|
|
421
|
+
<title>Dot big</title>
|
|
422
|
+
<circle cx="12.1" cy="12.1" r="4"></circle>
|
|
423
|
+
</svg>
|
|
424
|
+
</ArkMenu.ItemIndicator>
|
|
425
|
+
</>
|
|
426
|
+
))}
|
|
388
427
|
</ArkMenu.RadioItem>
|
|
389
428
|
)
|
|
390
429
|
|
|
@@ -414,6 +453,7 @@ const SUBMENU_ALIGN_OFFSET = -5
|
|
|
414
453
|
const Sub = ({ offset = 10, children, ...rest }: MenuSubProps) => (
|
|
415
454
|
<ArkMenu.Root
|
|
416
455
|
positioning={{ offset: { mainAxis: offset, crossAxis: SUBMENU_ALIGN_OFFSET } }}
|
|
456
|
+
navigate={clickLink}
|
|
417
457
|
{...rest}
|
|
418
458
|
>
|
|
419
459
|
{children}
|
|
@@ -432,19 +472,27 @@ const SubTrigger = ({
|
|
|
432
472
|
className,
|
|
433
473
|
children,
|
|
434
474
|
testId,
|
|
475
|
+
asChild,
|
|
435
476
|
...rest
|
|
436
477
|
}: MenuSubTriggerProps) => (
|
|
437
478
|
<ArkMenu.TriggerItem
|
|
479
|
+
asChild={asChild}
|
|
438
480
|
data-color={color}
|
|
439
481
|
className={cn(menuItem({ colored: color != null }), className)}
|
|
440
482
|
{...props({ "data-testid": testId })}
|
|
441
483
|
{...rest}
|
|
442
484
|
>
|
|
443
|
-
{
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
485
|
+
{composeChildren(asChild, children, (own) => (
|
|
486
|
+
<>
|
|
487
|
+
{startSection != null && <StartSection>{startSection}</StartSection>}
|
|
488
|
+
{own}
|
|
489
|
+
<span
|
|
490
|
+
className={cn(popoverChevron, "ms-auto -me-1 -rotate-90 rtl:rotate-90 [&_svg]:size-4")}
|
|
491
|
+
>
|
|
492
|
+
<ChevronIcon />
|
|
493
|
+
</span>
|
|
494
|
+
</>
|
|
495
|
+
))}
|
|
448
496
|
</ArkMenu.TriggerItem>
|
|
449
497
|
)
|
|
450
498
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { fireEvent, render, screen, waitFor } from "@testing-library/react"
|
|
2
|
+
import { describe, expect, it, vi } from "vitest"
|
|
3
|
+
import { Drawer } from "../drawer/drawer"
|
|
4
|
+
import { Modal } from "./modal"
|
|
5
|
+
|
|
6
|
+
/** Modal and Drawer share the close-trigger shape: a kit icon button by
|
|
7
|
+
* default, the consumer's own element under `asChild`. */
|
|
8
|
+
describe.each([
|
|
9
|
+
["Modal", Modal.Root, Modal.CloseTrigger],
|
|
10
|
+
["Drawer", Drawer.Root, Drawer.CloseTrigger],
|
|
11
|
+
] as const)("%s.CloseTrigger", (_, Root, CloseTrigger) => {
|
|
12
|
+
it("renders the kit's labelled icon button by default", () => {
|
|
13
|
+
render(
|
|
14
|
+
<Root open>
|
|
15
|
+
<CloseTrigger />
|
|
16
|
+
</Root>,
|
|
17
|
+
)
|
|
18
|
+
expect(screen.getByRole("button", { name: "Close" }).querySelector("svg")).toBeTruthy()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
// The consumer's button used to end up nested inside the kit's icon button.
|
|
22
|
+
it("replaces the icon button with the consumer's element under asChild", async () => {
|
|
23
|
+
const onOpenChange = vi.fn()
|
|
24
|
+
render(
|
|
25
|
+
<Root open onOpenChange={onOpenChange}>
|
|
26
|
+
<CloseTrigger asChild>
|
|
27
|
+
<button type="button">Cancel</button>
|
|
28
|
+
</CloseTrigger>
|
|
29
|
+
</Root>,
|
|
30
|
+
)
|
|
31
|
+
const buttons = screen.getAllByRole("button")
|
|
32
|
+
expect(buttons).toHaveLength(1)
|
|
33
|
+
const cancel = screen.getByRole("button", { name: "Cancel" })
|
|
34
|
+
expect(cancel.hasAttribute("aria-label")).toBe(false)
|
|
35
|
+
fireEvent.click(cancel)
|
|
36
|
+
await waitFor(() => expect(onOpenChange).toHaveBeenCalledWith({ open: false }))
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -5,6 +5,7 @@ import { Portal } from "@ark-ui/react/portal"
|
|
|
5
5
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
6
6
|
import { XIcon } from "lucide-react"
|
|
7
7
|
import { type ComponentPropsWithoutRef, type ReactNode, useRef } from "react"
|
|
8
|
+
import type { NoAsChild } from "../../lib/as-child"
|
|
8
9
|
import { cn } from "../../lib/cn"
|
|
9
10
|
import { OverlayContainerProvider } from "../../lib/overlay-container"
|
|
10
11
|
import { OverlayLayerProvider, useLayerGuard } from "../../lib/overlay-layer"
|
|
@@ -121,7 +122,7 @@ const ModalBackdrop = ({ className, testId, ...rest }: ModalBackdropProps) => (
|
|
|
121
122
|
)
|
|
122
123
|
|
|
123
124
|
export type ModalPosition = VariantProps<typeof modalPositioner>["position"]
|
|
124
|
-
export type ModalPositionerProps = ComponentPropsWithoutRef<typeof Ark.Positioner
|
|
125
|
+
export type ModalPositionerProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.Positioner>> &
|
|
125
126
|
WithTestId & {
|
|
126
127
|
position?: ModalPosition
|
|
127
128
|
}
|
|
@@ -131,6 +132,7 @@ const ModalPositioner = ({
|
|
|
131
132
|
position,
|
|
132
133
|
testId,
|
|
133
134
|
children,
|
|
135
|
+
asChild: _asChild,
|
|
134
136
|
...rest
|
|
135
137
|
}: ModalPositionerProps) => {
|
|
136
138
|
// A ref, not state: overlays read it when they portal, so nothing has to
|
|
@@ -188,23 +190,37 @@ export type ModalCloseTriggerProps = ComponentPropsWithoutRef<typeof Ark.CloseTr
|
|
|
188
190
|
const ModalCloseTrigger = ({
|
|
189
191
|
children,
|
|
190
192
|
className,
|
|
191
|
-
"aria-label": ariaLabel
|
|
193
|
+
"aria-label": ariaLabel,
|
|
192
194
|
testId,
|
|
195
|
+
asChild,
|
|
193
196
|
...rest
|
|
194
|
-
}: ModalCloseTriggerProps) =>
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
}: ModalCloseTriggerProps) =>
|
|
198
|
+
asChild ? (
|
|
199
|
+
// The consumer's element (a "Cancel" button, say) replaces the kit's icon
|
|
200
|
+
// button outright, rather than nesting inside it.
|
|
201
|
+
<Ark.CloseTrigger
|
|
202
|
+
asChild
|
|
200
203
|
aria-label={ariaLabel}
|
|
201
204
|
className={className}
|
|
202
|
-
|
|
205
|
+
{...props({ "data-testid": testId })}
|
|
206
|
+
{...rest}
|
|
203
207
|
>
|
|
204
|
-
{children
|
|
205
|
-
</
|
|
206
|
-
|
|
207
|
-
|
|
208
|
+
{children}
|
|
209
|
+
</Ark.CloseTrigger>
|
|
210
|
+
) : (
|
|
211
|
+
<Ark.CloseTrigger asChild {...rest}>
|
|
212
|
+
<ActionIcon
|
|
213
|
+
variant="subtle"
|
|
214
|
+
color="neutral"
|
|
215
|
+
size="xs"
|
|
216
|
+
aria-label={ariaLabel ?? "Close"}
|
|
217
|
+
className={className}
|
|
218
|
+
testId={testId}
|
|
219
|
+
>
|
|
220
|
+
{children ?? <XIcon />}
|
|
221
|
+
</ActionIcon>
|
|
222
|
+
</Ark.CloseTrigger>
|
|
223
|
+
)
|
|
208
224
|
|
|
209
225
|
export type ModalHeaderProps = ComponentPropsWithoutRef<"div"> & WithTestId
|
|
210
226
|
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from "lucide-react"
|
|
12
12
|
import { type ComponentPropsWithoutRef, type ReactNode, type Ref, useRef } from "react"
|
|
13
13
|
import { match } from "ts-pattern"
|
|
14
|
+
import type { ForbidAsChild } from "../../lib/as-child"
|
|
14
15
|
import { cn } from "../../lib/cn"
|
|
15
16
|
import type { Color } from "../../lib/colors"
|
|
16
17
|
import { focusStyles } from "../../lib/focus-styles"
|
|
@@ -236,7 +237,8 @@ export const CollapseTrigger = ({
|
|
|
236
237
|
* the Notifier-managed plumbing (`id` / `status` / `duration`) is optional, so a
|
|
237
238
|
* standalone card is just `<Notification type="success" title="Saved" />`.
|
|
238
239
|
*/
|
|
239
|
-
export type NotificationProps = Omit<NotificationRootProps, "title" | "color"> &
|
|
240
|
+
export type NotificationProps = Omit<NotificationRootProps, "title" | "color" | "asChild"> &
|
|
241
|
+
ForbidAsChild &
|
|
240
242
|
Omit<ToastFields, "id" | "status" | "duration"> &
|
|
241
243
|
Partial<Pick<ToastFields, "id" | "status" | "duration">> &
|
|
242
244
|
ToastHue & {
|
|
@@ -284,6 +286,7 @@ function NotificationComponent({
|
|
|
284
286
|
// Notifier-managed plumbing — not rendered onto the card.
|
|
285
287
|
status: _status,
|
|
286
288
|
duration: _duration,
|
|
289
|
+
asChild: _asChild,
|
|
287
290
|
...rest
|
|
288
291
|
}: NotificationProps) {
|
|
289
292
|
const preset = type ? TOAST_STATUS[type] : undefined
|