@trypattern/sdk 0.1.28 → 0.1.29
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/dist/components/ButtonBody.d.ts +2 -1
- package/dist/components/ButtonBody.js +5 -3
- package/dist/components/Checkbox.d.ts +2 -1
- package/dist/components/Checkbox.js +5 -2
- package/dist/components/IconButton.d.ts +3 -1
- package/dist/components/IconButton.js +17 -3
- package/dist/components/PlainSidebar.js +1 -1
- package/dist/components/Sidebar.js +1 -1
- package/package.json +1 -1
|
@@ -17,9 +17,10 @@ export type ButtonProps = {
|
|
|
17
17
|
disabled?: boolean;
|
|
18
18
|
isPending?: boolean;
|
|
19
19
|
isFullWidth?: boolean;
|
|
20
|
+
align?: 'start' | 'center';
|
|
20
21
|
onClick?: () => void;
|
|
21
22
|
style?: Placement;
|
|
22
23
|
};
|
|
23
|
-
export declare function ButtonBody({ children, variant, tone, size, to, href, icon, trailingIcon, shortcut, type, disabled, isPending, isFullWidth, onClick, style, isIconPinned }: ButtonProps & {
|
|
24
|
+
export declare function ButtonBody({ children, variant, tone, size, to, href, icon, trailingIcon, shortcut, type, disabled, isPending, isFullWidth, align, onClick, style, isIconPinned }: ButtonProps & {
|
|
24
25
|
isIconPinned?: boolean;
|
|
25
26
|
}): import("react").JSX.Element;
|
|
@@ -8,13 +8,13 @@ import { Icon } from "./Icon.js";
|
|
|
8
8
|
import { interact, textOf } from "./interaction.js";
|
|
9
9
|
import { Kbd } from "./Kbd.js";
|
|
10
10
|
import { Spinner } from "./Spinner.js";
|
|
11
|
-
export function ButtonBody({ children, variant = 'primary', tone = variant === 'primary' ? 'brand' : 'neutral', size = 'md', to, href, icon, trailingIcon, shortcut, type = 'button', disabled = false, isPending = false, isFullWidth = false, onClick, style, isIconPinned = false }) {
|
|
11
|
+
export function ButtonBody({ children, variant = 'primary', tone = variant === 'primary' ? 'brand' : 'neutral', size = 'md', to, href, icon, trailingIcon, shortcut, type = 'button', disabled = false, isPending = false, isFullWidth = false, align = 'center', onClick, style, isIconPinned = false }) {
|
|
12
12
|
const isDisabled = disabled || isPending;
|
|
13
13
|
const report = () => {
|
|
14
14
|
interact({ primitive: 'Button', event: 'click', label: textOf(children) });
|
|
15
15
|
onClick?.();
|
|
16
16
|
};
|
|
17
|
-
const className = stylex.props(styles.button, controlSizes[size], buttonCorners[size], icon !== undefined && !isIconPinned && leadingIconSizes[size], trailingIcon !== undefined && trailingIconSizes[size], looks[`${variant}${toneKeys[tone]}`], !isDisabled && hovers[`${variant}${toneKeys[tone]}`], isDisabled && styles.disabled, isDisabled && variant === 'transparent' && styles.disabledTransparent, isFullWidth && styles.fullWidth, focusRing.visible, style).className;
|
|
17
|
+
const className = stylex.props(styles.button, controlSizes[size], buttonCorners[size], icon !== undefined && !isIconPinned && leadingIconSizes[size], trailingIcon !== undefined && trailingIconSizes[size], looks[`${variant}${toneKeys[tone]}`], !isDisabled && hovers[`${variant}${toneKeys[tone]}`], isDisabled && styles.disabled, isDisabled && variant === 'transparent' && styles.disabledTransparent, isFullWidth && styles.fullWidth, align === 'start' && styles.alignStart, focusRing.visible, style).className;
|
|
18
18
|
const content = (_jsxs("span", { ...stylex.props(styles.stack), children: [_jsxs("span", { ...stylex.props(styles.content, isIconPinned && styles.pinnedContent, isPending && styles.hidden), children: [icon === undefined ? null : _jsx(Icon, { name: icon, size: size }), _jsx("span", { ...stylex.props(styles.label, shortcut !== undefined && styles.labelBeforeShortcut, isIconPinned && styles.labelBetweenPins), children: children }), isIconPinned ? (_jsx("span", { "aria-hidden": "true", ...stylex.props(pinBalances[size]) })) : null, trailingIcon === undefined ? null : (_jsx(Icon, { name: trailingIcon, size: size })), shortcut === undefined ? null : _jsx(Kbd, { keys: shortcut })] }), isPending ? (_jsx("span", { "aria-hidden": "true", ...stylex.props(styles.pending), children: _jsx(Spinner, { size: size }) })) : null] }));
|
|
19
19
|
if (href !== undefined) {
|
|
20
20
|
return (_jsx("a", { href: href, target: "_blank", rel: "noreferrer", onClick: report, className: className, children: content }));
|
|
@@ -48,9 +48,11 @@ const styles = stylex.create({
|
|
|
48
48
|
transitionProperty: 'color, background-color, transform'
|
|
49
49
|
},
|
|
50
50
|
fullWidth: {
|
|
51
|
-
justifyContent: 'flex-start',
|
|
52
51
|
width: '100%'
|
|
53
52
|
},
|
|
53
|
+
alignStart: {
|
|
54
|
+
justifyContent: 'flex-start'
|
|
55
|
+
},
|
|
54
56
|
stack: {
|
|
55
57
|
display: 'grid',
|
|
56
58
|
flexGrow: 1,
|
|
@@ -3,8 +3,9 @@ type CheckboxProps = {
|
|
|
3
3
|
label: string;
|
|
4
4
|
checked: boolean;
|
|
5
5
|
disabled?: boolean;
|
|
6
|
+
shape?: 'round' | 'square';
|
|
6
7
|
onChange: (checked: boolean) => void;
|
|
7
8
|
style?: Placement;
|
|
8
9
|
};
|
|
9
|
-
export declare function Checkbox({ label, checked, disabled, onChange, style }: CheckboxProps): import("react").JSX.Element;
|
|
10
|
+
export declare function Checkbox({ label, checked, disabled, shape, onChange, style }: CheckboxProps): import("react").JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -4,11 +4,11 @@ import * as stylex from '@stylexjs/stylex';
|
|
|
4
4
|
import { borders, colors, iconSizes, motion, radii, space } from "../theme/tokens.stylex.js";
|
|
5
5
|
import { focusRing } from "./controlLook.js";
|
|
6
6
|
import { interact } from "./interaction.js";
|
|
7
|
-
export function Checkbox({ label, checked, disabled = false, onChange, style }) {
|
|
7
|
+
export function Checkbox({ label, checked, disabled = false, shape = 'round', onChange, style }) {
|
|
8
8
|
return (_jsx(BaseCheckbox.Root, { "aria-label": label, checked: checked, disabled: disabled, onCheckedChange: (next) => {
|
|
9
9
|
interact({ primitive: 'Checkbox', event: 'change', label });
|
|
10
10
|
onChange(next);
|
|
11
|
-
}, className: (state) => stylex.props(styles.box, state.checked ? styles.on : styles.off, disabled && styles.disabled, focusRing.visible, style).className, children: _jsx(BaseCheckbox.Indicator, { className: stylex.props(styles.indicator).className, children: _jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3.25", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", ...stylex.props(styles.tick), children: _jsx("path", { d: "M5 12.5 9.5 17 19 7.5" }) }) }) }));
|
|
11
|
+
}, className: (state) => stylex.props(styles.box, shape === 'square' && styles.square, state.checked ? styles.on : styles.off, disabled && styles.disabled, focusRing.visible, style).className, children: _jsx(BaseCheckbox.Indicator, { className: stylex.props(styles.indicator).className, children: _jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3.25", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", ...stylex.props(styles.tick), children: _jsx("path", { d: "M5 12.5 9.5 17 19 7.5" }) }) }) }));
|
|
12
12
|
}
|
|
13
13
|
const styles = stylex.create({
|
|
14
14
|
box: {
|
|
@@ -32,6 +32,9 @@ const styles = stylex.create({
|
|
|
32
32
|
borderRadius: radii.full
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
+
square: {
|
|
36
|
+
borderRadius: radii.sm
|
|
37
|
+
},
|
|
35
38
|
off: {
|
|
36
39
|
backgroundColor: 'transparent',
|
|
37
40
|
boxShadow: `0 0 0 ${borders.thin} ${colors.borderStrong} inset, 0 ${borders.thin} ${borders.thin} ${colors.borderSubtle}`
|
|
@@ -5,10 +5,12 @@ type IconButtonProps = {
|
|
|
5
5
|
icon: IconName;
|
|
6
6
|
label: string;
|
|
7
7
|
size?: Size;
|
|
8
|
+
variant?: 'transparent' | 'primary';
|
|
9
|
+
shape?: 'square' | 'round';
|
|
8
10
|
shortcut?: readonly string[];
|
|
9
11
|
disabled?: boolean;
|
|
10
12
|
onClick: () => void;
|
|
11
13
|
style?: Placement;
|
|
12
14
|
};
|
|
13
|
-
export declare function IconButton({ icon, label, size, shortcut, disabled, onClick, style }: IconButtonProps): import("react").JSX.Element;
|
|
15
|
+
export declare function IconButton({ icon, label, size, variant, shape, shortcut, disabled, onClick, style }: IconButtonProps): import("react").JSX.Element;
|
|
14
16
|
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Button as BaseButton } from '@base-ui/react/button';
|
|
3
3
|
import * as stylex from '@stylexjs/stylex';
|
|
4
|
-
import { colors, controls, corners } from "../theme/tokens.stylex.js";
|
|
4
|
+
import { colors, controls, corners, radii } from "../theme/tokens.stylex.js";
|
|
5
5
|
import { focusRing, transparentLook } from "./controlLook.js";
|
|
6
6
|
import { Icon } from "./Icon.js";
|
|
7
7
|
import { interact } from "./interaction.js";
|
|
8
8
|
import { Tooltip } from "./Tooltip.js";
|
|
9
|
-
export function IconButton({ icon, label, size = 'md', shortcut, disabled = false, onClick, style }) {
|
|
9
|
+
export function IconButton({ icon, label, size = 'md', variant = 'transparent', shape = 'square', shortcut, disabled = false, onClick, style }) {
|
|
10
10
|
return (_jsx(Tooltip, { label: label, shortcut: shortcut, children: _jsx(BaseButton, { "aria-label": label, disabled: disabled, focusableWhenDisabled: true, onClick: () => {
|
|
11
11
|
interact({ primitive: 'IconButton', event: 'click', label });
|
|
12
12
|
onClick();
|
|
13
|
-
}, className: stylex.props(styles.button, sizes[size], transparentLook.rest, !disabled && transparentLook.hoverable, disabled && styles.disabled, focusRing.visible, style).className, children: _jsx(Icon, { name: icon, size: size }) }) }));
|
|
13
|
+
}, className: stylex.props(styles.button, sizes[size], variant === 'transparent' && transparentLook.rest, variant === 'transparent' && !disabled && transparentLook.hoverable, variant === 'primary' && styles.primary, variant === 'primary' && !disabled && styles.primaryHoverable, shape === 'round' && styles.round, disabled && styles.disabled, focusRing.visible, style).className, children: _jsx(Icon, { name: icon, size: size }) }) }));
|
|
14
14
|
}
|
|
15
15
|
const styles = stylex.create({
|
|
16
16
|
button: {
|
|
@@ -20,6 +20,20 @@ const styles = stylex.create({
|
|
|
20
20
|
justifyContent: 'center',
|
|
21
21
|
outlineOffset: 0
|
|
22
22
|
},
|
|
23
|
+
primary: {
|
|
24
|
+
color: colors.onBrandSolidForeground,
|
|
25
|
+
backgroundColor: colors.brandSolid
|
|
26
|
+
},
|
|
27
|
+
primaryHoverable: {
|
|
28
|
+
backgroundColor: {
|
|
29
|
+
default: colors.brandSolid,
|
|
30
|
+
':hover': colors.brandSolidHover,
|
|
31
|
+
':active': colors.brandSolidActive
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
round: {
|
|
35
|
+
borderRadius: radii.full
|
|
36
|
+
},
|
|
23
37
|
disabled: {
|
|
24
38
|
color: colors.disabledForeground
|
|
25
39
|
}
|
|
@@ -18,7 +18,7 @@ export function PlainSidebar({ title, user, accountMenu, links, isToggled, isAni
|
|
|
18
18
|
interact({ primitive: 'AppFrame', event: 'navigate', label: link.label });
|
|
19
19
|
onFollowLink();
|
|
20
20
|
};
|
|
21
|
-
return (_jsxs("nav", { ...stylex.props(styles.sidebar, isToggled && styles.sidebarToggled, isAnimating && styles.sidebarAnimating), children: [_jsx("div", { ...stylex.props(styles.header), children: _jsx("span", { ...stylex.props(styles.title), children: title }) }), onSearch === undefined ? null : (_jsx(Button, { variant: "secondary", icon: "search", shortcut: ['mod', 'k'], isFullWidth: true, onClick: onSearch, children: "Search" })), _jsx("div", { ...stylex.props(styles.body), children: _jsx(ScrollArea, { children: _jsx("div", { ...stylex.props(styles.group), children: links.map((item) => (_jsxs(NavLink, { onClick: () => followLink(item), to: item.to, end: item.to === '/' ||
|
|
21
|
+
return (_jsxs("nav", { ...stylex.props(styles.sidebar, isToggled && styles.sidebarToggled, isAnimating && styles.sidebarAnimating), children: [_jsx("div", { ...stylex.props(styles.header), children: _jsx("span", { ...stylex.props(styles.title), children: title }) }), onSearch === undefined ? null : (_jsx(Button, { variant: "secondary", icon: "search", shortcut: ['mod', 'k'], isFullWidth: true, align: "start", onClick: onSearch, children: "Search" })), _jsx("div", { ...stylex.props(styles.body), children: _jsx(ScrollArea, { children: _jsx("div", { ...stylex.props(styles.group), children: links.map((item) => (_jsxs(NavLink, { onClick: () => followLink(item), to: item.to, end: item.to === '/' ||
|
|
22
22
|
links.some((other) => String(other.to).startsWith(`${String(item.to)}/`)), className: ({ isActive }) => stylex.props(styles.item, isActive && styles.itemCurrent, focusRing.visible, focusRing.inside).className ?? '', children: [_jsx(Icon, { name: item.icon, weight: "light" }), _jsx(Text, { variant: "label", isTruncated: true, style: styles.itemLabel, children: item.label }), typeof item.count !== 'number' ? null : (_jsx(Badge, { variant: "transparent", children: item.count }))] }, item.to))) }) }) }), user === null ? null : (_jsxs(BaseMenu.Root, { children: [_jsxs(BaseMenu.Trigger, { className: (state) => stylex.props(styles.account, transparentLook.rest, transparentLook.hoverable, state.open && transparentLook.open, styles.accountText, focusRing.visible).className, children: [_jsx(Avatar, { name: user.name, imageUrl: user.avatarUrl }), _jsxs("span", { ...stylex.props(styles.who), children: [_jsx("span", { ...stylex.props(styles.name), children: user.name }), _jsx("span", { ...stylex.props(styles.email), children: user.email })] }), _jsx(Icon, { name: "chevronUpDown", tone: "secondary" })] }), _jsx(BaseMenu.Portal, { children: _jsx(BaseMenu.Positioner, { side: "top", align: "start", sideOffset: 4, className: stylex.props(styles.positioner).className, children: _jsx(BaseMenu.Popup, { render: (props, state) => (_jsx(Popup, { ...props, kind: "menu", isOpen: state.open, transitionStatus: state.transitionStatus })), children: _jsx(MenuItems, { items: accountMenu, primitive: "Menu" }) }) }) })] }))] }));
|
|
23
23
|
}
|
|
24
24
|
const styles = stylex.create({
|
|
@@ -15,7 +15,7 @@ export function Sidebar({ workspace, workspaceMenu, links, isToggled, isAnimatin
|
|
|
15
15
|
interact({ primitive: 'AppFrame', event: 'navigate', label: link.label });
|
|
16
16
|
onFollowLink();
|
|
17
17
|
};
|
|
18
|
-
return (_jsxs("nav", { ...stylex.props(styles.sidebar, isToggled && styles.sidebarToggled, isAnimating && styles.sidebarAnimating), children: [_jsx("div", { ...stylex.props(styles.header), children: _jsx(Menu, { trigger: _jsxs(_Fragment, { children: [_jsx("span", { ...stylex.props(styles.logo), children: _jsx(Text, { variant: "caption", children: workspace.charAt(0) }) }), _jsx(Text, { variant: "label", isTruncated: true, children: workspace }), _jsx(Icon, { name: "chevronDown" })] }), items: workspaceMenu }) }), onSearch === undefined ? null : (_jsx(Button, { variant: "secondary", icon: "search", shortcut: ['mod', 'k'], isFullWidth: true, onClick: onSearch, children: "Search" })), _jsx("div", { ...stylex.props(styles.body), children: _jsx(ScrollArea, { children: _jsxs("div", { ...stylex.props(styles.group), children: [_jsx("span", { ...stylex.props(styles.groupLabel), children: _jsx(Text, { variant: "label", tone: "tertiary", children: "Workspace" }) }), links.map((item) => (_jsxs(NavLink, { onClick: () => followLink(item), to: item.to, end: item.to === '/' ||
|
|
18
|
+
return (_jsxs("nav", { ...stylex.props(styles.sidebar, isToggled && styles.sidebarToggled, isAnimating && styles.sidebarAnimating), children: [_jsx("div", { ...stylex.props(styles.header), children: _jsx(Menu, { trigger: _jsxs(_Fragment, { children: [_jsx("span", { ...stylex.props(styles.logo), children: _jsx(Text, { variant: "caption", children: workspace.charAt(0) }) }), _jsx(Text, { variant: "label", isTruncated: true, children: workspace }), _jsx(Icon, { name: "chevronDown" })] }), items: workspaceMenu }) }), onSearch === undefined ? null : (_jsx(Button, { variant: "secondary", icon: "search", shortcut: ['mod', 'k'], isFullWidth: true, align: "start", onClick: onSearch, children: "Search" })), _jsx("div", { ...stylex.props(styles.body), children: _jsx(ScrollArea, { children: _jsxs("div", { ...stylex.props(styles.group), children: [_jsx("span", { ...stylex.props(styles.groupLabel), children: _jsx(Text, { variant: "label", tone: "tertiary", children: "Workspace" }) }), links.map((item) => (_jsxs(NavLink, { onClick: () => followLink(item), to: item.to, end: item.to === '/' ||
|
|
19
19
|
links.some((other) => String(other.to).startsWith(`${String(item.to)}/`)), className: ({ isActive }) => stylex.props(styles.item, isActive && styles.itemCurrent, focusRing.visible, focusRing.inside).className ?? '', children: [_jsx(Icon, { name: item.icon }), _jsx(Text, { variant: "label", isTruncated: true, style: styles.itemLabel, children: item.label }), typeof item.count !== 'number' ? null : (_jsx(Badge, { variant: "transparent", children: item.count }))] }, item.to)))] }) }) })] }));
|
|
20
20
|
}
|
|
21
21
|
const styles = stylex.create({
|