@xsolla/xui-color-picker 0.174.3 → 0.176.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +62 -0
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,6 +1,68 @@
1
1
  # Color Picker
2
2
 
3
3
  A cross-platform React color picker component with a visual selection area, format switching, and color value controls.
4
+ <!-- BEGIN:xui-mcp-instructions:color-picker -->
5
+ A compound component that lets users select a colour through a combination of a gradient canvas, hue and alpha sliders, a numeric input bar, and an optional eyedropper. Supports four colour formats and an optional alpha channel. Designed to be embedded in a popover, modal, or panel triggered by a colour swatch button.
6
+
7
+ ### When to use
8
+ - When a user needs to pick an arbitrary colour — theme customisation, avatar backgrounds, design tools, data visualisation palettes
9
+ - When the product supports branded colour selection with precise numeric input
10
+ - When alpha (opacity) control is part of the feature requirement
11
+
12
+ ### When not to use
13
+ - When the user must choose from a fixed set of colours — use a Select with colour options instead
14
+ - When space is constrained and a full picker is not feasible — offer a hex input field paired with a colour swatch preview
15
+ - As an inline always-visible element on a page — ColorPicker is heavy; embed it in a popover triggered by a swatch button
16
+
17
+ ### Content guidelines
18
+ - Trigger button — the swatch that opens ColorPicker must show the current selected colour as its fill. Pair it with a label or tooltip (*"Choose colour"*) for clarity.
19
+ - Format selector — no visible label is needed inside the Select; the format name itself (HEX, RGB, etc.) acts as the label.
20
+ - Input placeholders — for HEX use #000000; for channel fields use 0. Do not use descriptive placeholder text inside narrow numeric inputs — it will be cut off.
21
+ - Extra content heading — if the slot contains a palette or team swatches, add a short section label above the slot in the popover header, not inside the slot itself.
22
+
23
+ ### Behaviour guidelines
24
+ - Canvas interaction — clicking anywhere on the colour canvas moves the handle to that position and updates all fields immediately. The handle must be draggable with both mouse and touch. Dragging outside the canvas bounds clamps the value to the nearest edge rather than throwing an error.
25
+ - Hue slider — dragging the hue handle updates the canvas background gradient in real time. The current saturation and brightness positions on the canvas are preserved when hue changes so the colour shifts smoothly.
26
+ - Alpha slider — the track background is a gradient from transparent to the current fully-opaque colour, overlaid on a checkerboard pattern. Moving the handle updates the A channel across all input fields.
27
+ - Format switching — switching the format in the Select reformats the input field values to the new format. The colour itself does not change; canvas and slider positions are preserved.
28
+ - Manual input — edits in any input field should update the canvas and sliders in real time as the user types, but commit only on blur, Enter, or Tab. Invalid entries (out-of-range values, malformed HEX strings) are silently clamped or rejected, restoring the last valid value on blur.
29
+ - HEX normalisation — accept 3-character shorthand (#F50 → #FF5500) and 6-/8-character full form. Normalise to uppercase on commit.
30
+ - Copy action — the copy Icon button copies the current colour value to the clipboard in the active format string (e.g. #FF5500, rgb(255, 85, 0), hsl(20, 100%, 50%)). Show a brief confirmation (tooltip or button state change) after copy.
31
+ - Eyedropper flow — after sampling, focus returns to the ColorPicker and all fields update to the picked colour. The format selector retains its current value.
32
+ - Magnifier — the internal .item-colorMagnifier sub-component appears during eyedropper sampling and shows a zoomed pixel grid around the cursor. It has no configurable props at the ColorPicker level.
33
+ - Popover placement — ColorPicker is typically opened from a small colour swatch trigger button. Position the popover so it does not clip the viewport; prefer bottom-start or bottom-end, with top-start / top-end as fallback. The popover width is fixed at 380 px.
34
+ - Closing — the picker closes on: clicking outside the popover, pressing Escape, or an explicit confirm/cancel action if the integration requires it. Live-apply vs confirm-on-close is a product decision — document the chosen behaviour per feature.
35
+
36
+ ### Accessibility
37
+ - The colour canvas handle must have role=*"slider"* with aria-label=*"Colour"* and paired aria-valuenow / aria-valuemin / aria-valuemax attributes for both the horizontal (saturation) and vertical (brightness/lightness) axes. Expose both axes as separate sliders if a single 2D handle is not supported by the target assistive technology.
38
+ - Hue and alpha sliders must each carry role=*"slider"* with aria-label=*"Hue"* / aria-label=*"Opacity"* and aria-valuetext showing the human-readable value (e.g. *"120°"*, *"75%"*).
39
+ - Each numeric input field must have a programmatic label (aria-label) identifying the channel — *"Red"*, *"Green"*, *"Blue"*, *"Alpha"*, *"Hue"*, *"Saturation"*, *"Lightness"*, *"Hex colour"*, etc.
40
+ - The format selector must have aria-label=*"Colour format"*.
41
+ - The eyedropper button must have aria-label=*"Pick colour from screen"*.
42
+ - The copy button must have aria-label=*"Copy colour value"*.
43
+ - If the EyeDropper API is unavailable, hide the button entirely rather than disabling it without explanation.
44
+
45
+ ### Eyedropper
46
+ - When Eyedropper=True, an eyedropper Icon button appears to the left of the sliders. Clicking it activates the native EyeDropper API (where supported), allowing the user to sample any pixel on screen. The picked colour immediately populates all fields and updates the canvas.
47
+
48
+ Browser support for the EyeDropper API must be checked at runtime. When unsupported, hide the button entirely (Eyedropper=False) rather than showing a disabled control with no explanation.
49
+
50
+ ### Keyboard navigation
51
+ - Tab / Shift+Tab
52
+ - Move focus between canvas handle, sliders, format selector, and input fields
53
+ - Arrow keys (canvas focused)
54
+ - Move the colour handle 1 px in the pressed direction
55
+ - Arrow keys (slider focused)
56
+ - Increment / decrement hue or alpha by 1 unit
57
+ - Enter / Space (eyedropper button)
58
+ - Activate eyedropper
59
+ - Enter (input focused)
60
+ - Commit the typed value
61
+ - Tab (input focused)
62
+ - Commit value and move focus to the next field
63
+ - Escape
64
+ - Close the popover (if open) without committing uncommitted input
65
+ <!-- END:xui-mcp-instructions:color-picker -->
4
66
 
5
67
  ## Installation
6
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-color-picker",
3
- "version": "0.174.3",
3
+ "version": "0.176.0",
4
4
  "main": "./web/index.js",
5
5
  "module": "./web/index.mjs",
6
6
  "types": "./web/index.d.ts",
@@ -13,11 +13,11 @@
13
13
  "test:coverage": "vitest run --coverage"
14
14
  },
15
15
  "dependencies": {
16
- "@xsolla/xui-button": "0.174.3",
17
- "@xsolla/xui-core": "0.174.3",
18
- "@xsolla/xui-input": "0.174.3",
19
- "@xsolla/xui-primitives-core": "0.174.3",
20
- "@xsolla/xui-select": "0.174.3"
16
+ "@xsolla/xui-button": "0.176.0",
17
+ "@xsolla/xui-core": "0.176.0",
18
+ "@xsolla/xui-input": "0.176.0",
19
+ "@xsolla/xui-primitives-core": "0.176.0",
20
+ "@xsolla/xui-select": "0.176.0"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "react": ">=16.8.0"