UNPKG

@wordpress/components

Version:
1 lines • 1.15 kB
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/context/utils.ts"],"sourcesContent":["import { CONNECTED_NAMESPACE, COMPONENT_NAMESPACE } from './constants';\n\n/**\n * Creates a dedicated context namespace HTML attribute for components.\n * ns is short for \"namespace\"\n *\n * @example\n * ```jsx\n * <div {...ns('Container')} />\n * ```\n *\n * @param componentName The name for the component.\n * @return A props object with the namespaced HTML attribute.\n */\nexport function getNamespace(\n\tcomponentName: string\n): Record< string, unknown > {\n\treturn { [ COMPONENT_NAMESPACE ]: componentName };\n}\n\n/**\n * Creates a dedicated connected context namespace HTML attribute for components.\n * ns is short for \"namespace\"\n *\n * @example\n * ```jsx\n * <div {...cns()} />\n * ```\n *\n * @return A props object with the namespaced HTML attribute.\n */\nexport function getConnectedNamespace(): Record< string, unknown > {\n\treturn { [ CONNECTED_NAMESPACE ]: true };\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAgB,aACf,eAC4B;CAC5B,OAAO,GAAI,sBAAuB,cAAc;AACjD;;;;;;;;;;;;AAaA,SAAgB,wBAAmD;CAClE,OAAO,GAAI,sBAAuB,KAAK;AACxC"}