{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "files-property-panel",
  "type": "registry:component",
  "title": "Property panels",
  "description": "A key/value editor for text, number, boolean and select",
  "author": "sudo-kw <https://github.com/sudo-kw>",
  "dependencies": [
    "@gpuix/native@0.11.0",
    "@gpuix/react@0.11.0",
    "effect@4.1.2",
    "react@^19.2.4"
  ],
  "registryDependencies": [
    "https://gpuixui.sudokw.com/gpuix-primitives.json",
    "https://gpuixui.sudokw.com/gpuix-tokens.json",
    "https://gpuixui.sudokw.com/gpuix-tw.json"
  ],
  "files": [
    {
      "path": "packages/files/src/property/logic.ts",
      "target": "@ui/gpuixui/files/property/logic.ts",
      "type": "registry:lib",
      "content": "import type { SelectOption } from \"../../primitives/index.js\";\nimport * as Arr from \"effect/Array\";\n\nexport type PropertyValue = string | number | boolean;\n\nexport interface PropertyRowBase {\n  readonly key: string;\n\n  readonly label: string;\n}\n\nexport interface TextPropertyRow extends PropertyRowBase {\n  readonly type: \"text\";\n  readonly value: string;\n}\n\nexport interface NumberPropertyRow extends PropertyRowBase {\n  readonly type: \"number\";\n  readonly value: number;\n\n  readonly min?: number;\n\n  readonly max?: number;\n\n  readonly step?: number;\n}\n\nexport interface BooleanPropertyRow extends PropertyRowBase {\n  readonly type: \"boolean\";\n  readonly value: boolean;\n}\n\nexport interface SelectPropertyRow extends PropertyRowBase {\n  readonly type: \"select\";\n  readonly value: string;\n  readonly options: ReadonlyArray<SelectOption>;\n}\n\nexport type PropertyRow =\n  | TextPropertyRow\n  | NumberPropertyRow\n  | BooleanPropertyRow\n  | SelectPropertyRow;\n\nexport type PropertyRecord = Readonly<Record<string, PropertyValue>>;\n\nexport const isTextRow = (row: PropertyRow): row is TextPropertyRow =>\n  row.type === \"text\";\n\nexport const isNumberRow = (row: PropertyRow): row is NumberPropertyRow =>\n  row.type === \"number\";\n\nexport const isBooleanRow = (row: PropertyRow): row is BooleanPropertyRow =>\n  row.type === \"boolean\";\n\nexport const isSelectRow = (row: PropertyRow): row is SelectPropertyRow =>\n  row.type === \"select\";\n\nconst emptyRecord: PropertyRecord = {};\n\nexport const propertyRecord = (\n  rows: ReadonlyArray<PropertyRow>,\n): PropertyRecord =>\n  Arr.reduce(rows, emptyRecord, (record, row) => ({\n    ...record,\n    [row.key]: row.value,\n  }));\n\nexport const setProperty = (\n  record: PropertyRecord,\n  key: string,\n  value: PropertyValue,\n): PropertyRecord => ({ ...record, [key]: value });\n"
    },
    {
      "path": "packages/files/src/property/property-panel.tsx",
      "target": "@ui/gpuixui/files/property/property-panel.tsx",
      "type": "registry:component",
      "content": "import type { Props } from \"@gpuix/react\";\nimport { mergeStyles } from \"@gpuix/react/floating\";\nimport {\n  Input,\n  NumberField,\n  NumberFieldScrubHandle,\n  Select,\n  Switch,\n  Text,\n} from \"../../primitives/index.js\";\nimport { cn } from \"../../tw/index.js\";\nimport { Match } from \"effect\";\nimport type { ReactElement } from \"react\";\nimport { recipeStyle } from \"../recipe.js\";\nimport { useTheme } from \"../theme.js\";\nimport {\n  isBooleanRow,\n  isNumberRow,\n  isSelectRow,\n  isTextRow,\n  propertyRecord,\n  setProperty,\n  type PropertyRecord,\n  type PropertyRow,\n  type PropertyValue,\n} from \"./logic.js\";\nimport {\n  PROPERTY_HEADER,\n  PROPERTY_LABEL,\n  PROPERTY_PANEL,\n  PROPERTY_ROW,\n} from \"./recipe.js\";\n\nexport const DEFAULT_LABEL_WIDTH = 120;\n\nexport interface PropertyPanelProps extends Omit<\n  Props,\n  \"children\" | \"onChange\"\n> {\n  readonly rows: ReadonlyArray<PropertyRow>;\n\n  readonly onChange: (record: PropertyRecord) => void;\n\n  readonly title?: string;\n\n  readonly labelWidth?: number;\n  readonly className?: string;\n  readonly testId?: string;\n}\n\nconst renderField = (\n  row: PropertyRow,\n  edit: (value: PropertyValue) => void,\n): ReactElement =>\n  Match.value(row).pipe(\n    Match.when(isTextRow, (row) => (\n      <Input\n        value={row.value}\n        onValueChange={edit}\n        size=\"sm\"\n        fullWidth\n        testId={`field-${row.key}`}\n      />\n    )),\n    Match.when(isNumberRow, (row) => (\n      <NumberField\n        value={row.value}\n        onValueChange={edit}\n        size=\"sm\"\n        className=\"w-full\"\n        min={row.min}\n        max={row.max}\n        step={row.step}\n        testId={`field-${row.key}`}\n      />\n    )),\n    Match.when(isBooleanRow, (row) => (\n      <Switch\n        checked={row.value}\n        onCheckedChange={edit}\n        size=\"sm\"\n        testId={`field-${row.key}`}\n      />\n    )),\n    Match.when(isSelectRow, (row) => (\n      <Select\n        value={row.value}\n        options={row.options}\n        onValueChange={edit}\n        size=\"sm\"\n        fullWidth\n        testId={`field-${row.key}`}\n      />\n    )),\n    Match.exhaustive,\n  );\n\nexport const PropertyPanel = ({\n  rows,\n  onChange,\n  title,\n  labelWidth = DEFAULT_LABEL_WIDTH,\n  className,\n  testId,\n  style,\n  ...rest\n}: PropertyPanelProps) => {\n  const theme = useTheme();\n  const record = propertyRecord(rows);\n  return (\n    <div\n      {...rest}\n      style={mergeStyles(\n        recipeStyle(cn(PROPERTY_PANEL, className), theme),\n        style,\n      )}\n    >\n      {title === undefined ? undefined : (\n        <div style={recipeStyle(PROPERTY_HEADER, theme)}>\n          <div style={recipeStyle(\"text-xs font-medium\", theme)}>{title}</div>\n        </div>\n      )}\n      <div\n        style={{\n          paddingLeft: theme.spacing.sm,\n          paddingRight: theme.spacing.sm,\n        }}\n      >\n        {rows.map((row) => {\n          const edit = (value: PropertyValue): void =>\n            onChange(setProperty(record, row.key, value));\n          const labelStyle = {\n            ...recipeStyle(PROPERTY_LABEL, theme),\n            width: labelWidth,\n            flexGrow: 0,\n            flexShrink: 0,\n            flexBasis: labelWidth,\n          };\n          const labelTestId =\n            testId === undefined ? undefined : `${testId}-label-${row.key}`;\n          return (\n            <div\n              key={row.key}\n              style={{\n                display: \"flex\",\n                flexDirection: \"row\",\n                alignItems: \"center\",\n                gap: theme.spacing.sm,\n                ...recipeStyle(PROPERTY_ROW, theme),\n              }}\n            >\n              {isNumberRow(row) ? (\n                <NumberFieldScrubHandle\n                  testId={labelTestId}\n                  value={row.value}\n                  min={row.min}\n                  max={row.max}\n                  step={row.step}\n                  onValueChange={edit}\n                  style={labelStyle}\n                >\n                  <Text role=\"caption\" tone=\"muted\">\n                    {row.label}\n                  </Text>\n                </NumberFieldScrubHandle>\n              ) : (\n                <div testId={labelTestId} style={labelStyle}>\n                  {row.label}\n                </div>\n              )}\n              <div\n                style={{\n                  flexGrow: 1,\n                  flexShrink: 1,\n                  flexBasis: 0,\n                  minWidth: 0,\n                }}\n              >\n                {renderField(row, edit)}\n              </div>\n            </div>\n          );\n        })}\n      </div>\n    </div>\n  );\n};\n"
    },
    {
      "path": "packages/files/src/property/recipe.ts",
      "target": "@ui/gpuixui/files/property/recipe.ts",
      "type": "registry:lib",
      "content": "export const PROPERTY_PANEL =\n  \"flex flex-col rounded-lg border border-input bg-card text-foreground\";\n\nexport const PROPERTY_HEADER =\n  \"flex flex-row items-center justify-between gap-2 border-b border-input px-3 py-2\";\n\nexport const PROPERTY_ROW = \"flex flex-row items-center gap-2 py-1\";\n\nexport const PROPERTY_LABEL = \"text-xs text-muted-foreground\";\n"
    },
    {
      "path": "packages/files/src/recipe.ts",
      "target": "@ui/gpuixui/files/recipe.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport { classesToStyle } from \"../tw/index.js\";\nimport * as MutableHashMap from \"effect/MutableHashMap\";\nimport * as Option from \"effect/Option\";\nimport type { Theme } from \"./theme.js\";\n\nconst CACHE_LIMIT = 256;\n\nconst compiled = new WeakMap<\n  Theme,\n  MutableHashMap.MutableHashMap<string, StyleDesc>\n>();\n\nexport const recipeStyle = (recipe: string, theme: Theme): StyleDesc => {\n  const byRecipe = compiled.get(theme);\n  if (byRecipe !== undefined) {\n    const hit = MutableHashMap.get(byRecipe, recipe);\n    if (Option.isSome(hit)) return hit.value;\n  }\n  const style = Object.freeze(classesToStyle(recipe, theme).style);\n  if (byRecipe === undefined) {\n    compiled.set(theme, MutableHashMap.make([recipe, style]));\n  } else if (MutableHashMap.size(byRecipe) < CACHE_LIMIT) {\n    MutableHashMap.set(byRecipe, recipe, style);\n  }\n  return style;\n};\n"
    },
    {
      "path": "packages/files/src/theme.ts",
      "target": "@ui/gpuixui/files/theme.ts",
      "type": "registry:lib",
      "content": "import type { Theme } from \"../tokens/index.js\";\nimport { useTheme as useTokenTheme } from \"../tokens/react.js\";\n\nexport {\n  pointerWash,\n  statusTone,\n  textStyle,\n  themeColors,\n} from \"../tokens/index.js\";\nexport type { Theme };\n\nexport const useTheme = (): Theme => useTokenTheme();\n"
    }
  ],
  "docs": "[Property panels](https://gpuixui.sudokw.com/files/property-panel) — These are GPUix native components: the files render through GPUix's reconciler against `@gpuix/react`, not the DOM, and need the per-platform `@gpuix/native` binding. The CLI installs the `@gpuixui/*` runtime the components import as registry items, so the copied tree resolves on its own; wrap it in `ThemeProvider` before it renders.",
  "meta": {
    "url": "/files/property-panel",
    "kind": "component",
    "runtime": "gpuix",
    "registry": "gpuixui"
  }
}