@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,42 @@
|
|
|
1
|
+
// src/utils/reactivity.ts
|
|
2
|
+
import { combineProps } from "@solid-primitives/props";
|
|
3
|
+
import {
|
|
4
|
+
createSignal,
|
|
5
|
+
mergeProps as solidMergeProps,
|
|
6
|
+
splitProps,
|
|
7
|
+
untrack
|
|
8
|
+
} from "solid-js";
|
|
9
|
+
function stableAccessor(value, callback) {
|
|
10
|
+
return () => callback(value);
|
|
11
|
+
}
|
|
12
|
+
function extractPropsWithDefaults(props, defaults) {
|
|
13
|
+
const [own, rest] = splitProps(props, Object.keys(defaults));
|
|
14
|
+
return [
|
|
15
|
+
solidMergeProps(defaults, own),
|
|
16
|
+
rest
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
function createRef(initialValue) {
|
|
20
|
+
const [get, set] = createSignal(initialValue);
|
|
21
|
+
return {
|
|
22
|
+
get current() {
|
|
23
|
+
return untrack(() => get());
|
|
24
|
+
},
|
|
25
|
+
get,
|
|
26
|
+
set,
|
|
27
|
+
reset: () => set(initialValue)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function mergeProps(base, overrides, skipProps) {
|
|
31
|
+
return combineProps(
|
|
32
|
+
[base, skipProps ? splitProps(overrides, skipProps)[1] : overrides],
|
|
33
|
+
{ reverseEventHandlers: true }
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
stableAccessor,
|
|
39
|
+
extractPropsWithDefaults,
|
|
40
|
+
createRef,
|
|
41
|
+
mergeProps
|
|
42
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createHook,
|
|
3
|
+
createInstance
|
|
4
|
+
} from "./OKOFCLOZ.js";
|
|
5
|
+
import {
|
|
6
|
+
mergeProps
|
|
7
|
+
} from "./QKOHDUFI.js";
|
|
8
|
+
|
|
9
|
+
// src/visually-hidden/visually-hidden.tsx
|
|
10
|
+
var TagName = "span";
|
|
11
|
+
var useVisuallyHidden = createHook(function useVisuallyHidden2(props) {
|
|
12
|
+
props = mergeProps({
|
|
13
|
+
style: {
|
|
14
|
+
border: 0,
|
|
15
|
+
clip: "rect(0 0 0 0)",
|
|
16
|
+
height: "1px",
|
|
17
|
+
margin: "-1px",
|
|
18
|
+
overflow: "hidden",
|
|
19
|
+
padding: 0,
|
|
20
|
+
position: "absolute",
|
|
21
|
+
"white-space": "nowrap",
|
|
22
|
+
width: "1px"
|
|
23
|
+
}
|
|
24
|
+
}, props);
|
|
25
|
+
return props;
|
|
26
|
+
});
|
|
27
|
+
function VisuallyHidden(props) {
|
|
28
|
+
const htmlProps = useVisuallyHidden(props);
|
|
29
|
+
return createInstance(TagName, htmlProps);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
useVisuallyHidden,
|
|
34
|
+
VisuallyHidden
|
|
35
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/utils/misc.ts
|
|
2
|
+
import { access } from "@solid-primitives/utils";
|
|
3
|
+
import { createUniqueId } from "solid-js";
|
|
4
|
+
function createId(defaultId) {
|
|
5
|
+
const id = createUniqueId();
|
|
6
|
+
return () => {
|
|
7
|
+
var _a;
|
|
8
|
+
return (_a = access(defaultId)) != null ? _a : id;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function extractTagName(element, fallback) {
|
|
12
|
+
return () => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
return (_b = (_a = access(element)) == null ? void 0 : _a.tagName.toLowerCase()) != null ? _b : typeof fallback === "string" ? fallback : void 0;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
createId,
|
|
20
|
+
extractTagName
|
|
21
|
+
};
|
package/esm/as/as.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Component, ComponentProps, JSX, ValidComponent } from "solid-js";
|
|
2
|
+
type AsElements = {
|
|
3
|
+
[K in keyof JSX.IntrinsicElements]: Component<ComponentProps<K>>;
|
|
4
|
+
};
|
|
5
|
+
type AsComponent = <T extends Component<any>, P = ComponentProps<T>>(props: AsProps<T, P>) => JSX.Element;
|
|
6
|
+
/**
|
|
7
|
+
* Allows a component to be rendered as a different HTML element or Solid
|
|
8
|
+
* component. Must be passed to the `render` prop of a component that
|
|
9
|
+
* supports it.
|
|
10
|
+
*
|
|
11
|
+
* To render as an HTML element, use `<As.element />` (e.g. `<As.button />`).
|
|
12
|
+
*
|
|
13
|
+
* To render as a component, use `<As component={Component} />` (e.g. `<As
|
|
14
|
+
* component={MyButton} />`).
|
|
15
|
+
*
|
|
16
|
+
* Check out the [Composition](https://solid.ariakit.org/guide/composition)
|
|
17
|
+
* guide for more details.
|
|
18
|
+
* @example
|
|
19
|
+
* ```jsx
|
|
20
|
+
* <Role render={<As component={MyButton} variant="primary" />} />
|
|
21
|
+
* <Role render={<As.button type="button" />} />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const As: AsComponent & AsElements;
|
|
25
|
+
export type AsProps<T extends ValidComponent, P = ComponentProps<T>> = {
|
|
26
|
+
[K in keyof P]: P[K];
|
|
27
|
+
} & {
|
|
28
|
+
component: T;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
package/esm/as/as.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ValidComponent } from "solid-js";
|
|
2
|
+
import type { Options, Props } from "../utils/types.ts";
|
|
3
|
+
declare const TagName = "div";
|
|
4
|
+
type TagName = typeof TagName;
|
|
5
|
+
/**
|
|
6
|
+
* Returns props to create a `FocusTrapRegion` component.
|
|
7
|
+
* @see https://solid.ariakit.org/components/focus-trap-region
|
|
8
|
+
* @example
|
|
9
|
+
* ```jsx
|
|
10
|
+
* const props = useFocusTrapRegion();
|
|
11
|
+
* <Role {...props} />
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const useFocusTrapRegion: import("../utils/types.ts").Hook<"div", FocusTrapRegionOptions<"div">>;
|
|
15
|
+
/**
|
|
16
|
+
* Renders a wrapper element that traps the focus inside it when the
|
|
17
|
+
* [`enabled`](https://solid.ariakit.org/reference/focus-trap-region#enabled)
|
|
18
|
+
* prop is `true`.
|
|
19
|
+
* @see https://solid.ariakit.org/components/focus-trap
|
|
20
|
+
* @example
|
|
21
|
+
* ```jsx
|
|
22
|
+
* <FocusTrapRegion>
|
|
23
|
+
* <Button>click me</Button>
|
|
24
|
+
* <Button>trap focus</Button>
|
|
25
|
+
* <Button disabled>disabled Button</Button>
|
|
26
|
+
* </FocusTrapRegion>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const FocusTrapRegion: (props: FocusTrapRegionProps) => import("solid-js").JSX.Element;
|
|
30
|
+
export interface FocusTrapRegionOptions<_T extends ValidComponent = TagName> extends Options {
|
|
31
|
+
/**
|
|
32
|
+
* If true, it will trap the focus in the region.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export type FocusTrapRegionProps<T extends ValidComponent = TagName> = Props<T, FocusTrapRegionOptions<T>>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FocusTrap
|
|
3
|
+
} from "../__chunks/ILGMKAYU.js";
|
|
4
|
+
import "../__chunks/SFKMELHD.js";
|
|
5
|
+
import {
|
|
6
|
+
createHook,
|
|
7
|
+
createInstance,
|
|
8
|
+
withOptions,
|
|
9
|
+
wrapInstance
|
|
10
|
+
} from "../__chunks/OKOFCLOZ.js";
|
|
11
|
+
import {
|
|
12
|
+
createRef,
|
|
13
|
+
mergeProps
|
|
14
|
+
} from "../__chunks/QKOHDUFI.js";
|
|
15
|
+
|
|
16
|
+
// src/focus-trap/focus-trap-region.tsx
|
|
17
|
+
import { memo as _$memo } from "solid-js/web";
|
|
18
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
19
|
+
import { getAllTabbableIn } from "@ariakit/core/utils/focus";
|
|
20
|
+
import { Show } from "solid-js";
|
|
21
|
+
var TagName = "div";
|
|
22
|
+
var useFocusTrapRegion = createHook(withOptions({
|
|
23
|
+
enabled: false
|
|
24
|
+
}, function useFocusTrapRegion2(props, options) {
|
|
25
|
+
const ref = createRef();
|
|
26
|
+
props = wrapInstance(props, (wrapperProps) => {
|
|
27
|
+
const renderFocusTrap = () => {
|
|
28
|
+
return _$createComponent(Show, {
|
|
29
|
+
get when() {
|
|
30
|
+
return options.enabled;
|
|
31
|
+
},
|
|
32
|
+
get children() {
|
|
33
|
+
return _$createComponent(FocusTrap, {
|
|
34
|
+
onFocus: (event) => {
|
|
35
|
+
const container = ref.current;
|
|
36
|
+
if (!container) return;
|
|
37
|
+
const tabbables = getAllTabbableIn(container, true);
|
|
38
|
+
const first = tabbables[0];
|
|
39
|
+
const last = tabbables[tabbables.length - 1];
|
|
40
|
+
if (!tabbables.length) {
|
|
41
|
+
container.focus();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (event.relatedTarget === first) {
|
|
45
|
+
last == null ? void 0 : last.focus();
|
|
46
|
+
} else {
|
|
47
|
+
first == null ? void 0 : first.focus();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
return [_$memo(renderFocusTrap), _$memo(() => wrapperProps.children), _$memo(renderFocusTrap)];
|
|
55
|
+
});
|
|
56
|
+
props = mergeProps({
|
|
57
|
+
ref: ref.set
|
|
58
|
+
}, props);
|
|
59
|
+
return props;
|
|
60
|
+
}));
|
|
61
|
+
var FocusTrapRegion = function FocusTrapRegion2(props) {
|
|
62
|
+
const htmlProps = useFocusTrapRegion(props);
|
|
63
|
+
return createInstance(TagName, htmlProps);
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
FocusTrapRegion,
|
|
67
|
+
useFocusTrapRegion
|
|
68
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ValidComponent } from "solid-js";
|
|
2
|
+
import type { Props } from "../utils/types.ts";
|
|
3
|
+
import type { VisuallyHiddenOptions } from "../visually-hidden/visually-hidden.tsx";
|
|
4
|
+
declare const TagName = "span";
|
|
5
|
+
type TagName = typeof TagName;
|
|
6
|
+
/**
|
|
7
|
+
* Returns props to create a `FocusTrap` component.
|
|
8
|
+
* @see https://solid.ariakit.org/components/focus-trap
|
|
9
|
+
* @example
|
|
10
|
+
* ```jsx
|
|
11
|
+
* const props = useFocusTrap();
|
|
12
|
+
* <Role {...props} />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const useFocusTrap: import("../utils/types.ts").Hook<"span", FocusTrapOptions<"span">>;
|
|
16
|
+
/**
|
|
17
|
+
* Renders a focus trap element.
|
|
18
|
+
* @see https://solid.ariakit.org/components/focus-trap
|
|
19
|
+
* @example
|
|
20
|
+
* ```jsx
|
|
21
|
+
* <FocusTrap onFocus={focusSomethingElse} />
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function FocusTrap(props: FocusTrapProps): import("solid-js").JSX.Element;
|
|
25
|
+
export type FocusTrapOptions<T extends ValidComponent = TagName> = VisuallyHiddenOptions<T>;
|
|
26
|
+
export type FocusTrapProps<T extends ValidComponent = TagName> = Props<T, FocusTrapOptions<T>>;
|
|
27
|
+
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 = "div";
|
|
4
|
+
type TagName = typeof TagName;
|
|
5
|
+
/**
|
|
6
|
+
* Returns props to create a `GroupLabel` component. This hook must be used in a
|
|
7
|
+
* component that's wrapped with `Group` so the `aria-labelledby` prop is
|
|
8
|
+
* properly set on the group element.
|
|
9
|
+
* @see https://solid.ariakit.org/components/group
|
|
10
|
+
* @example
|
|
11
|
+
* ```jsx
|
|
12
|
+
* // This component must be wrapped with Group
|
|
13
|
+
* const props = useGroupLabel();
|
|
14
|
+
* <Role {...props}>Label</Role>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const useGroupLabel: import("../utils/types.ts").Hook<"div", GroupLabelOptions<"div">>;
|
|
18
|
+
/**
|
|
19
|
+
* Renders a label in a group. This component should be wrapped with a
|
|
20
|
+
* [`Group`](https://solid.ariakit.org/reference/group) so the `aria-labelledby`
|
|
21
|
+
* prop is correctly set on the group element.
|
|
22
|
+
* @see https://solid.ariakit.org/components/group
|
|
23
|
+
* @example
|
|
24
|
+
* ```jsx
|
|
25
|
+
* <Group>
|
|
26
|
+
* <GroupLabel>Label</GroupLabel>
|
|
27
|
+
* </Group>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare const GroupLabel: (props: GroupLabelProps) => import("solid-js").JSX.Element;
|
|
31
|
+
export interface GroupLabelOptions<_T extends ValidComponent = TagName> extends Options {
|
|
32
|
+
}
|
|
33
|
+
export type GroupLabelProps<T extends ValidComponent = TagName> = Props<T, GroupLabelOptions<T>>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createId
|
|
3
|
+
} from "../__chunks/UKDBTPK5.js";
|
|
4
|
+
import {
|
|
5
|
+
createHook,
|
|
6
|
+
createInstance
|
|
7
|
+
} from "../__chunks/OKOFCLOZ.js";
|
|
8
|
+
import {
|
|
9
|
+
mergeProps,
|
|
10
|
+
stableAccessor
|
|
11
|
+
} from "../__chunks/QKOHDUFI.js";
|
|
12
|
+
import {
|
|
13
|
+
GroupLabelContext
|
|
14
|
+
} from "../__chunks/VOWRNGOM.js";
|
|
15
|
+
|
|
16
|
+
// src/group/group-label.tsx
|
|
17
|
+
import { createEffect, onCleanup, useContext } from "solid-js";
|
|
18
|
+
var TagName = "div";
|
|
19
|
+
var useGroupLabel = createHook(function useGroupLabel2(props) {
|
|
20
|
+
const setLabelId = useContext(GroupLabelContext);
|
|
21
|
+
const id = createId(stableAccessor(props, (p) => p.id));
|
|
22
|
+
createEffect(() => {
|
|
23
|
+
setLabelId == null ? void 0 : setLabelId(id());
|
|
24
|
+
onCleanup(() => setLabelId == null ? void 0 : setLabelId(void 0));
|
|
25
|
+
});
|
|
26
|
+
props = mergeProps({
|
|
27
|
+
get id() {
|
|
28
|
+
return id();
|
|
29
|
+
},
|
|
30
|
+
"aria-hidden": true
|
|
31
|
+
}, props);
|
|
32
|
+
return props;
|
|
33
|
+
});
|
|
34
|
+
var GroupLabel = function GroupLabel2(props) {
|
|
35
|
+
const htmlProps = useGroupLabel(props);
|
|
36
|
+
return createInstance(TagName, htmlProps);
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
GroupLabel,
|
|
40
|
+
useGroupLabel
|
|
41
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ValidComponent } from "solid-js";
|
|
2
|
+
import type { Options, Props } from "../utils/types.ts";
|
|
3
|
+
declare const TagName = "div";
|
|
4
|
+
type TagName = typeof TagName;
|
|
5
|
+
/**
|
|
6
|
+
* Returns props to create a `Group` component.
|
|
7
|
+
* @see https://solid.ariakit.org/components/group
|
|
8
|
+
* @example
|
|
9
|
+
* ```jsx
|
|
10
|
+
* const props = useGroup();
|
|
11
|
+
* <Role {...props}>Group</Role>
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const useGroup: import("../utils/types.ts").Hook<"div", Options>;
|
|
15
|
+
/**
|
|
16
|
+
* Renders a group element. Optionally, a
|
|
17
|
+
* [`GroupLabel`](https://solid.ariakit.org/reference/group-label) can be rendered as
|
|
18
|
+
* a child to provide a label for the group.
|
|
19
|
+
* @see https://solid.ariakit.org/components/group
|
|
20
|
+
* @example
|
|
21
|
+
* ```jsx
|
|
22
|
+
* <Group>Group</Group>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const Group: (props: GroupProps) => import("solid-js").JSX.Element;
|
|
26
|
+
export type GroupOptions<_T extends ValidComponent = TagName> = Options;
|
|
27
|
+
export type GroupProps<T extends ValidComponent = TagName> = Props<T, GroupOptions<T>>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
As
|
|
3
|
+
} from "../__chunks/NX66AMGW.js";
|
|
4
|
+
import {
|
|
5
|
+
createHook,
|
|
6
|
+
createInstance,
|
|
7
|
+
wrapInstance
|
|
8
|
+
} from "../__chunks/OKOFCLOZ.js";
|
|
9
|
+
import {
|
|
10
|
+
mergeProps
|
|
11
|
+
} from "../__chunks/QKOHDUFI.js";
|
|
12
|
+
import {
|
|
13
|
+
GroupLabelContext
|
|
14
|
+
} from "../__chunks/VOWRNGOM.js";
|
|
15
|
+
|
|
16
|
+
// src/group/group.tsx
|
|
17
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
18
|
+
import { createSignal } from "solid-js";
|
|
19
|
+
var TagName = "div";
|
|
20
|
+
var useGroup = createHook(function useGroup2(props) {
|
|
21
|
+
const [labelId, setLabelId] = createSignal();
|
|
22
|
+
props = wrapInstance(props, _$createComponent(As, {
|
|
23
|
+
get component() {
|
|
24
|
+
return GroupLabelContext.Provider;
|
|
25
|
+
},
|
|
26
|
+
value: setLabelId
|
|
27
|
+
}));
|
|
28
|
+
props = mergeProps({
|
|
29
|
+
role: "group",
|
|
30
|
+
get "aria-labelledby"() {
|
|
31
|
+
return labelId();
|
|
32
|
+
}
|
|
33
|
+
}, props);
|
|
34
|
+
return props;
|
|
35
|
+
});
|
|
36
|
+
var Group = function Group2(props) {
|
|
37
|
+
const htmlProps = useGroup(props);
|
|
38
|
+
return createInstance(TagName, htmlProps);
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
Group,
|
|
42
|
+
useGroup
|
|
43
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type JSX } from "solid-js";
|
|
2
|
+
import type { HeadingLevels } from "./utils.ts";
|
|
3
|
+
/**
|
|
4
|
+
* A component that sets the heading level for its children. It doesn't render
|
|
5
|
+
* any HTML element, just sets the
|
|
6
|
+
* [`level`](https://solid.ariakit.org/reference/heading-level#level) prop on the
|
|
7
|
+
* context.
|
|
8
|
+
* @see https://solid.ariakit.org/components/heading
|
|
9
|
+
* @example
|
|
10
|
+
* ```jsx
|
|
11
|
+
* <HeadingLevel>
|
|
12
|
+
* <Heading>Heading 1</Heading>
|
|
13
|
+
* <HeadingLevel>
|
|
14
|
+
* <Heading>Heading 2</Heading>
|
|
15
|
+
* </HeadingLevel>
|
|
16
|
+
* </HeadingLevel>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function HeadingLevel(props: HeadingLevelProps): JSX.Element;
|
|
20
|
+
export interface HeadingLevelProps {
|
|
21
|
+
/**
|
|
22
|
+
* The heading level. By default, it'll increase the level by 1 based on the
|
|
23
|
+
* context.
|
|
24
|
+
*/
|
|
25
|
+
level?: HeadingLevels;
|
|
26
|
+
children?: JSX.Element;
|
|
27
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HeadingContext
|
|
3
|
+
} from "../__chunks/I7JSIDPD.js";
|
|
4
|
+
|
|
5
|
+
// src/heading/heading-level.tsx
|
|
6
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
7
|
+
import { useContext } from "solid-js";
|
|
8
|
+
function HeadingLevel(props) {
|
|
9
|
+
const contextLevel = useContext(HeadingContext);
|
|
10
|
+
const nextLevel = () => {
|
|
11
|
+
var _a;
|
|
12
|
+
return Math.max(Math.min(props.level || ((_a = contextLevel == null ? void 0 : contextLevel()) != null ? _a : 0) + 1, 6), 1);
|
|
13
|
+
};
|
|
14
|
+
return _$createComponent(HeadingContext.Provider, {
|
|
15
|
+
value: nextLevel,
|
|
16
|
+
get children() {
|
|
17
|
+
return props.children;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
HeadingLevel
|
|
23
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ValidComponent } from "solid-js";
|
|
2
|
+
import type { Options, Props } from "../utils/types.ts";
|
|
3
|
+
import type { HeadingLevels } from "./utils.ts";
|
|
4
|
+
type HeadingElements = `h${HeadingLevels}`;
|
|
5
|
+
declare const TagName = "h1";
|
|
6
|
+
type TagName = HeadingElements;
|
|
7
|
+
/**
|
|
8
|
+
* Returns props to create a `Heading` component. The element type (or the
|
|
9
|
+
* `aria-level` prop, if the element type is not a native heading) is determined
|
|
10
|
+
* by the context level provided by the parent `HeadingLevel` component.
|
|
11
|
+
* @see https://solid.ariakit.org/components/heading
|
|
12
|
+
* @example
|
|
13
|
+
* ```jsx
|
|
14
|
+
* const props = useHeading();
|
|
15
|
+
* <Role {...props}>Heading</Role>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const useHeading: import("../utils/types.ts").Hook<"h1" | "h2" | "h3" | "h4" | "h5" | "h6", HeadingOptions<"h1" | "h2" | "h3" | "h4" | "h5" | "h6">>;
|
|
19
|
+
/**
|
|
20
|
+
* Renders a heading element. The element type (or the `aria-level` attribute,
|
|
21
|
+
* if the element type is not a native heading) is determined by the context
|
|
22
|
+
* level provided by the closest
|
|
23
|
+
* [`HeadingLevel`](https://solid.ariakit.org/reference/heading-level) ancestor.
|
|
24
|
+
* @see https://solid.ariakit.org/components/heading
|
|
25
|
+
* @example
|
|
26
|
+
* ```jsx
|
|
27
|
+
* <HeadingLevel>
|
|
28
|
+
* <Heading>Heading 1</Heading>
|
|
29
|
+
* <HeadingLevel>
|
|
30
|
+
* <Heading>Heading 2</Heading>
|
|
31
|
+
* </HeadingLevel>
|
|
32
|
+
* </HeadingLevel>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare const Heading: (props: HeadingProps) => import("solid-js").JSX.Element;
|
|
36
|
+
export interface HeadingOptions<_T extends ValidComponent = TagName> extends Options {
|
|
37
|
+
}
|
|
38
|
+
export type HeadingProps<T extends ValidComponent = TagName> = Props<T, HeadingOptions<T>>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractTagName
|
|
3
|
+
} from "../__chunks/UKDBTPK5.js";
|
|
4
|
+
import {
|
|
5
|
+
createHook,
|
|
6
|
+
createInstance
|
|
7
|
+
} from "../__chunks/OKOFCLOZ.js";
|
|
8
|
+
import {
|
|
9
|
+
createRef,
|
|
10
|
+
mergeProps
|
|
11
|
+
} from "../__chunks/QKOHDUFI.js";
|
|
12
|
+
import {
|
|
13
|
+
HeadingContext
|
|
14
|
+
} from "../__chunks/I7JSIDPD.js";
|
|
15
|
+
|
|
16
|
+
// src/heading/heading.tsx
|
|
17
|
+
import { createMemo, useContext } from "solid-js";
|
|
18
|
+
var TagName = "h1";
|
|
19
|
+
var useHeading = createHook(function useHeading2(props) {
|
|
20
|
+
const ref = createRef();
|
|
21
|
+
const level = useContext(HeadingContext) || (() => 1);
|
|
22
|
+
const Element = () => `h${level()}`;
|
|
23
|
+
const tagName = extractTagName(ref.get);
|
|
24
|
+
const isNativeHeading = createMemo(() => !!tagName() && /^h\d$/.test(tagName()));
|
|
25
|
+
props = mergeProps({
|
|
26
|
+
// TODO: replace with LazyDynamic
|
|
27
|
+
render: Element(),
|
|
28
|
+
get role() {
|
|
29
|
+
return !isNativeHeading() ? "heading" : void 0;
|
|
30
|
+
},
|
|
31
|
+
get "aria-level"() {
|
|
32
|
+
return !isNativeHeading() ? level() : void 0;
|
|
33
|
+
},
|
|
34
|
+
ref: ref.set
|
|
35
|
+
}, props);
|
|
36
|
+
return props;
|
|
37
|
+
});
|
|
38
|
+
var Heading = function Heading2(props) {
|
|
39
|
+
const htmlProps = useHeading(props);
|
|
40
|
+
return createInstance(TagName, htmlProps);
|
|
41
|
+
};
|
|
42
|
+
export {
|
|
43
|
+
Heading,
|
|
44
|
+
useHeading
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type HeadingLevels = 1 | 2 | 3 | 4 | 5 | 6;
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Component, ValidComponent } from "solid-js";
|
|
2
|
+
import type { Options, Props } from "../utils/types.ts";
|
|
3
|
+
declare const TagName = "div";
|
|
4
|
+
type TagName = typeof TagName;
|
|
5
|
+
export declare const elements: readonly ["a", "button", "details", "dialog", "div", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "img", "input", "label", "li", "nav", "ol", "p", "section", "select", "span", "summary", "textarea", "ul", "svg"];
|
|
6
|
+
type RoleElements = {
|
|
7
|
+
[K in (typeof elements)[number]]: Component<RoleProps<K>>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Returns props to create a `Role` component.
|
|
11
|
+
* @see https://solid.ariakit.org/components/role
|
|
12
|
+
* @example
|
|
13
|
+
* ```jsx
|
|
14
|
+
* const props = useRole();
|
|
15
|
+
* <Role {...props} />
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const useRole: import("../utils/types.ts").Hook<"div", RoleOptions<"div">>;
|
|
19
|
+
/**
|
|
20
|
+
* Renders an abstract element that supports the `render` prop and a
|
|
21
|
+
* `wrapInstance` prop that can be used to wrap the underlying component
|
|
22
|
+
* instance with Solid Portal, Context or other component types.
|
|
23
|
+
* @see https://solid.ariakit.org/components/role
|
|
24
|
+
* @example
|
|
25
|
+
* ```jsx
|
|
26
|
+
* <Role render={<As.div />} />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const Role: Component<RoleProps> & RoleElements;
|
|
30
|
+
export interface RoleOptions<_T extends ValidComponent = TagName> extends Options {
|
|
31
|
+
}
|
|
32
|
+
export type RoleProps<T extends ValidComponent = TagName> = Props<T, RoleOptions>;
|
|
33
|
+
export {};
|