JavaScript Extension Development API for Oracle Visual Builder Cloud Service - Classic Applications

Source: components.dt/js/spi/registration/PaletteRegistrationProvider.js

define([], function () {

    'use strict';

    /**
     * Provider interface returning component's palette registration configuration.
     * Registers into ABCS with the {@link components.dt/js/api/ComponentProviderRegistry Component Registration API}.
     *
     * <p>Palette registration configuration describes the way the component is
     * represented in ABCS Component palette and initially dropped into ABCS designer.
     * Use this when you want to give users a chance to drop your components
     * from the palette into ABCS designer. Implement {@link components.dt/js/spi/registration/PaletteRegistrationProvider#getPaletteItemConfig PaletteRegistrationProvider.getPaletteItemConfig}
     * and return an object literal described by {@link components.dt/js/spi/registration/PaletteRegistrationProvider.PaletteItemConfig PaletteItemConfig}.</p>
     *
     * <p>You do not have to register a PaletteRegistrationProvider in which
     * case users will not be able to instantiate your components in the UI. That
     * may be useful for helper components that make sense only as part of a larger
     * component that may instantiate them through the {@link components.dt/js/api/ComponentFactory Creator API}
     * when dropped from the Component palette itself and incorporate your <em>hidden</em>
     * component into its view hierarchy.</p>
     *
     * @AbcsExtension stable
     * @exports components.dt/js/spi/registration/PaletteRegistrationProvider
     * @constructor
     * @private
     * @version 16.3.5
     * @example <caption>An example of a component palette registration provider.</caption>
     * define([
     * ], function (
     *    ) {
     *
     *    'use strict';
     *
     *    var PaletteRegistrationProvider = function () {
     *    };
     *
     *    PaletteRegistrationProvider.prototype.getPaletteItemConfig = function () {
     *        return {
     *            // registers your component into the 'Custom' category
     *            categoryName: 'Custom',
     *            // instructs ABCS designer that the component will occupy
     *            // 6 columns by default when dropped into a page
     *            defaultWidth: 6
     *        };
     *    }
     *
     *    return new PaletteRegistrationProvider();
     *
     * });
     * @see {@link components.dt/js/api/ComponentProviderRegistry Component Registration API}
     * @see {@link components.dt/js/spi/registration/PaletteRegistrationProvider.PaletteItemConfig Palette configuration description}
     */
    var PaletteRegistrationProvider = function() {
        AbcsLib.checkThis(this);
    };

    /**
     * Get the configuration of a new palette item representing the component in the Component palette.
     *
     * @AbcsExtension stable
     * @version 16.3.5
     * @returns {components.dt/js/spi/registration/PaletteRegistrationProvider.PaletteItemConfig}
     */
    PaletteRegistrationProvider.prototype.getPaletteItemConfig = function () {};

    /**
     * Palette item registration object containing info about palette item.
     * Returned from {@link components.dt/js/spi/registration/PaletteRegistrationProvider#getPaletteItemConfig PaletteRegistrationProvider.getPaletteItemConfig}
     * method.
     *
     * <p>Describes the way the component is added to ABCS Component palette and
     * the way it is initially dropped into ABCS designer.</p>
     *
     * @AbcsExtension stable
     * @version 16.3.5
     * @memberof components.dt/js/spi/registration/PaletteRegistrationProvider
     * @objectLiteral
     * @example <caption>PaletteItemConfig example</caption>
     * {
     *     // registers your component into the 'Custom' category
     *     categoryName: 'Custom',
     *     // instructs ABCS designer that the component will occupy
     *     // 6 columns by default when dropped into a page
     *     defaultWidth: 6,
     *     // sets palette item tile's CSS class (including an icon) to custom-component-palette-icon
     *     iconClassName: 'custom-component-palette-icon',
     *     // tells ABCS where to load the custom CSS stylesheet
     *     // for the palette item
     *     styleResource: 'style/custom-component-palette.dt.css'
     * }
     */
    var PaletteItemConfig = function () {
    };

    /**
     * Icon class name representing palette item tile in component palette. Set
     * this to any CSS class ABCS internally provides or that is described in
     * one of your component stylesheets to properly render the palette item's
     * tile icon. See {@link components.dt/js/spi/registration/PaletteRegistrationProvider.PaletteItemConfig#styleResource PaletteItemConfig.styleResource}
     * for how to provide your CSS stylesheet for palette items.
     *
     * @AbcsExtension stable
     * @version 16.3.5
     * @type {String}
     */
    PaletteItemConfig.prototype.iconClassName = '';

    /**
     * Desired width of the component after drop in columns (1 - 12).
     *
     * @AbcsExtension stable
     * @version 16.3.5
     * @type {Number}
     */
    PaletteItemConfig.prototype.defaultWidth = 12;

    /**
     * Name of a component palette category.
     *
     * @AbcsExtension stable
     * @version 16.3.5
     * @type {String}
     */
    PaletteItemConfig.prototype.categoryName = '';

    /**
     * Drop zone acceptor used for filtering drop zones during drag from component palette.
     *
     * @AbcsExtension unstable
     * @type {components.dr/js/spi/dropzoneacceptors/DropZoneAcceptor}
     */
    PaletteItemConfig.prototype.dropZoneAcceptor = undefined;

    /**
     * An optional path to a css resource defining the look of the palette icon.
     * <p>As {@link components.dt/js/spi/registration/PaletteRegistrationProvider.PaletteItemConfig#iconClassName PaletteItemConfig.iconClassName}
     * may return class name of an icon not one of the ABCS predefined icons but
     * a custom one defined by the component, <code>styleResource</code> point to
     * the css style resource containing the icon class name definition.</p>
     * <p>Most of the styling for palette items is done by ABCS itself, the
     * component should define only the icon image, see the example on how to
     * do it.</p>
     *
     * @AbcsExtension stable
     * @version 16.3.5
     * @type {String}
     * @example <caption>Content of the styling resource</caption>
     * .custom-component-palette-icon:before {
     *     background-image:url(../images/icon_60_ena.png);
     * }
     * .custom-component-palette-icon:hover:before{
     *     background-image:url(../images/icon_60_hov.png);
     * }
     *
     * @example <caption>Using <code>styleResource</code> and <code>iconClassName</code></caption>
     * PaletteRegistrationProvider.prototype.getPaletteItemConfig = function () {
     *     return {
     *         iconClassName: 'custom-component-palette-icon',
     *         styleResource: 'style/custom-component-palette.dt.css',
     *         categoryName: 'Custom'
     *     };
     * }
     */
    PaletteItemConfig.prototype.styleResource = '';

    return PaletteRegistrationProvider;

});