UNPKG

@wordpress/widget-dashboard

Version:

Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.

1 lines • 2.15 kB
{"version":3,"file":"callback-action.cjs","names":["IconButton","Button"],"sources":["../../../src/components/widget-actions/callback-action.tsx"],"sourcesContent":["import {\n\t// eslint-disable-next-line @wordpress/use-recommended-components\n\tButton,\n\t// eslint-disable-next-line @wordpress/use-recommended-components\n\tIconButton,\n} from '@wordpress/ui';\nimport type { WidgetCallbackAction } from '@wordpress/widget-primitives';\n\ninterface CallbackActionProps {\n\taction: WidgetCallbackAction;\n\n\t/**\n\t * Whether its promise is still settling.\n\t */\n\tisPending: boolean;\n\n\tonRun: ( action: WidgetCallbackAction ) => void;\n\n\t/**\n\t * The footer's trailing form: icon-only when the action has an icon.\n\t */\n\tcompact?: boolean;\n}\n\n/**\n * A callback action as a button, disabled while its promise settles.\n *\n * @param {CallbackActionProps} props Component props.\n */\nexport function CallbackAction( {\n\taction,\n\tisPending,\n\tonRun,\n\tcompact = false,\n}: CallbackActionProps ): React.ReactNode {\n\tif ( compact && action.icon ) {\n\t\treturn (\n\t\t\t<IconButton\n\t\t\t\ticon={ action.icon }\n\t\t\t\tlabel={ action.label }\n\t\t\t\tvariant=\"minimal\"\n\t\t\t\ttone=\"neutral\"\n\t\t\t\tsize=\"compact\"\n\t\t\t\tdisabled={ isPending }\n\t\t\t\tonClick={ () => onRun( action ) }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\tvariant=\"minimal\"\n\t\t\ttone={ compact ? 'neutral' : 'brand' }\n\t\t\tsize=\"compact\"\n\t\t\tdisabled={ isPending }\n\t\t\tonClick={ () => onRun( action ) }\n\t\t>\n\t\t\t{ action.icon && <Button.Icon icon={ action.icon } /> }\n\t\t\t{ action.label }\n\t\t</Button>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;AA6BA,SAAgB,eAAgB,EAC/B,QACA,WACA,OACA,UAAU,SAC+B;CACzC,IAAK,WAAW,OAAO,MACtB,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,YAAD;EACC,MAAO,OAAO;EACd,OAAQ,OAAO;EACf,SAAQ;EACR,MAAK;EACL,MAAK;EACL,UAAW;EACX,eAAgB,MAAO,MAAO;CAC9B,CAAA;CAIH,OACC,iBAAA,GAAA,kBAAA,KAAA,CAACC,cAAAA,QAAD;EACC,SAAQ;EACR,MAAO,UAAU,YAAY;EAC7B,MAAK;EACL,UAAW;EACX,eAAgB,MAAO,MAAO;EAL/B,UAAA,CAOG,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,OAAO,MAAR,EAAa,MAAO,OAAO,KAAQ,CAAA,GAClD,OAAO,KACF;;AAEV"}