@jigs.design/catalog 0.1.0 → 0.1.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.
@@ -1,7 +1,7 @@
1
1
  import { buttonColors, controlSizes, controlVariants, fieldVariants } from "../catalog.js";
2
2
  import { classes, isBoolean, isNumber, keyField, oneOf, textField } from "./props.js";
3
3
  import { Glyph, iconLabel } from "./icons.js";
4
- import { controlled, useLocalValue } from "./local-value.js";
4
+ import { controlled, useLocalValue } from "@jigs.design/react";
5
5
  import { ChevronDown, Minus, Plus, X } from "lucide-react";
6
6
  import { useId, useState } from "react";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jigs.design/catalog",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "The default catalog, modeled on ChatKit widgets, and a React registry for it.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -34,14 +34,14 @@
34
34
  "dependencies": {
35
35
  "lucide-react": "1.57.0",
36
36
  "recharts": "3.10.1",
37
- "@jigs.design/react": "0.1.0",
38
- "@jigs.design/host": "0.1.0"
37
+ "@jigs.design/host": "0.1.1",
38
+ "@jigs.design/react": "0.1.1"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": "^18.0.0 || ^19.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@jigs.design/prompt": "0.1.0",
45
- "@jigs.design/server": "0.1.0"
44
+ "@jigs.design/prompt": "0.1.1",
45
+ "@jigs.design/server": "0.1.1"
46
46
  }
47
47
  }
@@ -1,47 +0,0 @@
1
- import { useState } from "react";
2
- import { useHandlerSettled } from "@jigs.design/react";
3
- //#region src/react/local-value.ts
4
- /**
5
- * Whether the program controls a control's value: it sets the value prop
6
- * (`value`, or `checked`) and handles `onChange`. A control with only
7
- * `onChange` is uncontrolled, like a React input without `value`: the
8
- * program hears each edit but the control keeps what the user did.
9
- */
10
- const controlled = (value, onChange) => value !== void 0 && onChange !== void 0;
11
- /**
12
- * A local copy of a value the program owns, so a control can run ahead of the
13
- * round trip to the sandbox. Pass `echoes` when the program controls the
14
- * value (`controlled`): echoes of the edits sent to it then don't reset the
15
- * control, but any other new value does, and so does an edit the program did
16
- * not take: once it has answered every call (`useHandlerSettled`) and `value`
17
- * is still not the edit, the control goes back to `value`. Without `echoes`,
18
- * the control keeps its own state until `value` changes.
19
- */
20
- function useLocalValue(value, echoes) {
21
- const settled = useHandlerSettled();
22
- const [local, setLocal] = useState(value);
23
- const [seen, setSeen] = useState(value);
24
- const [seenSettled, setSeenSettled] = useState(settled);
25
- const [pending, setPending] = useState([]);
26
- if (!Object.is(value, seen)) {
27
- setSeen(value);
28
- const echo = pending.findIndex((sent) => Object.is(sent, value));
29
- if (echo === -1) {
30
- setLocal(value);
31
- setPending([]);
32
- } else setPending(pending.slice(echo + 1));
33
- } else if (settled !== seenSettled) {
34
- setSeenSettled(settled);
35
- if (pending.length > 0) {
36
- setLocal(value);
37
- setPending([]);
38
- }
39
- }
40
- const edit = (next) => {
41
- setLocal(next);
42
- if (echoes) setPending([...pending.slice(-20), next]);
43
- };
44
- return [local, edit];
45
- }
46
- //#endregion
47
- export { controlled, useLocalValue };