@zendeskgarden/react-colorpickers 9.0.0-next.1 → 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 +10 -9
- package/dist/typings/styled/ColorSwatch/StyledSwatchButton.d.ts +0 -8
package/dist/index.cjs.js
CHANGED
|
@@ -18,8 +18,9 @@ var reactButtons = require('@zendeskgarden/react-buttons');
|
|
|
18
18
|
var reactModals = require('@zendeskgarden/react-modals');
|
|
19
19
|
var isEqual = require('lodash.isequal');
|
|
20
20
|
var containerUtilities = require('@zendeskgarden/container-utilities');
|
|
21
|
-
var
|
|
21
|
+
var reactMergeRefs = require('react-merge-refs');
|
|
22
22
|
var containerGrid = require('@zendeskgarden/container-grid');
|
|
23
|
+
var reactTooltips = require('@zendeskgarden/react-tooltips');
|
|
23
24
|
|
|
24
25
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
25
26
|
|
|
@@ -146,22 +147,22 @@ const getThumbPosition = (x, y, rtl, container) => {
|
|
|
146
147
|
};
|
|
147
148
|
};
|
|
148
149
|
|
|
149
|
-
const COMPONENT_ID$
|
|
150
|
+
const COMPONENT_ID$m = 'colorpickers.colorpicker';
|
|
150
151
|
const getColorPickerWidth = props => {
|
|
151
152
|
return props.isOpaque ? 268 : 312;
|
|
152
153
|
};
|
|
153
154
|
const StyledColorPicker = styled__default.default.div.attrs({
|
|
154
|
-
'data-garden-id': COMPONENT_ID$
|
|
155
|
-
'data-garden-version': '9.0.0-next.
|
|
155
|
+
'data-garden-id': COMPONENT_ID$m,
|
|
156
|
+
'data-garden-version': '9.0.0-next.2'
|
|
156
157
|
}).withConfig({
|
|
157
158
|
displayName: "StyledColorPicker",
|
|
158
159
|
componentId: "sc-1donyl9-0"
|
|
159
|
-
})(["width:", "px;min-width:", "px;", ";"], getColorPickerWidth, getColorPickerWidth, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
160
|
+
})(["width:", "px;min-width:", "px;", ";"], getColorPickerWidth, getColorPickerWidth, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$m, props));
|
|
160
161
|
StyledColorPicker.defaultProps = {
|
|
161
162
|
theme: reactTheming.DEFAULT_THEME
|
|
162
163
|
};
|
|
163
164
|
|
|
164
|
-
const COMPONENT_ID$
|
|
165
|
+
const COMPONENT_ID$l = 'colorpickers.colorpicker_range';
|
|
165
166
|
const thumbStyles = function (styles) {
|
|
166
167
|
let modifier = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
167
168
|
return `
|
|
@@ -287,23 +288,23 @@ const sizeStyles$2 = props => {
|
|
|
287
288
|
`;
|
|
288
289
|
};
|
|
289
290
|
const StyledRange = styled__default.default(reactForms.Range).attrs({
|
|
290
|
-
'data-garden-id': COMPONENT_ID$
|
|
291
|
-
'data-garden-version': '9.0.0-next.
|
|
291
|
+
'data-garden-id': COMPONENT_ID$l,
|
|
292
|
+
'data-garden-version': '9.0.0-next.2',
|
|
292
293
|
hasLowerTrack: false
|
|
293
294
|
}).withConfig({
|
|
294
295
|
displayName: "StyledRange",
|
|
295
296
|
componentId: "sc-ug3wi9-0"
|
|
296
297
|
})(["", ";", " ", ";", ";"], sizeStyles$2, trackStyles(`
|
|
297
298
|
border-radius: 0;
|
|
298
|
-
`), colorStyles$1, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
299
|
+
`), colorStyles$1, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$l, props));
|
|
299
300
|
StyledRange.defaultProps = {
|
|
300
301
|
theme: reactTheming.DEFAULT_THEME
|
|
301
302
|
};
|
|
302
303
|
|
|
303
|
-
const COMPONENT_ID$
|
|
304
|
+
const COMPONENT_ID$k = 'colorpickers.colorpicker_hue';
|
|
304
305
|
const StyledHueRange = styled__default.default(StyledRange).attrs({
|
|
305
|
-
'data-garden-id': COMPONENT_ID$
|
|
306
|
-
'data-garden-version': '9.0.0-next.
|
|
306
|
+
'data-garden-id': COMPONENT_ID$k,
|
|
307
|
+
'data-garden-version': '9.0.0-next.2'
|
|
307
308
|
}).withConfig({
|
|
308
309
|
displayName: "StyledHueRange",
|
|
309
310
|
componentId: "sc-13ly7p-0"
|
|
@@ -331,7 +332,7 @@ const checkeredBackground = function (theme, size) {
|
|
|
331
332
|
`;
|
|
332
333
|
};
|
|
333
334
|
|
|
334
|
-
const COMPONENT_ID$
|
|
335
|
+
const COMPONENT_ID$j = 'colorpickers.colorpicker_alpha';
|
|
335
336
|
const background$3 = props => {
|
|
336
337
|
const direction = `to ${props.theme.rtl ? 'left' : 'right'}`;
|
|
337
338
|
const fromColor = `rgba(${props.red}, ${props.green}, ${props.blue}, 0)`;
|
|
@@ -346,8 +347,8 @@ const StyledAlphaRange = styled__default.default(StyledRange).attrs(props => ({
|
|
|
346
347
|
backgroundSize: 'auto',
|
|
347
348
|
background: background$3(props)
|
|
348
349
|
},
|
|
349
|
-
'data-garden-id': COMPONENT_ID$
|
|
350
|
-
'data-garden-version': '9.0.0-next.
|
|
350
|
+
'data-garden-id': COMPONENT_ID$j,
|
|
351
|
+
'data-garden-version': '9.0.0-next.2'
|
|
351
352
|
})).withConfig({
|
|
352
353
|
displayName: "StyledAlphaRange",
|
|
353
354
|
componentId: "sc-kuh2xc-0"
|
|
@@ -356,7 +357,7 @@ StyledAlphaRange.defaultProps = {
|
|
|
356
357
|
theme: reactTheming.DEFAULT_THEME
|
|
357
358
|
};
|
|
358
359
|
|
|
359
|
-
const COMPONENT_ID$
|
|
360
|
+
const COMPONENT_ID$i = 'colorpickers.colorpicker_preview_box';
|
|
360
361
|
const background$2 = props => {
|
|
361
362
|
const alpha = props.alpha ? props.alpha / 100 : 0;
|
|
362
363
|
const color = `rgba(${props.red}, ${props.green}, ${props.blue}, ${alpha})`;
|
|
@@ -370,18 +371,18 @@ const StyledPreview = styled__default.default.div.attrs(props => ({
|
|
|
370
371
|
style: {
|
|
371
372
|
background: background$2(props)
|
|
372
373
|
},
|
|
373
|
-
'data-garden-id': COMPONENT_ID$
|
|
374
|
-
'data-garden-version': '9.0.0-next.
|
|
374
|
+
'data-garden-id': COMPONENT_ID$i,
|
|
375
|
+
'data-garden-version': '9.0.0-next.2',
|
|
375
376
|
'data-test-id': 'preview-box'
|
|
376
377
|
})).withConfig({
|
|
377
378
|
displayName: "StyledPreview",
|
|
378
379
|
componentId: "sc-d70mj1-0"
|
|
379
|
-
})(["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 => polished.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 => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
380
|
+
})(["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 => polished.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 => reactTheming.retrieveComponentStyles(COMPONENT_ID$i, props));
|
|
380
381
|
StyledPreview.defaultProps = {
|
|
381
382
|
theme: reactTheming.DEFAULT_THEME
|
|
382
383
|
};
|
|
383
384
|
|
|
384
|
-
const COMPONENT_ID$
|
|
385
|
+
const COMPONENT_ID$h = 'colorpickers.colorpicker_colorwell';
|
|
385
386
|
const background$1 = props => {
|
|
386
387
|
const blackAlpha = polished.rgba(props.theme.palette.black, 0.9);
|
|
387
388
|
const black = `linear-gradient(0deg, ${props.theme.palette.black}, ${blackAlpha} 1%, transparent 99%)`;
|
|
@@ -392,8 +393,8 @@ const background$1 = props => {
|
|
|
392
393
|
return `${black}, ${white}, ${color}`;
|
|
393
394
|
};
|
|
394
395
|
const StyledColorWell = styled__default.default.div.attrs(props => ({
|
|
395
|
-
'data-garden-id': COMPONENT_ID$
|
|
396
|
-
'data-garden-version': '9.0.0-next.
|
|
396
|
+
'data-garden-id': COMPONENT_ID$h,
|
|
397
|
+
'data-garden-version': '9.0.0-next.2',
|
|
397
398
|
'data-test-id': 'colorwell',
|
|
398
399
|
style: {
|
|
399
400
|
background: background$1(props)
|
|
@@ -401,12 +402,12 @@ const StyledColorWell = styled__default.default.div.attrs(props => ({
|
|
|
401
402
|
})).withConfig({
|
|
402
403
|
displayName: "StyledColorWell",
|
|
403
404
|
componentId: "sc-54ly7s-0"
|
|
404
|
-
})(["position:relative;margin-bottom:", "px;cursor:pointer;height:208px;overflow:hidden;", ";"], props => props.theme.space.base * 2, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
405
|
+
})(["position:relative;margin-bottom:", "px;cursor:pointer;height:208px;overflow:hidden;", ";"], props => props.theme.space.base * 2, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$h, props));
|
|
405
406
|
StyledColorWell.defaultProps = {
|
|
406
407
|
theme: reactTheming.DEFAULT_THEME
|
|
407
408
|
};
|
|
408
409
|
|
|
409
|
-
const COMPONENT_ID$
|
|
410
|
+
const COMPONENT_ID$g = 'colorpickers.colorpicker_colorwell_thumb';
|
|
410
411
|
const sizeStyles$1 = theme => {
|
|
411
412
|
const borderWidth = polished.stripUnit(theme.borderWidths.sm) * 2;
|
|
412
413
|
const size = theme.space.base * 5;
|
|
@@ -420,8 +421,8 @@ const sizeStyles$1 = theme => {
|
|
|
420
421
|
`;
|
|
421
422
|
};
|
|
422
423
|
const StyledColorWellThumb = styled__default.default.div.attrs(props => ({
|
|
423
|
-
'data-garden-id': COMPONENT_ID$
|
|
424
|
-
'data-garden-version': '9.0.0-next.
|
|
424
|
+
'data-garden-id': COMPONENT_ID$g,
|
|
425
|
+
'data-garden-version': '9.0.0-next.2',
|
|
425
426
|
'data-test-id': 'colorwell-thumb',
|
|
426
427
|
style: {
|
|
427
428
|
top: `${props.top}%`,
|
|
@@ -430,74 +431,74 @@ const StyledColorWellThumb = styled__default.default.div.attrs(props => ({
|
|
|
430
431
|
})).withConfig({
|
|
431
432
|
displayName: "StyledColorWellThumb",
|
|
432
433
|
componentId: "sc-1pnz3jz-0"
|
|
433
|
-
})(["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`, reactTheming.getColor('neutralHue', 800, props.theme, 0.24)), props => sizeStyles$1(props.theme), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
434
|
+
})(["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`, reactTheming.getColor('neutralHue', 800, props.theme, 0.24)), props => sizeStyles$1(props.theme), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$g, props));
|
|
434
435
|
StyledColorWellThumb.defaultProps = {
|
|
435
436
|
theme: reactTheming.DEFAULT_THEME
|
|
436
437
|
};
|
|
437
438
|
|
|
438
|
-
const COMPONENT_ID$
|
|
439
|
+
const COMPONENT_ID$f = 'colorpickers.colorpicker_slider_group';
|
|
439
440
|
const StyledSliderGroup = styled__default.default.div.attrs({
|
|
440
|
-
'data-garden-id': COMPONENT_ID$
|
|
441
|
-
'data-garden-version': '9.0.0-next.
|
|
441
|
+
'data-garden-id': COMPONENT_ID$f,
|
|
442
|
+
'data-garden-version': '9.0.0-next.2'
|
|
442
443
|
}).withConfig({
|
|
443
444
|
displayName: "StyledSliderGroup",
|
|
444
445
|
componentId: "sc-rsq0ak-0"
|
|
445
|
-
})(["display:flex;justify-content:space-between;margin-bottom:", "px;", ";"], props => props.theme.space.base * 2, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
446
|
+
})(["display:flex;justify-content:space-between;margin-bottom:", "px;", ";"], props => props.theme.space.base * 2, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$f, props));
|
|
446
447
|
StyledSliderGroup.defaultProps = {
|
|
447
448
|
theme: reactTheming.DEFAULT_THEME
|
|
448
449
|
};
|
|
449
450
|
|
|
450
|
-
const COMPONENT_ID$
|
|
451
|
+
const COMPONENT_ID$e = 'colorpickers.colorpicker_hex_field';
|
|
451
452
|
const StyledHexField = styled__default.default(reactForms.Field).attrs({
|
|
452
|
-
'data-garden-id': COMPONENT_ID$
|
|
453
|
-
'data-garden-version': '9.0.0-next.
|
|
453
|
+
'data-garden-id': COMPONENT_ID$e,
|
|
454
|
+
'data-garden-version': '9.0.0-next.2',
|
|
454
455
|
spellcheck: false
|
|
455
456
|
}).withConfig({
|
|
456
457
|
displayName: "StyledHexField",
|
|
457
458
|
componentId: "sc-1lk14t4-0"
|
|
458
|
-
})(["display:flex;flex-basis:0;flex-direction:column;flex-grow:1;width:auto;text-align:center;input{direction:ltr;}", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
459
|
+
})(["display:flex;flex-basis:0;flex-direction:column;flex-grow:1;width:auto;text-align:center;input{direction:ltr;}", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$e, props));
|
|
459
460
|
StyledHexField.defaultProps = {
|
|
460
461
|
theme: reactTheming.DEFAULT_THEME
|
|
461
462
|
};
|
|
462
463
|
|
|
463
|
-
const COMPONENT_ID$
|
|
464
|
+
const COMPONENT_ID$d = 'colorpickers.colorpicker_label';
|
|
464
465
|
const StyledLabel = styled__default.default(reactForms.Label).attrs({
|
|
465
|
-
'data-garden-id': COMPONENT_ID$
|
|
466
|
-
'data-garden-version': '9.0.0-next.
|
|
466
|
+
'data-garden-id': COMPONENT_ID$d,
|
|
467
|
+
'data-garden-version': '9.0.0-next.2'
|
|
467
468
|
}).withConfig({
|
|
468
469
|
displayName: "StyledLabel",
|
|
469
470
|
componentId: "sc-1klhp6m-0"
|
|
470
|
-
})(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
471
|
+
})(["overflow:hidden;text-overflow:ellipsis;white-space:nowrap;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$d, props));
|
|
471
472
|
StyledLabel.defaultProps = {
|
|
472
473
|
theme: reactTheming.DEFAULT_THEME
|
|
473
474
|
};
|
|
474
475
|
|
|
475
|
-
const COMPONENT_ID$
|
|
476
|
+
const COMPONENT_ID$c = 'colorpickers.colorpicker_input';
|
|
476
477
|
const StyledInput = styled__default.default(reactForms.Input).attrs({
|
|
477
|
-
'data-garden-id': COMPONENT_ID$
|
|
478
|
-
'data-garden-version': '9.0.0-next.
|
|
478
|
+
'data-garden-id': COMPONENT_ID$c,
|
|
479
|
+
'data-garden-version': '9.0.0-next.2',
|
|
479
480
|
focusInset: false
|
|
480
481
|
}).withConfig({
|
|
481
482
|
displayName: "StyledInput",
|
|
482
483
|
componentId: "sc-1iap93p-0"
|
|
483
|
-
})(["text-align:center;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
484
|
+
})(["text-align:center;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$c, props));
|
|
484
485
|
StyledInput.defaultProps = {
|
|
485
486
|
theme: reactTheming.DEFAULT_THEME
|
|
486
487
|
};
|
|
487
488
|
|
|
488
|
-
const COMPONENT_ID$
|
|
489
|
+
const COMPONENT_ID$b = 'colorpickers.colorpicker_input_group';
|
|
489
490
|
const StyledInputGroup = styled__default.default.div.attrs({
|
|
490
|
-
'data-garden-id': COMPONENT_ID$
|
|
491
|
-
'data-garden-version': '9.0.0-next.
|
|
491
|
+
'data-garden-id': COMPONENT_ID$b,
|
|
492
|
+
'data-garden-version': '9.0.0-next.2'
|
|
492
493
|
}).withConfig({
|
|
493
494
|
displayName: "StyledInputGroup",
|
|
494
495
|
componentId: "sc-mmy93w-0"
|
|
495
|
-
})(["display:flex;justify-content:space-between;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
496
|
+
})(["display:flex;justify-content:space-between;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$b, props));
|
|
496
497
|
StyledInputGroup.defaultProps = {
|
|
497
498
|
theme: reactTheming.DEFAULT_THEME
|
|
498
499
|
};
|
|
499
500
|
|
|
500
|
-
const COMPONENT_ID$
|
|
501
|
+
const COMPONENT_ID$a = 'colorpickers.colorpicker_rgb_field';
|
|
501
502
|
const sizeStyles = theme => {
|
|
502
503
|
const margin = `${theme.space.base * 1.5}px`;
|
|
503
504
|
const width = `${theme.space.base * 12.75}px`;
|
|
@@ -508,42 +509,42 @@ const sizeStyles = theme => {
|
|
|
508
509
|
`;
|
|
509
510
|
};
|
|
510
511
|
const StyledRGBAField = styled__default.default(reactForms.Field).attrs({
|
|
511
|
-
'data-garden-id': COMPONENT_ID$
|
|
512
|
-
'data-garden-version': '9.0.0-next.
|
|
512
|
+
'data-garden-id': COMPONENT_ID$a,
|
|
513
|
+
'data-garden-version': '9.0.0-next.2'
|
|
513
514
|
}).withConfig({
|
|
514
515
|
displayName: "StyledRGBAField",
|
|
515
516
|
componentId: "sc-ibo1yw-0"
|
|
516
|
-
})(["display:flex;flex-direction:column;text-align:center;", ";", ";"], props => sizeStyles(props.theme), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
517
|
+
})(["display:flex;flex-direction:column;text-align:center;", ";", ";"], props => sizeStyles(props.theme), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$a, props));
|
|
517
518
|
StyledRGBAField.defaultProps = {
|
|
518
519
|
theme: reactTheming.DEFAULT_THEME
|
|
519
520
|
};
|
|
520
521
|
|
|
521
|
-
const COMPONENT_ID$
|
|
522
|
+
const COMPONENT_ID$9 = 'colorpickers.colorpicker_sliders';
|
|
522
523
|
const StyledSliders = styled__default.default.div.attrs({
|
|
523
|
-
'data-garden-id': COMPONENT_ID$
|
|
524
|
-
'data-garden-version': '9.0.0-next.
|
|
524
|
+
'data-garden-id': COMPONENT_ID$9,
|
|
525
|
+
'data-garden-version': '9.0.0-next.2'
|
|
525
526
|
}).withConfig({
|
|
526
527
|
displayName: "StyledSliders",
|
|
527
528
|
componentId: "sc-aclca2-0"
|
|
528
|
-
})(["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 => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
529
|
+
})(["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 => reactTheming.retrieveComponentStyles(COMPONENT_ID$9, props));
|
|
529
530
|
StyledSliders.defaultProps = {
|
|
530
531
|
theme: reactTheming.DEFAULT_THEME
|
|
531
532
|
};
|
|
532
533
|
|
|
533
|
-
const COMPONENT_ID$
|
|
534
|
+
const COMPONENT_ID$8 = 'colorpickers.colordialog_button';
|
|
534
535
|
const StyledButton = styled__default.default(reactButtons.Button).attrs({
|
|
535
536
|
isNeutral: true,
|
|
536
|
-
'data-garden-id': COMPONENT_ID$
|
|
537
|
-
'data-garden-version': '9.0.0-next.
|
|
537
|
+
'data-garden-id': COMPONENT_ID$8,
|
|
538
|
+
'data-garden-version': '9.0.0-next.2'
|
|
538
539
|
}).withConfig({
|
|
539
540
|
displayName: "StyledButton",
|
|
540
541
|
componentId: "sc-101xjve-0"
|
|
541
|
-
})(["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 => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
542
|
+
})(["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 => reactTheming.retrieveComponentStyles(COMPONENT_ID$8, props));
|
|
542
543
|
StyledButton.defaultProps = {
|
|
543
544
|
theme: reactTheming.DEFAULT_THEME
|
|
544
545
|
};
|
|
545
546
|
|
|
546
|
-
const COMPONENT_ID$
|
|
547
|
+
const COMPONENT_ID$7 = 'colorpickers.colordialog_preview';
|
|
547
548
|
const background = props => {
|
|
548
549
|
const {
|
|
549
550
|
backgroundColor
|
|
@@ -568,102 +569,124 @@ const StyledButtonPreview = styled__default.default.span.attrs(props => ({
|
|
|
568
569
|
style: {
|
|
569
570
|
background: `${background(props)}, ${checkeredBackground(props.theme, 8)}`
|
|
570
571
|
},
|
|
571
|
-
'data-garden-id': COMPONENT_ID$
|
|
572
|
-
'data-garden-version': '9.0.0-next.
|
|
572
|
+
'data-garden-id': COMPONENT_ID$7,
|
|
573
|
+
'data-garden-version': '9.0.0-next.2',
|
|
573
574
|
'data-test-id': 'dialog-preview'
|
|
574
575
|
})).withConfig({
|
|
575
576
|
displayName: "StyledButtonPreview",
|
|
576
577
|
componentId: "sc-1jzysg3-0"
|
|
577
|
-
})(["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 => polished.rgba(props.theme.palette.black, 0.19), props => props.theme.space.base * 5, props => props.theme.space.base * 5, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
578
|
+
})(["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 => polished.rgba(props.theme.palette.black, 0.19), props => props.theme.space.base * 5, props => props.theme.space.base * 5, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$7, props));
|
|
578
579
|
StyledButtonPreview.defaultProps = {
|
|
579
580
|
theme: reactTheming.DEFAULT_THEME
|
|
580
581
|
};
|
|
581
582
|
|
|
582
|
-
const COMPONENT_ID$
|
|
583
|
+
const COMPONENT_ID$6 = 'colorpickers.colordialog_tooltipmodal';
|
|
583
584
|
const StyledTooltipModal = styled__default.default(reactModals.TooltipModal).attrs({
|
|
584
|
-
'data-garden-id': COMPONENT_ID$
|
|
585
|
-
'data-garden-version': '9.0.0-next.
|
|
585
|
+
'data-garden-id': COMPONENT_ID$6,
|
|
586
|
+
'data-garden-version': '9.0.0-next.2'
|
|
586
587
|
}).withConfig({
|
|
587
588
|
displayName: "StyledTooltipModal",
|
|
588
589
|
componentId: "sc-o022s8-0"
|
|
589
|
-
})(["width:auto !important;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
590
|
+
})(["width:auto !important;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$6, props));
|
|
590
591
|
StyledTooltipModal.defaultProps = {
|
|
591
592
|
theme: reactTheming.DEFAULT_THEME
|
|
592
593
|
};
|
|
593
594
|
|
|
594
|
-
const COMPONENT_ID$
|
|
595
|
+
const COMPONENT_ID$5 = 'colorpickers.colordialog_tooltipmodal_body';
|
|
595
596
|
const StyledTooltipBody = styled__default.default(reactModals.TooltipModal.Body).attrs({
|
|
596
|
-
'data-garden-id': COMPONENT_ID$
|
|
597
|
-
'data-garden-version': '9.0.0-next.
|
|
597
|
+
'data-garden-id': COMPONENT_ID$5,
|
|
598
|
+
'data-garden-version': '9.0.0-next.2'
|
|
598
599
|
}).withConfig({
|
|
599
600
|
displayName: "StyledTooltipBody",
|
|
600
601
|
componentId: "sc-6gsgsy-0"
|
|
601
|
-
})(["padding:0;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
602
|
+
})(["padding:0;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
602
603
|
StyledTooltipBody.defaultProps = {
|
|
603
604
|
theme: reactTheming.DEFAULT_THEME
|
|
604
605
|
};
|
|
605
606
|
|
|
606
|
-
const COMPONENT_ID$
|
|
607
|
-
const StyledSwatchButton = styled__default.default(StyledButtonPreview).attrs(props => ({
|
|
608
|
-
as: 'button',
|
|
609
|
-
'data-garden-id': COMPONENT_ID$3,
|
|
610
|
-
'data-test-id': props.backgroundColor,
|
|
611
|
-
'data-garden-version': '9.0.0-next.1'
|
|
612
|
-
})).withConfig({
|
|
613
|
-
displayName: "StyledSwatchButton",
|
|
614
|
-
componentId: "sc-edpwpp-0"
|
|
615
|
-
})(["transition:box-shadow 0.1s ease-in-out;outline:none;border:none;border-radius:", ";cursor:pointer;padding:0;", " ", ";"], props => props.theme.borderRadii.md, props => reactTheming.focusStyles({
|
|
616
|
-
theme: props.theme
|
|
617
|
-
}), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
618
|
-
StyledSwatchButton.defaultProps = {
|
|
619
|
-
theme: reactTheming.DEFAULT_THEME
|
|
620
|
-
};
|
|
621
|
-
|
|
622
|
-
const COMPONENT_ID$2 = 'colorpickers.color_swatch';
|
|
607
|
+
const COMPONENT_ID$4 = 'colorpickers.color_swatch';
|
|
623
608
|
const StyledColorSwatch = styled__default.default.table.attrs({
|
|
624
|
-
'data-garden-id': COMPONENT_ID$
|
|
625
|
-
'data-garden-version': '9.0.0-next.
|
|
626
|
-
role: 'grid'
|
|
609
|
+
'data-garden-id': COMPONENT_ID$4,
|
|
610
|
+
'data-garden-version': '9.0.0-next.2'
|
|
627
611
|
}).withConfig({
|
|
628
612
|
displayName: "StyledColorSwatch",
|
|
629
613
|
componentId: "sc-ajx440-0"
|
|
630
|
-
})(["border-collapse:collapse;line-height:normal;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
614
|
+
})(["border-collapse:collapse;line-height:normal;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
631
615
|
StyledColorSwatch.defaultProps = {
|
|
632
616
|
theme: reactTheming.DEFAULT_THEME
|
|
633
617
|
};
|
|
634
618
|
|
|
635
|
-
const COMPONENT_ID$
|
|
619
|
+
const COMPONENT_ID$3 = 'colorpickers.color_swatch_input';
|
|
620
|
+
const StyledColorSwatchInput = styled__default.default.input.attrs({
|
|
621
|
+
'data-garden-id': COMPONENT_ID$3,
|
|
622
|
+
'data-garden-version': '9.0.0-next.2'
|
|
623
|
+
}).withConfig({
|
|
624
|
+
displayName: "StyledColorSwatchInput",
|
|
625
|
+
componentId: "sc-em45h0-0"
|
|
626
|
+
})(["position:absolute;opacity:0;z-index:1;margin:0;width:100%;height:100%;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
627
|
+
StyledColorSwatchInput.defaultProps = {
|
|
628
|
+
theme: reactTheming.DEFAULT_THEME
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
const COMPONENT_ID$2 = 'colorpickers.color_swatch_label';
|
|
636
632
|
const colorStyles = props => {
|
|
637
|
-
const
|
|
638
|
-
theme,
|
|
639
|
-
color
|
|
640
|
-
} = props;
|
|
633
|
+
const boxShadow = props.theme.shadows.md(reactTheming.getColor('primaryHue', 600, props.theme, 0.35));
|
|
641
634
|
const {
|
|
642
635
|
alpha
|
|
643
|
-
} = polished.parseToRgb(
|
|
644
|
-
let
|
|
645
|
-
if (alpha
|
|
646
|
-
|
|
636
|
+
} = polished.parseToRgb(props.backgroundColor);
|
|
637
|
+
let foregroundColor;
|
|
638
|
+
if (alpha && alpha < 0.4) {
|
|
639
|
+
foregroundColor = props.theme.colors.foreground;
|
|
640
|
+
} else {
|
|
641
|
+
foregroundColor = polished.readableColor(props.backgroundColor, props.theme.colors.foreground, props.theme.colors.background);
|
|
647
642
|
}
|
|
648
643
|
return `
|
|
649
|
-
color: ${
|
|
644
|
+
color: ${foregroundColor};
|
|
645
|
+
|
|
646
|
+
&[data-garden-focus-visible] {
|
|
647
|
+
box-shadow: ${boxShadow};
|
|
650
648
|
`;
|
|
651
649
|
};
|
|
652
|
-
const
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
650
|
+
const StyledColorSwatchLabel = styled__default.default(StyledButtonPreview).attrs({
|
|
651
|
+
as: 'label',
|
|
652
|
+
'data-garden-id': COMPONENT_ID$2,
|
|
653
|
+
'data-garden-version': '9.0.0-next.2'
|
|
654
|
+
}).withConfig({
|
|
655
|
+
displayName: "StyledColorSwatchLabel",
|
|
656
|
+
componentId: "sc-1aghocg-0"
|
|
657
|
+
})(["position:relative;border-radius:", ";cursor:pointer;", ";", ";"], props => props.theme.borderRadii.md, colorStyles, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
658
|
+
StyledColorSwatchLabel.defaultProps = {
|
|
659
|
+
theme: reactTheming.DEFAULT_THEME
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
var _path$1;
|
|
663
|
+
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); }
|
|
664
|
+
var SvgCheckSmFill = function SvgCheckSmFill(props) {
|
|
665
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$1({
|
|
666
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
667
|
+
width: 12,
|
|
668
|
+
height: 12,
|
|
669
|
+
focusable: "false",
|
|
670
|
+
viewBox: "0 0 12 12",
|
|
671
|
+
"aria-hidden": "true"
|
|
672
|
+
}, props), _path$1 || (_path$1 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
673
|
+
fill: "none",
|
|
674
|
+
stroke: "currentColor",
|
|
675
|
+
strokeLinecap: "round",
|
|
676
|
+
strokeLinejoin: "round",
|
|
677
|
+
strokeWidth: 2,
|
|
678
|
+
d: "M3 6l2 2 4-4"
|
|
679
|
+
})));
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
const COMPONENT_ID$1 = 'colorpickers.colorswatch_check';
|
|
683
|
+
const StyledIcon = styled__default.default(SvgCheckSmFill).attrs({
|
|
661
684
|
'data-garden-id': COMPONENT_ID$1,
|
|
662
|
-
'data-garden-version': '9.0.0-next.
|
|
685
|
+
'data-garden-version': '9.0.0-next.2'
|
|
663
686
|
}).withConfig({
|
|
664
687
|
displayName: "StyledIcon",
|
|
665
688
|
componentId: "sc-8oigif-0"
|
|
666
|
-
})(["transition:opacity 0.2s ease-in-out;opacity:
|
|
689
|
+
})(["position:absolute;top:0;left:0;transition:opacity 0.2s ease-in-out;opacity:0;width:100%;height:100%;", ":checked ~ &{opacity:1;}", ";"], StyledColorSwatchInput, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
667
690
|
StyledIcon.defaultProps = {
|
|
668
691
|
theme: reactTheming.DEFAULT_THEME
|
|
669
692
|
};
|
|
@@ -671,7 +694,7 @@ StyledIcon.defaultProps = {
|
|
|
671
694
|
const COMPONENT_ID = 'colorpickers.swatch_cell';
|
|
672
695
|
const StyledCell = styled__default.default.td.attrs({
|
|
673
696
|
'data-garden-id': COMPONENT_ID,
|
|
674
|
-
'data-garden-version': '9.0.0-next.
|
|
697
|
+
'data-garden-version': '9.0.0-next.2'
|
|
675
698
|
}).withConfig({
|
|
676
699
|
displayName: "StyledCell",
|
|
677
700
|
componentId: "sc-qr3oit-0"
|
|
@@ -1225,17 +1248,17 @@ Colorpicker.propTypes = {
|
|
|
1225
1248
|
defaultColor: PropTypes__default.default.oneOfType([PropTypes__default.default.object, PropTypes__default.default.string])
|
|
1226
1249
|
};
|
|
1227
1250
|
|
|
1228
|
-
var _path
|
|
1229
|
-
function _extends
|
|
1251
|
+
var _path;
|
|
1252
|
+
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); }
|
|
1230
1253
|
var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
|
|
1231
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends
|
|
1254
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends({
|
|
1232
1255
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1233
1256
|
width: 16,
|
|
1234
1257
|
height: 16,
|
|
1235
1258
|
focusable: "false",
|
|
1236
1259
|
viewBox: "0 0 16 16",
|
|
1237
1260
|
"aria-hidden": "true"
|
|
1238
|
-
}, props), _path
|
|
1261
|
+
}, props), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
|
|
1239
1262
|
fill: "currentColor",
|
|
1240
1263
|
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"
|
|
1241
1264
|
})));
|
|
@@ -1253,7 +1276,6 @@ const ColorpickerDialog = React.forwardRef((_ref, ref) => {
|
|
|
1253
1276
|
isAnimated,
|
|
1254
1277
|
isOpaque,
|
|
1255
1278
|
isOpen,
|
|
1256
|
-
popperModifiers,
|
|
1257
1279
|
zIndex,
|
|
1258
1280
|
focusInset,
|
|
1259
1281
|
disabled,
|
|
@@ -1315,7 +1337,6 @@ const ColorpickerDialog = React.forwardRef((_ref, ref) => {
|
|
|
1315
1337
|
}, React__namespace.default.createElement(SvgChevronDownStroke, null))), React__namespace.default.createElement(StyledTooltipModal, _extends$2({
|
|
1316
1338
|
ref: ref,
|
|
1317
1339
|
hasArrow: hasArrow,
|
|
1318
|
-
popperModifiers: popperModifiers,
|
|
1319
1340
|
zIndex: zIndex,
|
|
1320
1341
|
isAnimated: isAnimated,
|
|
1321
1342
|
isOpaque: isOpaque,
|
|
@@ -1345,7 +1366,6 @@ ColorpickerDialog.propTypes = {
|
|
|
1345
1366
|
disabled: PropTypes__default.default.bool,
|
|
1346
1367
|
labels: PropTypes__default.default.object,
|
|
1347
1368
|
buttonProps: PropTypes__default.default.object,
|
|
1348
|
-
popperModifiers: PropTypes__default.default.any,
|
|
1349
1369
|
zIndex: PropTypes__default.default.number,
|
|
1350
1370
|
hasArrow: PropTypes__default.default.bool,
|
|
1351
1371
|
isAnimated: PropTypes__default.default.bool,
|
|
@@ -1360,109 +1380,134 @@ ColorpickerDialog.defaultProps = {
|
|
|
1360
1380
|
};
|
|
1361
1381
|
ColorpickerDialog.displayName = 'ColorpickerDialog';
|
|
1362
1382
|
|
|
1363
|
-
var _path;
|
|
1364
|
-
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); }
|
|
1365
|
-
var SvgCheckSmFill = function SvgCheckSmFill(props) {
|
|
1366
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends({
|
|
1367
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1368
|
-
width: 12,
|
|
1369
|
-
height: 12,
|
|
1370
|
-
focusable: "false",
|
|
1371
|
-
viewBox: "0 0 12 12",
|
|
1372
|
-
"aria-hidden": "true"
|
|
1373
|
-
}, props), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
|
|
1374
|
-
fill: "none",
|
|
1375
|
-
stroke: "currentColor",
|
|
1376
|
-
strokeLinecap: "round",
|
|
1377
|
-
strokeLinejoin: "round",
|
|
1378
|
-
strokeWidth: 2,
|
|
1379
|
-
d: "M3 6l2 2 4-4"
|
|
1380
|
-
})));
|
|
1381
|
-
};
|
|
1382
|
-
|
|
1383
1383
|
const ColorSwatch = React.forwardRef((_ref, ref) => {
|
|
1384
1384
|
let {
|
|
1385
|
+
name,
|
|
1385
1386
|
colors,
|
|
1387
|
+
isCheckboxGroup,
|
|
1388
|
+
defaultSelectedColIndex,
|
|
1389
|
+
defaultSelectedRowIndex,
|
|
1390
|
+
selectedColIndex,
|
|
1391
|
+
selectedRowIndex,
|
|
1392
|
+
onSelect,
|
|
1386
1393
|
...props
|
|
1387
1394
|
} = _ref;
|
|
1388
|
-
const
|
|
1389
|
-
|
|
1390
|
-
|
|
1395
|
+
const theme = React.useContext(styled.ThemeContext) || reactTheming.DEFAULT_THEME;
|
|
1396
|
+
const environment = reactTheming.useDocument(theme);
|
|
1397
|
+
const gridRef = React.useRef();
|
|
1398
|
+
const [rowIndex, setRowIndex] = React.useState(selectedRowIndex === null ? undefined : selectedRowIndex);
|
|
1399
|
+
const [colIndex, setColIndex] = React.useState(selectedColIndex === null ? undefined : selectedColIndex);
|
|
1400
|
+
const isControlled = selectedColIndex !== undefined && selectedRowIndex !== undefined;
|
|
1391
1401
|
const {
|
|
1392
1402
|
getGridCellProps
|
|
1393
1403
|
} = containerGrid.useGrid({
|
|
1394
|
-
|
|
1404
|
+
environment,
|
|
1405
|
+
rtl: theme.rtl,
|
|
1395
1406
|
matrix: colors,
|
|
1396
|
-
selection: true,
|
|
1397
1407
|
wrap: true,
|
|
1398
1408
|
idPrefix: containerUtilities.useId(undefined),
|
|
1399
|
-
|
|
1409
|
+
defaultRowIndex: defaultSelectedRowIndex,
|
|
1410
|
+
defaultColIndex: defaultSelectedColIndex,
|
|
1411
|
+
rowIndex,
|
|
1412
|
+
colIndex,
|
|
1413
|
+
onChange: (row, col) => {
|
|
1414
|
+
setRowIndex(row);
|
|
1415
|
+
setColIndex(col);
|
|
1416
|
+
}
|
|
1400
1417
|
});
|
|
1401
|
-
return React__namespace.default.createElement(StyledColorSwatch, {
|
|
1402
|
-
|
|
1403
|
-
|
|
1418
|
+
return React__namespace.default.createElement(StyledColorSwatch, _extends$2({
|
|
1419
|
+
role: "grid",
|
|
1420
|
+
ref: reactMergeRefs.mergeRefs([gridRef, ref])
|
|
1421
|
+
}, props), React__namespace.default.createElement("tbody", null, colors.map((row, _rowIndex) => React__namespace.default.createElement("tr", {
|
|
1404
1422
|
key: row[0].value
|
|
1405
|
-
}, row.map((color,
|
|
1423
|
+
}, row.map((color, _colIndex) => {
|
|
1406
1424
|
const {
|
|
1407
1425
|
label,
|
|
1408
1426
|
value
|
|
1409
1427
|
} = color;
|
|
1410
1428
|
const {
|
|
1411
|
-
|
|
1412
|
-
|
|
1429
|
+
role,
|
|
1430
|
+
onFocus,
|
|
1431
|
+
...gridCellProps
|
|
1413
1432
|
} = getGridCellProps({
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
type: 'button',
|
|
1417
|
-
role: undefined
|
|
1433
|
+
colIndex: _colIndex,
|
|
1434
|
+
rowIndex: _rowIndex
|
|
1418
1435
|
});
|
|
1436
|
+
const checked = isControlled ? selectedRowIndex === _rowIndex && selectedColIndex === _colIndex : undefined;
|
|
1437
|
+
const defaultChecked = isControlled ? undefined : defaultSelectedRowIndex === _rowIndex && defaultSelectedColIndex === _colIndex;
|
|
1438
|
+
const handleChange = event => {
|
|
1439
|
+
if (onSelect) {
|
|
1440
|
+
if (event.target.checked) {
|
|
1441
|
+
onSelect(_rowIndex, _colIndex);
|
|
1442
|
+
} else {
|
|
1443
|
+
onSelect(null, null);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
if (isCheckboxGroup && event.target.checked) {
|
|
1447
|
+
const inputs = gridRef.current?.querySelectorAll('input');
|
|
1448
|
+
inputs?.forEach(input => {
|
|
1449
|
+
if (input !== event.target) {
|
|
1450
|
+
input.checked = false;
|
|
1451
|
+
}
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
};
|
|
1455
|
+
const handleBlur = event => {
|
|
1456
|
+
event.target.parentElement?.removeAttribute('data-garden-focus-visible');
|
|
1457
|
+
if (!(isCheckboxGroup || gridRef.current?.contains(event.relatedTarget))) {
|
|
1458
|
+
const selectedInput = gridRef.current?.querySelector(`input[name='${event.target.name}']:checked`);
|
|
1459
|
+
if (selectedInput !== null) {
|
|
1460
|
+
const inputs = gridRef.current?.querySelectorAll('input');
|
|
1461
|
+
inputs?.forEach(input => input.setAttribute('tabIndex', input.checked ? '0' : '-1'));
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
const handleFocus = containerUtilities.composeEventHandlers(onFocus, event => event.target.parentElement?.setAttribute('data-garden-focus-visible', 'true'));
|
|
1419
1466
|
return React__namespace.default.createElement(StyledCell, {
|
|
1420
1467
|
key: value,
|
|
1421
|
-
|
|
1468
|
+
role: role
|
|
1469
|
+
}, React__namespace.default.createElement(StyledColorSwatchLabel, {
|
|
1470
|
+
backgroundColor: value
|
|
1422
1471
|
}, React__namespace.default.createElement(reactTooltips.Tooltip, {
|
|
1423
1472
|
content: label
|
|
1424
|
-
}, React__namespace.default.createElement(
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1473
|
+
}, React__namespace.default.createElement(StyledColorSwatchInput, _extends$2({
|
|
1474
|
+
"aria-label": label,
|
|
1475
|
+
name: name,
|
|
1476
|
+
type: isCheckboxGroup ? 'checkbox' : 'radio',
|
|
1477
|
+
value: value,
|
|
1478
|
+
defaultChecked: defaultChecked,
|
|
1479
|
+
checked: checked,
|
|
1480
|
+
onFocus: handleFocus,
|
|
1481
|
+
onBlur: handleBlur,
|
|
1482
|
+
onChange: handleChange
|
|
1483
|
+
}, gridCellProps))), React__namespace.default.createElement(StyledIcon, null)));
|
|
1432
1484
|
})))));
|
|
1433
1485
|
});
|
|
1434
1486
|
ColorSwatch.displayName = 'ColorSwatch';
|
|
1435
1487
|
ColorSwatch.propTypes = {
|
|
1488
|
+
name: PropTypes__default.default.string.isRequired,
|
|
1436
1489
|
colors: PropTypes__default.default.arrayOf(PropTypes__default.default.any).isRequired,
|
|
1437
|
-
|
|
1438
|
-
colIndex: PropTypes__default.default.number,
|
|
1490
|
+
isCheckboxGroup: PropTypes__default.default.bool,
|
|
1439
1491
|
selectedRowIndex: PropTypes__default.default.number,
|
|
1440
1492
|
selectedColIndex: PropTypes__default.default.number,
|
|
1441
|
-
defaultRowIndex: PropTypes__default.default.number,
|
|
1442
|
-
defaultColIndex: PropTypes__default.default.number,
|
|
1443
1493
|
defaultSelectedRowIndex: PropTypes__default.default.number,
|
|
1444
1494
|
defaultSelectedColIndex: PropTypes__default.default.number,
|
|
1445
|
-
onChange: PropTypes__default.default.func,
|
|
1446
1495
|
onSelect: PropTypes__default.default.func
|
|
1447
1496
|
};
|
|
1448
1497
|
|
|
1449
1498
|
const ColorSwatchDialog = React.forwardRef((_ref, ref) => {
|
|
1450
1499
|
let {
|
|
1500
|
+
name,
|
|
1451
1501
|
colors,
|
|
1452
|
-
|
|
1453
|
-
colIndex,
|
|
1502
|
+
isCheckboxGroup,
|
|
1454
1503
|
selectedRowIndex,
|
|
1455
1504
|
selectedColIndex,
|
|
1456
|
-
defaultRowIndex,
|
|
1457
|
-
defaultColIndex,
|
|
1458
1505
|
defaultSelectedRowIndex,
|
|
1459
1506
|
defaultSelectedColIndex,
|
|
1460
1507
|
placement,
|
|
1461
|
-
onChange,
|
|
1462
1508
|
onSelect,
|
|
1463
1509
|
hasArrow,
|
|
1464
1510
|
isAnimated,
|
|
1465
|
-
popperModifiers,
|
|
1466
1511
|
zIndex,
|
|
1467
1512
|
isOpen,
|
|
1468
1513
|
focusInset,
|
|
@@ -1473,17 +1518,21 @@ const ColorSwatchDialog = React.forwardRef((_ref, ref) => {
|
|
|
1473
1518
|
'aria-label': ariaLabel,
|
|
1474
1519
|
...props
|
|
1475
1520
|
} = _ref;
|
|
1476
|
-
const
|
|
1477
|
-
const controlledSelect = selectedRowIndex !== null && selectedColIndex !== null && selectedRowIndex !== undefined && selectedColIndex !== undefined;
|
|
1478
|
-
const isControlled = controlledFocus || controlledSelect;
|
|
1521
|
+
const isControlled = selectedRowIndex !== undefined && selectedColIndex !== undefined;
|
|
1479
1522
|
const isDialogControlled = isOpen !== undefined && isOpen !== null;
|
|
1480
1523
|
const buttonRef = React.useRef(null);
|
|
1481
1524
|
const colorSwatchRef = React.useRef(null);
|
|
1482
|
-
const [referenceElement, setReferenceElement] = React.useState();
|
|
1483
|
-
const [
|
|
1484
|
-
const [
|
|
1485
|
-
|
|
1486
|
-
|
|
1525
|
+
const [referenceElement, setReferenceElement] = React.useState(null);
|
|
1526
|
+
const [rowIndex, setRowIndex] = React.useState(defaultSelectedRowIndex);
|
|
1527
|
+
const [colIndex, setColIndex] = React.useState(defaultSelectedColIndex);
|
|
1528
|
+
let backgroundColor;
|
|
1529
|
+
if (isControlled) {
|
|
1530
|
+
if (selectedRowIndex !== null && selectedColIndex !== null) {
|
|
1531
|
+
backgroundColor = colors[selectedRowIndex][selectedColIndex].value;
|
|
1532
|
+
}
|
|
1533
|
+
} else if (rowIndex !== undefined && colIndex !== undefined) {
|
|
1534
|
+
backgroundColor = colors[rowIndex][colIndex].value;
|
|
1535
|
+
}
|
|
1487
1536
|
const ariaLabelText = reactTheming.useText(ColorSwatchDialog, {
|
|
1488
1537
|
'aria-label': ariaLabel
|
|
1489
1538
|
}, 'aria-label', 'Color swatch');
|
|
@@ -1496,14 +1545,6 @@ const ColorSwatchDialog = React.forwardRef((_ref, ref) => {
|
|
|
1496
1545
|
}
|
|
1497
1546
|
}
|
|
1498
1547
|
}, [isOpen, isDialogControlled]);
|
|
1499
|
-
let uncontrolledSelectedColor;
|
|
1500
|
-
let controlledSelectedColor;
|
|
1501
|
-
if (uncontrolledSelectedRowIndex > -1 && uncontrolledSelectedColIndex > -1) {
|
|
1502
|
-
uncontrolledSelectedColor = colors[uncontrolledSelectedRowIndex][uncontrolledSelectedColIndex];
|
|
1503
|
-
}
|
|
1504
|
-
if (selectedRowIndex !== undefined && selectedColIndex !== undefined && selectedRowIndex > -1 && selectedColIndex > -1) {
|
|
1505
|
-
controlledSelectedColor = colors[selectedRowIndex][selectedColIndex];
|
|
1506
|
-
}
|
|
1507
1548
|
const openDialog = () => {
|
|
1508
1549
|
setReferenceElement(buttonRef.current);
|
|
1509
1550
|
onDialogChange && onDialogChange({
|
|
@@ -1511,8 +1552,6 @@ const ColorSwatchDialog = React.forwardRef((_ref, ref) => {
|
|
|
1511
1552
|
});
|
|
1512
1553
|
};
|
|
1513
1554
|
const closeDialog = () => {
|
|
1514
|
-
setUncontrolledRowIndex(uncontrolledSelectedRowIndex);
|
|
1515
|
-
setUncontrolledColIndex(uncontrolledSelectedColIndex);
|
|
1516
1555
|
setReferenceElement(null);
|
|
1517
1556
|
onDialogChange && onDialogChange({
|
|
1518
1557
|
isOpen: false
|
|
@@ -1527,15 +1566,22 @@ const ColorSwatchDialog = React.forwardRef((_ref, ref) => {
|
|
|
1527
1566
|
});
|
|
1528
1567
|
React.useEffect(() => {
|
|
1529
1568
|
if (referenceElement && colorSwatchRef.current) {
|
|
1530
|
-
const
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1569
|
+
const input = colorSwatchRef.current.querySelector('[tabindex="0"]');
|
|
1570
|
+
input?.focus();
|
|
1571
|
+
}
|
|
1572
|
+
}, [referenceElement]);
|
|
1573
|
+
const handleSelect = (row, col) => {
|
|
1574
|
+
if (isControlled === false) {
|
|
1575
|
+
if (row === null || col === null) {
|
|
1576
|
+
setRowIndex(undefined);
|
|
1577
|
+
setColIndex(undefined);
|
|
1534
1578
|
} else {
|
|
1535
|
-
|
|
1579
|
+
setRowIndex(row);
|
|
1580
|
+
setColIndex(col);
|
|
1536
1581
|
}
|
|
1537
1582
|
}
|
|
1538
|
-
|
|
1583
|
+
onSelect && onSelect(row, col);
|
|
1584
|
+
};
|
|
1539
1585
|
return React__namespace.default.createElement(React__namespace.default.Fragment, null, children ? ( React.cloneElement(React.Children.only(children), {
|
|
1540
1586
|
onClick,
|
|
1541
1587
|
ref: buttonRef
|
|
@@ -1545,9 +1591,9 @@ const ColorSwatchDialog = React.forwardRef((_ref, ref) => {
|
|
|
1545
1591
|
ref: buttonRef,
|
|
1546
1592
|
onClick: onClick
|
|
1547
1593
|
}, buttonProps), React__namespace.default.createElement(StyledButtonPreview, {
|
|
1548
|
-
backgroundColor:
|
|
1594
|
+
backgroundColor: backgroundColor
|
|
1549
1595
|
}), React__namespace.default.createElement(reactButtons.Button.EndIcon, {
|
|
1550
|
-
isRotated: referenceElement
|
|
1596
|
+
isRotated: referenceElement !== null
|
|
1551
1597
|
}, React__namespace.default.createElement(SvgChevronDownStroke, null))), React__namespace.default.createElement(StyledTooltipModal, _extends$2({
|
|
1552
1598
|
ref: ref,
|
|
1553
1599
|
zIndex: zIndex,
|
|
@@ -1555,35 +1601,19 @@ const ColorSwatchDialog = React.forwardRef((_ref, ref) => {
|
|
|
1555
1601
|
focusOnMount: false,
|
|
1556
1602
|
placement: placement,
|
|
1557
1603
|
isAnimated: isAnimated,
|
|
1558
|
-
popperModifiers: popperModifiers,
|
|
1559
1604
|
referenceElement: referenceElement,
|
|
1560
1605
|
onClose: closeDialog,
|
|
1561
1606
|
"aria-label": ariaLabelText
|
|
1562
1607
|
}, props), React__namespace.default.createElement(StyledTooltipBody, null, React__namespace.default.createElement(ColorSwatch, {
|
|
1608
|
+
name: name,
|
|
1563
1609
|
colors: colors,
|
|
1564
1610
|
ref: colorSwatchRef,
|
|
1565
|
-
|
|
1566
|
-
colIndex: colIndex,
|
|
1611
|
+
isCheckboxGroup: isCheckboxGroup,
|
|
1567
1612
|
selectedRowIndex: selectedRowIndex,
|
|
1568
1613
|
selectedColIndex: selectedColIndex,
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
defaultSelectedColIndex: uncontrolledSelectedColIndex,
|
|
1573
|
-
onChange: (rowIdx, colIdx) => {
|
|
1574
|
-
if (isControlled === false) {
|
|
1575
|
-
setUncontrolledRowIndex(rowIdx);
|
|
1576
|
-
setUncontrolledColIndex(colIdx);
|
|
1577
|
-
}
|
|
1578
|
-
onChange && onChange(rowIdx, colIdx);
|
|
1579
|
-
},
|
|
1580
|
-
onSelect: (rowIdx, colIdx) => {
|
|
1581
|
-
if (isControlled === false) {
|
|
1582
|
-
setUncontrolledSelectedRowIndex(rowIdx);
|
|
1583
|
-
setUncontrolledSelectedColIndex(colIdx);
|
|
1584
|
-
}
|
|
1585
|
-
onSelect && onSelect(rowIdx, colIdx);
|
|
1586
|
-
}
|
|
1614
|
+
defaultSelectedRowIndex: rowIndex,
|
|
1615
|
+
defaultSelectedColIndex: colIndex,
|
|
1616
|
+
onSelect: handleSelect
|
|
1587
1617
|
}))));
|
|
1588
1618
|
});
|
|
1589
1619
|
ColorSwatchDialog.propTypes = {
|
|
@@ -1592,7 +1622,6 @@ ColorSwatchDialog.propTypes = {
|
|
|
1592
1622
|
onDialogChange: PropTypes__default.default.func,
|
|
1593
1623
|
disabled: PropTypes__default.default.bool,
|
|
1594
1624
|
buttonProps: PropTypes__default.default.object,
|
|
1595
|
-
popperModifiers: PropTypes__default.default.any,
|
|
1596
1625
|
zIndex: PropTypes__default.default.number,
|
|
1597
1626
|
hasArrow: PropTypes__default.default.bool,
|
|
1598
1627
|
isAnimated: PropTypes__default.default.bool,
|