paintcannon-react 0.0.40 → 0.0.42

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.
@@ -5,4 +5,4 @@ import type { CommonProps, Scrollable } from "./shared.ts";
5
5
  export type ApplyCommonProps = (node: PaintElement, oldProps: Partial<CommonProps>, newProps: CommonProps) => void;
6
6
  export declare function applyScrollableElementProps<Props extends CommonProps & Partial<Scrollable>>(node: PaintElement & Scrollable, oldProps: Partial<Props>, newProps: Props, applyCommonProps: ApplyCommonProps): void;
7
7
  export declare function applyScrollableProps(node: Scrollable, props: Partial<Scrollable>): void;
8
- export declare function applyTextControlProps<T extends InputElement | TextAreaElement>(node: T, oldProps: Partial<input.Props | textarea.Props>, newProps: input.Props | textarea.Props): void;
8
+ export declare function applyTextControlProps<T extends InputElement | TextAreaElement>(node: T, _oldProps: Partial<input.Props | textarea.Props>, newProps: input.Props | textarea.Props): void;
@@ -10,7 +10,7 @@ export function applyScrollableProps(node, props) {
10
10
  node.scrollTop = props.scrollTop;
11
11
  }
12
12
  }
13
- export function applyTextControlProps(node, oldProps, newProps) {
13
+ export function applyTextControlProps(node, _oldProps, newProps) {
14
14
  if (newProps.value !== undefined) {
15
15
  node.value = newProps.value;
16
16
  }
@@ -20,7 +20,4 @@ export function applyTextControlProps(node, oldProps, newProps) {
20
20
  if (newProps.cursorPosition !== undefined) {
21
21
  node.cursorPosition = newProps.cursorPosition;
22
22
  }
23
- if (newProps.autoFocus === true && oldProps.autoFocus !== true) {
24
- node.focus();
25
- }
26
23
  }
@@ -31,11 +31,11 @@ type ElementEventProps = {
31
31
  export type CommonProps = ElementEventProps & {
32
32
  children?: React.ReactNode;
33
33
  style?: CSSStyleProperties;
34
+ autoFocus?: boolean;
34
35
  };
35
36
  export type TextControlProps = CommonProps & {
36
37
  value?: string;
37
38
  placeholder?: string;
38
39
  cursorPosition?: number;
39
- autoFocus?: boolean;
40
40
  };
41
41
  export {};
@@ -70,7 +70,10 @@ const reconciler = createReconciler({
70
70
  removeVirtualChild(container, child);
71
71
  destroyHostNode(child);
72
72
  },
73
- finalizeInitialChildren: () => false,
73
+ finalizeInitialChildren: (_instance, _type, props) => props.autoFocus === true,
74
+ commitMount(instance) {
75
+ instance.node.focus();
76
+ },
74
77
  resetTextContent: () => { },
75
78
  getPublicInstance(instance) {
76
79
  return instance.node;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paintcannon-react",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
4
4
  "license": "ISC",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,7 +36,7 @@
36
36
  "scheduler": "^0.25.0"
37
37
  },
38
38
  "peerDependencies": {
39
- "paintcannon": "^0.0.40",
39
+ "paintcannon": "^0.0.42",
40
40
  "react": "^19.0.0"
41
41
  },
42
42
  "devDependencies": {