@rogieking/figui3 11.6.0 → 11.6.2

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.
@@ -124,10 +124,11 @@ Authored trailing accessory (`/figui3#property/custom-accessory`):
124
124
  </fig-property>
125
125
  ```
126
126
 
127
- - Attrs: `label`, `leading` (`drag` | `chevron`), `trailing` (`remove` | `add` | `bind`), `show-leading`, `show-trailing`
127
+ - Attrs: `label`, `leading` (`drag` | `chevron`), `trailing` (`remove` | `add` | `bind`), `show-leading`, `show-trailing`, `selected`
128
128
  - Slots: `input` (one direct primary control), `label`, `leading`, `trailing`
129
129
  - Authored label markup overrides the `label` attribute.
130
130
  - Authored accessory slots override generated shortcuts.
131
+ - `selected` and `selected="true"` use the selected background; `selected="false"` does not.
131
132
  - Omitted or `"hover"` show attributes use hover visibility; `"false"` never shows the slot; an empty/present attribute always shows it.
132
133
  - Generated trailing controls emit bubbling, composed `remove`, `add`, or `bind` events with the slotted control in `detail.input`.
133
134
  - Child input events bubble unchanged.
@@ -163,8 +164,10 @@ Reusable ordered palette editor used by `fig-input-palette edit="picker"`.
163
164
  />
164
165
  ```
165
166
 
166
- - Attrs: `value`, `min`, `max`, `fixed`, `disabled`
167
+ - Attrs: `value`, `min`, `max`, `fixed`, `disabled`, `overflow="fade|visible"`, `show-rows`
167
168
  - `max` is unbounded when omitted.
169
+ - Overflow defaults to 6.5 rows with vertical fades; `show-rows` maps to `--fig-palette-editor-overflow-show-rows`, and `visible` shows every row.
170
+ - Additions use shared OKLCH utilities to choose a deterministic, perceptually distinct color that matches the palette.
168
171
  - Events: `input` / `change` with the normalized ordered color array in `detail`
169
172
  - Uses `fig-reorder` for pointer and keyboard reordering.
170
173
 
@@ -180,7 +183,9 @@ Reusable full gradient editor used by the Gradient tab in `fig-fill-picker`.
180
183
  />
181
184
  ```
182
185
 
183
- - Attrs: `value`, `color-space` (`srgb` | `display-p3`), `disabled`.
186
+ - Attrs: `value`, `color-space` (`srgb` | `display-p3`), `disabled`, `overflow="fade|visible"`, `show-rows`.
187
+ - Stop overflow defaults to 6.5 rows with vertical fades; `show-rows` maps to `--fig-gradient-editor-overflow-show-rows`, and `visible` shows every stop.
188
+ - Stop row and bar-handle selection stay synchronized and scroll the selected row into view. The first stop starts selected. Add Stop inserts midway after the selected row, then selects and focuses the new row.
184
189
  - Property: `value` is the normalized gradient config; `cssValue` is the rendered CSS gradient.
185
190
  - Property: `pickerAnchor` accepts an element used to anchor nested stop color pickers.
186
191
  - Events: `input` / `change` with `{ type: "gradient", gradient, css }`.
@@ -201,7 +206,7 @@ Reusable popup containing one `fig-gradient-editor`. It is the picker opened by
201
206
  ></dialog>
202
207
  ```
203
208
 
204
- - Attrs: `value`, `color-space`, `disabled`, plus inherited `fig-popup` attributes.
209
+ - Attrs: `value`, `color-space`, `disabled`, `overflow`, `show-rows`, plus inherited `fig-popup` attributes.
205
210
  - Events: bubbling `input` / `change` with `{ type: "gradient", gradient, css }`.
206
211
  - Create it as `<dialog is="fig-popup-gradient">`.
207
212
 
@@ -220,7 +225,7 @@ Reusable palette dialog used by `fig-input-palette edit="picker"`. It extends
220
225
  ></dialog>
221
226
  ```
222
227
 
223
- - Attrs: `value`, `min`, `max`, `fixed`, `disabled`, plus inherited `fig-popup` attributes.
228
+ - Attrs: `value`, `min`, `max`, `fixed`, `disabled`, `overflow`, `show-rows`, plus inherited `fig-popup` attributes.
224
229
  - Property: `value` returns the normalized `{ color, alpha }[]`.
225
230
  - Events: bubbling `input` / `change` with the normalized color array in `detail`.
226
231
  - Create it as `<dialog is="fig-popup-palette">`, not `<fig-popup-palette>`.
@@ -54,6 +54,7 @@ Events: `input`, `change`, `optionhover`, `optionfocus`.
54
54
  - `leading`: `drag` or `chevron`
55
55
  - `trailing`: `remove`, `add`, or `bind`
56
56
  - `show-leading` / `show-trailing`: omitted or `hover` reveals on hover, `false` hides, and an empty attribute always shows
57
+ - `selected`: present or `true` uses `--figma-color-bg-selected`; `false` leaves the row unselected
57
58
  - Authored accessory slots override generated shortcuts.
58
59
  - `input` returns the direct `slot="input"` element.
59
60
  - Generated labels associate to the input with `aria-labelledby` unless it already has an accessible name.
@@ -81,26 +82,31 @@ Events: `input`, `change`, `optionhover`, `optionfocus`.
81
82
 
82
83
  ## Palette editor
83
84
 
84
- `fig-palette-editor` observes `value`, `min`, `max`, `fixed`, and `disabled`. An omitted `max` allows unlimited colors.
85
+ `fig-palette-editor` observes `value`, `min`, `max`, `fixed`, `disabled`, `overflow`, and `show-rows`. An omitted `max` allows unlimited colors.
85
86
 
86
87
  - `value`: JSON array of hex strings or `{ color, alpha }` objects, or comma-separated hex
87
88
  - `value` property and `input` / `change` event `detail`: normalized ordered `{ color, alpha }[]`
89
+ - `overflow="fade|visible"`: defaults to a bounded list with vertical fades; `visible` shows every row.
90
+ - `show-rows`: defaults to `6.5` and maps to `--fig-palette-editor-overflow-show-rows`.
88
91
  - Rows are direct `fig-reorder` items and support pointer or keyboard reordering.
89
92
 
90
93
  ## Gradient editor
91
94
 
92
- `fig-gradient-editor` observes `value`, `color-space`, and `disabled`.
95
+ `fig-gradient-editor` observes `value`, `color-space`, `disabled`, `overflow`, and `show-rows`.
93
96
 
94
97
  - `value` accepts a gradient config or `{ type: "gradient", gradient }` and returns a normalized gradient config.
95
98
  - `cssValue` returns the current CSS gradient.
96
99
  - `pickerAnchor` anchors nested stop color pickers.
100
+ - `overflow="fade|visible"`: stop rows default to a bounded list with vertical fades; `visible` shows every stop.
101
+ - `show-rows`: defaults to `6.5` and maps to `--fig-gradient-editor-overflow-show-rows`.
97
102
  - Bubbling `input` / `change` detail is `{ type: "gradient", gradient, css }`.
98
103
  - Interpolation remains locked to sRGB to match the fill picker’s current behavior.
99
104
 
100
105
  ## Gradient popup
101
106
 
102
107
  `dialog[is="fig-popup-gradient"]` extends `fig-popup`, owns a
103
- `fig-gradient-editor`, and observes `value`, `color-space`, and `disabled`.
108
+ `fig-gradient-editor`, and observes `value`, `color-space`, `disabled`,
109
+ `overflow`, and `show-rows`.
104
110
 
105
111
  - Defaults: `position="bottom left"`, `offset="0 8"`, `viewport-margin="8"`, and `popover="manual"`.
106
112
  - Bubbling `input` / `change` detail is `{ type: "gradient", gradient, css }`.
@@ -109,7 +115,7 @@ Events: `input`, `change`, `optionhover`, `optionfocus`.
109
115
 
110
116
  `dialog[is="fig-popup-palette"]` extends `fig-popup`, owns a
111
117
  `fig-palette-editor`, and observes `value`, `min`, `max`, `fixed`, and
112
- `disabled` in addition to inherited popup attributes.
118
+ `disabled`, `overflow`, and `show-rows` in addition to inherited popup attributes.
113
119
 
114
120
  - `value` property and bubbling `input` / `change` detail are normalized `{ color, alpha }[]`.
115
121
  - Defaults: `position="bottom left"`, `offset="0 8"`, `viewport-margin="8"`, and `popover="manual"`.
@@ -2,6 +2,14 @@
2
2
 
3
3
  Public API: `README.md`. React recipes: [components.md](components.md).
4
4
 
5
+ ## Color utilities
6
+
7
+ Import pure color math from `@rogieking/figui3/fig-color.js`.
8
+
9
+ - RGB channels: `0–255`; HSL/HSV percentages: `0–100`; OKLab/OKLCH lightness: `0–1`; hue: normalized degrees.
10
+ - Supports sRGB and true Display-P3 conversion, OKLab distance, hue interpolation, gamut testing, and OKLCH chroma-reduction gamut mapping.
11
+ - Achromatic OKLCH colors use hue `0`.
12
+
5
13
  ## Option string formats
6
14
 
7
15
 
package/CHANGELOG.md CHANGED
@@ -2,6 +2,38 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [11.6.2]
6
+
7
+ ### Added
8
+
9
+ - Added shared `fig-color.js` color parsing, conversion, interpolation, contrast, and palette-generation utilities.
10
+ - Added `overflow` and `show-rows` controls for palette and gradient editor stop lists.
11
+ - Added selected-state styling and playground controls for `fig-property`.
12
+
13
+ ### Changed
14
+
15
+ - Refactored palette and gradient editors to synchronize mounted controls and rows in place, preserving focus, popups, drag state, and controlled-value feedback.
16
+ - Extracted the palette editor into dedicated source and stylesheet modules.
17
+ - Improved palette additions with deterministic, harmonious OKLCH colors.
18
+ - Synchronized gradient stop row and handle selection, scrolled selections into view, and inserted new stops after the selected stop.
19
+ - Expanded editor playground examples, controls, tests, and skill documentation.
20
+
21
+ ### Fixed
22
+
23
+ - Prevented semantically equivalent editor updates from replacing active controls or interrupting pointer interactions.
24
+ - Kept gradient stop selection singular and stable across adding, removing, reordering, and external updates.
25
+
26
+ ## [11.6.1]
27
+
28
+ ### Changed
29
+
30
+ - Refined color tips with the tooltip surface color and inset highlight in dark mode.
31
+
32
+ ### Fixed
33
+
34
+ - Kept recursively nested and portaled popups open while interacting with their owning popup chain.
35
+ - Ensured gradient editors keep only one color-stop handle selected at a time.
36
+
5
37
  ## [11.6.0]
6
38
 
7
39
  ### Added
package/README.md CHANGED
@@ -715,7 +715,7 @@ The editable palette is a single tab stop. Enter or Space expands inline mode or
715
715
 
716
716
  `<fig-property>`
717
717
 
718
- An editor-bundle property row. Supply one control in `slot="input"` and optionally author `slot="label"`, `slot="leading"`, or `slot="trailing"` content. Authored label markup takes precedence over the `label` attribute. The `leading="drag|chevron"` and `trailing="remove|add|bind"` attributes generate common accessories; authored slot content takes precedence. Leading and trailing content appears on hover or focus by default. Set `show-leading="false"` or `show-trailing="false"` to hide it, or add an empty `show-leading` or `show-trailing` attribute to always show it. Generated trailing actions emit bubbling, composed events named `remove`, `add`, or `bind` with the slotted control in `detail.input`. Input events bubble directly from the supplied control.
718
+ An editor-bundle property row. Supply one control in `slot="input"` and optionally author `slot="label"`, `slot="leading"`, or `slot="trailing"` content. Authored label markup takes precedence over the `label` attribute. The `leading="drag|chevron"` and `trailing="remove|add|bind"` attributes generate common accessories; authored slot content takes precedence. Leading and trailing content appears on hover or focus by default. Set `show-leading="false"` or `show-trailing="false"` to hide it, or add an empty `show-leading` or `show-trailing` attribute to always show it. Add `selected` or `selected="true"` for the selected background; `selected="false"` leaves the row unselected. Generated trailing actions emit bubbling, composed events named `remove`, `add`, or `bind` with the slotted control in `detail.input`. Input events bubble directly from the supplied control.
719
719
 
720
720
  ```html
721
721
  <fig-property label="Size" leading="drag" trailing="remove">
@@ -725,11 +725,26 @@ An editor-bundle property row. Supply one control in `slot="input"` and optional
725
725
 
726
726
  Import `fig-property.js` and `fig-property.css` directly, or use the `fig-editor` bundle, which includes both.
727
727
 
728
+ #### Color Utilities
729
+
730
+ `fig-color.js` is a side-effect-free color math entry point shared by core and editor components.
731
+
732
+ ```js
733
+ import {
734
+ figHexToOklch,
735
+ figOklchToHex,
736
+ figOklabDistance,
737
+ figMapOklchToGamut,
738
+ } from "@rogieking/figui3/fig-color.js";
739
+ ```
740
+
741
+ RGB channels use `0–255`; HSL/HSV saturation, lightness, and value use `0–100`; OKLab/OKLCH lightness uses `0–1`, chroma is unbounded, and hue uses normalized degrees. Achromatic colors return hue `0`. `figHexToRGB()` returns alpha and `figRGBToHex()` accepts optional alpha; color-space conversion otherwise leaves alpha to the caller. Converters support `colorSpace: "srgb" | "display-p3"`, and `figMapOklchToGamut()` reduces chroma while preserving lightness and hue.
742
+
728
743
  #### Palette Editor
729
744
 
730
745
  `<fig-palette-editor>`
731
746
 
732
- A reusable editor-bundle component for ordered color arrays. It uses `<fig-reorder>` for pointer and keyboard reordering and emits normalized color arrays from `input` and `change`. It supports `value`, `min`, `max`, `fixed`, and `disabled`; omit `max` for an unlimited number of colors.
747
+ A reusable editor-bundle component for ordered color arrays. It uses `<fig-reorder>` for pointer and keyboard reordering and emits normalized color arrays from `input` and `change`. New colors are selected deterministically in OKLCH to remain perceptually distinct while matching the palette’s lightness and chroma. It supports `value`, `min`, `max`, `fixed`, `disabled`, `overflow="fade|visible"`, and `show-rows`; omit `max` for an unlimited number of colors. Overflow defaults to a bounded list showing 6.5 rows with vertical fades. Set `show-rows` to change that height or use `overflow="visible"` to show every row. `show-rows` maps to `--fig-palette-editor-overflow-show-rows`.
733
748
 
734
749
  ```html
735
750
  <fig-palette-editor value='["#94BD00","#83AD00","#1A632A","#003905"]'></fig-palette-editor>
@@ -740,9 +755,15 @@ A reusable editor-bundle component for ordered color arrays. It uses `<fig-reord
740
755
  `<fig-gradient-editor>`
741
756
 
742
757
  A reusable editor-bundle component for gradient type, direction, stop handles,
743
- and reorderable stop rows. It supports `value`, `color-space`, and `disabled`;
744
- its `value` property is the normalized gradient config. Bubbling `input` and
745
- `change` events include `{ type, gradient, css }`.
758
+ and reorderable stop rows. It supports `value`, `color-space`, `disabled`,
759
+ `overflow="fade|visible"`, and `show-rows`. Stops default to a bounded list
760
+ showing 6.5 rows with vertical fades; `show-rows` maps to
761
+ `--fig-gradient-editor-overflow-show-rows`, and `overflow="visible"` shows every
762
+ stop. Stop row and bar-handle selection stay synchronized and scroll the
763
+ selected row into view. The first stop is selected initially. Selecting another
764
+ row makes Add Stop insert midway between it and the following stop; the new stop
765
+ is selected and focused. Its `value` property is the normalized gradient config.
766
+ Bubbling `input` and `change` events include `{ type, gradient, css }`.
746
767
 
747
768
  ```html
748
769
  <fig-gradient-editor
@@ -757,8 +778,8 @@ its `value` property is the normalized gradient config. Bubbling `input` and
757
778
  `<dialog is="fig-popup-gradient">`
758
779
 
759
780
  A reusable `fig-popup` subclass that owns a `<fig-gradient-editor>`. It
760
- supports `value`, `color-space`, and `disabled`, plus inherited popup
761
- positioning. Its bubbling `input` and `change` events include
781
+ supports `value`, `color-space`, `disabled`, `overflow`, and `show-rows`, plus
782
+ inherited popup positioning. Its bubbling `input` and `change` events include
762
783
  `{ type, gradient, css }`.
763
784
 
764
785
  ```html
@@ -1508,7 +1529,10 @@ An anchored floating surface built on `<dialog>` with collision-aware positionin
1508
1529
  </dialog>
1509
1530
  ```
1510
1531
 
1511
- Popups restore focus on close. Escape dismissal is scoped so nested menu and overlay behavior can keep its own keyboard handling.
1532
+ Popups restore focus on close. Escape dismissal is scoped so nested menu and
1533
+ overlay behavior can keep its own keyboard handling. Anchored popups may be
1534
+ rendered in the global overlay root; interacting with a child popup keeps every
1535
+ owning ancestor popup open, including recursively nested chains.
1512
1536
 
1513
1537
  ---
1514
1538
 
package/components.css CHANGED
@@ -7264,8 +7264,10 @@ fig-color-tip {
7264
7264
  height: var(--size);
7265
7265
  aspect-ratio: 1 / 1;
7266
7266
  flex-shrink: 0;
7267
- background-color: var(--figma-color-bg);
7267
+ background-color: light-dark(var(--figma-color-bg), var(--bg-tooltip));
7268
7268
  border-radius: var(--radius-medium, 0.3125rem);
7269
+ box-shadow: inset 0 0.5px 0 0
7270
+ light-dark(rgba(0, 0, 0, 0.06), rgba(255, 255, 255, 0.1));
7269
7271
  filter: var(--fig-popover-shadow);
7270
7272
 
7271
7273
  &[control="add"],