@mrpelz/uikit-ish 7.26.2 → 7.29.1
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.
- package/dist/components/accordion/style.css +0 -3
- package/dist/components/activity-view/style.css +17 -17
- package/dist/components/alert/style.css +12 -10
- package/dist/components/avatar/style.css +2 -2
- package/dist/components/badge/style.css +1 -1
- package/dist/components/button/style.css +12 -12
- package/dist/components/card/buttons.d.ts +35 -0
- package/dist/components/card/buttons.d.ts.map +1 -0
- package/dist/components/card/buttons.js +60 -0
- package/dist/components/card/buttons.js.map +1 -0
- package/dist/components/card/channels.d.ts +43 -0
- package/dist/components/card/channels.d.ts.map +1 -0
- package/dist/components/card/channels.js +321 -0
- package/dist/components/card/channels.js.map +1 -0
- package/dist/components/card/color.d.ts +21 -0
- package/dist/components/card/color.d.ts.map +1 -0
- package/dist/components/card/color.js +100 -0
- package/dist/components/card/color.js.map +1 -0
- package/dist/components/card/main.d.ts +67 -39
- package/dist/components/card/main.d.ts.map +1 -1
- package/dist/components/card/main.js +79 -274
- package/dist/components/card/main.js.map +1 -1
- package/dist/components/card/parts.css +769 -0
- package/dist/components/card/press.d.ts +25 -0
- package/dist/components/card/press.d.ts.map +1 -0
- package/dist/components/card/press.js +111 -0
- package/dist/components/card/press.js.map +1 -0
- package/dist/components/card/progress.d.ts +43 -0
- package/dist/components/card/progress.d.ts.map +1 -0
- package/dist/components/card/progress.js +122 -0
- package/dist/components/card/progress.js.map +1 -0
- package/dist/components/card/props.d.ts +324 -14
- package/dist/components/card/props.d.ts.map +1 -1
- package/dist/components/card/root.d.ts +100 -0
- package/dist/components/card/root.d.ts.map +1 -0
- package/dist/components/card/root.js +388 -0
- package/dist/components/card/root.js.map +1 -0
- package/dist/components/card/rows.d.ts +19 -0
- package/dist/components/card/rows.d.ts.map +1 -0
- package/dist/components/card/rows.js +185 -0
- package/dist/components/card/rows.js.map +1 -0
- package/dist/components/card/segmented.d.ts +61 -0
- package/dist/components/card/segmented.d.ts.map +1 -0
- package/dist/components/card/segmented.js +289 -0
- package/dist/components/card/segmented.js.map +1 -0
- package/dist/components/card/shared.d.ts +55 -0
- package/dist/components/card/shared.d.ts.map +1 -0
- package/dist/components/card/shared.js +80 -0
- package/dist/components/card/shared.js.map +1 -0
- package/dist/components/card/slider.d.ts +16 -0
- package/dist/components/card/slider.d.ts.map +1 -0
- package/dist/components/card/slider.js +48 -0
- package/dist/components/card/slider.js.map +1 -0
- package/dist/components/card/stages.d.ts +18 -0
- package/dist/components/card/stages.d.ts.map +1 -0
- package/dist/components/card/stages.js +37 -0
- package/dist/components/card/stages.js.map +1 -0
- package/dist/components/card/style.css +125 -66
- package/dist/components/checkbox/style.css +10 -5
- package/dist/components/collapsible/style.css +0 -3
- package/dist/components/color-picker/color.d.ts +2 -2
- package/dist/components/color-picker/color.d.ts.map +1 -1
- package/dist/components/color-picker/color.js +7 -7
- package/dist/components/color-picker/color.js.map +1 -1
- package/dist/components/color-picker/main.d.ts +11 -5
- package/dist/components/color-picker/main.d.ts.map +1 -1
- package/dist/components/color-picker/main.js +128 -57
- package/dist/components/color-picker/main.js.map +1 -1
- package/dist/components/color-picker/props.d.ts +216 -6
- package/dist/components/color-picker/props.d.ts.map +1 -1
- package/dist/components/color-picker/style.css +8 -8
- package/dist/components/control-cards/main.d.ts +6 -17
- package/dist/components/control-cards/main.d.ts.map +1 -1
- package/dist/components/control-cards/main.js +119 -758
- package/dist/components/control-cards/main.js.map +1 -1
- package/dist/components/control-cards/props.d.ts +79 -250
- package/dist/components/control-cards/props.d.ts.map +1 -1
- package/dist/components/control-cards/style.css +2 -492
- package/dist/components/date-picker/main.d.ts +8 -3
- package/dist/components/date-picker/main.d.ts.map +1 -1
- package/dist/components/date-picker/main.js +71 -29
- package/dist/components/date-picker/main.js.map +1 -1
- package/dist/components/date-picker/pager.d.ts.map +1 -1
- package/dist/components/date-picker/pager.js +9 -2
- package/dist/components/date-picker/pager.js.map +1 -1
- package/dist/components/date-picker/props.d.ts +81 -5
- package/dist/components/date-picker/props.d.ts.map +1 -1
- package/dist/components/date-picker/style.css +24 -16
- package/dist/components/edit-menu/style.css +2 -2
- package/dist/components/glass/style.css +38 -5
- package/dist/components/grid/main.d.ts +1 -1
- package/dist/components/grid/main.d.ts.map +1 -1
- package/dist/components/grid/main.js +104 -21
- package/dist/components/grid/main.js.map +1 -1
- package/dist/components/grid/props.d.ts +75 -5
- package/dist/components/grid/props.d.ts.map +1 -1
- package/dist/components/grid/style.css +68 -38
- package/dist/components/header/style.css +12 -6
- package/dist/components/index.d.ts +10 -8
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +6 -4
- package/dist/components/index.js.map +1 -1
- package/dist/components/layout/style.css +0 -3
- package/dist/components/list/main.d.ts +5 -3
- package/dist/components/list/main.d.ts.map +1 -1
- package/dist/components/list/main.js +42 -5
- package/dist/components/list/main.js.map +1 -1
- package/dist/components/list/props.d.ts +5 -0
- package/dist/components/list/props.d.ts.map +1 -1
- package/dist/components/list/reorder.d.ts +34 -0
- package/dist/components/list/reorder.d.ts.map +1 -1
- package/dist/components/list/reorder.js +40 -17
- package/dist/components/list/reorder.js.map +1 -1
- package/dist/components/list/style.css +135 -72
- package/dist/components/menu/style.css +38 -30
- package/dist/components/navigation/main.d.ts.map +1 -1
- package/dist/components/navigation/main.js +35 -13
- package/dist/components/navigation/main.js.map +1 -1
- package/dist/components/navigation/style.css +7 -0
- package/dist/components/page-control/main.d.ts.map +1 -1
- package/dist/components/page-control/main.js +32 -15
- package/dist/components/page-control/main.js.map +1 -1
- package/dist/components/page-control/props.d.ts +6 -0
- package/dist/components/page-control/props.d.ts.map +1 -1
- package/dist/components/page-control/style.css +36 -0
- package/dist/components/pager/main.d.ts +12 -0
- package/dist/components/pager/main.d.ts.map +1 -0
- package/dist/components/pager/main.js +368 -0
- package/dist/components/pager/main.js.map +1 -0
- package/dist/components/pager/props.d.ts +36 -0
- package/dist/components/pager/props.d.ts.map +1 -0
- package/dist/components/pager/props.js +2 -0
- package/dist/components/pager/props.js.map +1 -0
- package/dist/components/pager/style.css +42 -0
- package/dist/components/progress/main.d.ts.map +1 -1
- package/dist/components/progress/main.js +3 -2
- package/dist/components/progress/main.js.map +1 -1
- package/dist/components/progress/style.css +4 -10
- package/dist/components/roll/style.css +2 -2
- package/dist/components/segmented/style.css +16 -7
- package/dist/components/settings/main.d.ts +35 -1
- package/dist/components/settings/main.d.ts.map +1 -1
- package/dist/components/settings/main.js +297 -68
- package/dist/components/settings/main.js.map +1 -1
- package/dist/components/settings/props.d.ts +45 -4
- package/dist/components/settings/props.d.ts.map +1 -1
- package/dist/components/settings/region.d.ts +3 -0
- package/dist/components/settings/region.d.ts.map +1 -0
- package/dist/components/settings/region.js +120 -0
- package/dist/components/settings/region.js.map +1 -0
- package/dist/components/settings/style.css +2 -2
- package/dist/components/sheet/snap.d.ts.map +1 -1
- package/dist/components/sheet/snap.js +13 -5
- package/dist/components/sheet/snap.js.map +1 -1
- package/dist/components/sheet/style.css +48 -3
- package/dist/components/slider/main.d.ts.map +1 -1
- package/dist/components/slider/main.js +5 -2
- package/dist/components/slider/main.js.map +1 -1
- package/dist/components/slider/style.css +6 -6
- package/dist/components/stack/main.d.ts +8 -0
- package/dist/components/stack/main.d.ts.map +1 -0
- package/dist/components/stack/main.js +25 -0
- package/dist/components/stack/main.js.map +1 -0
- package/dist/components/stack/props.d.ts +42 -0
- package/dist/components/stack/props.d.ts.map +1 -0
- package/dist/components/stack/props.js +2 -0
- package/dist/components/stack/props.js.map +1 -0
- package/dist/components/stack/style.css +68 -0
- package/dist/components/stepper/main.d.ts +3 -1
- package/dist/components/stepper/main.d.ts.map +1 -1
- package/dist/components/stepper/main.js +4 -0
- package/dist/components/stepper/main.js.map +1 -1
- package/dist/components/stepper/style.css +2 -2
- package/dist/components/switch/main.d.ts.map +1 -1
- package/dist/components/switch/main.js +5 -1
- package/dist/components/switch/main.js.map +1 -1
- package/dist/components/switch/props.d.ts +4 -1
- package/dist/components/switch/props.d.ts.map +1 -1
- package/dist/components/tab-bar/style.css +36 -13
- package/dist/components/text-field/style.css +28 -17
- package/dist/components/toolbar/main.d.ts +5 -2
- package/dist/components/toolbar/main.d.ts.map +1 -1
- package/dist/components/toolbar/main.js +18 -0
- package/dist/components/toolbar/main.js.map +1 -1
- package/dist/components/toolbar/props.d.ts +15 -0
- package/dist/components/toolbar/props.d.ts.map +1 -1
- package/dist/components/toolbar/style.css +126 -10
- package/dist/components/tooltip/style.css +2 -2
- package/dist/components/typography/main.d.ts +1 -0
- package/dist/components/typography/main.d.ts.map +1 -1
- package/dist/components/typography/main.js +1 -0
- package/dist/components/typography/main.js.map +1 -1
- package/dist/components/typography/sizes.css +456 -0
- package/dist/components/typography/style.css +24 -456
- package/dist/components/utils/main.d.ts +23 -6
- package/dist/components/utils/main.d.ts.map +1 -1
- package/dist/components/utils/main.js +60 -7
- package/dist/components/utils/main.js.map +1 -1
- package/dist/components/viewport/edge-effect.d.ts.map +1 -1
- package/dist/components/viewport/edge-effect.js +6 -2
- package/dist/components/viewport/edge-effect.js.map +1 -1
- package/dist/components/viewport/focus-scroll.d.ts.map +1 -1
- package/dist/components/viewport/focus-scroll.js +2 -1
- package/dist/components/viewport/focus-scroll.js.map +1 -1
- package/dist/components/viewport/main.d.ts.map +1 -1
- package/dist/components/viewport/main.js +34 -2
- package/dist/components/viewport/main.js.map +1 -1
- package/dist/components/viewport/style.css +7 -13
- package/dist/styles.css +287 -120
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ import { List } from '../list/main.js';
|
|
|
15
15
|
import { Menu } from '../menu/main.js';
|
|
16
16
|
import { PageControl } from '../page-control/main.js';
|
|
17
17
|
import { Segmented } from '../segmented/main.js';
|
|
18
|
-
import { Checkmark, cn, useForwardedRef, useTouchHold, withStyle, } from '../utils/main.js';
|
|
18
|
+
import { Checkmark, cn, createLabels, smoothScrollOf, useForwardedRef, useTouchHold, withStyle, } from '../utils/main.js';
|
|
19
19
|
import { Viewport } from '../viewport/main.js';
|
|
20
20
|
import { codeGroups, parseCssColor } from './color.js';
|
|
21
21
|
import { cssNamedColors } from './named-colors.js';
|
|
@@ -151,6 +151,48 @@ const PanelContext = createContext({
|
|
|
151
151
|
registerMode: () => undefined,
|
|
152
152
|
setMode: () => undefined,
|
|
153
153
|
});
|
|
154
|
+
/**
|
|
155
|
+
* A picker's built-in words (English): the defaults of every part's
|
|
156
|
+
* `…Label` props (see `ColorPickerLabels`), shown (e.g. a channel's title,
|
|
157
|
+
* the swatches' menu and action sheet) or read by assistive technology.
|
|
158
|
+
*/
|
|
159
|
+
export const colorPickerLabels = {
|
|
160
|
+
addColorLabel: 'Add color',
|
|
161
|
+
blackLabel: 'Black',
|
|
162
|
+
blueLabel: 'Blue',
|
|
163
|
+
channelValueLabel: (channel) => `${channel} value`,
|
|
164
|
+
copyColorCodeLabel: 'Copy color code',
|
|
165
|
+
cyanLabel: 'Cyan',
|
|
166
|
+
deleteColorLabel: 'Delete',
|
|
167
|
+
eyedropperLabel: 'Eyedropper',
|
|
168
|
+
flattenColorLabel: 'Flatten color',
|
|
169
|
+
flattenColorTitleLabel: 'Flatten Color?',
|
|
170
|
+
flattenOnBlackLabel: 'Flatten on Black',
|
|
171
|
+
flattenOnWhiteLabel: 'Flatten on White',
|
|
172
|
+
greenLabel: 'Green',
|
|
173
|
+
gridLabel: 'Grid',
|
|
174
|
+
hexLabel: 'Hex',
|
|
175
|
+
hexWithAlphaLabel: 'Hex with alpha',
|
|
176
|
+
hueLabel: 'Hue',
|
|
177
|
+
indexLabel: 'Index',
|
|
178
|
+
lightnessLabel: 'Lightness',
|
|
179
|
+
magentaLabel: 'Magenta',
|
|
180
|
+
modesLabel: 'Mode',
|
|
181
|
+
opacityLabel: 'Opacity',
|
|
182
|
+
opacityValueLabel: 'Opacity percentage',
|
|
183
|
+
perceptualLabel: 'Perceptual',
|
|
184
|
+
redLabel: 'Red',
|
|
185
|
+
removeTransparencyLabel: 'Remove Transparency',
|
|
186
|
+
saturationLabel: 'Saturation',
|
|
187
|
+
savedColorsLabel: 'Saved colors',
|
|
188
|
+
spectrumLabel: 'Spectrum',
|
|
189
|
+
srgbLabel: 'sRGB',
|
|
190
|
+
systemColorsLabel: 'System colors',
|
|
191
|
+
wideGamutLabel: 'Wide gamut',
|
|
192
|
+
yellowLabel: 'Yellow',
|
|
193
|
+
};
|
|
194
|
+
/** A picker's words (see `Root`), for its parts within; a part's own. */
|
|
195
|
+
const { LabelsContext, omitLabels, useLabels } = createLabels(colorPickerLabels);
|
|
154
196
|
/**
|
|
155
197
|
* A color picker: its color and its mode, for its parts (`Modes`,
|
|
156
198
|
* `Panel`, `Eyedropper`, anywhere in it), in the app's popover or sheet.
|
|
@@ -158,7 +200,10 @@ const PanelContext = createContext({
|
|
|
158
200
|
* toolbar (and, in a sheet, its modes' control) can be in the popup's
|
|
159
201
|
* header (`Popover.Header`, `Sheet.Header`), its panel scrolling under it.
|
|
160
202
|
*/
|
|
161
|
-
const Root = forwardRef((
|
|
203
|
+
const Root = forwardRef((allProps, ref) => {
|
|
204
|
+
const labels = useLabels(allProps);
|
|
205
|
+
const { className, defaultMode, defaultValue = '#000000', mode: modeProp, onModeChange, onValueChange, render, style, value, ...rest } = allProps;
|
|
206
|
+
const props = omitLabels(rest);
|
|
162
207
|
const [own, setOwn] = useState(defaultValue);
|
|
163
208
|
// Its `Opacity`s rendered: without one, the color opaque (its alpha,
|
|
164
209
|
// if given one, dropped).
|
|
@@ -228,7 +273,7 @@ const Root = forwardRef(({ className, defaultMode, defaultValue = '#000000', mod
|
|
|
228
273
|
ref,
|
|
229
274
|
render,
|
|
230
275
|
});
|
|
231
|
-
return (_jsx(PickerContext.Provider, { value: state, children: _jsx(PanelContext.Provider, { value: modes, children: element }) }));
|
|
276
|
+
return (_jsx(LabelsContext.Provider, { value: labels, children: _jsx(PickerContext.Provider, { value: state, children: _jsx(PanelContext.Provider, { value: modes, children: element }) }) }));
|
|
232
277
|
});
|
|
233
278
|
/**
|
|
234
279
|
* Its panel: its modes' control (`Modes`, unless elsewhere, e.g. a sheet's
|
|
@@ -244,7 +289,8 @@ const Panel = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: r
|
|
|
244
289
|
*/
|
|
245
290
|
const Modes = forwardRef(({ children, ...props }, ref) => {
|
|
246
291
|
const { mode, setMode } = useContext(PanelContext);
|
|
247
|
-
|
|
292
|
+
const { modesLabel } = useContext(LabelsContext);
|
|
293
|
+
return (_jsxs(Segmented.Root, { ref: ref, "aria-label": modesLabel,
|
|
248
294
|
// (Its modes, however many, scrolled when they don't fit.)
|
|
249
295
|
overflow: "scroll", ...props, className: cn('uikit-color-picker-modes', props.className), value: mode, onValueChange: (next, details) => setMode(String(next), details), children: [children, _jsx(Segmented.Highlight, {})] }));
|
|
250
296
|
});
|
|
@@ -257,7 +303,8 @@ const Mode = forwardRef(({ value, ...props }, ref) => {
|
|
|
257
303
|
/** Swatches in rows (a gray row, then hues by lightness), its corners 18px. */
|
|
258
304
|
const Grid = forwardRef(({ className, ...props }, ref) => {
|
|
259
305
|
const { color, setColor } = useContext(PickerContext);
|
|
260
|
-
|
|
306
|
+
const { gridLabel } = useContext(LabelsContext);
|
|
307
|
+
return (_jsx("div", { ref: ref, "aria-label": gridLabel, role: "group", ...props, className: cn('uikit-color-picker-grid', className), "data-color-picker-part": "grid", children: grid.flatMap((row) => row.map((hex) => {
|
|
261
308
|
const swatch = parseColor(hex);
|
|
262
309
|
return (_jsx("button", { "aria-label": hex, "aria-pressed": sameColor(swatch, color), style: { backgroundColor: hex }, type: "button", onClick: (event) => setColor({ ...swatch, a: color.a }, { event, reason: 'grid' }) }, hex));
|
|
263
310
|
})) }));
|
|
@@ -265,6 +312,7 @@ const Grid = forwardRef(({ className, ...props }, ref) => {
|
|
|
265
312
|
/** Hues across, white to black down, the color ringed; its corners 18px. */
|
|
266
313
|
const Spectrum = forwardRef(({ className, ...props }, ref) => {
|
|
267
314
|
const { color, setColor } = useContext(PickerContext);
|
|
315
|
+
const { spectrumLabel } = useContext(LabelsContext);
|
|
268
316
|
const { h, l } = toHsl(color);
|
|
269
317
|
const pick = (event) => {
|
|
270
318
|
const { height, left, top, width } = event.currentTarget.getBoundingClientRect();
|
|
@@ -298,7 +346,7 @@ const Spectrum = forwardRef(({ className, ...props }, ref) => {
|
|
|
298
346
|
a: color.a,
|
|
299
347
|
}, { event, reason: 'spectrum' });
|
|
300
348
|
};
|
|
301
|
-
return (_jsx("div", { ref: ref, "aria-label":
|
|
349
|
+
return (_jsx("div", { ref: ref, "aria-label": spectrumLabel, "aria-valuetext": formatColor({ ...color, a: 1 }), role: "slider", tabIndex: 0, ...props, className: cn('uikit-color-picker-spectrum', className), "data-base-ui-swipe-ignore": "", "data-color-picker-part": "spectrum", onKeyDown: handleKeyDown, onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, children: _jsx("span", { style: {
|
|
302
350
|
backgroundColor: formatColor({ ...color, a: 1 }),
|
|
303
351
|
left: `${String((h / 360) * 100)}%`,
|
|
304
352
|
top: `${String((1 - l) * 100)}%`,
|
|
@@ -396,7 +444,7 @@ const ChannelRow = ({ fieldLabel, isCheckered = false, label, max, onValueChange
|
|
|
396
444
|
'--uikit-color-picker-channel-position': value / max,
|
|
397
445
|
'--uikit-color-picker-channel-stops': trackStops(stops),
|
|
398
446
|
'--uikit-color-picker-channel-thumb': thumbColor,
|
|
399
|
-
}, ...holdHandlers, children: _jsx(BaseSlider.Track, { children: _jsx(BaseSlider.Thumb, { className: "uikit-color-picker-channel-thumb", "data-color-picker-part": "channel-thumb" }) }) }) }), _jsxs("label", { className: "uikit-color-picker-channel-field", "data-color-picker-part": "channel-field", children: [_jsx("input", { "aria-label": fieldLabel
|
|
447
|
+
}, ...holdHandlers, children: _jsx(BaseSlider.Track, { children: _jsx(BaseSlider.Thumb, { className: "uikit-color-picker-channel-thumb", "data-color-picker-part": "channel-thumb" }) }) }) }), _jsxs("label", { className: "uikit-color-picker-channel-field", "data-color-picker-part": "channel-field", children: [_jsx("input", { "aria-label": fieldLabel, inputMode: "numeric", value: draft ?? String(value),
|
|
400
448
|
// (Left, or Enter: its value again, e.g. emptied; see
|
|
401
449
|
// `useFieldSelection`.)
|
|
402
450
|
onChange: (event) => type(event.currentTarget.value, event), ...selection }), unit ? _jsx("span", { "aria-hidden": "true", children: unit }) : null] })] })] }));
|
|
@@ -404,9 +452,9 @@ const ChannelRow = ({ fieldLabel, isCheckered = false, label, max, onValueChange
|
|
|
404
452
|
/** Hue (0–360°), saturation and lightness (0–100%). */
|
|
405
453
|
const hsl = {
|
|
406
454
|
channels: [
|
|
407
|
-
{
|
|
408
|
-
{
|
|
409
|
-
{
|
|
455
|
+
{ labelKey: 'hueLabel', max: 360, unit: '°' },
|
|
456
|
+
{ labelKey: 'saturationLabel', max: 100, unit: '%' },
|
|
457
|
+
{ labelKey: 'lightnessLabel', max: 100, unit: '%' },
|
|
410
458
|
],
|
|
411
459
|
from: (color) => {
|
|
412
460
|
const { h, l, s } = toHsl(color);
|
|
@@ -420,10 +468,10 @@ const hsl = {
|
|
|
420
468
|
*/
|
|
421
469
|
const cmyk = {
|
|
422
470
|
channels: [
|
|
423
|
-
{
|
|
424
|
-
{
|
|
425
|
-
{
|
|
426
|
-
{
|
|
471
|
+
{ labelKey: 'cyanLabel', max: 100, unit: '%' },
|
|
472
|
+
{ labelKey: 'magentaLabel', max: 100, unit: '%' },
|
|
473
|
+
{ labelKey: 'yellowLabel', max: 100, unit: '%' },
|
|
474
|
+
{ labelKey: 'blackLabel', max: 100, unit: '%' },
|
|
427
475
|
],
|
|
428
476
|
from: ({ b, g, r }) => {
|
|
429
477
|
const k = 1 - Math.max(r, g, b) / 255;
|
|
@@ -438,9 +486,9 @@ const cmyk = {
|
|
|
438
486
|
/** Red, green and blue (0–255). */
|
|
439
487
|
const rgb = {
|
|
440
488
|
channels: [
|
|
441
|
-
{
|
|
442
|
-
{
|
|
443
|
-
{
|
|
489
|
+
{ labelKey: 'redLabel', max: 255 },
|
|
490
|
+
{ labelKey: 'greenLabel', max: 255 },
|
|
491
|
+
{ labelKey: 'blueLabel', max: 255 },
|
|
444
492
|
],
|
|
445
493
|
from: ({ b, g, r }) => [r, g, b].map((channel) => Math.round(channel)),
|
|
446
494
|
to: ([r = 0, g = 0, b = 0]) => ({ b, g, r }),
|
|
@@ -452,9 +500,9 @@ const rgbKeys = ['r', 'g', 'b'];
|
|
|
452
500
|
*/
|
|
453
501
|
const rgbPercentage = {
|
|
454
502
|
channels: [
|
|
455
|
-
{
|
|
456
|
-
{
|
|
457
|
-
{
|
|
503
|
+
{ labelKey: 'redLabel', max: 100, unit: '%' },
|
|
504
|
+
{ labelKey: 'greenLabel', max: 100, unit: '%' },
|
|
505
|
+
{ labelKey: 'blueLabel', max: 100, unit: '%' },
|
|
458
506
|
],
|
|
459
507
|
from: ({ b, g, r }) => [r, g, b].map((channel) => Math.round((channel / 255) * 100)),
|
|
460
508
|
set: ({ b, g, r }, index, value) => ({
|
|
@@ -493,7 +541,10 @@ const trackColors = (model, color, values, index) => {
|
|
|
493
541
|
* yellow and black), each mixing from the color, its value typed too; then
|
|
494
542
|
* its children (e.g. the `Code`), spaced as the channels.
|
|
495
543
|
*/
|
|
496
|
-
const Sliders = forwardRef((
|
|
544
|
+
const Sliders = forwardRef((allProps, ref) => {
|
|
545
|
+
const labels = useLabels(allProps);
|
|
546
|
+
const { children, className, model: modelName = 'rgb', range = 'byte', ...rest } = allProps;
|
|
547
|
+
const props = omitLabels(rest);
|
|
497
548
|
const { color, setColor } = useContext(PickerContext);
|
|
498
549
|
const model = modelName === 'rgb' && range === 'percentage'
|
|
499
550
|
? rgbPercentage
|
|
@@ -506,7 +557,7 @@ const Sliders = forwardRef(({ children, className, model: modelName = 'rgb', ran
|
|
|
506
557
|
const values = last?.color === opaque && last.model === model
|
|
507
558
|
? last.values
|
|
508
559
|
: model.from(color);
|
|
509
|
-
return (_jsxs("div", { ref: ref, ...props, className: cn('uikit-color-picker-sliders', className), "data-color-picker-part": "sliders", "data-model": modelName, "data-range": modelName === 'rgb' ? range : undefined, children: [model.channels.map(({
|
|
560
|
+
return (_jsxs("div", { ref: ref, ...props, className: cn('uikit-color-picker-sliders', className), "data-color-picker-part": "sliders", "data-model": modelName, "data-range": modelName === 'rgb' ? range : undefined, children: [model.channels.map(({ labelKey, max, unit }, index) => (_jsx(ChannelRow, { fieldLabel: labels.channelValueLabel(labels[labelKey]), label: labels[labelKey], max: max, stops: trackColors(model, color, values, index), thumbColor: opaque, unit: unit, value: values[index] ?? 0, onValueChange: (next, event) => {
|
|
510
561
|
const nextValues = values.with(index, next);
|
|
511
562
|
const nextColor = {
|
|
512
563
|
...withChannel(model, color, values, index, next),
|
|
@@ -518,17 +569,20 @@ const Sliders = forwardRef(({ children, className, model: modelName = 'rgb', ran
|
|
|
518
569
|
values: nextValues,
|
|
519
570
|
});
|
|
520
571
|
setColor(nextColor, { event, reason: 'sliders' });
|
|
521
|
-
} },
|
|
572
|
+
} }, labelKey))), children] }));
|
|
522
573
|
});
|
|
523
574
|
/**
|
|
524
575
|
* The opacity: the color fading in over a checkerboard, in percent; 22px
|
|
525
576
|
* above what follows. Rendered, the color has it (see `Root`): without
|
|
526
577
|
* it, it's opaque.
|
|
527
578
|
*/
|
|
528
|
-
const Opacity = forwardRef((
|
|
579
|
+
const Opacity = forwardRef((allProps, ref) => {
|
|
580
|
+
const { opacityLabel, opacityValueLabel } = useLabels(allProps);
|
|
581
|
+
const { className, ...rest } = allProps;
|
|
582
|
+
const props = omitLabels(rest);
|
|
529
583
|
const { color, registerOpacity, setColor } = useContext(PickerContext);
|
|
530
584
|
useLayoutEffect(registerOpacity, [registerOpacity]);
|
|
531
|
-
return (_jsx("div", { ref: ref, ...props, className: cn('uikit-color-picker-opacity', className), "data-color-picker-part": "opacity", children: _jsx(ChannelRow, { isCheckered: true, fieldLabel:
|
|
585
|
+
return (_jsx("div", { ref: ref, ...props, className: cn('uikit-color-picker-opacity', className), "data-color-picker-part": "opacity", children: _jsx(ChannelRow, { isCheckered: true, fieldLabel: opacityValueLabel, label: opacityLabel, max: 100, thumbColor: formatColor(color), unit: "%", value: Math.round(color.a * 100), stops: [
|
|
532
586
|
formatColor({ ...color, a: 0 }),
|
|
533
587
|
formatColor({ ...color, a: 1 }),
|
|
534
588
|
], onValueChange: (next, event) => setColor({ ...color, a: next / 100 }, { event, reason: 'opacity' }) }) }));
|
|
@@ -540,9 +594,10 @@ const Saved = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: r
|
|
|
540
594
|
const pageSize = 10;
|
|
541
595
|
const SavedSwatch = ({ hex, onDelete }) => {
|
|
542
596
|
const { color, setColor } = useContext(PickerContext);
|
|
597
|
+
const { deleteColorLabel } = useContext(LabelsContext);
|
|
543
598
|
const swatch = parseColor(hex);
|
|
544
599
|
// Its menu (a secondary click: right click, or a long press): delete it.
|
|
545
|
-
return (_jsxs(Menu.Root, { children: [_jsx(Menu.Trigger, { openOn: "secondaryClick", render: _jsx("button", { "aria-label": hex, "aria-pressed": sameColor(swatch, color) && swatch.a === color.a, style: { '--uikit-color-picker-color': hex }, type: "button", onClick: (event) => setColor(swatch, { event, reason: 'saved' }) }) }), _jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Popup, { children: _jsx(Menu.Item, { destructive: true, onClick: (event) => onDelete(event), children: _jsx(Menu.Label, { children:
|
|
600
|
+
return (_jsxs(Menu.Root, { children: [_jsx(Menu.Trigger, { openOn: "secondaryClick", render: _jsx("button", { "aria-label": hex, "aria-pressed": sameColor(swatch, color) && swatch.a === color.a, style: { '--uikit-color-picker-color': hex }, type: "button", onClick: (event) => setColor(swatch, { event, reason: 'saved' }) }) }), _jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Popup, { children: _jsx(Menu.Item, { destructive: true, onClick: (event) => onDelete(event), children: _jsx(Menu.Label, { children: deleteColorLabel }) }) }) }) })] }));
|
|
546
601
|
};
|
|
547
602
|
/** A color laid over an opaque one (`on`): its mix, opaque. */
|
|
548
603
|
const flattened = (color, on) => {
|
|
@@ -556,10 +611,11 @@ const flattened = (color, on) => {
|
|
|
556
611
|
*/
|
|
557
612
|
const FlattenCurrent = () => {
|
|
558
613
|
const { color, setColor } = useContext(PickerContext);
|
|
614
|
+
const { flattenColorLabel, flattenColorTitleLabel, flattenOnBlackLabel, flattenOnWhiteLabel, removeTransparencyLabel, } = useContext(LabelsContext);
|
|
559
615
|
// (Pressed, its button: gone once the color's opaque.)
|
|
560
616
|
const triggerRef = useRef(null);
|
|
561
617
|
const choose = (next) => (event) => setColor(next, { event, reason: 'flatten' });
|
|
562
|
-
return (_jsxs(ActionSheet.Root, { children: [_jsx(ActionSheet.Trigger, { render: _jsx("button", { ref: triggerRef, "aria-label":
|
|
618
|
+
return (_jsxs(ActionSheet.Root, { children: [_jsx(ActionSheet.Trigger, { render: _jsx("button", { ref: triggerRef, "aria-label": flattenColorLabel, className: "uikit-color-picker-current", "data-color-picker-part": "current", type: "button" }) }), _jsxs(ActionSheet.Popup, { finalFocus: () => triggerRef.current?.isConnected === true, children: [_jsx(ActionSheet.Header, { children: _jsx(ActionSheet.Title, { children: flattenColorTitleLabel }) }), _jsxs(ActionSheet.Actions, { children: [_jsx(ActionSheet.Action, { onClick: choose({ ...color, a: 1 }), children: removeTransparencyLabel }), _jsx(ActionSheet.Action, { onClick: choose(flattened(color, 255)), children: flattenOnWhiteLabel }), _jsx(ActionSheet.Action, { onClick: choose(flattened(color, 0)), children: flattenOnBlackLabel })] })] })] }));
|
|
563
619
|
};
|
|
564
620
|
/**
|
|
565
621
|
* The color (82px, 18px corners; translucent, over black and white) beside
|
|
@@ -567,7 +623,11 @@ const FlattenCurrent = () => {
|
|
|
567
623
|
* them, deleting one by its menu). Translucent, pressed: offering it opaque
|
|
568
624
|
* (`flattenOnPress`, see `FlattenCurrent`).
|
|
569
625
|
*/
|
|
570
|
-
const Swatches = forwardRef((
|
|
626
|
+
const Swatches = forwardRef((allProps, ref) => {
|
|
627
|
+
// (Its words, for its saved colors' menus and its action sheet too.)
|
|
628
|
+
const labels = useLabels(allProps);
|
|
629
|
+
const { className, defaultSavedColors: initialSaved = defaultSavedColors, flattenOnPress = true, onSavedColorsChange, savedColors: savedProp, ...rest } = allProps;
|
|
630
|
+
const props = omitLabels(rest);
|
|
571
631
|
const { color } = useContext(PickerContext);
|
|
572
632
|
const [ownSaved, setOwnSaved] = useState(initialSaved);
|
|
573
633
|
const saved = savedProp ?? ownSaved;
|
|
@@ -603,7 +663,7 @@ const Swatches = forwardRef(({ className, defaultSavedColors: initialSaved = def
|
|
|
603
663
|
return undefined;
|
|
604
664
|
const isRightToLeft = getComputedStyle(element).direction === 'rtl';
|
|
605
665
|
element.scrollTo({
|
|
606
|
-
behavior:
|
|
666
|
+
behavior: smoothScrollOf(element),
|
|
607
667
|
left: (isRightToLeft ? -1 : 1) * scrollTarget * element.clientWidth,
|
|
608
668
|
});
|
|
609
669
|
// (Swipes count again once it's there.)
|
|
@@ -619,21 +679,21 @@ const Swatches = forwardRef(({ className, defaultSavedColors: initialSaved = def
|
|
|
619
679
|
setPage(next);
|
|
620
680
|
setScrollTarget(next);
|
|
621
681
|
};
|
|
622
|
-
return (_jsxs("div", { ref: ref, ...props, className: cn('uikit-color-picker-swatches', className), "data-color-picker-part": "swatches", children: [flattenOnPress && color.a < 1 ? (_jsx(FlattenCurrent, {})) : (_jsx("div", { "aria-hidden": "true", className: "uikit-color-picker-current", "data-color-picker-part": "current" })), _jsxs("div", { className: "uikit-color-picker-saved-column", "data-color-picker-part": "saved-column", children: [_jsx("div", { ref: pagesRef, "aria-label":
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
682
|
+
return (_jsx(LabelsContext.Provider, { value: labels, children: _jsxs("div", { ref: ref, ...props, className: cn('uikit-color-picker-swatches', className), "data-color-picker-part": "swatches", children: [flattenOnPress && color.a < 1 ? (_jsx(FlattenCurrent, {})) : (_jsx("div", { "aria-hidden": "true", className: "uikit-color-picker-current", "data-color-picker-part": "current" })), _jsxs("div", { className: "uikit-color-picker-saved-column", "data-color-picker-part": "saved-column", children: [_jsx("div", { ref: pagesRef, "aria-label": labels.savedColorsLabel, className: "uikit-color-picker-saved-pages", "data-color-picker-part": "saved-pages", role: "group", onScroll: handleScroll, children: Array.from({ length: pages }, (_, index) => (_jsx(Saved, {
|
|
683
|
+
// (Only the page shown can be reached.)
|
|
684
|
+
inert: index !== shownPage, children: items
|
|
685
|
+
.slice(index * pageSize, (index + 1) * pageSize)
|
|
686
|
+
.map((hex) => hex === undefined ? (_jsx("button", { "aria-label": labels.addColorLabel, "data-add": "", type: "button", onClick: (event) => {
|
|
687
|
+
const next = formatColor(color);
|
|
688
|
+
if (saved.includes(next))
|
|
689
|
+
return;
|
|
690
|
+
changeSaved([...saved, next], {
|
|
691
|
+
event,
|
|
692
|
+
reason: 'add',
|
|
693
|
+
});
|
|
694
|
+
// On the page it lands on.
|
|
695
|
+
goTo(Math.floor(saved.length / pageSize));
|
|
696
|
+
}, children: "+" }, "add")) : (_jsx(SavedSwatch, { hex: hex, onDelete: (event) => changeSaved(saved.filter((other) => other !== hex), { event, reason: 'delete' }) }, hex))) }, index))) }), pages > 1 ? (_jsx(PageControl, { count: pages, value: shownPage, variant: "plain", onValueChange: goTo })) : null] })] }) }));
|
|
637
697
|
});
|
|
638
698
|
/** The browser's eyedropper (`EyeDropper`), if it has one. */
|
|
639
699
|
const eyeDropper = () => globalThis.EyeDropper;
|
|
@@ -644,6 +704,7 @@ const eyeDropper = () => globalThis.EyeDropper;
|
|
|
644
704
|
*/
|
|
645
705
|
const Eyedropper = ({ render, ...props }) => {
|
|
646
706
|
const { color, setColor } = useContext(PickerContext);
|
|
707
|
+
const { eyedropperLabel } = useContext(LabelsContext);
|
|
647
708
|
const Picker = eyeDropper();
|
|
648
709
|
if (!Picker)
|
|
649
710
|
return null;
|
|
@@ -654,10 +715,10 @@ const Eyedropper = ({ render, ...props }) => {
|
|
|
654
715
|
.catch(() => undefined);
|
|
655
716
|
};
|
|
656
717
|
return render ? (cloneElement(render, {
|
|
657
|
-
'aria-label':
|
|
718
|
+
'aria-label': eyedropperLabel,
|
|
658
719
|
...props,
|
|
659
720
|
onClick: pick,
|
|
660
|
-
})) : (_jsx(Button.Root, { "aria-label":
|
|
721
|
+
})) : (_jsx(Button.Root, { "aria-label": eyedropperLabel, ...props, onClick: pick }));
|
|
661
722
|
};
|
|
662
723
|
/** Whether the browser has a color input (its picker the system's). */
|
|
663
724
|
const hasColorInput = () => {
|
|
@@ -696,6 +757,7 @@ const setAlpha = (input, hasAlpha, value) => {
|
|
|
696
757
|
*/
|
|
697
758
|
const SystemColors = ({ render, ...props }) => {
|
|
698
759
|
const { color, hasOpacity, setColor } = useContext(PickerContext);
|
|
760
|
+
const { systemColorsLabel } = useContext(LabelsContext);
|
|
699
761
|
// (Its input, as rendered: for its button's press.)
|
|
700
762
|
const [input, setInput] = useState(null);
|
|
701
763
|
// (With the opacity, the input's alpha too, where it has one.)
|
|
@@ -710,10 +772,10 @@ const SystemColors = ({ render, ...props }) => {
|
|
|
710
772
|
return null;
|
|
711
773
|
const open = () => input?.click();
|
|
712
774
|
return (_jsxs("span", { className: "uikit-color-picker-system-colors", "data-color-picker-part": "system-colors", children: [render ? (cloneElement(render, {
|
|
713
|
-
'aria-label':
|
|
775
|
+
'aria-label': systemColorsLabel,
|
|
714
776
|
...props,
|
|
715
777
|
onClick: open,
|
|
716
|
-
})) : (_jsx(Button.Root, { "aria-label":
|
|
778
|
+
})) : (_jsx(Button.Root, { "aria-label": systemColorsLabel, ...props, onClick: open })), _jsx("input", { ref: setInput, "aria-hidden": "true", className: "uikit-color-picker-system-colors-input", disabled: props.disabled, tabIndex: -1, type: "color", value: value,
|
|
717
779
|
// (As it's picked, live; without its alpha, the opacity kept.)
|
|
718
780
|
onChange: (event) => {
|
|
719
781
|
// (Any CSS color, with an alpha: see color.ts.)
|
|
@@ -739,7 +801,10 @@ const noSpellcheck = (input) => {
|
|
|
739
801
|
* a code, 3, 4, 6 or 8 of them; with an alpha, 4 or 8), at its end. Kept above the keyboard as it's typed into (as a
|
|
740
802
|
* channel's row).
|
|
741
803
|
*/
|
|
742
|
-
const Code = forwardRef((
|
|
804
|
+
const Code = forwardRef((allProps, ref) => {
|
|
805
|
+
const { hexLabel } = useLabels(allProps);
|
|
806
|
+
const { children, className, ...rest } = allProps;
|
|
807
|
+
const props = omitLabels(rest);
|
|
743
808
|
const { color, setColor } = useContext(PickerContext);
|
|
744
809
|
const [draft, setDraft] = useState(undefined);
|
|
745
810
|
const selection = useFieldSelection(() => setDraft(undefined));
|
|
@@ -758,10 +823,10 @@ const Code = forwardRef(({ children, className, ...props }, ref) => {
|
|
|
758
823
|
reason: 'code',
|
|
759
824
|
});
|
|
760
825
|
};
|
|
761
|
-
return (_jsx(Viewport.KeyboardAccessory, { ref: ref, gap: 20, ...props, className: cn('uikit-color-picker-code', className), "data-color-picker-part": "code", children: _jsxs("div", { className: "uikit-color-picker-channel-row uikit-color-picker-code-row", "data-color-picker-part": "code-row", children: [_jsx("div", { "aria-hidden": "true", className: "uikit-color-picker-channel-title", "data-color-picker-part": "code-title", children:
|
|
826
|
+
return (_jsx(Viewport.KeyboardAccessory, { ref: ref, gap: 20, ...props, className: cn('uikit-color-picker-code', className), "data-color-picker-part": "code", children: _jsxs("div", { className: "uikit-color-picker-channel-row uikit-color-picker-code-row", "data-color-picker-part": "code-row", children: [_jsx("div", { "aria-hidden": "true", className: "uikit-color-picker-channel-title", "data-color-picker-part": "code-title", children: hexLabel }), children, _jsxs("label", { className: "uikit-color-picker-channel-field uikit-color-picker-code-field", "data-color-picker-part": "code-field", children: [_jsx("span", { "aria-hidden": "true", children: "#" }), _jsx("input", {
|
|
762
827
|
// (As a property: spelled differently in React's and Preact's
|
|
763
828
|
// JSX.)
|
|
764
|
-
ref: noSpellcheck, value: draft ?? formatColor(color).slice(1), onChange: (event) => type(event.currentTarget.value, event), ...selection })] })] }) }));
|
|
829
|
+
ref: noSpellcheck, "aria-label": hexLabel, value: draft ?? formatColor(color).slice(1), onChange: (event) => type(event.currentTarget.value, event), ...selection })] })] }) }));
|
|
765
830
|
});
|
|
766
831
|
/** A color well: its color, opening the picker. */
|
|
767
832
|
const Well = forwardRef(({ className, color, size = 'small', style, ...props }, ref) => (_jsx("button", { ref: ref, "aria-label": "Color", "data-color": color === undefined ? undefined : '', "data-size": size, style: withStyle({ '--uikit-color-picker-well-color': color }, style), type: "button", ...props, className: cn('uikit-color-picker-well', className), "data-color-picker-part": "well" })));
|
|
@@ -775,7 +840,10 @@ const copiedFor = 1500;
|
|
|
775
840
|
* clipboard (`onCodeCopy`); for a moment, a checkmark instead of its content
|
|
776
841
|
* (`data-copied`). Its place the app's (in a `Code`, or not).
|
|
777
842
|
*/
|
|
778
|
-
const CodeCopy = (
|
|
843
|
+
const CodeCopy = (allProps) => {
|
|
844
|
+
const labels = useLabels(allProps);
|
|
845
|
+
const { children, onCodeCopy, render, ...rest } = allProps;
|
|
846
|
+
const props = omitLabels(rest);
|
|
779
847
|
const { color } = useContext(PickerContext);
|
|
780
848
|
const [isCopied, setIsCopied] = useState(false);
|
|
781
849
|
useEffect(() => {
|
|
@@ -797,11 +865,11 @@ const CodeCopy = ({ children, onCodeCopy, render, ...props }) => {
|
|
|
797
865
|
const item = ({ code, label, subtitle, well }) => (_jsxs(Menu.Item, { onClick: (event) => copy(code, event), children: [_jsx(Menu.Label, { children: label }), _jsx(Menu.Subtitle, { children: subtitle }), well === undefined ? null : (_jsx(Well, { inert: true, "aria-hidden": "true", className: "uikit-color-picker-code-copy-well", color: well, tabIndex: -1 }))] }, code));
|
|
798
866
|
const content = isCopied ? (_jsx(Button.Icon, { children: _jsx(Checkmark, {}) })) : (children);
|
|
799
867
|
const trigger = render ? (cloneElement(render, {
|
|
800
|
-
'aria-label':
|
|
868
|
+
'aria-label': labels.copyColorCodeLabel,
|
|
801
869
|
...props,
|
|
802
870
|
'data-copied': isCopied ? '' : undefined,
|
|
803
|
-
}, content)) : (_jsx(Button.Root, { "aria-label":
|
|
804
|
-
return (_jsxs(Menu.Root, { children: [_jsx(Menu.Trigger, { render: trigger }), _jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Popup, { children: codeGroups(color, formatColor({ ...color, a: 1 })).map(([title, codes], index) => index === 0 ? (_jsx(Fragment, { children: codes.map((entry) => item(entry)) }, title)) : (_jsxs(Menu.SubmenuRoot, { children: [_jsx(Menu.SubmenuTrigger, { children: _jsx(Menu.Label, { children: title }) }), _jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Popup, { children: codes.map((entry) => item(entry)) }) }) })] }, title))) }) }) })] }));
|
|
871
|
+
}, content)) : (_jsx(Button.Root, { "aria-label": labels.copyColorCodeLabel, ...props, "data-copied": isCopied ? '' : undefined, children: content }));
|
|
872
|
+
return (_jsxs(Menu.Root, { children: [_jsx(Menu.Trigger, { render: trigger }), _jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Popup, { children: codeGroups(color, formatColor({ ...color, a: 1 }), labels).map(([title, codes], index) => index === 0 ? (_jsx(Fragment, { children: codes.map((entry) => item(entry)) }, title)) : (_jsxs(Menu.SubmenuRoot, { children: [_jsx(Menu.SubmenuTrigger, { children: _jsx(Menu.Label, { children: title }) }), _jsx(Menu.Portal, { children: _jsx(Menu.Positioner, { children: _jsx(Menu.Popup, { children: codes.map((entry) => item(entry)) }) }) })] }, title))) }) }) })] }));
|
|
805
873
|
};
|
|
806
874
|
/**
|
|
807
875
|
* Its named colors' rows (see `Named`): one registered (its label's first
|
|
@@ -848,7 +916,10 @@ const revealCentered = (element) => {
|
|
|
848
916
|
* at the top (below the container's scroll padding: e.g. a sheet's header).
|
|
849
917
|
* Shown, the color's row in view at once (see `revealCentered`).
|
|
850
918
|
*/
|
|
851
|
-
const Named = forwardRef((
|
|
919
|
+
const Named = forwardRef((allProps, forwardedRef) => {
|
|
920
|
+
const { indexLabel } = useLabels(allProps);
|
|
921
|
+
const { children, className, ...rest } = allProps;
|
|
922
|
+
const props = omitLabels(rest);
|
|
852
923
|
const ref = useForwardedRef(forwardedRef);
|
|
853
924
|
// Shown (e.g. its mode chosen): the color's row in view, at once.
|
|
854
925
|
useLayoutEffect(() => {
|
|
@@ -869,7 +940,7 @@ const Named = forwardRef(({ children, className, ...props }, forwardedRef) => {
|
|
|
869
940
|
// Its rows' letters, in order (each row its letter's index value, the
|
|
870
941
|
// first jumped to, see List.Index).
|
|
871
942
|
const letters = useMemo(() => [...new Set(entries.map(({ label }) => label))], [entries]);
|
|
872
|
-
return (_jsx(NamedContext.Provider, { value: register, children: _jsx("div", { ref: ref, ...props, className: cn('uikit-color-picker-named', className), "data-color-picker-part": "named", children: _jsxs(List.Root, { listStyle: "insetGrouped", children: [_jsx(List.Section, { children: _jsx(List.Group, { children: children }) }), letters.length > 0 ? (_jsx(List.Index, { "aria-label":
|
|
943
|
+
return (_jsx(NamedContext.Provider, { value: register, children: _jsx("div", { ref: ref, ...props, className: cn('uikit-color-picker-named', className), "data-color-picker-part": "named", children: _jsxs(List.Root, { listStyle: "insetGrouped", children: [_jsx(List.Section, { children: _jsx(List.Group, { children: children }) }), letters.length > 0 ? (_jsx(List.Index, { "aria-label": indexLabel, "data-color-picker-part": "named-index", children: letters.map((letter) => (_jsx(List.IndexItem, { children: letter }, letter))) })) : null] }) }) }));
|
|
873
944
|
});
|
|
874
945
|
/**
|
|
875
946
|
* A named color's row (in a `Named`): its color in a well (inert), its label
|