@42-central/ui-react 0.17.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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-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-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-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/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/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/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-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 +20 -19
- 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/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 +5 -3
- 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/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/lib/as-child.d.ts +104 -0
- package/dist/lib/as-child.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/as-child.contract.test.tsx +809 -0
- 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/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/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/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/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 +5 -3
- 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/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/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-NGAQITWP.js.map +0 -1
- package/dist/chunk-POKDSVQT.js.map +0 -1
- package/dist/chunk-QMW7D5GU.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
|
@@ -29,6 +29,7 @@ const DEFAULT_TRANSLATIONS: CodeBlockTranslations = {
|
|
|
29
29
|
|
|
30
30
|
export type CodeBlockClassNames = {
|
|
31
31
|
root?: string
|
|
32
|
+
title?: string
|
|
32
33
|
pre?: string
|
|
33
34
|
controls?: string
|
|
34
35
|
copyButton?: string
|
|
@@ -192,6 +193,9 @@ export type CodeBlockChromeProps = WithTestId & {
|
|
|
192
193
|
* `isCollapsible`. */
|
|
193
194
|
tailContent?: ReactNode
|
|
194
195
|
|
|
196
|
+
/** Header row above the code; hosts the toolbar when set. */
|
|
197
|
+
title?: ReactNode
|
|
198
|
+
|
|
195
199
|
/** @default true */
|
|
196
200
|
withCopyButton?: boolean
|
|
197
201
|
/** `null` hides it. @default <CopyIcon/> */
|
|
@@ -231,6 +235,7 @@ export function CodeBlockChrome({
|
|
|
231
235
|
isCollapsible,
|
|
232
236
|
headContent,
|
|
233
237
|
tailContent,
|
|
238
|
+
title,
|
|
234
239
|
withCopyButton = true,
|
|
235
240
|
copyIcon,
|
|
236
241
|
copiedIcon,
|
|
@@ -261,6 +266,53 @@ export function CodeBlockChrome({
|
|
|
261
266
|
// gap above/below) is the correct treatment there instead.
|
|
262
267
|
const isSingleLine = !code.includes("\n")
|
|
263
268
|
|
|
269
|
+
const toolbar = (controls != null || withCopyButton || isCollapsible) && (
|
|
270
|
+
<div
|
|
271
|
+
className={cn(
|
|
272
|
+
"flex items-center gap-1 p-0.5",
|
|
273
|
+
// In a title header the toolbar sits in-flow at the row's end;
|
|
274
|
+
// otherwise it floats over the code's top-right corner.
|
|
275
|
+
title == null && "absolute right-2 z-10",
|
|
276
|
+
title == null && (isSingleLine ? "top-1/2 -translate-y-1/2" : "top-2"),
|
|
277
|
+
// Same floating-surface chrome every other overlay panel in the
|
|
278
|
+
// kit uses (Popover/Menu/Select's positioner) — border-brand-900/20
|
|
279
|
+
// dark:border-white/15 + bg-brand-50/90 dark:bg-brand-950/85 +
|
|
280
|
+
// backdrop-blur-sm + shadow-lg — rather than an ad-hoc neutral
|
|
281
|
+
// white/gray-dark tint that doesn't match the kit's own convention
|
|
282
|
+
// for "a small panel floating over content." Only while floating —
|
|
283
|
+
// inside the title header it's part of the bar, not over content.
|
|
284
|
+
title == null && popoverChrome,
|
|
285
|
+
classNames?.controls,
|
|
286
|
+
)}
|
|
287
|
+
>
|
|
288
|
+
{controls}
|
|
289
|
+
{isCollapsible && (
|
|
290
|
+
<ExpandTrigger
|
|
291
|
+
expanded={expanded}
|
|
292
|
+
onToggle={() => setExpanded((prev) => !prev)}
|
|
293
|
+
expandLabel={t.expand}
|
|
294
|
+
collapseLabel={t.collapse}
|
|
295
|
+
expandIcon={expandIcon}
|
|
296
|
+
collapseIcon={collapseIcon}
|
|
297
|
+
className={classNames?.expandButton}
|
|
298
|
+
testId={testId && `${testId}-expand`}
|
|
299
|
+
/>
|
|
300
|
+
)}
|
|
301
|
+
{withCopyButton && (
|
|
302
|
+
<CopyTrigger
|
|
303
|
+
code={code}
|
|
304
|
+
onCopy={onCopy}
|
|
305
|
+
copyLabel={t.copy}
|
|
306
|
+
copiedLabel={t.copied}
|
|
307
|
+
copyIcon={copyIcon}
|
|
308
|
+
copiedIcon={copiedIcon}
|
|
309
|
+
className={classNames?.copyButton}
|
|
310
|
+
testId={testId && `${testId}-copy`}
|
|
311
|
+
/>
|
|
312
|
+
)}
|
|
313
|
+
</div>
|
|
314
|
+
)
|
|
315
|
+
|
|
264
316
|
return (
|
|
265
317
|
<div
|
|
266
318
|
className={cn(
|
|
@@ -270,47 +322,19 @@ export function CodeBlockChrome({
|
|
|
270
322
|
)}
|
|
271
323
|
{...props({ "data-testid": testId })}
|
|
272
324
|
>
|
|
273
|
-
{
|
|
325
|
+
{title != null ? (
|
|
274
326
|
<div
|
|
275
327
|
className={cn(
|
|
276
|
-
"
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
// kit uses (Popover/Menu/Select's positioner) — border-brand-900/20
|
|
280
|
-
// dark:border-white/15 + bg-brand-50/90 dark:bg-brand-950/85 +
|
|
281
|
-
// backdrop-blur-sm + shadow-lg — rather than an ad-hoc neutral
|
|
282
|
-
// white/gray-dark tint that doesn't match the kit's own convention
|
|
283
|
-
// for "a small panel floating over content."
|
|
284
|
-
popoverChrome,
|
|
285
|
-
classNames?.controls,
|
|
328
|
+
"flex min-h-9 items-center gap-2 border-b border-brand-900/30 dark:border-white/10 ps-4 pe-2",
|
|
329
|
+
"text-xs font-mono text-gray-light-500 dark:text-gray-dark-400",
|
|
330
|
+
classNames?.title,
|
|
286
331
|
)}
|
|
287
332
|
>
|
|
288
|
-
{
|
|
289
|
-
{
|
|
290
|
-
<ExpandTrigger
|
|
291
|
-
expanded={expanded}
|
|
292
|
-
onToggle={() => setExpanded((prev) => !prev)}
|
|
293
|
-
expandLabel={t.expand}
|
|
294
|
-
collapseLabel={t.collapse}
|
|
295
|
-
expandIcon={expandIcon}
|
|
296
|
-
collapseIcon={collapseIcon}
|
|
297
|
-
className={classNames?.expandButton}
|
|
298
|
-
testId={testId && `${testId}-expand`}
|
|
299
|
-
/>
|
|
300
|
-
)}
|
|
301
|
-
{withCopyButton && (
|
|
302
|
-
<CopyTrigger
|
|
303
|
-
code={code}
|
|
304
|
-
onCopy={onCopy}
|
|
305
|
-
copyLabel={t.copy}
|
|
306
|
-
copiedLabel={t.copied}
|
|
307
|
-
copyIcon={copyIcon}
|
|
308
|
-
copiedIcon={copiedIcon}
|
|
309
|
-
className={classNames?.copyButton}
|
|
310
|
-
testId={testId && `${testId}-copy`}
|
|
311
|
-
/>
|
|
312
|
-
)}
|
|
333
|
+
<span className="min-w-0 flex-1 truncate">{title}</span>
|
|
334
|
+
{toolbar}
|
|
313
335
|
</div>
|
|
336
|
+
) : (
|
|
337
|
+
toolbar
|
|
314
338
|
)}
|
|
315
339
|
|
|
316
340
|
{headContent}
|
|
@@ -249,4 +249,31 @@ describe("CodeBlock", () => {
|
|
|
249
249
|
expect(copy.className).toContain("focus-visible:ring-2")
|
|
250
250
|
expect(copy.className).not.toContain("focus-visible:ring-(--c-solid)")
|
|
251
251
|
})
|
|
252
|
+
|
|
253
|
+
it("renders a title header that hosts the toolbar in-flow instead of floating it", () => {
|
|
254
|
+
render(<CodeBlock code={"a\nb"} title="app.tsx" testId="snippet" />)
|
|
255
|
+
expect(screen.getByText("app.tsx")).toBeTruthy()
|
|
256
|
+
const toolbar = screen.getByTestId("snippet-copy").parentElement
|
|
257
|
+
expect(toolbar?.className).not.toContain("absolute")
|
|
258
|
+
expect(toolbar?.parentElement?.textContent).toContain("app.tsx")
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
it("passes notation={false} through as a disabled parse, keeping markers verbatim", async () => {
|
|
262
|
+
const code = "x // [!code highlight]"
|
|
263
|
+
render(<CodeBlock code={code} notation={false} />)
|
|
264
|
+
await waitFor(() => expect(mockedHighlightCode).toHaveBeenCalled())
|
|
265
|
+
const opts = mockedHighlightCode.mock.calls[0]?.[1]
|
|
266
|
+
expect(opts?.notation?.perLine).toEqual([{ matches: [], stripCount: 0, blank: false }])
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
it("keeps the code itself left-to-right on an RTL page, before and after highlighting", async () => {
|
|
270
|
+
const { container } = render(
|
|
271
|
+
<div dir="rtl">
|
|
272
|
+
<CodeBlock code="const x = 1" />
|
|
273
|
+
</div>,
|
|
274
|
+
)
|
|
275
|
+
expect(container.querySelector("pre")?.getAttribute("dir")).toBe("ltr")
|
|
276
|
+
await waitFor(() => expect(container.querySelector(".shiki")).toBeTruthy())
|
|
277
|
+
expect(container.querySelector(".shiki")?.parentElement?.getAttribute("dir")).toBe("ltr")
|
|
278
|
+
})
|
|
252
279
|
})
|
|
@@ -74,6 +74,13 @@ export type CodeBlockProps = WithTestId & {
|
|
|
74
74
|
* `registerTheme` (exported from `@42/ui-react/code-block`) for
|
|
75
75
|
* registering a custom language/theme the bundled set doesn't ship. */
|
|
76
76
|
transformers?: ShikiTransformer[]
|
|
77
|
+
/** Parse `// [!code tag]` markers. `false` renders them verbatim instead —
|
|
78
|
+
* for a snippet that teaches the notation itself. @default true */
|
|
79
|
+
notation?: boolean
|
|
80
|
+
|
|
81
|
+
/** Header row above the code (e.g. a filename). When set, the toolbar
|
|
82
|
+
* moves into the header instead of floating over the code. */
|
|
83
|
+
title?: ReactNode
|
|
77
84
|
|
|
78
85
|
/** @default true */
|
|
79
86
|
withCopyButton?: boolean
|
|
@@ -168,13 +175,15 @@ function HighlightedPre({
|
|
|
168
175
|
// No horizontal padding here — `.shiki .line` (styles.css) carries its
|
|
169
176
|
// own `padding-inline` instead, so a decorated line's background hugs
|
|
170
177
|
// this container's edges rather than stopping short of it.
|
|
178
|
+
// `dir="ltr"`: source code reads left-to-right on an RTL page too — the
|
|
179
|
+
// chrome (title, toolbar) still follows the page direction.
|
|
171
180
|
// biome-ignore lint/security/noDangerouslySetInnerHtml: trusted, deterministic Shiki output, not user input
|
|
172
|
-
return <div className={className} dangerouslySetInnerHTML={{ __html: html }} />
|
|
181
|
+
return <div dir="ltr" className={className} dangerouslySetInnerHTML={{ __html: html }} />
|
|
173
182
|
}
|
|
174
183
|
return (
|
|
175
184
|
// The plain fallback has no `.line` spans of its own to carry padding,
|
|
176
185
|
// so it keeps the horizontal inset directly.
|
|
177
|
-
<pre className={cn(className, "px-4")}>
|
|
186
|
+
<pre dir="ltr" className={cn(className, "px-4")}>
|
|
178
187
|
<code>{code}</code>
|
|
179
188
|
</pre>
|
|
180
189
|
)
|
|
@@ -187,6 +196,7 @@ function CodeBlockComponent({
|
|
|
187
196
|
tags,
|
|
188
197
|
gutters,
|
|
189
198
|
transformers,
|
|
199
|
+
notation: notationEnabled = true,
|
|
190
200
|
collapsedLines,
|
|
191
201
|
className,
|
|
192
202
|
classNames,
|
|
@@ -201,7 +211,7 @@ function CodeBlockComponent({
|
|
|
201
211
|
// what keeps a `skip`-aware gutter counter's numbering continuous across
|
|
202
212
|
// the collapse split: each half independently derives its own starting
|
|
203
213
|
// count from this one shared parse (see `gutters.ts`'s `resolveGutterColumns`).
|
|
204
|
-
const notation = useMemo(() => parseNotation(code), [code])
|
|
214
|
+
const notation = useMemo(() => parseNotation(code, notationEnabled), [code, notationEnabled])
|
|
205
215
|
|
|
206
216
|
const preClassName = cn("overflow-x-auto py-3 text-sm leading-relaxed font-mono", classNames?.pre)
|
|
207
217
|
|
|
@@ -8,6 +8,14 @@ function parse(code: string, i = 0) {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
describe("parseNotation", () => {
|
|
11
|
+
it("treats every line as a non-match when disabled, keeping one entry per line", () => {
|
|
12
|
+
const parsed = parseNotation("a // [!code highlight]\n// [!code removed]", false)
|
|
13
|
+
expect(parsed.perLine).toEqual([
|
|
14
|
+
{ matches: [], stripCount: 0, blank: false },
|
|
15
|
+
{ matches: [], stripCount: 0, blank: false },
|
|
16
|
+
])
|
|
17
|
+
})
|
|
18
|
+
|
|
11
19
|
it("returns a no-op parse for a line with no marker", () => {
|
|
12
20
|
expect(parse("const x = 1")).toEqual({ matches: [], stripCount: 0, blank: false })
|
|
13
21
|
})
|
|
@@ -227,7 +227,10 @@ function parseLine(line: string): ParsedLine {
|
|
|
227
227
|
return NO_MATCH
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
-
/** Parses every notation marker in `code`, once, line by line.
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
/** Parses every notation marker in `code`, once, line by line. With
|
|
231
|
+
* `enabled: false` every line is a non-match — the markers stay in the
|
|
232
|
+
* rendered source verbatim (a snippet that *documents* the notation), while
|
|
233
|
+
* `perLine` keeps one entry per line so gutter counters still size right. */
|
|
234
|
+
export function parseNotation(code: string, enabled = true): ParsedNotation {
|
|
235
|
+
return { perLine: code.split("\n").map((line) => (enabled ? parseLine(line) : NO_MATCH)) }
|
|
233
236
|
}
|
|
@@ -18,6 +18,9 @@ export type CodeBlockStaticProps = WithTestId & {
|
|
|
18
18
|
tags?: Record<string, CodeBlockTagStyle>
|
|
19
19
|
gutters?: CodeBlockGutterColumn[]
|
|
20
20
|
transformers?: ShikiTransformer[]
|
|
21
|
+
/** @default true */
|
|
22
|
+
notation?: boolean
|
|
23
|
+
title?: ReactNode
|
|
21
24
|
|
|
22
25
|
/** @default true */
|
|
23
26
|
withCopyButton?: boolean
|
|
@@ -44,9 +47,11 @@ export type CodeBlockStaticProps = WithTestId & {
|
|
|
44
47
|
* loading-fallback branch: by the time this renders, the `await` in
|
|
45
48
|
* `CodeBlockStatic` below has already resolved, so there's never a
|
|
46
49
|
* not-yet-highlighted state to fall back to. */
|
|
50
|
+
// `dir="ltr"`: source code reads left-to-right on an RTL page too — the
|
|
51
|
+
// chrome (title, toolbar) still follows the page direction.
|
|
47
52
|
function StaticPre({ html, className }: { html: string; className?: string }) {
|
|
48
53
|
// biome-ignore lint/security/noDangerouslySetInnerHtml: trusted, deterministic Shiki output, not user input
|
|
49
|
-
return <div className={className} dangerouslySetInnerHTML={{ __html: html }} />
|
|
54
|
+
return <div dir="ltr" className={className} dangerouslySetInnerHTML={{ __html: html }} />
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
/**
|
|
@@ -86,6 +91,7 @@ export async function CodeBlockStatic({
|
|
|
86
91
|
tags,
|
|
87
92
|
gutters,
|
|
88
93
|
transformers,
|
|
94
|
+
notation: notationEnabled = true,
|
|
89
95
|
collapsedLines,
|
|
90
96
|
className,
|
|
91
97
|
classNames,
|
|
@@ -97,7 +103,7 @@ export async function CodeBlockStatic({
|
|
|
97
103
|
const tailCode = isCollapsible ? lines.slice(collapsedLines).join("\n") : ""
|
|
98
104
|
// Same "parse once over the full source, share across both halves" reason
|
|
99
105
|
// as CodeBlockComponent's own `notation` — see its comment.
|
|
100
|
-
const notation = parseNotation(code)
|
|
106
|
+
const notation = parseNotation(code, notationEnabled)
|
|
101
107
|
|
|
102
108
|
const preClassName = cn("overflow-x-auto py-3 text-sm leading-relaxed font-mono", classNames?.pre)
|
|
103
109
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ark, type HTMLArkProps } from "@ark-ui/react"
|
|
2
|
+
import type { ReactNode } from "react"
|
|
3
|
+
import { composeChildren } from "../../lib/as-child"
|
|
2
4
|
import { cn } from "../../lib/cn"
|
|
3
5
|
import { props } from "../../lib/props"
|
|
4
6
|
import type { WithTestId } from "../../lib/test-id"
|
|
@@ -42,8 +44,11 @@ export type CollapseClassNames = {
|
|
|
42
44
|
* Override the timing with a `duration-*` / `ease-*` class on `className`
|
|
43
45
|
* (tailwind-merge lets the later class win); style the sliding region — layout,
|
|
44
46
|
* padding — with `classNames.content`.
|
|
47
|
+
*
|
|
48
|
+
* `asChild` makes the consumer's element the grid root, with the clipped cell
|
|
49
|
+
* folded inside it (`Accordion.ItemContent` merges Ark's part this way).
|
|
45
50
|
*/
|
|
46
|
-
export type CollapseProps =
|
|
51
|
+
export type CollapseProps = HTMLArkProps<"div"> &
|
|
47
52
|
WithTestId & {
|
|
48
53
|
/** Whether the content is revealed. Closed content is `inert`. */
|
|
49
54
|
open: boolean
|
|
@@ -58,24 +63,37 @@ export const Collapse = ({
|
|
|
58
63
|
classNames,
|
|
59
64
|
children,
|
|
60
65
|
testId,
|
|
66
|
+
asChild,
|
|
61
67
|
...rest
|
|
62
|
-
}: CollapseProps) =>
|
|
63
|
-
|
|
64
|
-
className
|
|
68
|
+
}: CollapseProps) => {
|
|
69
|
+
const root = {
|
|
70
|
+
className: cn(
|
|
65
71
|
"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]",
|
|
66
72
|
"motion-reduce:transition-none",
|
|
67
73
|
open ? "grid-rows-[1fr]" : "grid-rows-[0fr]",
|
|
68
74
|
className,
|
|
69
75
|
classNames?.root,
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
data-state
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
),
|
|
77
|
+
...props({ "data-testid": testId }),
|
|
78
|
+
...rest,
|
|
79
|
+
"data-state": open ? "open" : "closed",
|
|
80
|
+
}
|
|
81
|
+
// `inert` sits on the clipped cell, not the root, so a consumer keeps the
|
|
82
|
+
// root's own `inert` (and the rest of its div props) to itself.
|
|
83
|
+
const cell = composeChildren(asChild, children, (own) => (
|
|
77
84
|
<div className={cn("min-h-0 min-w-0 overflow-clip", classNames?.content)} inert={!open}>
|
|
78
|
-
{
|
|
85
|
+
{own}
|
|
79
86
|
</div>
|
|
80
|
-
|
|
81
|
-
|
|
87
|
+
))
|
|
88
|
+
// A plain `<div>` unless `asChild` is set. Collapse sits under every
|
|
89
|
+
// Accordion panel, Notification row and nested NavLink, and `ark.div`'s
|
|
90
|
+
// memo + forwardRef + ref-merging layer measured ~12% slower across 600 of
|
|
91
|
+
// them; only `asChild` needs Ark's factory.
|
|
92
|
+
return asChild ? (
|
|
93
|
+
<ark.div asChild {...root}>
|
|
94
|
+
{cell}
|
|
95
|
+
</ark.div>
|
|
96
|
+
) : (
|
|
97
|
+
<div {...root}>{cell}</div>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react"
|
|
2
|
+
import { describe, expect, it } from "vitest"
|
|
3
|
+
import { Combobox, createListCollection } from "."
|
|
4
|
+
|
|
5
|
+
const collection = createListCollection({ items: ["Paris", "Lyon"] })
|
|
6
|
+
|
|
7
|
+
describe("Combobox triggers under asChild", () => {
|
|
8
|
+
// The default icon used to be computed from `children`, which under
|
|
9
|
+
// `asChild` is the consumer's element, so it never showed up.
|
|
10
|
+
it.each([
|
|
11
|
+
["Trigger", Combobox.Trigger],
|
|
12
|
+
["ClearTrigger", Combobox.ClearTrigger],
|
|
13
|
+
] as const)("%s puts its default icon inside an empty child", (_, Part) => {
|
|
14
|
+
render(
|
|
15
|
+
<Combobox.Root collection={collection}>
|
|
16
|
+
<Part asChild>
|
|
17
|
+
<button type="button" data-testid="custom" />
|
|
18
|
+
</Part>
|
|
19
|
+
</Combobox.Root>,
|
|
20
|
+
)
|
|
21
|
+
expect(screen.getByTestId("custom").querySelector("svg")).toBeTruthy()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it("keeps the child's own content instead of the default icon", () => {
|
|
25
|
+
render(
|
|
26
|
+
<Combobox.Root collection={collection}>
|
|
27
|
+
<Combobox.Trigger asChild>
|
|
28
|
+
<button type="button" data-testid="custom">
|
|
29
|
+
Open
|
|
30
|
+
</button>
|
|
31
|
+
</Combobox.Trigger>
|
|
32
|
+
</Combobox.Root>,
|
|
33
|
+
)
|
|
34
|
+
const trigger = screen.getByTestId("custom")
|
|
35
|
+
expect(trigger.textContent).toBe("Open")
|
|
36
|
+
expect(trigger.querySelector("svg")).toBeNull()
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type ReactNode,
|
|
10
10
|
useContext,
|
|
11
11
|
} from "react"
|
|
12
|
+
import { composeChildren, type NoAsChild } from "../../lib/as-child"
|
|
12
13
|
import { cn } from "../../lib/cn"
|
|
13
14
|
import { useOverlayContainer } from "../../lib/overlay-container"
|
|
14
15
|
import { useNestedLayer } from "../../lib/overlay-layer"
|
|
@@ -115,7 +116,7 @@ const Root = <T extends Ark.CollectionItem = Ark.CollectionItem>({
|
|
|
115
116
|
</ComboboxStyleContext.Provider>
|
|
116
117
|
)
|
|
117
118
|
|
|
118
|
-
export type ComboboxControlProps = ComponentPropsWithoutRef<typeof Ark.Control
|
|
119
|
+
export type ComboboxControlProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.Control>> &
|
|
119
120
|
WithTestId & {
|
|
120
121
|
/** Inline-start adornment (icon, label). */
|
|
121
122
|
startSlot?: ReactNode
|
|
@@ -129,6 +130,7 @@ const Control = ({
|
|
|
129
130
|
className,
|
|
130
131
|
children,
|
|
131
132
|
testId,
|
|
133
|
+
asChild: _asChild,
|
|
132
134
|
...rest
|
|
133
135
|
}: ComboboxControlProps) => {
|
|
134
136
|
const { size, variant } = useContext(ComboboxStyleContext)
|
|
@@ -167,6 +169,7 @@ const Input = ({ className, testId, ...rest }: ComponentProps<typeof Ark.Input>
|
|
|
167
169
|
const Trigger = ({
|
|
168
170
|
className,
|
|
169
171
|
children,
|
|
172
|
+
asChild,
|
|
170
173
|
...rest
|
|
171
174
|
}: ComponentPropsWithoutRef<typeof Ark.Trigger>) => (
|
|
172
175
|
<Ark.Trigger
|
|
@@ -176,22 +179,29 @@ const Trigger = ({
|
|
|
176
179
|
"data-[state=open]:rotate-180 disabled:cursor-not-allowed",
|
|
177
180
|
className,
|
|
178
181
|
)}
|
|
182
|
+
asChild={asChild}
|
|
179
183
|
{...rest}
|
|
180
184
|
>
|
|
181
|
-
{children ?? <ChevronIcon />}
|
|
185
|
+
{composeChildren(asChild, children, (own) => own ?? <ChevronIcon />)}
|
|
182
186
|
</Ark.Trigger>
|
|
183
187
|
)
|
|
184
188
|
|
|
185
189
|
const ClearTrigger = ({
|
|
186
190
|
className,
|
|
187
191
|
children,
|
|
192
|
+
asChild,
|
|
188
193
|
...rest
|
|
189
194
|
}: ComponentPropsWithoutRef<typeof Ark.ClearTrigger>) => (
|
|
190
195
|
// zag marks the combobox clear control `tabIndex={-1}`; surface it in the tab
|
|
191
196
|
// order so keyboard users can reach it (matching Select's clear and the tree
|
|
192
197
|
// clears). A caller can still override via `tabIndex` in `rest`.
|
|
193
|
-
<Ark.ClearTrigger
|
|
194
|
-
{
|
|
198
|
+
<Ark.ClearTrigger
|
|
199
|
+
tabIndex={0}
|
|
200
|
+
className={cn(popoverClearTrigger, className)}
|
|
201
|
+
asChild={asChild}
|
|
202
|
+
{...rest}
|
|
203
|
+
>
|
|
204
|
+
{composeChildren(asChild, children, (own) => own ?? <CloseIcon />)}
|
|
195
205
|
</Ark.ClearTrigger>
|
|
196
206
|
)
|
|
197
207
|
|
|
@@ -201,8 +211,9 @@ const Content = ({
|
|
|
201
211
|
withPaddingTop = true,
|
|
202
212
|
withinPortal = true,
|
|
203
213
|
container,
|
|
214
|
+
asChild: _asChild,
|
|
204
215
|
...rest
|
|
205
|
-
}: ComponentPropsWithoutRef<typeof Ark.Content
|
|
216
|
+
}: NoAsChild<ComponentPropsWithoutRef<typeof Ark.Content>> & {
|
|
206
217
|
withPaddingTop?: boolean
|
|
207
218
|
/** Render the panel in a Portal so it escapes clipping ancestors.
|
|
208
219
|
* Default `true`. */
|
|
@@ -237,8 +248,9 @@ const Panel = ({
|
|
|
237
248
|
className,
|
|
238
249
|
children,
|
|
239
250
|
withPaddingTop = true,
|
|
251
|
+
asChild: _asChild,
|
|
240
252
|
...rest
|
|
241
|
-
}: ComponentPropsWithoutRef<typeof Ark.Content
|
|
253
|
+
}: NoAsChild<ComponentPropsWithoutRef<typeof Ark.Content>> & { withPaddingTop?: boolean }) => {
|
|
242
254
|
return (
|
|
243
255
|
<Ark.Content {...rest}>
|
|
244
256
|
<Ark.List className={cn(popoverList({ withPaddingTop }), className)}>{children}</Ark.List>
|
|
@@ -246,7 +258,9 @@ const Panel = ({
|
|
|
246
258
|
)
|
|
247
259
|
}
|
|
248
260
|
|
|
249
|
-
export type ComboboxItemProps =
|
|
261
|
+
export type ComboboxItemProps = NoAsChild<
|
|
262
|
+
Omit<ComponentPropsWithoutRef<typeof Ark.Item>, "children">
|
|
263
|
+
> &
|
|
250
264
|
WithTestId & {
|
|
251
265
|
/**
|
|
252
266
|
* Option content. A plain node renders as the label (the kit adds the check
|
|
@@ -256,7 +270,7 @@ export type ComboboxItemProps = Omit<ComponentPropsWithoutRef<typeof Ark.Item>,
|
|
|
256
270
|
children?: ReactNode | ((state: ItemRenderState) => ReactNode)
|
|
257
271
|
}
|
|
258
272
|
|
|
259
|
-
const Item = ({ className, children, testId, ...rest }: ComboboxItemProps) => {
|
|
273
|
+
const Item = ({ className, children, testId, asChild: _asChild, ...rest }: ComboboxItemProps) => {
|
|
260
274
|
const { size } = useContext(ComboboxStyleContext)
|
|
261
275
|
return (
|
|
262
276
|
<Ark.Item
|
|
@@ -280,12 +294,12 @@ const Item = ({ className, children, testId, ...rest }: ComboboxItemProps) => {
|
|
|
280
294
|
)
|
|
281
295
|
}
|
|
282
296
|
|
|
283
|
-
export type ComboboxGroupProps = ComponentPropsWithoutRef<typeof Ark.ItemGroup
|
|
297
|
+
export type ComboboxGroupProps = NoAsChild<ComponentPropsWithoutRef<typeof Ark.ItemGroup>> & {
|
|
284
298
|
/** Group heading rendered above the options. */
|
|
285
299
|
label?: ReactNode
|
|
286
300
|
}
|
|
287
301
|
|
|
288
|
-
const Group = ({ label, className, children, ...rest }: ComboboxGroupProps) => (
|
|
302
|
+
const Group = ({ label, className, children, asChild: _asChild, ...rest }: ComboboxGroupProps) => (
|
|
289
303
|
<Ark.ItemGroup className={className} {...rest}>
|
|
290
304
|
{label != null && (
|
|
291
305
|
<Ark.ItemGroupLabel className={popoverGroupLabel}>{label}</Ark.ItemGroupLabel>
|
|
@@ -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 { ReactNode } from "react"
|
|
4
4
|
import type { Align } from "../../lib/align"
|
|
5
|
+
import type { NoAsChild } from "../../lib/as-child"
|
|
5
6
|
import { cn } from "../../lib/cn"
|
|
6
7
|
import type { Color } from "../../lib/colors"
|
|
7
8
|
import { props } from "../../lib/props"
|
|
@@ -62,7 +63,7 @@ export type DividerVariant = NonNullable<VariantProps<typeof dividerVariants>["v
|
|
|
62
63
|
export type DividerSize = Size
|
|
63
64
|
export type DividerLabelPosition = Align
|
|
64
65
|
|
|
65
|
-
export type DividerProps = Omit<HTMLArkProps<"div">, "children"
|
|
66
|
+
export type DividerProps = NoAsChild<Omit<HTMLArkProps<"div">, "children">> &
|
|
66
67
|
VariantProps<typeof dividerVariants> &
|
|
67
68
|
WithTestId & {
|
|
68
69
|
/**
|
|
@@ -115,6 +116,7 @@ export const Divider = ({
|
|
|
115
116
|
label,
|
|
116
117
|
labelPosition,
|
|
117
118
|
testId,
|
|
119
|
+
asChild: _asChild,
|
|
118
120
|
...rest
|
|
119
121
|
}: DividerProps) => {
|
|
120
122
|
const isVertical = orientation === "vertical"
|
|
@@ -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
|