@ariakit/solid-components 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/as/as.d.ts +30 -0
  3. package/dist/as/as.d.ts.map +1 -0
  4. package/dist/as/as.js +40 -0
  5. package/dist/as/as.js.map +1 -0
  6. package/dist/focus-trap/focus-trap-region.d.ts +42 -0
  7. package/dist/focus-trap/focus-trap-region.d.ts.map +1 -0
  8. package/dist/focus-trap/focus-trap-region.js +71 -0
  9. package/dist/focus-trap/focus-trap-region.js.map +1 -0
  10. package/dist/focus-trap/focus-trap.d.ts +31 -0
  11. package/dist/focus-trap/focus-trap.d.ts.map +1 -0
  12. package/dist/focus-trap/focus-trap.js +42 -0
  13. package/dist/focus-trap/focus-trap.js.map +1 -0
  14. package/dist/group/group-label-context.d.ts +7 -0
  15. package/dist/group/group-label-context.d.ts.map +1 -0
  16. package/dist/group/group-label-context.js +7 -0
  17. package/dist/group/group-label-context.js.map +1 -0
  18. package/dist/group/group-label.d.ts +37 -0
  19. package/dist/group/group-label.d.ts.map +1 -0
  20. package/dist/group/group-label.js +51 -0
  21. package/dist/group/group-label.js.map +1 -0
  22. package/dist/group/group.d.ts +32 -0
  23. package/dist/group/group.d.ts.map +1 -0
  24. package/dist/group/group.js +49 -0
  25. package/dist/group/group.js.map +1 -0
  26. package/dist/heading/heading-context.d.ts +8 -0
  27. package/dist/heading/heading-context.d.ts.map +1 -0
  28. package/dist/heading/heading-context.js +7 -0
  29. package/dist/heading/heading-context.js.map +1 -0
  30. package/dist/heading/heading-level.d.ts +32 -0
  31. package/dist/heading/heading-level.d.ts.map +1 -0
  32. package/dist/heading/heading-level.js +34 -0
  33. package/dist/heading/heading-level.js.map +1 -0
  34. package/dist/heading/heading.d.ts +42 -0
  35. package/dist/heading/heading.d.ts.map +1 -0
  36. package/dist/heading/heading.js +57 -0
  37. package/dist/heading/heading.js.map +1 -0
  38. package/dist/heading/utils.d.ts +5 -0
  39. package/dist/heading/utils.d.ts.map +1 -0
  40. package/dist/heading/utils.js +0 -0
  41. package/dist/role/role.d.ts +34 -0
  42. package/dist/role/role.d.ts.map +1 -0
  43. package/dist/role/role.js +67 -0
  44. package/dist/role/role.js.map +1 -0
  45. package/dist/separator/separator.d.ts +36 -0
  46. package/dist/separator/separator.d.ts.map +1 -0
  47. package/dist/separator/separator.js +36 -0
  48. package/dist/separator/separator.js.map +1 -0
  49. package/dist/visually-hidden/visually-hidden.d.ts +37 -0
  50. package/dist/visually-hidden/visually-hidden.d.ts.map +1 -0
  51. package/dist/visually-hidden/visually-hidden.js +48 -0
  52. package/dist/visually-hidden/visually-hidden.js.map +1 -0
  53. package/index.ts +1 -0
  54. package/license +21 -0
  55. package/package.json +113 -0
  56. package/readme.md +19 -0
  57. package/solid/as/as.jsx +38 -0
  58. package/solid/as/as.jsx.map +1 -0
  59. package/solid/focus-trap/focus-trap-region.jsx +65 -0
  60. package/solid/focus-trap/focus-trap-region.jsx.map +1 -0
  61. package/solid/focus-trap/focus-trap.jsx +42 -0
  62. package/solid/focus-trap/focus-trap.jsx.map +1 -0
  63. package/solid/group/group-label-context.jsx +7 -0
  64. package/solid/group/group-label-context.jsx.map +1 -0
  65. package/solid/group/group-label.jsx +51 -0
  66. package/solid/group/group-label.jsx.map +1 -0
  67. package/solid/group/group.jsx +43 -0
  68. package/solid/group/group.jsx.map +1 -0
  69. package/solid/heading/heading-context.jsx +7 -0
  70. package/solid/heading/heading-context.jsx.map +1 -0
  71. package/solid/heading/heading-level.jsx +30 -0
  72. package/solid/heading/heading-level.jsx.map +1 -0
  73. package/solid/heading/heading.jsx +57 -0
  74. package/solid/heading/heading.jsx.map +1 -0
  75. package/solid/heading/utils.jsx +0 -0
  76. package/solid/role/role.jsx +67 -0
  77. package/solid/role/role.jsx.map +1 -0
  78. package/solid/separator/separator.jsx +36 -0
  79. package/solid/separator/separator.jsx.map +1 -0
  80. package/solid/visually-hidden/visually-hidden.jsx +48 -0
  81. package/solid/visually-hidden/visually-hidden.jsx.map +1 -0
  82. package/src/as/as.tsx +62 -0
  83. package/src/focus-trap/focus-trap-region.tsx +108 -0
  84. package/src/focus-trap/focus-trap.tsx +61 -0
  85. package/src/group/group-label-context.tsx +4 -0
  86. package/src/group/group-label.tsx +76 -0
  87. package/src/group/group.tsx +68 -0
  88. package/src/heading/heading-context.tsx +5 -0
  89. package/src/heading/heading-level.tsx +43 -0
  90. package/src/heading/heading.tsx +87 -0
  91. package/src/heading/utils.ts +1 -0
  92. package/src/role/role.tsx +91 -0
  93. package/src/separator/separator.tsx +66 -0
  94. package/src/visually-hidden/visually-hidden.tsx +63 -0
@@ -0,0 +1,38 @@
1
+ import { mergeProps } from "@ariakit/solid-utils";
2
+ import { Dynamic } from "solid-js/web";
3
+ //#region src/as/as.tsx
4
+ const cache = /* @__PURE__ */ new Map();
5
+ /**
6
+ * Allows a component to be rendered as a different HTML element or Solid
7
+ * component. Must be passed to the `render` prop of a component that
8
+ * supports it.
9
+ *
10
+ * To render as an HTML element, use `<As.element />` (e.g. `<As.button />`).
11
+ *
12
+ * To render as a component, use `<As component={Component} />` (e.g. `<As
13
+ * component={MyButton} />`).
14
+ *
15
+ * Check out the [Composition](https://solid.ariakit.com/guide/composition)
16
+ * guide for more details.
17
+ * @example
18
+ * ```jsx
19
+ * <Role render={<As component={MyButton} variant="primary" />} />
20
+ * <Role render={<As.button type="button" />} />
21
+ * ```
22
+ */
23
+ const As = new Proxy(function As(props) {
24
+ return ((parentProps) => <Dynamic {...mergeProps(parentProps, props)} component={props.component} />);
25
+ }, { get: (_, key) => {
26
+ let component = cache.get(key);
27
+ if (!component) {
28
+ component = function AsElement(props) {
29
+ return ((parentProps) => <Dynamic {...mergeProps(parentProps, props)} component={key} />);
30
+ };
31
+ cache.set(key, component);
32
+ }
33
+ return component;
34
+ } });
35
+ //#endregion
36
+ export { As };
37
+
38
+ //# sourceMappingURL=as.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"as.jsx","names":[],"sources":["../../src/as/as.tsx"],"sourcesContent":["import { mergeProps } from \"@ariakit/solid-utils\";\nimport type { Component, ComponentProps, JSX, ValidComponent } from \"solid-js\";\nimport { Dynamic } from \"solid-js/web\";\n\ntype AsElements = {\n [K in keyof JSX.IntrinsicElements]: Component<ComponentProps<K>>;\n};\n\ntype AsComponent = <T extends Component<any>, P = ComponentProps<T>>(\n props: AsProps<T, P>,\n) => JSX.Element;\n\nconst cache = new Map<string, Component<any>>();\n\n/**\n * Allows a component to be rendered as a different HTML element or Solid\n * component. Must be passed to the `render` prop of a component that\n * supports it.\n *\n * To render as an HTML element, use `<As.element />` (e.g. `<As.button />`).\n *\n * To render as a component, use `<As component={Component} />` (e.g. `<As\n * component={MyButton} />`).\n *\n * Check out the [Composition](https://solid.ariakit.com/guide/composition)\n * guide for more details.\n * @example\n * ```jsx\n * <Role render={<As component={MyButton} variant=\"primary\" />} />\n * <Role render={<As.button type=\"button\" />} />\n * ```\n */\nexport const As = new Proxy(\n function As(props: any) {\n return ((parentProps: unknown) => (\n // TODO: replace with LazyDynamic\n <Dynamic\n {...mergeProps(parentProps, props)}\n component={props.component}\n />\n )) as unknown as JSX.Element;\n } as AsComponent & AsElements,\n {\n get: (_, key: keyof JSX.IntrinsicElements) => {\n let component = cache.get(key);\n if (!component) {\n component = function AsElement(props: any): JSX.Element {\n return ((parentProps: unknown) => (\n // TODO: replace with LazyDynamic\n <Dynamic {...mergeProps(parentProps, props)} component={key} />\n )) as unknown as JSX.Element;\n };\n cache.set(key, component);\n }\n return component;\n },\n },\n);\n\nexport type AsProps<T extends ValidComponent, P = ComponentProps<T>> = {\n [K in keyof P]: P[K];\n} & { component: T };\n"],"mappings":";;;AAYA,MAAM,wBAAQ,IAAI,IAA4B;;;;;;;;;;;;;;;;;;;AAoB9C,MAAa,KAAK,IAAI,MACpB,SAAS,GAAG,OAAY;CACtB,SAAS,gBAEP,CAAC,YACK,WAAW,aAAa,KAAK,GACjC,WAAW,MAAM;AAGvB,GACA,EACE,MAAM,GAAG,QAAqC;CAC5C,IAAI,YAAY,MAAM,IAAI,GAAG;CAC7B,IAAI,CAAC,WAAW;EACd,YAAY,SAAS,UAAU,OAAyB;GACtD,SAAS,gBAEP,CAAC,YAAY,WAAW,aAAa,KAAK,GAAG,WAAW;EAE5D;EACA,MAAM,IAAI,KAAK,SAAS;CAC1B;CACA,OAAO;AACT,EACF,CACF"}
@@ -0,0 +1,65 @@
1
+ import { FocusTrap } from "./focus-trap.jsx";
2
+ import { createHook, createInstance, createRef, mergeProps, withOptions, wrapInstance } from "@ariakit/solid-utils";
3
+ import { getAllTabbableIn } from "@ariakit/utils";
4
+ import { Show } from "solid-js";
5
+ //#region src/focus-trap/focus-trap-region.tsx
6
+ const TagName = "div";
7
+ /**
8
+ * Returns props to create a `FocusTrapRegion` component.
9
+ * @see https://solid.ariakit.com/components/focus-trap-region
10
+ * @example
11
+ * ```jsx
12
+ * const props = useFocusTrapRegion();
13
+ * <Role {...props} />
14
+ * ```
15
+ */
16
+ const useFocusTrapRegion = createHook(withOptions({ enabled: false }, function useFocusTrapRegion(props, options) {
17
+ const ref = createRef();
18
+ props = wrapInstance(props, (wrapperProps) => {
19
+ const renderFocusTrap = () => {
20
+ return <Show when={options.enabled}>
21
+ <FocusTrap onFocus={(event) => {
22
+ const container = ref.current;
23
+ if (!container) return;
24
+ const tabbables = getAllTabbableIn(container, true);
25
+ const first = tabbables[0];
26
+ const last = tabbables[tabbables.length - 1];
27
+ if (!tabbables.length) {
28
+ container.focus();
29
+ return;
30
+ }
31
+ if (event.relatedTarget === first) last?.focus();
32
+ else first?.focus();
33
+ }} />
34
+ </Show>;
35
+ };
36
+ return <>
37
+ {renderFocusTrap()}
38
+ {wrapperProps.children}
39
+ {renderFocusTrap()}
40
+ </>;
41
+ });
42
+ props = mergeProps({ ref: ref.set }, props);
43
+ return props;
44
+ }));
45
+ /**
46
+ * Renders a wrapper element that traps the focus inside it when the
47
+ * [`enabled`](https://solid.ariakit.com/reference/focus-trap-region#enabled)
48
+ * prop is `true`.
49
+ * @see https://solid.ariakit.com/components/focus-trap
50
+ * @example
51
+ * ```jsx
52
+ * <FocusTrapRegion>
53
+ * <Button>click me</Button>
54
+ * <Button>trap focus</Button>
55
+ * <Button disabled>disabled Button</Button>
56
+ * </FocusTrapRegion>
57
+ * ```
58
+ */
59
+ const FocusTrapRegion = function FocusTrapRegion(props) {
60
+ return createInstance(TagName, useFocusTrapRegion(props));
61
+ };
62
+ //#endregion
63
+ export { FocusTrapRegion, useFocusTrapRegion };
64
+
65
+ //# sourceMappingURL=focus-trap-region.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus-trap-region.jsx","names":[],"sources":["../../src/focus-trap/focus-trap-region.tsx"],"sourcesContent":["import {\n createRef,\n mergeProps,\n createHook,\n createInstance,\n withOptions,\n wrapInstance,\n} from \"@ariakit/solid-utils\";\nimport type { Options, Props } from \"@ariakit/solid-utils\";\nimport { getAllTabbableIn } from \"@ariakit/utils\";\nimport type { ValidComponent } from \"solid-js\";\nimport { Show } from \"solid-js\";\nimport { FocusTrap } from \"./focus-trap.tsx\";\n\nconst TagName = \"div\" satisfies ValidComponent;\ntype TagName = typeof TagName;\ntype HTMLType = HTMLElementTagNameMap[TagName];\n\n/**\n * Returns props to create a `FocusTrapRegion` component.\n * @see https://solid.ariakit.com/components/focus-trap-region\n * @example\n * ```jsx\n * const props = useFocusTrapRegion();\n * <Role {...props} />\n * ```\n */\nexport const useFocusTrapRegion = createHook<TagName, FocusTrapRegionOptions>(\n withOptions({ enabled: false }, function useFocusTrapRegion(props, options) {\n const ref = createRef<HTMLType>();\n\n props = wrapInstance(props, (wrapperProps) => {\n const renderFocusTrap = () => {\n return (\n <Show when={options.enabled}>\n <FocusTrap\n onFocus={(event) => {\n // TODO: (react) opportunity to extract into @ariakit/components?\n const container = ref.current;\n if (!container) return;\n const tabbables = getAllTabbableIn(container, true);\n const first = tabbables[0];\n const last = tabbables[tabbables.length - 1];\n // Fallbacks to the container element\n if (!tabbables.length) {\n container.focus();\n return;\n }\n if (event.relatedTarget === first) {\n last?.focus();\n } else {\n first?.focus();\n }\n }}\n />\n </Show>\n );\n };\n return (\n <>\n {renderFocusTrap()}\n {wrapperProps.children}\n {renderFocusTrap()}\n </>\n );\n });\n\n props = mergeProps({ ref: ref.set }, props);\n\n return props;\n }),\n);\n\n/**\n * Renders a wrapper element that traps the focus inside it when the\n * [`enabled`](https://solid.ariakit.com/reference/focus-trap-region#enabled)\n * prop is `true`.\n * @see https://solid.ariakit.com/components/focus-trap\n * @example\n * ```jsx\n * <FocusTrapRegion>\n * <Button>click me</Button>\n * <Button>trap focus</Button>\n * <Button disabled>disabled Button</Button>\n * </FocusTrapRegion>\n * ```\n */\nexport const FocusTrapRegion = function FocusTrapRegion(\n props: FocusTrapRegionProps,\n) {\n const htmlProps = useFocusTrapRegion(props);\n return createInstance(TagName, htmlProps);\n};\n\nexport interface FocusTrapRegionOptions<\n _T extends ValidComponent = TagName,\n> extends Options {\n /**\n * If true, it will trap the focus in the region.\n * @default false\n */\n enabled?: boolean;\n}\n\nexport type FocusTrapRegionProps<T extends ValidComponent = TagName> = Props<\n T,\n FocusTrapRegionOptions<T>\n>;\n"],"mappings":";;;;;AAcA,MAAM,UAAU;;;;;;;;;;AAahB,MAAa,qBAAqB,WAChC,YAAY,EAAE,SAAS,MAAM,GAAG,SAAS,mBAAmB,OAAO,SAAS;CAC1E,MAAM,MAAM,UAAoB;CAEhC,QAAQ,aAAa,QAAQ,iBAAiB;EAC5C,MAAM,wBAAwB;GAC5B,OACE,CAAC,KAAK,MAAM,QAAQ,SAAS;YAC3B,CAAC,UACC,UAAU,UAAU;IAElB,MAAM,YAAY,IAAI;IACtB,IAAI,CAAC,WAAW;IAChB,MAAM,YAAY,iBAAiB,WAAW,IAAI;IAClD,MAAM,QAAQ,UAAU;IACxB,MAAM,OAAO,UAAU,UAAU,SAAS;IAE1C,IAAI,CAAC,UAAU,QAAQ;KACrB,UAAU,MAAM;KAChB;IACF;IACA,IAAI,MAAM,kBAAkB,OAC1B,MAAM,MAAM;SAEZ,OAAO,MAAM;GAEjB,KACA;UACJ,EAAE;EAEN;EACA,OACE,EAAE;WACC,gBAAgB,EAAE;WAClB,aAAa,SAAS;WACtB,gBAAgB,EAAE;QACrB;CAEJ,CAAC;CAED,QAAQ,WAAW,EAAE,KAAK,IAAI,IAAI,GAAG,KAAK;CAE1C,OAAO;AACT,CAAC,CACH;;;;;;;;;;;;;;;AAgBA,MAAa,kBAAkB,SAAS,gBACtC,OACA;CAEA,OAAO,eAAe,SADJ,mBAAmB,KACE,CAAC;AAC1C"}
@@ -0,0 +1,42 @@
1
+ import { useVisuallyHidden } from "../visually-hidden/visually-hidden.jsx";
2
+ import { createHook, createInstance, mergeProps } from "@ariakit/solid-utils";
3
+ //#region src/focus-trap/focus-trap.tsx
4
+ const TagName = "span";
5
+ /**
6
+ * Returns props to create a `FocusTrap` component.
7
+ * @see https://solid.ariakit.com/components/focus-trap
8
+ * @example
9
+ * ```jsx
10
+ * const props = useFocusTrap();
11
+ * <Role {...props} />
12
+ * ```
13
+ */
14
+ const useFocusTrap = createHook(function useFocusTrap(props) {
15
+ props = mergeProps({
16
+ "data-focus-trap": "",
17
+ tabIndex: 0,
18
+ "aria-hidden": true,
19
+ style: {
20
+ position: "fixed",
21
+ top: 0,
22
+ left: 0
23
+ }
24
+ }, props);
25
+ props = useVisuallyHidden(props);
26
+ return props;
27
+ });
28
+ /**
29
+ * Renders a focus trap element.
30
+ * @see https://solid.ariakit.com/components/focus-trap
31
+ * @example
32
+ * ```jsx
33
+ * <FocusTrap onFocus={focusSomethingElse} />
34
+ * ```
35
+ */
36
+ function FocusTrap(props) {
37
+ return createInstance(TagName, useFocusTrap(props));
38
+ }
39
+ //#endregion
40
+ export { FocusTrap, useFocusTrap };
41
+
42
+ //# sourceMappingURL=focus-trap.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focus-trap.jsx","names":[],"sources":["../../src/focus-trap/focus-trap.tsx"],"sourcesContent":["import { mergeProps, createHook, createInstance } from \"@ariakit/solid-utils\";\nimport type { Props } from \"@ariakit/solid-utils\";\nimport type { ValidComponent } from \"solid-js\";\nimport type { VisuallyHiddenOptions } from \"../visually-hidden/visually-hidden.tsx\";\nimport { useVisuallyHidden } from \"../visually-hidden/visually-hidden.tsx\";\n\nconst TagName = \"span\" satisfies ValidComponent;\ntype TagName = typeof TagName;\n\n/**\n * Returns props to create a `FocusTrap` component.\n * @see https://solid.ariakit.com/components/focus-trap\n * @example\n * ```jsx\n * const props = useFocusTrap();\n * <Role {...props} />\n * ```\n */\nexport const useFocusTrap = createHook<TagName, FocusTrapOptions>(\n function useFocusTrap(props) {\n props = mergeProps(\n {\n \"data-focus-trap\": \"\",\n tabIndex: 0,\n \"aria-hidden\": true,\n style: {\n // Prevents unintended scroll jumps.\n position: \"fixed\",\n top: 0,\n left: 0,\n },\n },\n props,\n );\n\n props = useVisuallyHidden(props);\n\n return props;\n },\n);\n\n/**\n * Renders a focus trap element.\n * @see https://solid.ariakit.com/components/focus-trap\n * @example\n * ```jsx\n * <FocusTrap onFocus={focusSomethingElse} />\n * ```\n */\nexport function FocusTrap(props: FocusTrapProps) {\n const htmlProps = useFocusTrap(props);\n return createInstance(TagName, htmlProps);\n}\n\nexport type FocusTrapOptions<T extends ValidComponent = TagName> =\n VisuallyHiddenOptions<T>;\n\nexport type FocusTrapProps<T extends ValidComponent = TagName> = Props<\n T,\n FocusTrapOptions<T>\n>;\n"],"mappings":";;;AAMA,MAAM,UAAU;;;;;;;;;;AAYhB,MAAa,eAAe,WAC1B,SAAS,aAAa,OAAO;CAC3B,QAAQ,WACN;EACE,mBAAmB;EACnB,UAAU;EACV,eAAe;EACf,OAAO;GAEL,UAAU;GACV,KAAK;GACL,MAAM;EACR;CACF,GACA,KACF;CAEA,QAAQ,kBAAkB,KAAK;CAE/B,OAAO;AACT,CACF;;;;;;;;;AAUA,SAAgB,UAAU,OAAuB;CAE/C,OAAO,eAAe,SADJ,aAAa,KACQ,CAAC;AAC1C"}
@@ -0,0 +1,7 @@
1
+ import { createContext } from "solid-js";
2
+ //#region src/group/group-label-context.tsx
3
+ const GroupLabelContext = createContext();
4
+ //#endregion
5
+ export { GroupLabelContext };
6
+
7
+ //# sourceMappingURL=group-label-context.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-label-context.jsx","names":[],"sources":["../../src/group/group-label-context.tsx"],"sourcesContent":["import type { Setter } from \"solid-js\";\nimport { createContext } from \"solid-js\";\n\nexport const GroupLabelContext = createContext<Setter<string | undefined>>();\n"],"mappings":";;AAGA,MAAa,oBAAoB,cAA0C"}
@@ -0,0 +1,51 @@
1
+ import { GroupLabelContext } from "./group-label-context.jsx";
2
+ import { createHook, createId, createInstance, mergeProps, stableAccessor } from "@ariakit/solid-utils";
3
+ import { createEffect, onCleanup, useContext } from "solid-js";
4
+ //#region src/group/group-label.tsx
5
+ const TagName = "div";
6
+ /**
7
+ * Returns props to create a `GroupLabel` component. This hook must be used in a
8
+ * component that's wrapped with `Group` so the `aria-labelledby` prop is
9
+ * properly set on the group element.
10
+ * @see https://solid.ariakit.com/components/group
11
+ * @example
12
+ * ```jsx
13
+ * // This component must be wrapped with Group
14
+ * const props = useGroupLabel();
15
+ * <Role {...props}>Label</Role>
16
+ * ```
17
+ */
18
+ const useGroupLabel = createHook(function useGroupLabel(props) {
19
+ const setLabelId = useContext(GroupLabelContext);
20
+ const id = createId(stableAccessor(props, (p) => p.id));
21
+ createEffect(() => {
22
+ setLabelId?.(id());
23
+ onCleanup(() => setLabelId?.(void 0));
24
+ });
25
+ props = mergeProps({
26
+ get id() {
27
+ return id();
28
+ },
29
+ "aria-hidden": true
30
+ }, props);
31
+ return props;
32
+ });
33
+ /**
34
+ * Renders a label in a group. This component should be wrapped with a
35
+ * [`Group`](https://solid.ariakit.com/reference/group) so the `aria-labelledby`
36
+ * prop is correctly set on the group element.
37
+ * @see https://solid.ariakit.com/components/group
38
+ * @example
39
+ * ```jsx
40
+ * <Group>
41
+ * <GroupLabel>Label</GroupLabel>
42
+ * </Group>
43
+ * ```
44
+ */
45
+ const GroupLabel = function GroupLabel(props) {
46
+ return createInstance(TagName, useGroupLabel(props));
47
+ };
48
+ //#endregion
49
+ export { GroupLabel, useGroupLabel };
50
+
51
+ //# sourceMappingURL=group-label.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-label.jsx","names":[],"sources":["../../src/group/group-label.tsx"],"sourcesContent":["import {\n createId,\n mergeProps,\n stableAccessor,\n createHook,\n createInstance,\n} from \"@ariakit/solid-utils\";\nimport type { Options, Props } from \"@ariakit/solid-utils\";\nimport type { ValidComponent } from \"solid-js\";\nimport { createEffect, onCleanup, useContext } from \"solid-js\";\nimport { GroupLabelContext } from \"./group-label-context.tsx\";\n\nconst TagName = \"div\" satisfies ValidComponent;\ntype TagName = typeof TagName;\n\n/**\n * Returns props to create a `GroupLabel` component. This hook must be used in a\n * component that's wrapped with `Group` so the `aria-labelledby` prop is\n * properly set on the group element.\n * @see https://solid.ariakit.com/components/group\n * @example\n * ```jsx\n * // This component must be wrapped with Group\n * const props = useGroupLabel();\n * <Role {...props}>Label</Role>\n * ```\n */\nexport const useGroupLabel = createHook<TagName, GroupLabelOptions>(\n function useGroupLabel(props) {\n const setLabelId = useContext(GroupLabelContext);\n const id = createId(stableAccessor(props, (p) => p.id));\n\n createEffect(() => {\n setLabelId?.(id());\n onCleanup(() => setLabelId?.(undefined));\n });\n\n props = mergeProps(\n {\n get id() {\n return id();\n },\n \"aria-hidden\": true,\n },\n props,\n );\n\n return props;\n },\n);\n\n/**\n * Renders a label in a group. This component should be wrapped with a\n * [`Group`](https://solid.ariakit.com/reference/group) so the `aria-labelledby`\n * prop is correctly set on the group element.\n * @see https://solid.ariakit.com/components/group\n * @example\n * ```jsx\n * <Group>\n * <GroupLabel>Label</GroupLabel>\n * </Group>\n * ```\n */\nexport const GroupLabel = function GroupLabel(props: GroupLabelProps) {\n const htmlProps = useGroupLabel(props);\n return createInstance(TagName, htmlProps);\n};\n\nexport interface GroupLabelOptions<\n _T extends ValidComponent = TagName,\n> extends Options {}\n\nexport type GroupLabelProps<T extends ValidComponent = TagName> = Props<\n T,\n GroupLabelOptions<T>\n>;\n"],"mappings":";;;;AAYA,MAAM,UAAU;;;;;;;;;;;;;AAehB,MAAa,gBAAgB,WAC3B,SAAS,cAAc,OAAO;CAC5B,MAAM,aAAa,WAAW,iBAAiB;CAC/C,MAAM,KAAK,SAAS,eAAe,QAAQ,MAAM,EAAE,EAAE,CAAC;CAEtD,mBAAmB;EACjB,aAAa,GAAG,CAAC;EACjB,gBAAgB,aAAa,KAAA,CAAS,CAAC;CACzC,CAAC;CAED,QAAQ,WACN;EACE,IAAI,KAAK;GACP,OAAO,GAAG;EACZ;EACA,eAAe;CACjB,GACA,KACF;CAEA,OAAO;AACT,CACF;;;;;;;;;;;;;AAcA,MAAa,aAAa,SAAS,WAAW,OAAwB;CAEpE,OAAO,eAAe,SADJ,cAAc,KACO,CAAC;AAC1C"}
@@ -0,0 +1,43 @@
1
+ import { As } from "../as/as.jsx";
2
+ import { GroupLabelContext } from "./group-label-context.jsx";
3
+ import { createHook, createInstance, mergeProps, wrapInstance } from "@ariakit/solid-utils";
4
+ import { createSignal } from "solid-js";
5
+ //#region src/group/group.tsx
6
+ const TagName = "div";
7
+ /**
8
+ * Returns props to create a `Group` component.
9
+ * @see https://solid.ariakit.com/components/group
10
+ * @example
11
+ * ```jsx
12
+ * const props = useGroup();
13
+ * <Role {...props}>Group</Role>
14
+ * ```
15
+ */
16
+ const useGroup = createHook(function useGroup(props) {
17
+ const [labelId, setLabelId] = createSignal();
18
+ props = wrapInstance(props, <As component={GroupLabelContext.Provider} value={setLabelId} />);
19
+ props = mergeProps({
20
+ role: "group",
21
+ get "aria-labelledby"() {
22
+ return labelId();
23
+ }
24
+ }, props);
25
+ return props;
26
+ });
27
+ /**
28
+ * Renders a group element. Optionally, a
29
+ * [`GroupLabel`](https://solid.ariakit.com/reference/group-label) can be rendered as
30
+ * a child to provide a label for the group.
31
+ * @see https://solid.ariakit.com/components/group
32
+ * @example
33
+ * ```jsx
34
+ * <Group>Group</Group>
35
+ * ```
36
+ */
37
+ const Group = function Group(props) {
38
+ return createInstance(TagName, useGroup(props));
39
+ };
40
+ //#endregion
41
+ export { Group, useGroup };
42
+
43
+ //# sourceMappingURL=group.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group.jsx","names":[],"sources":["../../src/group/group.tsx"],"sourcesContent":["import {\n mergeProps,\n createHook,\n createInstance,\n wrapInstance,\n} from \"@ariakit/solid-utils\";\nimport type { Options, Props } from \"@ariakit/solid-utils\";\nimport type { ValidComponent } from \"solid-js\";\nimport { createSignal } from \"solid-js\";\nimport { As } from \"../as/as.tsx\";\nimport { GroupLabelContext } from \"./group-label-context.tsx\";\n\nconst TagName = \"div\" satisfies ValidComponent;\ntype TagName = typeof TagName;\n\n/**\n * Returns props to create a `Group` component.\n * @see https://solid.ariakit.com/components/group\n * @example\n * ```jsx\n * const props = useGroup();\n * <Role {...props}>Group</Role>\n * ```\n */\nexport const useGroup = createHook<TagName, GroupOptions>(\n function useGroup(props) {\n const [labelId, setLabelId] = createSignal<string>();\n\n props = wrapInstance(\n props,\n <As component={GroupLabelContext.Provider} value={setLabelId} />,\n );\n\n props = mergeProps(\n {\n role: \"group\" as const,\n get \"aria-labelledby\"() {\n return labelId();\n },\n },\n props,\n );\n\n return props;\n },\n);\n\n/**\n * Renders a group element. Optionally, a\n * [`GroupLabel`](https://solid.ariakit.com/reference/group-label) can be rendered as\n * a child to provide a label for the group.\n * @see https://solid.ariakit.com/components/group\n * @example\n * ```jsx\n * <Group>Group</Group>\n * ```\n */\nexport const Group = function Group(props: GroupProps) {\n const htmlProps = useGroup(props);\n return createInstance(TagName, htmlProps);\n};\n\nexport type GroupOptions<_T extends ValidComponent = TagName> = Options;\n\nexport type GroupProps<T extends ValidComponent = TagName> = Props<\n T,\n GroupOptions<T>\n>;\n"],"mappings":";;;;;AAYA,MAAM,UAAU;;;;;;;;;;AAYhB,MAAa,WAAW,WACtB,SAAS,SAAS,OAAO;CACvB,MAAM,CAAC,SAAS,cAAc,aAAqB;CAEnD,QAAQ,aACN,OACA,CAAC,GAAG,WAAW,kBAAkB,UAAU,OAAO,cACpD;CAEA,QAAQ,WACN;EACE,MAAM;EACN,IAAI,oBAAoB;GACtB,OAAO,QAAQ;EACjB;CACF,GACA,KACF;CAEA,OAAO;AACT,CACF;;;;;;;;;;;AAYA,MAAa,QAAQ,SAAS,MAAM,OAAmB;CAErD,OAAO,eAAe,SADJ,SAAS,KACY,CAAC;AAC1C"}
@@ -0,0 +1,7 @@
1
+ import { createContext } from "solid-js";
2
+ //#region src/heading/heading-context.tsx
3
+ const HeadingContext = createContext();
4
+ //#endregion
5
+ export { HeadingContext };
6
+
7
+ //# sourceMappingURL=heading-context.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading-context.jsx","names":[],"sources":["../../src/heading/heading-context.tsx"],"sourcesContent":["import type { Accessor } from \"solid-js\";\nimport { createContext } from \"solid-js\";\nimport type { HeadingLevels } from \"./utils.ts\";\n\nexport const HeadingContext = createContext<Accessor<HeadingLevels>>();\n"],"mappings":";;AAIA,MAAa,iBAAiB,cAAuC"}
@@ -0,0 +1,30 @@
1
+ import { HeadingContext } from "./heading-context.jsx";
2
+ import { useContext } from "solid-js";
3
+ //#region src/heading/heading-level.tsx
4
+ /**
5
+ * A component that sets the heading level for its children. It doesn't render
6
+ * any HTML element, just sets the
7
+ * [`level`](https://solid.ariakit.com/reference/heading-level#level) prop on the
8
+ * context.
9
+ * @see https://solid.ariakit.com/components/heading
10
+ * @example
11
+ * ```jsx
12
+ * <HeadingLevel>
13
+ * <Heading>Heading 1</Heading>
14
+ * <HeadingLevel>
15
+ * <Heading>Heading 2</Heading>
16
+ * </HeadingLevel>
17
+ * </HeadingLevel>
18
+ * ```
19
+ */
20
+ function HeadingLevel(props) {
21
+ const contextLevel = useContext(HeadingContext);
22
+ const nextLevel = () => Math.max(Math.min(props.level || (contextLevel?.() ?? 0) + 1, 6), 1);
23
+ return <HeadingContext.Provider value={nextLevel}>
24
+ {props.children}
25
+ </HeadingContext.Provider>;
26
+ }
27
+ //#endregion
28
+ export { HeadingLevel };
29
+
30
+ //# sourceMappingURL=heading-level.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading-level.jsx","names":[],"sources":["../../src/heading/heading-level.tsx"],"sourcesContent":["import type { JSX } from \"solid-js\";\nimport { useContext } from \"solid-js\";\nimport { HeadingContext } from \"./heading-context.tsx\";\nimport type { HeadingLevels } from \"./utils.ts\";\n\n/**\n * A component that sets the heading level for its children. It doesn't render\n * any HTML element, just sets the\n * [`level`](https://solid.ariakit.com/reference/heading-level#level) prop on the\n * context.\n * @see https://solid.ariakit.com/components/heading\n * @example\n * ```jsx\n * <HeadingLevel>\n * <Heading>Heading 1</Heading>\n * <HeadingLevel>\n * <Heading>Heading 2</Heading>\n * </HeadingLevel>\n * </HeadingLevel>\n * ```\n */\nexport function HeadingLevel(props: HeadingLevelProps) {\n const contextLevel = useContext(HeadingContext);\n const nextLevel = () =>\n Math.max(\n Math.min(props.level || (contextLevel?.() ?? 0) + 1, 6),\n 1,\n ) as HeadingLevels;\n return (\n <HeadingContext.Provider value={nextLevel}>\n {props.children}\n </HeadingContext.Provider>\n );\n}\n\nexport interface HeadingLevelProps {\n /**\n * The heading level. By default, it'll increase the level by 1 based on the\n * context.\n */\n level?: HeadingLevels;\n children?: JSX.Element;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,aAAa,OAA0B;CACrD,MAAM,eAAe,WAAW,cAAc;CAC9C,MAAM,kBACJ,KAAK,IACH,KAAK,IAAI,MAAM,UAAU,eAAe,KAAK,KAAK,GAAG,CAAC,GACtD,CACF;CACF,OACE,CAAC,eAAe,SAAS,OAAO,WAAW;OACxC,MAAM,SAAS;IAClB,EAAE,eAAe;AAErB"}
@@ -0,0 +1,57 @@
1
+ import { HeadingContext } from "./heading-context.jsx";
2
+ import { createHook, createInstance, createRef, extractTagName, mergeProps } from "@ariakit/solid-utils";
3
+ import { createMemo, useContext } from "solid-js";
4
+ //#region src/heading/heading.tsx
5
+ const TagName = "h1";
6
+ /**
7
+ * Returns props to create a `Heading` component. The element type (or the
8
+ * `aria-level` prop, if the element type is not a native heading) is determined
9
+ * by the context level provided by the parent `HeadingLevel` component.
10
+ * @see https://solid.ariakit.com/components/heading
11
+ * @example
12
+ * ```jsx
13
+ * const props = useHeading();
14
+ * <Role {...props}>Heading</Role>
15
+ * ```
16
+ */
17
+ const useHeading = createHook(function useHeading(props) {
18
+ const ref = createRef();
19
+ const level = useContext(HeadingContext) || (() => 1);
20
+ const Element = () => `h${level()}`;
21
+ const tagName = extractTagName(ref.get);
22
+ const isNativeHeading = createMemo(() => !!tagName() && /^h\d$/.test(tagName()));
23
+ props = mergeProps({
24
+ render: Element(),
25
+ get role() {
26
+ return !isNativeHeading() ? "heading" : void 0;
27
+ },
28
+ get "aria-level"() {
29
+ return !isNativeHeading() ? level() : void 0;
30
+ },
31
+ ref: ref.set
32
+ }, props);
33
+ return props;
34
+ });
35
+ /**
36
+ * Renders a heading element. The element type (or the `aria-level` attribute,
37
+ * if the element type is not a native heading) is determined by the context
38
+ * level provided by the closest
39
+ * [`HeadingLevel`](https://solid.ariakit.com/reference/heading-level) ancestor.
40
+ * @see https://solid.ariakit.com/components/heading
41
+ * @example
42
+ * ```jsx
43
+ * <HeadingLevel>
44
+ * <Heading>Heading 1</Heading>
45
+ * <HeadingLevel>
46
+ * <Heading>Heading 2</Heading>
47
+ * </HeadingLevel>
48
+ * </HeadingLevel>
49
+ * ```
50
+ */
51
+ const Heading = function Heading(props) {
52
+ return createInstance(TagName, useHeading(props));
53
+ };
54
+ //#endregion
55
+ export { Heading, useHeading };
56
+
57
+ //# sourceMappingURL=heading.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading.jsx","names":[],"sources":["../../src/heading/heading.tsx"],"sourcesContent":["import {\n extractTagName,\n createRef,\n mergeProps,\n createHook,\n createInstance,\n} from \"@ariakit/solid-utils\";\nimport type { Options, Props } from \"@ariakit/solid-utils\";\nimport type { ValidComponent } from \"solid-js\";\nimport { createMemo, useContext } from \"solid-js\";\nimport { HeadingContext } from \"./heading-context.tsx\";\nimport type { HeadingLevels } from \"./utils.ts\";\n\ntype HeadingElements = `h${HeadingLevels}`;\nconst TagName = \"h1\" satisfies ValidComponent;\ntype TagName = HeadingElements;\ntype HTMLType = HTMLElementTagNameMap[TagName];\n\n/**\n * Returns props to create a `Heading` component. The element type (or the\n * `aria-level` prop, if the element type is not a native heading) is determined\n * by the context level provided by the parent `HeadingLevel` component.\n * @see https://solid.ariakit.com/components/heading\n * @example\n * ```jsx\n * const props = useHeading();\n * <Role {...props}>Heading</Role>\n * ```\n */\nexport const useHeading = createHook<TagName, HeadingOptions>(\n function useHeading(props) {\n const ref = createRef<HTMLType>();\n const level = useContext(HeadingContext) || (() => 1);\n const Element = () => `h${level()}` as const;\n const tagName = extractTagName(ref.get);\n const isNativeHeading = createMemo(\n () => !!tagName() && /^h\\d$/.test(tagName()!),\n );\n\n props = mergeProps(\n {\n // TODO: replace with LazyDynamic\n render: Element(),\n get role() {\n return !isNativeHeading() ? \"heading\" : undefined;\n },\n get \"aria-level\"() {\n return !isNativeHeading() ? level() : undefined;\n },\n ref: ref.set,\n },\n props,\n );\n\n return props;\n },\n);\n\n/**\n * Renders a heading element. The element type (or the `aria-level` attribute,\n * if the element type is not a native heading) is determined by the context\n * level provided by the closest\n * [`HeadingLevel`](https://solid.ariakit.com/reference/heading-level) ancestor.\n * @see https://solid.ariakit.com/components/heading\n * @example\n * ```jsx\n * <HeadingLevel>\n * <Heading>Heading 1</Heading>\n * <HeadingLevel>\n * <Heading>Heading 2</Heading>\n * </HeadingLevel>\n * </HeadingLevel>\n * ```\n */\nexport const Heading = function Heading(props: HeadingProps) {\n const htmlProps = useHeading(props);\n return createInstance(TagName, htmlProps);\n};\n\nexport interface HeadingOptions<\n _T extends ValidComponent = TagName,\n> extends Options {}\n\nexport type HeadingProps<T extends ValidComponent = TagName> = Props<\n T,\n HeadingOptions<T>\n>;\n"],"mappings":";;;;AAcA,MAAM,UAAU;;;;;;;;;;;;AAehB,MAAa,aAAa,WACxB,SAAS,WAAW,OAAO;CACzB,MAAM,MAAM,UAAoB;CAChC,MAAM,QAAQ,WAAW,cAAc,YAAY;CACnD,MAAM,gBAAgB,IAAI,MAAM;CAChC,MAAM,UAAU,eAAe,IAAI,GAAG;CACtC,MAAM,kBAAkB,iBAChB,CAAC,CAAC,QAAQ,KAAK,QAAQ,KAAK,QAAQ,CAAE,CAC9C;CAEA,QAAQ,WACN;EAEE,QAAQ,QAAQ;EAChB,IAAI,OAAO;GACT,OAAO,CAAC,gBAAgB,IAAI,YAAY,KAAA;EAC1C;EACA,IAAI,eAAe;GACjB,OAAO,CAAC,gBAAgB,IAAI,MAAM,IAAI,KAAA;EACxC;EACA,KAAK,IAAI;CACX,GACA,KACF;CAEA,OAAO;AACT,CACF;;;;;;;;;;;;;;;;;AAkBA,MAAa,UAAU,SAAS,QAAQ,OAAqB;CAE3D,OAAO,eAAe,SADJ,WAAW,KACU,CAAC;AAC1C"}
File without changes
@@ -0,0 +1,67 @@
1
+ import { createHook, createInstance } from "@ariakit/solid-utils";
2
+ //#region src/role/role.tsx
3
+ const TagName = "div";
4
+ const elements = [
5
+ "a",
6
+ "button",
7
+ "details",
8
+ "dialog",
9
+ "div",
10
+ "form",
11
+ "h1",
12
+ "h2",
13
+ "h3",
14
+ "h4",
15
+ "h5",
16
+ "h6",
17
+ "header",
18
+ "img",
19
+ "input",
20
+ "label",
21
+ "li",
22
+ "nav",
23
+ "ol",
24
+ "p",
25
+ "section",
26
+ "select",
27
+ "span",
28
+ "summary",
29
+ "textarea",
30
+ "ul",
31
+ "svg"
32
+ ];
33
+ /**
34
+ * Returns props to create a `Role` component.
35
+ * @see https://solid.ariakit.com/components/role
36
+ * @example
37
+ * ```jsx
38
+ * const props = useRole();
39
+ * <Role {...props} />
40
+ * ```
41
+ */
42
+ const useRole = createHook(function useRole(props) {
43
+ return props;
44
+ });
45
+ /**
46
+ * Renders an abstract element that supports the `render` prop and a
47
+ * `wrapInstance` prop that can be used to wrap the underlying component
48
+ * instance with Solid Portal, Context or other component types.
49
+ * @see https://solid.ariakit.com/components/role
50
+ * @example
51
+ * ```jsx
52
+ * <Role render={<As.div />} />
53
+ * ```
54
+ */
55
+ const Role = function Role(props) {
56
+ return createInstance(TagName, props);
57
+ };
58
+ Object.assign(Role, elements.reduce((acc, element) => {
59
+ acc[element] = function Role(props) {
60
+ return createInstance(element, props);
61
+ };
62
+ return acc;
63
+ }, {}));
64
+ //#endregion
65
+ export { Role, elements, useRole };
66
+
67
+ //# sourceMappingURL=role.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"role.jsx","names":[],"sources":["../../src/role/role.tsx"],"sourcesContent":["import { createHook, createInstance } from \"@ariakit/solid-utils\";\nimport type { Options, Props } from \"@ariakit/solid-utils\";\nimport type { Component, JSX, ValidComponent } from \"solid-js\";\n\nconst TagName = \"div\" satisfies ValidComponent;\ntype TagName = typeof TagName;\n\nexport const elements = [\n \"a\",\n \"button\",\n \"details\",\n \"dialog\",\n \"div\",\n \"form\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n \"header\",\n \"img\",\n \"input\",\n \"label\",\n \"li\",\n \"nav\",\n \"ol\",\n \"p\",\n \"section\",\n \"select\",\n \"span\",\n \"summary\",\n \"textarea\",\n \"ul\",\n \"svg\",\n] as const;\n\ntype RoleElements = {\n [K in (typeof elements)[number]]: Component<RoleProps<K>>;\n};\n\n/**\n * Returns props to create a `Role` component.\n * @see https://solid.ariakit.com/components/role\n * @example\n * ```jsx\n * const props = useRole();\n * <Role {...props} />\n * ```\n */\nexport const useRole = createHook<TagName, RoleOptions>(\n function useRole(props) {\n return props;\n },\n);\n\n// TODO: adapt docs wording to be more accurate for Solid\n/**\n * Renders an abstract element that supports the `render` prop and a\n * `wrapInstance` prop that can be used to wrap the underlying component\n * instance with Solid Portal, Context or other component types.\n * @see https://solid.ariakit.com/components/role\n * @example\n * ```jsx\n * <Role render={<As.div />} />\n * ```\n */\nexport const Role = function Role(props: RoleProps): JSX.Element {\n return createInstance(TagName, props);\n} as Component<RoleProps> & RoleElements;\n\nObject.assign(\n Role,\n elements.reduce((acc, element) => {\n acc[element] = function Role(\n props: RoleProps<typeof element>,\n ): JSX.Element {\n return createInstance(element, props);\n };\n return acc;\n }, {} as RoleElements),\n);\n\nexport interface RoleOptions<\n _T extends ValidComponent = TagName,\n> extends Options {}\n\nexport type RoleProps<T extends ValidComponent = TagName> = Props<\n T,\n RoleOptions\n>;\n"],"mappings":";;AAIA,MAAM,UAAU;AAGhB,MAAa,WAAW;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;AAeA,MAAa,UAAU,WACrB,SAAS,QAAQ,OAAO;CACtB,OAAO;AACT,CACF;;;;;;;;;;;AAaA,MAAa,OAAO,SAAS,KAAK,OAA+B;CAC/D,OAAO,eAAe,SAAS,KAAK;AACtC;AAEA,OAAO,OACL,MACA,SAAS,QAAQ,KAAK,YAAY;CAChC,IAAI,WAAW,SAAS,KACtB,OACa;EACb,OAAO,eAAe,SAAS,KAAK;CACtC;CACA,OAAO;AACT,GAAG,CAAC,CAAiB,CACvB"}
@@ -0,0 +1,36 @@
1
+ import { createHook, createInstance, mergeProps, withOptions } from "@ariakit/solid-utils";
2
+ //#region src/separator/separator.tsx
3
+ const TagName = "hr";
4
+ /**
5
+ * Returns props to create a `Separator` component.
6
+ * @see https://solid.ariakit.com/components/separator
7
+ * @example
8
+ * ```jsx
9
+ * const props = useSeparator({ orientation: "horizontal" });
10
+ * <Role {...props} />
11
+ * ```
12
+ */
13
+ const useSeparator = createHook(withOptions({ orientation: "horizontal" }, function useSeparator(props, options) {
14
+ props = mergeProps({
15
+ role: "separator",
16
+ get "aria-orientation"() {
17
+ return options.orientation;
18
+ }
19
+ }, props);
20
+ return props;
21
+ }));
22
+ /**
23
+ * Renders a separator element.
24
+ * @see https://solid.ariakit.com/components/separator
25
+ * @example
26
+ * ```jsx
27
+ * <Separator orientation="horizontal" />
28
+ * ```
29
+ */
30
+ const Separator = function Separator(props) {
31
+ return createInstance(TagName, useSeparator(props));
32
+ };
33
+ //#endregion
34
+ export { Separator, useSeparator };
35
+
36
+ //# sourceMappingURL=separator.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"separator.jsx","names":[],"sources":["../../src/separator/separator.tsx"],"sourcesContent":["import {\n mergeProps,\n createHook,\n createInstance,\n withOptions,\n} from \"@ariakit/solid-utils\";\nimport type { Options, Props } from \"@ariakit/solid-utils\";\nimport type { ValidComponent } from \"solid-js\";\n\nconst TagName = \"hr\" satisfies ValidComponent;\ntype TagName = typeof TagName;\n\n/**\n * Returns props to create a `Separator` component.\n * @see https://solid.ariakit.com/components/separator\n * @example\n * ```jsx\n * const props = useSeparator({ orientation: \"horizontal\" });\n * <Role {...props} />\n * ```\n */\nexport const useSeparator = createHook<TagName, SeparatorOptions>(\n withOptions(\n { orientation: \"horizontal\" },\n function useSeparator(props, options) {\n props = mergeProps(\n {\n role: \"separator\" as const,\n get \"aria-orientation\"() {\n return options.orientation;\n },\n },\n props,\n );\n return props;\n },\n ),\n);\n\n/**\n * Renders a separator element.\n * @see https://solid.ariakit.com/components/separator\n * @example\n * ```jsx\n * <Separator orientation=\"horizontal\" />\n * ```\n */\nexport const Separator = function Separator(props: SeparatorProps) {\n const htmlProps = useSeparator(props);\n return createInstance(TagName, htmlProps);\n};\n\nexport interface SeparatorOptions<\n _T extends ValidComponent = TagName,\n> extends Options {\n /**\n * The orientation of the separator.\n * @default \"horizontal\"\n */\n orientation?: \"horizontal\" | \"vertical\";\n}\n\nexport type SeparatorProps<T extends ValidComponent = TagName> = Props<\n T,\n SeparatorOptions<T>\n>;\n"],"mappings":";;AASA,MAAM,UAAU;;;;;;;;;;AAYhB,MAAa,eAAe,WAC1B,YACE,EAAE,aAAa,aAAa,GAC5B,SAAS,aAAa,OAAO,SAAS;CACpC,QAAQ,WACN;EACE,MAAM;EACN,IAAI,qBAAqB;GACvB,OAAO,QAAQ;EACjB;CACF,GACA,KACF;CACA,OAAO;AACT,CACF,CACF;;;;;;;;;AAUA,MAAa,YAAY,SAAS,UAAU,OAAuB;CAEjE,OAAO,eAAe,SADJ,aAAa,KACQ,CAAC;AAC1C"}
@@ -0,0 +1,48 @@
1
+ import { createHook, createInstance, mergeProps } from "@ariakit/solid-utils";
2
+ //#region src/visually-hidden/visually-hidden.tsx
3
+ const TagName = "span";
4
+ /**
5
+ * Returns props to create a `VisuallyHidden` component. When applying the props
6
+ * returned by this hook to a component, the component will be visually hidden,
7
+ * but still accessible to screen readers.
8
+ * @see https://solid.ariakit.com/components/visually-hidden
9
+ * @example
10
+ * ```jsx
11
+ * const props = useVisuallyHidden();
12
+ * <a href="#">
13
+ * Learn more<Role {...props}> about the Solar System</Role>.
14
+ * </a>
15
+ * ```
16
+ */
17
+ const useVisuallyHidden = createHook(function useVisuallyHidden(props) {
18
+ props = mergeProps({ style: {
19
+ border: 0,
20
+ clip: "rect(0 0 0 0)",
21
+ height: "1px",
22
+ margin: "-1px",
23
+ overflow: "hidden",
24
+ padding: 0,
25
+ position: "absolute",
26
+ "white-space": "nowrap",
27
+ width: "1px"
28
+ } }, props);
29
+ return props;
30
+ });
31
+ /**
32
+ * Renders an element that's visually hidden, but still accessible to screen
33
+ * readers.
34
+ * @see https://solid.ariakit.com/components/visually-hidden
35
+ * @example
36
+ * ```jsx
37
+ * <a href="#">
38
+ * Learn more<VisuallyHidden> about the Solar System</VisuallyHidden>.
39
+ * </a>
40
+ * ```
41
+ */
42
+ function VisuallyHidden(props) {
43
+ return createInstance(TagName, useVisuallyHidden(props));
44
+ }
45
+ //#endregion
46
+ export { VisuallyHidden, useVisuallyHidden };
47
+
48
+ //# sourceMappingURL=visually-hidden.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visually-hidden.jsx","names":[],"sources":["../../src/visually-hidden/visually-hidden.tsx"],"sourcesContent":["import { mergeProps, createHook, createInstance } from \"@ariakit/solid-utils\";\nimport type { Options, Props } from \"@ariakit/solid-utils\";\nimport type { ValidComponent } from \"solid-js\";\n\nconst TagName = \"span\" satisfies ValidComponent;\ntype TagName = typeof TagName;\n\n/**\n * Returns props to create a `VisuallyHidden` component. When applying the props\n * returned by this hook to a component, the component will be visually hidden,\n * but still accessible to screen readers.\n * @see https://solid.ariakit.com/components/visually-hidden\n * @example\n * ```jsx\n * const props = useVisuallyHidden();\n * <a href=\"#\">\n * Learn more<Role {...props}> about the Solar System</Role>.\n * </a>\n * ```\n */\nexport const useVisuallyHidden = createHook<TagName, VisuallyHiddenOptions>(\n function useVisuallyHidden(props) {\n props = mergeProps(\n {\n style: {\n border: 0,\n clip: \"rect(0 0 0 0)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: 0,\n position: \"absolute\",\n \"white-space\": \"nowrap\",\n width: \"1px\",\n },\n },\n props,\n );\n return props;\n },\n);\n\n/**\n * Renders an element that's visually hidden, but still accessible to screen\n * readers.\n * @see https://solid.ariakit.com/components/visually-hidden\n * @example\n * ```jsx\n * <a href=\"#\">\n * Learn more<VisuallyHidden> about the Solar System</VisuallyHidden>.\n * </a>\n * ```\n */\nexport function VisuallyHidden(props: VisuallyHiddenProps) {\n const htmlProps = useVisuallyHidden(props);\n return createInstance(TagName, htmlProps);\n}\n\nexport interface VisuallyHiddenOptions<\n _T extends ValidComponent = TagName,\n> extends Options {}\n\nexport type VisuallyHiddenProps = Props<TagName, VisuallyHiddenOptions>;\n"],"mappings":";;AAIA,MAAM,UAAU;;;;;;;;;;;;;;AAgBhB,MAAa,oBAAoB,WAC/B,SAAS,kBAAkB,OAAO;CAChC,QAAQ,WACN,EACE,OAAO;EACL,QAAQ;EACR,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,UAAU;EACV,SAAS;EACT,UAAU;EACV,eAAe;EACf,OAAO;CACT,EACF,GACA,KACF;CACA,OAAO;AACT,CACF;;;;;;;;;;;;AAaA,SAAgB,eAAe,OAA4B;CAEzD,OAAO,eAAe,SADJ,kBAAkB,KACG,CAAC;AAC1C"}