@ariakit/core 0.3.3 → 0.3.4
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 +12 -0
- package/cjs/__chunks/{W5IQT6Z2.cjs → 25WWT2VO.cjs} +17 -16
- package/cjs/__chunks/{EXM2AW52.cjs → FTB5CXVB.cjs} +3 -1
- package/cjs/__chunks/{EIRIJC7T.cjs → G5EW4WED.cjs} +8 -7
- package/cjs/__chunks/{RCYVACJO.cjs → LMT335NJ.cjs} +9 -4
- package/cjs/__chunks/LUOEAZGU.cjs +42 -0
- package/cjs/__chunks/{TTWS4MDC.cjs → M44E4T5A.cjs} +30 -29
- package/cjs/__chunks/{DFFIYGBS.cjs → MLPOXRDT.cjs} +4 -3
- package/cjs/__chunks/{A4GDJCZB.cjs → OASSVCYR.cjs} +18 -17
- package/cjs/__chunks/{ZYIEFAMB.cjs → ROX3MRGO.cjs} +18 -17
- package/cjs/__chunks/{GDZQUFNP.cjs → ULSPM3Y3.cjs} +3 -1
- package/cjs/__chunks/{72I2GWXF.cjs → WYXAWBLE.cjs} +2 -1
- package/cjs/__chunks/{A7K3KZJL.cjs → YXSGST3H.cjs} +20 -19
- package/cjs/checkbox/checkbox-store.cjs +9 -8
- package/cjs/checkbox/checkbox-store.d.cts +41 -0
- package/cjs/collection/collection-store.cjs +8 -7
- package/cjs/collection/collection-store.d.cts +65 -0
- package/cjs/combobox/combobox-store.cjs +37 -36
- package/cjs/combobox/combobox-store.d.cts +77 -0
- package/cjs/composite/composite-overflow-store.cjs +9 -8
- package/cjs/composite/composite-overflow-store.d.cts +10 -0
- package/cjs/composite/composite-store.cjs +10 -9
- package/cjs/composite/composite-store.d.cts +206 -0
- package/cjs/dialog/dialog-store.cjs +8 -7
- package/cjs/dialog/dialog-store.d.cts +10 -0
- package/cjs/disclosure/disclosure-store.cjs +7 -6
- package/cjs/disclosure/disclosure-store.d.cts +125 -0
- package/cjs/form/form-store.cjs +30 -29
- package/cjs/form/form-store.d.cts +236 -0
- package/cjs/form/types.cjs +1 -1
- package/cjs/form/types.d.cts +38 -0
- package/cjs/hovercard/hovercard-store.cjs +10 -9
- package/cjs/hovercard/hovercard-store.d.cts +46 -0
- package/cjs/index.cjs +2 -1
- package/cjs/index.d.cts +2 -0
- package/cjs/menu/menu-bar-store.cjs +12 -11
- package/cjs/menu/menu-bar-store.d.cts +10 -0
- package/cjs/menu/menu-store.cjs +35 -34
- package/cjs/menu/menu-store.d.cts +78 -0
- package/cjs/popover/popover-store.cjs +9 -8
- package/cjs/popover/popover-store.d.cts +69 -0
- package/cjs/radio/radio-store.cjs +16 -15
- package/cjs/radio/radio-store.d.cts +36 -0
- package/cjs/select/select-store.cjs +37 -36
- package/cjs/select/select-store.d.cts +93 -0
- package/cjs/tab/tab-store.cjs +28 -27
- package/cjs/tab/tab-store.d.cts +87 -0
- package/cjs/toolbar/toolbar-store.cjs +12 -11
- package/cjs/toolbar/toolbar-store.d.cts +21 -0
- package/cjs/tooltip/tooltip-store.cjs +17 -16
- package/cjs/tooltip/tooltip-store.d.cts +29 -0
- package/cjs/utils/array.cjs +5 -4
- package/cjs/utils/array.d.cts +29 -0
- package/cjs/utils/dom.cjs +5 -4
- package/cjs/utils/dom.d.cts +105 -0
- package/cjs/utils/events.cjs +10 -9
- package/cjs/utils/events.d.cts +70 -0
- package/cjs/utils/focus.cjs +17 -16
- package/cjs/utils/focus.d.cts +117 -0
- package/cjs/utils/misc.cjs +7 -4
- package/cjs/utils/misc.d.cts +124 -0
- package/cjs/utils/misc.d.ts +7 -0
- package/cjs/utils/platform.cjs +6 -5
- package/cjs/utils/platform.d.cts +20 -0
- package/cjs/utils/store.cjs +6 -5
- package/cjs/utils/store.d.cts +71 -0
- package/cjs/utils/types.cjs +1 -1
- package/cjs/utils/types.d.cts +74 -0
- package/esm/__chunks/{PNRLI7OV.js → 2SMRF6AD.js} +1 -0
- package/esm/__chunks/{UCFCIHEU.js → 5UJPJ37G.js} +2 -1
- package/esm/__chunks/{5XEKIOCW.js → 7PRQYBBV.js} +2 -0
- package/esm/__chunks/{WVTCK5PV.js → D23ES3Z4.js} +6 -1
- package/esm/__chunks/{E6THWJ7N.js → FGW7QUD2.js} +6 -5
- package/esm/__chunks/{Y5SJEQQJ.js → GME4NYXR.js} +3 -2
- package/esm/__chunks/{HN27WCTM.js → I7YGHQ4Z.js} +2 -1
- package/esm/__chunks/{L4QLJSLG.js → LWQU4J4N.js} +5 -4
- package/esm/__chunks/{O35LWD4W.js → NIF7E7VE.js} +2 -0
- package/esm/__chunks/{C57Q2UMF.js → Q332EHXG.js} +5 -4
- package/esm/__chunks/{A2MHRHOV.js → TEJLMP2M.js} +4 -3
- package/esm/__chunks/{JLNC5RR2.js → VEWADM34.js} +5 -4
- package/esm/checkbox/checkbox-store.js +4 -3
- package/esm/collection/collection-store.js +6 -5
- package/esm/combobox/combobox-store.js +12 -11
- package/esm/composite/composite-overflow-store.js +7 -6
- package/esm/composite/composite-store.js +8 -7
- package/esm/dialog/dialog-store.js +6 -5
- package/esm/disclosure/disclosure-store.js +5 -4
- package/esm/form/form-store.js +6 -5
- package/esm/form/types.js +1 -0
- package/esm/hovercard/hovercard-store.js +8 -7
- package/esm/index.js +2 -1
- package/esm/menu/menu-bar-store.js +8 -7
- package/esm/menu/menu-store.js +12 -11
- package/esm/popover/popover-store.js +7 -6
- package/esm/radio/radio-store.js +8 -7
- package/esm/select/select-store.js +11 -10
- package/esm/tab/tab-store.js +8 -7
- package/esm/toolbar/toolbar-store.js +8 -7
- package/esm/tooltip/tooltip-store.js +8 -7
- package/esm/utils/array.js +3 -2
- package/esm/utils/dom.js +3 -2
- package/esm/utils/events.js +4 -3
- package/esm/utils/focus.js +3 -2
- package/esm/utils/misc.d.ts +7 -0
- package/esm/utils/misc.js +5 -2
- package/esm/utils/platform.js +4 -3
- package/esm/utils/store.js +4 -3
- package/esm/utils/types.js +1 -0
- package/package.json +109 -28
- package/cjs/__chunks/NEBQQIUX.cjs +0 -41
- package/cjs/tsconfig.build.tsbuildinfo +0 -1
- package/esm/tsconfig.build.tsbuildinfo +0 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { DialogStoreFunctions, DialogStoreOptions, DialogStoreState } from "../dialog/dialog-store.js";
|
|
2
|
+
import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
|
|
3
|
+
import type { SetState } from "../utils/types.js";
|
|
4
|
+
type BasePlacement = "top" | "bottom" | "left" | "right";
|
|
5
|
+
type Placement = BasePlacement | `${BasePlacement}-start` | `${BasePlacement}-end`;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a popover store.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createPopoverStore({ popover: otherPopover, ...props }?: PopoverStoreProps): PopoverStore;
|
|
10
|
+
export interface PopoverStoreState extends DialogStoreState {
|
|
11
|
+
/**
|
|
12
|
+
* The anchor element.
|
|
13
|
+
*/
|
|
14
|
+
anchorElement: HTMLElement | null;
|
|
15
|
+
/**
|
|
16
|
+
* The popover element that will render the placement attributes.
|
|
17
|
+
*/
|
|
18
|
+
popoverElement: HTMLElement | null;
|
|
19
|
+
/**
|
|
20
|
+
* The arrow element.
|
|
21
|
+
*/
|
|
22
|
+
arrowElement: HTMLElement | null;
|
|
23
|
+
/**
|
|
24
|
+
* The current temporary placement state of the popover. This may be different
|
|
25
|
+
* from the the `placement` state if the popover has needed to update its
|
|
26
|
+
* position on the fly.
|
|
27
|
+
*/
|
|
28
|
+
currentPlacement: Placement;
|
|
29
|
+
/**
|
|
30
|
+
* The placement of the popover.
|
|
31
|
+
* @default "bottom"
|
|
32
|
+
*/
|
|
33
|
+
placement: Placement;
|
|
34
|
+
/**
|
|
35
|
+
* A symbol that's used to recompute the popover position when the `render`
|
|
36
|
+
* method is called.
|
|
37
|
+
*/
|
|
38
|
+
rendered: symbol;
|
|
39
|
+
}
|
|
40
|
+
export interface PopoverStoreFunctions extends DialogStoreFunctions {
|
|
41
|
+
/**
|
|
42
|
+
* Sets the anchor element.
|
|
43
|
+
*/
|
|
44
|
+
setAnchorElement: SetState<PopoverStoreState["anchorElement"]>;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the popover element.
|
|
47
|
+
*/
|
|
48
|
+
setPopoverElement: SetState<PopoverStoreState["popoverElement"]>;
|
|
49
|
+
/**
|
|
50
|
+
* Sets the arrow element.
|
|
51
|
+
*/
|
|
52
|
+
setArrowElement: SetState<PopoverStoreState["arrowElement"]>;
|
|
53
|
+
/**
|
|
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.
|
|
57
|
+
*/
|
|
58
|
+
render: () => void;
|
|
59
|
+
}
|
|
60
|
+
export interface PopoverStoreOptions extends StoreOptions<PopoverStoreState, "placement">, DialogStoreOptions {
|
|
61
|
+
/**
|
|
62
|
+
* A reference to another popover store that's controlling another popover to
|
|
63
|
+
* keep them in sync.
|
|
64
|
+
*/
|
|
65
|
+
popover?: PopoverStore | null;
|
|
66
|
+
}
|
|
67
|
+
export type PopoverStoreProps = PopoverStoreOptions & StoreProps<PopoverStoreState>;
|
|
68
|
+
export type PopoverStore = PopoverStoreFunctions & Store<PopoverStoreState>;
|
|
69
|
+
export {};
|
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
|
-
var _TTWS4MDCcjs = require('../__chunks/TTWS4MDC.cjs');
|
|
4
|
-
require('../__chunks/W5IQT6Z2.cjs');
|
|
5
3
|
|
|
4
|
+
var _M44E4T5Acjs = require('../__chunks/M44E4T5A.cjs');
|
|
5
|
+
require('../__chunks/25WWT2VO.cjs');
|
|
6
6
|
|
|
7
|
-
var _A4GDJCZBcjs = require('../__chunks/A4GDJCZB.cjs');
|
|
8
7
|
|
|
8
|
+
var _OASSVCYRcjs = require('../__chunks/OASSVCYR.cjs');
|
|
9
9
|
|
|
10
|
-
var _RCYVACJOcjs = require('../__chunks/RCYVACJO.cjs');
|
|
11
|
-
require('../__chunks/EXM2AW52.cjs');
|
|
12
|
-
require('../__chunks/GDZQUFNP.cjs');
|
|
13
10
|
|
|
11
|
+
var _LMT335NJcjs = require('../__chunks/LMT335NJ.cjs');
|
|
12
|
+
require('../__chunks/FTB5CXVB.cjs');
|
|
13
|
+
require('../__chunks/ULSPM3Y3.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
var _WYXAWBLEcjs = require('../__chunks/WYXAWBLE.cjs');
|
|
18
19
|
|
|
19
20
|
// src/radio/radio-store.ts
|
|
20
21
|
function createRadioStore(_a = {}) {
|
|
21
|
-
var props =
|
|
22
|
+
var props = _WYXAWBLEcjs.__objRest.call(void 0, _a, []);
|
|
22
23
|
var _a2;
|
|
23
24
|
const syncState = (_a2 = props.store) == null ? void 0 : _a2.getState();
|
|
24
|
-
const composite =
|
|
25
|
-
focusLoop:
|
|
25
|
+
const composite = _M44E4T5Acjs.createCompositeStore.call(void 0, _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
26
|
+
focusLoop: _LMT335NJcjs.defaultValue.call(void 0, props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true)
|
|
26
27
|
}));
|
|
27
|
-
const initialState =
|
|
28
|
-
value:
|
|
28
|
+
const initialState = _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, composite.getState()), {
|
|
29
|
+
value: _LMT335NJcjs.defaultValue.call(void 0,
|
|
29
30
|
props.value,
|
|
30
31
|
syncState == null ? void 0 : syncState.value,
|
|
31
32
|
props.defaultValue,
|
|
32
33
|
null
|
|
33
34
|
)
|
|
34
35
|
});
|
|
35
|
-
const radio =
|
|
36
|
-
return
|
|
36
|
+
const radio = _OASSVCYRcjs.createStore.call(void 0, initialState, composite, props.store);
|
|
37
|
+
return _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, composite), radio), {
|
|
37
38
|
setValue: (value) => radio.setState("value", value)
|
|
38
39
|
});
|
|
39
40
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
|
|
2
|
+
import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
|
|
3
|
+
import type { SetState } from "../utils/types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a radio store.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createRadioStore({ ...props }?: RadioStoreProps): RadioStore;
|
|
8
|
+
export interface RadioStoreState extends CompositeStoreState {
|
|
9
|
+
/**
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
focusLoop: CompositeStoreState["focusLoop"];
|
|
13
|
+
/**
|
|
14
|
+
* The value of the radio group.
|
|
15
|
+
* @default null
|
|
16
|
+
*/
|
|
17
|
+
value: string | number | null;
|
|
18
|
+
}
|
|
19
|
+
export interface RadioStoreFunctions extends CompositeStoreFunctions {
|
|
20
|
+
/**
|
|
21
|
+
* Sets the `value` state.
|
|
22
|
+
* @example
|
|
23
|
+
* store.setValue("apple");
|
|
24
|
+
* store.setValue((value) => value === "apple" ? "orange" : "apple");
|
|
25
|
+
*/
|
|
26
|
+
setValue: SetState<RadioStoreState["value"]>;
|
|
27
|
+
}
|
|
28
|
+
export interface RadioStoreOptions extends StoreOptions<RadioStoreState, "focusLoop" | "value">, CompositeStoreOptions {
|
|
29
|
+
/**
|
|
30
|
+
* The default value of the radio group.
|
|
31
|
+
* @default null
|
|
32
|
+
*/
|
|
33
|
+
defaultValue?: RadioStoreState["value"];
|
|
34
|
+
}
|
|
35
|
+
export type RadioStoreProps = RadioStoreOptions & StoreProps<RadioStoreState>;
|
|
36
|
+
export type RadioStore = RadioStoreFunctions & Store<RadioStoreState>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
|
-
var _ZYIEFAMBcjs = require('../__chunks/ZYIEFAMB.cjs');
|
|
4
|
-
require('../__chunks/DFFIYGBS.cjs');
|
|
5
|
-
require('../__chunks/A7K3KZJL.cjs');
|
|
6
3
|
|
|
4
|
+
var _ROX3MRGOcjs = require('../__chunks/ROX3MRGO.cjs');
|
|
5
|
+
require('../__chunks/MLPOXRDT.cjs');
|
|
6
|
+
require('../__chunks/YXSGST3H.cjs');
|
|
7
7
|
|
|
8
|
-
var _TTWS4MDCcjs = require('../__chunks/TTWS4MDC.cjs');
|
|
9
|
-
require('../__chunks/W5IQT6Z2.cjs');
|
|
10
8
|
|
|
9
|
+
var _M44E4T5Acjs = require('../__chunks/M44E4T5A.cjs');
|
|
10
|
+
require('../__chunks/25WWT2VO.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -15,30 +15,31 @@ require('../__chunks/W5IQT6Z2.cjs');
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
var _A4GDJCZBcjs = require('../__chunks/A4GDJCZB.cjs');
|
|
19
18
|
|
|
19
|
+
var _OASSVCYRcjs = require('../__chunks/OASSVCYR.cjs');
|
|
20
20
|
|
|
21
|
-
var _RCYVACJOcjs = require('../__chunks/RCYVACJO.cjs');
|
|
22
|
-
require('../__chunks/EXM2AW52.cjs');
|
|
23
21
|
|
|
22
|
+
var _LMT335NJcjs = require('../__chunks/LMT335NJ.cjs');
|
|
23
|
+
require('../__chunks/FTB5CXVB.cjs');
|
|
24
24
|
|
|
25
|
-
var _GDZQUFNPcjs = require('../__chunks/GDZQUFNP.cjs');
|
|
26
25
|
|
|
26
|
+
var _ULSPM3Y3cjs = require('../__chunks/ULSPM3Y3.cjs');
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
var _WYXAWBLEcjs = require('../__chunks/WYXAWBLE.cjs');
|
|
31
32
|
|
|
32
33
|
// src/select/select-store.ts
|
|
33
34
|
function createSelectStore(_a = {}) {
|
|
34
35
|
var _b = _a, {
|
|
35
36
|
combobox
|
|
36
|
-
} = _b, props =
|
|
37
|
+
} = _b, props = _WYXAWBLEcjs.__objRest.call(void 0, _b, [
|
|
37
38
|
"combobox"
|
|
38
39
|
]);
|
|
39
|
-
const store =
|
|
40
|
+
const store = _OASSVCYRcjs.mergeStore.call(void 0,
|
|
40
41
|
props.store,
|
|
41
|
-
|
|
42
|
+
_OASSVCYRcjs.omit.call(void 0, combobox, [
|
|
42
43
|
"value",
|
|
43
44
|
"items",
|
|
44
45
|
"renderedItems",
|
|
@@ -50,60 +51,60 @@ function createSelectStore(_a = {}) {
|
|
|
50
51
|
"disclosureElement"
|
|
51
52
|
])
|
|
52
53
|
);
|
|
53
|
-
|
|
54
|
+
_OASSVCYRcjs.throwOnConflictingProps.call(void 0, props, store);
|
|
54
55
|
const syncState = store.getState();
|
|
55
|
-
const composite =
|
|
56
|
+
const composite = _M44E4T5Acjs.createCompositeStore.call(void 0, _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
56
57
|
store,
|
|
57
|
-
virtualFocus:
|
|
58
|
+
virtualFocus: _LMT335NJcjs.defaultValue.call(void 0,
|
|
58
59
|
props.virtualFocus,
|
|
59
60
|
syncState.virtualFocus,
|
|
60
61
|
true
|
|
61
62
|
),
|
|
62
|
-
includesBaseElement:
|
|
63
|
+
includesBaseElement: _LMT335NJcjs.defaultValue.call(void 0,
|
|
63
64
|
props.includesBaseElement,
|
|
64
65
|
syncState.includesBaseElement,
|
|
65
66
|
false
|
|
66
67
|
),
|
|
67
|
-
activeId:
|
|
68
|
+
activeId: _LMT335NJcjs.defaultValue.call(void 0,
|
|
68
69
|
props.activeId,
|
|
69
70
|
syncState.activeId,
|
|
70
71
|
props.defaultActiveId,
|
|
71
72
|
null
|
|
72
73
|
),
|
|
73
|
-
orientation:
|
|
74
|
+
orientation: _LMT335NJcjs.defaultValue.call(void 0,
|
|
74
75
|
props.orientation,
|
|
75
76
|
syncState.orientation,
|
|
76
77
|
"vertical"
|
|
77
78
|
)
|
|
78
79
|
}));
|
|
79
|
-
const popover =
|
|
80
|
+
const popover = _ROX3MRGOcjs.createPopoverStore.call(void 0, _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
80
81
|
store,
|
|
81
|
-
placement:
|
|
82
|
+
placement: _LMT335NJcjs.defaultValue.call(void 0,
|
|
82
83
|
props.placement,
|
|
83
84
|
syncState.placement,
|
|
84
85
|
"bottom-start"
|
|
85
86
|
)
|
|
86
87
|
}));
|
|
87
88
|
const initialValue = new String("");
|
|
88
|
-
const initialState =
|
|
89
|
-
value:
|
|
89
|
+
const initialState = _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, composite.getState()), popover.getState()), {
|
|
90
|
+
value: _LMT335NJcjs.defaultValue.call(void 0,
|
|
90
91
|
props.value,
|
|
91
92
|
syncState.value,
|
|
92
93
|
props.defaultValue,
|
|
93
94
|
initialValue
|
|
94
95
|
),
|
|
95
|
-
setValueOnMove:
|
|
96
|
+
setValueOnMove: _LMT335NJcjs.defaultValue.call(void 0,
|
|
96
97
|
props.setValueOnMove,
|
|
97
98
|
syncState.setValueOnMove,
|
|
98
99
|
false
|
|
99
100
|
),
|
|
100
|
-
selectElement:
|
|
101
|
-
labelElement:
|
|
101
|
+
selectElement: _LMT335NJcjs.defaultValue.call(void 0, syncState.selectElement, null),
|
|
102
|
+
labelElement: _LMT335NJcjs.defaultValue.call(void 0, syncState.labelElement, null)
|
|
102
103
|
});
|
|
103
|
-
const select =
|
|
104
|
-
|
|
104
|
+
const select = _OASSVCYRcjs.createStore.call(void 0, initialState, composite, popover, store);
|
|
105
|
+
_OASSVCYRcjs.setup.call(void 0,
|
|
105
106
|
select,
|
|
106
|
-
() =>
|
|
107
|
+
() => _OASSVCYRcjs.sync.call(void 0, select, ["value", "items"], (state) => {
|
|
107
108
|
if (state.value !== initialValue)
|
|
108
109
|
return;
|
|
109
110
|
if (!state.items.length)
|
|
@@ -116,14 +117,14 @@ function createSelectStore(_a = {}) {
|
|
|
116
117
|
select.setState("value", item.value);
|
|
117
118
|
})
|
|
118
119
|
);
|
|
119
|
-
|
|
120
|
+
_OASSVCYRcjs.setup.call(void 0,
|
|
120
121
|
select,
|
|
121
|
-
() =>
|
|
122
|
+
() => _OASSVCYRcjs.sync.call(void 0, select, ["mounted", "items", "value"], (state) => {
|
|
122
123
|
if (combobox)
|
|
123
124
|
return;
|
|
124
125
|
if (state.mounted)
|
|
125
126
|
return;
|
|
126
|
-
const values =
|
|
127
|
+
const values = _ULSPM3Y3cjs.toArray.call(void 0, state.value);
|
|
127
128
|
const lastValue = values[values.length - 1];
|
|
128
129
|
if (lastValue == null)
|
|
129
130
|
return;
|
|
@@ -135,9 +136,9 @@ function createSelectStore(_a = {}) {
|
|
|
135
136
|
select.setState("activeId", item.id);
|
|
136
137
|
})
|
|
137
138
|
);
|
|
138
|
-
|
|
139
|
+
_OASSVCYRcjs.setup.call(void 0,
|
|
139
140
|
select,
|
|
140
|
-
() =>
|
|
141
|
+
() => _OASSVCYRcjs.batch.call(void 0, select, ["setValueOnMove", "moves"], (state) => {
|
|
141
142
|
const { mounted, value, activeId } = select.getState();
|
|
142
143
|
if (!state.setValueOnMove && mounted)
|
|
143
144
|
return;
|
|
@@ -153,7 +154,7 @@ function createSelectStore(_a = {}) {
|
|
|
153
154
|
select.setState("value", item.value);
|
|
154
155
|
})
|
|
155
156
|
);
|
|
156
|
-
return
|
|
157
|
+
return _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, composite), popover), select), {
|
|
157
158
|
combobox,
|
|
158
159
|
setValue: (value) => select.setState("value", value),
|
|
159
160
|
setSelectElement: (element) => select.setState("selectElement", element),
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { ComboboxStore } from "../combobox/combobox-store.js";
|
|
2
|
+
import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
|
|
3
|
+
import type { PopoverStoreFunctions, PopoverStoreOptions, PopoverStoreState } from "../popover/popover-store.js";
|
|
4
|
+
import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
|
|
5
|
+
import type { PickRequired, SetState } from "../utils/types.js";
|
|
6
|
+
type Value = string | string[];
|
|
7
|
+
type MutableValue<T extends Value = Value> = T extends string ? string : T;
|
|
8
|
+
type Item = CompositeStoreItem & {
|
|
9
|
+
value?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function createSelectStore<T extends Value = Value>(props: PickRequired<SelectStoreProps<T>, "value" | "defaultValue">): SelectStore<T>;
|
|
12
|
+
export declare function createSelectStore(props?: SelectStoreProps): SelectStore;
|
|
13
|
+
export type SelectStoreItem = Item;
|
|
14
|
+
export type SelectStoreValue = Value;
|
|
15
|
+
export interface SelectStoreState<T extends Value = Value> extends CompositeStoreState<Item>, PopoverStoreState {
|
|
16
|
+
/** @default true */
|
|
17
|
+
virtualFocus: CompositeStoreState<Item>["virtualFocus"];
|
|
18
|
+
/** @default false */
|
|
19
|
+
includesBaseElement: CompositeStoreState<Item>["includesBaseElement"];
|
|
20
|
+
/** @default null */
|
|
21
|
+
activeId: CompositeStoreState<Item>["activeId"];
|
|
22
|
+
/** @default "vertical" */
|
|
23
|
+
orientation: CompositeStoreState<Item>["orientation"];
|
|
24
|
+
/** @default "bottom-start" */
|
|
25
|
+
placement: PopoverStoreState["placement"];
|
|
26
|
+
/**
|
|
27
|
+
* The select value.
|
|
28
|
+
*
|
|
29
|
+
* Live examples:
|
|
30
|
+
* - [Multi-selectable
|
|
31
|
+
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
32
|
+
*/
|
|
33
|
+
value: MutableValue<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the select value should be set when the active item changes by
|
|
36
|
+
* moving (which usually happens when moving to an item using the keyboard).
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
setValueOnMove: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The select button element.
|
|
42
|
+
*/
|
|
43
|
+
selectElement: HTMLElement | null;
|
|
44
|
+
/**
|
|
45
|
+
* The select label element.
|
|
46
|
+
*/
|
|
47
|
+
labelElement: HTMLElement | null;
|
|
48
|
+
}
|
|
49
|
+
export interface SelectStoreFunctions<T extends Value = Value> extends Pick<SelectStoreOptions<T>, "combobox">, CompositeStoreFunctions<Item>, PopoverStoreFunctions {
|
|
50
|
+
/**
|
|
51
|
+
* Sets the `value` state.
|
|
52
|
+
*
|
|
53
|
+
* Live examples:
|
|
54
|
+
* - [Multi-selectable
|
|
55
|
+
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
56
|
+
* @example
|
|
57
|
+
* store.setValue("Apple");
|
|
58
|
+
* store.setValue(["Apple", "Banana"]);
|
|
59
|
+
* store.setValue((value) => value === "Apple" ? "Banana" : "Apple"));
|
|
60
|
+
*/
|
|
61
|
+
setValue: SetState<SelectStoreState<T>["value"]>;
|
|
62
|
+
/**
|
|
63
|
+
* Sets the `selectElement` state.
|
|
64
|
+
*/
|
|
65
|
+
setSelectElement: SetState<SelectStoreState<T>["selectElement"]>;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the `labelElement` state.
|
|
68
|
+
*/
|
|
69
|
+
setLabelElement: SetState<SelectStoreState<T>["labelElement"]>;
|
|
70
|
+
}
|
|
71
|
+
export interface SelectStoreOptions<T extends Value = Value> extends StoreOptions<SelectStoreState<T>, "virtualFocus" | "includesBaseElement" | "activeId" | "orientation" | "placement" | "value" | "setValueOnMove">, CompositeStoreOptions<Item>, PopoverStoreOptions {
|
|
72
|
+
/**
|
|
73
|
+
* A reference to a combobox store. This is used when combining the combobox
|
|
74
|
+
* with a select (e.g., select with a search input). The stores will share the
|
|
75
|
+
* same state.
|
|
76
|
+
*
|
|
77
|
+
* Live examples:
|
|
78
|
+
* - [Multi-selectable
|
|
79
|
+
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
80
|
+
*/
|
|
81
|
+
combobox?: ComboboxStore | null;
|
|
82
|
+
/**
|
|
83
|
+
* The default value. If not set, the first non-disabled item will be used.
|
|
84
|
+
*
|
|
85
|
+
* Live examples:
|
|
86
|
+
* - [Multi-selectable
|
|
87
|
+
* Combobox](https://ariakit.org/examples/combobox-multiple)
|
|
88
|
+
*/
|
|
89
|
+
defaultValue?: SelectStoreState<T>["value"];
|
|
90
|
+
}
|
|
91
|
+
export type SelectStoreProps<T extends Value = Value> = SelectStoreOptions<T> & StoreProps<SelectStoreState<T>>;
|
|
92
|
+
export type SelectStore<T extends Value = Value> = SelectStoreFunctions<T> & Store<SelectStoreState<T>>;
|
|
93
|
+
export {};
|
package/cjs/tab/tab-store.cjs
CHANGED
|
@@ -1,55 +1,56 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
|
-
var _TTWS4MDCcjs = require('../__chunks/TTWS4MDC.cjs');
|
|
4
3
|
|
|
4
|
+
var _M44E4T5Acjs = require('../__chunks/M44E4T5A.cjs');
|
|
5
5
|
|
|
6
|
-
var _W5IQT6Z2cjs = require('../__chunks/W5IQT6Z2.cjs');
|
|
7
6
|
|
|
7
|
+
var _25WWT2VOcjs = require('../__chunks/25WWT2VO.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var _A4GDJCZBcjs = require('../__chunks/A4GDJCZB.cjs');
|
|
13
12
|
|
|
13
|
+
var _OASSVCYRcjs = require('../__chunks/OASSVCYR.cjs');
|
|
14
14
|
|
|
15
|
-
var _RCYVACJOcjs = require('../__chunks/RCYVACJO.cjs');
|
|
16
|
-
require('../__chunks/EXM2AW52.cjs');
|
|
17
|
-
require('../__chunks/GDZQUFNP.cjs');
|
|
18
15
|
|
|
16
|
+
var _LMT335NJcjs = require('../__chunks/LMT335NJ.cjs');
|
|
17
|
+
require('../__chunks/FTB5CXVB.cjs');
|
|
18
|
+
require('../__chunks/ULSPM3Y3.cjs');
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
var _WYXAWBLEcjs = require('../__chunks/WYXAWBLE.cjs');
|
|
22
23
|
|
|
23
24
|
// src/tab/tab-store.ts
|
|
24
25
|
function createTabStore(props = {}) {
|
|
25
26
|
var _a;
|
|
26
27
|
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
27
|
-
const composite =
|
|
28
|
-
orientation:
|
|
28
|
+
const composite = _M44E4T5Acjs.createCompositeStore.call(void 0, _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
29
|
+
orientation: _LMT335NJcjs.defaultValue.call(void 0,
|
|
29
30
|
props.orientation,
|
|
30
31
|
syncState == null ? void 0 : syncState.orientation,
|
|
31
32
|
"horizontal"
|
|
32
33
|
),
|
|
33
|
-
focusLoop:
|
|
34
|
+
focusLoop: _LMT335NJcjs.defaultValue.call(void 0, props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true)
|
|
34
35
|
}));
|
|
35
|
-
const panels =
|
|
36
|
-
const initialState =
|
|
37
|
-
selectedId:
|
|
36
|
+
const panels = _25WWT2VOcjs.createCollectionStore.call(void 0, );
|
|
37
|
+
const initialState = _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, composite.getState()), {
|
|
38
|
+
selectedId: _LMT335NJcjs.defaultValue.call(void 0,
|
|
38
39
|
props.selectedId,
|
|
39
40
|
syncState == null ? void 0 : syncState.selectedId,
|
|
40
41
|
props.defaultSelectedId,
|
|
41
42
|
void 0
|
|
42
43
|
),
|
|
43
|
-
selectOnMove:
|
|
44
|
+
selectOnMove: _LMT335NJcjs.defaultValue.call(void 0,
|
|
44
45
|
props.selectOnMove,
|
|
45
46
|
syncState == null ? void 0 : syncState.selectOnMove,
|
|
46
47
|
true
|
|
47
48
|
)
|
|
48
49
|
});
|
|
49
|
-
const tab =
|
|
50
|
-
|
|
50
|
+
const tab = _OASSVCYRcjs.createStore.call(void 0, initialState, composite, props.store);
|
|
51
|
+
_OASSVCYRcjs.setup.call(void 0,
|
|
51
52
|
tab,
|
|
52
|
-
() =>
|
|
53
|
+
() => _OASSVCYRcjs.sync.call(void 0, tab, ["moves"], () => {
|
|
53
54
|
const { activeId, selectOnMove } = tab.getState();
|
|
54
55
|
if (!selectOnMove)
|
|
55
56
|
return;
|
|
@@ -65,17 +66,17 @@ function createTabStore(props = {}) {
|
|
|
65
66
|
tab.setState("selectedId", tabItem.id);
|
|
66
67
|
})
|
|
67
68
|
);
|
|
68
|
-
|
|
69
|
+
_OASSVCYRcjs.setup.call(void 0,
|
|
69
70
|
tab,
|
|
70
|
-
() =>
|
|
71
|
+
() => _OASSVCYRcjs.batch.call(void 0,
|
|
71
72
|
tab,
|
|
72
73
|
["selectedId"],
|
|
73
74
|
(state) => tab.setState("activeId", state.selectedId)
|
|
74
75
|
)
|
|
75
76
|
);
|
|
76
|
-
|
|
77
|
+
_OASSVCYRcjs.setup.call(void 0,
|
|
77
78
|
tab,
|
|
78
|
-
() =>
|
|
79
|
+
() => _OASSVCYRcjs.sync.call(void 0, tab, ["selectedId", "renderedItems"], (state) => {
|
|
79
80
|
if (state.selectedId !== void 0)
|
|
80
81
|
return;
|
|
81
82
|
const { activeId, renderedItems } = tab.getState();
|
|
@@ -90,13 +91,13 @@ function createTabStore(props = {}) {
|
|
|
90
91
|
}
|
|
91
92
|
})
|
|
92
93
|
);
|
|
93
|
-
|
|
94
|
+
_OASSVCYRcjs.setup.call(void 0,
|
|
94
95
|
tab,
|
|
95
|
-
() =>
|
|
96
|
+
() => _OASSVCYRcjs.sync.call(void 0, tab, ["renderedItems"], (state) => {
|
|
96
97
|
const tabs = state.renderedItems;
|
|
97
98
|
if (!tabs.length)
|
|
98
99
|
return;
|
|
99
|
-
return
|
|
100
|
+
return _OASSVCYRcjs.sync.call(void 0, panels, ["renderedItems"], (state2) => {
|
|
100
101
|
const items = state2.renderedItems;
|
|
101
102
|
const hasOrphanPanels = items.some((panel) => !panel.tabId);
|
|
102
103
|
if (!hasOrphanPanels)
|
|
@@ -107,12 +108,12 @@ function createTabStore(props = {}) {
|
|
|
107
108
|
const tabItem = tabs[i];
|
|
108
109
|
if (!tabItem)
|
|
109
110
|
return;
|
|
110
|
-
panels.renderItem(
|
|
111
|
+
panels.renderItem(_WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, panel), { tabId: tabItem.id }));
|
|
111
112
|
});
|
|
112
113
|
});
|
|
113
114
|
})
|
|
114
115
|
);
|
|
115
|
-
return
|
|
116
|
+
return _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, composite), tab), {
|
|
116
117
|
panels,
|
|
117
118
|
setSelectedId: (id) => tab.setState("selectedId", id),
|
|
118
119
|
select: (id) => {
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.js";
|
|
2
|
+
import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
|
|
3
|
+
import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
|
|
4
|
+
import type { SetState } from "../utils/types.js";
|
|
5
|
+
type Item = CompositeStoreItem & {
|
|
6
|
+
dimmed?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type Panel = CollectionStoreItem & {
|
|
9
|
+
tabId?: string | null;
|
|
10
|
+
};
|
|
11
|
+
export declare function createTabStore(props?: TabStoreProps): TabStore;
|
|
12
|
+
export type TabStoreItem = Item;
|
|
13
|
+
export type TabStorePanel = Panel;
|
|
14
|
+
export interface TabStoreState extends CompositeStoreState<Item> {
|
|
15
|
+
/**
|
|
16
|
+
* @default "horizontal"
|
|
17
|
+
*/
|
|
18
|
+
orientation: CompositeStoreState<Item>["orientation"];
|
|
19
|
+
/**
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
focusLoop: CompositeStoreState<Item>["focusLoop"];
|
|
23
|
+
/**
|
|
24
|
+
* The id of the tab whose panel is currently visible. If it's `undefined`, it
|
|
25
|
+
* will be automatically set to the first enabled tab.
|
|
26
|
+
*
|
|
27
|
+
* Live examples:
|
|
28
|
+
* - [Tab with React Router](https://ariakit.org/examples/tab-react-router)
|
|
29
|
+
*/
|
|
30
|
+
selectedId: TabStoreState["activeId"];
|
|
31
|
+
/**
|
|
32
|
+
* Whether the tab should be selected when it receives focus. If it's set to
|
|
33
|
+
* `false`, the tab will be selected only when it's clicked.
|
|
34
|
+
*
|
|
35
|
+
* Live examples:
|
|
36
|
+
* - [Tab with React Router](https://ariakit.org/examples/tab-react-router)
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
selectOnMove?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface TabStoreFunctions extends CompositeStoreFunctions<Item> {
|
|
42
|
+
/**
|
|
43
|
+
* Sets the `selectedId` state without moving focus. If you want to move focus,
|
|
44
|
+
* use the `select` function instead.
|
|
45
|
+
*
|
|
46
|
+
* Live examples:
|
|
47
|
+
* - [Tab with React Router](https://ariakit.org/examples/tab-react-router)
|
|
48
|
+
* @example
|
|
49
|
+
* // Selects the tab with id "tab-1"
|
|
50
|
+
* store.setSelectedId("tab-1");
|
|
51
|
+
* // Toggles between "tab-1" and "tab-2"
|
|
52
|
+
* store.setSelectedId((id) => id === "tab-1" ? "tab-2" : "tab-1"));
|
|
53
|
+
* // Selects the first tab
|
|
54
|
+
* store.setSelectedId(store.first());
|
|
55
|
+
* // Selects the next tab
|
|
56
|
+
* store.setSelectedId(store.next());
|
|
57
|
+
*/
|
|
58
|
+
setSelectedId: SetState<TabStoreState["selectedId"]>;
|
|
59
|
+
/**
|
|
60
|
+
* A collection store containing the tab panels.
|
|
61
|
+
*/
|
|
62
|
+
panels: CollectionStore<Panel>;
|
|
63
|
+
/**
|
|
64
|
+
* Selects the tab for the given id and moves focus to it. If you want to set
|
|
65
|
+
* the `selectedId` state without moving focus, use the `setSelectedId`
|
|
66
|
+
* function instead.
|
|
67
|
+
* @param id The id of the tab to select.
|
|
68
|
+
* @example
|
|
69
|
+
* // Selects the tab with id "tab-1"
|
|
70
|
+
* store.select("tab-1");
|
|
71
|
+
* // Selects the first tab
|
|
72
|
+
* store.select(store.first());
|
|
73
|
+
* // Selects the next tab
|
|
74
|
+
* store.select(store.next());
|
|
75
|
+
*/
|
|
76
|
+
select: TabStore["move"];
|
|
77
|
+
}
|
|
78
|
+
export interface TabStoreOptions extends StoreOptions<TabStoreState, "orientation" | "focusLoop" | "selectedId" | "selectOnMove">, CompositeStoreOptions<Item> {
|
|
79
|
+
/**
|
|
80
|
+
* The id of the tab whose panel is currently visible. If it's `undefined`, it
|
|
81
|
+
* will be automatically set to the first enabled tab.
|
|
82
|
+
*/
|
|
83
|
+
defaultSelectedId?: TabStoreState["selectedId"];
|
|
84
|
+
}
|
|
85
|
+
export type TabStoreProps = TabStoreOptions & StoreProps<TabStoreState>;
|
|
86
|
+
export type TabStore = TabStoreFunctions & Store<TabStoreState>;
|
|
87
|
+
export {};
|