@zendeskgarden/react-colorpickers 9.0.0-next.0 → 9.0.0-next.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.
- package/dist/index.cjs.js +254 -225
- package/dist/index.esm.js +256 -227
- package/dist/typings/styled/ColorSwatch/StyledColorSwatch.d.ts +1 -2
- package/dist/typings/styled/ColorSwatch/StyledColorSwatchInput.d.ts +13 -0
- package/dist/typings/styled/ColorSwatch/StyledColorSwatchLabel.d.ts +16 -0
- package/dist/typings/styled/ColorSwatch/StyledIcon.d.ts +1 -3
- package/dist/typings/styled/index.d.ts +2 -1
- package/dist/typings/types/index.d.ts +10 -30
- package/package.json +11 -10
- package/dist/typings/styled/ColorSwatch/StyledSwatchButton.d.ts +0 -8
package/dist/index.esm.js
CHANGED
|
@@ -6,19 +6,20 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import * as React from 'react';
|
|
9
|
-
import React__default, {
|
|
9
|
+
import React__default, { useContext, useRef, useState, useEffect, useMemo, useCallback, forwardRef, useReducer, cloneElement, Children } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import { Range, Field, Label, Input } from '@zendeskgarden/react-forms';
|
|
12
12
|
import throttle from 'lodash.throttle';
|
|
13
13
|
import styled, { ThemeContext } from 'styled-components';
|
|
14
|
-
import { retrieveComponentStyles, DEFAULT_THEME, getColor,
|
|
14
|
+
import { retrieveComponentStyles, DEFAULT_THEME, getColor, useText, useDocument } from '@zendeskgarden/react-theming';
|
|
15
15
|
import { stripUnit, math, rgba, hsl, parseToRgb, readableColor, parseToHsl, rgb } from 'polished';
|
|
16
16
|
import { Button } from '@zendeskgarden/react-buttons';
|
|
17
17
|
import { TooltipModal, PLACEMENT } from '@zendeskgarden/react-modals';
|
|
18
18
|
import isEqual from 'lodash.isequal';
|
|
19
19
|
import { composeEventHandlers, useId } from '@zendeskgarden/container-utilities';
|
|
20
|
-
import {
|
|
20
|
+
import { mergeRefs } from 'react-merge-refs';
|
|
21
21
|
import { useGrid } from '@zendeskgarden/container-grid';
|
|
22
|
+
import { Tooltip } from '@zendeskgarden/react-tooltips';
|
|
22
23
|
|
|
23
24
|
function _extends$2() {
|
|
24
25
|
_extends$2 = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -119,22 +120,22 @@ const getThumbPosition = (x, y, rtl, container) => {
|
|
|
119
120
|
};
|
|
120
121
|
};
|
|
121
122
|
|
|
122
|
-
const COMPONENT_ID$
|
|
123
|
+
const COMPONENT_ID$m = 'colorpickers.colorpicker';
|
|
123
124
|
const getColorPickerWidth = props => {
|
|
124
125
|
return props.isOpaque ? 268 : 312;
|
|
125
126
|
};
|
|
126
127
|
const StyledColorPicker = styled.div.attrs({
|
|
127
|
-
'data-garden-id': COMPONENT_ID$
|
|
128
|
-
'data-garden-version': '9.0.0-next.
|
|
128
|
+
'data-garden-id': COMPONENT_ID$m,
|
|
129
|
+
'data-garden-version': '9.0.0-next.2'
|
|
129
130
|
}).withConfig({
|
|
130
131
|
displayName: "StyledColorPicker",
|
|
131
132
|
componentId: "sc-1donyl9-0"
|
|
132
|
-
})(["width:", "px;min-width:", "px;", ";"], getColorPickerWidth, getColorPickerWidth, props => retrieveComponentStyles(COMPONENT_ID$
|
|
133
|
+
})(["width:", "px;min-width:", "px;", ";"], getColorPickerWidth, getColorPickerWidth, props => retrieveComponentStyles(COMPONENT_ID$m, props));
|
|
133
134
|
StyledColorPicker.defaultProps = {
|
|
134
135
|
theme: DEFAULT_THEME
|
|
135
136
|
};
|
|
136
137
|
|
|
137
|
-
const COMPONENT_ID$
|
|
138
|
+
const COMPONENT_ID$l = 'colorpickers.colorpicker_range';
|
|
138
139
|
const thumbStyles = function (styles) {
|
|
139
140
|
let modifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
140
141
|
return `
|
|
@@ -260,23 +261,23 @@ const sizeStyles$2 = props => {
|
|
|
260
261
|
`;
|
|
261
262
|
};
|
|
262
263
|
const StyledRange = styled(Range).attrs({
|
|
263
|
-
'data-garden-id': COMPONENT_ID$
|
|
264
|
-
'data-garden-version': '9.0.0-next.
|
|
264
|
+
'data-garden-id': COMPONENT_ID$l,
|
|
265
|
+
'data-garden-version': '9.0.0-next.2',
|
|
265
266
|
hasLowerTrack: false
|
|
266
267
|
}).withConfig({
|
|
267
268
|
displayName: "StyledRange",
|
|
268
269
|
componentId: "sc-ug3wi9-0"
|
|
269
270
|
})(["", ";", " ", ";", ";"], sizeStyles$2, trackStyles(`
|
|
270
271
|
border-radius: 0;
|
|
271
|
-
`), colorStyles$1, props => retrieveComponentStyles(COMPONENT_ID$
|
|
272
|
+
`), colorStyles$1, props => retrieveComponentStyles(COMPONENT_ID$l, props));
|
|
272
273
|
StyledRange.defaultProps = {
|
|
273
274
|
theme: DEFAULT_THEME
|
|
274
275
|
};
|
|
275
276
|
|
|
276
|
-
const COMPONENT_ID$
|
|
277
|
+
const COMPONENT_ID$k = 'colorpickers.colorpicker_hue';
|
|
277
278
|
const StyledHueRange = styled(StyledRange).attrs({
|
|
278
|
-
'data-garden-id': COMPONENT_ID$
|
|
279
|
-
'data-garden-version': '9.0.0-next.
|
|
279
|
+
'data-garden-id': COMPONENT_ID$k,
|
|
280
|
+
'data-garden-version': '9.0.0-next.2'
|
|
280
281
|
}).withConfig({
|
|
281
282
|
displayName: "StyledHueRange",
|
|
282
283
|
componentId: "sc-13ly7p-0"
|
|
@@ -304,7 +305,7 @@ const checkeredBackground = function (theme, size) {
|
|
|
304
305
|
`;
|
|
305
306
|
};
|
|
306
307
|
|
|
307
|
-
const COMPONENT_ID$
|
|
308
|
+
const COMPONENT_ID$j = 'colorpickers.colorpicker_alpha';
|
|
308
309
|
const background$3 = props => {
|
|
309
310
|
const direction = `to ${props.theme.rtl ? 'left' : 'right'}`;
|
|
310
311
|
const fromColor = `rgba(${props.red}, ${props.green}, ${props.blue}, 0)`;
|
|
@@ -319,8 +320,8 @@ const StyledAlphaRange = styled(StyledRange).attrs(props => ({
|
|
|
319
320
|
backgroundSize: 'auto',
|
|
320
321
|
background: background$3(props)
|
|
321
322
|
},
|
|
322
|
-
'data-garden-id': COMPONENT_ID$
|
|
323
|
-
'data-garden-version': '9.0.0-next.
|
|
323
|
+
'data-garden-id': COMPONENT_ID$j,
|
|
324
|
+
'data-garden-version': '9.0.0-next.2'
|
|
324
325
|
})).withConfig({
|
|
325
326
|
displayName: "StyledAlphaRange",
|
|
326
327
|
componentId: "sc-kuh2xc-0"
|
|
@@ -329,7 +330,7 @@ StyledAlphaRange.defaultProps = {
|
|
|
329
330
|
theme: DEFAULT_THEME
|
|
330
331
|
};
|
|
331
332
|
|
|
332
|
-
const COMPONENT_ID$
|
|
333
|
+
const COMPONENT_ID$i = 'colorpickers.colorpicker_preview_box';
|
|
333
334
|
const background$2 = props => {
|
|
334
335
|
const alpha = props.alpha ? props.alpha / 100 : 0;
|
|
335
336
|
const color = `rgba(${props.red}, ${props.green}, ${props.blue}, ${alpha})`;
|
|
@@ -343,18 +344,18 @@ const StyledPreview = styled.div.attrs(props => ({
|
|
|
343
344
|
style: {
|
|
344
345
|
background: background$2(props)
|
|
345
346
|
},
|
|
346
|
-
'data-garden-id': COMPONENT_ID$
|
|
347
|
-
'data-garden-version': '9.0.0-next.
|
|
347
|
+
'data-garden-id': COMPONENT_ID$i,
|
|
348
|
+
'data-garden-version': '9.0.0-next.2',
|
|
348
349
|
'data-test-id': 'preview-box'
|
|
349
350
|
})).withConfig({
|
|
350
351
|
displayName: "StyledPreview",
|
|
351
352
|
componentId: "sc-d70mj1-0"
|
|
352
|
-
})(["flex-shrink:0;border-radius:", ";box-shadow:inset 0 0 0 ", " ", ";width:", "px;height:", "px;", ";"], props => props.theme.borderRadii.md, props => props.theme.borderWidths.sm, props => rgba(props.theme.palette.black, 0.19), props => props.theme.space.base * (props.isOpaque ? 6 : 8), props => props.theme.space.base * (props.isOpaque ? 6 : 8), props => retrieveComponentStyles(COMPONENT_ID$
|
|
353
|
+
})(["flex-shrink:0;border-radius:", ";box-shadow:inset 0 0 0 ", " ", ";width:", "px;height:", "px;", ";"], props => props.theme.borderRadii.md, props => props.theme.borderWidths.sm, props => rgba(props.theme.palette.black, 0.19), props => props.theme.space.base * (props.isOpaque ? 6 : 8), props => props.theme.space.base * (props.isOpaque ? 6 : 8), props => retrieveComponentStyles(COMPONENT_ID$i, props));
|
|
353
354
|
StyledPreview.defaultProps = {
|
|
354
355
|
theme: DEFAULT_THEME
|
|
355
356
|
};
|
|
356
357
|
|
|
357
|
-
const COMPONENT_ID$
|
|
358
|
+
const COMPONENT_ID$h = 'colorpickers.colorpicker_colorwell';
|
|
358
359
|
const background$1 = props => {
|
|
359
360
|
const blackAlpha = rgba(props.theme.palette.black, 0.9);
|
|
360
361
|
const black = `linear-gradient(0deg, ${props.theme.palette.black}, ${blackAlpha} 1%, transparent 99%)`;
|
|
@@ -365,8 +366,8 @@ const background$1 = props => {
|
|
|
365
366
|
return `${black}, ${white}, ${color}`;
|
|
366
367
|
};
|
|
367
368
|
const StyledColorWell = styled.div.attrs(props => ({
|
|
368
|
-
'data-garden-id': COMPONENT_ID$
|
|
369
|
-
'data-garden-version': '9.0.0-next.
|
|
369
|
+
'data-garden-id': COMPONENT_ID$h,
|
|
370
|
+
'data-garden-version': '9.0.0-next.2',
|
|
370
371
|
'data-test-id': 'colorwell',
|
|
371
372
|
style: {
|
|
372
373
|
background: background$1(props)
|
|
@@ -374,12 +375,12 @@ const StyledColorWell = styled.div.attrs(props => ({
|
|
|
374
375
|
})).withConfig({
|
|
375
376
|
displayName: "StyledColorWell",
|
|
376
377
|
componentId: "sc-54ly7s-0"
|
|
377
|
-
})(["position:relative;margin-bottom:", "px;cursor:pointer;height:208px;overflow:hidden;", ";"], props => props.theme.space.base * 2, props => retrieveComponentStyles(COMPONENT_ID$
|
|
378
|
+
})(["position:relative;margin-bottom:", "px;cursor:pointer;height:208px;overflow:hidden;", ";"], props => props.theme.space.base * 2, props => retrieveComponentStyles(COMPONENT_ID$h, props));
|
|
378
379
|
StyledColorWell.defaultProps = {
|
|
379
380
|
theme: DEFAULT_THEME
|
|
380
381
|
};
|
|
381
382
|
|
|
382
|
-
const COMPONENT_ID$
|
|
383
|
+
const COMPONENT_ID$g = 'colorpickers.colorpicker_colorwell_thumb';
|
|
383
384
|
const sizeStyles$1 = theme => {
|
|
384
385
|
const borderWidth = stripUnit(theme.borderWidths.sm) * 2;
|
|
385
386
|
const size = theme.space.base * 5;
|
|
@@ -393,8 +394,8 @@ const sizeStyles$1 = theme => {
|
|
|
393
394
|
`;
|
|
394
395
|
};
|
|
395
396
|
const StyledColorWellThumb = styled.div.attrs(props => ({
|
|
396
|
-
'data-garden-id': COMPONENT_ID$
|
|
397
|
-
'data-garden-version': '9.0.0-next.
|
|
397
|
+
'data-garden-id': COMPONENT_ID$g,
|
|
398
|
+
'data-garden-version': '9.0.0-next.2',
|
|
398
399
|
'data-test-id': 'colorwell-thumb',
|
|
399
400
|
style: {
|
|
400
401
|
top: `${props.top}%`,
|
|
@@ -403,74 +404,74 @@ const StyledColorWellThumb = styled.div.attrs(props => ({
|
|
|
403
404
|
})).withConfig({
|
|
404
405
|
displayName: "StyledColorWellThumb",
|
|
405
406
|
componentId: "sc-1pnz3jz-0"
|
|
406
|
-
})(["position:absolute;border:solid ", ";border-radius:50%;box-shadow:", ";", ";", ";"], props => props.theme.palette.white, props => props.theme.shadows.lg(`${props.theme.space.base}px`, `${props.theme.space.base * 2}px`, getColor('neutralHue', 800, props.theme, 0.24)), props => sizeStyles$1(props.theme), props => retrieveComponentStyles(COMPONENT_ID$
|
|
407
|
+
})(["position:absolute;border:solid ", ";border-radius:50%;box-shadow:", ";", ";", ";"], props => props.theme.palette.white, props => props.theme.shadows.lg(`${props.theme.space.base}px`, `${props.theme.space.base * 2}px`, getColor('neutralHue', 800, props.theme, 0.24)), props => sizeStyles$1(props.theme), props => retrieveComponentStyles(COMPONENT_ID$g, props));
|
|
407
408
|
StyledColorWellThumb.defaultProps = {
|
|
408
409
|
theme: DEFAULT_THEME
|
|
409
410
|
};
|
|
410
411
|
|
|
411
|
-
const COMPONENT_ID$
|
|
412
|
+
const COMPONENT_ID$f = 'colorpickers.colorpicker_slider_group';
|
|
412
413
|
const StyledSliderGroup = styled.div.attrs({
|
|
413
|
-
'data-garden-id': COMPONENT_ID$
|
|
414
|
-
'data-garden-version': '9.0.0-next.
|
|
414
|
+
'data-garden-id': COMPONENT_ID$f,
|
|
415
|
+
'data-garden-version': '9.0.0-next.2'
|
|
415
416
|
}).withConfig({
|
|
416
417
|
displayName: "StyledSliderGroup",
|
|
417
418
|
componentId: "sc-rsq0ak-0"
|
|
418
|
-
})(["display:flex;justify-content:space-between;margin-bottom:", "px;", ";"], props => props.theme.space.base * 2, props => retrieveComponentStyles(COMPONENT_ID$
|
|
419
|
+
})(["display:flex;justify-content:space-between;margin-bottom:", "px;", ";"], props => props.theme.space.base * 2, props => retrieveComponentStyles(COMPONENT_ID$f, props));
|
|
419
420
|
StyledSliderGroup.defaultProps = {
|
|
420
421
|
theme: DEFAULT_THEME
|
|
421
422
|
};
|
|
422
423
|
|
|
423
|
-
const COMPONENT_ID$
|
|
424
|
+
const COMPONENT_ID$e = 'colorpickers.colorpicker_hex_field';
|
|
424
425
|
const StyledHexField = styled(Field).attrs({
|
|
425
|
-
'data-garden-id': COMPONENT_ID$
|
|
426
|
-
'data-garden-version': '9.0.0-next.
|
|
426
|
+
'data-garden-id': COMPONENT_ID$e,
|
|
427
|
+
'data-garden-version': '9.0.0-next.2',
|
|
427
428
|
spellcheck: false
|
|
428
429
|
}).withConfig({
|
|
429
430
|
displayName: "StyledHexField",
|
|
430
431
|
componentId: "sc-1lk14t4-0"
|
|
431
|
-
})(["display:flex;flex-basis:0;flex-direction:column;flex-grow:1;width:auto;text-align:center;input{direction:ltr;}", ";"], props => retrieveComponentStyles(COMPONENT_ID$
|
|
432
|
+
})(["display:flex;flex-basis:0;flex-direction:column;flex-grow:1;width:auto;text-align:center;input{direction:ltr;}", ";"], props => retrieveComponentStyles(COMPONENT_ID$e, props));
|
|
432
433
|
StyledHexField.defaultProps = {
|
|
433
434
|
theme: DEFAULT_THEME
|
|
434
435
|
};
|
|
435
436
|
|
|
436
|
-
const COMPONENT_ID$
|
|
437
|
+
const COMPONENT_ID$d = 'colorpickers.colorpicker_label';
|
|
437
438
|
const StyledLabel = styled(Label).attrs({
|
|
438
|
-
'data-garden-id': COMPONENT_ID$
|
|
439
|
-
'data-garden-version': '9.0.0-next.
|
|
439
|
+
'data-garden-id': COMPONENT_ID$d,
|
|
440
|
+
'data-garden-version': '9.0.0-next.2'
|
|
440
441
|
}).withConfig({
|
|
441
442
|
displayName: "StyledLabel",
|
|
442
443
|
componentId: "sc-1klhp6m-0"
|
|
443
|
-
})(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;", ";"], props => retrieveComponentStyles(COMPONENT_ID$
|
|
444
|
+
})(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;", ";"], props => retrieveComponentStyles(COMPONENT_ID$d, props));
|
|
444
445
|
StyledLabel.defaultProps = {
|
|
445
446
|
theme: DEFAULT_THEME
|
|
446
447
|
};
|
|
447
448
|
|
|
448
|
-
const COMPONENT_ID$
|
|
449
|
+
const COMPONENT_ID$c = 'colorpickers.colorpicker_input';
|
|
449
450
|
const StyledInput = styled(Input).attrs({
|
|
450
|
-
'data-garden-id': COMPONENT_ID$
|
|
451
|
-
'data-garden-version': '9.0.0-next.
|
|
451
|
+
'data-garden-id': COMPONENT_ID$c,
|
|
452
|
+
'data-garden-version': '9.0.0-next.2',
|
|
452
453
|
focusInset: false
|
|
453
454
|
}).withConfig({
|
|
454
455
|
displayName: "StyledInput",
|
|
455
456
|
componentId: "sc-1iap93p-0"
|
|
456
|
-
})(["text-align:center;", ";"], props => retrieveComponentStyles(COMPONENT_ID$
|
|
457
|
+
})(["text-align:center;", ";"], props => retrieveComponentStyles(COMPONENT_ID$c, props));
|
|
457
458
|
StyledInput.defaultProps = {
|
|
458
459
|
theme: DEFAULT_THEME
|
|
459
460
|
};
|
|
460
461
|
|
|
461
|
-
const COMPONENT_ID$
|
|
462
|
+
const COMPONENT_ID$b = 'colorpickers.colorpicker_input_group';
|
|
462
463
|
const StyledInputGroup = styled.div.attrs({
|
|
463
|
-
'data-garden-id': COMPONENT_ID$
|
|
464
|
-
'data-garden-version': '9.0.0-next.
|
|
464
|
+
'data-garden-id': COMPONENT_ID$b,
|
|
465
|
+
'data-garden-version': '9.0.0-next.2'
|
|
465
466
|
}).withConfig({
|
|
466
467
|
displayName: "StyledInputGroup",
|
|
467
468
|
componentId: "sc-mmy93w-0"
|
|
468
|
-
})(["display:flex;justify-content:space-between;", ";"], props => retrieveComponentStyles(COMPONENT_ID$
|
|
469
|
+
})(["display:flex;justify-content:space-between;", ";"], props => retrieveComponentStyles(COMPONENT_ID$b, props));
|
|
469
470
|
StyledInputGroup.defaultProps = {
|
|
470
471
|
theme: DEFAULT_THEME
|
|
471
472
|
};
|
|
472
473
|
|
|
473
|
-
const COMPONENT_ID$
|
|
474
|
+
const COMPONENT_ID$a = 'colorpickers.colorpicker_rgb_field';
|
|
474
475
|
const sizeStyles = theme => {
|
|
475
476
|
const margin = `${theme.space.base * 1.5}px`;
|
|
476
477
|
const width = `${theme.space.base * 12.75}px`;
|
|
@@ -481,42 +482,42 @@ const sizeStyles = theme => {
|
|
|
481
482
|
`;
|
|
482
483
|
};
|
|
483
484
|
const StyledRGBAField = styled(Field).attrs({
|
|
484
|
-
'data-garden-id': COMPONENT_ID$
|
|
485
|
-
'data-garden-version': '9.0.0-next.
|
|
485
|
+
'data-garden-id': COMPONENT_ID$a,
|
|
486
|
+
'data-garden-version': '9.0.0-next.2'
|
|
486
487
|
}).withConfig({
|
|
487
488
|
displayName: "StyledRGBAField",
|
|
488
489
|
componentId: "sc-ibo1yw-0"
|
|
489
|
-
})(["display:flex;flex-direction:column;text-align:center;", ";", ";"], props => sizeStyles(props.theme), props => retrieveComponentStyles(COMPONENT_ID$
|
|
490
|
+
})(["display:flex;flex-direction:column;text-align:center;", ";", ";"], props => sizeStyles(props.theme), props => retrieveComponentStyles(COMPONENT_ID$a, props));
|
|
490
491
|
StyledRGBAField.defaultProps = {
|
|
491
492
|
theme: DEFAULT_THEME
|
|
492
493
|
};
|
|
493
494
|
|
|
494
|
-
const COMPONENT_ID$
|
|
495
|
+
const COMPONENT_ID$9 = 'colorpickers.colorpicker_sliders';
|
|
495
496
|
const StyledSliders = styled.div.attrs({
|
|
496
|
-
'data-garden-id': COMPONENT_ID$
|
|
497
|
-
'data-garden-version': '9.0.0-next.
|
|
497
|
+
'data-garden-id': COMPONENT_ID$9,
|
|
498
|
+
'data-garden-version': '9.0.0-next.2'
|
|
498
499
|
}).withConfig({
|
|
499
500
|
displayName: "StyledSliders",
|
|
500
501
|
componentId: "sc-aclca2-0"
|
|
501
|
-
})(["position:relative;margin-", ":", "px;width:100%;& > *{position:absolute;width:100%;height:", "px;}& > :first-child{top:-", "px;}& > :last-child{bottom:-", "px;}", ";"], props => props.theme.rtl ? 'right' : 'left', props => props.theme.space.base * 2, props => getTrackMargin(props) * 2 + getTrackHeight(props), getTrackMargin, getTrackMargin, props => retrieveComponentStyles(COMPONENT_ID$
|
|
502
|
+
})(["position:relative;margin-", ":", "px;width:100%;& > *{position:absolute;width:100%;height:", "px;}& > :first-child{top:-", "px;}& > :last-child{bottom:-", "px;}", ";"], props => props.theme.rtl ? 'right' : 'left', props => props.theme.space.base * 2, props => getTrackMargin(props) * 2 + getTrackHeight(props), getTrackMargin, getTrackMargin, props => retrieveComponentStyles(COMPONENT_ID$9, props));
|
|
502
503
|
StyledSliders.defaultProps = {
|
|
503
504
|
theme: DEFAULT_THEME
|
|
504
505
|
};
|
|
505
506
|
|
|
506
|
-
const COMPONENT_ID$
|
|
507
|
+
const COMPONENT_ID$8 = 'colorpickers.colordialog_button';
|
|
507
508
|
const StyledButton = styled(Button).attrs({
|
|
508
509
|
isNeutral: true,
|
|
509
|
-
'data-garden-id': COMPONENT_ID$
|
|
510
|
-
'data-garden-version': '9.0.0-next.
|
|
510
|
+
'data-garden-id': COMPONENT_ID$8,
|
|
511
|
+
'data-garden-version': '9.0.0-next.2'
|
|
511
512
|
}).withConfig({
|
|
512
513
|
displayName: "StyledButton",
|
|
513
514
|
componentId: "sc-101xjve-0"
|
|
514
|
-
})(["padding:0;width:", "px;max-width:", "px;&:last-of-type:not(:first-child){border-top-", "-radius:", " !important;border-bottom-", "-radius:", " !important;}", ";"], props => props.theme.space.base * 17, props => props.theme.space.base * 17, props => props.theme.rtl ? 'left' : 'right', props => props.theme.borderRadii.md, props => props.theme.rtl ? 'left' : 'right', props => props.theme.borderRadii.md, props => retrieveComponentStyles(COMPONENT_ID$
|
|
515
|
+
})(["padding:0;width:", "px;max-width:", "px;&:last-of-type:not(:first-child){border-top-", "-radius:", " !important;border-bottom-", "-radius:", " !important;}", ";"], props => props.theme.space.base * 17, props => props.theme.space.base * 17, props => props.theme.rtl ? 'left' : 'right', props => props.theme.borderRadii.md, props => props.theme.rtl ? 'left' : 'right', props => props.theme.borderRadii.md, props => retrieveComponentStyles(COMPONENT_ID$8, props));
|
|
515
516
|
StyledButton.defaultProps = {
|
|
516
517
|
theme: DEFAULT_THEME
|
|
517
518
|
};
|
|
518
519
|
|
|
519
|
-
const COMPONENT_ID$
|
|
520
|
+
const COMPONENT_ID$7 = 'colorpickers.colordialog_preview';
|
|
520
521
|
const background = props => {
|
|
521
522
|
const {
|
|
522
523
|
backgroundColor
|
|
@@ -541,102 +542,124 @@ const StyledButtonPreview = styled.span.attrs(props => ({
|
|
|
541
542
|
style: {
|
|
542
543
|
background: `${background(props)}, ${checkeredBackground(props.theme, 8)}`
|
|
543
544
|
},
|
|
544
|
-
'data-garden-id': COMPONENT_ID$
|
|
545
|
-
'data-garden-version': '9.0.0-next.
|
|
545
|
+
'data-garden-id': COMPONENT_ID$7,
|
|
546
|
+
'data-garden-version': '9.0.0-next.2',
|
|
546
547
|
'data-test-id': 'dialog-preview'
|
|
547
548
|
})).withConfig({
|
|
548
549
|
displayName: "StyledButtonPreview",
|
|
549
550
|
componentId: "sc-1jzysg3-0"
|
|
550
|
-
})(["display:inline-block;bottom:", "px;border-radius:", ";box-shadow:inset 0 0 0 ", " ", ";width:", "px;height:", "px;", ";"], props => props.theme.space.base, props => props.theme.borderRadii.sm, props => props.theme.borderWidths.sm, props => rgba(props.theme.palette.black, 0.19), props => props.theme.space.base * 5, props => props.theme.space.base * 5, props => retrieveComponentStyles(COMPONENT_ID$
|
|
551
|
+
})(["display:inline-block;bottom:", "px;border-radius:", ";box-shadow:inset 0 0 0 ", " ", ";width:", "px;height:", "px;", ";"], props => props.theme.space.base, props => props.theme.borderRadii.sm, props => props.theme.borderWidths.sm, props => rgba(props.theme.palette.black, 0.19), props => props.theme.space.base * 5, props => props.theme.space.base * 5, props => retrieveComponentStyles(COMPONENT_ID$7, props));
|
|
551
552
|
StyledButtonPreview.defaultProps = {
|
|
552
553
|
theme: DEFAULT_THEME
|
|
553
554
|
};
|
|
554
555
|
|
|
555
|
-
const COMPONENT_ID$
|
|
556
|
+
const COMPONENT_ID$6 = 'colorpickers.colordialog_tooltipmodal';
|
|
556
557
|
const StyledTooltipModal = styled(TooltipModal).attrs({
|
|
557
|
-
'data-garden-id': COMPONENT_ID$
|
|
558
|
-
'data-garden-version': '9.0.0-next.
|
|
558
|
+
'data-garden-id': COMPONENT_ID$6,
|
|
559
|
+
'data-garden-version': '9.0.0-next.2'
|
|
559
560
|
}).withConfig({
|
|
560
561
|
displayName: "StyledTooltipModal",
|
|
561
562
|
componentId: "sc-o022s8-0"
|
|
562
|
-
})(["width:auto !important;", ";"], props => retrieveComponentStyles(COMPONENT_ID$
|
|
563
|
+
})(["width:auto !important;", ";"], props => retrieveComponentStyles(COMPONENT_ID$6, props));
|
|
563
564
|
StyledTooltipModal.defaultProps = {
|
|
564
565
|
theme: DEFAULT_THEME
|
|
565
566
|
};
|
|
566
567
|
|
|
567
|
-
const COMPONENT_ID$
|
|
568
|
+
const COMPONENT_ID$5 = 'colorpickers.colordialog_tooltipmodal_body';
|
|
568
569
|
const StyledTooltipBody = styled(TooltipModal.Body).attrs({
|
|
569
|
-
'data-garden-id': COMPONENT_ID$
|
|
570
|
-
'data-garden-version': '9.0.0-next.
|
|
570
|
+
'data-garden-id': COMPONENT_ID$5,
|
|
571
|
+
'data-garden-version': '9.0.0-next.2'
|
|
571
572
|
}).withConfig({
|
|
572
573
|
displayName: "StyledTooltipBody",
|
|
573
574
|
componentId: "sc-6gsgsy-0"
|
|
574
|
-
})(["padding:0;", ";"], props => retrieveComponentStyles(COMPONENT_ID$
|
|
575
|
+
})(["padding:0;", ";"], props => retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
575
576
|
StyledTooltipBody.defaultProps = {
|
|
576
577
|
theme: DEFAULT_THEME
|
|
577
578
|
};
|
|
578
579
|
|
|
579
|
-
const COMPONENT_ID$
|
|
580
|
-
const StyledSwatchButton = styled(StyledButtonPreview).attrs(props => ({
|
|
581
|
-
as: 'button',
|
|
582
|
-
'data-garden-id': COMPONENT_ID$3,
|
|
583
|
-
'data-test-id': props.backgroundColor,
|
|
584
|
-
'data-garden-version': '9.0.0-next.0'
|
|
585
|
-
})).withConfig({
|
|
586
|
-
displayName: "StyledSwatchButton",
|
|
587
|
-
componentId: "sc-edpwpp-0"
|
|
588
|
-
})(["transition:box-shadow 0.1s ease-in-out;outline:none;border:none;border-radius:", ";cursor:pointer;padding:0;", " ", ";"], props => props.theme.borderRadii.md, props => focusStyles({
|
|
589
|
-
theme: props.theme
|
|
590
|
-
}), props => retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
591
|
-
StyledSwatchButton.defaultProps = {
|
|
592
|
-
theme: DEFAULT_THEME
|
|
593
|
-
};
|
|
594
|
-
|
|
595
|
-
const COMPONENT_ID$2 = 'colorpickers.color_swatch';
|
|
580
|
+
const COMPONENT_ID$4 = 'colorpickers.color_swatch';
|
|
596
581
|
const StyledColorSwatch = styled.table.attrs({
|
|
597
|
-
'data-garden-id': COMPONENT_ID$
|
|
598
|
-
'data-garden-version': '9.0.0-next.
|
|
599
|
-
role: 'grid'
|
|
582
|
+
'data-garden-id': COMPONENT_ID$4,
|
|
583
|
+
'data-garden-version': '9.0.0-next.2'
|
|
600
584
|
}).withConfig({
|
|
601
585
|
displayName: "StyledColorSwatch",
|
|
602
586
|
componentId: "sc-ajx440-0"
|
|
603
|
-
})(["border-collapse:collapse;line-height:normal;", ";"], props => retrieveComponentStyles(COMPONENT_ID$
|
|
587
|
+
})(["border-collapse:collapse;line-height:normal;", ";"], props => retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
604
588
|
StyledColorSwatch.defaultProps = {
|
|
605
589
|
theme: DEFAULT_THEME
|
|
606
590
|
};
|
|
607
591
|
|
|
608
|
-
const COMPONENT_ID$
|
|
592
|
+
const COMPONENT_ID$3 = 'colorpickers.color_swatch_input';
|
|
593
|
+
const StyledColorSwatchInput = styled.input.attrs({
|
|
594
|
+
'data-garden-id': COMPONENT_ID$3,
|
|
595
|
+
'data-garden-version': '9.0.0-next.2'
|
|
596
|
+
}).withConfig({
|
|
597
|
+
displayName: "StyledColorSwatchInput",
|
|
598
|
+
componentId: "sc-em45h0-0"
|
|
599
|
+
})(["position:absolute;opacity:0;z-index:1;margin:0;width:100%;height:100%;", ";"], props => retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
600
|
+
StyledColorSwatchInput.defaultProps = {
|
|
601
|
+
theme: DEFAULT_THEME
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
const COMPONENT_ID$2 = 'colorpickers.color_swatch_label';
|
|
609
605
|
const colorStyles = props => {
|
|
610
|
-
const
|
|
611
|
-
theme,
|
|
612
|
-
color
|
|
613
|
-
} = props;
|
|
606
|
+
const boxShadow = props.theme.shadows.md(getColor('primaryHue', 600, props.theme, 0.35));
|
|
614
607
|
const {
|
|
615
608
|
alpha
|
|
616
|
-
} = parseToRgb(
|
|
617
|
-
let
|
|
618
|
-
if (alpha
|
|
619
|
-
|
|
609
|
+
} = parseToRgb(props.backgroundColor);
|
|
610
|
+
let foregroundColor;
|
|
611
|
+
if (alpha && alpha < 0.4) {
|
|
612
|
+
foregroundColor = props.theme.colors.foreground;
|
|
613
|
+
} else {
|
|
614
|
+
foregroundColor = readableColor(props.backgroundColor, props.theme.colors.foreground, props.theme.colors.background);
|
|
620
615
|
}
|
|
621
616
|
return `
|
|
622
|
-
color: ${
|
|
617
|
+
color: ${foregroundColor};
|
|
618
|
+
|
|
619
|
+
&[data-garden-focus-visible] {
|
|
620
|
+
box-shadow: ${boxShadow};
|
|
623
621
|
`;
|
|
624
622
|
};
|
|
625
|
-
const
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
623
|
+
const StyledColorSwatchLabel = styled(StyledButtonPreview).attrs({
|
|
624
|
+
as: 'label',
|
|
625
|
+
'data-garden-id': COMPONENT_ID$2,
|
|
626
|
+
'data-garden-version': '9.0.0-next.2'
|
|
627
|
+
}).withConfig({
|
|
628
|
+
displayName: "StyledColorSwatchLabel",
|
|
629
|
+
componentId: "sc-1aghocg-0"
|
|
630
|
+
})(["position:relative;border-radius:", ";cursor:pointer;", ";", ";"], props => props.theme.borderRadii.md, colorStyles, props => retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
631
|
+
StyledColorSwatchLabel.defaultProps = {
|
|
632
|
+
theme: DEFAULT_THEME
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
var _path$1;
|
|
636
|
+
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
637
|
+
var SvgCheckSmFill = function SvgCheckSmFill(props) {
|
|
638
|
+
return /*#__PURE__*/React.createElement("svg", _extends$1({
|
|
639
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
640
|
+
width: 12,
|
|
641
|
+
height: 12,
|
|
642
|
+
focusable: "false",
|
|
643
|
+
viewBox: "0 0 12 12",
|
|
644
|
+
"aria-hidden": "true"
|
|
645
|
+
}, props), _path$1 || (_path$1 = /*#__PURE__*/React.createElement("path", {
|
|
646
|
+
fill: "none",
|
|
647
|
+
stroke: "currentColor",
|
|
648
|
+
strokeLinecap: "round",
|
|
649
|
+
strokeLinejoin: "round",
|
|
650
|
+
strokeWidth: 2,
|
|
651
|
+
d: "M3 6l2 2 4-4"
|
|
652
|
+
})));
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
const COMPONENT_ID$1 = 'colorpickers.colorswatch_check';
|
|
656
|
+
const StyledIcon = styled(SvgCheckSmFill).attrs({
|
|
634
657
|
'data-garden-id': COMPONENT_ID$1,
|
|
635
|
-
'data-garden-version': '9.0.0-next.
|
|
658
|
+
'data-garden-version': '9.0.0-next.2'
|
|
636
659
|
}).withConfig({
|
|
637
660
|
displayName: "StyledIcon",
|
|
638
661
|
componentId: "sc-8oigif-0"
|
|
639
|
-
})(["transition:opacity 0.2s ease-in-out;opacity:
|
|
662
|
+
})(["position:absolute;top:0;left:0;transition:opacity 0.2s ease-in-out;opacity:0;width:100%;height:100%;", ":checked ~ &{opacity:1;}", ";"], StyledColorSwatchInput, props => retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
640
663
|
StyledIcon.defaultProps = {
|
|
641
664
|
theme: DEFAULT_THEME
|
|
642
665
|
};
|
|
@@ -644,7 +667,7 @@ StyledIcon.defaultProps = {
|
|
|
644
667
|
const COMPONENT_ID = 'colorpickers.swatch_cell';
|
|
645
668
|
const StyledCell = styled.td.attrs({
|
|
646
669
|
'data-garden-id': COMPONENT_ID,
|
|
647
|
-
'data-garden-version': '9.0.0-next.
|
|
670
|
+
'data-garden-version': '9.0.0-next.2'
|
|
648
671
|
}).withConfig({
|
|
649
672
|
displayName: "StyledCell",
|
|
650
673
|
componentId: "sc-qr3oit-0"
|
|
@@ -1198,17 +1221,17 @@ Colorpicker.propTypes = {
|
|
|
1198
1221
|
defaultColor: PropTypes.oneOfType([PropTypes.object, PropTypes.string])
|
|
1199
1222
|
};
|
|
1200
1223
|
|
|
1201
|
-
var _path
|
|
1202
|
-
function _extends
|
|
1224
|
+
var _path;
|
|
1225
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
1203
1226
|
var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
|
|
1204
|
-
return /*#__PURE__*/React.createElement("svg", _extends
|
|
1227
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
1205
1228
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1206
1229
|
width: 16,
|
|
1207
1230
|
height: 16,
|
|
1208
1231
|
focusable: "false",
|
|
1209
1232
|
viewBox: "0 0 16 16",
|
|
1210
1233
|
"aria-hidden": "true"
|
|
1211
|
-
}, props), _path
|
|
1234
|
+
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
1212
1235
|
fill: "currentColor",
|
|
1213
1236
|
d: "M12.688 5.61a.5.5 0 01.69.718l-.066.062-5 4a.5.5 0 01-.542.054l-.082-.054-5-4a.5.5 0 01.55-.83l.074.05L8 9.359l4.688-3.75z"
|
|
1214
1237
|
})));
|
|
@@ -1226,7 +1249,6 @@ const ColorpickerDialog = forwardRef((_ref, ref) => {
|
|
|
1226
1249
|
isAnimated,
|
|
1227
1250
|
isOpaque,
|
|
1228
1251
|
isOpen,
|
|
1229
|
-
popperModifiers,
|
|
1230
1252
|
zIndex,
|
|
1231
1253
|
focusInset,
|
|
1232
1254
|
disabled,
|
|
@@ -1288,7 +1310,6 @@ const ColorpickerDialog = forwardRef((_ref, ref) => {
|
|
|
1288
1310
|
}, React__default.createElement(SvgChevronDownStroke, null))), React__default.createElement(StyledTooltipModal, _extends$2({
|
|
1289
1311
|
ref: ref,
|
|
1290
1312
|
hasArrow: hasArrow,
|
|
1291
|
-
popperModifiers: popperModifiers,
|
|
1292
1313
|
zIndex: zIndex,
|
|
1293
1314
|
isAnimated: isAnimated,
|
|
1294
1315
|
isOpaque: isOpaque,
|
|
@@ -1318,7 +1339,6 @@ ColorpickerDialog.propTypes = {
|
|
|
1318
1339
|
disabled: PropTypes.bool,
|
|
1319
1340
|
labels: PropTypes.object,
|
|
1320
1341
|
buttonProps: PropTypes.object,
|
|
1321
|
-
popperModifiers: PropTypes.any,
|
|
1322
1342
|
zIndex: PropTypes.number,
|
|
1323
1343
|
hasArrow: PropTypes.bool,
|
|
1324
1344
|
isAnimated: PropTypes.bool,
|
|
@@ -1333,109 +1353,134 @@ ColorpickerDialog.defaultProps = {
|
|
|
1333
1353
|
};
|
|
1334
1354
|
ColorpickerDialog.displayName = 'ColorpickerDialog';
|
|
1335
1355
|
|
|
1336
|
-
var _path;
|
|
1337
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
1338
|
-
var SvgCheckSmFill = function SvgCheckSmFill(props) {
|
|
1339
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
1340
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1341
|
-
width: 12,
|
|
1342
|
-
height: 12,
|
|
1343
|
-
focusable: "false",
|
|
1344
|
-
viewBox: "0 0 12 12",
|
|
1345
|
-
"aria-hidden": "true"
|
|
1346
|
-
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
1347
|
-
fill: "none",
|
|
1348
|
-
stroke: "currentColor",
|
|
1349
|
-
strokeLinecap: "round",
|
|
1350
|
-
strokeLinejoin: "round",
|
|
1351
|
-
strokeWidth: 2,
|
|
1352
|
-
d: "M3 6l2 2 4-4"
|
|
1353
|
-
})));
|
|
1354
|
-
};
|
|
1355
|
-
|
|
1356
1356
|
const ColorSwatch = forwardRef((_ref, ref) => {
|
|
1357
1357
|
let {
|
|
1358
|
+
name,
|
|
1358
1359
|
colors,
|
|
1360
|
+
isCheckboxGroup,
|
|
1361
|
+
defaultSelectedColIndex,
|
|
1362
|
+
defaultSelectedRowIndex,
|
|
1363
|
+
selectedColIndex,
|
|
1364
|
+
selectedRowIndex,
|
|
1365
|
+
onSelect,
|
|
1359
1366
|
...props
|
|
1360
1367
|
} = _ref;
|
|
1361
|
-
const
|
|
1362
|
-
|
|
1363
|
-
|
|
1368
|
+
const theme = useContext(ThemeContext) || DEFAULT_THEME;
|
|
1369
|
+
const environment = useDocument(theme);
|
|
1370
|
+
const gridRef = useRef();
|
|
1371
|
+
const [rowIndex, setRowIndex] = useState(selectedRowIndex === null ? undefined : selectedRowIndex);
|
|
1372
|
+
const [colIndex, setColIndex] = useState(selectedColIndex === null ? undefined : selectedColIndex);
|
|
1373
|
+
const isControlled = selectedColIndex !== undefined && selectedRowIndex !== undefined;
|
|
1364
1374
|
const {
|
|
1365
1375
|
getGridCellProps
|
|
1366
1376
|
} = useGrid({
|
|
1367
|
-
|
|
1377
|
+
environment,
|
|
1378
|
+
rtl: theme.rtl,
|
|
1368
1379
|
matrix: colors,
|
|
1369
|
-
selection: true,
|
|
1370
1380
|
wrap: true,
|
|
1371
1381
|
idPrefix: useId(undefined),
|
|
1372
|
-
|
|
1382
|
+
defaultRowIndex: defaultSelectedRowIndex,
|
|
1383
|
+
defaultColIndex: defaultSelectedColIndex,
|
|
1384
|
+
rowIndex,
|
|
1385
|
+
colIndex,
|
|
1386
|
+
onChange: (row, col) => {
|
|
1387
|
+
setRowIndex(row);
|
|
1388
|
+
setColIndex(col);
|
|
1389
|
+
}
|
|
1373
1390
|
});
|
|
1374
|
-
return React__default.createElement(StyledColorSwatch, {
|
|
1375
|
-
|
|
1376
|
-
|
|
1391
|
+
return React__default.createElement(StyledColorSwatch, _extends$2({
|
|
1392
|
+
role: "grid",
|
|
1393
|
+
ref: mergeRefs([gridRef, ref])
|
|
1394
|
+
}, props), React__default.createElement("tbody", null, colors.map((row, _rowIndex) => React__default.createElement("tr", {
|
|
1377
1395
|
key: row[0].value
|
|
1378
|
-
}, row.map((color,
|
|
1396
|
+
}, row.map((color, _colIndex) => {
|
|
1379
1397
|
const {
|
|
1380
1398
|
label,
|
|
1381
1399
|
value
|
|
1382
1400
|
} = color;
|
|
1383
1401
|
const {
|
|
1384
|
-
|
|
1385
|
-
|
|
1402
|
+
role,
|
|
1403
|
+
onFocus,
|
|
1404
|
+
...gridCellProps
|
|
1386
1405
|
} = getGridCellProps({
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
type: 'button',
|
|
1390
|
-
role: undefined
|
|
1406
|
+
colIndex: _colIndex,
|
|
1407
|
+
rowIndex: _rowIndex
|
|
1391
1408
|
});
|
|
1409
|
+
const checked = isControlled ? selectedRowIndex === _rowIndex && selectedColIndex === _colIndex : undefined;
|
|
1410
|
+
const defaultChecked = isControlled ? undefined : defaultSelectedRowIndex === _rowIndex && defaultSelectedColIndex === _colIndex;
|
|
1411
|
+
const handleChange = event => {
|
|
1412
|
+
if (onSelect) {
|
|
1413
|
+
if (event.target.checked) {
|
|
1414
|
+
onSelect(_rowIndex, _colIndex);
|
|
1415
|
+
} else {
|
|
1416
|
+
onSelect(null, null);
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
if (isCheckboxGroup && event.target.checked) {
|
|
1420
|
+
const inputs = gridRef.current?.querySelectorAll('input');
|
|
1421
|
+
inputs?.forEach(input => {
|
|
1422
|
+
if (input !== event.target) {
|
|
1423
|
+
input.checked = false;
|
|
1424
|
+
}
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
};
|
|
1428
|
+
const handleBlur = event => {
|
|
1429
|
+
event.target.parentElement?.removeAttribute('data-garden-focus-visible');
|
|
1430
|
+
if (!(isCheckboxGroup || gridRef.current?.contains(event.relatedTarget))) {
|
|
1431
|
+
const selectedInput = gridRef.current?.querySelector(`input[name='${event.target.name}']:checked`);
|
|
1432
|
+
if (selectedInput !== null) {
|
|
1433
|
+
const inputs = gridRef.current?.querySelectorAll('input');
|
|
1434
|
+
inputs?.forEach(input => input.setAttribute('tabIndex', input.checked ? '0' : '-1'));
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
};
|
|
1438
|
+
const handleFocus = composeEventHandlers(onFocus, event => event.target.parentElement?.setAttribute('data-garden-focus-visible', 'true'));
|
|
1392
1439
|
return React__default.createElement(StyledCell, {
|
|
1393
1440
|
key: value,
|
|
1394
|
-
|
|
1441
|
+
role: role
|
|
1442
|
+
}, React__default.createElement(StyledColorSwatchLabel, {
|
|
1443
|
+
backgroundColor: value
|
|
1395
1444
|
}, React__default.createElement(Tooltip, {
|
|
1396
1445
|
content: label
|
|
1397
|
-
}, React__default.createElement(
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1446
|
+
}, React__default.createElement(StyledColorSwatchInput, _extends$2({
|
|
1447
|
+
"aria-label": label,
|
|
1448
|
+
name: name,
|
|
1449
|
+
type: isCheckboxGroup ? 'checkbox' : 'radio',
|
|
1450
|
+
value: value,
|
|
1451
|
+
defaultChecked: defaultChecked,
|
|
1452
|
+
checked: checked,
|
|
1453
|
+
onFocus: handleFocus,
|
|
1454
|
+
onBlur: handleBlur,
|
|
1455
|
+
onChange: handleChange
|
|
1456
|
+
}, gridCellProps))), React__default.createElement(StyledIcon, null)));
|
|
1405
1457
|
})))));
|
|
1406
1458
|
});
|
|
1407
1459
|
ColorSwatch.displayName = 'ColorSwatch';
|
|
1408
1460
|
ColorSwatch.propTypes = {
|
|
1461
|
+
name: PropTypes.string.isRequired,
|
|
1409
1462
|
colors: PropTypes.arrayOf(PropTypes.any).isRequired,
|
|
1410
|
-
|
|
1411
|
-
colIndex: PropTypes.number,
|
|
1463
|
+
isCheckboxGroup: PropTypes.bool,
|
|
1412
1464
|
selectedRowIndex: PropTypes.number,
|
|
1413
1465
|
selectedColIndex: PropTypes.number,
|
|
1414
|
-
defaultRowIndex: PropTypes.number,
|
|
1415
|
-
defaultColIndex: PropTypes.number,
|
|
1416
1466
|
defaultSelectedRowIndex: PropTypes.number,
|
|
1417
1467
|
defaultSelectedColIndex: PropTypes.number,
|
|
1418
|
-
onChange: PropTypes.func,
|
|
1419
1468
|
onSelect: PropTypes.func
|
|
1420
1469
|
};
|
|
1421
1470
|
|
|
1422
1471
|
const ColorSwatchDialog = forwardRef((_ref, ref) => {
|
|
1423
1472
|
let {
|
|
1473
|
+
name,
|
|
1424
1474
|
colors,
|
|
1425
|
-
|
|
1426
|
-
colIndex,
|
|
1475
|
+
isCheckboxGroup,
|
|
1427
1476
|
selectedRowIndex,
|
|
1428
1477
|
selectedColIndex,
|
|
1429
|
-
defaultRowIndex,
|
|
1430
|
-
defaultColIndex,
|
|
1431
1478
|
defaultSelectedRowIndex,
|
|
1432
1479
|
defaultSelectedColIndex,
|
|
1433
1480
|
placement,
|
|
1434
|
-
onChange,
|
|
1435
1481
|
onSelect,
|
|
1436
1482
|
hasArrow,
|
|
1437
1483
|
isAnimated,
|
|
1438
|
-
popperModifiers,
|
|
1439
1484
|
zIndex,
|
|
1440
1485
|
isOpen,
|
|
1441
1486
|
focusInset,
|
|
@@ -1446,17 +1491,21 @@ const ColorSwatchDialog = forwardRef((_ref, ref) => {
|
|
|
1446
1491
|
'aria-label': ariaLabel,
|
|
1447
1492
|
...props
|
|
1448
1493
|
} = _ref;
|
|
1449
|
-
const
|
|
1450
|
-
const controlledSelect = selectedRowIndex !== null && selectedColIndex !== null && selectedRowIndex !== undefined && selectedColIndex !== undefined;
|
|
1451
|
-
const isControlled = controlledFocus || controlledSelect;
|
|
1494
|
+
const isControlled = selectedRowIndex !== undefined && selectedColIndex !== undefined;
|
|
1452
1495
|
const isDialogControlled = isOpen !== undefined && isOpen !== null;
|
|
1453
1496
|
const buttonRef = useRef(null);
|
|
1454
1497
|
const colorSwatchRef = useRef(null);
|
|
1455
|
-
const [referenceElement, setReferenceElement] = useState();
|
|
1456
|
-
const [
|
|
1457
|
-
const [
|
|
1458
|
-
|
|
1459
|
-
|
|
1498
|
+
const [referenceElement, setReferenceElement] = useState(null);
|
|
1499
|
+
const [rowIndex, setRowIndex] = useState(defaultSelectedRowIndex);
|
|
1500
|
+
const [colIndex, setColIndex] = useState(defaultSelectedColIndex);
|
|
1501
|
+
let backgroundColor;
|
|
1502
|
+
if (isControlled) {
|
|
1503
|
+
if (selectedRowIndex !== null && selectedColIndex !== null) {
|
|
1504
|
+
backgroundColor = colors[selectedRowIndex][selectedColIndex].value;
|
|
1505
|
+
}
|
|
1506
|
+
} else if (rowIndex !== undefined && colIndex !== undefined) {
|
|
1507
|
+
backgroundColor = colors[rowIndex][colIndex].value;
|
|
1508
|
+
}
|
|
1460
1509
|
const ariaLabelText = useText(ColorSwatchDialog, {
|
|
1461
1510
|
'aria-label': ariaLabel
|
|
1462
1511
|
}, 'aria-label', 'Color swatch');
|
|
@@ -1469,14 +1518,6 @@ const ColorSwatchDialog = forwardRef((_ref, ref) => {
|
|
|
1469
1518
|
}
|
|
1470
1519
|
}
|
|
1471
1520
|
}, [isOpen, isDialogControlled]);
|
|
1472
|
-
let uncontrolledSelectedColor;
|
|
1473
|
-
let controlledSelectedColor;
|
|
1474
|
-
if (uncontrolledSelectedRowIndex > -1 && uncontrolledSelectedColIndex > -1) {
|
|
1475
|
-
uncontrolledSelectedColor = colors[uncontrolledSelectedRowIndex][uncontrolledSelectedColIndex];
|
|
1476
|
-
}
|
|
1477
|
-
if (selectedRowIndex !== undefined && selectedColIndex !== undefined && selectedRowIndex > -1 && selectedColIndex > -1) {
|
|
1478
|
-
controlledSelectedColor = colors[selectedRowIndex][selectedColIndex];
|
|
1479
|
-
}
|
|
1480
1521
|
const openDialog = () => {
|
|
1481
1522
|
setReferenceElement(buttonRef.current);
|
|
1482
1523
|
onDialogChange && onDialogChange({
|
|
@@ -1484,8 +1525,6 @@ const ColorSwatchDialog = forwardRef((_ref, ref) => {
|
|
|
1484
1525
|
});
|
|
1485
1526
|
};
|
|
1486
1527
|
const closeDialog = () => {
|
|
1487
|
-
setUncontrolledRowIndex(uncontrolledSelectedRowIndex);
|
|
1488
|
-
setUncontrolledColIndex(uncontrolledSelectedColIndex);
|
|
1489
1528
|
setReferenceElement(null);
|
|
1490
1529
|
onDialogChange && onDialogChange({
|
|
1491
1530
|
isOpen: false
|
|
@@ -1500,15 +1539,22 @@ const ColorSwatchDialog = forwardRef((_ref, ref) => {
|
|
|
1500
1539
|
});
|
|
1501
1540
|
useEffect(() => {
|
|
1502
1541
|
if (referenceElement && colorSwatchRef.current) {
|
|
1503
|
-
const
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1542
|
+
const input = colorSwatchRef.current.querySelector('[tabindex="0"]');
|
|
1543
|
+
input?.focus();
|
|
1544
|
+
}
|
|
1545
|
+
}, [referenceElement]);
|
|
1546
|
+
const handleSelect = (row, col) => {
|
|
1547
|
+
if (isControlled === false) {
|
|
1548
|
+
if (row === null || col === null) {
|
|
1549
|
+
setRowIndex(undefined);
|
|
1550
|
+
setColIndex(undefined);
|
|
1507
1551
|
} else {
|
|
1508
|
-
|
|
1552
|
+
setRowIndex(row);
|
|
1553
|
+
setColIndex(col);
|
|
1509
1554
|
}
|
|
1510
1555
|
}
|
|
1511
|
-
|
|
1556
|
+
onSelect && onSelect(row, col);
|
|
1557
|
+
};
|
|
1512
1558
|
return React__default.createElement(React__default.Fragment, null, children ? ( cloneElement(Children.only(children), {
|
|
1513
1559
|
onClick,
|
|
1514
1560
|
ref: buttonRef
|
|
@@ -1518,9 +1564,9 @@ const ColorSwatchDialog = forwardRef((_ref, ref) => {
|
|
|
1518
1564
|
ref: buttonRef,
|
|
1519
1565
|
onClick: onClick
|
|
1520
1566
|
}, buttonProps), React__default.createElement(StyledButtonPreview, {
|
|
1521
|
-
backgroundColor:
|
|
1567
|
+
backgroundColor: backgroundColor
|
|
1522
1568
|
}), React__default.createElement(Button.EndIcon, {
|
|
1523
|
-
isRotated: referenceElement
|
|
1569
|
+
isRotated: referenceElement !== null
|
|
1524
1570
|
}, React__default.createElement(SvgChevronDownStroke, null))), React__default.createElement(StyledTooltipModal, _extends$2({
|
|
1525
1571
|
ref: ref,
|
|
1526
1572
|
zIndex: zIndex,
|
|
@@ -1528,35 +1574,19 @@ const ColorSwatchDialog = forwardRef((_ref, ref) => {
|
|
|
1528
1574
|
focusOnMount: false,
|
|
1529
1575
|
placement: placement,
|
|
1530
1576
|
isAnimated: isAnimated,
|
|
1531
|
-
popperModifiers: popperModifiers,
|
|
1532
1577
|
referenceElement: referenceElement,
|
|
1533
1578
|
onClose: closeDialog,
|
|
1534
1579
|
"aria-label": ariaLabelText
|
|
1535
1580
|
}, props), React__default.createElement(StyledTooltipBody, null, React__default.createElement(ColorSwatch, {
|
|
1581
|
+
name: name,
|
|
1536
1582
|
colors: colors,
|
|
1537
1583
|
ref: colorSwatchRef,
|
|
1538
|
-
|
|
1539
|
-
colIndex: colIndex,
|
|
1584
|
+
isCheckboxGroup: isCheckboxGroup,
|
|
1540
1585
|
selectedRowIndex: selectedRowIndex,
|
|
1541
1586
|
selectedColIndex: selectedColIndex,
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
defaultSelectedColIndex: uncontrolledSelectedColIndex,
|
|
1546
|
-
onChange: (rowIdx, colIdx) => {
|
|
1547
|
-
if (isControlled === false) {
|
|
1548
|
-
setUncontrolledRowIndex(rowIdx);
|
|
1549
|
-
setUncontrolledColIndex(colIdx);
|
|
1550
|
-
}
|
|
1551
|
-
onChange && onChange(rowIdx, colIdx);
|
|
1552
|
-
},
|
|
1553
|
-
onSelect: (rowIdx, colIdx) => {
|
|
1554
|
-
if (isControlled === false) {
|
|
1555
|
-
setUncontrolledSelectedRowIndex(rowIdx);
|
|
1556
|
-
setUncontrolledSelectedColIndex(colIdx);
|
|
1557
|
-
}
|
|
1558
|
-
onSelect && onSelect(rowIdx, colIdx);
|
|
1559
|
-
}
|
|
1587
|
+
defaultSelectedRowIndex: rowIndex,
|
|
1588
|
+
defaultSelectedColIndex: colIndex,
|
|
1589
|
+
onSelect: handleSelect
|
|
1560
1590
|
}))));
|
|
1561
1591
|
});
|
|
1562
1592
|
ColorSwatchDialog.propTypes = {
|
|
@@ -1565,7 +1595,6 @@ ColorSwatchDialog.propTypes = {
|
|
|
1565
1595
|
onDialogChange: PropTypes.func,
|
|
1566
1596
|
disabled: PropTypes.bool,
|
|
1567
1597
|
buttonProps: PropTypes.object,
|
|
1568
|
-
popperModifiers: PropTypes.any,
|
|
1569
1598
|
zIndex: PropTypes.number,
|
|
1570
1599
|
hasArrow: PropTypes.bool,
|
|
1571
1600
|
isAnimated: PropTypes.bool,
|