rift-ds 1.0.1 → 1.2.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.
- package/LICENSE +1 -1
- package/README.md +8 -2
- package/components/AppLayout/AppLayout.css +13 -3
- package/components/AppLayout/AppLayout.d.ts +5 -1
- package/components/AppLayout/AppLayout.js +4 -0
- package/components/AppSidebar/AppSidebar.css +237 -0
- package/components/AppSidebar/AppSidebar.d.ts +32 -3
- package/components/AppSidebar/AppSidebar.js +187 -16
- package/components/BottomNav/BottomNav.css +417 -0
- package/components/BottomNav/BottomNav.d.ts +73 -0
- package/components/BottomNav/BottomNav.js +100 -0
- package/components/Chart/AreaChart.js +67 -56
- package/components/Chart/BarChart.js +67 -56
- package/components/Chart/ComboChart.js +93 -82
- package/components/Chart/LineChart.js +59 -48
- package/components/Chart/PieChart.js +56 -45
- package/components/Chart/RadarChart.js +60 -49
- package/components/Chart/RadialChart.js +70 -59
- package/components/Chart/ScatterChart.js +61 -50
- package/components/Chart/StackedBarChart.js +64 -53
- package/components/Chart/Treemap.js +34 -23
- package/components/Inspector/Inspector.css +511 -0
- package/components/Inspector/InspectorDropdown.d.ts +39 -0
- package/components/Inspector/InspectorDropdown.js +68 -0
- package/components/Inspector/InspectorInput.d.ts +32 -0
- package/components/Inspector/InspectorInput.js +52 -0
- package/components/Inspector/InspectorSection.d.ts +32 -0
- package/components/Inspector/InspectorSection.js +70 -0
- package/components/Inspector/InspectorSegmentedControl.d.ts +46 -0
- package/components/Inspector/InspectorSegmentedControl.js +62 -0
- package/components/Inspector/InspectorSlider.d.ts +41 -0
- package/components/Inspector/InspectorSlider.js +81 -0
- package/components/Inspector/InspectorToggleSwitch.d.ts +29 -0
- package/components/Inspector/InspectorToggleSwitch.js +51 -0
- package/components/Nav/Nav.d.ts +11 -3
- package/components/Nav/Nav.js +3 -2
- package/components/SegmentedControl/SegmentedControl.css +7 -5
- package/components/SidebarPanel/SidebarPanel.css +291 -0
- package/components/SidebarPanel/SidebarPanel.d.ts +45 -0
- package/components/SidebarPanel/SidebarPanel.js +166 -0
- package/components/Stepper/Stepper.d.ts +3 -1
- package/components/Stepper/Stepper.js +1 -1
- package/components/TopAppBar/TopAppBar.css +464 -0
- package/components/TopAppBar/TopAppBar.d.ts +80 -0
- package/components/TopAppBar/TopAppBar.js +138 -0
- package/components/registry.json +84 -1
- package/components/registry.json.d.ts +84 -1
- package/components/registry.json.js +2 -2
- package/index.d.ts +9 -0
- package/index.js +18 -0
- package/package.json +5 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** Props owned by InspectorSection itself — everything else falls through to the <section>. */
|
|
3
|
+
type InspectorSectionOwnProps = {
|
|
4
|
+
/** The section's heading, shown on its header row. Not the native tooltip `title` attribute. */
|
|
5
|
+
title: string;
|
|
6
|
+
/** Whether the section is expanded (controlled). Pair with `onOpenChange`. */
|
|
7
|
+
open?: boolean;
|
|
8
|
+
/** Whether an uncontrolled section starts expanded. */
|
|
9
|
+
defaultOpen?: boolean;
|
|
10
|
+
/** Called with the next expanded state when the header is pressed. */
|
|
11
|
+
onOpenChange?: (open: boolean) => void;
|
|
12
|
+
/** The section's controls, stacked one rhythm apart. */
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
/** Additional CSS classes, applied to the <section>. */
|
|
15
|
+
className?: string;
|
|
16
|
+
};
|
|
17
|
+
export interface InspectorSectionProps extends InspectorSectionOwnProps, Omit<React.ComponentPropsWithoutRef<'section'>, keyof InspectorSectionOwnProps> {
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A collapsible, titled run of inspector controls: the header row toggles
|
|
21
|
+
* it, and stacked sections are divided by a hairline. The general-purpose
|
|
22
|
+
* counterpart, a bordered set of content panels, is Accordion.
|
|
23
|
+
*
|
|
24
|
+
* Two behaviours separate it from Accordion. The body clips only while
|
|
25
|
+
* closed or animating, and goes `overflow: visible` once settled open, so
|
|
26
|
+
* a Dropdown menu inside can open past the section's edge. And a closed
|
|
27
|
+
* body is `inert`, so its controls leave the tab order rather than sitting
|
|
28
|
+
* focusable at zero height. Forwards a ref to the <section> and spreads
|
|
29
|
+
* unrecognised props onto it.
|
|
30
|
+
*/
|
|
31
|
+
export declare const InspectorSection: React.ForwardRefExoticComponent<InspectorSectionProps & React.RefAttributes<HTMLElement>>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import React, { useState } from "react";
|
|
4
|
+
import "./Inspector.css";
|
|
5
|
+
import "../../fonts/material-symbols.css";
|
|
6
|
+
const InspectorSection = React.forwardRef(
|
|
7
|
+
({ title, open, defaultOpen = false, onOpenChange, children, className = "", ...rest }, ref) => {
|
|
8
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
9
|
+
const isOpen = open ?? uncontrolledOpen;
|
|
10
|
+
const [settled, setSettled] = useState(isOpen);
|
|
11
|
+
const baseId = React.useId();
|
|
12
|
+
const panelId = `${baseId}-panel`;
|
|
13
|
+
const headerId = `${baseId}-header`;
|
|
14
|
+
const toggle = () => {
|
|
15
|
+
const next = !isOpen;
|
|
16
|
+
setSettled(false);
|
|
17
|
+
if (open === void 0) setUncontrolledOpen(next);
|
|
18
|
+
onOpenChange?.(next);
|
|
19
|
+
};
|
|
20
|
+
const classes = [
|
|
21
|
+
"ds-inspector-section",
|
|
22
|
+
isOpen ? "ds-inspector-section--open" : "",
|
|
23
|
+
isOpen && settled ? "ds-inspector-section--settled" : "",
|
|
24
|
+
className
|
|
25
|
+
].filter(Boolean).join(" ");
|
|
26
|
+
return /* @__PURE__ */ jsxs("section", { ...rest, ref, className: classes, children: [
|
|
27
|
+
/* @__PURE__ */ jsxs(
|
|
28
|
+
"button",
|
|
29
|
+
{
|
|
30
|
+
type: "button",
|
|
31
|
+
id: headerId,
|
|
32
|
+
className: "ds-inspector-section__trigger",
|
|
33
|
+
"aria-expanded": isOpen,
|
|
34
|
+
"aria-controls": panelId,
|
|
35
|
+
onClick: toggle,
|
|
36
|
+
children: [
|
|
37
|
+
/* @__PURE__ */ jsx("span", { children: title }),
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
"span",
|
|
40
|
+
{
|
|
41
|
+
className: "ds-inspector-section__icon material-symbols-rounded",
|
|
42
|
+
"aria-hidden": "true",
|
|
43
|
+
children: "expand_more"
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
/* @__PURE__ */ jsx(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
id: panelId,
|
|
53
|
+
role: "region",
|
|
54
|
+
"aria-labelledby": headerId,
|
|
55
|
+
className: "ds-inspector-section__panel",
|
|
56
|
+
inert: !isOpen,
|
|
57
|
+
onTransitionEnd: (event) => {
|
|
58
|
+
if (event.target !== event.currentTarget) return;
|
|
59
|
+
if (isOpen) setSettled(true);
|
|
60
|
+
},
|
|
61
|
+
children: /* @__PURE__ */ jsx("div", { className: "ds-inspector-section__body", children })
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] });
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
InspectorSection.displayName = "InspectorSection";
|
|
68
|
+
export {
|
|
69
|
+
InspectorSection
|
|
70
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** One choice in an InspectorSegmentedControl. */
|
|
3
|
+
export interface InspectorSegment {
|
|
4
|
+
/** The value reported when this segment is chosen. */
|
|
5
|
+
value: string;
|
|
6
|
+
/** Visible text. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Takes this one choice out of the set. */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Props owned by InspectorSegmentedControl itself — everything else falls through to the radiogroup. */
|
|
12
|
+
type InspectorSegmentedControlOwnProps = {
|
|
13
|
+
/** The setting's name, drawn inside the bar on the left. Names the radiogroup. */
|
|
14
|
+
label: string;
|
|
15
|
+
/** The choices, drawn left to right in the bar's end. */
|
|
16
|
+
options: InspectorSegment[];
|
|
17
|
+
/** The selected value (controlled). Leave unset and use `defaultValue` for an uncontrolled set. */
|
|
18
|
+
value?: string;
|
|
19
|
+
/** The starting selection for an uncontrolled set. */
|
|
20
|
+
defaultValue?: string;
|
|
21
|
+
/** The radios' shared `name`, for native form submission. Generated when unset. */
|
|
22
|
+
name?: string;
|
|
23
|
+
/** Takes the whole set out of use. */
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/** Component size, matching Button: `default` is 40px tall, `compact` 32px. */
|
|
26
|
+
size?: 'default' | 'compact';
|
|
27
|
+
/** Called with the newly chosen value. */
|
|
28
|
+
onValueChange?: (value: string) => void;
|
|
29
|
+
/** Additional CSS classes, applied to the bar. */
|
|
30
|
+
className?: string;
|
|
31
|
+
};
|
|
32
|
+
export interface InspectorSegmentedControlProps extends InspectorSegmentedControlOwnProps, Omit<React.ComponentPropsWithoutRef<'div'>, keyof InspectorSegmentedControlOwnProps> {
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A one-row choice of a few options for inspector panels: the name on the
|
|
36
|
+
* left, the options as chips on the right. The selected chip takes a
|
|
37
|
+
* neutral fill, never the action colour. The form-and-toolbar counterpart,
|
|
38
|
+
* a free-standing pill strip, is SegmentedControl.
|
|
39
|
+
*
|
|
40
|
+
* Each option is a native radio, so arrow keys move the selection, the set
|
|
41
|
+
* announces as one radiogroup, and it submits with a form. A native
|
|
42
|
+
* `onChange` on the root receives each radio's bubbled change event.
|
|
43
|
+
* Forwards a ref to the root and spreads unrecognised props onto it.
|
|
44
|
+
*/
|
|
45
|
+
export declare const InspectorSegmentedControl: React.ForwardRefExoticComponent<InspectorSegmentedControlProps & React.RefAttributes<HTMLDivElement>>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import "./Inspector.css";
|
|
5
|
+
const InspectorSegmentedControl = React.forwardRef(
|
|
6
|
+
({
|
|
7
|
+
label,
|
|
8
|
+
options,
|
|
9
|
+
value,
|
|
10
|
+
defaultValue,
|
|
11
|
+
name,
|
|
12
|
+
disabled = false,
|
|
13
|
+
size = "default",
|
|
14
|
+
onValueChange,
|
|
15
|
+
className = "",
|
|
16
|
+
...rest
|
|
17
|
+
}, ref) => {
|
|
18
|
+
const generatedId = React.useId();
|
|
19
|
+
const groupName = name ?? generatedId;
|
|
20
|
+
const labelId = `${generatedId}-label`;
|
|
21
|
+
const classes = [
|
|
22
|
+
"ds-inspector-bar",
|
|
23
|
+
"ds-inspector-segmented-control",
|
|
24
|
+
size === "compact" ? "ds-inspector-bar--compact" : "",
|
|
25
|
+
disabled ? "ds-inspector-bar--disabled" : "",
|
|
26
|
+
className
|
|
27
|
+
].filter(Boolean).join(" ");
|
|
28
|
+
return /* @__PURE__ */ jsxs(
|
|
29
|
+
"div",
|
|
30
|
+
{
|
|
31
|
+
"aria-labelledby": labelId,
|
|
32
|
+
...rest,
|
|
33
|
+
ref,
|
|
34
|
+
className: classes,
|
|
35
|
+
role: "radiogroup",
|
|
36
|
+
"aria-disabled": disabled || void 0,
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ jsx("span", { id: labelId, className: "ds-inspector-bar__label", children: label }),
|
|
39
|
+
/* @__PURE__ */ jsx("span", { className: "ds-inspector-segmented-control__segments", children: options.map((option) => /* @__PURE__ */ jsxs("label", { className: "ds-inspector-segmented-control__segment", children: [
|
|
40
|
+
/* @__PURE__ */ jsx(
|
|
41
|
+
"input",
|
|
42
|
+
{
|
|
43
|
+
className: "ds-inspector-segmented-control__radio",
|
|
44
|
+
type: "radio",
|
|
45
|
+
name: groupName,
|
|
46
|
+
value: option.value,
|
|
47
|
+
disabled: disabled || option.disabled,
|
|
48
|
+
...value !== void 0 ? { checked: option.value === value } : { defaultChecked: option.value === defaultValue },
|
|
49
|
+
onChange: () => onValueChange?.(option.value)
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
option.label
|
|
53
|
+
] }, option.value)) })
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
InspectorSegmentedControl.displayName = "InspectorSegmentedControl";
|
|
60
|
+
export {
|
|
61
|
+
InspectorSegmentedControl
|
|
62
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** Props owned by InspectorSlider itself — everything else falls through to the <input type="range">. */
|
|
3
|
+
type InspectorSliderOwnProps = {
|
|
4
|
+
/** The setting's name, drawn inside the bar on the left. Also the range's accessible name. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Current value (controlled). Leave unset and use `defaultValue` for an uncontrolled slider. */
|
|
7
|
+
value?: number;
|
|
8
|
+
/** Starting value for an uncontrolled slider. Defaults to `min`. */
|
|
9
|
+
defaultValue?: number;
|
|
10
|
+
/** Minimum value. */
|
|
11
|
+
min?: number;
|
|
12
|
+
/** Maximum value. */
|
|
13
|
+
max?: number;
|
|
14
|
+
/** Step increment. Also sets how many decimals the reading shows (0.02 reads "0.50"). */
|
|
15
|
+
step?: number;
|
|
16
|
+
/** Formats the reading on the right, and the value a screen reader announces. Defaults to the step's precision. */
|
|
17
|
+
format?: (value: number) => string;
|
|
18
|
+
/** Component size, matching Button: `default` is 40px tall, `compact` 32px (not the native character-width `size` attribute). */
|
|
19
|
+
size?: 'default' | 'compact';
|
|
20
|
+
/**
|
|
21
|
+
* Convenience callback receiving the numeric value directly.
|
|
22
|
+
* Fires alongside `onChange`, which keeps the standard React event signature.
|
|
23
|
+
*/
|
|
24
|
+
onValueChange?: (value: number) => void;
|
|
25
|
+
/** Additional CSS classes, applied to the bar rather than the <input>. */
|
|
26
|
+
className?: string;
|
|
27
|
+
};
|
|
28
|
+
export interface InspectorSliderProps extends InspectorSliderOwnProps, Omit<React.ComponentPropsWithoutRef<'input'>, keyof InspectorSliderOwnProps | 'type'> {
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A one-row slider for inspector panels: the whole bar is the control, its
|
|
32
|
+
* fill is the value, and the name and reading sit inside it. The form
|
|
33
|
+
* counterpart, with a label above and a track, is Slider.
|
|
34
|
+
*
|
|
35
|
+
* A native range input covers the bar invisibly, so dragging anywhere,
|
|
36
|
+
* clicking to jump, the keyboard and the screen-reader semantics are the
|
|
37
|
+
* platform's. Forwards a ref to that input and spreads unrecognised props
|
|
38
|
+
* onto it.
|
|
39
|
+
*/
|
|
40
|
+
export declare const InspectorSlider: React.ForwardRefExoticComponent<InspectorSliderProps & React.RefAttributes<HTMLInputElement>>;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import React, { useState } from "react";
|
|
4
|
+
import "./Inspector.css";
|
|
5
|
+
const decimalsOf = (step) => {
|
|
6
|
+
const text = String(step);
|
|
7
|
+
const dot = text.indexOf(".");
|
|
8
|
+
return dot < 0 ? 0 : text.length - dot - 1;
|
|
9
|
+
};
|
|
10
|
+
const InspectorSlider = React.forwardRef(
|
|
11
|
+
({
|
|
12
|
+
label,
|
|
13
|
+
value,
|
|
14
|
+
defaultValue,
|
|
15
|
+
min = 0,
|
|
16
|
+
max = 100,
|
|
17
|
+
step = 1,
|
|
18
|
+
format,
|
|
19
|
+
size = "default",
|
|
20
|
+
disabled = false,
|
|
21
|
+
onChange,
|
|
22
|
+
onValueChange,
|
|
23
|
+
className = "",
|
|
24
|
+
id,
|
|
25
|
+
...rest
|
|
26
|
+
}, ref) => {
|
|
27
|
+
const generatedId = React.useId();
|
|
28
|
+
const inputId = id ?? generatedId;
|
|
29
|
+
const [uncontrolled, setUncontrolled] = useState(defaultValue ?? min);
|
|
30
|
+
const current = value ?? uncontrolled;
|
|
31
|
+
const pct = max === min ? 0 : (current - min) / (max - min) * 100;
|
|
32
|
+
const reading = format ? format(current) : current.toFixed(decimalsOf(step));
|
|
33
|
+
const classes = [
|
|
34
|
+
"ds-inspector-bar",
|
|
35
|
+
"ds-inspector-slider",
|
|
36
|
+
size === "compact" ? "ds-inspector-bar--compact" : "",
|
|
37
|
+
disabled ? "ds-inspector-bar--disabled" : "",
|
|
38
|
+
className
|
|
39
|
+
].filter(Boolean).join(" ");
|
|
40
|
+
const handleChange = (e) => {
|
|
41
|
+
const next = Number(e.target.value);
|
|
42
|
+
if (value === void 0) setUncontrolled(next);
|
|
43
|
+
onChange?.(e);
|
|
44
|
+
onValueChange?.(next);
|
|
45
|
+
};
|
|
46
|
+
return /* @__PURE__ */ jsxs(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
className: classes,
|
|
50
|
+
style: { "--ds-inspector-pct": `${pct}%` },
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ jsx("span", { className: "ds-inspector-slider__fill", "aria-hidden": "true" }),
|
|
53
|
+
/* @__PURE__ */ jsx("span", { className: "ds-inspector-slider__grip", "aria-hidden": "true" }),
|
|
54
|
+
/* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "ds-inspector-bar__label", children: label }),
|
|
55
|
+
/* @__PURE__ */ jsx("span", { className: "ds-inspector-bar__value", "aria-hidden": "true", children: reading }),
|
|
56
|
+
/* @__PURE__ */ jsx(
|
|
57
|
+
"input",
|
|
58
|
+
{
|
|
59
|
+
"aria-valuetext": reading,
|
|
60
|
+
...rest,
|
|
61
|
+
ref,
|
|
62
|
+
id: inputId,
|
|
63
|
+
className: "ds-inspector-bar__native",
|
|
64
|
+
type: "range",
|
|
65
|
+
min,
|
|
66
|
+
max,
|
|
67
|
+
step,
|
|
68
|
+
value: current,
|
|
69
|
+
disabled,
|
|
70
|
+
onChange: handleChange
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
InspectorSlider.displayName = "InspectorSlider";
|
|
79
|
+
export {
|
|
80
|
+
InspectorSlider
|
|
81
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/** Props owned by InspectorToggleSwitch itself — everything else falls through to the <input type="checkbox">. */
|
|
3
|
+
type InspectorToggleSwitchOwnProps = {
|
|
4
|
+
/** The setting's name, drawn inside the bar on the left. Also the switch's accessible name. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Component size, matching Button: `default` is 40px tall, `compact` 32px (not the native character-width `size` attribute). */
|
|
7
|
+
size?: 'default' | 'compact';
|
|
8
|
+
/**
|
|
9
|
+
* Convenience callback receiving the checked state directly.
|
|
10
|
+
* Fires alongside `onChange`, which keeps the standard React event signature.
|
|
11
|
+
*/
|
|
12
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
13
|
+
/** Additional CSS classes, applied to the bar rather than the <input>. */
|
|
14
|
+
className?: string;
|
|
15
|
+
};
|
|
16
|
+
export interface InspectorToggleSwitchProps extends InspectorToggleSwitchOwnProps, Omit<React.ComponentPropsWithoutRef<'input'>, keyof InspectorToggleSwitchOwnProps | 'type'> {
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A one-row switch for inspector panels: the whole bar is the switch, with
|
|
20
|
+
* the name on the left and a small track on the right. The form
|
|
21
|
+
* counterpart, a standalone switch with its label beside it, is
|
|
22
|
+
* ToggleSwitch.
|
|
23
|
+
*
|
|
24
|
+
* A native checkbox with `role="switch"` covers the bar, and the paint
|
|
25
|
+
* reads its `:checked` state, so `checked` and `defaultChecked` both work.
|
|
26
|
+
* Forwards a ref to that input and spreads unrecognised props onto it.
|
|
27
|
+
*/
|
|
28
|
+
export declare const InspectorToggleSwitch: React.ForwardRefExoticComponent<InspectorToggleSwitchProps & React.RefAttributes<HTMLInputElement>>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import "./Inspector.css";
|
|
5
|
+
const InspectorToggleSwitch = React.forwardRef(
|
|
6
|
+
({
|
|
7
|
+
label,
|
|
8
|
+
size = "default",
|
|
9
|
+
disabled = false,
|
|
10
|
+
onChange,
|
|
11
|
+
onCheckedChange,
|
|
12
|
+
className = "",
|
|
13
|
+
id,
|
|
14
|
+
...rest
|
|
15
|
+
}, ref) => {
|
|
16
|
+
const generatedId = React.useId();
|
|
17
|
+
const inputId = id ?? generatedId;
|
|
18
|
+
const classes = [
|
|
19
|
+
"ds-inspector-bar",
|
|
20
|
+
"ds-inspector-toggle-switch",
|
|
21
|
+
size === "compact" ? "ds-inspector-bar--compact" : "",
|
|
22
|
+
disabled ? "ds-inspector-bar--disabled" : "",
|
|
23
|
+
className
|
|
24
|
+
].filter(Boolean).join(" ");
|
|
25
|
+
const handleChange = (e) => {
|
|
26
|
+
onChange?.(e);
|
|
27
|
+
onCheckedChange?.(e.target.checked);
|
|
28
|
+
};
|
|
29
|
+
return /* @__PURE__ */ jsxs("div", { className: classes, children: [
|
|
30
|
+
/* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "ds-inspector-bar__label", children: label }),
|
|
31
|
+
/* @__PURE__ */ jsx("span", { className: "ds-inspector-toggle-switch__track", "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: "ds-inspector-toggle-switch__knob" }) }),
|
|
32
|
+
/* @__PURE__ */ jsx(
|
|
33
|
+
"input",
|
|
34
|
+
{
|
|
35
|
+
...rest,
|
|
36
|
+
ref,
|
|
37
|
+
id: inputId,
|
|
38
|
+
className: "ds-inspector-bar__native",
|
|
39
|
+
type: "checkbox",
|
|
40
|
+
role: "switch",
|
|
41
|
+
disabled,
|
|
42
|
+
onChange: handleChange
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
] });
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
InspectorToggleSwitch.displayName = "InspectorToggleSwitch";
|
|
49
|
+
export {
|
|
50
|
+
InspectorToggleSwitch
|
|
51
|
+
};
|
package/components/Nav/Nav.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { ButtonGroupProps } from '../ButtonGroup/ButtonGroup';
|
|
3
|
-
|
|
3
|
+
/** Props owned by Nav itself — everything else falls through to the `<nav>`. */
|
|
4
|
+
type NavOwnProps = {
|
|
4
5
|
/** Brand/logo text */
|
|
5
6
|
brandText?: string;
|
|
6
7
|
/** Brand icon element (img, svg, etc.) */
|
|
@@ -11,9 +12,16 @@ export interface NavProps {
|
|
|
11
12
|
trailing?: React.ReactNode;
|
|
12
13
|
/** Additional CSS classes */
|
|
13
14
|
className?: string;
|
|
15
|
+
};
|
|
16
|
+
export interface NavProps extends NavOwnProps, Omit<React.ComponentPropsWithoutRef<'nav'>, keyof NavOwnProps> {
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* Nav component from Figma design system
|
|
17
|
-
* Renders a horizontal navigation bar using ButtonGroup
|
|
20
|
+
* Renders a horizontal navigation bar using ButtonGroup.
|
|
21
|
+
*
|
|
22
|
+
* The landmark is labelled "Main" by default so assistive tech can tell it
|
|
23
|
+
* apart from any other navigation on the page; pass `aria-label` to name it
|
|
24
|
+
* differently. Unrecognised props are spread onto the `<nav>`.
|
|
18
25
|
*/
|
|
19
|
-
export declare const Nav: ({ brandText, brandIcon, buttons, trailing, className, }: NavProps) => React.JSX.Element;
|
|
26
|
+
export declare const Nav: ({ brandText, brandIcon, buttons, trailing, className, ...rest }: NavProps) => React.JSX.Element;
|
|
27
|
+
export {};
|
package/components/Nav/Nav.js
CHANGED
|
@@ -7,10 +7,11 @@ const Nav = ({
|
|
|
7
7
|
brandIcon,
|
|
8
8
|
buttons,
|
|
9
9
|
trailing,
|
|
10
|
-
className = ""
|
|
10
|
+
className = "",
|
|
11
|
+
...rest
|
|
11
12
|
}) => {
|
|
12
13
|
const baseClass = "ds-nav";
|
|
13
|
-
return /* @__PURE__ */ jsxs("nav", { className: `${baseClass} ${className}`, children: [
|
|
14
|
+
return /* @__PURE__ */ jsxs("nav", { "aria-label": "Main", ...rest, className: `${baseClass} ${className}`, children: [
|
|
14
15
|
(brandText || brandIcon) && /* @__PURE__ */ jsxs("div", { className: `${baseClass}__brand`, children: [
|
|
15
16
|
brandIcon && /* @__PURE__ */ jsx("span", { className: `${baseClass}__brand-icon`, children: brandIcon }),
|
|
16
17
|
brandText && /* @__PURE__ */ jsx("span", { className: `${baseClass}__brand-text`, children: brandText })
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
gap: var(--gap-050); /* 2px */
|
|
11
11
|
padding: var(--padding-100); /* 4px */
|
|
12
12
|
/* Concentric with the segments, the Composer's rule: the track's
|
|
13
|
-
curve is the segment's radius plus the inset between them
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
curve is the segment's radius plus the inset between them (the
|
|
14
|
+
padding and the hairline both, since the curve is drawn at the
|
|
15
|
+
border's outer edge), so a theme that squares the pill token keeps
|
|
16
|
+
the two curves parallel instead of a soft track hugging sharp
|
|
17
|
+
segments. At the shipped 999px pill every term saturates and nothing
|
|
18
|
+
changes. */
|
|
19
|
+
border-radius: calc(var(--radius-pill) + var(--padding-100) + var(--border-025));
|
|
18
20
|
background-color: var(--color-bg-container-primary);
|
|
19
21
|
border: var(--border-025) solid var(--color-bg-container-border);
|
|
20
22
|
}
|