chunk-TXJFAAIW.js

Overview

This file implements a comprehensive color picker UI component with support for multiple color formats (RGB, HSL, Hex), alpha channel control, and an editable color input. It provides a class-based API to create, display, update, and interact with the color picker widget in a web page. The component supports popup and inline modes, customizable layouts and options, and exposes events for color change, opening, and closing.

The file also includes utility functions and classes for color parsing, conversion between color spaces (RGB↔HSL), and event management to handle user input and interactions.

Primary functionality includes:

Detailed Explanation of Classes and Functions

Class: z (Color)

This class encapsulates color representation and conversion logic.

Purpose:
Represents a color with internal storage in either RGBA or HSLA format, provides methods to convert, print, and parse color values.

Constructor:
constructor(i, e, t, r)

Properties:

Methods:

Static Methods:

Usage Example:

let c1 = new z("#3498db");         // Hex input
console.log(c1.rgba);               // [52, 152, 219, 1]
console.log(c1.hslaString);         // "hsla(204,70%,53%,1)"
c1.hsla = [0.5, 0.5, 0.5, 0.8];     // Set HSLA color
console.log(c1.printRGB(true));     // "rgba(64,128,128,0.8)"

Class: F (EventManager)

Purpose:
Manages DOM event listeners, providing add, remove, and destroy functionality to help attach and detach events cleanly.

Methods:

Usage:
Used internally to manage events for the picker UI elements such as sliders and buttons.


Function: U(htmlString)

Creates a DOM element from an HTML string.


Function: T(eventManager, element, callback)

Sets up mouse and touch drag event handlers on a slider element to track normalized (0-1) coordinates during interaction.

Supports mouse and touch events, ensures proper coordinate clamping, and prevents default browser behaviors.


Class: W (ColorPicker)

Purpose:
Main exported class implementing the interactive color picker component.

Constructor:
new W(options)

Key Settings:

Public Methods:

Events (Properties to assign callbacks):

Internal Methods & Workflow:

Usage Example:

let picker = new W({
  parent: document.getElementById("color-picker-container"),
  alpha: true,
  editorFormat: "rgb",
  defaultColor: "#ff0000"
});

picker.onChange = (color) => {
  console.log("Color changed:", color.rgbaString);
};

picker.show();

Important Implementation Details

Interaction With Other System Components

Mermaid Diagram

classDiagram
class z {
+constructor(...)
+rgba
+hsla
+rgbString
+rgbaString
+hslString
+hslaString
+hex
+printRGB()
+printHSL()
+static hexToRgb()
+static nameToRgb()
+static rgbToHsl()
+static hslToRgb()
}
class F {
+add()
+remove()
+destroy()
}
class W {
+setOptions()
+setColor()
+setColour()
+show()
+hide()
+destroy()
+onChange
+onDone
+onOpen
+onClose
}
F ..> HTMLElement : manages events on
W *-- F : uses
W *-- z : uses color parsing/conversion

This diagram illustrates the main class relationships:


This file is a self-contained color picker implementation designed for flexible integration into web applications requiring color selection UI with rich format support and customizable interaction. It encapsulates color math, UI rendering, and event management within a single module.