@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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { ark, type HTMLArkProps } from "@ark-ui/react"
|
|
4
4
|
import { type ReactNode, useEffect, useRef } from "react"
|
|
5
5
|
import { match } from "ts-pattern"
|
|
6
|
+
import type { NoAsChild } from "../../lib/as-child"
|
|
6
7
|
import type { AvailableIf, UnavailableProps } from "../../lib/available-if"
|
|
7
8
|
import { cn } from "../../lib/cn"
|
|
8
9
|
import { devWarn } from "../../lib/dev-warn"
|
|
@@ -91,7 +92,7 @@ const PROP_RENDERERS = {
|
|
|
91
92
|
onOverflowClick: ["days", "month"],
|
|
92
93
|
withOverflowDetails: ["days", "month"],
|
|
93
94
|
renderOverflowDetails: ["days", "month"],
|
|
94
|
-
visibleDays: ["days"],
|
|
95
|
+
visibleDays: ["days", "agenda"],
|
|
95
96
|
revealBehavior: ["days"],
|
|
96
97
|
editable: ["days"],
|
|
97
98
|
onEventChange: ["days"],
|
|
@@ -211,7 +212,7 @@ export type ScheduleProps<
|
|
|
211
212
|
// two intersect into a handler that has to satisfy *both* signatures, so the
|
|
212
213
|
// declaration compiles and every call site fails. The kit already uses this
|
|
213
214
|
// treatment for other redefined natives.
|
|
214
|
-
Omit<HTMLArkProps<"div">, "onSelect"
|
|
215
|
+
NoAsChild<Omit<HTMLArkProps<"div">, "onSelect">> &
|
|
215
216
|
WithTestId &
|
|
216
217
|
// ─── days · month · year ───────────────────────────────────────────────
|
|
217
218
|
AvailableIf<
|
|
@@ -231,6 +232,18 @@ export type ScheduleProps<
|
|
|
231
232
|
ScheduleEmptyProps,
|
|
232
233
|
"requires a days or agenda renderer in `views` — month and year always draw a calendar, so they have no empty state"
|
|
233
234
|
> &
|
|
235
|
+
AvailableIf<
|
|
236
|
+
HasRenderer<V, "days" | "agenda">,
|
|
237
|
+
{
|
|
238
|
+
/** Fallback window size, in days, for the `"days"` and `"agenda"`
|
|
239
|
+
* renderers. Default `7`. An active entry that pins its own
|
|
240
|
+
* `visibleDays` (`"day"` and `"week"` do) overrides this; `"days"` and
|
|
241
|
+
* `"agenda"` deliberately do not, so the two share one span unless an
|
|
242
|
+
* entry says otherwise. */
|
|
243
|
+
visibleDays?: number
|
|
244
|
+
},
|
|
245
|
+
"requires a days or agenda renderer in `views` — month and year draw a whole calendar period, not a span of days"
|
|
246
|
+
> &
|
|
234
247
|
// ─── days · month ──────────────────────────────────────────────────────
|
|
235
248
|
AvailableIf<
|
|
236
249
|
HasRenderer<V, "days" | "month">,
|
|
@@ -267,11 +280,6 @@ export type ScheduleProps<
|
|
|
267
280
|
ScheduleTimedProps<P>,
|
|
268
281
|
"editable" | "onEventChange" | "onEventRemove" | "onEventCreate"
|
|
269
282
|
> & {
|
|
270
|
-
/** Fallback window size, in days, for the `"days"` renderer. Default `7`.
|
|
271
|
-
* An active entry that pins its own `visibleDays` (`"day"` and `"week"`
|
|
272
|
-
* do) overrides this; `"days"` deliberately does not, so this prop keeps
|
|
273
|
-
* working exactly as before under the default entries. */
|
|
274
|
-
visibleDays?: number
|
|
275
283
|
/**
|
|
276
284
|
* How a **reveal** scrolls the days grid — the day brought into view by
|
|
277
285
|
* navigating to it, and the chip brought into view by selecting it.
|
|
@@ -360,10 +368,6 @@ export type ScheduleProps<
|
|
|
360
368
|
* `DaysView`/... has no toolbar row of its own to put it in unless
|
|
361
369
|
* `withPagination` is also on; `Root` always has one. */
|
|
362
370
|
withNowButton?: boolean
|
|
363
|
-
/** Fallback window size, in days, for the `"days"` renderer. Default `7`.
|
|
364
|
-
* An active entry that pins its own `visibleDays` (`"day"` and `"week"`
|
|
365
|
-
* do) overrides this; `"days"` deliberately does not, so this prop keeps
|
|
366
|
-
* working exactly as before under the default entries. */
|
|
367
371
|
}
|
|
368
372
|
|
|
369
373
|
/**
|
|
@@ -387,7 +391,7 @@ type ScheduleAllProps<P = unknown> = ScheduleSharedProps<P> &
|
|
|
387
391
|
ScheduleYearOnlyProps &
|
|
388
392
|
ScheduleAgendaOnlyProps<P> &
|
|
389
393
|
AnchorDateProps &
|
|
390
|
-
Omit<HTMLArkProps<"div">, "onSelect"
|
|
394
|
+
NoAsChild<Omit<HTMLArkProps<"div">, "onSelect">> &
|
|
391
395
|
WithTestId & {
|
|
392
396
|
views?: ScheduleViews
|
|
393
397
|
view?: string
|
|
@@ -421,7 +425,10 @@ export function ScheduleRoot<P = unknown>(allProps: ScheduleAllProps<P>) {
|
|
|
421
425
|
defaultSelected,
|
|
422
426
|
onSelect,
|
|
423
427
|
withSelection = true,
|
|
424
|
-
|
|
428
|
+
// No default here: each renderer owns its own — `true` for the grids,
|
|
429
|
+
// whose chips can't show a description, `false` for the agenda, whose
|
|
430
|
+
// rows already do.
|
|
431
|
+
withEventDetails,
|
|
425
432
|
onDayClick,
|
|
426
433
|
renderEventDetails,
|
|
427
434
|
locale: localeProp,
|
|
@@ -467,6 +474,7 @@ export function ScheduleRoot<P = unknown>(allProps: ScheduleAllProps<P>) {
|
|
|
467
474
|
onMonthClick,
|
|
468
475
|
renderEvent,
|
|
469
476
|
testId,
|
|
477
|
+
asChild: _asChild,
|
|
470
478
|
...rest
|
|
471
479
|
} = allProps
|
|
472
480
|
const locale = useLocale(localeProp)
|
|
@@ -1031,6 +1039,7 @@ export function ScheduleRoot<P = unknown>(allProps: ScheduleAllProps<P>) {
|
|
|
1031
1039
|
withPagination={false}
|
|
1032
1040
|
withNowButton={false}
|
|
1033
1041
|
now={now}
|
|
1042
|
+
visibleDays={activeVisibleDays}
|
|
1034
1043
|
/>
|
|
1035
1044
|
))
|
|
1036
1045
|
.exhaustive()}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Slider as Ark } from "@ark-ui/react/slider"
|
|
4
4
|
import { cva } from "class-variance-authority"
|
|
5
5
|
import type { ComponentPropsWithoutRef, FocusEvent, ReactNode, Ref } from "react"
|
|
6
|
+
import type { ForbidAsChild } from "../../lib/as-child"
|
|
6
7
|
import { cn } from "../../lib/cn"
|
|
7
8
|
import type { Color } from "../../lib/colors"
|
|
8
9
|
import { focusStyles } from "../../lib/focus-styles"
|
|
@@ -191,8 +192,10 @@ export type SliderProps<V extends SliderValue = number> = Pick<
|
|
|
191
192
|
// thumb label (see below), so the Field gets only the surrounding slots.
|
|
192
193
|
"description" | "error" | "required"
|
|
193
194
|
> &
|
|
195
|
+
ForbidAsChild &
|
|
194
196
|
Omit<
|
|
195
197
|
ArkRootProps,
|
|
198
|
+
| "asChild"
|
|
196
199
|
| "value"
|
|
197
200
|
| "defaultValue"
|
|
198
201
|
| "onValueChange"
|
|
@@ -260,6 +263,7 @@ export const Slider = <V extends SliderValue = number>({
|
|
|
260
263
|
className,
|
|
261
264
|
classNames,
|
|
262
265
|
testId,
|
|
266
|
+
asChild: _asChild,
|
|
263
267
|
...rest
|
|
264
268
|
}: SliderProps<V>) => {
|
|
265
269
|
const _showLabel =
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import type { ReactNode } from "react"
|
|
4
|
+
import type { ForbidAsChild } from "../../lib/as-child"
|
|
4
5
|
import type { Color } from "../../lib/colors"
|
|
5
6
|
import type { Size } from "../../lib/sizes"
|
|
6
7
|
import {
|
|
@@ -54,20 +55,21 @@ export type TabsValue<Data extends TabsData> = Data[number]["value"]
|
|
|
54
55
|
|
|
55
56
|
export type TabsProps<Data extends TabsData = TabsData> = Omit<
|
|
56
57
|
TabsRootProps,
|
|
57
|
-
"children" | "onValueChange"
|
|
58
|
-
> &
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
"children" | "onValueChange" | "onChange" | "asChild"
|
|
59
|
+
> &
|
|
60
|
+
ForbidAsChild & {
|
|
61
|
+
/** Tabs, in order. Each needs its own `content`. */
|
|
62
|
+
data: Data
|
|
63
|
+
/** Tray + trigger + indicator treatment, mirroring `Button`/`SegmentGroup`. */
|
|
64
|
+
variant?: TabsVariant
|
|
65
|
+
/** Trigger size. */
|
|
66
|
+
size?: Size
|
|
67
|
+
/** Palette for the sliding indicator + active-trigger text. Scoped to the
|
|
68
|
+
* strip (it lands on the `List`), so it never tints the panel content. */
|
|
69
|
+
color?: Color
|
|
70
|
+
/** Fires with the selected value (narrowed to the data value union). */
|
|
71
|
+
onChange?: (value: TabsValue<Data>) => void
|
|
72
|
+
}
|
|
71
73
|
|
|
72
74
|
const TabsComponent = <const Data extends TabsData>({
|
|
73
75
|
data,
|
|
@@ -77,6 +79,7 @@ const TabsComponent = <const Data extends TabsData>({
|
|
|
77
79
|
value,
|
|
78
80
|
defaultValue,
|
|
79
81
|
onChange,
|
|
82
|
+
asChild: _asChild,
|
|
80
83
|
...root
|
|
81
84
|
}: TabsProps<Data>) => (
|
|
82
85
|
<Root
|
|
@@ -38,7 +38,7 @@ const themeIconVariants = cva(
|
|
|
38
38
|
// fill blends with whatever surface it sits on instead of reading
|
|
39
39
|
// as a painted CTA block. The border mixes in black on top of that
|
|
40
40
|
// same var — a fixed darkening, not another opacity step of it —
|
|
41
|
-
// so it reads as a recessed edge in both themes; some colors (
|
|
41
|
+
// so it reads as a recessed edge in both themes; some colors (neutral
|
|
42
42
|
// in particular) have a dark-mode `--c-solid` that's lighter than
|
|
43
43
|
// its own soft/text steps, which would flip a same-var-opacity
|
|
44
44
|
// border the wrong way. This is the ThemeIcon-specific reading of
|
|
@@ -2,6 +2,7 @@ import { ark, type HTMLArkProps } from "@ark-ui/react"
|
|
|
2
2
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
3
3
|
import type { CSSProperties, ReactElement, ReactNode } from "react"
|
|
4
4
|
import { Children, cloneElement, isValidElement } from "react"
|
|
5
|
+
import { composeChildren } from "../../lib/as-child"
|
|
5
6
|
import { cn } from "../../lib/cn"
|
|
6
7
|
import type { Color } from "../../lib/colors"
|
|
7
8
|
import {
|
|
@@ -505,6 +506,7 @@ const TimelineItem = ({
|
|
|
505
506
|
// Read by `TimelineRoot` (see `stateAt`); kept off the `<li>`.
|
|
506
507
|
active: _active,
|
|
507
508
|
testId,
|
|
509
|
+
asChild,
|
|
508
510
|
...rest
|
|
509
511
|
}: TimelineItemInternalProps) => {
|
|
510
512
|
const isGradient = variant === "gradient"
|
|
@@ -527,6 +529,7 @@ const TimelineItem = ({
|
|
|
527
529
|
|
|
528
530
|
return (
|
|
529
531
|
<ark.li
|
|
532
|
+
asChild={asChild}
|
|
530
533
|
style={
|
|
531
534
|
{
|
|
532
535
|
...(size ? { "--tl-bullet-size": BULLET_SIZE[size] } : undefined),
|
|
@@ -547,105 +550,109 @@ const TimelineItem = ({
|
|
|
547
550
|
})}
|
|
548
551
|
{...rest}
|
|
549
552
|
>
|
|
550
|
-
{
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
553
|
+
{composeChildren(asChild, children, (own) => (
|
|
554
|
+
<>
|
|
555
|
+
{/* Two line segments share `data-part="line"` (so the first/last-item
|
|
556
|
+
suppression selectors above match both) but differ in `data-edge`
|
|
557
|
+
for layout and visibility. Both are a `--tl-line-width`-wide
|
|
558
|
+
background bar rather than a border, so a gradient fill and the
|
|
559
|
+
`--tl-line-mask` dash pattern can be combined.
|
|
555
560
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
561
|
+
`data-edge="start"` (leading) fills the gap `axisOffset` opens
|
|
562
|
+
*above* this item's own (shifted-down) bullet — a plain height of
|
|
563
|
+
`--tl-axis-offset` (0, i.e. invisible, when `axisOffset` isn't
|
|
564
|
+
set), `self-start` so it sits flush at the row's own top edge.
|
|
565
|
+
Hidden on the first item: nothing renders above the very first
|
|
566
|
+
bullet to connect to. It's flat in this item's own entry color:
|
|
567
|
+
the previous item's trailing segment has already blended into
|
|
568
|
+
exactly that color by the time it reaches this row's top edge, so
|
|
569
|
+
the two meet with no seam. Only its dash pattern comes from the
|
|
570
|
+
previous item (`prevItem.lineVariant`), since it continues that
|
|
571
|
+
item's segment.
|
|
567
572
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
573
|
+
`data-edge="end"` (trailing) is the connector to the next item: a
|
|
574
|
+
grid item in the same cell as the bullet (col/row-start-2/1,
|
|
575
|
+
default align-self:stretch fills the row's real height), whose
|
|
576
|
+
margin-top pushes its own box down by exactly the bullet's
|
|
577
|
+
diameter plus `--tl-axis-offset` — so it stops right at the
|
|
578
|
+
bullet's edge instead of running behind it, and the hollow
|
|
579
|
+
variants can stay genuinely transparent. Hidden on the last item.
|
|
575
580
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
581
|
+
It blends from this item's exit color to the next item's entry
|
|
582
|
+
color. Those are usually two *different* palettes, and a `--c-*`
|
|
583
|
+
slot only resolves against the `data-color` of the element it's
|
|
584
|
+
read on, so it takes two elements: the outer span carries this
|
|
585
|
+
item's palette and declares `--tl-from`, the inner one carries the
|
|
586
|
+
next item's and declares `--tl-to`. A custom property inherits its
|
|
587
|
+
*computed* value — the `var(--c-solid)` in `--tl-from` is already
|
|
588
|
+
substituted with this item's color by the time the inner span reads
|
|
589
|
+
it — so the inner span sees both colors at once. The outer span stays
|
|
590
|
+
the direct grid item (stretching through a nested element is
|
|
591
|
+
unreliable); the inner one just fills it with `absolute inset-0`.
|
|
587
592
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
593
|
+
`--tl-bullet-size`/`--tl-axis-offset` are declared on the `<li>`
|
|
594
|
+
(see `timelineVariants` / this component's own `style`), not
|
|
595
|
+
scoped to the bullet, so these siblings can read the same values
|
|
596
|
+
as the axis div below — siblings can only stay in sync through a
|
|
597
|
+
shared var. */}
|
|
598
|
+
<span
|
|
599
|
+
data-part="line"
|
|
600
|
+
data-edge="start"
|
|
601
|
+
data-color={entry.dataColor}
|
|
602
|
+
style={{ "--tl-from": entry.value, ...leadingMask } as CSSProperties}
|
|
603
|
+
className={cn(
|
|
604
|
+
"col-start-2 row-start-1 self-start justify-self-center w-(--tl-line-width)",
|
|
605
|
+
"h-(--tl-axis-offset,0px) bg-(--tl-from) [mask-image:var(--tl-line-mask)]",
|
|
606
|
+
)}
|
|
607
|
+
/>
|
|
608
|
+
<span
|
|
609
|
+
data-part="line"
|
|
610
|
+
data-edge="end"
|
|
611
|
+
data-color={exit.dataColor}
|
|
612
|
+
style={{ "--tl-from": exit.value, ...ownMask } as CSSProperties}
|
|
613
|
+
className={cn(
|
|
614
|
+
"relative col-start-2 row-start-1 justify-self-center w-(--tl-line-width)",
|
|
615
|
+
"mt-[calc(var(--tl-bullet-size)+var(--tl-axis-offset,0px))]",
|
|
616
|
+
"[mask-image:var(--tl-line-mask)]",
|
|
617
|
+
)}
|
|
618
|
+
>
|
|
619
|
+
<span
|
|
620
|
+
data-color={target.dataColor}
|
|
621
|
+
style={{ "--tl-to": target.value } as CSSProperties}
|
|
622
|
+
className="absolute inset-0 [background-image:linear-gradient(to_bottom_in_oklab,var(--tl-from),var(--tl-to))]"
|
|
623
|
+
/>
|
|
624
|
+
</span>
|
|
625
|
+
<div
|
|
626
|
+
data-part="axis"
|
|
627
|
+
className="col-start-2 row-start-1 flex justify-center self-start pt-(--tl-axis-offset)"
|
|
628
|
+
>
|
|
629
|
+
<span
|
|
630
|
+
data-part="bullet"
|
|
631
|
+
// A pending bullet drops its palette: `[data-color]` and the
|
|
632
|
+
// `pending` slot remap would both set `--c-*` on this one element,
|
|
633
|
+
// leaving the winner to stylesheet order. The disabled slots it
|
|
634
|
+
// remaps to are shared by every palette anyway.
|
|
635
|
+
data-color={!isGradient && !pending ? color : undefined}
|
|
636
|
+
style={gradientVars as CSSProperties}
|
|
637
|
+
className={cn(
|
|
638
|
+
timelineBulletVariants({
|
|
639
|
+
variant,
|
|
640
|
+
// A pending `default` step is a bare outer ring: no inset gap
|
|
641
|
+
// and center to draw.
|
|
642
|
+
ringed: !bullet && !(pending && (variant ?? "default") === "default"),
|
|
643
|
+
state,
|
|
644
|
+
}),
|
|
645
|
+
"size-(--tl-bullet-size) grid place-items-center overflow-hidden",
|
|
646
|
+
"[&_svg]:size-full [&_svg]:p-0.5",
|
|
647
|
+
isGradient && !pending && gradient?.dir && GRADIENT_DIR_CLASS[gradient.dir],
|
|
648
|
+
)}
|
|
649
|
+
>
|
|
650
|
+
{bullet}
|
|
651
|
+
</span>
|
|
652
|
+
</div>
|
|
653
|
+
{own}
|
|
654
|
+
</>
|
|
655
|
+
))}
|
|
649
656
|
</ark.li>
|
|
650
657
|
)
|
|
651
658
|
}
|
|
@@ -6,6 +6,7 @@ import { Tooltip as ArkTooltip } from "@ark-ui/react/tooltip"
|
|
|
6
6
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
7
7
|
import { createContext, type ReactNode, useContext, useId } from "react"
|
|
8
8
|
import { match } from "ts-pattern"
|
|
9
|
+
import type { NoAsChild } from "../../lib/as-child"
|
|
9
10
|
import { cn } from "../../lib/cn"
|
|
10
11
|
import { focusStyles } from "../../lib/focus-styles"
|
|
11
12
|
import { useOverlayContainer } from "../../lib/overlay-container"
|
|
@@ -177,7 +178,7 @@ const Content = ({ className, children, testId, ...rest }: TooltipContentProps)
|
|
|
177
178
|
return <Portal container={portalContainer}>{bubble}</Portal>
|
|
178
179
|
}
|
|
179
180
|
|
|
180
|
-
export type TooltipArrowProps = ArkTooltip.ArrowProps & WithTestId
|
|
181
|
+
export type TooltipArrowProps = NoAsChild<ArkTooltip.ArrowProps> & WithTestId
|
|
181
182
|
|
|
182
183
|
/** The little arrow linking the bubble to its trigger. Compose it inside a
|
|
183
184
|
* `Tooltip.Content` (or let the convenience form's `withArrow` add it for you).
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { render } from "@testing-library/react"
|
|
2
|
+
import { describe, expect, it } from "vitest"
|
|
3
|
+
import { type ForbidAsChild, type NoAsChild, withAsChildContent } from "./as-child"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Type-level guards for the two forbid shapes, plus the folding helper's
|
|
7
|
+
* runtime. As in `available-if.test.ts`, `pnpm typecheck` enforces the
|
|
8
|
+
* negative cases, and each `@ts-expect-error` has a positive twin proving the
|
|
9
|
+
* line is otherwise well-formed.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
type Slice = { asChild?: boolean; id?: string }
|
|
13
|
+
const Part = (_: NoAsChild<Slice>) => null
|
|
14
|
+
|
|
15
|
+
/** A discriminated pair kept outside the omitted slice, the way
|
|
16
|
+
* `NotificationProps` keeps `ToastHue`. */
|
|
17
|
+
type Hue = { type: "info"; color?: undefined } | { type?: undefined; color?: string }
|
|
18
|
+
const Paired = (_: Omit<Slice, "asChild"> & ForbidAsChild & Hue) => null
|
|
19
|
+
|
|
20
|
+
describe("NoAsChild", () => {
|
|
21
|
+
it("rejects asChild passed directly", () => {
|
|
22
|
+
// @ts-expect-error asChild is unavailable, and the brand says why.
|
|
23
|
+
const bad = <Part asChild />
|
|
24
|
+
const ok = <Part id="x" />
|
|
25
|
+
expect([bad, ok]).toHaveLength(2)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it("rejects asChild arriving through a spread", () => {
|
|
29
|
+
const forwarded = { asChild: true }
|
|
30
|
+
// @ts-expect-error a spread is how prop bags get forwarded, so it must be caught too.
|
|
31
|
+
const bad = <Part {...forwarded} />
|
|
32
|
+
const allowed = { id: "x" }
|
|
33
|
+
const ok = <Part {...allowed} />
|
|
34
|
+
expect([bad, ok]).toHaveLength(2)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it("still allows an explicit undefined", () => {
|
|
38
|
+
expect(<Part asChild={undefined} />).toBeTruthy()
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
describe("ForbidAsChild", () => {
|
|
43
|
+
it("leaves a union beside it intact", () => {
|
|
44
|
+
// @ts-expect-error `type` and `color` stay exclusive: no Omit flattened the union.
|
|
45
|
+
const bad = <Paired type="info" color="red" />
|
|
46
|
+
const ok = [<Paired key="t" type="info" />, <Paired key="c" color="red" />]
|
|
47
|
+
expect([bad, ...ok]).toHaveLength(3)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it("rejects asChild", () => {
|
|
51
|
+
// @ts-expect-error asChild is unavailable here too.
|
|
52
|
+
const bad = <Paired asChild />
|
|
53
|
+
expect(bad).toBeTruthy()
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
describe("withAsChildContent", () => {
|
|
58
|
+
it("rebuilds an element child's own children and merges extra props", () => {
|
|
59
|
+
const { container } = render(
|
|
60
|
+
withAsChildContent(<a href="/x">label</a>, (own) => <b>{own}</b>, { title: "t" }),
|
|
61
|
+
)
|
|
62
|
+
const link = container.querySelector("a")
|
|
63
|
+
expect(link?.innerHTML).toBe("<b>label</b>")
|
|
64
|
+
expect(link?.getAttribute("title")).toBe("t")
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it("passes a non-element child through untouched", () => {
|
|
68
|
+
expect(withAsChildContent("text", (own) => <b>{own}</b>)).toBe("text")
|
|
69
|
+
})
|
|
70
|
+
})
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { cloneElement, isValidElement, type ReactNode } from "react"
|
|
2
|
+
import type { UnavailableProps } from "./available-if"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The two sanctioned ways for a kit part to meet Ark's `asChild`.
|
|
6
|
+
*
|
|
7
|
+
* Ark's factory clones **exactly one** valid element under `asChild` and
|
|
8
|
+
* renders `null` otherwise (`isValidElement(children) ? clone : null`). So a
|
|
9
|
+
* part that renders anything besides a bare `{children}` — an icon, a
|
|
10
|
+
* section, an indicator, a default fallback — breaks in one of two ways:
|
|
11
|
+
*
|
|
12
|
+
* - **It renders nothing.** Two or more JSX child expressions become an
|
|
13
|
+
* array, even when some of them evaluate to `false`
|
|
14
|
+
* (`{start && <Start/>}{children}{end && <End/>}`), and an array is not an
|
|
15
|
+
* element.
|
|
16
|
+
* - **Its own content is lost or misplaced.** Under `asChild`, `children`
|
|
17
|
+
* *is* the consumer's element, so `children ?? <DefaultIcon/>` never
|
|
18
|
+
* reaches the fallback, and a wrapper (`<Provider>{children}</Provider>`)
|
|
19
|
+
* is what gets cloned instead of the consumer's element.
|
|
20
|
+
*
|
|
21
|
+
* Every such part must pick one of these:
|
|
22
|
+
*
|
|
23
|
+
* - **`withAsChildContent`** — the part can sensibly *become* the consumer's
|
|
24
|
+
* element (a menu item rendered as a router `<Link>`, a crumb, an alert
|
|
25
|
+
* that links somewhere). The kit's content is folded into the child's own
|
|
26
|
+
* children, so Ark still receives a single element.
|
|
27
|
+
* - **`NoAsChild`** — the part renders structure that cannot live inside an
|
|
28
|
+
* arbitrary element (a slider's track and thumbs, a scheduler grid). The
|
|
29
|
+
* prop becomes a compile error that says why.
|
|
30
|
+
*
|
|
31
|
+
* `as-child.contract.test.tsx` enforces the choice: it derives every public
|
|
32
|
+
* part that accepts `asChild` from the component entries, renders each one
|
|
33
|
+
* with an `<a>` child, and fails the typecheck when a part is in neither its
|
|
34
|
+
* render table nor `NoAsChild`.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Rebuilds the single `asChild` child's own children through `render`, so
|
|
39
|
+
* kit content (sections, icons, spinners) lands *inside* the element Ark
|
|
40
|
+
* clones instead of beside it. `extra` is merged onto the child too, for the
|
|
41
|
+
* odd prop the kit has to own (a click guard while loading).
|
|
42
|
+
*
|
|
43
|
+
* A child that isn't a single element falls through unchanged, leaving
|
|
44
|
+
* Ark's own handling of the misuse as it is.
|
|
45
|
+
*
|
|
46
|
+
* ```tsx
|
|
47
|
+
* <ArkMenu.Item asChild {...rest}>
|
|
48
|
+
* {withAsChildContent(children, (own) => (
|
|
49
|
+
* <>
|
|
50
|
+
* <StartSection>{startSection}</StartSection>
|
|
51
|
+
* {own}
|
|
52
|
+
* </>
|
|
53
|
+
* ))}
|
|
54
|
+
* </ArkMenu.Item>
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export const withAsChildContent = (
|
|
58
|
+
child: ReactNode,
|
|
59
|
+
render: (own: ReactNode) => ReactNode,
|
|
60
|
+
extra?: Record<string, unknown>,
|
|
61
|
+
): ReactNode => {
|
|
62
|
+
if (!isValidElement<{ children?: ReactNode }>(child)) return child
|
|
63
|
+
return cloneElement(child, { ...extra, children: render(child.props.children) })
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The usual call site: `render` wraps the part's `children` with its own
|
|
68
|
+
* content either way, around `children` normally and inside the consumer's
|
|
69
|
+
* element under `asChild`. One `render` serves both branches, so the two
|
|
70
|
+
* can't drift apart.
|
|
71
|
+
*
|
|
72
|
+
* ```tsx
|
|
73
|
+
* <ArkMenu.Item asChild={asChild} {...rest}>
|
|
74
|
+
* {composeChildren(asChild, children, (own) => <>{icon}{own}</>)}
|
|
75
|
+
* </ArkMenu.Item>
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export const composeChildren = (
|
|
79
|
+
asChild: boolean | undefined,
|
|
80
|
+
children: ReactNode,
|
|
81
|
+
render: (own: ReactNode) => ReactNode,
|
|
82
|
+
): ReactNode => (asChild ? withAsChildContent(children, render) : render(children))
|
|
83
|
+
|
|
84
|
+
/** The sentence a caller reads when passing `asChild` to a `NoAsChild` part. */
|
|
85
|
+
export type NoAsChildReason =
|
|
86
|
+
"renders its own structure around its children, so asChild is not supported"
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The forbid shape on its own: `asChild` typed as a branded `Unavailable`.
|
|
90
|
+
* Intersect it beside a props type (`Omit<RootProps, "children"> &
|
|
91
|
+
* ForbidAsChild & { data }`); `NoAsChild<P>` is the same thing as a wrapper.
|
|
92
|
+
*
|
|
93
|
+
* Uses the brand rather than omitting the key, because omission is silent
|
|
94
|
+
* on a JSX spread (`<Slider {...props} />`), which is exactly how prop bags
|
|
95
|
+
* get forwarded. Either way the error names the reason:
|
|
96
|
+
*
|
|
97
|
+
* Type 'boolean' is not assignable to type 'Unavailable<"renders its own
|
|
98
|
+
* structure around its children, so asChild is not supported">'
|
|
99
|
+
*/
|
|
100
|
+
export type ForbidAsChild = UnavailableProps<{ asChild?: boolean }, NoAsChildReason>
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* `P` with `asChild` forbidden: `P & ForbidAsChild`, so `asChild` resolves
|
|
104
|
+
* to `(boolean & Unavailable<…>) | undefined`, which nothing but `undefined`
|
|
105
|
+
* satisfies.
|
|
106
|
+
*
|
|
107
|
+
* An intersection, not `Omit<P, "asChild"> & …`. `Omit` re-maps every key of
|
|
108
|
+
* a large HTML/Ark props type, and measured on the forbidden parts that cost
|
|
109
|
+
* each importing file about 38k extra type instantiations (+8.6%); the
|
|
110
|
+
* intersection costs nothing measurable. It also leaves a union in `P` (a
|
|
111
|
+
* discriminated `type` / `color` pair, a slot-size union) and any generic
|
|
112
|
+
* untouched, where `Omit` would flatten the one and hide the other from
|
|
113
|
+
* inference.
|
|
114
|
+
*
|
|
115
|
+
* The component destructures `asChild` out before spreading the rest onto
|
|
116
|
+
* its Ark part (`({ asChild: _asChild, ...rest })`), so a JS caller that
|
|
117
|
+
* passes it anyway gets the normal render rather than Ark's `null`.
|
|
118
|
+
*/
|
|
119
|
+
export type NoAsChild<P> = P & ForbidAsChild
|
package/src/lib/colors.ts
CHANGED
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export const COLORS = [
|
|
13
13
|
"brand",
|
|
14
|
-
"gray",
|
|
15
14
|
// Composed from existing white/gray/brand-950 tokens rather than its own
|
|
16
|
-
// scale — the literal white/dark-navy button from the 42 UI Kit Figma
|
|
15
|
+
// scale — the literal white/dark-navy button from the 42 UI Kit Figma
|
|
16
|
+
// (where it is still labelled "gray" on Button). The former mid-gray `gray`
|
|
17
|
+
// palette was cut in its favor; `data-color="gray"` survives only as a
|
|
18
|
+
// deprecated CSS alias of this one (see colors.css).
|
|
17
19
|
"neutral",
|
|
18
20
|
"red",
|
|
19
21
|
"orange",
|