@trypattern/sdk 0.1.10 → 0.1.11

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.
@@ -2,12 +2,14 @@ import type { ReactNode } from 'react';
2
2
  import type { AppPath } from '../registered.ts';
3
3
  type ListRowProps = {
4
4
  to?: AppPath;
5
+ href?: string;
5
6
  onClick?: () => void;
6
7
  isMuted?: boolean;
7
8
  isCurrent?: boolean;
9
+ size?: 'sm' | 'md' | 'lg';
8
10
  leading?: ReactNode;
9
11
  trailing?: ReactNode;
10
12
  children: ReactNode;
11
13
  };
12
- export declare function ListRow({ to, onClick, isMuted, isCurrent, leading, trailing, children }: ListRowProps): import("react").JSX.Element;
14
+ export declare function ListRow({ to, href, onClick, isMuted, isCurrent, size, leading, trailing, children }: ListRowProps): import("react").JSX.Element;
13
15
  export {};
@@ -5,20 +5,24 @@ import { Link as RouterLink } from 'react-router';
5
5
  import { colors, controls, radii, space } from "../theme/tokens.stylex.js";
6
6
  import { focusRing } from "./controlLook.js";
7
7
  import { interact, textOf } from "./interaction.js";
8
- export function ListRow({ to, onClick, isMuted = false, isCurrent = false, leading, trailing, children }) {
8
+ export function ListRow({ to, href, onClick, isMuted = false, isCurrent = false, size = 'md', leading, trailing, children }) {
9
9
  const content = (_jsxs(_Fragment, { children: [leading, _jsx("span", { ...stylex.props(styles.main), children: children }), trailing === undefined ? null : (_jsx("span", { ...stylex.props(styles.trailing), children: trailing }))] }));
10
- const look = stylex.props(styles.row, (to !== undefined || onClick !== undefined) && styles.interactive, isMuted && styles.muted, isCurrent && styles.current, focusRing.visible, focusRing.inside);
10
+ const look = stylex.props(styles.row, (to !== undefined || href !== undefined || onClick !== undefined) &&
11
+ styles.interactive, isMuted && styles.muted, isCurrent && styles.current, size === 'sm' && styles.small, size === 'lg' && styles.large, focusRing.visible, focusRing.inside);
11
12
  const report = () => {
12
13
  interact({
13
14
  primitive: 'ListRow',
14
- event: to === undefined ? 'click' : 'navigate',
15
- label: textOf(children) || (to ?? '')
15
+ event: to === undefined && href === undefined ? 'click' : 'navigate',
16
+ label: textOf(children) || (to ?? href ?? '')
16
17
  });
17
18
  onClick?.();
18
19
  };
19
20
  if (to !== undefined) {
20
21
  return (_jsx(RouterLink, { to: to, onClick: report, "aria-current": isCurrent ? 'page' : undefined, ...look, children: content }));
21
22
  }
23
+ if (href !== undefined) {
24
+ return (_jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", onClick: report, ...look, children: content }));
25
+ }
22
26
  if (onClick !== undefined) {
23
27
  return (_jsx(BaseButton, { onClick: report, "aria-pressed": isCurrent, className: look.className, children: content }));
24
28
  }
@@ -49,6 +53,16 @@ const styles = stylex.create({
49
53
  current: {
50
54
  backgroundColor: colors.transparentHover
51
55
  },
56
+ large: {
57
+ height: 'auto',
58
+ minHeight: controls.heightXl,
59
+ paddingBlock: space.md
60
+ },
61
+ small: {
62
+ gap: space.sm,
63
+ height: controls.heightMd,
64
+ paddingInline: space.sm
65
+ },
52
66
  main: {
53
67
  display: 'flex',
54
68
  flexGrow: 1,
@@ -10,6 +10,7 @@ type ScrollAreaProps = {
10
10
  paddingBlock?: number | string;
11
11
  paddingInline?: number | string;
12
12
  }>;
13
+ axis?: 'vertical' | 'horizontal';
13
14
  };
14
- export declare function ScrollArea({ children, style }: ScrollAreaProps): import("react").JSX.Element;
15
+ export declare function ScrollArea({ children, style, axis }: ScrollAreaProps): import("react").JSX.Element;
15
16
  export {};
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import * as stylex from '@stylexjs/stylex';
3
- export function ScrollArea({ children, style }) {
4
- return _jsx("div", { ...stylex.props(styles.scroll, style), children: children });
3
+ export function ScrollArea({ children, style, axis = 'vertical' }) {
4
+ return (_jsx("div", { ...stylex.props(styles.scroll, axis === 'horizontal' && styles.horizontal, style), children: children }));
5
5
  }
6
6
  const styles = stylex.create({
7
7
  scroll: {
@@ -9,5 +9,10 @@ const styles = stylex.create({
9
9
  minHeight: 0,
10
10
  overflowY: 'auto',
11
11
  overscrollBehavior: 'contain'
12
+ },
13
+ horizontal: {
14
+ height: 'auto',
15
+ overflowX: 'auto',
16
+ overflowY: 'hidden'
12
17
  }
13
18
  });
@@ -3,7 +3,7 @@ import type { Placement } from './Placement.ts';
3
3
  import type { Tone } from './tones.ts';
4
4
  type TextProps = {
5
5
  children: ReactNode;
6
- variant?: 'heading' | 'subheading' | 'title' | 'label' | 'body' | 'caption' | 'code';
6
+ variant?: 'heading' | 'subheading' | 'title' | 'lead' | 'label' | 'body' | 'caption' | 'code';
7
7
  tone?: Tone;
8
8
  align?: 'start' | 'center' | 'end';
9
9
  as?: 'span' | 'p' | 'h1' | 'h2' | 'h3';
@@ -23,17 +23,23 @@ const styles = stylex.create({
23
23
  const variants = stylex.create({
24
24
  heading: {
25
25
  fontSize: fontSizes.heading5,
26
- fontWeight: fontWeights.semibold,
27
- lineHeight: lineHeights.heading5
26
+ fontWeight: fontWeights.medium,
27
+ lineHeight: lineHeights.heading5,
28
+ letterSpacing: '-0.01em'
28
29
  },
29
30
  subheading: {
30
31
  fontSize: fontSizes.heading6,
31
- fontWeight: fontWeights.semibold,
32
+ fontWeight: fontWeights.medium,
32
33
  lineHeight: lineHeights.heading6
33
34
  },
34
35
  title: {
35
36
  fontSize: fontSizes.bodyBase,
36
- fontWeight: fontWeights.semibold,
37
+ fontWeight: fontWeights.medium,
38
+ lineHeight: lineHeights.body
39
+ },
40
+ lead: {
41
+ fontSize: fontSizes.bodyBase,
42
+ fontWeight: fontWeights.normal,
37
43
  lineHeight: lineHeights.body
38
44
  },
39
45
  label: {
@@ -1,3 +1,4 @@
1
+ import type { IconName } from './icons.ts';
1
2
  import type { Placement } from './Placement.ts';
2
3
  import type { Size } from './Size.ts';
3
4
  type TextFieldProps = {
@@ -21,7 +22,8 @@ type TextFieldProps = {
21
22
  multiline?: boolean;
22
23
  rows?: number;
23
24
  size?: Size;
25
+ icon?: IconName;
24
26
  style?: Placement;
25
27
  };
26
- export declare function TextField({ label, isLabelHidden, description, error, onChange, multiline, rows, size, style, ...input }: TextFieldProps): import("react").JSX.Element;
28
+ export declare function TextField({ label, isLabelHidden, description, error, onChange, multiline, rows, size, icon, style, ...input }: TextFieldProps): import("react").JSX.Element;
27
29
  export {};
@@ -3,18 +3,19 @@ import { Field } from '@base-ui/react/field';
3
3
  import * as stylex from '@stylexjs/stylex';
4
4
  import { useRef } from 'react';
5
5
  import { borders, colors, controls, fontSizes, fontWeights, lineHeights, motion, shadows, space } from "../theme/tokens.stylex.js";
6
+ import { Icon } from "./Icon.js";
6
7
  import { controlSizes } from "./controlLook.js";
7
8
  import { interact } from "./interaction.js";
8
- export function TextField({ label, isLabelHidden = false, description, error, onChange, multiline = false, rows = 3, size = 'md', style, ...input }) {
9
+ export function TextField({ label, isLabelHidden = false, description, error, onChange, multiline = false, rows = 3, size = 'md', icon, style, ...input }) {
9
10
  const isInvalid = error !== undefined;
10
11
  const valueOnFocus = useRef('');
11
- return (_jsxs(Field.Root, { invalid: isInvalid, disabled: input.disabled ?? false, className: stylex.props(styles.field, style).className, children: [isLabelHidden ? null : (_jsx(Field.Label, { className: stylex.props(styles.label).className, children: label })), _jsx(Field.Control, { ...input, ...(multiline ? { render: _jsx("textarea", { rows: rows }) } : {}), "aria-label": isLabelHidden ? label : undefined, onChange: (event) => onChange?.(event.currentTarget.value), onFocus: (event) => {
12
- valueOnFocus.current = event.currentTarget.value;
13
- }, onBlur: (event) => {
14
- if (event.currentTarget.value !== valueOnFocus.current) {
15
- interact({ primitive: 'TextField', event: 'change', label });
16
- }
17
- }, className: stylex.props(styles.input, controlSizes[size], multiline && styles.multiline, multiline && multilinePaddings[size], isInvalid && styles.invalid, input.disabled === true && styles.disabled).className }), description === undefined ? null : (_jsx(Field.Description, { className: stylex.props(styles.note).className, children: description })), error === undefined ? null : (_jsx(Field.Error, { match: true, className: stylex.props(styles.error).className, children: error }))] }));
12
+ return (_jsxs(Field.Root, { invalid: isInvalid, disabled: input.disabled ?? false, className: stylex.props(styles.field, style).className, children: [isLabelHidden ? null : (_jsx(Field.Label, { className: stylex.props(styles.label).className, children: label })), _jsxs("div", { ...stylex.props(styles.control), children: [icon === undefined ? null : (_jsx("span", { ...stylex.props(styles.icon), children: _jsx(Icon, { name: icon, tone: "tertiary" }) })), _jsx(Field.Control, { ...input, ...(multiline ? { render: _jsx("textarea", { rows: rows }) } : {}), "aria-label": isLabelHidden ? label : undefined, onChange: (event) => onChange?.(event.currentTarget.value), onFocus: (event) => {
13
+ valueOnFocus.current = event.currentTarget.value;
14
+ }, onBlur: (event) => {
15
+ if (event.currentTarget.value !== valueOnFocus.current) {
16
+ interact({ primitive: 'TextField', event: 'change', label });
17
+ }
18
+ }, className: stylex.props(styles.input, controlSizes[size], multiline && styles.multiline, multiline && multilinePaddings[size], icon !== undefined && styles.withIcon, isInvalid && styles.invalid, input.disabled === true && styles.disabled).className })] }), description === undefined ? null : (_jsx(Field.Description, { className: stylex.props(styles.note).className, children: description })), error === undefined ? null : (_jsx(Field.Error, { match: true, className: stylex.props(styles.error).className, children: error }))] }));
18
19
  }
19
20
  const focusRing = `inset 0 0 0 ${borders.hairline} ${colors.brandBorderFocus}, 0 0 0 ${borders.thin} ${colors.brandBorderFocus}, ${shadows.default}`;
20
21
  const invalidRing = `inset 0 0 0 ${borders.hairline} ${colors.dangerBorderDefault}, 0 0 0 ${borders.thin} ${colors.dangerBorderDefault}, ${shadows.default}`;
@@ -25,6 +26,22 @@ const styles = stylex.create({
25
26
  gap: space.xs,
26
27
  minWidth: 0
27
28
  },
29
+ control: {
30
+ position: 'relative',
31
+ display: 'flex',
32
+ flexDirection: 'column'
33
+ },
34
+ icon: {
35
+ position: 'absolute',
36
+ insetBlock: 0,
37
+ insetInlineStart: space.sm,
38
+ display: 'flex',
39
+ alignItems: 'center',
40
+ pointerEvents: 'none'
41
+ },
42
+ withIcon: {
43
+ paddingInlineStart: `calc(${space.xl} + ${space.xs})`
44
+ },
28
45
  label: {
29
46
  fontWeight: fontWeights.medium,
30
47
  color: colors.primaryForeground
@@ -43,7 +43,7 @@ export async function sessionCookieFor(env, user) {
43
43
  email: user.email,
44
44
  recheckAt: nowInSeconds() + RECHECK_SECONDS
45
45
  };
46
- const cookie = await serializeSigned(SESSION_COOKIE, JSON.stringify(pass), env.SESSION_SECRET);
46
+ const cookie = await serializeSigned(SESSION_COOKIE, JSON.stringify(pass), env.SESSION_SECRET, { path: '/', secure: true });
47
47
  return { cookie: cookie.split(';')[0] ?? cookie, sessionId };
48
48
  }
49
49
  export async function readPass(c) {
package/dist/start.js CHANGED
@@ -165,6 +165,9 @@ const base = stylex.create({
165
165
  [breakpoints.compact]: lineHeights.body
166
166
  },
167
167
  color: colors.primaryForeground,
168
- backgroundColor: colors.shell
168
+ backgroundColor: colors.shell,
169
+ WebkitFontSmoothing: 'antialiased',
170
+ MozOsxFontSmoothing: 'grayscale',
171
+ fontSynthesis: 'none'
169
172
  }
170
173
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trypattern/sdk",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",