@jig-ui/react 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.
- package/LICENSE +52 -0
- package/README.md +193 -0
- package/dist/adorn/adorn.d.ts +38 -0
- package/dist/adorn/index.d.ts +2 -0
- package/dist/box/box.d.ts +32 -0
- package/dist/box/index.d.ts +2 -0
- package/dist/breakpoints.d.ts +35 -0
- package/dist/button/button.d.ts +37 -0
- package/dist/button/index.d.ts +2 -0
- package/dist/codeblock/codeblock.d.ts +28 -0
- package/dist/codeblock/index.d.ts +2 -0
- package/dist/collapsible/collapsible.d.ts +116 -0
- package/dist/collapsible/index.d.ts +2 -0
- package/dist/combobox/combobox.d.ts +119 -0
- package/dist/combobox/index.d.ts +2 -0
- package/dist/dev.d.ts +14 -0
- package/dist/dialog/dialog.d.ts +80 -0
- package/dist/dialog/index.d.ts +2 -0
- package/dist/focus-ring.d.ts +15 -0
- package/dist/grid/grid.d.ts +54 -0
- package/dist/grid/index.d.ts +2 -0
- package/dist/icon/generated/arrow-down.d.ts +4 -0
- package/dist/icon/generated/arrow-left.d.ts +4 -0
- package/dist/icon/generated/arrow-right.d.ts +4 -0
- package/dist/icon/generated/arrow-square-out.d.ts +4 -0
- package/dist/icon/generated/arrow-up.d.ts +4 -0
- package/dist/icon/generated/bell.d.ts +4 -0
- package/dist/icon/generated/calendar.d.ts +4 -0
- package/dist/icon/generated/caret-down.d.ts +4 -0
- package/dist/icon/generated/caret-left.d.ts +4 -0
- package/dist/icon/generated/caret-right.d.ts +4 -0
- package/dist/icon/generated/caret-up.d.ts +4 -0
- package/dist/icon/generated/check-circle.d.ts +4 -0
- package/dist/icon/generated/check.d.ts +4 -0
- package/dist/icon/generated/clock.d.ts +4 -0
- package/dist/icon/generated/copy.d.ts +4 -0
- package/dist/icon/generated/dots-nine.d.ts +4 -0
- package/dist/icon/generated/dots-three.d.ts +4 -0
- package/dist/icon/generated/eye-slash.d.ts +4 -0
- package/dist/icon/generated/eye.d.ts +4 -0
- package/dist/icon/generated/gear.d.ts +4 -0
- package/dist/icon/generated/github-logo.d.ts +4 -0
- package/dist/icon/generated/heart.d.ts +4 -0
- package/dist/icon/generated/index.d.ts +151 -0
- package/dist/icon/generated/info.d.ts +4 -0
- package/dist/icon/generated/list.d.ts +4 -0
- package/dist/icon/generated/magnifying-glass.d.ts +4 -0
- package/dist/icon/generated/minus.d.ts +4 -0
- package/dist/icon/generated/moon.d.ts +4 -0
- package/dist/icon/generated/pencil-simple.d.ts +4 -0
- package/dist/icon/generated/plus.d.ts +4 -0
- package/dist/icon/generated/question.d.ts +4 -0
- package/dist/icon/generated/star.d.ts +4 -0
- package/dist/icon/generated/sun.d.ts +4 -0
- package/dist/icon/generated/trash.d.ts +4 -0
- package/dist/icon/generated/user.d.ts +4 -0
- package/dist/icon/generated/warning-circle.d.ts +4 -0
- package/dist/icon/generated/warning.d.ts +4 -0
- package/dist/icon/generated/x.d.ts +4 -0
- package/dist/icon/icon.d.ts +46 -0
- package/dist/icon/index.d.ts +2 -0
- package/dist/icon-BRHwInc5.js +165 -0
- package/dist/icon-B_NrwKaL.js +173 -0
- package/dist/iconbutton/iconbutton.d.ts +35 -0
- package/dist/iconbutton/index.d.ts +2 -0
- package/dist/icons.d.ts +17 -0
- package/dist/icons.js +2 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +3061 -0
- package/dist/input/index.d.ts +2 -0
- package/dist/input/input.d.ts +63 -0
- package/dist/layout.d.ts +87 -0
- package/dist/link/index.d.ts +2 -0
- package/dist/link/link.d.ts +125 -0
- package/dist/listitem/index.d.ts +2 -0
- package/dist/listitem/listitem.d.ts +92 -0
- package/dist/polymorphic.d.ts +31 -0
- package/dist/reset.css +4 -0
- package/dist/responsive.d.ts +10 -0
- package/dist/scrollarea/index.d.ts +2 -0
- package/dist/scrollarea/scrollarea.d.ts +26 -0
- package/dist/separator/index.d.ts +2 -0
- package/dist/separator/separator.d.ts +48 -0
- package/dist/sidenav/index.d.ts +2 -0
- package/dist/sidenav/sidenav.d.ts +35 -0
- package/dist/sidenavsection/index.d.ts +2 -0
- package/dist/sidenavsection/sidenavsection.d.ts +44 -0
- package/dist/slider/index.d.ts +2 -0
- package/dist/slider/slider.d.ts +73 -0
- package/dist/spacing.d.ts +35 -0
- package/dist/stack/index.d.ts +2 -0
- package/dist/stack/stack.d.ts +52 -0
- package/dist/structuredlist/index.d.ts +2 -0
- package/dist/structuredlist/structuredlist.d.ts +104 -0
- package/dist/styles.css +911 -0
- package/dist/togglebutton/index.d.ts +2 -0
- package/dist/togglebutton/togglebutton.d.ts +93 -0
- package/dist/togglebuttongroup/index.d.ts +2 -0
- package/dist/togglebuttongroup/togglebuttongroup.d.ts +72 -0
- package/dist/token/index.d.ts +2 -0
- package/dist/token/token.d.ts +82 -0
- package/dist/tokens-vars.d.ts +579 -0
- package/dist/tokens.d.ts +24 -0
- package/dist/tokens.js +577 -0
- package/dist/tooltip/index.d.ts +2 -0
- package/dist/tooltip/tooltip.d.ts +52 -0
- package/dist/typography/index.d.ts +2 -0
- package/dist/typography/typography.d.ts +71 -0
- package/package.json +81 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { IconName } from '../icon';
|
|
3
|
+
type ToggleButtonSize = 'sm' | 'md' | 'lg';
|
|
4
|
+
/**
|
|
5
|
+
* What a handler receives alongside the new pressed state.
|
|
6
|
+
*
|
|
7
|
+
* Declared here rather than re-exported from Base UI: 0001 settled that
|
|
8
|
+
* consumers import from `@jig-ui/react` and should not need to know Base UI
|
|
9
|
+
* exists. This is the subset of its change details that is useful to call —
|
|
10
|
+
* the object passed at runtime carries more, and passing it through unchanged
|
|
11
|
+
* is what makes the cancellation reach Base UI.
|
|
12
|
+
*/
|
|
13
|
+
export interface ToggleChangeDetails {
|
|
14
|
+
/**
|
|
15
|
+
* Cancels the change. The button does not move, and inside a
|
|
16
|
+
* `ToggleButtonGroup` the group's value is not committed either.
|
|
17
|
+
*/
|
|
18
|
+
cancel: () => void;
|
|
19
|
+
/** The native event behind the change. */
|
|
20
|
+
readonly event: Event;
|
|
21
|
+
/** Whether something has already cancelled this change. */
|
|
22
|
+
readonly isCanceled: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface ToggleButtonBaseProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'aria-pressed' | 'aria-label' | 'value'> {
|
|
25
|
+
size?: ToggleButtonSize;
|
|
26
|
+
/** Controlled pressed state. Leave undefined to let the button manage its own. */
|
|
27
|
+
pressed?: boolean;
|
|
28
|
+
defaultPressed?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Fires before the change is applied. Call `details.cancel()` to veto it.
|
|
31
|
+
*
|
|
32
|
+
* This replaced an earlier contract where an `onClick` handler calling
|
|
33
|
+
* `preventDefault()` cancelled the toggle. Base UI does not read
|
|
34
|
+
* `defaultPrevented`, and only this route can also veto a group's value
|
|
35
|
+
* commit. See apps/docs/decisions/0005-toggle-button-group.html (D2).
|
|
36
|
+
*/
|
|
37
|
+
onPressedChange?: (pressed: boolean, details: ToggleChangeDetails) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Identifies this button within a `ToggleButtonGroup`. Required in practice
|
|
40
|
+
* when nested in one — the type cannot express "only when nested", so Base
|
|
41
|
+
* UI logs a development error if it is missing.
|
|
42
|
+
*/
|
|
43
|
+
value?: string;
|
|
44
|
+
/** Shown while unpressed, at the regular weight. */
|
|
45
|
+
icon?: IconName;
|
|
46
|
+
/**
|
|
47
|
+
* Swapped in while pressed. Defaults to `icon`, and either way the pressed
|
|
48
|
+
* state renders at the `fill` weight — which is what fill is for.
|
|
49
|
+
*/
|
|
50
|
+
pressedIcon?: IconName;
|
|
51
|
+
/** Which side of the label the icon sits on. */
|
|
52
|
+
iconPosition?: 'start' | 'end';
|
|
53
|
+
ref?: Ref<HTMLButtonElement>;
|
|
54
|
+
}
|
|
55
|
+
export type ToggleButtonProps = ToggleButtonBaseProps & ({
|
|
56
|
+
/**
|
|
57
|
+
* Drops the label and takes IconButton's square padding, so the two
|
|
58
|
+
* sit together at matching dimensions.
|
|
59
|
+
*/
|
|
60
|
+
isIconOnly?: false;
|
|
61
|
+
/** Overrides the accessible name that the visible text would give. */
|
|
62
|
+
label?: string;
|
|
63
|
+
} | {
|
|
64
|
+
isIconOnly: true;
|
|
65
|
+
/**
|
|
66
|
+
* Required here: with no visible text there is nothing else to name
|
|
67
|
+
* the button for assistive technology.
|
|
68
|
+
*/
|
|
69
|
+
label: string;
|
|
70
|
+
/** Required here too — an icon-only toggle with no icon is an empty square. */
|
|
71
|
+
icon: IconName;
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* A button that stays pressed.
|
|
75
|
+
*
|
|
76
|
+
* Manages its own state by default; pass `pressed` and `onPressedChange` to
|
|
77
|
+
* control it. `onPressedChange` fires before the change is applied, so calling
|
|
78
|
+
* `details.cancel()` inside it vetoes the toggle.
|
|
79
|
+
*
|
|
80
|
+
* `icon` shows while unpressed and `pressedIcon` while pressed, defaulting to
|
|
81
|
+
* the same glyph — either way the pressed state renders at the `fill` weight.
|
|
82
|
+
*
|
|
83
|
+
* `isIconOnly` drops the label and takes square padding, matching `IconButton`;
|
|
84
|
+
* it requires both `label` and `icon`.
|
|
85
|
+
*
|
|
86
|
+
* Inside a `ToggleButtonGroup` the pressed state comes from the group instead,
|
|
87
|
+
* and each button needs a `value` identifying it.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* <ToggleButton icon="star" pressedIcon="star" isIconOnly label="Favourite" />
|
|
91
|
+
*/
|
|
92
|
+
export declare function ToggleButton({ size, pressed, defaultPressed, onPressedChange, value, icon, pressedIcon, iconPosition, isIconOnly, label, disabled, type, className, children, ref, ...props }: ToggleButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ReactNode, Ref } from 'react';
|
|
2
|
+
export interface ToggleButtonGroupProps<Value extends string = string> {
|
|
3
|
+
/**
|
|
4
|
+
* The pressed buttons, as an array of their `value`s — an array even when
|
|
5
|
+
* `multiple` is false, where it holds at most one. Controlled counterpart of
|
|
6
|
+
* `defaultValue`.
|
|
7
|
+
*/
|
|
8
|
+
value?: readonly Value[];
|
|
9
|
+
defaultValue?: readonly Value[];
|
|
10
|
+
/**
|
|
11
|
+
* Narrowed to the group's `Value` when one is inferred or given. Note this
|
|
12
|
+
* does *not* check each button's `value` prop — React children are opaque to
|
|
13
|
+
* a parent's type argument, so a mistyped item is a runtime mismatch either
|
|
14
|
+
* way.
|
|
15
|
+
*/
|
|
16
|
+
onValueChange?: (value: Value[]) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Allow more than one button pressed at a time. When false, pressing one
|
|
19
|
+
* releases the others.
|
|
20
|
+
*
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
multiple?: boolean;
|
|
24
|
+
/** Disables every button in the group, whatever their own `disabled` says. */
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Which arrow keys move focus, and the value reported to assistive
|
|
28
|
+
* technology.
|
|
29
|
+
*
|
|
30
|
+
* @default 'horizontal'
|
|
31
|
+
*/
|
|
32
|
+
orientation?: 'horizontal' | 'vertical';
|
|
33
|
+
/**
|
|
34
|
+
* Wrap focus from the last button back to the first.
|
|
35
|
+
*
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
loopFocus?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Names the group. A set of toggles is announced as a group, and an unnamed
|
|
41
|
+
* one tells a screen-reader user nothing about what it controls.
|
|
42
|
+
*/
|
|
43
|
+
'aria-label'?: string;
|
|
44
|
+
'aria-labelledby'?: string;
|
|
45
|
+
className?: string;
|
|
46
|
+
children?: ReactNode;
|
|
47
|
+
ref?: Ref<HTMLDivElement>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A set of `ToggleButton`s sharing one value, with arrow-key navigation between
|
|
51
|
+
* them and a single tab stop.
|
|
52
|
+
*
|
|
53
|
+
* The children are plain `ToggleButton`s — there is no separate item
|
|
54
|
+
* component — and each needs a `value` identifying it within the group.
|
|
55
|
+
*
|
|
56
|
+
* The group's value is an array. By default one button is pressed at a time;
|
|
57
|
+
* `multiple` allows several. Set `aria-label` or `aria-labelledby` to name the
|
|
58
|
+
* group, since it has no visible label of its own.
|
|
59
|
+
*
|
|
60
|
+
* `orientation` sets which arrow keys move focus, and `loopFocus` wraps from
|
|
61
|
+
* the last button to the first.
|
|
62
|
+
*
|
|
63
|
+
* Carries no visual treatment of its own: the buttons look as they do
|
|
64
|
+
* standalone, so wrap it in a `Stack` for spacing.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* <ToggleButtonGroup aria-label="Theme" value={theme} onValueChange={setTheme}>
|
|
68
|
+
* <ToggleButton value="light" isIconOnly icon="sun" label="Light" />
|
|
69
|
+
* <ToggleButton value="dark" isIconOnly icon="moon" label="Dark" />
|
|
70
|
+
* </ToggleButtonGroup>
|
|
71
|
+
*/
|
|
72
|
+
export declare function ToggleButtonGroup<Value extends string = string>({ value, defaultValue, onValueChange, multiple, disabled, orientation, loopFocus, className, children, ref, ...props }: ToggleButtonGroupProps<Value>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { AnchorHTMLAttributes, HTMLAttributes, MouseEvent, ReactNode, Ref } from 'react';
|
|
2
|
+
import { IconName } from '../icon';
|
|
3
|
+
/**
|
|
4
|
+
* The hues a Token can take, in ramp order.
|
|
5
|
+
*
|
|
6
|
+
* A Token's colour says what kind of thing it is, not how loud it is, so this
|
|
7
|
+
* names a hue rather than reusing Button's `primary | secondary | danger |
|
|
8
|
+
* ghost`. Decided in apps/docs/decisions/0006-token.html (D2). Kept in step
|
|
9
|
+
* with `TOKEN_HUES` in packages/tokens/src/utils.ts, which generates the
|
|
10
|
+
* matching `color.token.*` sets.
|
|
11
|
+
*/
|
|
12
|
+
export type TokenColor = 'warm' | 'cool' | 'blue' | 'teal' | 'green' | 'lime' | 'yellow' | 'orange' | 'red' | 'fuschia' | 'purple' | 'gray';
|
|
13
|
+
export type TokenSize = 'sm' | 'md' | 'lg';
|
|
14
|
+
/** What Token owns, whichever element it ends up rendering. */
|
|
15
|
+
interface TokenOwnProps {
|
|
16
|
+
/** The label. Truncates with an ellipsis; it never wraps. */
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
color?: TokenColor;
|
|
19
|
+
size?: TokenSize;
|
|
20
|
+
/**
|
|
21
|
+
* An icon from the curated set, sized and spaced by the Token rather than by
|
|
22
|
+
* the caller. Decorative — the label names the token.
|
|
23
|
+
*/
|
|
24
|
+
icon?: IconName;
|
|
25
|
+
/**
|
|
26
|
+
* Names the remove button for assistive technology. Derived as
|
|
27
|
+
* `Remove {children}` when the label is a string, so this is only needed
|
|
28
|
+
* when it is not — or when the derived name reads badly.
|
|
29
|
+
*/
|
|
30
|
+
removeLabel?: string;
|
|
31
|
+
}
|
|
32
|
+
/** Attributes React declares that Token decides for itself. */
|
|
33
|
+
type Reserved = keyof TokenOwnProps | 'color';
|
|
34
|
+
/**
|
|
35
|
+
* A link and nothing else: the whole pill is the `<a>`, because there is no
|
|
36
|
+
* second control that would have to nest inside it.
|
|
37
|
+
*/
|
|
38
|
+
type LinkTokenProps = TokenOwnProps & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, Reserved> & {
|
|
39
|
+
href: string;
|
|
40
|
+
onRemove?: never;
|
|
41
|
+
ref?: Ref<HTMLAnchorElement>;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Removable, with or without a link. A `<button>` may not sit inside an
|
|
45
|
+
* `<a>` — interactive content cannot nest — so the pill becomes a `<span>`
|
|
46
|
+
* container and the anchor, where there is one, shrinks to the label.
|
|
47
|
+
* Decided in 0006 D4.
|
|
48
|
+
*/
|
|
49
|
+
type RemovableTokenProps = TokenOwnProps & Omit<HTMLAttributes<HTMLSpanElement>, Reserved> & {
|
|
50
|
+
href?: string;
|
|
51
|
+
/** Renders the × button. */
|
|
52
|
+
onRemove: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
53
|
+
ref?: Ref<HTMLSpanElement>;
|
|
54
|
+
};
|
|
55
|
+
/** Neither: a plain rendered value. */
|
|
56
|
+
type PlainTokenProps = TokenOwnProps & Omit<HTMLAttributes<HTMLSpanElement>, Reserved> & {
|
|
57
|
+
href?: never;
|
|
58
|
+
onRemove?: never;
|
|
59
|
+
ref?: Ref<HTMLSpanElement>;
|
|
60
|
+
};
|
|
61
|
+
export type TokenProps = LinkTokenProps | RemovableTokenProps | PlainTokenProps;
|
|
62
|
+
/**
|
|
63
|
+
* A small labelled value — a chip. A filter, a tag, a selected entry in a
|
|
64
|
+
* multi-value field.
|
|
65
|
+
*
|
|
66
|
+
* `color` names a hue rather than an emphasis, because a token's colour says
|
|
67
|
+
* what kind of thing it is, not how important it is.
|
|
68
|
+
*
|
|
69
|
+
* Passing `onRemove` adds a remove button, whose accessible name is derived
|
|
70
|
+
* from the label; set `removeLabel` when the label is not a string. Passing
|
|
71
|
+
* `href` makes it a link. With both, the link shrinks to the label so the two
|
|
72
|
+
* controls stay separate.
|
|
73
|
+
*
|
|
74
|
+
* The label truncates with an ellipsis and never wraps — cap the width with
|
|
75
|
+
* `style` where that matters. Its height matches an `Input` of the same `size`,
|
|
76
|
+
* so it nests inside one cleanly.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* <Token color="teal" icon="user" onRemove={() => remove(person)}>{person.name}</Token>
|
|
80
|
+
*/
|
|
81
|
+
export declare function Token({ color, size, icon, href, onRemove, removeLabel, className, children, ref, ...props }: TokenProps): import("react/jsx-runtime").JSX.Element;
|
|
82
|
+
export {};
|