@ariakit/core 0.1.5 → 0.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/CHANGELOG.md +56 -0
- package/cjs/__chunks/{LBTLD2RB.cjs → CNODBYSG.cjs} +2 -2
- package/cjs/__chunks/RD3S4VKY.cjs +60 -0
- package/cjs/combobox/combobox-store.cjs +2 -2
- package/cjs/composite/composite-overflow-store.cjs +2 -2
- package/cjs/hovercard/hovercard-store.cjs +3 -3
- package/cjs/hovercard/hovercard-store.d.ts +3 -2
- package/cjs/menu/menu-store.cjs +3 -3
- package/cjs/popover/popover-store.cjs +2 -2
- package/cjs/popover/popover-store.d.ts +8 -89
- package/cjs/select/select-store.cjs +2 -2
- package/cjs/tooltip/tooltip-store.cjs +21 -68
- package/cjs/tooltip/tooltip-store.d.ts +20 -15
- package/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/esm/__chunks/{AHZW5LR4.js → 3BAGFTL5.js} +1 -1
- package/esm/__chunks/Z5IDQSMV.js +60 -0
- package/esm/combobox/combobox-store.js +1 -1
- package/esm/composite/composite-overflow-store.js +1 -1
- package/esm/hovercard/hovercard-store.d.ts +3 -2
- package/esm/hovercard/hovercard-store.js +2 -2
- package/esm/menu/menu-store.js +2 -2
- package/esm/popover/popover-store.d.ts +8 -89
- package/esm/popover/popover-store.js +1 -1
- package/esm/select/select-store.js +1 -1
- package/esm/tooltip/tooltip-store.d.ts +20 -15
- package/esm/tooltip/tooltip-store.js +22 -69
- package/esm/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/cjs/__chunks/SDBF6KIY.cjs +0 -1491
- package/esm/__chunks/CUW3E24J.js +0 -1491
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# @ariakit/core
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- **BREAKING**: Moved props from the `usePopoverStore` hook to the `Popover` component: `fixed`, `gutter`, `shift`, `flip`, `slide`, `overlap`, `sameWidth`, `fitViewport`, `arrowPadding`, `overflowPadding`, `getAnchorRect`, `renderCallback` (renamed to `updatePosition`). ([#2279](https://github.com/ariakit/ariakit/pull/2279))
|
|
8
|
+
|
|
9
|
+
The exception is the `placement` prop that should still be passed to the store.
|
|
10
|
+
|
|
11
|
+
**Before**:
|
|
12
|
+
|
|
13
|
+
```jsx
|
|
14
|
+
const popover = usePopoverStore({
|
|
15
|
+
placement: "bottom",
|
|
16
|
+
fixed: true,
|
|
17
|
+
gutter: 8,
|
|
18
|
+
shift: 8,
|
|
19
|
+
flip: true,
|
|
20
|
+
slide: true,
|
|
21
|
+
overlap: true,
|
|
22
|
+
sameWidth: true,
|
|
23
|
+
fitViewport: true,
|
|
24
|
+
arrowPadding: 8,
|
|
25
|
+
overflowPadding: 8,
|
|
26
|
+
getAnchorRect: (anchor) => anchor?.getBoundingClientRect(),
|
|
27
|
+
renderCallback: (props) => props.defaultRenderCallback(),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
<Popover store={popover} />;
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**After**:
|
|
34
|
+
|
|
35
|
+
```jsx
|
|
36
|
+
const popover = usePopoverStore({ placement: "bottom" });
|
|
37
|
+
|
|
38
|
+
<Popover
|
|
39
|
+
store={popover}
|
|
40
|
+
fixed
|
|
41
|
+
gutter={8}
|
|
42
|
+
shift={8}
|
|
43
|
+
flip
|
|
44
|
+
slide
|
|
45
|
+
overlap
|
|
46
|
+
sameWidth
|
|
47
|
+
fitViewport
|
|
48
|
+
arrowPadding={8}
|
|
49
|
+
overflowPadding={8}
|
|
50
|
+
getAnchorRect={(anchor) => anchor?.getBoundingClientRect()}
|
|
51
|
+
updatePosition={(props) => props.updatePosition()}
|
|
52
|
+
/>;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This change affects all the hooks and components that use `usePopoverStore` and `Popover` underneath: `useComboboxStore`, `ComboboxPopover`, `useHovercardStore`, `Hovercard`, `useMenuStore`, `Menu`, `useSelectStore`, `SelectPopover`, `useTooltipStore`, `Tooltip`.
|
|
56
|
+
|
|
57
|
+
With this change, the underlying `@floating-ui/dom` dependency has been also moved to the `Popover` component, which means it can be lazy loaded. See the [Lazy Popover](https://ariakit.org/examples/popover-lazy) example.
|
|
58
|
+
|
|
3
59
|
## 0.1.5
|
|
4
60
|
|
|
5
61
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _RD3S4VKYcjs = require('./RD3S4VKY.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _6SPJEESBcjs = require('./6SPJEESB.cjs');
|
|
@@ -17,7 +17,7 @@ function createHovercardStore(props = {}) {
|
|
|
17
17
|
var _a;
|
|
18
18
|
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
19
19
|
const timeout = _M6ZA7XUPcjs.defaultValue.call(void 0, props.timeout, syncState == null ? void 0 : syncState.timeout, 500);
|
|
20
|
-
const popover =
|
|
20
|
+
const popover = _RD3S4VKYcjs.createPopoverStore.call(void 0, _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, props), {
|
|
21
21
|
placement: _M6ZA7XUPcjs.defaultValue.call(void 0,
|
|
22
22
|
props.placement,
|
|
23
23
|
syncState == null ? void 0 : syncState.placement,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _HEFJPUYDcjs = require('./HEFJPUYD.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _6SPJEESBcjs = require('./6SPJEESB.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _M6ZA7XUPcjs = require('./M6ZA7XUP.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
var _6455U47Tcjs = require('./6455U47T.cjs');
|
|
16
|
+
|
|
17
|
+
// src/popover/popover-store.ts
|
|
18
|
+
function createPopoverStore(_a = {}) {
|
|
19
|
+
var _b = _a, {
|
|
20
|
+
popover: otherPopover
|
|
21
|
+
} = _b, props = _6455U47Tcjs.__objRest.call(void 0, _b, [
|
|
22
|
+
"popover"
|
|
23
|
+
]);
|
|
24
|
+
const store = _6SPJEESBcjs.mergeStore.call(void 0,
|
|
25
|
+
props.store,
|
|
26
|
+
otherPopover == null ? void 0 : otherPopover.omit(
|
|
27
|
+
"arrowElement",
|
|
28
|
+
"anchorElement",
|
|
29
|
+
"contentElement",
|
|
30
|
+
"popoverElement",
|
|
31
|
+
"disclosureElement"
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
const syncState = store == null ? void 0 : store.getState();
|
|
35
|
+
const dialog = _HEFJPUYDcjs.createDialogStore.call(void 0, _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, props), { store }));
|
|
36
|
+
const placement = _M6ZA7XUPcjs.defaultValue.call(void 0,
|
|
37
|
+
props.placement,
|
|
38
|
+
syncState == null ? void 0 : syncState.placement,
|
|
39
|
+
"bottom"
|
|
40
|
+
);
|
|
41
|
+
const initialState = _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, dialog.getState()), {
|
|
42
|
+
placement,
|
|
43
|
+
currentPlacement: placement,
|
|
44
|
+
anchorElement: _M6ZA7XUPcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.anchorElement, null),
|
|
45
|
+
popoverElement: _M6ZA7XUPcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.popoverElement, null),
|
|
46
|
+
arrowElement: _M6ZA7XUPcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.arrowElement, null),
|
|
47
|
+
rendered: Symbol("rendered")
|
|
48
|
+
});
|
|
49
|
+
const popover = _6SPJEESBcjs.createStore.call(void 0, initialState, dialog, store);
|
|
50
|
+
return _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, dialog), popover), {
|
|
51
|
+
setAnchorElement: (element) => popover.setState("anchorElement", element),
|
|
52
|
+
setPopoverElement: (element) => popover.setState("popoverElement", element),
|
|
53
|
+
setArrowElement: (element) => popover.setState("arrowElement", element),
|
|
54
|
+
render: () => popover.setState("rendered", Symbol("rendered"))
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
exports.createPopoverStore = createPopoverStore;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _RD3S4VKYcjs = require('../__chunks/RD3S4VKY.cjs');
|
|
4
4
|
require('../__chunks/HEFJPUYD.cjs');
|
|
5
5
|
require('../__chunks/27ZAGOYG.cjs');
|
|
6
6
|
|
|
@@ -86,7 +86,7 @@ function createComboboxStore(_a = {}) {
|
|
|
86
86
|
!isSafariOnMobile
|
|
87
87
|
)
|
|
88
88
|
}));
|
|
89
|
-
const popover =
|
|
89
|
+
const popover = _RD3S4VKYcjs.createPopoverStore.call(void 0, _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, props), {
|
|
90
90
|
store,
|
|
91
91
|
placement: _M6ZA7XUPcjs.defaultValue.call(void 0,
|
|
92
92
|
props.placement,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _RD3S4VKYcjs = require('../__chunks/RD3S4VKY.cjs');
|
|
4
4
|
require('../__chunks/HEFJPUYD.cjs');
|
|
5
5
|
require('../__chunks/27ZAGOYG.cjs');
|
|
6
6
|
require('../__chunks/6SPJEESB.cjs');
|
|
@@ -9,7 +9,7 @@ require('../__chunks/6455U47T.cjs');
|
|
|
9
9
|
|
|
10
10
|
// src/composite/composite-overflow-store.ts
|
|
11
11
|
function createCompositeOverflowStore(props = {}) {
|
|
12
|
-
return
|
|
12
|
+
return _RD3S4VKYcjs.createPopoverStore.call(void 0, props);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../__chunks/
|
|
3
|
+
var _CNODBYSGcjs = require('../__chunks/CNODBYSG.cjs');
|
|
4
|
+
require('../__chunks/RD3S4VKY.cjs');
|
|
5
5
|
require('../__chunks/HEFJPUYD.cjs');
|
|
6
6
|
require('../__chunks/27ZAGOYG.cjs');
|
|
7
7
|
require('../__chunks/6SPJEESB.cjs');
|
|
@@ -9,4 +9,4 @@ require('../__chunks/M6ZA7XUP.cjs');
|
|
|
9
9
|
require('../__chunks/6455U47T.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
exports.createHovercardStore =
|
|
12
|
+
exports.createHovercardStore = _CNODBYSGcjs.createHovercardStore;
|
|
@@ -11,8 +11,9 @@ export interface HovercardStoreState extends PopoverStoreState {
|
|
|
11
11
|
*/
|
|
12
12
|
placement: PopoverStoreState["placement"];
|
|
13
13
|
/**
|
|
14
|
-
* The amount of time in milliseconds to wait before showing
|
|
15
|
-
* popover.
|
|
14
|
+
* The amount of time in milliseconds to wait before showing and hiding the
|
|
15
|
+
* popover. To control the delay for showing and hiding separately, use
|
|
16
|
+
* `showTimeout` and `hideTimeout`.
|
|
16
17
|
* @default 500
|
|
17
18
|
*/
|
|
18
19
|
timeout: number;
|
package/cjs/menu/menu-store.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../__chunks/
|
|
3
|
+
var _CNODBYSGcjs = require('../__chunks/CNODBYSG.cjs');
|
|
4
|
+
require('../__chunks/RD3S4VKY.cjs');
|
|
5
5
|
require('../__chunks/HEFJPUYD.cjs');
|
|
6
6
|
require('../__chunks/27ZAGOYG.cjs');
|
|
7
7
|
|
|
@@ -50,7 +50,7 @@ function createMenuStore(_a = {}) {
|
|
|
50
50
|
"vertical"
|
|
51
51
|
)
|
|
52
52
|
}));
|
|
53
|
-
const hovercard =
|
|
53
|
+
const hovercard = _CNODBYSGcjs.createHovercardStore.call(void 0, _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, props), {
|
|
54
54
|
store,
|
|
55
55
|
placement: _M6ZA7XUPcjs.defaultValue.call(void 0,
|
|
56
56
|
props.placement,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _RD3S4VKYcjs = require('../__chunks/RD3S4VKY.cjs');
|
|
4
4
|
require('../__chunks/HEFJPUYD.cjs');
|
|
5
5
|
require('../__chunks/27ZAGOYG.cjs');
|
|
6
6
|
require('../__chunks/6SPJEESB.cjs');
|
|
@@ -8,4 +8,4 @@ require('../__chunks/M6ZA7XUP.cjs');
|
|
|
8
8
|
require('../__chunks/6455U47T.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
exports.createPopoverStore =
|
|
11
|
+
exports.createPopoverStore = _RD3S4VKYcjs.createPopoverStore;
|
|
@@ -3,27 +3,10 @@ import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
|
|
|
3
3
|
import type { SetState } from "../utils/types.js";
|
|
4
4
|
type BasePlacement = "top" | "bottom" | "left" | "right";
|
|
5
5
|
type Placement = BasePlacement | `${BasePlacement}-start` | `${BasePlacement}-end`;
|
|
6
|
-
type AnchorRect = {
|
|
7
|
-
x?: number;
|
|
8
|
-
y?: number;
|
|
9
|
-
width?: number;
|
|
10
|
-
height?: number;
|
|
11
|
-
};
|
|
12
6
|
/**
|
|
13
7
|
* Creates a popover store.
|
|
14
8
|
*/
|
|
15
|
-
export declare function createPopoverStore({
|
|
16
|
-
export interface PopoverStoreRenderCallbackProps extends Pick<PopoverStoreState, "anchorElement" | "popoverElement" | "arrowElement" | "mounted" | "placement" | "fixed" | "gutter" | "shift" | "overlap" | "flip" | "sameWidth" | "fitViewport" | "arrowPadding" | "overflowPadding"> {
|
|
17
|
-
/**
|
|
18
|
-
* A method that updates the `currentPlacement` state.
|
|
19
|
-
*/
|
|
20
|
-
setPlacement: SetState<Placement>;
|
|
21
|
-
/**
|
|
22
|
-
* The default render callback that will be called when the `renderCallback`
|
|
23
|
-
* prop is not provided.
|
|
24
|
-
*/
|
|
25
|
-
defaultRenderCallback: () => () => void;
|
|
26
|
-
}
|
|
9
|
+
export declare function createPopoverStore({ popover: otherPopover, ...props }?: PopoverStoreProps): PopoverStore;
|
|
27
10
|
export interface PopoverStoreState extends DialogStoreState {
|
|
28
11
|
/**
|
|
29
12
|
* The anchor element.
|
|
@@ -49,64 +32,10 @@ export interface PopoverStoreState extends DialogStoreState {
|
|
|
49
32
|
*/
|
|
50
33
|
placement: Placement;
|
|
51
34
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*/
|
|
55
|
-
fixed: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* The distance between the popover and the anchor element. By default, it's 0
|
|
58
|
-
* plus half of the arrow offset, if it exists.
|
|
35
|
+
* A symbol that's used to recompute the popover position when the `render`
|
|
36
|
+
* method is called.
|
|
59
37
|
*/
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* The skidding of the popover along the anchor element.
|
|
63
|
-
* @default 0
|
|
64
|
-
*/
|
|
65
|
-
shift: number;
|
|
66
|
-
/**
|
|
67
|
-
* Controls the behavior of the popover when it overflows the viewport:
|
|
68
|
-
* - If a `boolean`, specifies whether the popover should flip to the
|
|
69
|
-
* opposite side when it overflows.
|
|
70
|
-
* - If a `string`, indicates the preferred fallback placements when it
|
|
71
|
-
* overflows. The placements must be spaced-delimited, e.g. "top left".
|
|
72
|
-
* @default true
|
|
73
|
-
*/
|
|
74
|
-
flip: boolean | string;
|
|
75
|
-
/**
|
|
76
|
-
* Whether the popover should slide when it overflows.
|
|
77
|
-
* @default true
|
|
78
|
-
*/
|
|
79
|
-
slide: boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Whether the popover can overlap the anchor element when it overflows.
|
|
82
|
-
* @default false
|
|
83
|
-
*/
|
|
84
|
-
overlap: boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Whether the popover should have the same width as the anchor element. This
|
|
87
|
-
* will be exposed to CSS as `--popover-anchor-width`.
|
|
88
|
-
* @default false
|
|
89
|
-
*/
|
|
90
|
-
sameWidth: boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Whether the popover should fit the viewport. If this is set to true, the
|
|
93
|
-
* popover wrapper will have `maxWidth` and `maxHeight` set to the viewport
|
|
94
|
-
* size. This will be exposed to CSS as `--popover-available-width` and
|
|
95
|
-
* `--popover-available-height`.
|
|
96
|
-
* @default false
|
|
97
|
-
*/
|
|
98
|
-
fitViewport: boolean;
|
|
99
|
-
/**
|
|
100
|
-
* The minimum padding between the arrow and the popover corner.
|
|
101
|
-
* @default 4
|
|
102
|
-
*/
|
|
103
|
-
arrowPadding: number;
|
|
104
|
-
/**
|
|
105
|
-
* The minimum padding between the popover and the viewport edge. This will be
|
|
106
|
-
* exposed to CSS as `--popover-overflow-padding`.
|
|
107
|
-
* @default 8
|
|
108
|
-
*/
|
|
109
|
-
overflowPadding: number;
|
|
38
|
+
rendered: symbol;
|
|
110
39
|
}
|
|
111
40
|
export interface PopoverStoreFunctions extends DialogStoreFunctions {
|
|
112
41
|
/**
|
|
@@ -122,23 +51,13 @@ export interface PopoverStoreFunctions extends DialogStoreFunctions {
|
|
|
122
51
|
*/
|
|
123
52
|
setArrowElement: SetState<PopoverStoreState["arrowElement"]>;
|
|
124
53
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*/
|
|
129
|
-
getAnchorRect?: (anchor: HTMLElement | null) => AnchorRect | null;
|
|
130
|
-
/**
|
|
131
|
-
* A function that will be called when the popover needs to calculate its
|
|
132
|
-
* styles. It will override the internal behavior.
|
|
133
|
-
*/
|
|
134
|
-
renderCallback?: (props: PopoverStoreRenderCallbackProps) => void | (() => void);
|
|
135
|
-
/**
|
|
136
|
-
* A function that can be used to recompute the popover styles. This is useful
|
|
137
|
-
* when the popover anchor changes in a way that affects the popover position.
|
|
54
|
+
* A function that can be used to recompute the popover position. This is
|
|
55
|
+
* useful when the popover anchor changes in a way that affects the popover
|
|
56
|
+
* position.
|
|
138
57
|
*/
|
|
139
58
|
render: () => void;
|
|
140
59
|
}
|
|
141
|
-
export interface PopoverStoreOptions extends StoreOptions<PopoverStoreState, "placement"
|
|
60
|
+
export interface PopoverStoreOptions extends StoreOptions<PopoverStoreState, "placement">, DialogStoreOptions {
|
|
142
61
|
/**
|
|
143
62
|
* A reference to another popover store that's controlling another popover to
|
|
144
63
|
* keep them in sync.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _RD3S4VKYcjs = require('../__chunks/RD3S4VKY.cjs');
|
|
4
4
|
require('../__chunks/HEFJPUYD.cjs');
|
|
5
5
|
require('../__chunks/27ZAGOYG.cjs');
|
|
6
6
|
|
|
@@ -70,7 +70,7 @@ function createSelectStore(_a = {}) {
|
|
|
70
70
|
"vertical"
|
|
71
71
|
)
|
|
72
72
|
}));
|
|
73
|
-
const popover =
|
|
73
|
+
const popover = _RD3S4VKYcjs.createPopoverStore.call(void 0, _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, props), {
|
|
74
74
|
store,
|
|
75
75
|
placement: _M6ZA7XUPcjs.defaultValue.call(void 0,
|
|
76
76
|
props.placement,
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _CNODBYSGcjs = require('../__chunks/CNODBYSG.cjs');
|
|
4
|
+
require('../__chunks/RD3S4VKY.cjs');
|
|
4
5
|
require('../__chunks/HEFJPUYD.cjs');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _27ZAGOYGcjs = require('../__chunks/27ZAGOYG.cjs');
|
|
6
|
+
require('../__chunks/27ZAGOYG.cjs');
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
var _6SPJEESBcjs = require('../__chunks/6SPJEESB.cjs');
|
|
@@ -17,80 +16,34 @@ var _M6ZA7XUPcjs = require('../__chunks/M6ZA7XUP.cjs');
|
|
|
17
16
|
var _6455U47Tcjs = require('../__chunks/6455U47T.cjs');
|
|
18
17
|
|
|
19
18
|
// src/tooltip/tooltip-store.ts
|
|
20
|
-
var tooltips = _6SPJEESBcjs.createStore.call(void 0, { activeRef: null });
|
|
21
|
-
function afterTimeout(timeoutMs, cb) {
|
|
22
|
-
const timeoutId = setTimeout(cb, timeoutMs);
|
|
23
|
-
return () => clearTimeout(timeoutId);
|
|
24
|
-
}
|
|
25
19
|
function createTooltipStore(props = {}) {
|
|
26
20
|
var _a;
|
|
27
21
|
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
28
|
-
const
|
|
29
|
-
const disclosure = _27ZAGOYGcjs.createDisclosureStore.call(void 0, _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, props), { open }));
|
|
30
|
-
const popover = _SDBF6KIYcjs.createPopoverStore.call(void 0, _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, props), {
|
|
31
|
-
open,
|
|
22
|
+
const hovercard = _CNODBYSGcjs.createHovercardStore.call(void 0, _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, props), {
|
|
32
23
|
placement: _M6ZA7XUPcjs.defaultValue.call(void 0,
|
|
33
24
|
props.placement,
|
|
34
25
|
syncState == null ? void 0 : syncState.placement,
|
|
35
26
|
"top"
|
|
36
27
|
),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const ref = Symbol();
|
|
49
|
-
tooltip.setup(
|
|
50
|
-
() => disclosure.sync(
|
|
51
|
-
(state, prev) => {
|
|
52
|
-
const { timeout } = tooltip.getState();
|
|
53
|
-
const { activeRef } = tooltips.getState();
|
|
54
|
-
if (state.open) {
|
|
55
|
-
if (!timeout || activeRef) {
|
|
56
|
-
tooltips.setState("activeRef", ref);
|
|
57
|
-
tooltip.setState("open", true);
|
|
58
|
-
return;
|
|
59
|
-
} else {
|
|
60
|
-
tooltips.setState("activeRef", null);
|
|
61
|
-
return afterTimeout(timeout, () => {
|
|
62
|
-
tooltips.setState("activeRef", ref);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
} else if (state.open !== prev.open) {
|
|
66
|
-
tooltip.setState("open", false);
|
|
67
|
-
return afterTimeout(timeout, () => {
|
|
68
|
-
tooltips.setState(
|
|
69
|
-
"activeRef",
|
|
70
|
-
(activeRef2) => activeRef2 === ref ? null : activeRef2
|
|
71
|
-
);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
return;
|
|
75
|
-
},
|
|
76
|
-
["open"]
|
|
77
|
-
)
|
|
78
|
-
);
|
|
79
|
-
tooltip.setup(
|
|
80
|
-
() => tooltips.sync(
|
|
81
|
-
(state) => {
|
|
82
|
-
tooltip.setState("open", state.activeRef === ref);
|
|
83
|
-
},
|
|
84
|
-
["activeRef"]
|
|
28
|
+
showTimeout: _M6ZA7XUPcjs.defaultValue.call(void 0,
|
|
29
|
+
props.showTimeout,
|
|
30
|
+
syncState == null ? void 0 : syncState.showTimeout,
|
|
31
|
+
props.timeout,
|
|
32
|
+
500
|
|
33
|
+
),
|
|
34
|
+
hideTimeout: _M6ZA7XUPcjs.defaultValue.call(void 0,
|
|
35
|
+
props.hideTimeout,
|
|
36
|
+
syncState == null ? void 0 : syncState.hideTimeout,
|
|
37
|
+
props.timeout,
|
|
38
|
+
0
|
|
85
39
|
)
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
(activeRef) => activeRef === ref ? null : activeRef
|
|
91
|
-
);
|
|
40
|
+
}));
|
|
41
|
+
const initialState = _6455U47Tcjs.__spreadProps.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, hovercard.getState()), {
|
|
42
|
+
type: _M6ZA7XUPcjs.defaultValue.call(void 0, props.type, syncState == null ? void 0 : syncState.type, "description"),
|
|
43
|
+
skipTimeout: _M6ZA7XUPcjs.defaultValue.call(void 0, props.skipTimeout, syncState == null ? void 0 : syncState.skipTimeout, 300)
|
|
92
44
|
});
|
|
93
|
-
|
|
45
|
+
const tooltip = _6SPJEESBcjs.createStore.call(void 0, initialState, hovercard, props.store);
|
|
46
|
+
return _6455U47Tcjs.__spreadValues.call(void 0, _6455U47Tcjs.__spreadValues.call(void 0, {}, hovercard), tooltip);
|
|
94
47
|
}
|
|
95
48
|
|
|
96
49
|
|
|
@@ -1,28 +1,33 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HovercardStoreFunctions, HovercardStoreOptions, HovercardStoreState } from "../hovercard/hovercard-store.js";
|
|
2
2
|
import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a tooltip store.
|
|
5
5
|
*/
|
|
6
6
|
export declare function createTooltipStore(props?: TooltipStoreProps): TooltipStore;
|
|
7
|
-
export interface TooltipStoreState extends
|
|
7
|
+
export interface TooltipStoreState extends HovercardStoreState {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Determines whether the tooltip is being used as a label or a description
|
|
10
|
+
* for the anchor element.
|
|
11
|
+
* @default "description"
|
|
10
12
|
*/
|
|
11
|
-
|
|
13
|
+
type: "label" | "description";
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
15
|
+
* The amount of time after a tooltip is hidden while all tooltips on the
|
|
16
|
+
* page can be shown immediately, without waiting for the show timeout.
|
|
17
|
+
* @default 300
|
|
14
18
|
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
skipTimeout: number;
|
|
20
|
+
/** @default "top" */
|
|
21
|
+
placement: HovercardStoreState["placement"];
|
|
22
|
+
/** @default 0 */
|
|
23
|
+
timeout: HovercardStoreState["timeout"];
|
|
24
|
+
/** @default 500 */
|
|
25
|
+
showTimeout: HovercardStoreState["showTimeout"];
|
|
26
|
+
/** @default 0 */
|
|
27
|
+
hideTimeout: HovercardStoreState["hideTimeout"];
|
|
23
28
|
}
|
|
24
|
-
export type TooltipStoreFunctions =
|
|
25
|
-
export interface TooltipStoreOptions extends StoreOptions<TooltipStoreState, "
|
|
29
|
+
export type TooltipStoreFunctions = HovercardStoreFunctions;
|
|
30
|
+
export interface TooltipStoreOptions extends StoreOptions<TooltipStoreState, "type" | "placement" | "timeout" | "showTimeout" | "hideTimeout" | "skipTimeout">, HovercardStoreOptions {
|
|
26
31
|
}
|
|
27
32
|
export type TooltipStoreProps = TooltipStoreOptions & StoreProps<TooltipStoreState>;
|
|
28
33
|
export type TooltipStore = TooltipStoreFunctions & Store<TooltipStoreState>;
|