import { Meta } from '@storybook/addon-docs/blocks'

<Meta title='@dxtmisha/en/functional/Functions/getIndexForRender - Key Generation for Rendering'/>

# `getIndexForRender`

A utility function used to generate a unique component `key`. The key is formed **additively**: all identified parts (including the component name) are joined with dots.

### Parameters:
- `name: string | any` — Component name or tag (the key base).
- `props?: T` — Component properties (used to extract `index`, `class`, and `id`).
- `index?: string` — An optional external index.

### Returns:
`string | undefined` — The generated composite key, or `undefined` if no key could be generated.

### Generation Examples:

```typescript
import { getIndexForRender } from '@dxtmisha/functional'

// 1. Name only
getIndexForRender('li') 
// => '.li'

// 2. Name + external index
getIndexForRender('div', {}, 'row-1') 
// => '.div.row-1'

// 3. Name + index from props + class + id
getIndexForRender('button', { 
  index: 'primary', 
  class: 'btn-large', 
  id: 'submit-01' 
}) 
// => '.button.primary.btn-large.submit-01'

// 4. Full set (external argument + everything from props)
getIndexForRender('span', { 
  index: 'p-idx', 
  class: 'text-red', 
  id: 'id-99' 
}, 'arg-idx') 
// => '.span.arg-idx.p-idx.text-red.id-99'

// 5. Empty case
getIndexForRender(undefined)
// => undefined
```

### Key Assembly Logic

The key is assembled in a chain:
1.  **`.name`** (if `name` is a string)
2.  `+ .index` (if the `index` argument is passed)
3.  `+ .props.index` (if present in properties and is a string)
4.  `+ .className` (if present in properties)
5.  `+ .props.id` (if present in properties)
