react-store-input 0.5.0 → 0.6.0

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/CHANGELOG.md CHANGED
@@ -5,6 +5,16 @@ All notable changes to this project are documented in this file.
5
5
  The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project uses [Semantic Versioning](https://semver.org/).
7
7
 
8
+ ## [0.6.0] - 2026-08-10
9
+
10
+ ### Changed
11
+
12
+ - Replaced the optional `gw-react-text-editor` peer integration with
13
+ `gw-rich-text-editor@^0.1.4` and updated the text editor binding for its
14
+ current value callback API.
15
+ - The optional text editor integration now requires Node.js 20 or newer,
16
+ matching the new peer package.
17
+
8
18
  ## [0.5.0] - 2026-07-31
9
19
 
10
20
  ### Changed
package/README.md CHANGED
@@ -255,11 +255,11 @@ function Counter({ store }: { store: Store<{ count: number }> }) {
255
255
  ## Optional text editor
256
256
 
257
257
  The ProseMirror-based editor is a separate entry point so normal forms do not
258
- download or bundle editor dependencies. It requires React 19 and an explicit
259
- optional peer installation:
258
+ download or bundle editor dependencies. It requires React 19, Node.js 20 or
259
+ newer, and an explicit optional peer installation:
260
260
 
261
261
  ```sh
262
- npm install gw-react-text-editor
262
+ npm install gw-rich-text-editor
263
263
  ```
264
264
 
265
265
  ```tsx
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { TextEditorProps as TextEditorProps$1 } from 'gw-react-text-editor';
2
+ import { TextEditorProps as TextEditorProps$1 } from 'gw-rich-text-editor';
3
3
  import { Store } from 'gw-store';
4
4
 
5
5
  type TextEditorProps<TState extends object> = Omit<TextEditorProps$1, "name"> & {
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { TextEditorProps as TextEditorProps$1 } from 'gw-react-text-editor';
2
+ import { TextEditorProps as TextEditorProps$1 } from 'gw-rich-text-editor';
3
3
  import { Store } from 'gw-store';
4
4
 
5
5
  type TextEditorProps<TState extends object> = Omit<TextEditorProps$1, "name"> & {
@@ -25,7 +25,7 @@ __export(text_editor_exports, {
25
25
  module.exports = __toCommonJS(text_editor_exports);
26
26
 
27
27
  // src/editor/text_editor.tsx
28
- var import_gw_react_text_editor = require("gw-react-text-editor");
28
+ var import_gw_rich_text_editor = require("gw-rich-text-editor");
29
29
  var import_gw_result = require("gw-result");
30
30
  var import_react2 = require("react");
31
31
 
@@ -183,15 +183,15 @@ function TextEditor({
183
183
  }
184
184
  });
185
185
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
186
- import_gw_react_text_editor.TextEditor,
186
+ import_gw_rich_text_editor.TextEditor,
187
187
  {
188
188
  ...props,
189
189
  ref: controllerRef,
190
190
  name: String(name),
191
191
  defaultValue: defaultValue ?? initialValue,
192
- onChange: (event) => {
193
- commit(controllerRef.current?.value ?? "");
194
- props.onChange?.(event);
192
+ onChange: (value) => {
193
+ commit(value);
194
+ props.onChange?.(value);
195
195
  }
196
196
  }
197
197
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/text_editor.tsx","../src/editor/text_editor.tsx","../src/binding/binding.ts","../src/binding/codec.ts","../src/binding/lens.ts","../src/binding/use_store_binding.tsx"],"sourcesContent":["export * from \"./editor/text_editor\";\n","import {\n TextEditor as GwTextEditor,\n TextEditorController,\n type TextEditorProps as GwTextEditorProps,\n} from \"gw-react-text-editor\";\nimport { ok } from \"gw-result\";\nimport { useImperativeHandle, useMemo, useRef } from \"react\";\nimport type { Store } from \"gw-store\";\nimport { defineBinding } from \"../binding/binding\";\nimport { defineCodec } from \"../binding/codec\";\nimport { stateLens } from \"../binding/lens\";\nimport { useStoreBinding } from \"../binding/use_store_binding\";\n\nexport type TextEditorProps<TState extends object> = Omit<GwTextEditorProps, \"name\"> & {\n store: Store<TState>;\n name: keyof TState;\n};\n\nexport function TextEditor<TState extends object>({\n store,\n name,\n defaultValue,\n ref,\n ...props\n}: TextEditorProps<TState>) {\n const controllerRef = useRef<TextEditorController>(null);\n\n useImperativeHandle(ref, () => controllerRef.current as TextEditorController, []);\n\n const binding = useMemo(() => {\n type TValue = TState[typeof name];\n return defineBinding({\n lens: stateLens<TState>().prop(name),\n codec: defineCodec<TValue, string>({\n format: (value) => (typeof value === \"string\" ? value : \"\"),\n parse: (value) => ok(value as TValue),\n }),\n });\n }, [name]);\n\n const { commit, initialValue } = useStoreBinding(store, binding, {\n onStoreChange: (value) => {\n const controller = controllerRef.current;\n\n if (controller && controller.value !== value) {\n controller.value = value;\n }\n },\n });\n\n return (\n <GwTextEditor\n {...props}\n ref={controllerRef}\n name={String(name)}\n defaultValue={defaultValue ?? initialValue}\n onChange={(event) => {\n commit(controllerRef.current?.value ?? \"\");\n props.onChange?.(event);\n }}\n />\n );\n}\n","import type { Codec } from \"./codec\";\nimport type { Lens } from \"./lens\";\n\nexport type InputBinding<TState extends object, TValue, TInput, TError = never> = {\n lens: Lens<TState, TValue>;\n codec: Codec<TValue, TInput, TError>;\n};\n\nexport function defineBinding<TState extends object, TValue, TInput, TError = never>(\n binding: InputBinding<TState, TValue, TInput, TError>,\n) {\n return binding;\n}\n","import type { Result } from \"gw-result\";\n\nexport type Codec<TValue, TInput, TError = never> = {\n format: (value: TValue) => TInput;\n parse: (input: TInput) => Result<TValue, TError>;\n equals?: (previous: TValue, next: TValue) => boolean;\n};\n\nexport function defineCodec<TValue, TInput, TError = never>(codec: Codec<TValue, TInput, TError>) {\n return codec;\n}\n","import type { Draft, Immutable } from \"immer\";\n\nexport type Lens<TState extends object, TValue> = {\n get: (state: Immutable<TState>) => TValue;\n set: (state: Draft<TState>, value: TValue) => void;\n};\n\nexport type LensBuilder<TState extends object, TValue> = Lens<TState, TValue> &\n (TValue extends object\n ? {\n prop<TKey extends keyof TValue>(key: TKey): LensBuilder<TState, TValue[TKey]>;\n }\n : object);\n\nexport type StateLens<TState extends object> = {\n prop<TKey extends keyof TState>(key: TKey): LensBuilder<TState, TState[TKey]>;\n};\n\nexport function defineLens<TState extends object, TValue>(lens: Lens<TState, TValue>) {\n return lens;\n}\n\nfunction readPath(value: unknown, path: readonly PropertyKey[]) {\n return path.reduce<unknown>((current, key) => (current as Record<PropertyKey, unknown>)[key], value);\n}\n\nfunction writePath(state: unknown, path: readonly PropertyKey[], value: unknown) {\n const parent = path\n .slice(0, -1)\n .reduce<\n Record<PropertyKey, unknown>\n >((current, key) => current[key] as Record<PropertyKey, unknown>, state as Record<PropertyKey, unknown>);\n parent[path.at(-1) as PropertyKey] = value;\n}\n\nfunction createPathLens<TState extends object, TValue>(path: readonly PropertyKey[]): LensBuilder<TState, TValue> {\n return {\n get: (state: Immutable<TState>) => readPath(state, path) as TValue,\n set: (state: Draft<TState>, value: TValue) => writePath(state, path, value),\n prop: (key: PropertyKey) => createPathLens([...path, key]),\n } as unknown as LensBuilder<TState, TValue>;\n}\n\nexport function stateLens<TState extends object>(): StateLens<TState> {\n return {\n prop: (key) => createPathLens<TState, TState[typeof key]>([key]),\n };\n}\n","import { useCallback, useEffect, useId, useRef, useState } from \"react\";\nimport type { Immutable } from \"immer\";\nimport type { Result } from \"gw-result\";\nimport type { Store } from \"gw-store\";\nimport type { InputBinding } from \"./binding\";\n\nexport type StoreBindingMeta<TError> = { valid: true; error?: never } | { valid: false; error: TError };\n\nexport type StoreBindingOptions<TValue, TInput> = {\n onStoreChange?: (input: TInput, value: TValue) => void;\n};\n\nexport type StoreBindingResult<TValue, TInput, TError> = {\n initialValue: TInput;\n meta: StoreBindingMeta<TError>;\n commit: (input: TInput) => Result<TValue, TError>;\n reset: (value: TValue) => void;\n};\n\nfunction equalStoreValue(previous: unknown, next: unknown) {\n if (Object.is(previous, next)) {\n return true;\n }\n\n if (previous instanceof Date && next instanceof Date) {\n return Object.is(previous.getTime(), next.getTime());\n }\n\n if (Array.isArray(previous) && Array.isArray(next)) {\n return previous.length === next.length && previous.every((value, index) => Object.is(value, next[index]));\n }\n\n return false;\n}\n\nexport function useStoreBinding<TState extends object, TValue, TInput, TError>(\n store: Store<TState>,\n binding: InputBinding<TState, TValue, TInput, TError>,\n options: StoreBindingOptions<TValue, TInput> = {},\n): StoreBindingResult<TValue, TInput, TError> {\n const dispatchKey = useId();\n const [initialValue] = useState(() => binding.codec.format(binding.lens.get(store.state)));\n const [meta, setMeta] = useState<StoreBindingMeta<TError>>({ valid: true });\n const metaRef = useRef<StoreBindingMeta<TError>>(meta);\n const optionsRef = useRef(options);\n const subscribedStoreRef = useRef<Store<TState> | null>(null);\n const subscribedBindingRef = useRef(binding);\n\n useEffect(() => {\n optionsRef.current = options;\n }, [options]);\n\n useEffect(() => {\n const isReplacement =\n subscribedStoreRef.current !== null &&\n (subscribedStoreRef.current !== store || subscribedBindingRef.current !== binding);\n\n subscribedStoreRef.current = store;\n subscribedBindingRef.current = binding;\n\n const sync = (state: Immutable<TState>) => {\n if (!metaRef.current.valid) {\n return;\n }\n\n const value = binding.lens.get(state);\n optionsRef.current.onStoreChange?.(binding.codec.format(value), value);\n };\n\n const unsubscribe = store.subscribe((state, key) => {\n if (key !== dispatchKey) {\n sync(state);\n }\n });\n\n if (isReplacement) {\n sync(store.state);\n }\n\n return unsubscribe;\n }, [binding, dispatchKey, store]);\n\n const setValue = useCallback(\n (value: TValue) => {\n const currentValue = binding.lens.get(store.state);\n const equals = binding.codec.equals ?? equalStoreValue;\n\n if (equals(currentValue, value)) {\n return;\n }\n\n store.dispatch((state) => binding.lens.set(state, value), { key: dispatchKey });\n },\n [binding, dispatchKey, store],\n );\n\n const commit = useCallback(\n (input: TInput) => {\n const result = binding.codec.parse(input);\n\n if (result.isErr) {\n const invalidMeta: StoreBindingMeta<TError> = {\n valid: false,\n error: result.error,\n };\n metaRef.current = invalidMeta;\n setMeta(invalidMeta);\n return result;\n }\n\n const validMeta: StoreBindingMeta<TError> = { valid: true };\n metaRef.current = validMeta;\n setMeta((current) => (current.valid ? current : validMeta));\n setValue(result.value);\n return result;\n },\n [binding, setValue],\n );\n\n const reset = useCallback(\n (value: TValue) => {\n const validMeta: StoreBindingMeta<TError> = { valid: true };\n metaRef.current = validMeta;\n setMeta((current) => (current.valid ? current : validMeta));\n setValue(value);\n },\n [setValue],\n );\n\n return {\n initialValue,\n meta,\n commit,\n reset,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kCAIO;AACP,uBAAmB;AACnB,IAAAA,gBAAqD;;;ACE9C,SAAS,cACd,SACA;AACA,SAAO;AACT;;;ACJO,SAAS,YAA4C,OAAsC;AAChG,SAAO;AACT;;;ACYA,SAAS,SAAS,OAAgB,MAA8B;AAC9D,SAAO,KAAK,OAAgB,CAAC,SAAS,QAAS,QAAyC,GAAG,GAAG,KAAK;AACrG;AAEA,SAAS,UAAU,OAAgB,MAA8B,OAAgB;AAC/E,QAAM,SAAS,KACZ,MAAM,GAAG,EAAE,EACX,OAEC,CAAC,SAAS,QAAQ,QAAQ,GAAG,GAAmC,KAAqC;AACzG,SAAO,KAAK,GAAG,EAAE,CAAgB,IAAI;AACvC;AAEA,SAAS,eAA8C,MAA2D;AAChH,SAAO;AAAA,IACL,KAAK,CAAC,UAA6B,SAAS,OAAO,IAAI;AAAA,IACvD,KAAK,CAAC,OAAsB,UAAkB,UAAU,OAAO,MAAM,KAAK;AAAA,IAC1E,MAAM,CAAC,QAAqB,eAAe,CAAC,GAAG,MAAM,GAAG,CAAC;AAAA,EAC3D;AACF;AAEO,SAAS,YAAsD;AACpE,SAAO;AAAA,IACL,MAAM,CAAC,QAAQ,eAA2C,CAAC,GAAG,CAAC;AAAA,EACjE;AACF;;;AC/CA,mBAAgE;AAmBhE,SAAS,gBAAgB,UAAmB,MAAe;AACzD,MAAI,OAAO,GAAG,UAAU,IAAI,GAAG;AAC7B,WAAO;AAAA,EACT;AAEA,MAAI,oBAAoB,QAAQ,gBAAgB,MAAM;AACpD,WAAO,OAAO,GAAG,SAAS,QAAQ,GAAG,KAAK,QAAQ,CAAC;AAAA,EACrD;AAEA,MAAI,MA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,MAAM,cAAc,SAAiC,CAAC,CAAC;AAEhF,QAAM,cAAU,uBAAQ,MAAM;AAE5B,WAAO,cAAc;AAAA,MACnB,MAAM,UAAkB,EAAE,KAAK,IAAI;AAAA,MACnC,OAAO,YAA4B;AAAA,QACjC,QAAQ,CAAC,UAAW,OAAO,UAAU,WAAW,QAAQ;AAAA,QACxD,OAAO,CAAC,cAAU,qBAAG,KAAe;AAAA,MACtC,CAAC;AAAA,IACH,CAAC;AAAA,EACH,GAAG,CAAC,IAAI,CAAC;AAET,QAAM,EAAE,QAAQ,aAAa,IAAI,gBAAgB,OAAO,SAAS;AAAA,IAC/D,eAAe,CAAC,UAAU;AACxB,YAAM,aAAa,cAAc;AAEjC,UAAI,cAAc,WAAW,UAAU,OAAO;AAC5C,mBAAW,QAAQ;AAAA,MACrB;AAAA,IACF;AAAA,EACF,CAAC;AAED,SACE;AAAA,IAAC,4BAAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,KAAK;AAAA,MACL,MAAM,OAAO,IAAI;AAAA,MACjB,cAAc,gBAAgB;AAAA,MAC9B,UAAU,CAAC,UAAU;AACnB,eAAO,cAAc,SAAS,SAAS,EAAE;AACzC,cAAM,WAAW,KAAK;AAAA,MACxB;AAAA;AAAA,EACF;AAEJ;","names":["import_react","GwTextEditor"]}
1
+ {"version":3,"sources":["../src/text_editor.tsx","../src/editor/text_editor.tsx","../src/binding/binding.ts","../src/binding/codec.ts","../src/binding/lens.ts","../src/binding/use_store_binding.tsx"],"sourcesContent":["export * from \"./editor/text_editor\";\n","import {\n TextEditor as GwTextEditor,\n TextEditorController,\n type TextEditorProps as GwTextEditorProps,\n} from \"gw-rich-text-editor\";\nimport { ok } from \"gw-result\";\nimport { useImperativeHandle, useMemo, useRef } from \"react\";\nimport type { Store } from \"gw-store\";\nimport { defineBinding } from \"../binding/binding\";\nimport { defineCodec } from \"../binding/codec\";\nimport { stateLens } from \"../binding/lens\";\nimport { useStoreBinding } from \"../binding/use_store_binding\";\n\nexport type TextEditorProps<TState extends object> = Omit<GwTextEditorProps, \"name\"> & {\n store: Store<TState>;\n name: keyof TState;\n};\n\nexport function TextEditor<TState extends object>({\n store,\n name,\n defaultValue,\n ref,\n ...props\n}: TextEditorProps<TState>) {\n const controllerRef = useRef<TextEditorController>(null);\n\n useImperativeHandle(ref, () => controllerRef.current as TextEditorController, []);\n\n const binding = useMemo(() => {\n type TValue = TState[typeof name];\n return defineBinding({\n lens: stateLens<TState>().prop(name),\n codec: defineCodec<TValue, string>({\n format: (value) => (typeof value === \"string\" ? value : \"\"),\n parse: (value) => ok(value as TValue),\n }),\n });\n }, [name]);\n\n const { commit, initialValue } = useStoreBinding(store, binding, {\n onStoreChange: (value) => {\n const controller = controllerRef.current;\n\n if (controller && controller.value !== value) {\n controller.value = value;\n }\n },\n });\n\n return (\n <GwTextEditor\n {...props}\n ref={controllerRef}\n name={String(name)}\n defaultValue={defaultValue ?? initialValue}\n onChange={(value) => {\n commit(value);\n props.onChange?.(value);\n }}\n />\n );\n}\n","import type { Codec } from \"./codec\";\nimport type { Lens } from \"./lens\";\n\nexport type InputBinding<TState extends object, TValue, TInput, TError = never> = {\n lens: Lens<TState, TValue>;\n codec: Codec<TValue, TInput, TError>;\n};\n\nexport function defineBinding<TState extends object, TValue, TInput, TError = never>(\n binding: InputBinding<TState, TValue, TInput, TError>,\n) {\n return binding;\n}\n","import type { Result } from \"gw-result\";\n\nexport type Codec<TValue, TInput, TError = never> = {\n format: (value: TValue) => TInput;\n parse: (input: TInput) => Result<TValue, TError>;\n equals?: (previous: TValue, next: TValue) => boolean;\n};\n\nexport function defineCodec<TValue, TInput, TError = never>(codec: Codec<TValue, TInput, TError>) {\n return codec;\n}\n","import type { Draft, Immutable } from \"immer\";\n\nexport type Lens<TState extends object, TValue> = {\n get: (state: Immutable<TState>) => TValue;\n set: (state: Draft<TState>, value: TValue) => void;\n};\n\nexport type LensBuilder<TState extends object, TValue> = Lens<TState, TValue> &\n (TValue extends object\n ? {\n prop<TKey extends keyof TValue>(key: TKey): LensBuilder<TState, TValue[TKey]>;\n }\n : object);\n\nexport type StateLens<TState extends object> = {\n prop<TKey extends keyof TState>(key: TKey): LensBuilder<TState, TState[TKey]>;\n};\n\nexport function defineLens<TState extends object, TValue>(lens: Lens<TState, TValue>) {\n return lens;\n}\n\nfunction readPath(value: unknown, path: readonly PropertyKey[]) {\n return path.reduce<unknown>((current, key) => (current as Record<PropertyKey, unknown>)[key], value);\n}\n\nfunction writePath(state: unknown, path: readonly PropertyKey[], value: unknown) {\n const parent = path\n .slice(0, -1)\n .reduce<\n Record<PropertyKey, unknown>\n >((current, key) => current[key] as Record<PropertyKey, unknown>, state as Record<PropertyKey, unknown>);\n parent[path.at(-1) as PropertyKey] = value;\n}\n\nfunction createPathLens<TState extends object, TValue>(path: readonly PropertyKey[]): LensBuilder<TState, TValue> {\n return {\n get: (state: Immutable<TState>) => readPath(state, path) as TValue,\n set: (state: Draft<TState>, value: TValue) => writePath(state, path, value),\n prop: (key: PropertyKey) => createPathLens([...path, key]),\n } as unknown as LensBuilder<TState, TValue>;\n}\n\nexport function stateLens<TState extends object>(): StateLens<TState> {\n return {\n prop: (key) => createPathLens<TState, TState[typeof key]>([key]),\n };\n}\n","import { useCallback, useEffect, useId, useRef, useState } from \"react\";\nimport type { Immutable } from \"immer\";\nimport type { Result } from \"gw-result\";\nimport type { Store } from \"gw-store\";\nimport type { InputBinding } from \"./binding\";\n\nexport type StoreBindingMeta<TError> = { valid: true; error?: never } | { valid: false; error: TError };\n\nexport type StoreBindingOptions<TValue, TInput> = {\n onStoreChange?: (input: TInput, value: TValue) => void;\n};\n\nexport type StoreBindingResult<TValue, TInput, TError> = {\n initialValue: TInput;\n meta: StoreBindingMeta<TError>;\n commit: (input: TInput) => Result<TValue, TError>;\n reset: (value: TValue) => void;\n};\n\nfunction equalStoreValue(previous: unknown, next: unknown) {\n if (Object.is(previous, next)) {\n return true;\n }\n\n if (previous instanceof Date && next instanceof Date) {\n return Object.is(previous.getTime(), next.getTime());\n }\n\n if (Array.isArray(previous) && Array.isArray(next)) {\n return previous.length === next.length && previous.every((value, index) => Object.is(value, next[index]));\n }\n\n return false;\n}\n\nexport function useStoreBinding<TState extends object, TValue, TInput, TError>(\n store: Store<TState>,\n binding: InputBinding<TState, TValue, TInput, TError>,\n options: StoreBindingOptions<TValue, TInput> = {},\n): StoreBindingResult<TValue, TInput, TError> {\n const dispatchKey = useId();\n const [initialValue] = useState(() => binding.codec.format(binding.lens.get(store.state)));\n const [meta, setMeta] = useState<StoreBindingMeta<TError>>({ valid: true });\n const metaRef = useRef<StoreBindingMeta<TError>>(meta);\n const optionsRef = useRef(options);\n const subscribedStoreRef = useRef<Store<TState> | null>(null);\n const subscribedBindingRef = useRef(binding);\n\n useEffect(() => {\n optionsRef.current = options;\n }, [options]);\n\n useEffect(() => {\n const isReplacement =\n subscribedStoreRef.current !== null &&\n (subscribedStoreRef.current !== store || subscribedBindingRef.current !== binding);\n\n subscribedStoreRef.current = store;\n subscribedBindingRef.current = binding;\n\n const sync = (state: Immutable<TState>) => {\n if (!metaRef.current.valid) {\n return;\n }\n\n const value = binding.lens.get(state);\n optionsRef.current.onStoreChange?.(binding.codec.format(value), value);\n };\n\n const unsubscribe = store.subscribe((state, key) => {\n if (key !== dispatchKey) {\n sync(state);\n }\n });\n\n if (isReplacement) {\n sync(store.state);\n }\n\n return unsubscribe;\n }, [binding, dispatchKey, store]);\n\n const setValue = useCallback(\n (value: TValue) => {\n const currentValue = binding.lens.get(store.state);\n const equals = binding.codec.equals ?? equalStoreValue;\n\n if (equals(currentValue, value)) {\n return;\n }\n\n store.dispatch((state) => binding.lens.set(state, value), { key: dispatchKey });\n },\n [binding, dispatchKey, store],\n );\n\n const commit = useCallback(\n (input: TInput) => {\n const result = binding.codec.parse(input);\n\n if (result.isErr) {\n const invalidMeta: StoreBindingMeta<TError> = {\n valid: false,\n error: result.error,\n };\n metaRef.current = invalidMeta;\n setMeta(invalidMeta);\n return result;\n }\n\n const validMeta: StoreBindingMeta<TError> = { valid: true };\n metaRef.current = validMeta;\n setMeta((current) => (current.valid ? current : validMeta));\n setValue(result.value);\n return result;\n },\n [binding, setValue],\n );\n\n const reset = useCallback(\n (value: TValue) => {\n const validMeta: StoreBindingMeta<TError> = { valid: true };\n metaRef.current = validMeta;\n setMeta((current) => (current.valid ? current : validMeta));\n setValue(value);\n },\n [setValue],\n );\n\n return {\n initialValue,\n meta,\n commit,\n reset,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iCAIO;AACP,uBAAmB;AACnB,IAAAA,gBAAqD;;;ACE9C,SAAS,cACd,SACA;AACA,SAAO;AACT;;;ACJO,SAAS,YAA4C,OAAsC;AAChG,SAAO;AACT;;;ACYA,SAAS,SAAS,OAAgB,MAA8B;AAC9D,SAAO,KAAK,OAAgB,CAAC,SAAS,QAAS,QAAyC,GAAG,GAAG,KAAK;AACrG;AAEA,SAAS,UAAU,OAAgB,MAA8B,OAAgB;AAC/E,QAAM,SAAS,KACZ,MAAM,GAAG,EAAE,EACX,OAEC,CAAC,SAAS,QAAQ,QAAQ,GAAG,GAAmC,KAAqC;AACzG,SAAO,KAAK,GAAG,EAAE,CAAgB,IAAI;AACvC;AAEA,SAAS,eAA8C,MAA2D;AAChH,SAAO;AAAA,IACL,KAAK,CAAC,UAA6B,SAAS,OAAO,IAAI;AAAA,IACvD,KAAK,CAAC,OAAsB,UAAkB,UAAU,OAAO,MAAM,KAAK;AAAA,IAC1E,MAAM,CAAC,QAAqB,eAAe,CAAC,GAAG,MAAM,GAAG,CAAC;AAAA,EAC3D;AACF;AAEO,SAAS,YAAsD;AACpE,SAAO;AAAA,IACL,MAAM,CAAC,QAAQ,eAA2C,CAAC,GAAG,CAAC;AAAA,EACjE;AACF;;;AC/CA,mBAAgE;AAmBhE,SAAS,gBAAgB,UAAmB,MAAe;AACzD,MAAI,OAAO,GAAG,UAAU,IAAI,GAAG;AAC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;AAjCG,SAAS,WAAkC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAA4B;AAC1B,QAAM,oBAAgB,sBAA6B,IAAI;AAEvD,yCAAoB,KAAK,MAAM,cAAc,SAAiC,CAAC,CAAC;AAEhF,QAAM,cAAU,uBAAQ,MAAM;AAE5B,WAAO,cAAc;AAAA,MACnB,MAAM,UAAkB,EAAE,KAAK,IAAI;AAAA,MACnC,OAAO,YAA4B;AAAA,QACjC,QAAQ,CAAC,UAAW,OAAO,UAAU,WAAW,QAAQ;AAAA,QACxD,OAAO,CAAC,cAAU,qBAAG,KAAe;AAAA,MACtC,CAAC;AAAA,IACH,CAAC;AAAA,EACH,GAAG,CAAC,IAAI,CAAC;AAET,QAAM,EAAE,QAAQ,aAAa,IAAI,gBAAgB,OAAO,SAAS;AAAA,IAC/D,eAAe,CAAC,UAAU;AACxB,YAAM,aAAa,cAAc;AAEjC,UAAI,cAAc,WAAW,UAAU,OAAO;AAC5C,mBAAW,QAAQ;AAAA,MACrB;AAAA,IACF;AAAA,EACF,CAAC;AAED,SACE;AAAA,IAAC,2BAAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,KAAK;AAAA,MACL,MAAM,OAAO,IAAI;AAAA,MACjB,cAAc,gBAAgB;AAAA,MAC9B,UAAU,CAAC,UAAU;AACnB,eAAO,KAAK;AACZ,cAAM,WAAW,KAAK;AAAA,MACxB;AAAA;AAAA,EACF;AAEJ;","names":["import_react","GwTextEditor"]}
@@ -1,7 +1,7 @@
1
1
  // src/editor/text_editor.tsx
2
2
  import {
3
3
  TextEditor as GwTextEditor
4
- } from "gw-react-text-editor";
4
+ } from "gw-rich-text-editor";
5
5
  import { ok } from "gw-result";
6
6
  import { useImperativeHandle, useMemo, useRef as useRef2 } from "react";
7
7
 
@@ -165,9 +165,9 @@ function TextEditor({
165
165
  ref: controllerRef,
166
166
  name: String(name),
167
167
  defaultValue: defaultValue ?? initialValue,
168
- onChange: (event) => {
169
- commit(controllerRef.current?.value ?? "");
170
- props.onChange?.(event);
168
+ onChange: (value) => {
169
+ commit(value);
170
+ props.onChange?.(value);
171
171
  }
172
172
  }
173
173
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/editor/text_editor.tsx","../src/binding/binding.ts","../src/binding/codec.ts","../src/binding/lens.ts","../src/binding/use_store_binding.tsx"],"sourcesContent":["import {\n TextEditor as GwTextEditor,\n TextEditorController,\n type TextEditorProps as GwTextEditorProps,\n} from \"gw-react-text-editor\";\nimport { ok } from \"gw-result\";\nimport { useImperativeHandle, useMemo, useRef } from \"react\";\nimport type { Store } from \"gw-store\";\nimport { defineBinding } from \"../binding/binding\";\nimport { defineCodec } from \"../binding/codec\";\nimport { stateLens } from \"../binding/lens\";\nimport { useStoreBinding } from \"../binding/use_store_binding\";\n\nexport type TextEditorProps<TState extends object> = Omit<GwTextEditorProps, \"name\"> & {\n store: Store<TState>;\n name: keyof TState;\n};\n\nexport function TextEditor<TState extends object>({\n store,\n name,\n defaultValue,\n ref,\n ...props\n}: TextEditorProps<TState>) {\n const controllerRef = useRef<TextEditorController>(null);\n\n useImperativeHandle(ref, () => controllerRef.current as TextEditorController, []);\n\n const binding = useMemo(() => {\n type TValue = TState[typeof name];\n return defineBinding({\n lens: stateLens<TState>().prop(name),\n codec: defineCodec<TValue, string>({\n format: (value) => (typeof value === \"string\" ? value : \"\"),\n parse: (value) => ok(value as TValue),\n }),\n });\n }, [name]);\n\n const { commit, initialValue } = useStoreBinding(store, binding, {\n onStoreChange: (value) => {\n const controller = controllerRef.current;\n\n if (controller && controller.value !== value) {\n controller.value = value;\n }\n },\n });\n\n return (\n <GwTextEditor\n {...props}\n ref={controllerRef}\n name={String(name)}\n defaultValue={defaultValue ?? initialValue}\n onChange={(event) => {\n commit(controllerRef.current?.value ?? \"\");\n props.onChange?.(event);\n }}\n />\n );\n}\n","import type { Codec } from \"./codec\";\nimport type { Lens } from \"./lens\";\n\nexport type InputBinding<TState extends object, TValue, TInput, TError = never> = {\n lens: Lens<TState, TValue>;\n codec: Codec<TValue, TInput, TError>;\n};\n\nexport function defineBinding<TState extends object, TValue, TInput, TError = never>(\n binding: InputBinding<TState, TValue, TInput, TError>,\n) {\n return binding;\n}\n","import type { Result } from \"gw-result\";\n\nexport type Codec<TValue, TInput, TError = never> = {\n format: (value: TValue) => TInput;\n parse: (input: TInput) => Result<TValue, TError>;\n equals?: (previous: TValue, next: TValue) => boolean;\n};\n\nexport function defineCodec<TValue, TInput, TError = never>(codec: Codec<TValue, TInput, TError>) {\n return codec;\n}\n","import type { Draft, Immutable } from \"immer\";\n\nexport type Lens<TState extends object, TValue> = {\n get: (state: Immutable<TState>) => TValue;\n set: (state: Draft<TState>, value: TValue) => void;\n};\n\nexport type LensBuilder<TState extends object, TValue> = Lens<TState, TValue> &\n (TValue extends object\n ? {\n prop<TKey extends keyof TValue>(key: TKey): LensBuilder<TState, TValue[TKey]>;\n }\n : object);\n\nexport type StateLens<TState extends object> = {\n prop<TKey extends keyof TState>(key: TKey): LensBuilder<TState, TState[TKey]>;\n};\n\nexport function defineLens<TState extends object, TValue>(lens: Lens<TState, TValue>) {\n return lens;\n}\n\nfunction readPath(value: unknown, path: readonly PropertyKey[]) {\n return path.reduce<unknown>((current, key) => (current as Record<PropertyKey, unknown>)[key], value);\n}\n\nfunction writePath(state: unknown, path: readonly PropertyKey[], value: unknown) {\n const parent = path\n .slice(0, -1)\n .reduce<\n Record<PropertyKey, unknown>\n >((current, key) => current[key] as Record<PropertyKey, unknown>, state as Record<PropertyKey, unknown>);\n parent[path.at(-1) as PropertyKey] = value;\n}\n\nfunction createPathLens<TState extends object, TValue>(path: readonly PropertyKey[]): LensBuilder<TState, TValue> {\n return {\n get: (state: Immutable<TState>) => readPath(state, path) as TValue,\n set: (state: Draft<TState>, value: TValue) => writePath(state, path, value),\n prop: (key: PropertyKey) => createPathLens([...path, key]),\n } as unknown as LensBuilder<TState, TValue>;\n}\n\nexport function stateLens<TState extends object>(): StateLens<TState> {\n return {\n prop: (key) => createPathLens<TState, TState[typeof key]>([key]),\n };\n}\n","import { useCallback, useEffect, useId, useRef, useState } from \"react\";\nimport type { Immutable } from \"immer\";\nimport type { Result } from \"gw-result\";\nimport type { Store } from \"gw-store\";\nimport type { InputBinding } from \"./binding\";\n\nexport type StoreBindingMeta<TError> = { valid: true; error?: never } | { valid: false; error: TError };\n\nexport type StoreBindingOptions<TValue, TInput> = {\n onStoreChange?: (input: TInput, value: TValue) => void;\n};\n\nexport type StoreBindingResult<TValue, TInput, TError> = {\n initialValue: TInput;\n meta: StoreBindingMeta<TError>;\n commit: (input: TInput) => Result<TValue, TError>;\n reset: (value: TValue) => void;\n};\n\nfunction equalStoreValue(previous: unknown, next: unknown) {\n if (Object.is(previous, next)) {\n return true;\n }\n\n if (previous instanceof Date && next instanceof Date) {\n return Object.is(previous.getTime(), next.getTime());\n }\n\n if (Array.isArray(previous) && Array.isArray(next)) {\n return previous.length === next.length && previous.every((value, index) => Object.is(value, next[index]));\n }\n\n return false;\n}\n\nexport function useStoreBinding<TState extends object, TValue, TInput, TError>(\n store: Store<TState>,\n binding: InputBinding<TState, TValue, TInput, TError>,\n options: StoreBindingOptions<TValue, TInput> = {},\n): StoreBindingResult<TValue, TInput, TError> {\n const dispatchKey = useId();\n const [initialValue] = useState(() => binding.codec.format(binding.lens.get(store.state)));\n const [meta, setMeta] = useState<StoreBindingMeta<TError>>({ valid: true });\n const metaRef = useRef<StoreBindingMeta<TError>>(meta);\n const optionsRef = useRef(options);\n const subscribedStoreRef = useRef<Store<TState> | null>(null);\n const subscribedBindingRef = useRef(binding);\n\n useEffect(() => {\n optionsRef.current = options;\n }, [options]);\n\n useEffect(() => {\n const isReplacement =\n subscribedStoreRef.current !== null &&\n (subscribedStoreRef.current !== store || subscribedBindingRef.current !== binding);\n\n subscribedStoreRef.current = store;\n subscribedBindingRef.current = binding;\n\n const sync = (state: Immutable<TState>) => {\n if (!metaRef.current.valid) {\n return;\n }\n\n const value = binding.lens.get(state);\n optionsRef.current.onStoreChange?.(binding.codec.format(value), value);\n };\n\n const unsubscribe = store.subscribe((state, key) => {\n if (key !== dispatchKey) {\n sync(state);\n }\n });\n\n if (isReplacement) {\n sync(store.state);\n }\n\n return unsubscribe;\n }, [binding, dispatchKey, store]);\n\n const setValue = useCallback(\n (value: TValue) => {\n const currentValue = binding.lens.get(store.state);\n const equals = binding.codec.equals ?? equalStoreValue;\n\n if (equals(currentValue, value)) {\n return;\n }\n\n store.dispatch((state) => binding.lens.set(state, value), { key: dispatchKey });\n },\n [binding, dispatchKey, store],\n );\n\n const commit = useCallback(\n (input: TInput) => {\n const result = binding.codec.parse(input);\n\n if (result.isErr) {\n const invalidMeta: StoreBindingMeta<TError> = {\n valid: false,\n error: result.error,\n };\n metaRef.current = invalidMeta;\n setMeta(invalidMeta);\n return result;\n }\n\n const validMeta: StoreBindingMeta<TError> = { valid: true };\n metaRef.current = validMeta;\n setMeta((current) => (current.valid ? current : validMeta));\n setValue(result.value);\n return result;\n },\n [binding, setValue],\n );\n\n const reset = useCallback(\n (value: TValue) => {\n const validMeta: StoreBindingMeta<TError> = { valid: true };\n metaRef.current = validMeta;\n setMeta((current) => (current.valid ? current : validMeta));\n setValue(value);\n },\n [setValue],\n );\n\n return {\n initialValue,\n meta,\n commit,\n reset,\n };\n}\n"],"mappings":";AAAA;AAAA,EACE,cAAc;AAAA,OAGT;AACP,SAAS,UAAU;AACnB,SAAS,qBAAqB,SAAS,UAAAA,eAAc;;;ACE9C,SAAS,cACd,SACA;AACA,SAAO;AACT;;;ACJO,SAAS,YAA4C,OAAsC;AAChG,SAAO;AACT;;;ACYA,SAAS,SAAS,OAAgB,MAA8B;AAC9D,SAAO,KAAK,OAAgB,CAAC,SAAS,QAAS,QAAyC,GAAG,GAAG,KAAK;AACrG;AAEA,SAAS,UAAU,OAAgB,MAA8B,OAAgB;AAC/E,QAAM,SAAS,KACZ,MAAM,GAAG,EAAE,EACX,OAEC,CAAC,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AED,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,KAAK;AAAA,MACL,MAAM,OAAO,IAAI;AAAA,MACjB,cAAc,gBAAgB;AAAA,MAC9B,UAAU,CAAC,UAAU;AACnB,eAAO,cAAc,SAAS,SAAS,EAAE;AACzC,cAAM,WAAW,KAAK;AAAA,MACxB;AAAA;AAAA,EACF;AAEJ;","names":["useRef","useRef"]}
1
+ {"version":3,"sources":["../src/editor/text_editor.tsx","../src/binding/binding.ts","../src/binding/codec.ts","../src/binding/lens.ts","../src/binding/use_store_binding.tsx"],"sourcesContent":["import {\n TextEditor as GwTextEditor,\n TextEditorController,\n type TextEditorProps as GwTextEditorProps,\n} from \"gw-rich-text-editor\";\nimport { ok } from \"gw-result\";\nimport { useImperativeHandle, useMemo, useRef } from \"react\";\nimport type { Store } from \"gw-store\";\nimport { defineBinding } from \"../binding/binding\";\nimport { defineCodec } from \"../binding/codec\";\nimport { stateLens } from \"../binding/lens\";\nimport { useStoreBinding } from \"../binding/use_store_binding\";\n\nexport type TextEditorProps<TState extends object> = Omit<GwTextEditorProps, \"name\"> & {\n store: Store<TState>;\n name: keyof TState;\n};\n\nexport function TextEditor<TState extends object>({\n store,\n name,\n defaultValue,\n ref,\n ...props\n}: TextEditorProps<TState>) {\n const controllerRef = useRef<TextEditorController>(null);\n\n useImperativeHandle(ref, () => controllerRef.current as TextEditorController, []);\n\n const binding = useMemo(() => {\n type TValue = TState[typeof name];\n return defineBinding({\n lens: stateLens<TState>().prop(name),\n codec: defineCodec<TValue, string>({\n format: (value) => (typeof value === \"string\" ? value : \"\"),\n parse: (value) => ok(value as TValue),\n }),\n });\n }, [name]);\n\n const { commit, initialValue } = useStoreBinding(store, binding, {\n onStoreChange: (value) => {\n const controller = controllerRef.current;\n\n if (controller && controller.value !== value) {\n controller.value = value;\n }\n },\n });\n\n return (\n <GwTextEditor\n {...props}\n ref={controllerRef}\n name={String(name)}\n defaultValue={defaultValue ?? initialValue}\n onChange={(value) => {\n commit(value);\n props.onChange?.(value);\n }}\n />\n );\n}\n","import type { Codec } from \"./codec\";\nimport type { Lens } from \"./lens\";\n\nexport type InputBinding<TState extends object, TValue, TInput, TError = never> = {\n lens: Lens<TState, TValue>;\n codec: Codec<TValue, TInput, TError>;\n};\n\nexport function defineBinding<TState extends object, TValue, TInput, TError = never>(\n binding: InputBinding<TState, TValue, TInput, TError>,\n) {\n return binding;\n}\n","import type { Result } from \"gw-result\";\n\nexport type Codec<TValue, TInput, TError = never> = {\n format: (value: TValue) => TInput;\n parse: (input: TInput) => Result<TValue, TError>;\n equals?: (previous: TValue, next: TValue) => boolean;\n};\n\nexport function defineCodec<TValue, TInput, TError = never>(codec: Codec<TValue, TInput, TError>) {\n return codec;\n}\n","import type { Draft, Immutable } from \"immer\";\n\nexport type Lens<TState extends object, TValue> = {\n get: (state: Immutable<TState>) => TValue;\n set: (state: Draft<TState>, value: TValue) => void;\n};\n\nexport type LensBuilder<TState extends object, TValue> = Lens<TState, TValue> &\n (TValue extends object\n ? {\n prop<TKey extends keyof TValue>(key: TKey): LensBuilder<TState, TValue[TKey]>;\n }\n : object);\n\nexport type StateLens<TState extends object> = {\n prop<TKey extends keyof TState>(key: TKey): LensBuilder<TState, TState[TKey]>;\n};\n\nexport function defineLens<TState extends object, TValue>(lens: Lens<TState, TValue>) {\n return lens;\n}\n\nfunction readPath(value: unknown, path: readonly PropertyKey[]) {\n return path.reduce<unknown>((current, key) => (current as Record<PropertyKey, unknown>)[key], value);\n}\n\nfunction writePath(state: unknown, path: readonly PropertyKey[], value: unknown) {\n const parent = path\n .slice(0, -1)\n .reduce<\n Record<PropertyKey, unknown>\n >((current, key) => current[key] as Record<PropertyKey, unknown>, state as Record<PropertyKey, unknown>);\n parent[path.at(-1) as PropertyKey] = value;\n}\n\nfunction createPathLens<TState extends object, TValue>(path: readonly PropertyKey[]): LensBuilder<TState, TValue> {\n return {\n get: (state: Immutable<TState>) => readPath(state, path) as TValue,\n set: (state: Draft<TState>, value: TValue) => writePath(state, path, value),\n prop: (key: PropertyKey) => createPathLens([...path, key]),\n } as unknown as LensBuilder<TState, TValue>;\n}\n\nexport function stateLens<TState extends object>(): StateLens<TState> {\n return {\n prop: (key) => createPathLens<TState, TState[typeof key]>([key]),\n };\n}\n","import { useCallback, useEffect, useId, useRef, useState } from \"react\";\nimport type { Immutable } from \"immer\";\nimport type { Result } from \"gw-result\";\nimport type { Store } from \"gw-store\";\nimport type { InputBinding } from \"./binding\";\n\nexport type StoreBindingMeta<TError> = { valid: true; error?: never } | { valid: false; error: TError };\n\nexport type StoreBindingOptions<TValue, TInput> = {\n onStoreChange?: (input: TInput, value: TValue) => void;\n};\n\nexport type StoreBindingResult<TValue, TInput, TError> = {\n initialValue: TInput;\n meta: StoreBindingMeta<TError>;\n commit: (input: TInput) => Result<TValue, TError>;\n reset: (value: TValue) => void;\n};\n\nfunction equalStoreValue(previous: unknown, next: unknown) {\n if (Object.is(previous, next)) {\n return true;\n }\n\n if (previous instanceof Date && next instanceof Date) {\n return Object.is(previous.getTime(), next.getTime());\n }\n\n if (Array.isArray(previous) && Array.isArray(next)) {\n return previous.length === next.length && previous.every((value, index) => Object.is(value, next[index]));\n }\n\n return false;\n}\n\nexport function useStoreBinding<TState extends object, TValue, TInput, TError>(\n store: Store<TState>,\n binding: InputBinding<TState, TValue, TInput, TError>,\n options: StoreBindingOptions<TValue, TInput> = {},\n): StoreBindingResult<TValue, TInput, TError> {\n const dispatchKey = useId();\n const [initialValue] = useState(() => binding.codec.format(binding.lens.get(store.state)));\n const [meta, setMeta] = useState<StoreBindingMeta<TError>>({ valid: true });\n const metaRef = useRef<StoreBindingMeta<TError>>(meta);\n const optionsRef = useRef(options);\n const subscribedStoreRef = useRef<Store<TState> | null>(null);\n const subscribedBindingRef = useRef(binding);\n\n useEffect(() => {\n optionsRef.current = options;\n }, [options]);\n\n useEffect(() => {\n const isReplacement =\n subscribedStoreRef.current !== null &&\n (subscribedStoreRef.current !== store || subscribedBindingRef.current !== binding);\n\n subscribedStoreRef.current = store;\n subscribedBindingRef.current = binding;\n\n const sync = (state: Immutable<TState>) => {\n if (!metaRef.current.valid) {\n return;\n }\n\n const value = binding.lens.get(state);\n optionsRef.current.onStoreChange?.(binding.codec.format(value), value);\n };\n\n const unsubscribe = store.subscribe((state, key) => {\n if (key !== dispatchKey) {\n sync(state);\n }\n });\n\n if (isReplacement) {\n sync(store.state);\n }\n\n return unsubscribe;\n }, [binding, dispatchKey, store]);\n\n const setValue = useCallback(\n (value: TValue) => {\n const currentValue = binding.lens.get(store.state);\n const equals = binding.codec.equals ?? equalStoreValue;\n\n if (equals(currentValue, value)) {\n return;\n }\n\n store.dispatch((state) => binding.lens.set(state, value), { key: dispatchKey });\n },\n [binding, dispatchKey, store],\n );\n\n const commit = useCallback(\n (input: TInput) => {\n const result = binding.codec.parse(input);\n\n if (result.isErr) {\n const invalidMeta: StoreBindingMeta<TError> = {\n valid: false,\n error: result.error,\n };\n metaRef.current = invalidMeta;\n setMeta(invalidMeta);\n return result;\n }\n\n const validMeta: StoreBindingMeta<TError> = { valid: true };\n metaRef.current = validMeta;\n setMeta((current) => (current.valid ? current : validMeta));\n setValue(result.value);\n return result;\n },\n [binding, setValue],\n );\n\n const reset = useCallback(\n (value: TValue) => {\n const validMeta: StoreBindingMeta<TError> = { valid: true };\n metaRef.current = validMeta;\n setMeta((current) => (current.valid ? current : validMeta));\n setValue(value);\n },\n [setValue],\n );\n\n return {\n initialValue,\n meta,\n commit,\n reset,\n };\n}\n"],"mappings":";AAAA;AAAA,EACE,cAAc;AAAA,OAGT;AACP,SAAS,UAAU;AACnB,SAAS,qBAAqB,SAAS,UAAAA,eAAc;;;ACE9C,SAAS,cACd,SACA;AACA,SAAO;AACT;;;ACJO,SAAS,YAA4C,OAAsC;AAChG,SAAO;AACT;;;ACYA,SAAS,SAAS,OAAgB,MAA8B;AAC9D,SAAO,KAAK,OAAgB,CAAC,SAAS,QAAS,QAAyC,GAAG,GAAG,KAAK;AACrG;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AAEjC,UAAI,cAAc,WAAW,UAAU,OAAO;AAC5C,mBAAW,QAAQ;AAAA,MACrB;AAAA,IACF;AAAA,EACF,CAAC;AAED,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,KAAK;AAAA,MACL,MAAM,OAAO,IAAI;AAAA,MACjB,cAAc,gBAAgB;AAAA,MAC9B,UAAU,CAAC,UAAU;AACnB,eAAO,KAAK;AACZ,cAAM,WAAW,KAAK;AAAA,MACxB;AAAA;AAAA,EACF;AAEJ;","names":["useRef","useRef"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-store-input",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Typed React form inputs backed by a small immutable store",
5
5
  "keywords": [
6
6
  "react",
@@ -73,7 +73,7 @@
73
73
  "@types/react-dom": "^18.3.1 || ^19.2.1",
74
74
  "eslint": "^9.39.5",
75
75
  "eslint-plugin-react-hooks": "^7.1.1",
76
- "gw-react-text-editor": "^0.1.6",
76
+ "gw-rich-text-editor": "^0.1.4",
77
77
  "jsdom": "^24.1.3",
78
78
  "react": "^19.2.8",
79
79
  "react-dom": "^19.2.8",
@@ -82,12 +82,12 @@
82
82
  "typescript-eslint": "^8.65.0"
83
83
  },
84
84
  "peerDependencies": {
85
- "gw-react-text-editor": "^0.1.6",
85
+ "gw-rich-text-editor": "^0.1.4",
86
86
  "react": ">=18.0.0 <20.0.0",
87
87
  "react-dom": ">=18.0.0 <20.0.0"
88
88
  },
89
89
  "peerDependenciesMeta": {
90
- "gw-react-text-editor": {
90
+ "gw-rich-text-editor": {
91
91
  "optional": true
92
92
  }
93
93
  },