{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/connect/api.ts"],"names":[],"mappings":"","sourcesContent":["export type EnumValue =\n | string\n | boolean\n | number\n | symbol\n | undefined\n | React.ReactElement\n | Function\n | Object\n\n/**\n * These types are intended to be returned by figma helper functions for exposing the\n * supported output modifiers for that type. There's no implementation for these types,\n * they are resolved to primitive types when the `props` object is passed to `example`.\n */\nexport interface ConnectedComponent {\n /**\n * Returns the resolved props of the connected component. This is useful for accessing\n * the `props` object of a child in a parent context. For example:\n * ```ts\n * figma.connect(\"parent\", {\n * props: {\n * iconProps: figma.instance(\"Icon\").getProps(),\n * },\n * example: (iconProps) => ,\n * }\n */\n getProps(): T\n /**\n * Renders the instance with the provided render function. The function is passed the resolved\n * `props` of the nested connected component. This is useful for dynamically rendering a child\n * component depending on parent context. For example:\n * ```ts\n * figma.connect(\"parent\", {\n * props: {\n * icon: figma.instance(\"Icon\").render(({ iconId }) => ),\n * },\n * example: ({ icon }) => ,\n * }\n */\n render(renderFunction: (props: T) => React.ReactElement): React.ReactElement\n}\n\n// This contains the base API interface for figma.connect calls across React and\n// HTML. Any parts which are platform-specific (either the function signature or\n// its docblock) are specified in the individual index_ and added to\n// this using union typing.\n//\n// To override a docblock, all signatures of that function must be moved into\n// the platform-specific index file.\nexport interface FigmaConnectAPI {\n /**\n * Maps a Figma Variant property to a set if values for the connected component. This prop is replaced\n * with values from the Figma instance when viewed in Dev Mode. For example:\n * ```ts\n * props: {\n * type: figma.enum('Type', {\n * Primary: 'primary',\n * Secondary: 'secondary',\n * }),\n * }\n * ```\n * Would output \"primary\" if the Type Variant in Figma is set to \"Primary\".\n *\n * @param figmaPropName The name of the property on the Figma component\n * @param valueMapping A mapping of values for the Figma Variant\n */\n enum(figmaPropName: string, valueMapping: Record): V\n\n /**\n * Maps a Figma property to a string value for the connected component. This prop is replaced\n * with values from the Figma instance when viewed in Dev Mode. For example:\n * ```ts\n * props: {\n * text: figma.string('Text'),\n * }\n * ```\n * Would replace `text` with the text content from the Figma property \"Text\".\n *\n * @param figmaPropName The name of the property on the Figma component\n */\n string(figmaPropName: string): string\n\n /**\n * Maps a Figma instance property for the connected component. This prop is replaced\n * with values from the Figma instance when viewed in Dev Mode. For example:\n * ```ts\n * props: {\n * icon: figma.instance('Icon'),\n * }\n * ```\n * Would show the nested examples for the component passed to the \"Icon\" property in Figma.\n *\n * @param figmaPropName The name of the property on the Figma component\n */\n instance(figmaPropName: string): T\n\n /**\n * Maps a Figma instance property for the connected slot layer. This prop is replaced\n * with values from the Figma slot layer when viewed in Dev Mode. For example:\n * ```ts\n * props: {\n * Menu: figma.slot('Menu'),\n * }\n * ```\n * Would show the \"Menu\" slot layer connected as an instance property in Figma.\n *\n * @param figmaPropName The name of the property on the Figma component\n */\n slot(figmaPropName: string): T\n\n /**\n * Maps a Figma instance layer to a nested code example. For example:\n * ```ts\n * props: {\n * icon: figma.children('Icon')\n * }\n * ```\n * Would show the nested code example for the child instance named 'Icon'. This also supports\n * an array: `tabs: figma.children(['Tab 1', 'Tab 2'])` to map multiple nested examples.\n *\n * You can pass a single wildcard '*' character to match partial names. For example:\n * ```ts\n * props: {\n * icon: figma.children('Icon*')\n * }\n * ```\n * Would show the nested code example for any child instance which name starts with \"Icon\"\n *\n * @param figmaPropName The name of the property on the Figma component\n */\n children(layerNames: string | string[]): ChildrenT\n\n /**\n * Creates a className string by joining an array of strings. The argument supports both\n * string literals and nested functions like `figma.enum` and `figma.boolean` that return\n * a string. For example:\n * ```ts\n * props: {\n * className: figma.className([\n * 'btn-base',\n * figma.enum('Size', { Large: 'btn-large' }),\n * figma.boolean('Disabled', { true: 'btn-disabled', false: '' }),\n * ]),\n * }\n *\n * @param className\n */\n className(className: (string | undefined)[]): string\n\n /**\n * Maps a Figma text layer to a string value representing the text content of that layer.\n * This function takes the layer name within the original component as its parameter.\n * For example:\n * ```ts\n * props: {\n * text: figma.textContent('Text Layer')\n * }\n * ```\n *\n * @param layer The name of the text layer in the Figma component\n */\n textContent(layer: string): string\n}\n\nexport type ValueOf = T[keyof T]\n\nexport type PropMapping = {\n [key in keyof T]: T[key]\n}\n\nexport interface FigmaConnectLink {\n name: string\n url: string\n}\n\n// ExampleFnReturnT is the return type of an example function.\n// ExtraExampleT allows us to pass in an extra type to the `example` property,\n// so that in Storybook, we can use strings to refer to non-hoisted functions\nexport interface FigmaConnectMeta<\n PropsT = {},\n ResolvedPropsT = {},\n ExampleFnReturnT = unknown,\n ExtraExampleT = never,\n> {\n /**\n * Restricts this figma connect to any variants that fullfill the given filter.\n * The filter is a map of Figma variant names to values. Example:\n * ```ts\n * {\n * variant: { \"Has Icon\": true }\n * }\n */\n variant?: Record\n\n /**\n * Prop mappings for the connected component. This is used to map the values of the component's props\n * to the values that are used in Figma, using helper functions like `figma.boolean`. For example:\n * ```ts\n * props: {\n * disabled: figma.boolean('Disabled'),\n * text: figma.string('Text'),\n * size: figma.enum('Size', {\n * slim: 'slim',\n * medium: 'medium',\n * large: 'large',\n * }),\n * }\n */\n props?: PropsT\n\n /**\n * The code example to display in Figma. Any mapped `props` are passed to the component,\n * where those values will be replaced with the mapped value when inspecting that instance in Figma.\n * @param props\n * @returns\n */\n example?: ((props: ResolvedPropsT) => ExampleFnReturnT) | ExtraExampleT\n\n /**\n * A list of links that will display in Figma along with the examples\n */\n links?: FigmaConnectLink[]\n}\n"]}