Skip to content

Commit

Permalink
Merge branch 'main' into feat-update-node-edge
Browse files Browse the repository at this point in the history
  • Loading branch information
sroussey committed Feb 22, 2024
2 parents 201f771 + 33b3ea0 commit 737005a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 17 deletions.
18 changes: 16 additions & 2 deletions lib/components/NodeBaseInputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ export const NodeBaseInputField = ({
onPointerDown,
onPointerLeave,
children,
...props
inputMode,
pattern,
maxLength,
minLength,
max,
min,
step,
placeholder,
}: NodeBaseInputFieldProps) => {
const [labelVisible, setLabelVisible] = useState(true)
const ref = useRef<HTMLInputElement>(null)
Expand All @@ -45,7 +52,6 @@ export const NodeBaseInputField = ({
>
{children}
<input
{...props}
ref={ref}
style={{
background: '#545555',
Expand All @@ -71,6 +77,14 @@ export const NodeBaseInputField = ({
}}
onPointerDown={onPointerDown}
onPointerLeave={onPointerLeave}
inputMode={inputMode}
pattern={pattern}
maxLength={maxLength}
minLength={minLength}
max={max}
min={min}
step={step}
placeholder={placeholder}
/>
{labelVisible ? (
<div
Expand Down
2 changes: 1 addition & 1 deletion lib/components/NodeCheckboxField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const NodeCheckboxField = memo(
const [value, setValue] = useNodeFieldValue(props.id, props.defaultValue)

const handleChange = useCallback(
(e) => setValue(e.target.checked),
(e: React.ChangeEvent<HTMLInputElement>) => setValue(e.target.checked),
[setValue],
)

Expand Down
13 changes: 7 additions & 6 deletions lib/components/NodeInputField.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { useCallback, useEffect, useState } from 'react'
import { NodeBaseInputField } from './NodeBaseInputField'
import { useNodeFieldValue } from '../hooks/node'
import { NodeInputConfig, ValueTypeConfig } from '../config'
import { NodeInputConfig } from '../config'
import { BaseInputProps } from './inputs.ts'
import './NodeInputField.css'

type NodeInputFieldProps = BaseInputProps &
Omit<NodeInputConfig, 'valueType'> &
ValueTypeConfig &
Pick<NodeInputConfig, 'isConstant' | 'id' | 'defaultValue' | 'name'> &
React.InputHTMLAttributes<any>

export const NodeInputField = ({
Expand All @@ -16,10 +15,12 @@ export const NodeInputField = ({
type,
isConstant,
slots,
id,
defaultValue,
...props
}: NodeInputFieldProps) => {
const Handle = slots?.Handle
const [value, setValue] = useNodeFieldValue(props.id, props.defaultValue)
const [value, setValue] = useNodeFieldValue(id, defaultValue)

return (
<NodeBaseInputField
Expand Down Expand Up @@ -95,7 +96,7 @@ export const NodeInputDecimalField = ({
type NodeInputTypedFieldProps = Omit<NodeInputFieldProps, 'type'>

export const NodeInputTextField = (
props: NodeInputTypedFieldProps & { maxlength?: number; minlength?: number },
props: NodeInputTypedFieldProps & { maxLength?: number; minLength?: number },
) => {
return <NodeInputField type="text" {...props} />
}
Expand All @@ -107,7 +108,7 @@ export const NodeInputNumberField = (
}

export const NodeInputPasswordField = (
props: NodeInputTypedFieldProps & { maxlength?: number; minlength?: number },
props: NodeInputTypedFieldProps & { maxLength?: number; minLength?: number },
) => {
return <NodeInputField type="password" {...props} />
}
Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { GraphConfig, type InputProps } from './config'
export { NodeGraphEditor } from './NodeGraphEditor'
export { NodeGraphEditor, type NodeGraphHandle } from './NodeGraphEditor'
export { useBuildGraphConfig } from './hooks/config.ts'
export {
useNodeCollapsed,
Expand Down
2 changes: 1 addition & 1 deletion lib/node-builder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function NodeBody({
export function NodeWrapper({
children,
}: NodeFocusState & { children: ReactNode }) {
return <>{children}</>
return <>{children!}</>
}

/**
Expand Down
6 changes: 2 additions & 4 deletions lib/types/slots.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentType, ReactElement } from 'react'
import { ComponentType, ReactNode } from 'react'
import { NodeHeader, NodeHeaderProps } from '../components/NodeHeader.tsx'
import {
NodeBody,
Expand All @@ -10,9 +10,7 @@ import {
export type GraphSlots = {
header: ComponentType<NodeHeaderProps>
body: ComponentType<NodeBodyProps>
wrapper: ComponentType<
NodeFocusState & { children: ReactElement | ReactElement[] }
>
wrapper: ComponentType<NodeFocusState & { children: ReactNode }>
bodyTop?: ComponentType<NodeFocusState>
bodyBottom?: ComponentType<NodeFocusState>
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"main": "dist/cjs/main.jsx",
"exports": {
".": {
"types": "./dist/index.d.ts",
"types": "./dist/types/index.d.ts",
"import": "./dist/es/index.js",
"require": "./dist/cjs/index.js",
"default": "./dist/es/index.js"
}
},
"types": "dist/es/index.d.ts",
"types": "dist/types/index.d.ts",
"sideEffects": [
"**/*.css"
],
Expand Down

0 comments on commit 737005a

Please sign in to comment.