@solidrt/components 0.0.21 → 0.0.23

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/AGENTS.md CHANGED
@@ -28,7 +28,7 @@ Most components group props into two objects, plus top-level event handlers:
28
28
 
29
29
  - `Window` - root surface; renders a core `<window>`, so `render()` accepts it.
30
30
  Applies `layout` and `style.backgroundColor` only (a window cannot be
31
- transformed or bordered). Also: `title`, `fullscreen`, `vsync`, `fps`.
31
+ transformed or bordered). Also: `title`, `fullscreen`.
32
32
  - `View` - general box; draws a background/border when the matching `style`
33
33
  props are set.
34
34
  - `Text` - text in a layout box; font fields go in `layout`, `color` in `style`.
@@ -37,7 +37,7 @@ Most components group props into two objects, plus top-level event handlers:
37
37
  uncontrolled, plus `placeholder`, `maxLength`, `autoFocus`, `disabled`.
38
38
  - `ScrollView` - scrollable region; vertical by default, `horizontal` to flip.
39
39
  Wheel + drag, no momentum yet. Backed by `createScroll` from
40
- `@solidrt/core/scroll` (headless offset+clamp geometry).
40
+ `@solidrt/core` (headless offset+clamp geometry).
41
41
  - `Pressable` - pressable box; `onPress` on a primary press released inside,
42
42
  `disabled` opts out. `children`/`style` can be functions of `{ pressed,
43
43
  hovered }`. No pointer capture: a drag out cancels via onPointerLeave.
@@ -85,6 +85,23 @@ Most components group props into two objects, plus top-level event handlers:
85
85
  `setTheme({...})` merges a one-level-deep override. Default is dark. Color
86
86
  tokens: `background`, `surface`, `surfaceAlt`, `text`, `textMuted`, `border`,
87
87
  `primary`, `onPrimary`, `danger`, `scrim`.
88
+ - `policy` / `setPolicy` / `setPolicyResolver` / `defaultPolicyResolver` /
89
+ `densityScale` - shared REACTIVE behavior (theme answers "how does it look",
90
+ policy answers "how does it behave"). Derived from `@solidrt/core`'s
91
+ `capabilities`/`env` (touch vs. desktop, window size class, display scale).
92
+ Fields: `interaction` (`"touch" | "desktop" | "hybrid"`, gates hover vs.
93
+ long-press affordances), `density` (`"comfortable" | "compact" | "dense"`,
94
+ drives `densityScale()`: 1 / 0.85 / 0.7), `motion` (`"normal" | "reduced" |
95
+ "none"`), `focusRing` (boolean), `textScale`/`textWeightDelta` (Dynamic-Type
96
+ and low-DPI weight compensation, consumed by `Text`), `navigation`
97
+ (`"bottomTabs" | "rail" | "sidebar"`) and `layout` (`"singlePane" |
98
+ "twoPane"`, both recommendations derived from window size class). Read
99
+ `policy.*` directly (reactive getters, like `theme`); `setPolicy({ field:
100
+ value })` pins one field regardless of the derived value, `setPolicy({
101
+ field: undefined })` hands it back to the resolver; `setPolicyResolver(caps
102
+ => Policies)` replaces the whole derivation for full custom control.
103
+ `Tooltip`, `Select`, `ContextMenu` fork on `policy.interaction`; `NavShell`
104
+ on `policy.navigation`; `SplitView` on `policy.layout`.
88
105
 
89
106
  ## Minimal app (verified to render)
90
107
 
package/README.md CHANGED
@@ -28,6 +28,41 @@ setTheme({ color: { primary: "#ff2d55" } }) // override one token
28
28
 
29
29
  The color tokens are `background` (window fill), `surface` (control/card fill), `surfaceAlt` (subtle raised/track fill), `text`, `textMuted`, `border`, `primary`, `onPrimary`, `danger`, and `scrim` (modal dim). Non-color tokens are `spacing`, `radius`, `borderWidth`, and `text` (font sizes), shared across presets.
30
30
 
31
+ ## Policies
32
+
33
+ Theme answers "how does it look"; policies answer "how does it behave". Policies are a second reactive layer, derived from the platform facts in `@solidrt/core` (`capabilities`, `env`), so components adapt to touch vs. desktop, window size, and display without every app wiring that logic itself.
34
+
35
+ ```jsx
36
+ import { policy, setPolicy, densityScale } from "@solidrt/components"
37
+
38
+ policy.interaction // touch vs. desktop affordances (hover, long-press, ...)
39
+ policy.density // control/spacing scale
40
+ ```
41
+
42
+ `policy` fields:
43
+
44
+ | Field | Type | Description |
45
+ | ----------------- | ---------------------------------------------- | ----------------------------------------------------------------------------- |
46
+ | `interaction` | `"touch" \| "desktop" \| "hybrid"` | Which interaction affordances a component shows (hover states vs. long-press). |
47
+ | `density` | `"comfortable" \| "compact" \| "dense"` | Control/hit-target/spacing scale; see `densityScale()`. |
48
+ | `motion` | `"normal" \| "reduced" \| "none"` | Animation intensity. |
49
+ | `focusRing` | `boolean` | Whether focused controls draw a visible focus indicator. |
50
+ | `textScale` | `number` | Multiplier on type-scale font sizes; defaults to the OS text-scale preference. |
51
+ | `textWeightDelta` | `number` | Weight compensation (in steps of 100) for light-on-dark text on low-DPI displays. |
52
+ | `navigation` | `"bottomTabs" \| "rail" \| "sidebar"` | Recommended nav layout, derived from window size class. |
53
+ | `layout` | `"singlePane" \| "twoPane"` | Recommended single vs. two-pane layout, derived from window size class. |
54
+
55
+ Reads are reactive like `theme`, so a window resize or the first mouse move on a touch-capable device updates every consuming component live.
56
+
57
+ ```jsx
58
+ setPolicy({ density: "compact" }) // pin a field, overriding the derived value
59
+ setPolicy({ density: undefined }) // hand it back to the resolver
60
+ ```
61
+
62
+ `setPolicyResolver((caps) => Policies)` replaces the whole system-derivation function for full custom control; `defaultPolicyResolver` is exported to wrap or extend instead of replacing it outright.
63
+
64
+ `densityScale()` is a reactive multiplier (1 / 0.85 / 0.7 for comfortable/compact/dense) driven by `policy.density`, used internally for spacing and hit-target sizing.
65
+
31
66
  ## Layout and style
32
67
 
33
68
  Most components group their props into two objects:
@@ -74,8 +109,6 @@ function App() {
74
109
  | ------------ | ------------- | ------- | ------------------------------------ |
75
110
  | `title` | `string` | - | Window title. |
76
111
  | `fullscreen` | `boolean` | - | Open fullscreen. |
77
- | `vsync` | `boolean` | - | Enable vsync. |
78
- | `fps` | `boolean` | - | Show an FPS counter. |
79
112
  | `layout` | `LayoutProps` | - | Layout properties. |
80
113
  | `style` | `StyleProps` | - | Only `backgroundColor` is applied. |
81
114
  | `children` | `any` | - | Content. |
@@ -256,7 +289,7 @@ Accepts all pointer event props, plus:
256
289
  | `ref` | `(node: { id: number }) => void` | Reference to the outer box. |
257
290
  | `children` | `any` | Scrollable content. |
258
291
 
259
- The underlying geometry primitive `createScroll` is available from `@solidrt/core/scroll` for building custom scrollers.
292
+ The underlying geometry primitive `createScroll` is available from `@solidrt/core` for building custom scrollers.
260
293
 
261
294
  ### Pressable
262
295
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidrt/components",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "license": "MIT",
5
5
  "author": "Antoine van Wel",
6
6
  "type": "module",
@@ -18,6 +18,6 @@
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@solidjs/signals": "2.0.0-beta.15",
21
- "@solidrt/core": "0.0.21"
21
+ "@solidrt/core": "0.0.23"
22
22
  }
23
23
  }
@@ -1,4 +1,4 @@
1
- import { createScroll } from "@solidrt/core/scroll"
1
+ import { createScroll } from "@solidrt/core"
2
2
  import type { LayoutProps, PointerEvent, PointerProps, WheelEvent } from "@solidrt/core"
3
3
  import type { StyleProps } from "./types"
4
4
 
package/src/window.tsx CHANGED
@@ -5,8 +5,6 @@ export interface WindowProps extends PointerProps {
5
5
  children?: any
6
6
  title?: string
7
7
  fullscreen?: boolean
8
- vsync?: boolean
9
- fps?: boolean
10
8
  layout?: LayoutProps
11
9
  style?: StyleProps
12
10
  }
@@ -19,8 +17,6 @@ export function Window(props: WindowProps) {
19
17
  {...props.layout}
20
18
  title={props.title}
21
19
  fullscreen={props.fullscreen}
22
- vsync={props.vsync}
23
- fps={props.fps}
24
20
  onPointerEnter={props.onPointerEnter}
25
21
  onPointerLeave={props.onPointerLeave}
26
22
  onPointerDown={props.onPointerDown}