@octanejs/floating-ui 0.1.2
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/LICENSE +21 -0
- package/package.json +44 -0
- package/src/Composite.ts +241 -0
- package/src/FloatingArrow.ts +145 -0
- package/src/FloatingFocusManager.ts +813 -0
- package/src/FloatingList.ts +137 -0
- package/src/FloatingOverlay.ts +85 -0
- package/src/FloatingPortal.ts +257 -0
- package/src/context.ts +181 -0
- package/src/delayGroup.ts +142 -0
- package/src/index.ts +79 -0
- package/src/internal.ts +46 -0
- package/src/pubsub.ts +19 -0
- package/src/safePolygon.ts +339 -0
- package/src/transitions.ts +146 -0
- package/src/tree.ts +85 -0
- package/src/useClick.ts +139 -0
- package/src/useClientPoint.ts +193 -0
- package/src/useDismiss.ts +379 -0
- package/src/useFloating.ts +220 -0
- package/src/useFocus.ts +154 -0
- package/src/useHover.ts +406 -0
- package/src/useId.ts +6 -0
- package/src/useInteractions.ts +94 -0
- package/src/useListNavigation.ts +721 -0
- package/src/useMergeRefs.ts +59 -0
- package/src/useRole.ts +106 -0
- package/src/useTypeahead.ts +168 -0
- package/src/utils/index.ts +656 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dominic Gannaway
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@octanejs/floating-ui",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Floating UI bindings for the octane renderer — a port of @floating-ui/react (positioning + interactions + focus management) on top of the framework-agnostic @floating-ui/dom.",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Dominic Gannaway",
|
|
9
|
+
"email": "dg@domgan.com"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/octanejs/octane.git",
|
|
17
|
+
"directory": "packages/floating-ui"
|
|
18
|
+
},
|
|
19
|
+
"main": "src/index.ts",
|
|
20
|
+
"module": "src/index.ts",
|
|
21
|
+
"types": "src/index.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"src",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"exports": {
|
|
27
|
+
".": "./src/index.ts"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@floating-ui/dom": "^1.7.0",
|
|
31
|
+
"@floating-ui/utils": "^0.2.11",
|
|
32
|
+
"tabbable": "^6.5.0",
|
|
33
|
+
"octane": "0.1.3"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@floating-ui/react": "0.27.19",
|
|
37
|
+
"react": "^19.2.0",
|
|
38
|
+
"react-dom": "^19.2.0",
|
|
39
|
+
"vitest": "^4.1.9"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"test": "vitest run"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/Composite.ts
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// Ported from @floating-ui/react Composite + CompositeItem — a single tab-stop whose
|
|
2
|
+
// items are arrow-key navigated (list nav outside a floating context). `.ts`
|
|
3
|
+
// components via createElement; React forwardRef → props.ref. `renderJsx` supports the
|
|
4
|
+
// `render` prop (a function, an element to clone, or a default <div>); octane has no
|
|
5
|
+
// cloneElement, so it's implemented locally over createElement.
|
|
6
|
+
import { createContext, createElement, useContext, useMemo, useRef, useState } from 'octane';
|
|
7
|
+
|
|
8
|
+
import { FloatingList, useListItem } from './FloatingList';
|
|
9
|
+
import { S } from './internal';
|
|
10
|
+
import { useMergeRefs } from './useMergeRefs';
|
|
11
|
+
import {
|
|
12
|
+
createGridCellMap,
|
|
13
|
+
findNonDisabledListIndex,
|
|
14
|
+
getGridCellIndexOfCorner,
|
|
15
|
+
getGridCellIndices,
|
|
16
|
+
getGridNavigatedIndex,
|
|
17
|
+
getMaxListIndex,
|
|
18
|
+
getMinListIndex,
|
|
19
|
+
isIndexOutOfListBounds,
|
|
20
|
+
isListIndexDisabled,
|
|
21
|
+
useEffectEvent,
|
|
22
|
+
} from './utils';
|
|
23
|
+
|
|
24
|
+
const ARROW_LEFT = 'ArrowLeft';
|
|
25
|
+
const ARROW_RIGHT = 'ArrowRight';
|
|
26
|
+
const ARROW_UP = 'ArrowUp';
|
|
27
|
+
const ARROW_DOWN = 'ArrowDown';
|
|
28
|
+
const horizontalKeys = [ARROW_LEFT, ARROW_RIGHT];
|
|
29
|
+
const verticalKeys = [ARROW_UP, ARROW_DOWN];
|
|
30
|
+
const allKeys = [...horizontalKeys, ...verticalKeys];
|
|
31
|
+
|
|
32
|
+
function cloneElement(el: any, props: any): any {
|
|
33
|
+
return createElement(el.type, { ...el.props, ...props });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function renderJsx(render: any, computedProps: any): any {
|
|
37
|
+
if (typeof render === 'function') {
|
|
38
|
+
return render(computedProps);
|
|
39
|
+
}
|
|
40
|
+
if (render) {
|
|
41
|
+
return cloneElement(render, computedProps);
|
|
42
|
+
}
|
|
43
|
+
return createElement('div', { ...computedProps });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const CompositeContext = createContext<any>({
|
|
47
|
+
activeIndex: 0,
|
|
48
|
+
onNavigate: () => {},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export function Composite(props: any): any {
|
|
52
|
+
const render = props.render;
|
|
53
|
+
const orientation = props.orientation ?? 'both';
|
|
54
|
+
const loop = props.loop ?? true;
|
|
55
|
+
const rtl = props.rtl ?? false;
|
|
56
|
+
const cols = props.cols ?? 1;
|
|
57
|
+
const disabledIndices = props.disabledIndices;
|
|
58
|
+
const externalActiveIndex = props.activeIndex;
|
|
59
|
+
const externalSetActiveIndex = props.onNavigate;
|
|
60
|
+
const itemSizes = props.itemSizes;
|
|
61
|
+
const dense = props.dense ?? false;
|
|
62
|
+
const forwardedRef = props.ref;
|
|
63
|
+
const {
|
|
64
|
+
render: _r,
|
|
65
|
+
orientation: _o,
|
|
66
|
+
loop: _l,
|
|
67
|
+
rtl: _rtl,
|
|
68
|
+
cols: _c,
|
|
69
|
+
disabledIndices: _di,
|
|
70
|
+
activeIndex: _ai,
|
|
71
|
+
onNavigate: _on,
|
|
72
|
+
itemSizes: _is,
|
|
73
|
+
dense: _d,
|
|
74
|
+
ref: _ref,
|
|
75
|
+
...domProps
|
|
76
|
+
} = props;
|
|
77
|
+
|
|
78
|
+
const [internalActiveIndex, internalSetActiveIndex] = useState(0, S('Composite:active'));
|
|
79
|
+
const activeIndex = externalActiveIndex != null ? externalActiveIndex : internalActiveIndex;
|
|
80
|
+
const onNavigate = useEffectEvent(
|
|
81
|
+
externalSetActiveIndex != null ? externalSetActiveIndex : internalSetActiveIndex,
|
|
82
|
+
S('Composite:nav'),
|
|
83
|
+
);
|
|
84
|
+
const elementsRef = useRef<any[]>([], S('Composite:els'));
|
|
85
|
+
const renderElementProps = render && typeof render !== 'function' ? render.props : {};
|
|
86
|
+
const contextValue = useMemo(
|
|
87
|
+
() => ({ activeIndex, onNavigate }),
|
|
88
|
+
[activeIndex, onNavigate],
|
|
89
|
+
S('Composite:ctx'),
|
|
90
|
+
);
|
|
91
|
+
const isGrid = cols > 1;
|
|
92
|
+
|
|
93
|
+
function handleKeyDown(event: any) {
|
|
94
|
+
if (!allKeys.includes(event.key)) return;
|
|
95
|
+
let nextIndex = activeIndex;
|
|
96
|
+
const minIndex = getMinListIndex(elementsRef, disabledIndices);
|
|
97
|
+
const maxIndex = getMaxListIndex(elementsRef, disabledIndices);
|
|
98
|
+
const horizontalEndKey = rtl ? ARROW_LEFT : ARROW_RIGHT;
|
|
99
|
+
const horizontalStartKey = rtl ? ARROW_RIGHT : ARROW_LEFT;
|
|
100
|
+
if (isGrid) {
|
|
101
|
+
const sizes =
|
|
102
|
+
itemSizes ||
|
|
103
|
+
Array.from({ length: elementsRef.current.length }, () => ({ width: 1, height: 1 }));
|
|
104
|
+
const cellMap = createGridCellMap(sizes, cols, dense);
|
|
105
|
+
const minGridIndex = cellMap.findIndex(
|
|
106
|
+
(index) => index != null && !isListIndexDisabled(elementsRef, index, disabledIndices),
|
|
107
|
+
);
|
|
108
|
+
const maxGridIndex = cellMap.reduce(
|
|
109
|
+
(foundIndex, index, cellIndex) =>
|
|
110
|
+
index != null && !isListIndexDisabled(elementsRef, index, disabledIndices)
|
|
111
|
+
? cellIndex
|
|
112
|
+
: foundIndex,
|
|
113
|
+
-1,
|
|
114
|
+
);
|
|
115
|
+
const maybeNextIndex =
|
|
116
|
+
cellMap[
|
|
117
|
+
getGridNavigatedIndex(
|
|
118
|
+
{
|
|
119
|
+
current: cellMap.map((itemIndex) =>
|
|
120
|
+
itemIndex ? elementsRef.current[itemIndex] : null,
|
|
121
|
+
),
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
event,
|
|
125
|
+
orientation,
|
|
126
|
+
loop,
|
|
127
|
+
rtl,
|
|
128
|
+
cols,
|
|
129
|
+
disabledIndices: getGridCellIndices(
|
|
130
|
+
[
|
|
131
|
+
...((typeof disabledIndices !== 'function' ? disabledIndices : null) ||
|
|
132
|
+
elementsRef.current.map((_: any, index: number) =>
|
|
133
|
+
isListIndexDisabled(elementsRef, index, disabledIndices) ? index : undefined,
|
|
134
|
+
)),
|
|
135
|
+
undefined,
|
|
136
|
+
],
|
|
137
|
+
cellMap,
|
|
138
|
+
),
|
|
139
|
+
minIndex: minGridIndex,
|
|
140
|
+
maxIndex: maxGridIndex,
|
|
141
|
+
prevIndex: getGridCellIndexOfCorner(
|
|
142
|
+
activeIndex > maxIndex ? minIndex : activeIndex,
|
|
143
|
+
sizes,
|
|
144
|
+
cellMap,
|
|
145
|
+
cols,
|
|
146
|
+
event.key === ARROW_DOWN ? 'bl' : event.key === horizontalEndKey ? 'tr' : 'tl',
|
|
147
|
+
),
|
|
148
|
+
},
|
|
149
|
+
)
|
|
150
|
+
];
|
|
151
|
+
if (maybeNextIndex != null) {
|
|
152
|
+
nextIndex = maybeNextIndex;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const toEndKeys = {
|
|
156
|
+
horizontal: [horizontalEndKey],
|
|
157
|
+
vertical: [ARROW_DOWN],
|
|
158
|
+
both: [horizontalEndKey, ARROW_DOWN],
|
|
159
|
+
}[orientation as 'horizontal' | 'vertical' | 'both'];
|
|
160
|
+
const toStartKeys = {
|
|
161
|
+
horizontal: [horizontalStartKey],
|
|
162
|
+
vertical: [ARROW_UP],
|
|
163
|
+
both: [horizontalStartKey, ARROW_UP],
|
|
164
|
+
}[orientation as 'horizontal' | 'vertical' | 'both'];
|
|
165
|
+
const preventedKeys = isGrid
|
|
166
|
+
? allKeys
|
|
167
|
+
: {
|
|
168
|
+
horizontal: horizontalKeys,
|
|
169
|
+
vertical: verticalKeys,
|
|
170
|
+
both: allKeys,
|
|
171
|
+
}[orientation as 'horizontal' | 'vertical' | 'both'];
|
|
172
|
+
if (nextIndex === activeIndex && [...toEndKeys, ...toStartKeys].includes(event.key)) {
|
|
173
|
+
if (loop && nextIndex === maxIndex && toEndKeys.includes(event.key)) {
|
|
174
|
+
nextIndex = minIndex;
|
|
175
|
+
} else if (loop && nextIndex === minIndex && toStartKeys.includes(event.key)) {
|
|
176
|
+
nextIndex = maxIndex;
|
|
177
|
+
} else {
|
|
178
|
+
nextIndex = findNonDisabledListIndex(elementsRef, {
|
|
179
|
+
startingIndex: nextIndex,
|
|
180
|
+
decrement: toStartKeys.includes(event.key),
|
|
181
|
+
disabledIndices,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (nextIndex !== activeIndex && !isIndexOutOfListBounds(elementsRef, nextIndex)) {
|
|
186
|
+
event.stopPropagation();
|
|
187
|
+
if (preventedKeys.includes(event.key)) {
|
|
188
|
+
event.preventDefault();
|
|
189
|
+
}
|
|
190
|
+
onNavigate(nextIndex);
|
|
191
|
+
elementsRef.current[nextIndex]?.focus();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const computedProps = {
|
|
196
|
+
...domProps,
|
|
197
|
+
...renderElementProps,
|
|
198
|
+
ref: forwardedRef,
|
|
199
|
+
'aria-orientation': orientation === 'both' ? undefined : orientation,
|
|
200
|
+
onKeyDown(e: any) {
|
|
201
|
+
domProps.onKeyDown?.(e);
|
|
202
|
+
renderElementProps.onKeyDown?.(e);
|
|
203
|
+
handleKeyDown(e);
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
return createElement(CompositeContext.Provider, {
|
|
208
|
+
value: contextValue,
|
|
209
|
+
children: createElement(FloatingList, {
|
|
210
|
+
elementsRef,
|
|
211
|
+
children: renderJsx(render, computedProps),
|
|
212
|
+
}),
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function CompositeItem(props: any): any {
|
|
217
|
+
const render = props.render;
|
|
218
|
+
const forwardedRef = props.ref;
|
|
219
|
+
const { render: _r, ref: _ref, ...domProps } = props;
|
|
220
|
+
const renderElementProps = render && typeof render !== 'function' ? render.props : {};
|
|
221
|
+
const { activeIndex, onNavigate } = useContext(CompositeContext);
|
|
222
|
+
const { ref, index } = useListItem(S('CompositeItem:listItem'));
|
|
223
|
+
const mergedRef = useMergeRefs(
|
|
224
|
+
[ref, forwardedRef, renderElementProps.ref],
|
|
225
|
+
S('CompositeItem:merge'),
|
|
226
|
+
);
|
|
227
|
+
const isActive = activeIndex === index;
|
|
228
|
+
const computedProps = {
|
|
229
|
+
...domProps,
|
|
230
|
+
...renderElementProps,
|
|
231
|
+
ref: mergedRef,
|
|
232
|
+
tabIndex: isActive ? 0 : -1,
|
|
233
|
+
'data-active': isActive ? '' : undefined,
|
|
234
|
+
onFocus(e: any) {
|
|
235
|
+
domProps.onFocus?.(e);
|
|
236
|
+
renderElementProps.onFocus?.(e);
|
|
237
|
+
onNavigate(index);
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
return renderJsx(render, computedProps);
|
|
241
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Ported from @floating-ui/react FloatingArrow — the SVG arrow for a floating
|
|
2
|
+
// element. Now possible because octane's de-opt path namespaces `<svg>` subtrees.
|
|
3
|
+
// `.ts` component via createElement; React forwardRef → props.ref. Unlike React JSX
|
|
4
|
+
// (which maps `strokeWidth`→`stroke-width`), octane's de-opt setAttribute uses names
|
|
5
|
+
// verbatim, so SVG presentation attributes are written kebab-case here.
|
|
6
|
+
import { getComputedStyle } from '@floating-ui/utils/dom';
|
|
7
|
+
import { createElement, useState } from 'octane';
|
|
8
|
+
|
|
9
|
+
import { S } from './internal';
|
|
10
|
+
import { useId } from './useId';
|
|
11
|
+
import { useModernLayoutEffect } from './utils';
|
|
12
|
+
|
|
13
|
+
export function FloatingArrow(props: any): any {
|
|
14
|
+
const ref = props.ref;
|
|
15
|
+
const context = props.context;
|
|
16
|
+
const placement = context.placement;
|
|
17
|
+
const floating = context.elements.floating;
|
|
18
|
+
const arrow = context.middlewareData.arrow;
|
|
19
|
+
const shift = context.middlewareData.shift;
|
|
20
|
+
|
|
21
|
+
const width = props.width ?? 14;
|
|
22
|
+
const height = props.height ?? 7;
|
|
23
|
+
const tipRadius = props.tipRadius ?? 0;
|
|
24
|
+
const strokeWidth = props.strokeWidth ?? 0;
|
|
25
|
+
const staticOffset = props.staticOffset;
|
|
26
|
+
const stroke = props.stroke;
|
|
27
|
+
const d = props.d;
|
|
28
|
+
const { transform, ...restStyle } = props.style ?? {};
|
|
29
|
+
const {
|
|
30
|
+
context: _c,
|
|
31
|
+
width: _w,
|
|
32
|
+
height: _h,
|
|
33
|
+
tipRadius: _t,
|
|
34
|
+
strokeWidth: _s,
|
|
35
|
+
staticOffset: _so,
|
|
36
|
+
stroke: _st,
|
|
37
|
+
d: _d,
|
|
38
|
+
style: _sty,
|
|
39
|
+
ref: _r,
|
|
40
|
+
...rest
|
|
41
|
+
} = props;
|
|
42
|
+
|
|
43
|
+
const clipPathId = useId(S('FloatingArrow:id'));
|
|
44
|
+
const [isRTL, setIsRTL] = useState(false, S('FloatingArrow:rtl'));
|
|
45
|
+
|
|
46
|
+
useModernLayoutEffect(
|
|
47
|
+
() => {
|
|
48
|
+
if (!floating) return;
|
|
49
|
+
const rtl = getComputedStyle(floating).direction === 'rtl';
|
|
50
|
+
if (rtl) {
|
|
51
|
+
setIsRTL(true);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
[floating],
|
|
55
|
+
S('FloatingArrow:eff'),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (!floating) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const [side, alignment] = placement.split('-');
|
|
63
|
+
const isVerticalSide = side === 'top' || side === 'bottom';
|
|
64
|
+
let computedStaticOffset = staticOffset;
|
|
65
|
+
if (
|
|
66
|
+
(isVerticalSide && shift != null && shift.x) ||
|
|
67
|
+
(!isVerticalSide && shift != null && shift.y)
|
|
68
|
+
) {
|
|
69
|
+
computedStaticOffset = null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const computedStrokeWidth = strokeWidth * 2;
|
|
73
|
+
const halfStrokeWidth = computedStrokeWidth / 2;
|
|
74
|
+
const svgX = (width / 2) * (tipRadius / -8 + 1);
|
|
75
|
+
const svgY = ((height / 2) * tipRadius) / 4;
|
|
76
|
+
const isCustomShape = !!d;
|
|
77
|
+
const yOffsetProp = computedStaticOffset && alignment === 'end' ? 'bottom' : 'top';
|
|
78
|
+
let xOffsetProp = computedStaticOffset && alignment === 'end' ? 'right' : 'left';
|
|
79
|
+
if (computedStaticOffset && isRTL) {
|
|
80
|
+
xOffsetProp = alignment === 'end' ? 'left' : 'right';
|
|
81
|
+
}
|
|
82
|
+
const arrowX = arrow?.x != null ? computedStaticOffset || arrow.x : '';
|
|
83
|
+
const arrowY = arrow?.y != null ? computedStaticOffset || arrow.y : '';
|
|
84
|
+
const dValue =
|
|
85
|
+
d ||
|
|
86
|
+
'M0,0' +
|
|
87
|
+
(' H' + width) +
|
|
88
|
+
(' L' + (width - svgX) + ',' + (height - svgY)) +
|
|
89
|
+
(' Q' + width / 2 + ',' + height + ' ' + svgX + ',' + (height - svgY)) +
|
|
90
|
+
' Z';
|
|
91
|
+
const rotation: any = (
|
|
92
|
+
{
|
|
93
|
+
top: isCustomShape ? 'rotate(180deg)' : '',
|
|
94
|
+
left: isCustomShape ? 'rotate(90deg)' : 'rotate(-90deg)',
|
|
95
|
+
bottom: isCustomShape ? '' : 'rotate(180deg)',
|
|
96
|
+
right: isCustomShape ? 'rotate(-90deg)' : 'rotate(90deg)',
|
|
97
|
+
} as any
|
|
98
|
+
)[side];
|
|
99
|
+
|
|
100
|
+
return createElement(
|
|
101
|
+
'svg',
|
|
102
|
+
{
|
|
103
|
+
...rest,
|
|
104
|
+
'aria-hidden': true,
|
|
105
|
+
ref,
|
|
106
|
+
width: isCustomShape ? width : width + computedStrokeWidth,
|
|
107
|
+
height: width,
|
|
108
|
+
viewBox: '0 0 ' + width + ' ' + (height > width ? height : width),
|
|
109
|
+
style: {
|
|
110
|
+
position: 'absolute',
|
|
111
|
+
pointerEvents: 'none',
|
|
112
|
+
[xOffsetProp]: arrowX,
|
|
113
|
+
[yOffsetProp]: arrowY,
|
|
114
|
+
[side]:
|
|
115
|
+
isVerticalSide || isCustomShape
|
|
116
|
+
? '100%'
|
|
117
|
+
: 'calc(100% - ' + computedStrokeWidth / 2 + 'px)',
|
|
118
|
+
transform: [rotation, transform].filter((t) => !!t).join(' '),
|
|
119
|
+
...restStyle,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
computedStrokeWidth > 0 &&
|
|
123
|
+
createElement('path', {
|
|
124
|
+
'clip-path': 'url(#' + clipPathId + ')',
|
|
125
|
+
fill: 'none',
|
|
126
|
+
stroke,
|
|
127
|
+
'stroke-width': computedStrokeWidth + (d ? 0 : 1),
|
|
128
|
+
d: dValue,
|
|
129
|
+
}),
|
|
130
|
+
createElement('path', {
|
|
131
|
+
stroke: computedStrokeWidth && !d ? rest.fill : 'none',
|
|
132
|
+
d: dValue,
|
|
133
|
+
}),
|
|
134
|
+
createElement(
|
|
135
|
+
'clipPath',
|
|
136
|
+
{ id: clipPathId },
|
|
137
|
+
createElement('rect', {
|
|
138
|
+
x: -halfStrokeWidth,
|
|
139
|
+
y: halfStrokeWidth * (isCustomShape ? -1 : 1),
|
|
140
|
+
width: width + computedStrokeWidth,
|
|
141
|
+
height: width,
|
|
142
|
+
}),
|
|
143
|
+
),
|
|
144
|
+
);
|
|
145
|
+
}
|