opentui-responsive 0.2.8 → 0.3.1

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
@@ -41,7 +41,7 @@ Create the responsive provider in your layout, then use its hook directly in chi
41
41
  import { createResponsiveTui } from "opentui-responsive/solid";
42
42
  import type { ParentProps } from "solid-js";
43
43
 
44
- export const { ResponsiveTUI, useResponsiveTui } = createResponsiveTui({
44
+ export const { ResponsiveTUI, useBreakpoint } = createResponsiveTui({
45
45
  // Required: each axis must include a 0 threshold.
46
46
  width: { narrow: 0, medium: 60, wide: 100 },
47
47
  height: { short: 0, medium: 16, tall: 28 },
@@ -55,10 +55,10 @@ export function Layout(props: ParentProps) {
55
55
  `src/content.tsx`
56
56
 
57
57
  ```tsx
58
- import { useResponsiveTui } from "./layout.tsx";
58
+ import { useBreakpoint } from "./layout.tsx";
59
59
 
60
60
  export function Content() {
61
- const breakpoint = useResponsiveTui();
61
+ const breakpoint = useBreakpoint();
62
62
  // You can use it to directly check [width, height] breakpoint
63
63
  const isWideAndTall = breakpoint(["wide", "tall"]);
64
64
 
@@ -87,7 +87,7 @@ export function App() {
87
87
  }
88
88
  ```
89
89
 
90
- `useResponsiveTui()` updates when the terminal crosses a configured threshold. Its accessor returns the current width and height names, or accepts an exact `[width, height]` pair and returns whether both axes match.
90
+ `useBreakpoint()` updates when the terminal crosses a configured threshold. Its accessor returns the current width and height names, or accepts an exact `[width, height]` pair and returns whether both axes match.
91
91
 
92
92
  Run `bun run demo` from the package directory to try the Solid example. Resize the terminal to see its layout respond.
93
93
 
@@ -97,14 +97,14 @@ The React adapter has the same factory, provider, hook, and inferred breakpoint
97
97
 
98
98
  ### `opentui-responsive/solid` and `opentui-responsive/react`
99
99
 
100
- | API | Description |
101
- | --------------------------------- | ---------------------------------------------------------------------------------------- |
102
- | `createResponsiveTui(scales)` | Validates the scales and creates a `ResponsiveTUI` provider and `useResponsiveTui` hook. |
103
- | `ResponsiveTUI` | Tracks terminal dimensions and provides the current breakpoint accessor. |
104
- | `useResponsiveTui()` | Reads the accessor from the nearest generated provider. |
105
- | `ResponsiveBreakpointAccessor` | Reads the current match or tests an exact breakpoint pair. |
106
- | `ResponsiveTuiConfigurationError` | Thrown when the supplied breakpoint scales are invalid. |
107
- | `ResponsiveTuiProviderError` | Thrown when the generated hook is called outside its provider. |
100
+ | API | Description |
101
+ | --------------------------------- | ------------------------------------------------------------------------------------- |
102
+ | `createResponsiveTui(scales)` | Validates the scales and creates a `ResponsiveTUI` provider and `useBreakpoint` hook. |
103
+ | `ResponsiveTUI` | Tracks terminal dimensions and provides the current breakpoint accessor. |
104
+ | `useBreakpoint()` | Reads the accessor from the nearest generated provider. |
105
+ | `ResponsiveBreakpointAccessor` | Reads the current match or tests an exact breakpoint pair. |
106
+ | `ResponsiveTuiConfigurationError` | Thrown when the supplied breakpoint scales are invalid. |
107
+ | `ResponsiveTuiProviderError` | Thrown when the generated hook is called outside its provider. |
108
108
 
109
109
  ### `opentui-responsive/core`
110
110
 
@@ -121,7 +121,7 @@ For implementing another framework adapter, not application setup:
121
121
 
122
122
  ## Breakpoint Behavior
123
123
 
124
- Width and height use independent sets of inclusive minimum thresholds measured in terminal cells. Each axis must contain a zero threshold so every terminal size has a match. Names must be non-empty, and thresholds must be unique finite non-negative integers within their axis.
124
+ Width and height use independent sets of inclusive minimum thresholds measured in terminal cells. A threshold is selected when the dimension is greater than or equal to it: for example, a width threshold of `60` matches at `width >= 60`. Each axis must contain a zero threshold so every terminal size has a match. Names must be non-empty, and thresholds must be unique finite non-negative integers within their axis.
125
125
 
126
126
  Declaration order does not affect matching. Each axis selects its highest satisfied threshold.
127
127
 
@@ -14,5 +14,5 @@ export declare class ResponsiveTuiProviderError extends Error {
14
14
  /** Creates a React provider and hook bound to one breakpoint definition. */
15
15
  export declare const createResponsiveTui: <const Scales extends BreakpointScales>(scales: Parameters<typeof createBreakpointDefinition<Scales>>[0]) => {
16
16
  ResponsiveTUI: (props: PropsWithChildren) => import("react").FunctionComponentElement<import("react").ProviderProps<ResponsiveBreakpointAccessor<Scales> | undefined>>;
17
- useResponsiveTui: () => ResponsiveBreakpointAccessor<Scales>;
17
+ useBreakpoint: () => ResponsiveBreakpointAccessor<Scales>;
18
18
  };
@@ -82,7 +82,7 @@ var isThreshold = (value) => typeof value === "number" && Number.isFinite(value)
82
82
  class ResponsiveTuiProviderError extends Error {
83
83
  _tag = "ResponsiveTuiProviderError";
84
84
  constructor() {
85
- super("useResponsiveTui must be used within a ResponsiveTUI");
85
+ super("useBreakpoint must be used within a ResponsiveTUI");
86
86
  this.name = this._tag;
87
87
  }
88
88
  }
@@ -94,14 +94,14 @@ var createResponsiveTui = (scales) => {
94
94
  const breakpoint = (pair) => pair ? breakpoints.matches(dimensions, pair) : breakpoints.match(dimensions);
95
95
  return createElement(ResponsiveTuiContext.Provider, { value: breakpoint }, props.children);
96
96
  };
97
- const useResponsiveTui = () => {
97
+ const useBreakpoint = () => {
98
98
  const breakpoint = useContext(ResponsiveTuiContext);
99
99
  if (!breakpoint) {
100
100
  throw new ResponsiveTuiProviderError;
101
101
  }
102
102
  return breakpoint;
103
103
  };
104
- return { ResponsiveTUI, useResponsiveTui };
104
+ return { ResponsiveTUI, useBreakpoint };
105
105
  };
106
106
  export {
107
107
  ResponsiveTuiConfigurationError,
@@ -14,5 +14,5 @@ export declare class ResponsiveTuiProviderError extends Error {
14
14
  /** Creates a Solid provider and hook bound to one breakpoint definition. */
15
15
  export declare const createResponsiveTui: <const Scales extends BreakpointScales>(scales: Parameters<typeof createBreakpointDefinition<Scales>>[0]) => {
16
16
  ResponsiveTUI: (props: ParentProps) => any;
17
- useResponsiveTui: () => ResponsiveBreakpointAccessor<Scales>;
17
+ useBreakpoint: () => ResponsiveBreakpointAccessor<Scales>;
18
18
  };
@@ -82,7 +82,7 @@ var isThreshold = (value) => typeof value === "number" && Number.isFinite(value)
82
82
  class ResponsiveTuiProviderError extends Error {
83
83
  _tag = "ResponsiveTuiProviderError";
84
84
  constructor() {
85
- super("useResponsiveTui must be used within a ResponsiveTUI");
85
+ super("useBreakpoint must be used within a ResponsiveTUI");
86
86
  this.name = this._tag;
87
87
  }
88
88
  }
@@ -100,14 +100,14 @@ var createResponsiveTui = (scales) => {
100
100
  value: breakpoint
101
101
  });
102
102
  };
103
- const useResponsiveTui = () => {
103
+ const useBreakpoint = () => {
104
104
  const breakpoint = useContext(ResponsiveTuiContext);
105
105
  if (!breakpoint) {
106
106
  throw new ResponsiveTuiProviderError;
107
107
  }
108
108
  return breakpoint;
109
109
  };
110
- return { ResponsiveTUI, useResponsiveTui };
110
+ return { ResponsiveTUI, useBreakpoint };
111
111
  };
112
112
  export {
113
113
  ResponsiveTuiConfigurationError,
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "opentui-responsive",
3
- "version": "0.2.8",
3
+ "version": "0.3.1",
4
4
  "description": "Typed responsive breakpoints for OpenTUI.",
5
5
  "keywords": [
6
6
  "breakpoints",
7
+ "cli",
7
8
  "opentui",
8
9
  "reactjs",
9
10
  "responsive",
10
- "solidjs"
11
+ "solidjs",
12
+ "terminal",
13
+ "tui"
11
14
  ],
12
15
  "license": "MIT",
13
16
  "repository": {