@ariakit/core 0.4.2 → 0.4.3

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # @ariakit/core
2
2
 
3
+ ## 0.4.3
4
+
5
+ - Fixed regression in `v0.4.2` that caused nested tabs to stop working.
6
+ - Added new [`combobox`](https://ariakit.org/reference/tab-provider#combobox) property to tab store.
7
+ - Improved JSDocs.
8
+ - Fixed TypeScript error on `defaultValue`.
9
+
3
10
  ## 0.4.2
4
11
 
5
12
  - Fixed [`Focusable`](https://ariakit.org/reference/focusable) to identify `summary` as a native tabbable element.
@@ -27,22 +27,26 @@ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
27
27
  // src/tab/tab-store.ts
28
28
  function createTabStore(_a = {}) {
29
29
  var _b = _a, {
30
- composite: parentComposite
30
+ composite: parentComposite,
31
+ combobox
31
32
  } = _b, props = _AV6KTKLEcjs.__objRest.call(void 0, _b, [
32
- "composite"
33
+ "composite",
34
+ "combobox"
33
35
  ]);
36
+ const independentKeys = [
37
+ "items",
38
+ "renderedItems",
39
+ "moves",
40
+ "orientation",
41
+ "baseElement",
42
+ "focusLoop",
43
+ "focusShift",
44
+ "focusWrap"
45
+ ];
34
46
  const store = _B4LYZ4EMcjs.mergeStore.call(void 0,
35
47
  props.store,
36
- _B4LYZ4EMcjs.omit.call(void 0, parentComposite, [
37
- "items",
38
- "renderedItems",
39
- "moves",
40
- "orientation",
41
- "baseElement",
42
- "focusLoop",
43
- "focusShift",
44
- "focusWrap"
45
- ])
48
+ _B4LYZ4EMcjs.omit.call(void 0, parentComposite, independentKeys),
49
+ _B4LYZ4EMcjs.omit.call(void 0, combobox, independentKeys)
46
50
  );
47
51
  const syncState = store == null ? void 0 : store.getState();
48
52
  const composite = _Y7KNI5NScjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
@@ -1,8 +1,9 @@
1
1
  import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.js";
2
+ import type { ComboboxStore } from "../combobox/combobox-store.js";
2
3
  import type { CompositeStore, CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
3
4
  import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
4
5
  import type { SetState } from "../utils/types.js";
5
- export declare function createTabStore({ composite: parentComposite, ...props }?: TabStoreProps): TabStore;
6
+ export declare function createTabStore({ composite: parentComposite, combobox, ...props }?: TabStoreProps): TabStore;
6
7
  export interface TabStoreItem extends CompositeStoreItem {
7
8
  dimmed?: boolean;
8
9
  }
@@ -78,13 +79,20 @@ export interface TabStoreFunctions extends CompositeStoreFunctions<TabStoreItem>
78
79
  export interface TabStoreOptions extends StoreOptions<TabStoreState, "orientation" | "focusLoop" | "selectedId" | "selectOnMove">, CompositeStoreOptions<TabStoreItem> {
79
80
  /**
80
81
  * A reference to another [composite
81
- * store](https://ariakit.org/reference/composite-store). This is used when
82
+ * store](https://ariakit.org/reference/use-composite-store). This is used when
82
83
  * rendering tabs as part of another composite widget such as
83
84
  * [Combobox](https://ariakit.org/components/combobox) or
84
85
  * [Select](https://ariakit.org/components/select). The stores will share the
85
86
  * same state.
86
87
  */
87
88
  composite?: CompositeStore | null;
89
+ /**
90
+ * A reference to a [combobox
91
+ * store](https://ariakit.org/reference/use-combobox-store). This is used when
92
+ * rendering tabs inside a
93
+ * [Combobox](https://ariakit.org/components/combobox).
94
+ */
95
+ combobox?: ComboboxStore | null;
88
96
  /**
89
97
  * The id of the tab whose panel is currently visible. If it's `undefined`, it
90
98
  * will be automatically set to the first enabled tab.
@@ -1,8 +1,9 @@
1
1
  import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.js";
2
+ import type { ComboboxStore } from "../combobox/combobox-store.js";
2
3
  import type { CompositeStore, CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
3
4
  import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
4
5
  import type { SetState } from "../utils/types.js";
5
- export declare function createTabStore({ composite: parentComposite, ...props }?: TabStoreProps): TabStore;
6
+ export declare function createTabStore({ composite: parentComposite, combobox, ...props }?: TabStoreProps): TabStore;
6
7
  export interface TabStoreItem extends CompositeStoreItem {
7
8
  dimmed?: boolean;
8
9
  }
@@ -78,13 +79,20 @@ export interface TabStoreFunctions extends CompositeStoreFunctions<TabStoreItem>
78
79
  export interface TabStoreOptions extends StoreOptions<TabStoreState, "orientation" | "focusLoop" | "selectedId" | "selectOnMove">, CompositeStoreOptions<TabStoreItem> {
79
80
  /**
80
81
  * A reference to another [composite
81
- * store](https://ariakit.org/reference/composite-store). This is used when
82
+ * store](https://ariakit.org/reference/use-composite-store). This is used when
82
83
  * rendering tabs as part of another composite widget such as
83
84
  * [Combobox](https://ariakit.org/components/combobox) or
84
85
  * [Select](https://ariakit.org/components/select). The stores will share the
85
86
  * same state.
86
87
  */
87
88
  composite?: CompositeStore | null;
89
+ /**
90
+ * A reference to a [combobox
91
+ * store](https://ariakit.org/reference/use-combobox-store). This is used when
92
+ * rendering tabs inside a
93
+ * [Combobox](https://ariakit.org/components/combobox).
94
+ */
95
+ combobox?: ComboboxStore | null;
88
96
  /**
89
97
  * The id of the tab whose panel is currently visible. If it's `undefined`, it
90
98
  * will be automatically set to the first enabled tab.
@@ -121,8 +121,8 @@ export declare function removeUndefinedValues<T extends AnyObject>(obj: T): T;
121
121
  * Returns the first value that is not `undefined`.
122
122
  */
123
123
  export declare function defaultValue<T extends readonly any[]>(...values: T): DefaultValue<T>;
124
- type DefinedArray<T extends readonly any[]> = {
125
- [K in keyof T as undefined extends T[K] ? never : K]: undefined extends T[K] ? [Exclude<T[K], undefined>, never] : [T[K]];
126
- };
127
- type DefaultValue<T extends readonly any[]> = DefinedArray<T>[keyof DefinedArray<T>] extends [any, never] ? T[number] : DefinedArray<T>[keyof DefinedArray<T>][0];
124
+ type DefaultValue<T extends readonly any[], Other = never> = T extends [
125
+ infer Head,
126
+ ...infer Rest
127
+ ] ? Rest extends [] ? T[number] | Other : undefined extends Head ? DefaultValue<Rest, Exclude<Other | Head, undefined>> : Exclude<T[number], undefined> : never;
128
128
  export {};
@@ -121,8 +121,8 @@ export declare function removeUndefinedValues<T extends AnyObject>(obj: T): T;
121
121
  * Returns the first value that is not `undefined`.
122
122
  */
123
123
  export declare function defaultValue<T extends readonly any[]>(...values: T): DefaultValue<T>;
124
- type DefinedArray<T extends readonly any[]> = {
125
- [K in keyof T as undefined extends T[K] ? never : K]: undefined extends T[K] ? [Exclude<T[K], undefined>, never] : [T[K]];
126
- };
127
- type DefaultValue<T extends readonly any[]> = DefinedArray<T>[keyof DefinedArray<T>] extends [any, never] ? T[number] : DefinedArray<T>[keyof DefinedArray<T>][0];
124
+ type DefaultValue<T extends readonly any[], Other = never> = T extends [
125
+ infer Head,
126
+ ...infer Rest
127
+ ] ? Rest extends [] ? T[number] | Other : undefined extends Head ? DefaultValue<Rest, Exclude<Other | Head, undefined>> : Exclude<T[number], undefined> : never;
128
128
  export {};
@@ -1,8 +1,9 @@
1
1
  import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.js";
2
+ import type { ComboboxStore } from "../combobox/combobox-store.js";
2
3
  import type { CompositeStore, CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
3
4
  import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
4
5
  import type { SetState } from "../utils/types.js";
5
- export declare function createTabStore({ composite: parentComposite, ...props }?: TabStoreProps): TabStore;
6
+ export declare function createTabStore({ composite: parentComposite, combobox, ...props }?: TabStoreProps): TabStore;
6
7
  export interface TabStoreItem extends CompositeStoreItem {
7
8
  dimmed?: boolean;
8
9
  }
@@ -78,13 +79,20 @@ export interface TabStoreFunctions extends CompositeStoreFunctions<TabStoreItem>
78
79
  export interface TabStoreOptions extends StoreOptions<TabStoreState, "orientation" | "focusLoop" | "selectedId" | "selectOnMove">, CompositeStoreOptions<TabStoreItem> {
79
80
  /**
80
81
  * A reference to another [composite
81
- * store](https://ariakit.org/reference/composite-store). This is used when
82
+ * store](https://ariakit.org/reference/use-composite-store). This is used when
82
83
  * rendering tabs as part of another composite widget such as
83
84
  * [Combobox](https://ariakit.org/components/combobox) or
84
85
  * [Select](https://ariakit.org/components/select). The stores will share the
85
86
  * same state.
86
87
  */
87
88
  composite?: CompositeStore | null;
89
+ /**
90
+ * A reference to a [combobox
91
+ * store](https://ariakit.org/reference/use-combobox-store). This is used when
92
+ * rendering tabs inside a
93
+ * [Combobox](https://ariakit.org/components/combobox).
94
+ */
95
+ combobox?: ComboboxStore | null;
88
96
  /**
89
97
  * The id of the tab whose panel is currently visible. If it's `undefined`, it
90
98
  * will be automatically set to the first enabled tab.
@@ -27,22 +27,26 @@ import {
27
27
  // src/tab/tab-store.ts
28
28
  function createTabStore(_a = {}) {
29
29
  var _b = _a, {
30
- composite: parentComposite
30
+ composite: parentComposite,
31
+ combobox
31
32
  } = _b, props = __objRest(_b, [
32
- "composite"
33
+ "composite",
34
+ "combobox"
33
35
  ]);
36
+ const independentKeys = [
37
+ "items",
38
+ "renderedItems",
39
+ "moves",
40
+ "orientation",
41
+ "baseElement",
42
+ "focusLoop",
43
+ "focusShift",
44
+ "focusWrap"
45
+ ];
34
46
  const store = mergeStore(
35
47
  props.store,
36
- omit(parentComposite, [
37
- "items",
38
- "renderedItems",
39
- "moves",
40
- "orientation",
41
- "baseElement",
42
- "focusLoop",
43
- "focusShift",
44
- "focusWrap"
45
- ])
48
+ omit(parentComposite, independentKeys),
49
+ omit(combobox, independentKeys)
46
50
  );
47
51
  const syncState = store == null ? void 0 : store.getState();
48
52
  const composite = createCompositeStore(__spreadProps(__spreadValues({}, props), {
@@ -121,8 +121,8 @@ export declare function removeUndefinedValues<T extends AnyObject>(obj: T): T;
121
121
  * Returns the first value that is not `undefined`.
122
122
  */
123
123
  export declare function defaultValue<T extends readonly any[]>(...values: T): DefaultValue<T>;
124
- type DefinedArray<T extends readonly any[]> = {
125
- [K in keyof T as undefined extends T[K] ? never : K]: undefined extends T[K] ? [Exclude<T[K], undefined>, never] : [T[K]];
126
- };
127
- type DefaultValue<T extends readonly any[]> = DefinedArray<T>[keyof DefinedArray<T>] extends [any, never] ? T[number] : DefinedArray<T>[keyof DefinedArray<T>][0];
124
+ type DefaultValue<T extends readonly any[], Other = never> = T extends [
125
+ infer Head,
126
+ ...infer Rest
127
+ ] ? Rest extends [] ? T[number] | Other : undefined extends Head ? DefaultValue<Rest, Exclude<Other | Head, undefined>> : Exclude<T[number], undefined> : never;
128
128
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariakit/core",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Ariakit core",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",