menhir 0.0.0 → 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/LICENSE +0 -28
- package/README.md +53 -1
- package/dist/accordion/header/AccordionHeader.js +22 -0
- package/dist/accordion/index.js +2 -0
- package/dist/accordion/index.parts.js +6 -0
- package/dist/accordion/item/AccordionItem.js +51 -0
- package/dist/accordion/item/AccordionItemContext.js +10 -0
- package/dist/accordion/panel/AccordionPanel.js +32 -0
- package/dist/accordion/root/AccordionRoot.js +45 -0
- package/dist/accordion/root/AccordionRootContext.js +10 -0
- package/dist/accordion/trigger/AccordionTrigger.js +39 -0
- package/dist/checkbox/index.js +2 -0
- package/dist/checkbox/index.parts.js +3 -0
- package/dist/checkbox/indicator/CheckboxIndicator.js +20 -0
- package/dist/checkbox/root/CheckboxRoot.js +136 -0
- package/dist/checkbox/root/CheckboxRootContext.js +10 -0
- package/dist/collapsible/index.js +2 -0
- package/dist/collapsible/index.parts.js +4 -0
- package/dist/collapsible/panel/CollapsiblePanel.js +27 -0
- package/dist/collapsible/root/CollapsibleRoot.js +53 -0
- package/dist/collapsible/root/CollapsibleRootContext.js +10 -0
- package/dist/collapsible/trigger/CollapsibleTrigger.js +31 -0
- package/dist/color-scheme/colorScheme.js +28 -0
- package/dist/color-scheme/colorSchemeScript.js +18 -0
- package/dist/color-scheme/cookie/cookie.js +50 -0
- package/dist/color-scheme/cookie/index.js +3 -0
- package/dist/color-scheme/createColorScheme.js +41 -0
- package/dist/color-scheme/local-storage/index.js +3 -0
- package/dist/color-scheme/local-storage/localStorage.js +38 -0
- package/dist/core/button.js +56 -0
- package/dist/core/createControllableSignal.js +50 -0
- package/dist/core/listValue.js +49 -0
- package/dist/core/mergeElementProps.js +67 -0
- package/dist/core/preference/cookiePreference.js +44 -0
- package/dist/core/preference/createPreference.js +60 -0
- package/dist/core/preference/localStoragePreference.js +28 -0
- package/dist/core/preference/preference.js +21 -0
- package/dist/core/preference/preferenceScript.js +12 -0
- package/dist/core/range.js +53 -0
- package/dist/core/renderElement.js +14 -0
- package/dist/core/rovingFocus.js +50 -0
- package/dist/core/toggleButton.js +37 -0
- package/dist/meter/index.js +2 -0
- package/dist/meter/index.parts.js +3 -0
- package/dist/meter/root/MeterRoot.js +28 -0
- package/dist/meter/root/MeterRootContext.js +10 -0
- package/dist/meter/value/MeterValue.js +24 -0
- package/dist/progress/index.js +2 -0
- package/dist/progress/index.parts.js +4 -0
- package/dist/progress/indicator/ProgressIndicator.js +21 -0
- package/dist/progress/root/ProgressRoot.js +47 -0
- package/dist/progress/root/ProgressRootContext.js +10 -0
- package/dist/progress/value/ProgressValue.js +26 -0
- package/dist/separator/index.js +2 -0
- package/dist/separator/index.parts.js +1 -0
- package/dist/separator/root/SeparatorRoot.js +31 -0
- package/dist/source/accordion/header/AccordionHeader.d.ts +11 -0
- package/dist/source/accordion/header/AccordionHeader.jsx +14 -0
- package/dist/source/accordion/index.d.ts +1 -0
- package/dist/source/accordion/index.js +1 -0
- package/dist/source/accordion/index.parts.d.ts +5 -0
- package/dist/source/accordion/index.parts.js +5 -0
- package/dist/source/accordion/item/AccordionItem.d.ts +17 -0
- package/dist/source/accordion/item/AccordionItem.jsx +42 -0
- package/dist/source/accordion/item/AccordionItemContext.d.ts +33 -0
- package/dist/source/accordion/item/AccordionItemContext.js +12 -0
- package/dist/source/accordion/panel/AccordionPanel.d.ts +11 -0
- package/dist/source/accordion/panel/AccordionPanel.jsx +27 -0
- package/dist/source/accordion/root/AccordionRoot.d.ts +26 -0
- package/dist/source/accordion/root/AccordionRoot.jsx +37 -0
- package/dist/source/accordion/root/AccordionRootContext.d.ts +11 -0
- package/dist/source/accordion/root/AccordionRootContext.js +13 -0
- package/dist/source/accordion/trigger/AccordionTrigger.d.ts +10 -0
- package/dist/source/accordion/trigger/AccordionTrigger.jsx +35 -0
- package/dist/source/checkbox/index.d.ts +1 -0
- package/dist/source/checkbox/index.js +1 -0
- package/dist/source/checkbox/index.parts.d.ts +2 -0
- package/dist/source/checkbox/index.parts.js +2 -0
- package/dist/source/checkbox/indicator/CheckboxIndicator.d.ts +10 -0
- package/dist/source/checkbox/indicator/CheckboxIndicator.jsx +12 -0
- package/dist/source/checkbox/root/CheckboxRoot.d.ts +37 -0
- package/dist/source/checkbox/root/CheckboxRoot.jsx +135 -0
- package/dist/source/checkbox/root/CheckboxRootContext.d.ts +16 -0
- package/dist/source/checkbox/root/CheckboxRootContext.js +13 -0
- package/dist/source/collapsible/index.d.ts +1 -0
- package/dist/source/collapsible/index.js +1 -0
- package/dist/source/collapsible/index.parts.d.ts +3 -0
- package/dist/source/collapsible/index.parts.js +3 -0
- package/dist/source/collapsible/panel/CollapsiblePanel.d.ts +10 -0
- package/dist/source/collapsible/panel/CollapsiblePanel.jsx +22 -0
- package/dist/source/collapsible/root/CollapsibleRoot.d.ts +21 -0
- package/dist/source/collapsible/root/CollapsibleRoot.jsx +42 -0
- package/dist/source/collapsible/root/CollapsibleRootContext.d.ts +26 -0
- package/dist/source/collapsible/root/CollapsibleRootContext.js +13 -0
- package/dist/source/collapsible/trigger/CollapsibleTrigger.d.ts +10 -0
- package/dist/source/collapsible/trigger/CollapsibleTrigger.jsx +23 -0
- package/dist/source/color-scheme/colorScheme.d.ts +35 -0
- package/dist/source/color-scheme/colorScheme.js +30 -0
- package/dist/source/color-scheme/colorSchemeScript.d.ts +8 -0
- package/dist/source/color-scheme/colorSchemeScript.js +16 -0
- package/dist/source/color-scheme/cookie/cookie.d.ts +39 -0
- package/dist/source/color-scheme/cookie/cookie.js +48 -0
- package/dist/source/color-scheme/cookie/index.d.ts +4 -0
- package/dist/source/color-scheme/cookie/index.js +2 -0
- package/dist/source/color-scheme/createColorScheme.d.ts +26 -0
- package/dist/source/color-scheme/createColorScheme.js +44 -0
- package/dist/source/color-scheme/local-storage/index.d.ts +4 -0
- package/dist/source/color-scheme/local-storage/index.js +2 -0
- package/dist/source/color-scheme/local-storage/localStorage.d.ts +30 -0
- package/dist/source/color-scheme/local-storage/localStorage.js +36 -0
- package/dist/source/core/button.d.ts +53 -0
- package/dist/source/core/button.js +61 -0
- package/dist/source/core/createControllableSignal.d.ts +27 -0
- package/dist/source/core/createControllableSignal.js +74 -0
- package/dist/source/core/index.d.ts +1 -0
- package/dist/source/core/index.js +1 -0
- package/dist/source/core/listValue.d.ts +32 -0
- package/dist/source/core/listValue.js +51 -0
- package/dist/source/core/mergeElementProps.d.ts +19 -0
- package/dist/source/core/mergeElementProps.js +91 -0
- package/dist/source/core/preference/cookiePreference.d.ts +10 -0
- package/dist/source/core/preference/cookiePreference.js +57 -0
- package/dist/source/core/preference/createPreference.d.ts +44 -0
- package/dist/source/core/preference/createPreference.js +60 -0
- package/dist/source/core/preference/localStoragePreference.d.ts +3 -0
- package/dist/source/core/preference/localStoragePreference.js +36 -0
- package/dist/source/core/preference/preference.d.ts +40 -0
- package/dist/source/core/preference/preference.js +22 -0
- package/dist/source/core/preference/preferenceScript.d.ts +17 -0
- package/dist/source/core/preference/preferenceScript.js +13 -0
- package/dist/source/core/range.d.ts +52 -0
- package/dist/source/core/range.js +60 -0
- package/dist/source/core/renderElement.d.ts +25 -0
- package/dist/source/core/renderElement.jsx +11 -0
- package/dist/source/core/rovingFocus.d.ts +42 -0
- package/dist/source/core/rovingFocus.js +71 -0
- package/dist/source/core/toggleButton.d.ts +22 -0
- package/dist/source/core/toggleButton.js +35 -0
- package/dist/source/meter/index.d.ts +1 -0
- package/dist/source/meter/index.js +1 -0
- package/dist/source/meter/index.parts.d.ts +2 -0
- package/dist/source/meter/index.parts.js +2 -0
- package/dist/source/meter/root/MeterRoot.d.ts +27 -0
- package/dist/source/meter/root/MeterRoot.jsx +15 -0
- package/dist/source/meter/root/MeterRootContext.d.ts +9 -0
- package/dist/source/meter/root/MeterRootContext.js +13 -0
- package/dist/source/meter/value/MeterValue.d.ts +11 -0
- package/dist/source/meter/value/MeterValue.jsx +19 -0
- package/dist/source/progress/index.d.ts +1 -0
- package/dist/source/progress/index.js +1 -0
- package/dist/source/progress/index.parts.d.ts +3 -0
- package/dist/source/progress/index.parts.js +3 -0
- package/dist/source/progress/indicator/ProgressIndicator.d.ts +11 -0
- package/dist/source/progress/indicator/ProgressIndicator.jsx +13 -0
- package/dist/source/progress/root/ProgressRoot.d.ts +30 -0
- package/dist/source/progress/root/ProgressRoot.jsx +32 -0
- package/dist/source/progress/root/ProgressRootContext.d.ts +20 -0
- package/dist/source/progress/root/ProgressRootContext.js +13 -0
- package/dist/source/progress/value/ProgressValue.d.ts +12 -0
- package/dist/source/progress/value/ProgressValue.jsx +20 -0
- package/dist/source/separator/index.d.ts +1 -0
- package/dist/source/separator/index.js +1 -0
- package/dist/source/separator/index.parts.d.ts +1 -0
- package/dist/source/separator/index.parts.js +1 -0
- package/dist/source/separator/root/SeparatorRoot.d.ts +12 -0
- package/dist/source/separator/root/SeparatorRoot.jsx +26 -0
- package/dist/source/switch/index.d.ts +1 -0
- package/dist/source/switch/index.js +1 -0
- package/dist/source/switch/index.parts.d.ts +2 -0
- package/dist/source/switch/index.parts.js +2 -0
- package/dist/source/switch/root/SwitchRoot.d.ts +31 -0
- package/dist/source/switch/root/SwitchRoot.jsx +124 -0
- package/dist/source/switch/root/SwitchRootContext.d.ts +14 -0
- package/dist/source/switch/root/SwitchRootContext.js +13 -0
- package/dist/source/switch/thumb/SwitchThumb.d.ts +10 -0
- package/dist/source/switch/thumb/SwitchThumb.jsx +12 -0
- package/dist/source/tabs/index.d.ts +1 -0
- package/dist/source/tabs/index.js +1 -0
- package/dist/source/tabs/index.parts.d.ts +4 -0
- package/dist/source/tabs/index.parts.js +4 -0
- package/dist/source/tabs/list/TabsList.d.ts +11 -0
- package/dist/source/tabs/list/TabsList.jsx +27 -0
- package/dist/source/tabs/panel/TabsPanel.d.ts +12 -0
- package/dist/source/tabs/panel/TabsPanel.jsx +38 -0
- package/dist/source/tabs/root/TabsRoot.d.ts +30 -0
- package/dist/source/tabs/root/TabsRoot.jsx +74 -0
- package/dist/source/tabs/root/TabsRootContext.d.ts +47 -0
- package/dist/source/tabs/root/TabsRootContext.js +13 -0
- package/dist/source/tabs/tab/TabsTab.d.ts +20 -0
- package/dist/source/tabs/tab/TabsTab.jsx +77 -0
- package/dist/source/theme/cookie/cookie.d.ts +34 -0
- package/dist/source/theme/cookie/cookie.js +42 -0
- package/dist/source/theme/cookie/index.d.ts +2 -0
- package/dist/source/theme/cookie/index.js +1 -0
- package/dist/source/theme/local-storage/index.d.ts +2 -0
- package/dist/source/theme/local-storage/index.js +1 -0
- package/dist/source/theme/local-storage/localStorage.d.ts +28 -0
- package/dist/source/theme/local-storage/localStorage.js +34 -0
- package/dist/source/theme/theme.d.ts +46 -0
- package/dist/source/theme/theme.js +57 -0
- package/dist/source/toggle/index.d.ts +1 -0
- package/dist/source/toggle/index.js +1 -0
- package/dist/source/toggle/index.parts.d.ts +1 -0
- package/dist/source/toggle/index.parts.js +1 -0
- package/dist/source/toggle/root/ToggleRoot.d.ts +20 -0
- package/dist/source/toggle/root/ToggleRoot.jsx +30 -0
- package/dist/source/toggle-group/index.d.ts +1 -0
- package/dist/source/toggle-group/index.js +1 -0
- package/dist/source/toggle-group/index.parts.d.ts +2 -0
- package/dist/source/toggle-group/index.parts.js +2 -0
- package/dist/source/toggle-group/item/ToggleGroupItem.d.ts +14 -0
- package/dist/source/toggle-group/item/ToggleGroupItem.jsx +39 -0
- package/dist/source/toggle-group/root/ToggleGroupRoot.d.ts +28 -0
- package/dist/source/toggle-group/root/ToggleGroupRoot.jsx +68 -0
- package/dist/source/toggle-group/root/ToggleGroupRootContext.d.ts +25 -0
- package/dist/source/toggle-group/root/ToggleGroupRootContext.js +13 -0
- package/dist/switch/index.js +2 -0
- package/dist/switch/index.parts.js +3 -0
- package/dist/switch/root/SwitchRoot.js +129 -0
- package/dist/switch/root/SwitchRootContext.js +10 -0
- package/dist/switch/thumb/SwitchThumb.js +20 -0
- package/dist/tabs/index.js +2 -0
- package/dist/tabs/index.parts.js +5 -0
- package/dist/tabs/list/TabsList.js +33 -0
- package/dist/tabs/panel/TabsPanel.js +40 -0
- package/dist/tabs/root/TabsRoot.js +74 -0
- package/dist/tabs/root/TabsRootContext.js +10 -0
- package/dist/tabs/tab/TabsTab.js +74 -0
- package/dist/theme/cookie/cookie.js +44 -0
- package/dist/theme/cookie/index.js +1 -0
- package/dist/theme/local-storage/index.js +1 -0
- package/dist/theme/local-storage/localStorage.js +36 -0
- package/dist/theme/theme.js +52 -0
- package/dist/toggle/index.js +2 -0
- package/dist/toggle/index.parts.js +1 -0
- package/dist/toggle/root/ToggleRoot.js +38 -0
- package/dist/toggle-group/index.js +2 -0
- package/dist/toggle-group/index.parts.js +3 -0
- package/dist/toggle-group/item/ToggleGroupItem.js +48 -0
- package/dist/toggle-group/root/ToggleGroupRoot.js +71 -0
- package/dist/toggle-group/root/ToggleGroupRootContext.js +10 -0
- package/package.json +99 -6
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface MeterRootProps extends JSX.HTMLAttributes<HTMLElement> {
|
|
4
|
+
/** The measurement, from `min` to `max`, clamped to them. */
|
|
5
|
+
value: number;
|
|
6
|
+
/** The lowest value the measurement can take. Default 0. */
|
|
7
|
+
min?: number;
|
|
8
|
+
/** The highest value the measurement can take. Default 100. */
|
|
9
|
+
max?: number;
|
|
10
|
+
/**
|
|
11
|
+
* How `aria-valuetext` and `Meter.Value` format the value, as
|
|
12
|
+
* `Intl.NumberFormat` options. The `percent` style, the default, formats
|
|
13
|
+
* the percentage of the range; any other style formats the value itself.
|
|
14
|
+
* A consumer's `aria-valuetext` replaces the formatted text.
|
|
15
|
+
*/
|
|
16
|
+
format?: Intl.NumberFormatOptions;
|
|
17
|
+
/**
|
|
18
|
+
* The language to format in, else the runtime's default. Pass it when
|
|
19
|
+
* rendering on the server, so that the server and the browser agree.
|
|
20
|
+
*/
|
|
21
|
+
locale?: Intl.LocalesArgument;
|
|
22
|
+
render?: RenderProp;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The meter itself: a `<div role="meter">`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function MeterRoot(props: MeterRootProps): JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { omit } from "solid-js";
|
|
2
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { createRange } from "../../core/range.js";
|
|
4
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
5
|
+
import { MeterRootContext } from "./MeterRootContext.js";
|
|
6
|
+
/**
|
|
7
|
+
* The meter itself: a `<div role="meter">`.
|
|
8
|
+
*/
|
|
9
|
+
export function MeterRoot(props) {
|
|
10
|
+
const range = createRange(props, "meter", "--meter");
|
|
11
|
+
const elementProps = mergeElementProps(range.props, omit(props, "render", "value", "min", "max", "format", "locale"));
|
|
12
|
+
return (<MeterRootContext value={{ valueText: range.valueText }}>
|
|
13
|
+
{renderElement(props, elementProps, (p) => (<div {...p}/>))}
|
|
14
|
+
</MeterRootContext>);
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type MeterRootContextValue = {
|
|
2
|
+
/**
|
|
3
|
+
* The Root's `aria-valuetext`: the consumer's, else the formatted value,
|
|
4
|
+
* which a meter always has.
|
|
5
|
+
*/
|
|
6
|
+
valueText: () => string | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare const MeterRootContext: import("solid-js").Context<MeterRootContextValue | null>;
|
|
9
|
+
export declare function useMeterRootContext(): MeterRootContextValue;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext, useContext } from "solid-js";
|
|
2
|
+
import { isDev } from "@solidjs/web";
|
|
3
|
+
// `null` outside a Root, so that the part can name what is missing. Solid's
|
|
4
|
+
// own error for a context with no provider and no default does not.
|
|
5
|
+
export const MeterRootContext = createContext(null);
|
|
6
|
+
export function useMeterRootContext() {
|
|
7
|
+
const context = useContext(MeterRootContext);
|
|
8
|
+
// Production builds drop the check, and its message, with `isDev`.
|
|
9
|
+
if (isDev && !context) {
|
|
10
|
+
throw new Error("[menhir] Meter parts must be placed within <Meter.Root>.");
|
|
11
|
+
}
|
|
12
|
+
return context;
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface MeterValueProps extends Omit<JSX.HTMLAttributes<HTMLElement>, "children"> {
|
|
4
|
+
render?: RenderProp;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The value as text: a `<span>` with the Root's `aria-valuetext`, the
|
|
8
|
+
* consumer's or the value in the Root's `format` and `locale`. Place it
|
|
9
|
+
* inside `Meter.Root`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function MeterValue(props: MeterValueProps): JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { omit } from "solid-js";
|
|
2
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
4
|
+
import { useMeterRootContext } from "../root/MeterRootContext.js";
|
|
5
|
+
/**
|
|
6
|
+
* The value as text: a `<span>` with the Root's `aria-valuetext`, the
|
|
7
|
+
* consumer's or the value in the Root's `format` and `locale`. Place it
|
|
8
|
+
* inside `Meter.Root`.
|
|
9
|
+
*/
|
|
10
|
+
export function MeterValue(props) {
|
|
11
|
+
const context = useMeterRootContext();
|
|
12
|
+
const ownProps = {
|
|
13
|
+
get children() {
|
|
14
|
+
return context.valueText();
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
const elementProps = mergeElementProps(ownProps, omit(props, "render"));
|
|
18
|
+
return renderElement(props, elementProps, (p) => <span {...p}/>);
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Progress from "./index.parts.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Progress from "./index.parts.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface ProgressIndicatorProps extends JSX.HTMLAttributes<HTMLElement> {
|
|
4
|
+
render?: RenderProp;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The filled part of the bar: a `<div>` with the Root's `data-*` attributes.
|
|
8
|
+
* It draws nothing; size it with `--progress`, which it inherits from the
|
|
9
|
+
* Root. Place it inside `Progress.Root`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ProgressIndicator(props: ProgressIndicatorProps): JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { omit } from "solid-js";
|
|
2
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
4
|
+
import { useProgressRootContext } from "../root/ProgressRootContext.js";
|
|
5
|
+
/**
|
|
6
|
+
* The filled part of the bar: a `<div>` with the Root's `data-*` attributes.
|
|
7
|
+
* It draws nothing; size it with `--progress`, which it inherits from the
|
|
8
|
+
* Root. Place it inside `Progress.Root`.
|
|
9
|
+
*/
|
|
10
|
+
export function ProgressIndicator(props) {
|
|
11
|
+
const elementProps = mergeElementProps(useProgressRootContext().attributes, omit(props, "render"));
|
|
12
|
+
return renderElement(props, elementProps, (p) => <div {...p}/>);
|
|
13
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface ProgressRootProps extends JSX.HTMLAttributes<HTMLElement> {
|
|
4
|
+
/**
|
|
5
|
+
* How far the task has got, from `min` to `max`, clamped to them; `null`
|
|
6
|
+
* while unknown (indeterminate).
|
|
7
|
+
*/
|
|
8
|
+
value: number | null;
|
|
9
|
+
/** The value at the start of the task. Default 0. */
|
|
10
|
+
min?: number;
|
|
11
|
+
/** The value when the task is complete. Default 100. */
|
|
12
|
+
max?: number;
|
|
13
|
+
/**
|
|
14
|
+
* How `aria-valuetext` and `Progress.Value` format the value, as
|
|
15
|
+
* `Intl.NumberFormat` options. The `percent` style, the default, formats
|
|
16
|
+
* the percentage of the range; any other style formats the value itself.
|
|
17
|
+
* A consumer's `aria-valuetext` replaces the formatted text.
|
|
18
|
+
*/
|
|
19
|
+
format?: Intl.NumberFormatOptions;
|
|
20
|
+
/**
|
|
21
|
+
* The language to format in, else the runtime's default. Pass it when
|
|
22
|
+
* rendering on the server, so that the server and the browser agree.
|
|
23
|
+
*/
|
|
24
|
+
locale?: Intl.LocalesArgument;
|
|
25
|
+
render?: RenderProp;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The progress bar itself: a `<div role="progressbar">`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function ProgressRoot(props: ProgressRootProps): JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { merge, omit } from "solid-js";
|
|
2
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { createRange } from "../../core/range.js";
|
|
4
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
5
|
+
import { ProgressRootContext } from "./ProgressRootContext.js";
|
|
6
|
+
/**
|
|
7
|
+
* The progress bar itself: a `<div role="progressbar">`.
|
|
8
|
+
*/
|
|
9
|
+
export function ProgressRoot(props) {
|
|
10
|
+
const range = createRange(props, "progressbar", "--progress");
|
|
11
|
+
const state = () => {
|
|
12
|
+
const fraction = range.fraction();
|
|
13
|
+
if (fraction === undefined)
|
|
14
|
+
return "indeterminate";
|
|
15
|
+
return fraction === 1 ? "complete" : "progressing";
|
|
16
|
+
};
|
|
17
|
+
const attributes = {
|
|
18
|
+
get "data-indeterminate"() {
|
|
19
|
+
return state() === "indeterminate" ? "" : undefined;
|
|
20
|
+
},
|
|
21
|
+
get "data-progressing"() {
|
|
22
|
+
return state() === "progressing" ? "" : undefined;
|
|
23
|
+
},
|
|
24
|
+
get "data-complete"() {
|
|
25
|
+
return state() === "complete" ? "" : undefined;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const elementProps = mergeElementProps(merge(attributes, range.props), omit(props, "render", "value", "min", "max", "format", "locale"));
|
|
29
|
+
return (<ProgressRootContext value={{ attributes, valueText: range.valueText }}>
|
|
30
|
+
{renderElement(props, elementProps, (p) => (<div {...p}/>))}
|
|
31
|
+
</ProgressRootContext>);
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The progress bar's state as `data-*` attributes, each `""` when it applies
|
|
3
|
+
* and absent otherwise. Exactly one applies at a time. Every part spreads the
|
|
4
|
+
* same object, so its getters are read where each element uses them.
|
|
5
|
+
*/
|
|
6
|
+
export type ProgressStateAttributes = {
|
|
7
|
+
readonly "data-indeterminate": "" | undefined;
|
|
8
|
+
readonly "data-progressing": "" | undefined;
|
|
9
|
+
readonly "data-complete": "" | undefined;
|
|
10
|
+
};
|
|
11
|
+
export type ProgressRootContextValue = {
|
|
12
|
+
attributes: ProgressStateAttributes;
|
|
13
|
+
/**
|
|
14
|
+
* The Root's `aria-valuetext`: the consumer's, else the formatted value,
|
|
15
|
+
* which is `undefined` while indeterminate.
|
|
16
|
+
*/
|
|
17
|
+
valueText: () => string | undefined;
|
|
18
|
+
};
|
|
19
|
+
export declare const ProgressRootContext: import("solid-js").Context<ProgressRootContextValue | null>;
|
|
20
|
+
export declare function useProgressRootContext(): ProgressRootContextValue;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext, useContext } from "solid-js";
|
|
2
|
+
import { isDev } from "@solidjs/web";
|
|
3
|
+
// `null` outside a Root, so that the part can name what is missing. Solid's
|
|
4
|
+
// own error for a context with no provider and no default does not.
|
|
5
|
+
export const ProgressRootContext = createContext(null);
|
|
6
|
+
export function useProgressRootContext() {
|
|
7
|
+
const context = useContext(ProgressRootContext);
|
|
8
|
+
// Production builds drop the check, and its message, with `isDev`.
|
|
9
|
+
if (isDev && !context) {
|
|
10
|
+
throw new Error("[menhir] Progress parts must be placed within <Progress.Root>.");
|
|
11
|
+
}
|
|
12
|
+
return context;
|
|
13
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface ProgressValueProps extends Omit<JSX.HTMLAttributes<HTMLElement>, "children"> {
|
|
4
|
+
render?: RenderProp;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The value as text: a `<span>` with the Root's `aria-valuetext`, the
|
|
8
|
+
* consumer's or the value in the Root's `format` and `locale`, and its
|
|
9
|
+
* `data-*` attributes. Empty while indeterminate, unless the consumer gave
|
|
10
|
+
* `aria-valuetext`. Place it inside `Progress.Root`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ProgressValue(props: ProgressValueProps): JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { merge, omit } from "solid-js";
|
|
2
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
4
|
+
import { useProgressRootContext } from "../root/ProgressRootContext.js";
|
|
5
|
+
/**
|
|
6
|
+
* The value as text: a `<span>` with the Root's `aria-valuetext`, the
|
|
7
|
+
* consumer's or the value in the Root's `format` and `locale`, and its
|
|
8
|
+
* `data-*` attributes. Empty while indeterminate, unless the consumer gave
|
|
9
|
+
* `aria-valuetext`. Place it inside `Progress.Root`.
|
|
10
|
+
*/
|
|
11
|
+
export function ProgressValue(props) {
|
|
12
|
+
const context = useProgressRootContext();
|
|
13
|
+
const ownProps = merge(context.attributes, {
|
|
14
|
+
get children() {
|
|
15
|
+
return context.valueText();
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
const elementProps = mergeElementProps(ownProps, omit(props, "render"));
|
|
19
|
+
return renderElement(props, elementProps, (p) => <span {...p}/>);
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Separator from "./index.parts.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Separator from "./index.parts.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SeparatorRoot as Root } from "./root/SeparatorRoot.tsx";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SeparatorRoot as Root } from "./root/SeparatorRoot.jsx";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface SeparatorRootProps extends JSX.HTMLAttributes<HTMLElement> {
|
|
4
|
+
/** Whether the separator divides content stacked above and below, or side by side. */
|
|
5
|
+
orientation?: "horizontal" | "vertical";
|
|
6
|
+
render?: RenderProp;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A line between sections of content or groups of items: a
|
|
10
|
+
* `<div role="separator">`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function SeparatorRoot(props: SeparatorRootProps): JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { omit } from "solid-js";
|
|
2
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
4
|
+
/**
|
|
5
|
+
* A line between sections of content or groups of items: a
|
|
6
|
+
* `<div role="separator">`.
|
|
7
|
+
*/
|
|
8
|
+
export function SeparatorRoot(props) {
|
|
9
|
+
const vertical = () => props.orientation === "vertical";
|
|
10
|
+
const ownProps = {
|
|
11
|
+
role: "separator",
|
|
12
|
+
// Written out when horizontal too, the role's implicit value, so that
|
|
13
|
+
// a style can select either.
|
|
14
|
+
get "aria-orientation"() {
|
|
15
|
+
return vertical() ? "vertical" : "horizontal";
|
|
16
|
+
},
|
|
17
|
+
get "data-horizontal"() {
|
|
18
|
+
return vertical() ? undefined : "";
|
|
19
|
+
},
|
|
20
|
+
get "data-vertical"() {
|
|
21
|
+
return vertical() ? "" : undefined;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
const elementProps = mergeElementProps(ownProps, omit(props, "render", "orientation"));
|
|
25
|
+
return renderElement(props, elementProps, (p) => <div {...p}/>);
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Switch from "./index.parts.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Switch from "./index.parts.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface SwitchRootProps extends JSX.HTMLAttributes<HTMLElement> {
|
|
4
|
+
/** Whether the switch is on, when controlled. */
|
|
5
|
+
checked?: boolean;
|
|
6
|
+
/** Whether the switch starts on, when uncontrolled. */
|
|
7
|
+
defaultChecked?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Called with the new value when the user turns the switch on or off, or
|
|
10
|
+
* its form is reset. When controlled, the switch changes only if
|
|
11
|
+
* `checked` does.
|
|
12
|
+
*/
|
|
13
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
14
|
+
/** Submitted with the form, as the hidden input's `name`. */
|
|
15
|
+
name?: string;
|
|
16
|
+
/** Submitted with the form while the switch is on. The browser's default is `"on"`. */
|
|
17
|
+
value?: string;
|
|
18
|
+
/** Whether the switch ignores the user. It cannot be focused either. */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** Whether the switch can be focused but not turned on or off. */
|
|
21
|
+
readOnly?: boolean;
|
|
22
|
+
/** Whether the form can be submitted only while the switch is on. */
|
|
23
|
+
required?: boolean;
|
|
24
|
+
/** The `id` of the form the switch belongs to, when it is not inside it. */
|
|
25
|
+
form?: string;
|
|
26
|
+
render?: RenderProp;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The switch itself: a `<button role="switch">`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function SwitchRoot(props: SwitchRootProps): JSX.Element;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { isDev } from "@solidjs/web";
|
|
2
|
+
import { merge, omit, onFlush, onSettled, untrack } from "solid-js";
|
|
3
|
+
import { warnUnlessButton } from "../../core/button.js";
|
|
4
|
+
import { createControllableSignal } from "../../core/createControllableSignal.js";
|
|
5
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
6
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
7
|
+
import { SwitchRootContext } from "./SwitchRootContext.js";
|
|
8
|
+
/**
|
|
9
|
+
* The switch itself: a `<button role="switch">`.
|
|
10
|
+
*/
|
|
11
|
+
export function SwitchRoot(props) {
|
|
12
|
+
const [checked, setChecked] = createControllableSignal({
|
|
13
|
+
get value() {
|
|
14
|
+
return props.checked;
|
|
15
|
+
},
|
|
16
|
+
get defaultValue() {
|
|
17
|
+
return props.defaultChecked ?? false;
|
|
18
|
+
},
|
|
19
|
+
onChange: (value) => props.onCheckedChange?.(value),
|
|
20
|
+
});
|
|
21
|
+
const stateAttributes = {
|
|
22
|
+
get "data-checked"() {
|
|
23
|
+
return checked() ? "" : undefined;
|
|
24
|
+
},
|
|
25
|
+
get "data-unchecked"() {
|
|
26
|
+
return checked() ? undefined : "";
|
|
27
|
+
},
|
|
28
|
+
get "data-disabled"() {
|
|
29
|
+
return props.disabled ? "" : undefined;
|
|
30
|
+
},
|
|
31
|
+
get "data-readonly"() {
|
|
32
|
+
return props.readOnly ? "" : undefined;
|
|
33
|
+
},
|
|
34
|
+
get "data-required"() {
|
|
35
|
+
return props.required ? "" : undefined;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
const buttonProps = {
|
|
39
|
+
role: "switch",
|
|
40
|
+
type: "button",
|
|
41
|
+
get disabled() {
|
|
42
|
+
return props.disabled;
|
|
43
|
+
},
|
|
44
|
+
// Solid 2.0 removes an attribute set to false, so spell the value out.
|
|
45
|
+
get "aria-checked"() {
|
|
46
|
+
return checked() ? "true" : "false";
|
|
47
|
+
},
|
|
48
|
+
get "aria-readonly"() {
|
|
49
|
+
return props.readOnly ? "true" : undefined;
|
|
50
|
+
},
|
|
51
|
+
get "aria-required"() {
|
|
52
|
+
return props.required ? "true" : undefined;
|
|
53
|
+
},
|
|
54
|
+
// The change goes through the hidden input, so that the form sees the
|
|
55
|
+
// native `input` and `change` events a checkbox fires.
|
|
56
|
+
onClick: () => input?.click(),
|
|
57
|
+
ref: (element) => {
|
|
58
|
+
button = element;
|
|
59
|
+
// Production builds drop the check with `isDev`.
|
|
60
|
+
if (isDev)
|
|
61
|
+
warnUnlessButton(element, "Switch.Root");
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
let button;
|
|
65
|
+
let input;
|
|
66
|
+
// Puts the input back to the switch's value, once that has settled. The
|
|
67
|
+
// `checked` binding writes the DOM only when the value changes, so it
|
|
68
|
+
// does not undo a change of the input that the switch did not take.
|
|
69
|
+
const syncInput = () => {
|
|
70
|
+
if (input)
|
|
71
|
+
input.checked = untrack(checked);
|
|
72
|
+
};
|
|
73
|
+
const onInputChange = () => {
|
|
74
|
+
if (!input)
|
|
75
|
+
return;
|
|
76
|
+
setChecked(input.checked);
|
|
77
|
+
// The browser has already changed the input, so the form's own
|
|
78
|
+
// listeners, which run after this one, see the new value. The two
|
|
79
|
+
// differ afterwards only when a controlled switch's consumer declined
|
|
80
|
+
// the change.
|
|
81
|
+
onFlush(syncInput);
|
|
82
|
+
};
|
|
83
|
+
const onInputClick = (event) => {
|
|
84
|
+
// The click the button sends the input is an implementation detail:
|
|
85
|
+
// ancestors already received the user's click.
|
|
86
|
+
event.stopPropagation();
|
|
87
|
+
// Canceling the click keeps the checkbox as it was and fires no
|
|
88
|
+
// `input` or `change` event, whoever clicked it.
|
|
89
|
+
if (props.readOnly)
|
|
90
|
+
event.preventDefault();
|
|
91
|
+
};
|
|
92
|
+
// A form reset puts a checkbox back to its default, and so it does the
|
|
93
|
+
// switch: through the setter, so that a controlled switch asks.
|
|
94
|
+
onSettled(() => {
|
|
95
|
+
const form = input?.form;
|
|
96
|
+
if (!form)
|
|
97
|
+
return;
|
|
98
|
+
const onReset = () => {
|
|
99
|
+
setChecked(props.defaultChecked ?? false);
|
|
100
|
+
// The browser resets the input after this event, to its `checked`
|
|
101
|
+
// attribute, which the binding does not set. `onFlush` runs after
|
|
102
|
+
// that, as the event has finished by then.
|
|
103
|
+
onFlush(syncInput);
|
|
104
|
+
};
|
|
105
|
+
form.addEventListener("reset", onReset);
|
|
106
|
+
return () => form.removeEventListener("reset", onReset);
|
|
107
|
+
});
|
|
108
|
+
const elementProps = mergeElementProps(merge(stateAttributes, buttonProps), omit(props, "render", "checked", "defaultChecked", "onCheckedChange", "name", "value", "disabled", "readOnly", "required", "form"));
|
|
109
|
+
return (<SwitchRootContext value={stateAttributes}>
|
|
110
|
+
{renderElement(props, elementProps, (p) => (<button {...p}/>))}
|
|
111
|
+
<input type="checkbox" aria-hidden="true" tabindex={-1} style={visuallyHidden} name={props.name} value={props.value} disabled={props.disabled} required={props.required} form={props.form} checked={checked()} onChange={onInputChange}
|
|
112
|
+
// The browser focuses an invalid input when it blocks a submission.
|
|
113
|
+
// The user knows the switch, not the hidden input.
|
|
114
|
+
onFocus={() => button?.focus()} ref={(element) => {
|
|
115
|
+
input = element;
|
|
116
|
+
// Solid delegates click handlers to the document, so this one is
|
|
117
|
+
// a native listener, to act before the click bubbles.
|
|
118
|
+
element.addEventListener("click", onInputClick);
|
|
119
|
+
}}/>
|
|
120
|
+
</SwitchRootContext>);
|
|
121
|
+
}
|
|
122
|
+
// Hidden from sight but not from the form. Not `display: none`, so the
|
|
123
|
+
// browser can still anchor a validation message to it.
|
|
124
|
+
const visuallyHidden = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap;pointer-events:none";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The switch's state as `data-*` attributes, each `""` when it applies and
|
|
3
|
+
* absent otherwise. Root and Thumb both spread the same object, so its
|
|
4
|
+
* getters are read where each element uses them.
|
|
5
|
+
*/
|
|
6
|
+
export type SwitchStateAttributes = {
|
|
7
|
+
readonly "data-checked": "" | undefined;
|
|
8
|
+
readonly "data-unchecked": "" | undefined;
|
|
9
|
+
readonly "data-disabled": "" | undefined;
|
|
10
|
+
readonly "data-readonly": "" | undefined;
|
|
11
|
+
readonly "data-required": "" | undefined;
|
|
12
|
+
};
|
|
13
|
+
export declare const SwitchRootContext: import("solid-js").Context<SwitchStateAttributes | null>;
|
|
14
|
+
export declare function useSwitchRootContext(): SwitchStateAttributes;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext, useContext } from "solid-js";
|
|
2
|
+
import { isDev } from "@solidjs/web";
|
|
3
|
+
// `null` outside a Root, so that the part can name what is missing. Solid's
|
|
4
|
+
// own error for a context with no provider and no default does not.
|
|
5
|
+
export const SwitchRootContext = createContext(null);
|
|
6
|
+
export function useSwitchRootContext() {
|
|
7
|
+
const context = useContext(SwitchRootContext);
|
|
8
|
+
// Production builds drop the check, and its message, with `isDev`.
|
|
9
|
+
if (isDev && !context) {
|
|
10
|
+
throw new Error("[menhir] Switch parts must be placed within <Switch.Root>.");
|
|
11
|
+
}
|
|
12
|
+
return context;
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface SwitchThumbProps extends JSX.HTMLAttributes<HTMLElement> {
|
|
4
|
+
render?: RenderProp;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The part of the switch that slides between off and on: a `<span>` with
|
|
8
|
+
* the Root's `data-*` attributes. Place it inside `Switch.Root`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function SwitchThumb(props: SwitchThumbProps): JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { omit } from "solid-js";
|
|
2
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
4
|
+
import { useSwitchRootContext } from "../root/SwitchRootContext.js";
|
|
5
|
+
/**
|
|
6
|
+
* The part of the switch that slides between off and on: a `<span>` with
|
|
7
|
+
* the Root's `data-*` attributes. Place it inside `Switch.Root`.
|
|
8
|
+
*/
|
|
9
|
+
export function SwitchThumb(props) {
|
|
10
|
+
const elementProps = mergeElementProps(useSwitchRootContext(), omit(props, "render"));
|
|
11
|
+
return renderElement(props, elementProps, (p) => <span {...p}/>);
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Tabs from "./index.parts.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Tabs from "./index.parts.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface TabsListProps extends JSX.HTMLAttributes<HTMLElement> {
|
|
4
|
+
render?: RenderProp;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The list of tabs: a `<div role="tablist">` around `Tabs.Tab`s, with one
|
|
8
|
+
* tab stop among them. Name it with `aria-label` or `aria-labelledby`.
|
|
9
|
+
* Place it inside `Tabs.Root`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function TabsList(props: TabsListProps): JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { omit } from "solid-js";
|
|
2
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
4
|
+
import { useTabsRootContext } from "../root/TabsRootContext.js";
|
|
5
|
+
/**
|
|
6
|
+
* The list of tabs: a `<div role="tablist">` around `Tabs.Tab`s, with one
|
|
7
|
+
* tab stop among them. Name it with `aria-label` or `aria-labelledby`.
|
|
8
|
+
* Place it inside `Tabs.Root`.
|
|
9
|
+
*/
|
|
10
|
+
export function TabsList(props) {
|
|
11
|
+
const root = useTabsRootContext();
|
|
12
|
+
const ownProps = {
|
|
13
|
+
role: "tablist",
|
|
14
|
+
// Horizontal is the tablist role's default.
|
|
15
|
+
get "aria-orientation"() {
|
|
16
|
+
return root.vertical() ? "vertical" : undefined;
|
|
17
|
+
},
|
|
18
|
+
get "data-horizontal"() {
|
|
19
|
+
return root.vertical() ? undefined : "";
|
|
20
|
+
},
|
|
21
|
+
get "data-vertical"() {
|
|
22
|
+
return root.vertical() ? "" : undefined;
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
const elementProps = mergeElementProps(ownProps, omit(props, "render"));
|
|
26
|
+
return renderElement(props, elementProps, (p) => <div {...p}/>);
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface TabsPanelProps extends Omit<JSX.HTMLAttributes<HTMLElement>, "id"> {
|
|
4
|
+
/** The `value` of the tab that shows this Panel. */
|
|
5
|
+
value: string;
|
|
6
|
+
render?: RenderProp;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The content its tab shows: a `<div role="tabpanel">` named by the tab,
|
|
10
|
+
* `hidden` unless the tab is selected. Place it inside `Tabs.Root`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function TabsPanel(props: TabsPanelProps): JSX.Element;
|