@wordpress/components
Version:
UI components for WordPress.
1 lines • 2.25 kB
Source Map (JSON)
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/circular-option-picker/utils.tsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport deprecated from '@wordpress/deprecated';\nimport type { CircularOptionPickerProps } from './types';\n\nexport function warnIfCircularOptionPickerAsButtonsIsSet(\n\tcomponentName: string,\n\tasButtons?: boolean\n) {\n\tif ( asButtons === undefined ) {\n\t\treturn;\n\t}\n\n\tdeprecated( `\\`asButtons\\` prop in wp.components.${ componentName }`, {\n\t\tsince: '7.2',\n\t\talternative: '`presentation`',\n\t\thint: '`asButtons={ true }` maps to `presentation=\"toggle-buttons\"`. Explicit `presentation` takes precedence.',\n\t} );\n}\n\nexport function resolveCircularOptionPickerPresentation(\n\tpresentation?: CircularOptionPickerProps[ 'presentation' ],\n\tasButtons?: boolean\n): NonNullable< CircularOptionPickerProps[ 'presentation' ] > {\n\treturn presentation ?? ( asButtons ? 'toggle-buttons' : 'listbox' );\n}\n\n/**\n * Computes the common props for the CircularOptionPicker.\n */\nexport function getComputeCircularOptionPickerCommonProps(\n\tasButtons?: boolean,\n\tloop?: boolean,\n\tariaLabel?: string,\n\tariaLabelledby?: string,\n\tpresentation?: CircularOptionPickerProps[ 'presentation' ]\n) {\n\tconst resolvedPresentation = resolveCircularOptionPickerPresentation(\n\t\tpresentation,\n\t\tasButtons\n\t);\n\tconst metaProps =\n\t\tresolvedPresentation === 'listbox'\n\t\t\t? { presentation: 'listbox' as const, loop }\n\t\t\t: { presentation: resolvedPresentation };\n\n\tconst labelProps = {\n\t\t'aria-labelledby': ariaLabelledby,\n\t\t'aria-label': ariaLabelledby\n\t\t\t? undefined\n\t\t\t: ariaLabel || __( 'Custom color picker' ),\n\t};\n\n\treturn { metaProps, labelProps, resolvedPresentation };\n}\n"],"mappings":";;;AAIA,SAAgB,yCACf,eACA,WACC;CACD,IAAK,cAAc,KAAA,GAClB;CAGD,WAAY,uCAAwC,iBAAkB;EACrE,OAAO;EACP,aAAa;EACb,MAAM;CACP,CAAE;AACH;AAEA,SAAgB,wCACf,cACA,WAC6D;CAC7D,OAAO,iBAAkB,YAAY,mBAAmB;AACzD;;;;AAKA,SAAgB,0CACf,WACA,MACA,WACA,gBACA,cACC;CACD,MAAM,uBAAuB,wCAC5B,cACA,SACD;CAaA,OAAO;EAAE,WAXR,yBAAyB,YACtB;GAAE,cAAc;GAAoB;EAAK,IACzC,EAAE,cAAc,qBAAqB;EASrB,YAAA;GANnB,mBAAmB;GACnB,cAAc,iBACX,KAAA,IACA,aAAa,GAAI,qBAAsB;EAGd;EAAG;CAAqB;AACtD"}