rl-react-components 2.9.0 → 3.0.2

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/README.md CHANGED
@@ -89,17 +89,17 @@ override any of them in its own CSS.
89
89
 
90
90
  ## What is inside
91
91
 
92
- | Group | Components and hooks |
93
- | -------------- | --------------------------------------------------------------------- |
94
- | Foundations | `Text`, `Icon` |
95
- | Layout | `Container`, `Section`, `PageHero`, `PageTransition` |
96
- | Navigation | `SideNav` |
97
- | Forms | `Button`, `IconButton`, `TextInput`, `TextArea`, `Select`, `Checkbox` |
98
- | Tags | `Tag`, `TagFilter`, `TagGroup` |
99
- | Content | `Card`, `Accordion`, `Markdown`, `MarkdownEditor`, `ShimmerImage` |
100
- | Feedback | `ToastProvider`, `useToast` |
101
- | Canvas effects | `MatrixContainer`, `OrbitalDots` |
102
- | Hooks | `useDragReorder`, `useRotatingMessage` |
92
+ | Group | Components and hooks |
93
+ | -------------- | ------------------------------------------------------------------------------------------------------------- |
94
+ | Foundations | `Text`, `Icon` |
95
+ | Layout | `Container`, `Section`, `PageHero`, `PageTransition` |
96
+ | Navigation | `SideNav`, `Tabs` |
97
+ | Forms | `Button`, `IconButton`, `TextInput`, `TextArea`, `Select`, `Checkbox`, `Switch`, `SegmentedControl`, `Slider` |
98
+ | Tags | `Tag`, `TagFilter`, `TagGroup`, `LevelChip` |
99
+ | Content | `Card`, `Accordion`, `Markdown`, `MarkdownEditor`, `ShimmerImage` |
100
+ | Feedback | `ToastProvider`, `useToast` |
101
+ | Canvas effects | `MatrixContainer`, `OrbitalDots` |
102
+ | Hooks | `useDragReorder`, `useRotatingMessage` |
103
103
 
104
104
  ## Documentation
105
105
 
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ export interface LevelChipProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'children'> {
3
+ /** What the level is of, such as "React". */
4
+ label: string;
5
+ /** How many dots are filled, from 0 to `max`. */
6
+ level: number;
7
+ /** How many dots there are. Default: 5. */
8
+ max?: number;
9
+ /** What screen readers read for the dots, and their tooltip, such as "Level 4 of 5". */
10
+ levelLabel: string;
11
+ }
12
+ /** A small chip with a name and its level in dots, such as a skill and how well it is known. */
13
+ export default function LevelChip({ label, level, max, levelLabel, className, ...props }: LevelChipProps): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from './LevelChip';
2
+ export type { LevelChipProps } from './LevelChip';
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ export interface SegmentedControlOption {
3
+ value: string;
4
+ label: React.ReactNode;
5
+ /** The label's language where it differs from the page's, as in a language's own name. */
6
+ lang?: string;
7
+ }
8
+ export interface SegmentedControlProps {
9
+ /** Shown above the options. It names the group. */
10
+ label: string;
11
+ /** Keeps the label for screen readers only. */
12
+ hideLabel?: boolean;
13
+ /** The options, in order. Two to five short ones fit best. */
14
+ options: SegmentedControlOption[];
15
+ /** The picked option's value. Give it with `onChange` to keep the pick in the app. */
16
+ value?: string;
17
+ /** The option picked at first when `value` is not given. */
18
+ defaultValue?: string;
19
+ /** Called with the value of each option the visitor picks. */
20
+ onChange?: (value: string) => void;
21
+ /** The field's name in a form. Without one, the control makes a name of its own. */
22
+ name?: string;
23
+ disabled?: boolean;
24
+ className?: string;
25
+ }
26
+ /** Picks exactly one of a few options, drawn as the parts of one control. */
27
+ export default function SegmentedControl({ label, hideLabel, options, value, defaultValue, onChange, name, disabled, className, }: SegmentedControlProps): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from './SegmentedControl';
2
+ export type { SegmentedControlOption, SegmentedControlProps } from './SegmentedControl';
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'defaultValue' | 'min' | 'max' | 'step' | 'children'> {
3
+ /** Names the slider, and shows above it. */
4
+ label: string;
5
+ /** Keeps the label for screen readers only. */
6
+ hideLabel?: boolean;
7
+ /** The picked number. Give it with `onChange` to keep it in the app. */
8
+ value?: number;
9
+ /** The number picked at first when `value` is not given. Default: halfway. */
10
+ defaultValue?: number;
11
+ /** Default: 0. */
12
+ min?: number;
13
+ /** Default: 100. */
14
+ max?: number;
15
+ /** The distance between the numbers that can be picked, from `min`. Default: 1. */
16
+ step?: number;
17
+ /** Writes a value as text, such as "12 posts": shown, and read by screen readers. */
18
+ formatValue?: (value: number) => string;
19
+ /** Shows the value beside the label. Default: true. */
20
+ showValue?: boolean;
21
+ /** Numbers printed under the track, each where the thumb sits when it is picked. */
22
+ marks?: number[];
23
+ /** A line under the slider that describes it. */
24
+ hint?: string;
25
+ ref?: React.Ref<HTMLInputElement>;
26
+ }
27
+ /** Picks a number from a range, by dragging a thumb or with the arrow keys. */
28
+ export default function Slider({ label, hideLabel, value, defaultValue, min, max, step, formatValue, showValue, marks, hint, className, id, style, onChange, ref, 'aria-describedby': ariaDescribedBy, 'aria-valuetext': ariaValueText, ...props }: SliderProps): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from './Slider';
2
+ export type { SliderProps } from './Slider';
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export interface SwitchProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'role' | 'children'> {
3
+ /** Names the switch, and shows beside it. */
4
+ label: string;
5
+ /** Keeps the label for screen readers only, where the page already says what it switches. */
6
+ hideLabel?: boolean;
7
+ }
8
+ /** Turns one thing on or off, at once. For a choice sent with a form, use a Checkbox. */
9
+ export default function Switch({ label, hideLabel, className, ...props }: SwitchProps): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from './Switch';
2
+ export type { SwitchProps } from './Switch';
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ export interface TabItem {
3
+ /** Tells the tabs apart, in `activeId` and `onChange`. */
4
+ id: string;
5
+ /** The tab's text. */
6
+ label: React.ReactNode;
7
+ /** Shown before the label. Decorative: hidden from screen readers. */
8
+ icon?: React.ReactNode;
9
+ /** What the tab's panel holds. Only the selected tab's content is rendered. */
10
+ content: React.ReactNode;
11
+ }
12
+ export interface TabsProps {
13
+ /** Names the row of tabs for screen readers, such as "Curriculum sections". */
14
+ label: string;
15
+ /** The tabs and their panels, in order. */
16
+ items: TabItem[];
17
+ /** The selected tab's id. Give it with `onChange` to keep the selection in the app. */
18
+ activeId?: string;
19
+ /** The tab selected at first when `activeId` is not given. Default: the first. */
20
+ defaultActiveId?: string;
21
+ /** Called with the id of each tab the visitor picks. */
22
+ onChange?: (id: string) => void;
23
+ className?: string;
24
+ }
25
+ /** A row of tabs, one of them selected, with that tab's panel under the row. */
26
+ export default function Tabs({ label, items, activeId, defaultActiveId, onChange, className, }: TabsProps): React.JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from './Tabs';
2
+ export type { TabItem, TabsProps } from './Tabs';
package/dist/index.d.ts CHANGED
@@ -12,6 +12,8 @@ export { default as Icon, ICON_NAMES } from './components/Icon';
12
12
  export type { IconName, IconProps } from './components/Icon';
13
13
  export { default as IconButton } from './components/IconButton';
14
14
  export type { IconButtonProps } from './components/IconButton';
15
+ export { default as LevelChip } from './components/LevelChip';
16
+ export type { LevelChipProps } from './components/LevelChip';
15
17
  export { default as Markdown } from './components/Markdown';
16
18
  export type { MarkdownProps } from './components/Markdown';
17
19
  export { default as MarkdownEditor } from './components/MarkdownEditor';
@@ -26,12 +28,20 @@ export { default as PageTransition } from './components/PageTransition';
26
28
  export type { PageTransitionProps } from './components/PageTransition';
27
29
  export { default as Section } from './components/Section';
28
30
  export type { SectionProps } from './components/Section';
31
+ export { default as SegmentedControl } from './components/SegmentedControl';
32
+ export type { SegmentedControlOption, SegmentedControlProps } from './components/SegmentedControl';
29
33
  export { default as Select } from './components/Select';
30
34
  export type { SelectProps } from './components/Select';
31
35
  export { default as ShimmerImage } from './components/ShimmerImage';
32
36
  export type { ShimmerImageProps } from './components/ShimmerImage';
33
37
  export { default as SideNav } from './components/SideNav';
34
38
  export type { SideNavGroup, SideNavItem, SideNavProps } from './components/SideNav';
39
+ export { default as Slider } from './components/Slider';
40
+ export type { SliderProps } from './components/Slider';
41
+ export { default as Switch } from './components/Switch';
42
+ export type { SwitchProps } from './components/Switch';
43
+ export { default as Tabs } from './components/Tabs';
44
+ export type { TabItem, TabsProps } from './components/Tabs';
35
45
  export { default as Tag } from './components/Tag';
36
46
  export type { TagProps } from './components/Tag';
37
47
  export { default as TagFilter } from './components/TagFilter';