@ariakit/solid-core 0.0.1 → 0.1.1
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 +9 -0
- package/as/as/package.json +8 -0
- package/cjs/__chunks/53WPOLZU.cjs +7 -0
- package/cjs/__chunks/AUGTJ473.cjs +7 -0
- package/cjs/__chunks/GVOD7RTZ.cjs +21 -0
- package/cjs/__chunks/JFCGWMZC.cjs +35 -0
- package/cjs/__chunks/RLO4RIGL.cjs +42 -0
- package/cjs/__chunks/T5IUBZJK.cjs +39 -0
- package/cjs/__chunks/V3ZEI37L.cjs +61 -0
- package/cjs/__chunks/V5YR7HBG.cjs +37 -0
- package/cjs/as/as.cjs +7 -0
- package/cjs/as/as.d.cts +30 -0
- package/cjs/as/as.d.ts +30 -0
- package/cjs/focus-trap/focus-trap-region.cjs +68 -0
- package/cjs/focus-trap/focus-trap-region.d.cts +38 -0
- package/cjs/focus-trap/focus-trap-region.d.ts +38 -0
- package/cjs/focus-trap/focus-trap.cjs +11 -0
- package/cjs/focus-trap/focus-trap.d.cts +27 -0
- package/cjs/focus-trap/focus-trap.d.ts +27 -0
- package/cjs/group/group-label-context.cjs +6 -0
- package/cjs/group/group-label-context.d.cts +2 -0
- package/cjs/group/group-label-context.d.ts +2 -0
- package/cjs/group/group-label.cjs +41 -0
- package/cjs/group/group-label.d.cts +34 -0
- package/cjs/group/group-label.d.ts +34 -0
- package/cjs/group/group.cjs +43 -0
- package/cjs/group/group.d.cts +28 -0
- package/cjs/group/group.d.ts +28 -0
- package/cjs/heading/heading-context.cjs +6 -0
- package/cjs/heading/heading-context.d.cts +3 -0
- package/cjs/heading/heading-context.d.ts +3 -0
- package/cjs/heading/heading-level.cjs +23 -0
- package/cjs/heading/heading-level.d.cts +27 -0
- package/cjs/heading/heading-level.d.ts +27 -0
- package/cjs/heading/heading.cjs +45 -0
- package/cjs/heading/heading.d.cts +39 -0
- package/cjs/heading/heading.d.ts +39 -0
- package/cjs/heading/utils.cjs +1 -0
- package/cjs/heading/utils.d.cts +1 -0
- package/cjs/heading/utils.d.ts +1 -0
- package/cjs/role/role.cjs +26 -0
- package/cjs/role/role.d.cts +33 -0
- package/cjs/role/role.d.ts +33 -0
- package/cjs/separator/separator.cjs +30 -0
- package/cjs/separator/separator.d.cts +32 -0
- package/cjs/separator/separator.d.ts +32 -0
- package/cjs/utils/misc.cjs +8 -0
- package/cjs/utils/misc.d.cts +16 -0
- package/cjs/utils/misc.d.ts +16 -0
- package/cjs/utils/reactivity.cjs +12 -0
- package/cjs/utils/reactivity.d.cts +109 -0
- package/cjs/utils/reactivity.d.ts +109 -0
- package/cjs/utils/system.cjs +13 -0
- package/cjs/utils/system.d.cts +45 -0
- package/cjs/utils/system.d.ts +45 -0
- package/cjs/utils/types.cjs +1 -0
- package/cjs/utils/types.d.cts +56 -0
- package/cjs/utils/types.d.ts +56 -0
- package/cjs/visually-hidden/visually-hidden.cjs +10 -0
- package/cjs/visually-hidden/visually-hidden.d.cts +34 -0
- package/cjs/visually-hidden/visually-hidden.d.ts +34 -0
- package/esm/__chunks/I7JSIDPD.js +7 -0
- package/esm/__chunks/ILGMKAYU.js +37 -0
- package/esm/__chunks/NX66AMGW.js +39 -0
- package/esm/__chunks/OKOFCLOZ.js +61 -0
- package/esm/__chunks/QKOHDUFI.js +42 -0
- package/esm/__chunks/SFKMELHD.js +35 -0
- package/esm/__chunks/UKDBTPK5.js +21 -0
- package/esm/__chunks/VOWRNGOM.js +7 -0
- package/esm/as/as.d.ts +30 -0
- package/esm/as/as.js +7 -0
- package/esm/focus-trap/focus-trap-region.d.ts +38 -0
- package/esm/focus-trap/focus-trap-region.js +68 -0
- package/esm/focus-trap/focus-trap.d.ts +27 -0
- package/esm/focus-trap/focus-trap.js +11 -0
- package/esm/group/group-label-context.d.ts +2 -0
- package/esm/group/group-label-context.js +6 -0
- package/esm/group/group-label.d.ts +34 -0
- package/esm/group/group-label.js +41 -0
- package/esm/group/group.d.ts +28 -0
- package/esm/group/group.js +43 -0
- package/esm/heading/heading-context.d.ts +3 -0
- package/esm/heading/heading-context.js +6 -0
- package/esm/heading/heading-level.d.ts +27 -0
- package/esm/heading/heading-level.js +23 -0
- package/esm/heading/heading.d.ts +39 -0
- package/esm/heading/heading.js +45 -0
- package/esm/heading/utils.d.ts +1 -0
- package/esm/heading/utils.js +0 -0
- package/esm/role/role.d.ts +33 -0
- package/esm/role/role.js +26 -0
- package/esm/separator/separator.d.ts +32 -0
- package/esm/separator/separator.js +30 -0
- package/esm/utils/misc.d.ts +16 -0
- package/esm/utils/misc.js +8 -0
- package/esm/utils/reactivity.d.ts +109 -0
- package/esm/utils/reactivity.js +12 -0
- package/esm/utils/system.d.ts +45 -0
- package/esm/utils/system.js +13 -0
- package/esm/utils/types.d.ts +56 -0
- package/esm/utils/types.js +0 -0
- package/esm/visually-hidden/visually-hidden.d.ts +34 -0
- package/esm/visually-hidden/visually-hidden.js +10 -0
- package/focus-trap/focus-trap/package.json +8 -0
- package/focus-trap/focus-trap-region/package.json +8 -0
- package/group/group/package.json +8 -0
- package/group/group-label/package.json +8 -0
- package/group/group-label-context/package.json +8 -0
- package/heading/heading/package.json +8 -0
- package/heading/heading-context/package.json +8 -0
- package/heading/heading-level/package.json +8 -0
- package/heading/utils/package.json +8 -0
- package/index.ts +1 -0
- package/license +21 -0
- package/package.json +181 -6
- package/readme.md +19 -0
- package/role/role/package.json +8 -0
- package/separator/separator/package.json +8 -0
- package/solid/__chunks/ALJQAVR2.jsx +42 -0
- package/solid/__chunks/HBI7B4XO.jsx +52 -0
- package/solid/__chunks/HUX7TBVM.jsx +37 -0
- package/solid/__chunks/KXVBEYOF.jsx +21 -0
- package/solid/__chunks/O5QTZ2VS.jsx +42 -0
- package/solid/__chunks/PIGECGWJ.jsx +40 -0
- package/solid/__chunks/TCHPU5P4.jsx +7 -0
- package/solid/__chunks/VAA446IN.jsx +7 -0
- package/solid/as/as.jsx +7 -0
- package/solid/focus-trap/focus-trap-region.jsx +63 -0
- package/solid/focus-trap/focus-trap.jsx +11 -0
- package/solid/group/group-label-context.jsx +6 -0
- package/solid/group/group-label.jsx +50 -0
- package/solid/group/group.jsx +45 -0
- package/solid/heading/heading-context.jsx +6 -0
- package/solid/heading/heading-level.jsx +22 -0
- package/solid/heading/heading.jsx +52 -0
- package/solid/heading/utils.jsx +0 -0
- package/solid/role/role.jsx +59 -0
- package/solid/separator/separator.jsx +36 -0
- package/solid/utils/misc.jsx +8 -0
- package/solid/utils/reactivity.jsx +12 -0
- package/solid/utils/system.jsx +13 -0
- package/solid/utils/types.jsx +0 -0
- package/solid/visually-hidden/visually-hidden.jsx +10 -0
- package/tsconfig.build.json +4 -0
- package/utils/misc/package.json +8 -0
- package/utils/reactivity/package.json +8 -0
- package/utils/system/package.json +8 -0
- package/utils/types/package.json +8 -0
- package/visually-hidden/visually-hidden/package.json +8 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { AnyObject } from "@ariakit/core/utils/types";
|
|
2
|
+
import { type Accessor, type JSX, type Setter } from "solid-js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a stable accessor. Useful when creating derived accessors that
|
|
5
|
+
* depend on a mutable variable that may change later.
|
|
6
|
+
* @example
|
|
7
|
+
* let value = 0;
|
|
8
|
+
* const accessor = stableAccessor(value, (v) => v + 1);
|
|
9
|
+
* value = 100;
|
|
10
|
+
* accessor(); // 1
|
|
11
|
+
*/
|
|
12
|
+
export declare function stableAccessor<T, U>(value: T, callback: (value: T) => U): () => U;
|
|
13
|
+
type NullablyRequired<T> = {
|
|
14
|
+
[P in keyof T & keyof any]: T[P];
|
|
15
|
+
};
|
|
16
|
+
export type ExtractPropsWithDefaultsExtractedProps<P, D extends Partial<R>, R = NullablyRequired<P>> = {
|
|
17
|
+
-readonly [K in keyof R as Extract<K, keyof D>]: D[K] extends undefined ? R[K] : Exclude<R[K], undefined>;
|
|
18
|
+
};
|
|
19
|
+
export type ExtractPropsWithDefaultsRestProps<P, D extends Partial<P>> = Omit<P, keyof D>;
|
|
20
|
+
export type ExtractPropsWithDefaultsReturn<P, D extends Partial<P>> = [
|
|
21
|
+
ExtractPropsWithDefaultsExtractedProps<P, D>,
|
|
22
|
+
ExtractPropsWithDefaultsRestProps<P, D>
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Extracts props from a props object and applies defaults to them. The
|
|
26
|
+
* return value is a tuple of the extracted props and the rest of the props.
|
|
27
|
+
*
|
|
28
|
+
* To extract a prop without a default, set it to `undefined`.
|
|
29
|
+
* @example
|
|
30
|
+
* const [extractedProps, restProps] = extractPropsWithDefaults(
|
|
31
|
+
* props,
|
|
32
|
+
* { orientation: "horizontal" },
|
|
33
|
+
* );
|
|
34
|
+
*/
|
|
35
|
+
export declare function extractPropsWithDefaults<P extends AnyObject, const D extends Partial<P>>(props: P, defaults: D): ExtractPropsWithDefaultsReturn<P, D>;
|
|
36
|
+
/**
|
|
37
|
+
* A ref object that contains the value getter (`value`) and setter (`set`) as
|
|
38
|
+
* properties for convenience. It also has a `reset` method that can be used to
|
|
39
|
+
* set the value to the initial value that was passed, which is `undefined` by
|
|
40
|
+
* default. The `current` getter can be used to obtain the value without
|
|
41
|
+
* tracking it reactively.
|
|
42
|
+
*
|
|
43
|
+
* Created by the `createRef` function.
|
|
44
|
+
* @example
|
|
45
|
+
* const ref = createRef();
|
|
46
|
+
* createEffect(() => {
|
|
47
|
+
* console.log(ref.value);
|
|
48
|
+
* });
|
|
49
|
+
* ref.set(buttonElement);
|
|
50
|
+
* ref.reset();
|
|
51
|
+
*/
|
|
52
|
+
export type RefStore<T> = {
|
|
53
|
+
/**
|
|
54
|
+
* The current value of the ref. It is a non-reactive getter, wrapped with
|
|
55
|
+
* the `untrack` function.
|
|
56
|
+
*
|
|
57
|
+
* **Important note**: since this is a getter, TypeScript might reflect the
|
|
58
|
+
* wrong type in some cases. For example:
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* const ref = createRef<number>(); // ref.current type: number | undefined
|
|
62
|
+
* ref.set(1);
|
|
63
|
+
* console.log(ref.current); // 1
|
|
64
|
+
* if (ref.current) {
|
|
65
|
+
* // ref.current type: number (narrowed by the if statement)
|
|
66
|
+
* console.log(ref.current); // 1
|
|
67
|
+
* ref.set(undefined);
|
|
68
|
+
* // ref.current type: number (wrong!)
|
|
69
|
+
* console.log(ref.current); // undefined
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
current: T;
|
|
74
|
+
/**
|
|
75
|
+
* The getter function for the ref.
|
|
76
|
+
*/
|
|
77
|
+
get: Accessor<T>;
|
|
78
|
+
/**
|
|
79
|
+
* The setter function for the ref.
|
|
80
|
+
*/
|
|
81
|
+
set: Setter<T>;
|
|
82
|
+
/**
|
|
83
|
+
* Resets the ref to the initial value that was passed, which is `undefined`
|
|
84
|
+
* by default.
|
|
85
|
+
*/
|
|
86
|
+
reset: () => void;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Creates a ref object that contains the value getter (`value`) and setter
|
|
90
|
+
* (`set`) as properties for convenience. It also has a `reset` method that
|
|
91
|
+
* can be used to set the value to the initial value that was passed,
|
|
92
|
+
* which is `undefined` by default. The `current` getter can be used to obtain
|
|
93
|
+
* the value without tracking it reactively.
|
|
94
|
+
* @example
|
|
95
|
+
* ```jsx
|
|
96
|
+
* const ref = createRef();
|
|
97
|
+
* createEffect(() => {
|
|
98
|
+
* console.log(ref.value);
|
|
99
|
+
* });
|
|
100
|
+
* <button ref={ref.set}>Button</button>
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function createRef<T>(): RefStore<T | undefined>;
|
|
104
|
+
export declare function createRef<T>(initialValue: T): RefStore<T>;
|
|
105
|
+
/**
|
|
106
|
+
* Merges two sets of props.
|
|
107
|
+
*/
|
|
108
|
+
export declare function mergeProps<T extends JSX.HTMLAttributes<any>>(base: T, overrides: T, skipProps?: Array<keyof T>): T;
|
|
109
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { AnyObject } from "@ariakit/core/utils/types";
|
|
2
|
+
import { type Accessor, type JSX, type Setter } from "solid-js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a stable accessor. Useful when creating derived accessors that
|
|
5
|
+
* depend on a mutable variable that may change later.
|
|
6
|
+
* @example
|
|
7
|
+
* let value = 0;
|
|
8
|
+
* const accessor = stableAccessor(value, (v) => v + 1);
|
|
9
|
+
* value = 100;
|
|
10
|
+
* accessor(); // 1
|
|
11
|
+
*/
|
|
12
|
+
export declare function stableAccessor<T, U>(value: T, callback: (value: T) => U): () => U;
|
|
13
|
+
type NullablyRequired<T> = {
|
|
14
|
+
[P in keyof T & keyof any]: T[P];
|
|
15
|
+
};
|
|
16
|
+
export type ExtractPropsWithDefaultsExtractedProps<P, D extends Partial<R>, R = NullablyRequired<P>> = {
|
|
17
|
+
-readonly [K in keyof R as Extract<K, keyof D>]: D[K] extends undefined ? R[K] : Exclude<R[K], undefined>;
|
|
18
|
+
};
|
|
19
|
+
export type ExtractPropsWithDefaultsRestProps<P, D extends Partial<P>> = Omit<P, keyof D>;
|
|
20
|
+
export type ExtractPropsWithDefaultsReturn<P, D extends Partial<P>> = [
|
|
21
|
+
ExtractPropsWithDefaultsExtractedProps<P, D>,
|
|
22
|
+
ExtractPropsWithDefaultsRestProps<P, D>
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Extracts props from a props object and applies defaults to them. The
|
|
26
|
+
* return value is a tuple of the extracted props and the rest of the props.
|
|
27
|
+
*
|
|
28
|
+
* To extract a prop without a default, set it to `undefined`.
|
|
29
|
+
* @example
|
|
30
|
+
* const [extractedProps, restProps] = extractPropsWithDefaults(
|
|
31
|
+
* props,
|
|
32
|
+
* { orientation: "horizontal" },
|
|
33
|
+
* );
|
|
34
|
+
*/
|
|
35
|
+
export declare function extractPropsWithDefaults<P extends AnyObject, const D extends Partial<P>>(props: P, defaults: D): ExtractPropsWithDefaultsReturn<P, D>;
|
|
36
|
+
/**
|
|
37
|
+
* A ref object that contains the value getter (`value`) and setter (`set`) as
|
|
38
|
+
* properties for convenience. It also has a `reset` method that can be used to
|
|
39
|
+
* set the value to the initial value that was passed, which is `undefined` by
|
|
40
|
+
* default. The `current` getter can be used to obtain the value without
|
|
41
|
+
* tracking it reactively.
|
|
42
|
+
*
|
|
43
|
+
* Created by the `createRef` function.
|
|
44
|
+
* @example
|
|
45
|
+
* const ref = createRef();
|
|
46
|
+
* createEffect(() => {
|
|
47
|
+
* console.log(ref.value);
|
|
48
|
+
* });
|
|
49
|
+
* ref.set(buttonElement);
|
|
50
|
+
* ref.reset();
|
|
51
|
+
*/
|
|
52
|
+
export type RefStore<T> = {
|
|
53
|
+
/**
|
|
54
|
+
* The current value of the ref. It is a non-reactive getter, wrapped with
|
|
55
|
+
* the `untrack` function.
|
|
56
|
+
*
|
|
57
|
+
* **Important note**: since this is a getter, TypeScript might reflect the
|
|
58
|
+
* wrong type in some cases. For example:
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* const ref = createRef<number>(); // ref.current type: number | undefined
|
|
62
|
+
* ref.set(1);
|
|
63
|
+
* console.log(ref.current); // 1
|
|
64
|
+
* if (ref.current) {
|
|
65
|
+
* // ref.current type: number (narrowed by the if statement)
|
|
66
|
+
* console.log(ref.current); // 1
|
|
67
|
+
* ref.set(undefined);
|
|
68
|
+
* // ref.current type: number (wrong!)
|
|
69
|
+
* console.log(ref.current); // undefined
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
current: T;
|
|
74
|
+
/**
|
|
75
|
+
* The getter function for the ref.
|
|
76
|
+
*/
|
|
77
|
+
get: Accessor<T>;
|
|
78
|
+
/**
|
|
79
|
+
* The setter function for the ref.
|
|
80
|
+
*/
|
|
81
|
+
set: Setter<T>;
|
|
82
|
+
/**
|
|
83
|
+
* Resets the ref to the initial value that was passed, which is `undefined`
|
|
84
|
+
* by default.
|
|
85
|
+
*/
|
|
86
|
+
reset: () => void;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Creates a ref object that contains the value getter (`value`) and setter
|
|
90
|
+
* (`set`) as properties for convenience. It also has a `reset` method that
|
|
91
|
+
* can be used to set the value to the initial value that was passed,
|
|
92
|
+
* which is `undefined` by default. The `current` getter can be used to obtain
|
|
93
|
+
* the value without tracking it reactively.
|
|
94
|
+
* @example
|
|
95
|
+
* ```jsx
|
|
96
|
+
* const ref = createRef();
|
|
97
|
+
* createEffect(() => {
|
|
98
|
+
* console.log(ref.value);
|
|
99
|
+
* });
|
|
100
|
+
* <button ref={ref.set}>Button</button>
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function createRef<T>(): RefStore<T | undefined>;
|
|
104
|
+
export declare function createRef<T>(initialValue: T): RefStore<T>;
|
|
105
|
+
/**
|
|
106
|
+
* Merges two sets of props.
|
|
107
|
+
*/
|
|
108
|
+
export declare function mergeProps<T extends JSX.HTMLAttributes<any>>(base: T, overrides: T, skipProps?: Array<keyof T>): T;
|
|
109
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _V3ZEI37Lcjs = require('../__chunks/V3ZEI37L.cjs');
|
|
7
|
+
require('../__chunks/RLO4RIGL.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.createHook = _V3ZEI37Lcjs.createHook; exports.createInstance = _V3ZEI37Lcjs.createInstance; exports.withOptions = _V3ZEI37Lcjs.withOptions; exports.wrapInstance = _V3ZEI37Lcjs.wrapInstance;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { AnyObject, EmptyObject } from "@ariakit/core/utils/types";
|
|
2
|
+
import { type ValidComponent } from "solid-js";
|
|
3
|
+
import { type ExtractPropsWithDefaultsExtractedProps, type ExtractPropsWithDefaultsRestProps } from "./reactivity.ts";
|
|
4
|
+
import type { HTMLProps, Hook, Options, Props, WrapInstance, WrapInstanceValue } from "./types.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Creates a Solid component instance that supports the `render` and
|
|
7
|
+
* `wrapInstance` props.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createInstance(Component: ValidComponent, props: Props<ValidComponent, Options>): import("solid-js").JSX.Element;
|
|
10
|
+
/**
|
|
11
|
+
* Returns props with an additional `wrapInstance` prop.
|
|
12
|
+
*/
|
|
13
|
+
export declare function wrapInstance<P, Q = P & {
|
|
14
|
+
wrapInstance: WrapInstance;
|
|
15
|
+
}>(props: P & {
|
|
16
|
+
wrapInstance?: WrapInstance;
|
|
17
|
+
}, element: WrapInstanceValue): Q;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a component hook that accepts props and returns props so they can be
|
|
20
|
+
* passed to a Solid component.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createHook<T extends ValidComponent, P extends AnyObject = EmptyObject>(useProps: (props: Props<T, P>) => HTMLProps<T, P>): Hook<T, P>;
|
|
23
|
+
/**
|
|
24
|
+
* Splits "option props" from the rest in a component hook. Must be called
|
|
25
|
+
* inside `createHook`.
|
|
26
|
+
*
|
|
27
|
+
* The first argument is an object that defines the props that will be extracted,
|
|
28
|
+
* with their default values. To extract a prop without a default, set it to
|
|
29
|
+
* `undefined`.
|
|
30
|
+
*
|
|
31
|
+
* The hook function must be passed as the second argument, and it will receive
|
|
32
|
+
* the rest of the props and the extracted options.
|
|
33
|
+
* @example
|
|
34
|
+
* ```jsx
|
|
35
|
+
* export const useMyComponent = createHook<TagName, MyComponentOptions>(
|
|
36
|
+
* withOptions(
|
|
37
|
+
* { orientation: "horizontal" },
|
|
38
|
+
* function useMyComponent(props, options) {
|
|
39
|
+
* // ...
|
|
40
|
+
* },
|
|
41
|
+
* ),
|
|
42
|
+
* );
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function withOptions<T extends ValidComponent, P extends AnyObject, const D extends Partial<ComputedP>, ComputedP extends Props<T, P>>(defaults: D, useProps: (props: ExtractPropsWithDefaultsRestProps<ComputedP, D>, options: ExtractPropsWithDefaultsExtractedProps<ComputedP, D>) => HTMLProps<T, P>): (props: ComputedP) => HTMLProps<T, P>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { AnyObject, EmptyObject } from "@ariakit/core/utils/types";
|
|
2
|
+
import { type ValidComponent } from "solid-js";
|
|
3
|
+
import { type ExtractPropsWithDefaultsExtractedProps, type ExtractPropsWithDefaultsRestProps } from "./reactivity.ts";
|
|
4
|
+
import type { HTMLProps, Hook, Options, Props, WrapInstance, WrapInstanceValue } from "./types.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Creates a Solid component instance that supports the `render` and
|
|
7
|
+
* `wrapInstance` props.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createInstance(Component: ValidComponent, props: Props<ValidComponent, Options>): import("solid-js").JSX.Element;
|
|
10
|
+
/**
|
|
11
|
+
* Returns props with an additional `wrapInstance` prop.
|
|
12
|
+
*/
|
|
13
|
+
export declare function wrapInstance<P, Q = P & {
|
|
14
|
+
wrapInstance: WrapInstance;
|
|
15
|
+
}>(props: P & {
|
|
16
|
+
wrapInstance?: WrapInstance;
|
|
17
|
+
}, element: WrapInstanceValue): Q;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a component hook that accepts props and returns props so they can be
|
|
20
|
+
* passed to a Solid component.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createHook<T extends ValidComponent, P extends AnyObject = EmptyObject>(useProps: (props: Props<T, P>) => HTMLProps<T, P>): Hook<T, P>;
|
|
23
|
+
/**
|
|
24
|
+
* Splits "option props" from the rest in a component hook. Must be called
|
|
25
|
+
* inside `createHook`.
|
|
26
|
+
*
|
|
27
|
+
* The first argument is an object that defines the props that will be extracted,
|
|
28
|
+
* with their default values. To extract a prop without a default, set it to
|
|
29
|
+
* `undefined`.
|
|
30
|
+
*
|
|
31
|
+
* The hook function must be passed as the second argument, and it will receive
|
|
32
|
+
* the rest of the props and the extracted options.
|
|
33
|
+
* @example
|
|
34
|
+
* ```jsx
|
|
35
|
+
* export const useMyComponent = createHook<TagName, MyComponentOptions>(
|
|
36
|
+
* withOptions(
|
|
37
|
+
* { orientation: "horizontal" },
|
|
38
|
+
* function useMyComponent(props, options) {
|
|
39
|
+
* // ...
|
|
40
|
+
* },
|
|
41
|
+
* ),
|
|
42
|
+
* );
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function withOptions<T extends ValidComponent, P extends AnyObject, const D extends Partial<ComputedP>, ComputedP extends Props<T, P>>(defaults: D, useProps: (props: ExtractPropsWithDefaultsRestProps<ComputedP, D>, options: ExtractPropsWithDefaultsExtractedProps<ComputedP, D>) => HTMLProps<T, P>): (props: ComputedP) => HTMLProps<T, P>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { AnyObject, EmptyObject } from "@ariakit/core/utils/types";
|
|
2
|
+
import type { Component, ComponentProps, JSX, ParentProps, ValidComponent } from "solid-js";
|
|
3
|
+
/**
|
|
4
|
+
* A value that can be rendered when passed to the `render` prop or the
|
|
5
|
+
* `wrapInstance` prop.
|
|
6
|
+
*/
|
|
7
|
+
export type RenderValue<P extends AnyObject> = JSX.Element | Component<P>;
|
|
8
|
+
/**
|
|
9
|
+
* A value passed to the `wrapInstance` prop.
|
|
10
|
+
*/
|
|
11
|
+
export type WrapInstanceValue = RenderValue<ParentProps>;
|
|
12
|
+
/**
|
|
13
|
+
* The `wrapInstance` prop.
|
|
14
|
+
*/
|
|
15
|
+
export type WrapInstance = Array<WrapInstanceValue>;
|
|
16
|
+
/**
|
|
17
|
+
* Custom props including the `render` prop.
|
|
18
|
+
*/
|
|
19
|
+
export interface Options {
|
|
20
|
+
wrapInstance?: WrapInstance;
|
|
21
|
+
/**
|
|
22
|
+
* Allows the component to be rendered as a different HTML element or Solid
|
|
23
|
+
* component. The value can be an `As` component instance or a function that
|
|
24
|
+
* takes in the original component props and gives back a Solid component
|
|
25
|
+
* instance with the props merged.
|
|
26
|
+
*
|
|
27
|
+
* Check out the [Composition](https://solid.ariakit.org/guide/composition) guide
|
|
28
|
+
* for more details.
|
|
29
|
+
*/
|
|
30
|
+
render?: RenderValue<JSX.HTMLAttributes<any>>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* HTML props based on the element type, excluding custom props.
|
|
34
|
+
* @template T The element type.
|
|
35
|
+
* @template P Custom props.
|
|
36
|
+
* @example
|
|
37
|
+
* type ButtonHTMLProps = HTMLProps<"button", { custom?: boolean }>;
|
|
38
|
+
*/
|
|
39
|
+
export type HTMLProps<T extends ValidComponent, P extends AnyObject = EmptyObject> = Omit<ComponentProps<T>, keyof P> & {
|
|
40
|
+
[index: `data-${string}`]: unknown;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Props based on the element type, including custom props.
|
|
44
|
+
* @template T The element type.
|
|
45
|
+
* @template P Custom props.
|
|
46
|
+
*/
|
|
47
|
+
export type Props<T extends ValidComponent, P extends AnyObject = EmptyObject> = P & HTMLProps<T, P>;
|
|
48
|
+
/**
|
|
49
|
+
* A component hook that supports the `render` prop and returns HTML props based
|
|
50
|
+
* on the element type.
|
|
51
|
+
* @template T The element type.
|
|
52
|
+
* @template P Custom props.
|
|
53
|
+
* @example
|
|
54
|
+
* type UseButton = Hook<"button", { custom?: boolean }>;
|
|
55
|
+
*/
|
|
56
|
+
export type Hook<T extends ValidComponent, P extends AnyObject = EmptyObject> = <ElementType extends ValidComponent = T>(props?: Props<ElementType, P>) => HTMLProps<ElementType, P>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { AnyObject, EmptyObject } from "@ariakit/core/utils/types";
|
|
2
|
+
import type { Component, ComponentProps, JSX, ParentProps, ValidComponent } from "solid-js";
|
|
3
|
+
/**
|
|
4
|
+
* A value that can be rendered when passed to the `render` prop or the
|
|
5
|
+
* `wrapInstance` prop.
|
|
6
|
+
*/
|
|
7
|
+
export type RenderValue<P extends AnyObject> = JSX.Element | Component<P>;
|
|
8
|
+
/**
|
|
9
|
+
* A value passed to the `wrapInstance` prop.
|
|
10
|
+
*/
|
|
11
|
+
export type WrapInstanceValue = RenderValue<ParentProps>;
|
|
12
|
+
/**
|
|
13
|
+
* The `wrapInstance` prop.
|
|
14
|
+
*/
|
|
15
|
+
export type WrapInstance = Array<WrapInstanceValue>;
|
|
16
|
+
/**
|
|
17
|
+
* Custom props including the `render` prop.
|
|
18
|
+
*/
|
|
19
|
+
export interface Options {
|
|
20
|
+
wrapInstance?: WrapInstance;
|
|
21
|
+
/**
|
|
22
|
+
* Allows the component to be rendered as a different HTML element or Solid
|
|
23
|
+
* component. The value can be an `As` component instance or a function that
|
|
24
|
+
* takes in the original component props and gives back a Solid component
|
|
25
|
+
* instance with the props merged.
|
|
26
|
+
*
|
|
27
|
+
* Check out the [Composition](https://solid.ariakit.org/guide/composition) guide
|
|
28
|
+
* for more details.
|
|
29
|
+
*/
|
|
30
|
+
render?: RenderValue<JSX.HTMLAttributes<any>>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* HTML props based on the element type, excluding custom props.
|
|
34
|
+
* @template T The element type.
|
|
35
|
+
* @template P Custom props.
|
|
36
|
+
* @example
|
|
37
|
+
* type ButtonHTMLProps = HTMLProps<"button", { custom?: boolean }>;
|
|
38
|
+
*/
|
|
39
|
+
export type HTMLProps<T extends ValidComponent, P extends AnyObject = EmptyObject> = Omit<ComponentProps<T>, keyof P> & {
|
|
40
|
+
[index: `data-${string}`]: unknown;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Props based on the element type, including custom props.
|
|
44
|
+
* @template T The element type.
|
|
45
|
+
* @template P Custom props.
|
|
46
|
+
*/
|
|
47
|
+
export type Props<T extends ValidComponent, P extends AnyObject = EmptyObject> = P & HTMLProps<T, P>;
|
|
48
|
+
/**
|
|
49
|
+
* A component hook that supports the `render` prop and returns HTML props based
|
|
50
|
+
* on the element type.
|
|
51
|
+
* @template T The element type.
|
|
52
|
+
* @template P Custom props.
|
|
53
|
+
* @example
|
|
54
|
+
* type UseButton = Hook<"button", { custom?: boolean }>;
|
|
55
|
+
*/
|
|
56
|
+
export type Hook<T extends ValidComponent, P extends AnyObject = EmptyObject> = <ElementType extends ValidComponent = T>(props?: Props<ElementType, P>) => HTMLProps<ElementType, P>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _JFCGWMZCcjs = require('../__chunks/JFCGWMZC.cjs');
|
|
5
|
+
require('../__chunks/V3ZEI37L.cjs');
|
|
6
|
+
require('../__chunks/RLO4RIGL.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.VisuallyHidden = _JFCGWMZCcjs.VisuallyHidden; exports.useVisuallyHidden = _JFCGWMZCcjs.useVisuallyHidden;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ValidComponent } from "solid-js";
|
|
2
|
+
import type { Options, Props } from "../utils/types.ts";
|
|
3
|
+
declare const TagName = "span";
|
|
4
|
+
type TagName = typeof TagName;
|
|
5
|
+
/**
|
|
6
|
+
* Returns props to create a `VisuallyHidden` component. When applying the props
|
|
7
|
+
* returned by this hook to a component, the component will be visually hidden,
|
|
8
|
+
* but still accessible to screen readers.
|
|
9
|
+
* @see https://solid.ariakit.org/components/visually-hidden
|
|
10
|
+
* @example
|
|
11
|
+
* ```jsx
|
|
12
|
+
* const props = useVisuallyHidden();
|
|
13
|
+
* <a href="#">
|
|
14
|
+
* Learn more<Role {...props}> about the Solar System</Role>.
|
|
15
|
+
* </a>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const useVisuallyHidden: import("../utils/types.ts").Hook<"span", VisuallyHiddenOptions<"span">>;
|
|
19
|
+
/**
|
|
20
|
+
* Renders an element that's visually hidden, but still accessible to screen
|
|
21
|
+
* readers.
|
|
22
|
+
* @see https://solid.ariakit.org/components/visually-hidden
|
|
23
|
+
* @example
|
|
24
|
+
* ```jsx
|
|
25
|
+
* <a href="#">
|
|
26
|
+
* Learn more<VisuallyHidden> about the Solar System</VisuallyHidden>.
|
|
27
|
+
* </a>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function VisuallyHidden(props: VisuallyHiddenProps): import("solid-js").JSX.Element;
|
|
31
|
+
export interface VisuallyHiddenOptions<_T extends ValidComponent = TagName> extends Options {
|
|
32
|
+
}
|
|
33
|
+
export type VisuallyHiddenProps = Props<TagName, VisuallyHiddenOptions>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ValidComponent } from "solid-js";
|
|
2
|
+
import type { Options, Props } from "../utils/types.ts";
|
|
3
|
+
declare const TagName = "span";
|
|
4
|
+
type TagName = typeof TagName;
|
|
5
|
+
/**
|
|
6
|
+
* Returns props to create a `VisuallyHidden` component. When applying the props
|
|
7
|
+
* returned by this hook to a component, the component will be visually hidden,
|
|
8
|
+
* but still accessible to screen readers.
|
|
9
|
+
* @see https://solid.ariakit.org/components/visually-hidden
|
|
10
|
+
* @example
|
|
11
|
+
* ```jsx
|
|
12
|
+
* const props = useVisuallyHidden();
|
|
13
|
+
* <a href="#">
|
|
14
|
+
* Learn more<Role {...props}> about the Solar System</Role>.
|
|
15
|
+
* </a>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const useVisuallyHidden: import("../utils/types.ts").Hook<"span", VisuallyHiddenOptions<"span">>;
|
|
19
|
+
/**
|
|
20
|
+
* Renders an element that's visually hidden, but still accessible to screen
|
|
21
|
+
* readers.
|
|
22
|
+
* @see https://solid.ariakit.org/components/visually-hidden
|
|
23
|
+
* @example
|
|
24
|
+
* ```jsx
|
|
25
|
+
* <a href="#">
|
|
26
|
+
* Learn more<VisuallyHidden> about the Solar System</VisuallyHidden>.
|
|
27
|
+
* </a>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function VisuallyHidden(props: VisuallyHiddenProps): import("solid-js").JSX.Element;
|
|
31
|
+
export interface VisuallyHiddenOptions<_T extends ValidComponent = TagName> extends Options {
|
|
32
|
+
}
|
|
33
|
+
export type VisuallyHiddenProps = Props<TagName, VisuallyHiddenOptions>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useVisuallyHidden
|
|
3
|
+
} from "./SFKMELHD.js";
|
|
4
|
+
import {
|
|
5
|
+
createHook,
|
|
6
|
+
createInstance
|
|
7
|
+
} from "./OKOFCLOZ.js";
|
|
8
|
+
import {
|
|
9
|
+
mergeProps
|
|
10
|
+
} from "./QKOHDUFI.js";
|
|
11
|
+
|
|
12
|
+
// src/focus-trap/focus-trap.tsx
|
|
13
|
+
var TagName = "span";
|
|
14
|
+
var useFocusTrap = createHook(function useFocusTrap2(props) {
|
|
15
|
+
props = mergeProps({
|
|
16
|
+
"data-focus-trap": "",
|
|
17
|
+
tabIndex: 0,
|
|
18
|
+
"aria-hidden": true,
|
|
19
|
+
style: {
|
|
20
|
+
// Prevents unintended scroll jumps.
|
|
21
|
+
position: "fixed",
|
|
22
|
+
top: 0,
|
|
23
|
+
left: 0
|
|
24
|
+
}
|
|
25
|
+
}, props);
|
|
26
|
+
props = useVisuallyHidden(props);
|
|
27
|
+
return props;
|
|
28
|
+
});
|
|
29
|
+
function FocusTrap(props) {
|
|
30
|
+
const htmlProps = useFocusTrap(props);
|
|
31
|
+
return createInstance(TagName, htmlProps);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
useFocusTrap,
|
|
36
|
+
FocusTrap
|
|
37
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mergeProps
|
|
3
|
+
} from "./QKOHDUFI.js";
|
|
4
|
+
|
|
5
|
+
// src/as/as.tsx
|
|
6
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
7
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
8
|
+
import { Dynamic } from "solid-js/web";
|
|
9
|
+
var cache = /* @__PURE__ */ new Map();
|
|
10
|
+
var As = new Proxy(function As2(props) {
|
|
11
|
+
return (parentProps) => (
|
|
12
|
+
// TODO: replace with LazyDynamic
|
|
13
|
+
_$createComponent(Dynamic, _$mergeProps(() => mergeProps(parentProps, props), {
|
|
14
|
+
get component() {
|
|
15
|
+
return props.component;
|
|
16
|
+
}
|
|
17
|
+
}))
|
|
18
|
+
);
|
|
19
|
+
}, {
|
|
20
|
+
get: (_, key) => {
|
|
21
|
+
let component = cache.get(key);
|
|
22
|
+
if (!component) {
|
|
23
|
+
component = function AsElement(props) {
|
|
24
|
+
return (parentProps) => (
|
|
25
|
+
// TODO: replace with LazyDynamic
|
|
26
|
+
_$createComponent(Dynamic, _$mergeProps(() => mergeProps(parentProps, props), {
|
|
27
|
+
component: key
|
|
28
|
+
}))
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
cache.set(key, component);
|
|
32
|
+
}
|
|
33
|
+
return component;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
As
|
|
39
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractPropsWithDefaults
|
|
3
|
+
} from "./QKOHDUFI.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/system.tsx
|
|
6
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
7
|
+
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
8
|
+
import { memo as _$memo } from "solid-js/web";
|
|
9
|
+
import { mergeProps, splitProps } from "solid-js";
|
|
10
|
+
import { Dynamic } from "solid-js/web";
|
|
11
|
+
function createInstance(Component, props) {
|
|
12
|
+
const [features, rest] = splitProps(props, ["render", "wrapInstance"]);
|
|
13
|
+
const withRender = () => (
|
|
14
|
+
// TODO: replace with LazyDynamic
|
|
15
|
+
_$createComponent(Dynamic, _$mergeProps(rest, {
|
|
16
|
+
get component() {
|
|
17
|
+
var _a;
|
|
18
|
+
return (_a = features.render) != null ? _a : Component;
|
|
19
|
+
}
|
|
20
|
+
}))
|
|
21
|
+
);
|
|
22
|
+
let tree = withRender;
|
|
23
|
+
if (features.wrapInstance) {
|
|
24
|
+
for (const element of features.wrapInstance) {
|
|
25
|
+
const children = tree;
|
|
26
|
+
tree = () => (
|
|
27
|
+
// TODO: replace with LazyDynamic
|
|
28
|
+
_$createComponent(Dynamic, {
|
|
29
|
+
component: element,
|
|
30
|
+
get children() {
|
|
31
|
+
return children();
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return tree();
|
|
38
|
+
}
|
|
39
|
+
function wrapInstance(props, element) {
|
|
40
|
+
var _a;
|
|
41
|
+
const wrapInstance2 = [...(_a = props.wrapInstance) != null ? _a : [], element];
|
|
42
|
+
return mergeProps(props, {
|
|
43
|
+
wrapInstance: wrapInstance2
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function createHook(useProps) {
|
|
47
|
+
return useProps;
|
|
48
|
+
}
|
|
49
|
+
function withOptions(defaults, useProps) {
|
|
50
|
+
return function usePropsWithOptions(props) {
|
|
51
|
+
const [options, rest] = extractPropsWithDefaults(props, defaults);
|
|
52
|
+
return useProps(rest, options);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
createInstance,
|
|
58
|
+
wrapInstance,
|
|
59
|
+
createHook,
|
|
60
|
+
withOptions
|
|
61
|
+
};
|