@justanarthur/modo-ui 2.0.0 → 2.2.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/blocks/desktop-shell/index.tsx +2 -1
- package/components/data-display/sparkline/examples.mdx +79 -0
- package/components/data-display/sparkline/index.tsx +158 -0
- package/components/data-display/sparkline/live-demo.tsx +36 -0
- package/components/feedback/meter/examples.mdx +25 -0
- package/components/feedback/meter/index.tsx +23 -7
- package/components/feedback/meter/timer-demo.tsx +37 -0
- package/components/inputs/checkbox/index.tsx +5 -0
- package/components/inputs/combobox/index.tsx +9 -4
- package/components/inputs/radio/index.tsx +5 -0
- package/components/inputs/select/index.tsx +23 -3
- package/components/inputs/slider/comfortable.tsx +10 -4
- package/components/inputs/slider/compact.tsx +153 -71
- package/components/inputs/slider/examples.mdx +24 -0
- package/components/inputs/slider/geometry.ts +18 -6
- package/components/inputs/slider/index.tsx +30 -8
- package/components/inputs/slider/value-display.tsx +16 -9
- package/components/inputs/switch/index.tsx +7 -2
- package/components/inputs/textarea/examples.mdx +19 -0
- package/components/inputs/textarea/index.tsx +42 -5
- package/components/navigation/sidebar/sidebar-group.tsx +2 -1
- package/components/navigation/sidebar/sidebar-menu-sub.tsx +2 -1
- package/components/navigation/sidebar/sidebar-shell.tsx +2 -1
- package/components/navigation/tree/index.tsx +2 -1
- package/components/overlays/dropdown/index.tsx +50 -8
- package/components/overlays/dropdown/submenu.tsx +41 -10
- package/components/overlays/tooltip/examples.mdx +13 -0
- package/components/overlays/tooltip/index.tsx +58 -16
- package/dist/base.css +4 -0
- package/dist/blocks/desktop-shell/index.js +28 -27
- package/dist/blocks/sidebar-app/index.js +38 -37
- package/dist/components/actions/button/index.js +4 -4
- package/dist/components/actions/copy/index.js +12 -12
- package/dist/components/containers/accordion/index.d.ts +1 -1
- package/dist/components/containers/accordion/index.js +16 -16
- package/dist/components/containers/card/index.js +14 -14
- package/dist/components/data-display/avatar/index.js +3 -3
- package/dist/components/data-display/badge/index.js +2 -2
- package/dist/components/data-display/diff/index.js +4 -4
- package/dist/components/data-display/list/index.js +3 -3
- package/dist/components/data-display/log-view/index.js +8 -8
- package/dist/components/data-display/markdown/index.js +15 -15
- package/dist/components/data-display/sparkline/index.d.ts +44 -0
- package/dist/components/data-display/sparkline/index.js +11 -0
- package/dist/components/data-display/table/index.js +9 -9
- package/dist/components/feedback/empty-state/index.js +3 -3
- package/dist/components/feedback/meter/index.d.ts +9 -1
- package/dist/components/feedback/meter/index.js +2 -2
- package/dist/components/feedback/progress/index.js +2 -2
- package/dist/components/inputs/checkbox/index.d.ts +2 -0
- package/dist/components/inputs/checkbox/index.js +13 -13
- package/dist/components/inputs/choice-list/index.js +10 -10
- package/dist/components/inputs/color-picker/index.js +22 -22
- package/dist/components/inputs/combobox/index.d.ts +1 -1
- package/dist/components/inputs/combobox/index.js +21 -21
- package/dist/components/inputs/date-time/calendar/index.js +9 -9
- package/dist/components/inputs/date-time/date-picker/index.js +28 -28
- package/dist/components/inputs/date-time/date-range-picker/index.js +28 -28
- package/dist/components/inputs/date-time/duration-picker/index.js +27 -27
- package/dist/components/inputs/date-time/month-picker/index.js +26 -26
- package/dist/components/inputs/date-time/time-picker/index.js +27 -27
- package/dist/components/inputs/editable-text/index.js +2 -2
- package/dist/components/inputs/field/index.js +5 -5
- package/dist/components/inputs/file-dropzone/index.js +8 -8
- package/dist/components/inputs/input/index.js +6 -6
- package/dist/components/inputs/key-value/index.js +12 -12
- package/dist/components/inputs/number-input/index.js +7 -7
- package/dist/components/inputs/radio/index.d.ts +2 -0
- package/dist/components/inputs/radio/index.js +12 -12
- package/dist/components/inputs/search/index.js +23 -23
- package/dist/components/inputs/select/index.d.ts +22 -4
- package/dist/components/inputs/select/index.js +22 -22
- package/dist/components/inputs/slider/index.d.ts +12 -3
- package/dist/components/inputs/slider/index.js +4 -4
- package/dist/components/inputs/switch/index.d.ts +2 -0
- package/dist/components/inputs/switch/index.js +9 -9
- package/dist/components/inputs/textarea/index.d.ts +8 -1
- package/dist/components/inputs/textarea/index.js +4 -4
- package/dist/components/navigation/breadcrumb/index.js +25 -25
- package/dist/components/navigation/navigation-menu/index.js +17 -17
- package/dist/components/navigation/pagination/index.js +16 -16
- package/dist/components/navigation/sidebar/index.js +26 -25
- package/dist/components/navigation/tabs/index.js +13 -13
- package/dist/components/navigation/tree/index.js +10 -9
- package/dist/components/overlays/alert-dialog/index.d.ts +3 -3
- package/dist/components/overlays/alert-dialog/index.js +15 -15
- package/dist/components/overlays/command/index.d.ts +1 -1
- package/dist/components/overlays/command/index.js +21 -21
- package/dist/components/overlays/context-menu/index.d.ts +20 -1
- package/dist/components/overlays/context-menu/index.js +25 -25
- package/dist/components/overlays/dialog/index.d.ts +3 -3
- package/dist/components/overlays/dialog/index.js +14 -14
- package/dist/components/overlays/dropdown/index.d.ts +30 -8
- package/dist/components/overlays/dropdown/index.js +24 -24
- package/dist/components/overlays/lightbox/index.js +12 -12
- package/dist/components/overlays/popover/index.d.ts +6 -6
- package/dist/components/overlays/popover/index.js +11 -11
- package/dist/components/overlays/preview-card/index.js +10 -10
- package/dist/components/overlays/sheet/index.d.ts +3 -3
- package/dist/components/overlays/sheet/index.js +15 -15
- package/dist/components/overlays/toast/index.d.ts +1 -1
- package/dist/components/overlays/toast/index.js +11 -11
- package/dist/components/overlays/tooltip/index.d.ts +35 -10
- package/dist/components/overlays/tooltip/index.js +8 -8
- package/dist/docs/index.js +18 -17
- package/dist/index.d.ts +330 -228
- package/dist/index.js +82 -77
- package/dist/lib/fluid-hover-highlight.js +4 -4
- package/dist/lib/focus-ring.js +2 -2
- package/dist/lib/goo-indicator.js +3 -3
- package/dist/lib/inert.d.ts +7 -0
- package/dist/lib/inert.js +6 -0
- package/dist/lib/morph-layers.js +4 -4
- package/dist/lib/morph-part.js +2 -2
- package/dist/lib/overlay.d.ts +20 -13
- package/dist/lib/overlay.js +5 -4
- package/dist/lib/popup-rows.js +2 -2
- package/dist/lib/popup-surface.js +7 -7
- package/dist/lib/scroll-column.js +6 -6
- package/dist/lib/slot.d.ts +5 -2
- package/dist/lib/slot.js +1 -1
- package/dist/lib/use-merge-split.js +4 -4
- package/dist/lib/use-morph.js +2 -2
- package/dist/preset.d.ts +1 -0
- package/dist/preset.js +1 -0
- package/dist/primitives/content/code/index.js +3 -3
- package/dist/primitives/layout/resizable/index.js +2 -2
- package/dist/primitives/layout/sortable/index.js +5 -5
- package/dist/primitives/systems/craft/index.js +3 -3
- package/dist/primitives/systems/fluid-hover/index.js +6 -6
- package/dist/primitives/systems/morph/index.js +14 -14
- package/dist/primitives/systems/motion/index.js +7 -7
- package/dist/primitives/systems/sizes/index.js +2 -2
- package/dist/shared/{components-280grw6q.js → components-09n5hgmx.js} +2 -2
- package/dist/shared/{components-1f3a7gmg.js → components-151vndgm.js} +3 -3
- package/dist/shared/{components-14wzcym0.js → components-16wx5av1.js} +6 -6
- package/dist/shared/{components-yf2gtq68.js → components-19e2wpxc.js} +9 -6
- package/dist/shared/{components-rzy6h7s4.js → components-1nqp7wqr.js} +1 -1
- package/dist/shared/components-2myjk2zf.js +8 -0
- package/dist/shared/{components-9rebr89j.js → components-2q0m4mxf.js} +2 -2
- package/dist/shared/{components-1asw2ph0.js → components-2zr49v82.js} +3 -3
- package/dist/shared/{components-wq9hrera.js → components-313rmbxy.js} +2 -2
- package/dist/shared/{components-0h2mng6m.js → components-31pkxwfz.js} +1 -1
- package/dist/shared/{components-w2at9ntm.js → components-3cvwrzc1.js} +3 -3
- package/dist/shared/{components-n0gbyp5a.js → components-4xd21p2p.js} +6 -6
- package/dist/shared/{components-t0c1rw40.js → components-7v6869ga.js} +1 -1
- package/dist/shared/{components-kwxye0an.js → components-7wjkag2j.js} +4 -2
- package/dist/shared/{components-fqsgd07c.js → components-85dz3xx3.js} +4 -4
- package/dist/shared/{components-3rvrdsa9.js → components-8qkd3659.js} +1 -1
- package/dist/shared/{components-me742146.js → components-8qwbwtv9.js} +5 -5
- package/dist/shared/{components-nxqrw789.js → components-90sfqz5t.js} +1 -1
- package/dist/shared/{components-b9bj65j3.js → components-90y8qwxv.js} +9 -9
- package/dist/shared/{components-g35n8tzm.js → components-95kp19zn.js} +1 -1
- package/dist/shared/{components-nhmgr5xc.js → components-9e5fpy3v.js} +14 -11
- package/dist/shared/{components-a1ms36qq.js → components-9hysh6d3.js} +1 -1
- package/dist/shared/{components-hcftn5r8.js → components-9s9vb2w0.js} +7 -4
- package/dist/shared/{components-vfreweq3.js → components-a3edrqpb.js} +3 -3
- package/dist/shared/{components-ee09xmkh.js → components-afj2ajea.js} +8 -5
- package/dist/shared/{components-ev0ytbqb.js → components-ajgwbabq.js} +4 -4
- package/dist/shared/{components-62510420.js → components-dr5c27yd.js} +6 -6
- package/dist/shared/{components-s90v3jpr.js → components-fqdh9ysk.js} +68 -19
- package/dist/shared/{components-2m2hg11x.js → components-gfw4zk8b.js} +8 -8
- package/dist/shared/{components-z0kz9rxj.js → components-gvwxswpr.js} +1 -1
- package/dist/shared/{components-p32aqk3q.js → components-h9se5cz5.js} +110 -73
- package/dist/shared/{components-464zs8v6.js → components-hbqyf35a.js} +41 -34
- package/dist/shared/{components-77gxngmc.js → components-jd21f3mb.js} +8 -8
- package/dist/shared/{components-xnkc892z.js → components-mamtvenk.js} +2 -2
- package/dist/shared/{components-1hga6pkn.js → components-mcnyaaep.js} +3 -3
- package/dist/shared/{components-h0x2pj2y.js → components-mpx3yq5c.js} +24 -10
- package/dist/shared/{components-j79a6jqa.js → components-nc8wggew.js} +3 -3
- package/dist/shared/{components-r5q9gdh4.js → components-nd3f803g.js} +7 -7
- package/dist/shared/{components-9ca0c92a.js → components-nehs80xd.js} +1 -1
- package/dist/shared/components-nw2k1pg9.js +98 -0
- package/dist/shared/{components-4t2cjav8.js → components-pgs3p035.js} +1 -1
- package/dist/shared/{components-91mmbrw3.js → components-ppc2dmxs.js} +2 -2
- package/dist/shared/{components-b2kjsn1s.js → components-qc1fae2s.js} +6 -6
- package/dist/shared/{components-fmyvz4r2.js → components-qd27dvgj.js} +6 -6
- package/dist/shared/{components-9z7bq8gn.js → components-qe8yp3vf.js} +3 -3
- package/dist/shared/{components-wx1dcp2n.js → components-qhk2m7fj.js} +2 -2
- package/dist/shared/{components-a1mwqxsv.js → components-qkt4h7x4.js} +8 -8
- package/dist/shared/{components-6rtawx8y.js → components-qs0cwe8p.js} +10 -10
- package/dist/shared/{components-y8m64zdw.js → components-r6ejdtpr.js} +3 -3
- package/dist/shared/{components-1bnf96sr.js → components-rj4nnqkz.js} +39 -11
- package/dist/shared/{components-gd8gmr6w.js → components-rmhdr4g1.js} +1 -1
- package/dist/shared/{components-e7zxwja1.js → components-rts2mggt.js} +1 -1
- package/dist/shared/{components-ta4e10mx.js → components-s25rehbv.js} +1 -1
- package/dist/shared/{components-chda6b23.js → components-sxstx1x7.js} +33 -4
- package/dist/shared/{components-b7p1pjcm.js → components-t4eb37vd.js} +2 -2
- package/dist/shared/{components-7xc2dne4.js → components-v3c3madd.js} +2 -2
- package/dist/shared/{components-22h8dvt1.js → components-v81eejq6.js} +3 -3
- package/dist/shared/{components-w1ysefg1.js → components-veaxns17.js} +2 -2
- package/dist/shared/{components-czvraaw9.js → components-vkrp4nb9.js} +4 -4
- package/dist/shared/{components-gsstwhtv.js → components-vv420geb.js} +6 -3
- package/dist/shared/{components-5xs8pkkj.js → components-w5p7mfb4.js} +1 -1
- package/dist/shared/{components-rgng034x.js → components-xvf8jcza.js} +25 -4
- package/dist/shared/{components-q7zk70tx.js → components-y07de1qv.js} +1 -1
- package/dist/shared/{components-0cpte6s1.js → components-yn8bw8tv.js} +11 -10
- package/dist/shared/{components-xa9fvd5b.js → components-z9gc2weg.js} +3 -3
- package/dist/shared/{components-twyj2y8c.js → components-zk1tj5za.js} +3 -3
- package/dist/shared/{components-hz6armxa.js → components-zktkxnzq.js} +7 -4
- package/dist/styles.css +10 -1
- package/dist/tailwind.css +1 -0
- package/dist/tokens.css +4 -0
- package/index.ts +1 -0
- package/lib/inert.ts +15 -0
- package/lib/overlay.tsx +49 -5
- package/lib/slot.tsx +9 -3
- package/package.json +7 -2
- package/tokens/colors.css +4 -0
- /package/dist/shared/{components-jw45ck66.js → components-02683eqd.js} +0 -0
- /package/dist/shared/{components-q0hs5rqn.js → components-6c52v58g.js} +0 -0
- /package/dist/shared/{components-y4gsk1jt.js → components-fa61vwag.js} +0 -0
- /package/dist/shared/{components-nz14rwtd.js → components-ffng9rpa.js} +0 -0
- /package/dist/shared/{components-7mj5wsv3.js → components-k9qbcmaa.js} +0 -0
- /package/dist/shared/{components-8pnvkrbw.js → components-mp7en54n.js} +0 -0
- /package/dist/shared/{components-h8v9nh5r.js → components-pbx77hzb.js} +0 -0
- /package/dist/shared/{components-c515d6xr.js → components-v1m0xjbw.js} +0 -0
- /package/dist/shared/{components-pa43g2r2.js → components-wddr0r6a.js} +0 -0
- /package/dist/shared/{components-ymq8tbq9.js → components-wqac4434.js} +0 -0
- /package/dist/shared/{components-m3vxpz2z.js → components-yy0a9b02.js} +0 -0
- /package/dist/shared/{components-92mvpt9h.js → components-zwgxvktt.js} +0 -0
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
'use client'
|
|
10
10
|
|
|
11
|
-
import { forwardRef } from 'react'
|
|
11
|
+
import { forwardRef, useRef } from 'react'
|
|
12
12
|
import { type SizeVariant, useSizeVariant } from '../../../lib/size-context'
|
|
13
13
|
import { useControllableState } from '../../../lib/use-controllable-state'
|
|
14
14
|
import { ComfortableSlider } from './comfortable'
|
|
@@ -30,7 +30,7 @@ const COMPACT_ONLY = [
|
|
|
30
30
|
'thumbBorderColor',
|
|
31
31
|
] as const satisfies readonly (keyof SliderEngineProps)[]
|
|
32
32
|
|
|
33
|
-
interface SliderProps extends Omit<SliderEngineProps, 'value' | 'onValueChange'> {
|
|
33
|
+
interface SliderProps extends Omit<SliderEngineProps, 'value' | 'onValueChange' | 'onCommit'> {
|
|
34
34
|
/** Step on the size ladder (see Sizes). Default renders the pip/scrubber design; compact renders the dense design. Defaults to the surrounding SizeProvider, else `"default"`. */
|
|
35
35
|
size?: SizeVariant
|
|
36
36
|
/** Default-step layout. "pips" shows discrete dot indicators; "scrubber" drags anywhere in the row for a continuous value. Ignored when the compact design renders. Defaults to `"pips"`. */
|
|
@@ -41,6 +41,10 @@ interface SliderProps extends Omit<SliderEngineProps, 'value' | 'onValueChange'>
|
|
|
41
41
|
defaultValue?: SliderValue
|
|
42
42
|
/** Called when the value changes via drag, click, or keyboard. */
|
|
43
43
|
onValueChange?: (value: SliderValue) => void
|
|
44
|
+
/** Called once when an interaction ends, with the value it settled on: the pointer lifting after a drag or click, a keyboard step, or a committed edit of the value label. `onValueChange` reports every value on the way, so save from here and preview from there. */
|
|
45
|
+
onValueCommit?: (value: SliderValue) => void
|
|
46
|
+
/** Layout axis. `"vertical"` stands the track upright (min at the bottom; ArrowUp / ArrowRight raise it, ArrowDown / ArrowLeft lower it) and always renders the compact design, which is the only one with a vertical layout. Give it a height with `className` (`h-48`); `valuePosition` then defaults to `"top"`. Defaults to `"horizontal"`. */
|
|
47
|
+
orientation?: 'horizontal' | 'vertical'
|
|
44
48
|
/** Minimum value. Defaults to `0`. */
|
|
45
49
|
min?: number
|
|
46
50
|
/** Maximum value. Defaults to `100`. */
|
|
@@ -53,7 +57,7 @@ interface SliderProps extends Omit<SliderEngineProps, 'value' | 'onValueChange'>
|
|
|
53
57
|
showSteps?: boolean
|
|
54
58
|
/** Whether to display the current value label. Defaults to `true`. */
|
|
55
59
|
showValue?: boolean
|
|
56
|
-
/** Position of the value label. "tooltip" shows above the thumb during interaction. Defaults to `"left"
|
|
60
|
+
/** Position of the value label. "tooltip" shows above the thumb during interaction (beside it when vertical). Defaults to `"left"`, or `"top"` when vertical. */
|
|
57
61
|
valuePosition?: ValuePosition
|
|
58
62
|
/** Custom formatter for the value label. Defaults to `String`. */
|
|
59
63
|
formatValue?: (v: number) => string
|
|
@@ -79,7 +83,9 @@ interface SliderProps extends Omit<SliderEngineProps, 'value' | 'onValueChange'>
|
|
|
79
83
|
* value label is click-to-edit.
|
|
80
84
|
*
|
|
81
85
|
* Works controlled (`value` + `onValueChange`) or uncontrolled
|
|
82
|
-
* (`defaultValue`, with `onValueChange` reporting each change)
|
|
86
|
+
* (`defaultValue`, with `onValueChange` reporting each change);
|
|
87
|
+
* `onValueCommit` reports the value once an interaction ends.
|
|
88
|
+
* `orientation="vertical"` stands the dense design upright. Track
|
|
83
89
|
* styling props come from the compact engine: `trackClassName`,
|
|
84
90
|
* `trackStyle`, `fillClassName`, `fillStyle`, `hideFill`, `thumbColor` and
|
|
85
91
|
* `thumbBorderColor` — each one also forces the dense design.
|
|
@@ -89,7 +95,7 @@ interface SliderProps extends Omit<SliderEngineProps, 'value' | 'onValueChange'>
|
|
|
89
95
|
* @license MIT © 2026 Micka Touillaud
|
|
90
96
|
*/
|
|
91
97
|
const Slider = forwardRef<HTMLDivElement, SliderProps>(
|
|
92
|
-
({ size, variant = 'pips', value: valueProp, defaultValue, onValueChange, ...rest }, ref) => {
|
|
98
|
+
({ size, variant = 'pips', value: valueProp, defaultValue, onValueChange, onValueCommit, ...rest }, ref) => {
|
|
93
99
|
const [value, setValue] = useControllableState<SliderValue>(
|
|
94
100
|
valueProp,
|
|
95
101
|
defaultValue ?? (rest.steps && rest.steps.length > 0 ? Math.min(...rest.steps) : (rest.min ?? 0)),
|
|
@@ -97,8 +103,22 @@ const Slider = forwardRef<HTMLDivElement, SliderProps>(
|
|
|
97
103
|
)
|
|
98
104
|
const resolved = useSizeVariant(size)
|
|
99
105
|
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
// A pointer can lift before the render that carries its last value, so the commit reads what was last set.
|
|
107
|
+
const latest = useRef(value)
|
|
108
|
+
latest.current = value
|
|
109
|
+
const change = (next: SliderValue) => {
|
|
110
|
+
latest.current = next
|
|
111
|
+
setValue(next)
|
|
112
|
+
}
|
|
113
|
+
const onCommit = onValueCommit && (() => onValueCommit(latest.current))
|
|
114
|
+
|
|
115
|
+
if (
|
|
116
|
+
resolved === 'compact' ||
|
|
117
|
+
Array.isArray(value) ||
|
|
118
|
+
rest.orientation === 'vertical' ||
|
|
119
|
+
COMPACT_ONLY.some(key => rest[key] !== undefined)
|
|
120
|
+
) {
|
|
121
|
+
return <CompactSlider ref={ref} {...rest} value={value} onValueChange={change} onCommit={onCommit} />
|
|
102
122
|
}
|
|
103
123
|
|
|
104
124
|
const {
|
|
@@ -113,6 +133,7 @@ const Slider = forwardRef<HTMLDivElement, SliderProps>(
|
|
|
113
133
|
hideFill,
|
|
114
134
|
thumbColor,
|
|
115
135
|
thumbBorderColor,
|
|
136
|
+
orientation,
|
|
116
137
|
...comfortable
|
|
117
138
|
} = rest
|
|
118
139
|
|
|
@@ -121,7 +142,8 @@ const Slider = forwardRef<HTMLDivElement, SliderProps>(
|
|
|
121
142
|
ref={ref}
|
|
122
143
|
{...comfortable}
|
|
123
144
|
value={value as number}
|
|
124
|
-
onValueChange={
|
|
145
|
+
onValueChange={change}
|
|
146
|
+
onCommit={onCommit}
|
|
125
147
|
variant={variant}
|
|
126
148
|
/>
|
|
127
149
|
)
|
|
@@ -162,20 +162,27 @@ interface TooltipValueProps {
|
|
|
162
162
|
value: number
|
|
163
163
|
formatValue: (v: number) => string
|
|
164
164
|
motionX: MotionValue<number>
|
|
165
|
+
vertical?: boolean
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
export function TooltipValue({ value, formatValue, motionX }: TooltipValueProps) {
|
|
168
|
+
export function TooltipValue({ value, formatValue, motionX, vertical = false }: TooltipValueProps) {
|
|
168
169
|
const tooltipX = useTransform(motionX, x => x + THUMB_SIZE / 2)
|
|
170
|
+
const tooltipY = useTransform(motionX, x => -x)
|
|
169
171
|
return (
|
|
170
172
|
<motion.div
|
|
171
|
-
className=
|
|
172
|
-
style={
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
className={cn('absolute pointer-events-none z-20', vertical ? 'translate-y-1/2' : '-translate-x-1/2')}
|
|
174
|
+
style={
|
|
175
|
+
vertical
|
|
176
|
+
? { y: tooltipY, bottom: THUMB_SIZE / 2, left: `calc(50% + ${THUMB_SIZE}px)` }
|
|
177
|
+
: { x: tooltipX, top: -16 }
|
|
178
|
+
}
|
|
179
|
+
initial={vertical ? { opacity: 0, x: -4 } : { opacity: 0, y: 4 }}
|
|
180
|
+
animate={vertical ? { opacity: 1, x: 0 } : { opacity: 1, y: 0 }}
|
|
181
|
+
exit={
|
|
182
|
+
vertical
|
|
183
|
+
? { opacity: 0, x: -4, transition: spring.fast.exit }
|
|
184
|
+
: { opacity: 0, y: 4, transition: spring.fast.exit }
|
|
185
|
+
}
|
|
179
186
|
transition={spring.fast}
|
|
180
187
|
>
|
|
181
188
|
<ValueBubble>{formatValue(value)}</ValueBubble>
|
|
@@ -56,6 +56,8 @@ interface SwitchProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
56
56
|
disabled?: boolean
|
|
57
57
|
/** Submits the switch under this name in a form, while on. */
|
|
58
58
|
name?: string
|
|
59
|
+
/** Must be on before its form submits: the browser's validation (and an enclosing Field's) reports it missing. Defaults to `false`. */
|
|
60
|
+
required?: boolean
|
|
59
61
|
/** The value submitted while on. Defaults to `"on"`. */
|
|
60
62
|
value?: string
|
|
61
63
|
/** Transition for the thumb's slide and hover/press stretch. Defaults to the `spring.moderate` motion token. */
|
|
@@ -147,6 +149,7 @@ const Switch = forwardRef<HTMLDivElement, SwitchProps>(
|
|
|
147
149
|
onCheckedChange,
|
|
148
150
|
disabled = false,
|
|
149
151
|
name,
|
|
152
|
+
required,
|
|
150
153
|
value,
|
|
151
154
|
thumbTransition,
|
|
152
155
|
size,
|
|
@@ -198,7 +201,7 @@ const Switch = forwardRef<HTMLDivElement, SwitchProps>(
|
|
|
198
201
|
const thumb = { left: dragX ?? thumbX, top: thumbY, width: thumbWidth, height: thumbHeight }
|
|
199
202
|
|
|
200
203
|
const handlePointerDown = useCallback(
|
|
201
|
-
(e: React.PointerEvent<
|
|
204
|
+
(e: React.PointerEvent<HTMLElement>) => {
|
|
202
205
|
if (disabled) return
|
|
203
206
|
if (e.pointerType === 'mouse' && e.button !== 0) return
|
|
204
207
|
setPressed(true)
|
|
@@ -215,7 +218,7 @@ const Switch = forwardRef<HTMLDivElement, SwitchProps>(
|
|
|
215
218
|
)
|
|
216
219
|
|
|
217
220
|
const handlePointerMove = useCallback(
|
|
218
|
-
(e: React.PointerEvent<
|
|
221
|
+
(e: React.PointerEvent<HTMLElement>) => {
|
|
219
222
|
if (!pointerStart.current) return
|
|
220
223
|
const delta = e.clientX - pointerStart.current.clientX
|
|
221
224
|
|
|
@@ -305,6 +308,7 @@ const Switch = forwardRef<HTMLDivElement, SwitchProps>(
|
|
|
305
308
|
toggle()
|
|
306
309
|
}}
|
|
307
310
|
name={name}
|
|
311
|
+
required={required}
|
|
308
312
|
value={value}
|
|
309
313
|
disabled={disabled}
|
|
310
314
|
onPointerEnter={e => {
|
|
@@ -354,6 +358,7 @@ const Switch = forwardRef<HTMLDivElement, SwitchProps>(
|
|
|
354
358
|
<SwitchPrimitive.Root
|
|
355
359
|
checked={isChecked}
|
|
356
360
|
name={name}
|
|
361
|
+
required={required}
|
|
357
362
|
value={value}
|
|
358
363
|
aria-labelledby={labelId}
|
|
359
364
|
aria-describedby={description ? descriptionId : undefined}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Textarea from './index'
|
|
2
|
+
import Button from '../../actions/button'
|
|
2
3
|
import Input, { InputGroup, Label } from '../input'
|
|
3
4
|
|
|
4
5
|
# Basic
|
|
@@ -86,3 +87,21 @@ Inside `InputGroup.Field` the textarea joins the group's hover, and the field's
|
|
|
86
87
|
<div className="w-72 max-w-full">
|
|
87
88
|
<Textarea defaultValue="Read only for now" disabled />
|
|
88
89
|
</div>
|
|
90
|
+
|
|
91
|
+
# Uncontrolled
|
|
92
|
+
|
|
93
|
+
With neither `value` nor `onValueChange` the DOM holds the text, so `ref` is the real `<textarea>`: `defaultValue`, `ref.current.value = ''` and a native form reset behave as on any textarea. Type, grow the box, then reset: the text goes back to its default and the box re-fits.
|
|
94
|
+
|
|
95
|
+
<form className="flex flex-col items-start gap-2 w-72 max-w-full">
|
|
96
|
+
<Textarea name="note" aria-label="Note" defaultValue={'First line\nSecond line\nThird line\nFourth line'} />
|
|
97
|
+
<Button type="reset" variant="ghost">Reset</Button>
|
|
98
|
+
</form>
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
const ref = useRef<HTMLTextAreaElement>(null)
|
|
102
|
+
|
|
103
|
+
<Textarea ref={ref} name="note" defaultValue="Hello" />
|
|
104
|
+
|
|
105
|
+
ref.current.value // what was typed
|
|
106
|
+
ref.current.value = '' // clears it
|
|
107
|
+
```
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
'use client'
|
|
7
7
|
|
|
8
8
|
import { Field } from '@base-ui/react/field'
|
|
9
|
-
import { forwardRef, type Ref, type TextareaHTMLAttributes, useRef } from 'react'
|
|
9
|
+
import { forwardRef, type Ref, type TextareaHTMLAttributes, useEffect, useRef } from 'react'
|
|
10
10
|
import { focusControlOnPress, useFieldBox } from '../../../lib/field-box'
|
|
11
11
|
import type { FieldVariant } from '../../../lib/field-classes'
|
|
12
12
|
import { mergeRefs } from '../../../lib/merge-refs'
|
|
@@ -23,7 +23,7 @@ interface TextareaProps
|
|
|
23
23
|
value?: string
|
|
24
24
|
/** Initial value when uncontrolled. Defaults to `''`. */
|
|
25
25
|
defaultValue?: string
|
|
26
|
-
/** Called with the new value on every change. */
|
|
26
|
+
/** Called with the new value on every change. With neither `value` nor `onValueChange` the textarea keeps its text in the DOM, for forms that read it through a `ref`. */
|
|
27
27
|
onValueChange?: (value: string) => void
|
|
28
28
|
/** Rows shown when empty; the box never gets shorter. Defaults to `3`. */
|
|
29
29
|
minRows?: number
|
|
@@ -66,6 +66,13 @@ const PADDING_Y: Record<SizeVariant, string> = {
|
|
|
66
66
|
* or put it in an `InputGroup.Field` to label it, join the group's hover and
|
|
67
67
|
* take the field's error.
|
|
68
68
|
*
|
|
69
|
+
* With neither `value` nor `onValueChange` it is a plain uncontrolled
|
|
70
|
+
* `<textarea>`: the DOM holds the text, `ref` is the real element, and
|
|
71
|
+
* `defaultValue`, `ref.current.value = ''` and a native `form.reset()` all
|
|
72
|
+
* behave as on any textarea (the box re-fits after each), which is what a
|
|
73
|
+
* form library reading fields through refs (`register()`) needs. Pass it
|
|
74
|
+
* `name`, `ref` and `defaultValue`.
|
|
75
|
+
*
|
|
69
76
|
* @example {@include ./examples.mdx}
|
|
70
77
|
*/
|
|
71
78
|
const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
@@ -88,11 +95,42 @@ const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
88
95
|
ref,
|
|
89
96
|
) => {
|
|
90
97
|
const [value, setValue] = useControllableState(valueProp, defaultValue, onValueChange)
|
|
98
|
+
const domHeld = valueProp === undefined && onValueChange === undefined
|
|
91
99
|
|
|
92
100
|
const textareaRef = useRef<HTMLTextAreaElement | null>(null)
|
|
93
101
|
const box = useFieldBox({ variant, invalid, disabled, readOnly, required, size })
|
|
94
102
|
|
|
95
|
-
useAutosizeTextarea(textareaRef, { minRows, maxRows }, [value, box.size.variant])
|
|
103
|
+
const resize = useAutosizeTextarea(textareaRef, { minRows, maxRows }, [value, box.size.variant])
|
|
104
|
+
|
|
105
|
+
// DOM-held text changes without a render: re-fit when code assigns `value` (the setter is
|
|
106
|
+
// wrapped on the element, over React's own value tracker) and once a form reset has put the
|
|
107
|
+
// default back.
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
const el = textareaRef.current
|
|
110
|
+
if (!domHeld || !el) return
|
|
111
|
+
const own = Object.getOwnPropertyDescriptor(el, 'value')
|
|
112
|
+
const base = own ?? Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value')
|
|
113
|
+
const set = base?.set
|
|
114
|
+
if (set) {
|
|
115
|
+
Object.defineProperty(el, 'value', {
|
|
116
|
+
configurable: true,
|
|
117
|
+
enumerable: base.enumerable,
|
|
118
|
+
get: base.get,
|
|
119
|
+
set(next: string) {
|
|
120
|
+
set.call(this, next)
|
|
121
|
+
resize()
|
|
122
|
+
},
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
const form = el.form
|
|
126
|
+
const onReset = () => setTimeout(resize)
|
|
127
|
+
form?.addEventListener('reset', onReset)
|
|
128
|
+
return () => {
|
|
129
|
+
form?.removeEventListener('reset', onReset)
|
|
130
|
+
if (own) Object.defineProperty(el, 'value', own)
|
|
131
|
+
else if (set) Reflect.deleteProperty(el, 'value')
|
|
132
|
+
}
|
|
133
|
+
}, [domHeld, resize])
|
|
96
134
|
|
|
97
135
|
return (
|
|
98
136
|
// biome-ignore lint/a11y/noStaticElementInteractions: the textarea is the focusable control; the box only forwards pointer focus from its padding.
|
|
@@ -105,8 +143,7 @@ const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
105
143
|
<Field.Control
|
|
106
144
|
ref={mergeRefs(textareaRef, ref) as Ref<HTMLElement>}
|
|
107
145
|
render={<textarea rows={minRows} {...props} />}
|
|
108
|
-
|
|
109
|
-
onChange={e => setValue(e.target.value)}
|
|
146
|
+
{...(domHeld ? { defaultValue, onChange: resize } : { value, onChange: e => setValue(e.target.value) })}
|
|
110
147
|
disabled={box.disabled}
|
|
111
148
|
readOnly={box.readOnly}
|
|
112
149
|
required={box.required}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
useState,
|
|
26
26
|
} from 'react'
|
|
27
27
|
import { useIcon } from '../../../lib/icon-context'
|
|
28
|
+
import { inertProps } from '../../../lib/inert'
|
|
28
29
|
import { useShape } from '../../../lib/shape-context'
|
|
29
30
|
import { useSize } from '../../../lib/size-context'
|
|
30
31
|
import { resolveSlotTemplate, slotElement } from '../../../lib/slot'
|
|
@@ -103,7 +104,7 @@ const SidebarGroup = forwardRef<HTMLDivElement, SidebarGroupProps>(
|
|
|
103
104
|
if (open) setSettled(true)
|
|
104
105
|
}}
|
|
105
106
|
>
|
|
106
|
-
<div ref={fold.contentRef} className="flex w-full min-w-0 flex-col" {...(open
|
|
107
|
+
<div ref={fold.contentRef} className="flex w-full min-w-0 flex-col" {...inertProps(!open)}>
|
|
107
108
|
{tail.filter(k => !isHeaderAction(k))}
|
|
108
109
|
</div>
|
|
109
110
|
</motion.div>
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
useRef,
|
|
20
20
|
} from 'react'
|
|
21
21
|
import type { IconComponent } from '../../../lib/icon-context'
|
|
22
|
+
import { inertProps } from '../../../lib/inert'
|
|
22
23
|
import { mergeRefs, useMergeRefs } from '../../../lib/merge-refs'
|
|
23
24
|
import { useShape } from '../../../lib/shape-context'
|
|
24
25
|
import { type SizeVariant, useSize } from '../../../lib/size-context'
|
|
@@ -61,7 +62,7 @@ const SidebarMenuSub = forwardRef<HTMLUListElement, SidebarMenuSubProps>(
|
|
|
61
62
|
data-sidebar="menu-sub"
|
|
62
63
|
data-state={open ? 'open' : 'closed'}
|
|
63
64
|
aria-hidden={open ? undefined : true}
|
|
64
|
-
{...(open
|
|
65
|
+
{...inertProps(!open)}
|
|
65
66
|
className={cn(
|
|
66
67
|
// A margin, not a translate, so the measured rects include it:
|
|
67
68
|
// 15px + the 1px border + pl-2 + the row's pl-2 lands the label on
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { motion } from 'motion/react'
|
|
11
11
|
import { type CSSProperties, forwardRef, type HTMLAttributes, useEffect, useRef, useState } from 'react'
|
|
12
|
+
import { inertProps } from '../../../lib/inert'
|
|
12
13
|
import { useMergeRefs } from '../../../lib/merge-refs'
|
|
13
14
|
import { useReduceMotion } from '../../../lib/reduced-motion'
|
|
14
15
|
import { useShape } from '../../../lib/shape-context'
|
|
@@ -130,7 +131,7 @@ const SidebarShell = forwardRef<HTMLDivElement, SidebarShellProps>(
|
|
|
130
131
|
animate={{ x: open ? '0%' : side === 'left' ? '-100%' : '100%' }}
|
|
131
132
|
transition={transition}
|
|
132
133
|
// Mid-drag the rail inside holds the pointer through a collapse preview.
|
|
133
|
-
{...(open
|
|
134
|
+
{...inertProps(!open && !isResizing)}
|
|
134
135
|
>
|
|
135
136
|
{variant === 'floating' ? (
|
|
136
137
|
<div
|
|
@@ -24,6 +24,7 @@ import { FluidHoverHighlight } from '../../../lib/fluid-hover-highlight'
|
|
|
24
24
|
import { FocusRing } from '../../../lib/focus-ring'
|
|
25
25
|
import { GooIndicator } from '../../../lib/goo-indicator'
|
|
26
26
|
import { type IconComponent, useIcon } from '../../../lib/icon-context'
|
|
27
|
+
import { inertProps } from '../../../lib/inert'
|
|
27
28
|
import { useReduceMotion } from '../../../lib/reduced-motion'
|
|
28
29
|
import { useShape } from '../../../lib/shape-context'
|
|
29
30
|
import { type SizeVariant, useSize } from '../../../lib/size-context'
|
|
@@ -127,7 +128,7 @@ function TreeGroup({ open, items, depth }: { open: boolean; items: TreeItem[]; d
|
|
|
127
128
|
ref={ref}
|
|
128
129
|
role="group"
|
|
129
130
|
data-tree-group={open ? 'open' : 'closed'}
|
|
130
|
-
{...(open
|
|
131
|
+
{...inertProps(!open)}
|
|
131
132
|
className={cn('flex flex-col border-l border-border pl-[var(--space-1)]', GUIDE[size.variant])}
|
|
132
133
|
>
|
|
133
134
|
{items.map(item => (
|
|
@@ -21,7 +21,13 @@ import { FluidHoverHighlight } from '../../../lib/fluid-hover-highlight'
|
|
|
21
21
|
import { FocusRing } from '../../../lib/focus-ring'
|
|
22
22
|
import { GooIndicator } from '../../../lib/goo-indicator'
|
|
23
23
|
import { useMergeRefs } from '../../../lib/merge-refs'
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
type AnchorProps,
|
|
26
|
+
type CollisionProps,
|
|
27
|
+
OverlayContext,
|
|
28
|
+
positionerProps,
|
|
29
|
+
useOverlayRoot,
|
|
30
|
+
} from '../../../lib/overlay'
|
|
25
31
|
import { isDisabledRow, POPUP_SHAPE } from '../../../lib/popup'
|
|
26
32
|
import { PopupSeparator } from '../../../lib/popup-rows'
|
|
27
33
|
import { useRowGroup } from '../../../lib/row-group'
|
|
@@ -156,10 +162,11 @@ type DropdownComponent = ForwardRefExoticComponent<DropdownProps & RefAttributes
|
|
|
156
162
|
*
|
|
157
163
|
* Statics:
|
|
158
164
|
* - `Dropdown.Menu` — the popup root: `open`, `defaultOpen`, `onOpenChange`
|
|
159
|
-
* (with Base UI's details: `reason`, `cancel()`), `disabled`, `size`.
|
|
165
|
+
* (with Base UI's details: `reason`, `cancel()`), `disabled`, `modal`, `size`.
|
|
160
166
|
* - `Dropdown.Trigger` — `render` or `asChild`.
|
|
161
167
|
* - `Dropdown.Content` — the popup panel: the selection props above, `side`,
|
|
162
|
-
* `align`, `sideOffset`, `
|
|
168
|
+
* `align`, `sideOffset`, `alignOffset`, `collisionPadding`,
|
|
169
|
+
* `collisionBoundary`, `positionerClassName`, `container`, `keepMounted`, `initialFocus`,
|
|
163
170
|
* `finalFocus` and the morph options `from`, `effect`, `hideSource`, `tier`.
|
|
164
171
|
* - `Dropdown.Item` — a row: `label` or `children`, `textValue`, `icon`,
|
|
165
172
|
* `index`, `inset`, `checked`, `onSelect(event)` (`preventDefault()` keeps
|
|
@@ -294,18 +301,27 @@ interface DropdownMenuProps {
|
|
|
294
301
|
onOpenChange?: (open: boolean, details: DropdownOpenChangeDetails) => void
|
|
295
302
|
/** Disables the menu. Defaults to `false`. */
|
|
296
303
|
disabled?: boolean
|
|
304
|
+
/** Locks the page scroll while the menu is open and keeps the pointer off everything outside it. Non-modal, the page keeps scrolling and the popup follows its trigger. Defaults to `false`. */
|
|
305
|
+
modal?: boolean
|
|
297
306
|
/** Pins trigger-side content and the portalled popup rows to one step of the size ladder (default 36px, compact 28px — see Sizes). Omitted, they follow the surrounding SizeProvider. */
|
|
298
307
|
size?: SizeVariant
|
|
299
308
|
}
|
|
300
309
|
|
|
301
|
-
function DropdownMenu({
|
|
310
|
+
function DropdownMenu({
|
|
311
|
+
children,
|
|
312
|
+
open,
|
|
313
|
+
defaultOpen,
|
|
314
|
+
onOpenChange,
|
|
315
|
+
disabled = false,
|
|
316
|
+
modal = false,
|
|
317
|
+
size,
|
|
318
|
+
}: DropdownMenuProps) {
|
|
302
319
|
// Reported here rather than through the root's state, so the handler gets the details and can cancel.
|
|
303
320
|
const root = useOverlayRoot({ open, defaultOpen })
|
|
304
321
|
|
|
305
322
|
return (
|
|
306
323
|
<SizeScope size={size}>
|
|
307
324
|
<OverlayContext.Provider value={root.state}>
|
|
308
|
-
{/* Non-modal: the page keeps scrolling and the popup follows its trigger. */}
|
|
309
325
|
<Menu.Root
|
|
310
326
|
open={root.open}
|
|
311
327
|
onOpenChange={(next, details) => {
|
|
@@ -313,7 +329,7 @@ function DropdownMenu({ children, open, defaultOpen, onOpenChange, disabled = fa
|
|
|
313
329
|
if (!details.isCanceled) root.onOpenChange(next, details)
|
|
314
330
|
}}
|
|
315
331
|
disabled={disabled}
|
|
316
|
-
modal={
|
|
332
|
+
modal={modal}
|
|
317
333
|
>
|
|
318
334
|
{children}
|
|
319
335
|
</Menu.Root>
|
|
@@ -339,6 +355,7 @@ interface DropdownContentProps
|
|
|
339
355
|
extends PanelSelectionProps,
|
|
340
356
|
MenuFocusProps,
|
|
341
357
|
AnchorProps,
|
|
358
|
+
CollisionProps,
|
|
342
359
|
MorphProps,
|
|
343
360
|
Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
344
361
|
/** `Dropdown.Item` rows, plus `Dropdown.Label`, `Dropdown.Separator`, `Dropdown.Search`, `Dropdown.Empty`. */
|
|
@@ -350,12 +367,37 @@ interface DropdownContentProps
|
|
|
350
367
|
}
|
|
351
368
|
|
|
352
369
|
const DropdownContent = forwardRef<HTMLDivElement, DropdownContentProps>(
|
|
353
|
-
(
|
|
370
|
+
(
|
|
371
|
+
{
|
|
372
|
+
side,
|
|
373
|
+
align,
|
|
374
|
+
sideOffset,
|
|
375
|
+
alignOffset,
|
|
376
|
+
collisionPadding,
|
|
377
|
+
collisionBoundary,
|
|
378
|
+
positionerClassName,
|
|
379
|
+
effect,
|
|
380
|
+
hideSource,
|
|
381
|
+
className,
|
|
382
|
+
...props
|
|
383
|
+
},
|
|
384
|
+
ref,
|
|
385
|
+
) => (
|
|
354
386
|
<MenuPopup
|
|
355
387
|
ref={ref}
|
|
356
388
|
part="Dropdown.Content"
|
|
357
389
|
positioner={positionerProps(
|
|
358
|
-
{
|
|
390
|
+
{
|
|
391
|
+
side,
|
|
392
|
+
align,
|
|
393
|
+
sideOffset,
|
|
394
|
+
alignOffset,
|
|
395
|
+
collisionPadding,
|
|
396
|
+
collisionBoundary,
|
|
397
|
+
positionerClassName,
|
|
398
|
+
effect,
|
|
399
|
+
hideSource,
|
|
400
|
+
},
|
|
359
401
|
{ side: 'bottom', align: 'start', sideOffset: 6 },
|
|
360
402
|
)}
|
|
361
403
|
focusFirstRow
|
|
@@ -10,7 +10,14 @@
|
|
|
10
10
|
import { Menu, type MenuRootChangeEventDetails } from '@base-ui/react/menu'
|
|
11
11
|
import { forwardRef, type HTMLAttributes, type ReactNode, useMemo } from 'react'
|
|
12
12
|
import { useIcon } from '../../../lib/icon-context'
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
type AnchorProps,
|
|
15
|
+
type CollisionProps,
|
|
16
|
+
OverlayContext,
|
|
17
|
+
positionerProps,
|
|
18
|
+
useOverlay,
|
|
19
|
+
useOverlayRoot,
|
|
20
|
+
} from '../../../lib/overlay'
|
|
14
21
|
import { useSize } from '../../../lib/size-context'
|
|
15
22
|
import type { MorphProps } from '../../../lib/use-morph'
|
|
16
23
|
import { cn } from '../../../lib/utils'
|
|
@@ -124,6 +131,7 @@ interface DropdownSubContentProps
|
|
|
124
131
|
extends PanelSelectionProps,
|
|
125
132
|
MenuFocusProps,
|
|
126
133
|
AnchorProps,
|
|
134
|
+
CollisionProps,
|
|
127
135
|
MorphProps,
|
|
128
136
|
Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
129
137
|
/** The submenu's rows: the same parts as `Dropdown.Content`, another `Dropdown.Sub` included. */
|
|
@@ -134,6 +142,8 @@ interface DropdownSubContentProps
|
|
|
134
142
|
align?: AnchorProps['align']
|
|
135
143
|
/** Gap to the parent menu in px, the length of the goo neck. Defaults to `8`. */
|
|
136
144
|
sideOffset?: number
|
|
145
|
+
/** Shift along the aligned edge in px. Defaults to `-4`: the panel's padding, so its first row lines up with the trigger row. */
|
|
146
|
+
alignOffset?: CollisionProps['alignOffset']
|
|
137
147
|
/** Extra classes for the submenu surface: it is 14rem wide by default. */
|
|
138
148
|
className?: string
|
|
139
149
|
/** Keep the submenu mounted (hidden) while closed, so its rows keep their own state across opens. A kept parent keeps it too. Defaults to `false`. */
|
|
@@ -142,18 +152,39 @@ interface DropdownSubContentProps
|
|
|
142
152
|
|
|
143
153
|
/** The submenu's panel, lifted above the menu it came from and grown out of its trigger row. */
|
|
144
154
|
const DropdownSubContent = forwardRef<HTMLDivElement, DropdownSubContentProps>(
|
|
145
|
-
(
|
|
155
|
+
(
|
|
156
|
+
{
|
|
157
|
+
side,
|
|
158
|
+
align,
|
|
159
|
+
sideOffset,
|
|
160
|
+
alignOffset = -4,
|
|
161
|
+
collisionPadding,
|
|
162
|
+
collisionBoundary,
|
|
163
|
+
positionerClassName,
|
|
164
|
+
effect,
|
|
165
|
+
hideSource,
|
|
166
|
+
className,
|
|
167
|
+
...props
|
|
168
|
+
},
|
|
169
|
+
ref,
|
|
170
|
+
) => (
|
|
146
171
|
<MenuPopup
|
|
147
172
|
ref={ref}
|
|
148
173
|
part="Dropdown.SubContent"
|
|
149
|
-
positioner={
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
174
|
+
positioner={positionerProps(
|
|
175
|
+
{
|
|
176
|
+
side,
|
|
177
|
+
align,
|
|
178
|
+
sideOffset,
|
|
179
|
+
alignOffset,
|
|
180
|
+
collisionPadding,
|
|
181
|
+
collisionBoundary,
|
|
182
|
+
positionerClassName,
|
|
183
|
+
effect,
|
|
184
|
+
hideSource,
|
|
185
|
+
},
|
|
186
|
+
{ side: 'right', align: 'start', sideOffset: 8 },
|
|
187
|
+
)}
|
|
157
188
|
focusFirstRow={false}
|
|
158
189
|
effect={effect}
|
|
159
190
|
hideSource={hideSource}
|
|
@@ -98,3 +98,16 @@ tooltips skip it, and the morph: the next label shows in place.
|
|
|
98
98
|
</Tooltip>
|
|
99
99
|
</div>
|
|
100
100
|
</Tooltip.Provider>
|
|
101
|
+
|
|
102
|
+
# Close delay
|
|
103
|
+
|
|
104
|
+
`closeDelay` keeps the label up for a moment after the pointer leaves. Set it per tooltip or for a whole `Tooltip.Provider`.
|
|
105
|
+
|
|
106
|
+
<div className="flex flex-wrap gap-3">
|
|
107
|
+
<Tooltip content="Closes at once">
|
|
108
|
+
<Button variant="secondary">Default</Button>
|
|
109
|
+
</Tooltip>
|
|
110
|
+
<Tooltip content="Lingers for 500ms" closeDelay={500}>
|
|
111
|
+
<Button variant="secondary">500ms close delay</Button>
|
|
112
|
+
</Tooltip>
|
|
113
|
+
</div>
|