( state: JsonFormsState, ownProps: OwnPropsOfEnumCell )
| 216 | * @returns {StatePropsOfEnumCell} |
| 217 | */ |
| 218 | export const defaultMapStateToEnumCellProps = ( |
| 219 | state: JsonFormsState, |
| 220 | ownProps: OwnPropsOfEnumCell |
| 221 | ): StatePropsOfEnumCell => { |
| 222 | const props: StatePropsOfCell = mapStateToCellProps(state, ownProps); |
| 223 | const options: EnumOption[] = |
| 224 | ownProps.options || |
| 225 | props.schema.enum?.map((e) => |
| 226 | enumToEnumOptionMapper( |
| 227 | e, |
| 228 | getTranslator()(state), |
| 229 | getI18nKeyPrefix(props.schema, props.uischema, props.path) |
| 230 | ) |
| 231 | ) || |
| 232 | (props.schema.const && [ |
| 233 | enumToEnumOptionMapper( |
| 234 | props.schema.const, |
| 235 | getTranslator()(state), |
| 236 | getI18nKeyPrefix(props.schema, props.uischema, props.path) |
| 237 | ), |
| 238 | ]); |
| 239 | return { |
| 240 | ...props, |
| 241 | options, |
| 242 | }; |
| 243 | }; |
| 244 | |
| 245 | /** |
| 246 | * mapStateToOneOfEnumCellProps for one of enum cell. Options is used for populating dropdown list from oneOf |
no test coverage detected
searching dependent graphs…