bryntum / support

An issues-only repository for the Bryntum project management component suite which includes powerful Grid, Scheduler, Calendar, Kanban Task Board and Gantt chart components all built in pure JS / CSS / TypeScript
https://www.bryntum.com
53 stars 6 forks source link

Usage of `EventColorPicker` causes most of `Scheduler` to be imported #9549

Open ExtAnimal opened 2 weeks ago

ExtAnimal commented 2 weeks ago
Screenshot 2024-07-09 at 15 14 44

The colour set should be hoisted into its own module which both EventColorPicker, and SchedulerBase can then import.

ExtAnimal commented 2 weeks ago

As a quick fix, EventColorPicker.js could just import the single mixin which defines those colours, TimelineEventRendering.js. It does not include any other modules, so that removes 100 or so module loads, so:

import ColorPicker from '../../Core/widget/ColorPicker.js';
import TimelineEventRendering from '../view/mixin/TimelineEventRendering.js';
/**
 * @module Scheduler/widget/EventColorPicker
 */

/**
 * A color picker that displays a list of available event colors which the user can select by using mouse or keyboard.
 * See Schedulers {@link Scheduler.view.mixin.TimelineEventRendering#config-eventColor eventColor config} for default
 * available colors.
 *
 * {@inlineexample Scheduler/widget/EventColorPicker.js}
 *
 * ```javascript
 * new EventColorPicker({
 *    appendTo : 'container',
 *    width    : '10em',
 *    onColorSelected() {
 *        console.log(...arguments);
 *    }
 * });
 * ```
 *
 * @classtype colorpicker
 * @extends Core/widget/ColorPicker
 */
export default class EventColorPicker extends ColorPicker {
    static $name = 'EventColorPicker';

    static type = 'eventcolorpicker';

    static configurable = {

        colorClasses : TimelineEventRendering().eventColors,

        colorClassPrefix : 'b-sch-',

        /**
         * @hideconfigs colors
         */

        colors : null,

        /**
         * Provide a {@link Scheduler.model.EventModel} instance to update it's
         * {@link Scheduler.model.mixin.EventModelMixin#field-eventColor} field
         * @config {Scheduler.model.EventModel}
         */
        record : null
    };

    colorSelected({ color }) {
        if (this.record) {
            this.record.eventColor = color;
        }
    }
}

EventColorPicker.initClass();