@sanity/ui 1.7.7 → 1.7.9
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/index.d.ts +19 -19
- package/dist/index.esm.js +34 -24
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +33 -23
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
- package/src/primitives/tooltip/tooltip.tsx +22 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.9",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -76,7 +76,6 @@
|
|
|
76
76
|
"@types/react-dom": "^18.2.7",
|
|
77
77
|
"@types/react-is": "^18.2.1",
|
|
78
78
|
"@types/refractor": "^3.0.2",
|
|
79
|
-
"@types/styled-components": "^5.1.26",
|
|
80
79
|
"@types/testing-library__jest-dom": "^5.14.9",
|
|
81
80
|
"@typescript-eslint/eslint-plugin": "^6.3.0",
|
|
82
81
|
"@typescript-eslint/parser": "^6.3.0",
|
|
@@ -108,7 +107,7 @@
|
|
|
108
107
|
"rimraf": "^5.0.1",
|
|
109
108
|
"semantic-release": "^21.0.7",
|
|
110
109
|
"start-server-and-test": "^2.0.0",
|
|
111
|
-
"styled-components": "^
|
|
110
|
+
"styled-components": "^6.0.7",
|
|
112
111
|
"tsconfig-paths": "^4.2.0",
|
|
113
112
|
"typescript": "^5.1.6"
|
|
114
113
|
},
|
|
@@ -116,7 +115,7 @@
|
|
|
116
115
|
"react": "^18",
|
|
117
116
|
"react-dom": "^18",
|
|
118
117
|
"react-is": "^18",
|
|
119
|
-
"styled-components": "^5.2"
|
|
118
|
+
"styled-components": "^5.2 || ^6"
|
|
120
119
|
},
|
|
121
120
|
"engines": {
|
|
122
121
|
"node": ">=14.0.0"
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
useFloating,
|
|
9
9
|
Middleware,
|
|
10
10
|
RootBoundary,
|
|
11
|
+
size,
|
|
11
12
|
} from '@floating-ui/react-dom'
|
|
12
13
|
import {
|
|
13
14
|
cloneElement,
|
|
@@ -90,12 +91,25 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
90
91
|
fallbackPlacements,
|
|
91
92
|
padding: 4,
|
|
92
93
|
rootBoundary,
|
|
94
|
+
mainAxis: false,
|
|
93
95
|
}),
|
|
94
96
|
)
|
|
95
97
|
|
|
96
98
|
// Define distance between reference and floating element
|
|
97
99
|
ret.push(offset({mainAxis: 3}))
|
|
98
100
|
|
|
101
|
+
// Set width and height on the floating element
|
|
102
|
+
ret.push(
|
|
103
|
+
size({
|
|
104
|
+
apply({availableWidth, availableHeight, elements}) {
|
|
105
|
+
Object.assign(elements.floating.style, {
|
|
106
|
+
maxWidth: `${availableWidth - 4 * 2}px`, // the padding is `4px`
|
|
107
|
+
maxHeight: `${availableHeight - 4 * 2}px`, // the padding is `4px`
|
|
108
|
+
})
|
|
109
|
+
},
|
|
110
|
+
}),
|
|
111
|
+
)
|
|
112
|
+
|
|
99
113
|
// Shift the tooltip so its sits with the boundary eleement
|
|
100
114
|
ret.push(
|
|
101
115
|
shift({
|
|
@@ -111,21 +125,12 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
111
125
|
return ret
|
|
112
126
|
}, [boundaryElement, fallbackPlacements])
|
|
113
127
|
|
|
114
|
-
const {
|
|
128
|
+
const {floatingStyles, placement, middlewareData, refs, update} = useFloating({
|
|
115
129
|
middleware,
|
|
116
130
|
placement: placementProp,
|
|
117
131
|
whileElementsMounted: autoUpdate,
|
|
118
132
|
})
|
|
119
133
|
|
|
120
|
-
const rootStyle: CSSProperties = useMemo(
|
|
121
|
-
() => ({
|
|
122
|
-
position: strategy,
|
|
123
|
-
top: y ?? 0,
|
|
124
|
-
left: x ?? 0,
|
|
125
|
-
}),
|
|
126
|
-
[strategy, x, y],
|
|
127
|
-
)
|
|
128
|
-
|
|
129
134
|
const staticSide = placement && FLOATING_STATIC_SIDES[placement.split('-')[0]]
|
|
130
135
|
|
|
131
136
|
const arrowX = middlewareData.arrow?.x
|
|
@@ -238,7 +243,13 @@ export const Tooltip = forwardRef(function Tooltip(
|
|
|
238
243
|
if (disabled) return child
|
|
239
244
|
|
|
240
245
|
const root = (
|
|
241
|
-
<Root
|
|
246
|
+
<Root
|
|
247
|
+
data-ui="Tooltip"
|
|
248
|
+
{...restProps}
|
|
249
|
+
ref={setFloating}
|
|
250
|
+
style={floatingStyles}
|
|
251
|
+
zOffset={zOffset}
|
|
252
|
+
>
|
|
242
253
|
<Card
|
|
243
254
|
data-ui="Tooltip__card"
|
|
244
255
|
data-placement={placement}
|