MCPcopy
hub / github.com/kuma-ui/kuma-ui / resolveMergedBoxProps

Function resolveMergedBoxProps

packages/core/src/components/variants.ts:10–35  ·  view source on GitHub ↗
(
  componentName: ComponentType,
  props: Omit<ComponentProps<ComponentType>, "children">,
)

Source from the content-addressed store, hash-verified

8 * Centralizes the common pattern used by the Kuma React wrappers.
9 */
10export function resolveMergedBoxProps<
11 ComponentType extends keyof typeof componentList,
12>(
13 componentName: ComponentType,
14 props: Omit<ComponentProps<ComponentType>, "children">,
15): BoxProps {
16 type ComponentName = Parameters<typeof theme.getVariants>[0];
17 const variantData = theme.getVariants(componentName as ComponentName);
18 const variants = variantData?.variants;
19
20 // Variant is already typed as string literal union or undefined from ComponentProps
21 const variantKey = props.variant;
22 const variantProps: Partial<BoxProps> =
23 variantKey &&
24 variants &&
25 typeof variantKey === "string" &&
26 variantKey in variants
27 ? (variants[variantKey] as Partial<BoxProps>)
28 : {};
29
30 return {
31 ...variantProps,
32 ...props,
33 IS_KUMA_DEFAULT: true,
34 };
35}

Callers 12

react.tsxFile · 0.90
react.tsxFile · 0.90
react.tsxFile · 0.90
react.tsxFile · 0.90
react.tsxFile · 0.90
react.tsxFile · 0.90
react.tsxFile · 0.90
react.tsxFile · 0.90
react.tsxFile · 0.90
react.tsxFile · 0.90
react.tsxFile · 0.90
react.tsxFile · 0.90

Calls 1

getVariantsMethod · 0.80

Tested by

no test coverage detected