@itwin/itwinui-react 1.23.2 → 1.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/cjs/core/Buttons/Button/Button.d.ts +1 -1
  3. package/cjs/core/ColorPicker/ColorBuilder.js +40 -15
  4. package/cjs/core/ColorPicker/ColorInputPanel.js +125 -46
  5. package/cjs/core/ColorPicker/ColorPicker.d.ts +5 -0
  6. package/cjs/core/ColorPicker/ColorPicker.js +7 -6
  7. package/cjs/core/ColorPicker/ColorPickerContext.d.ts +4 -2
  8. package/cjs/core/ColorPicker/ColorSwatch.d.ts +1 -1
  9. package/cjs/core/ColorPicker/ColorSwatch.js +10 -4
  10. package/cjs/core/DatePicker/DatePicker.d.ts +1 -1
  11. package/cjs/core/InformationPanel/InformationPanel.d.ts +4 -1
  12. package/cjs/core/InformationPanel/InformationPanel.js +4 -1
  13. package/cjs/core/InformationPanel/InformationPanelContent.d.ts +42 -0
  14. package/cjs/core/InformationPanel/InformationPanelContent.js +66 -0
  15. package/cjs/core/InformationPanel/index.d.ts +2 -0
  16. package/cjs/core/InformationPanel/index.js +3 -1
  17. package/cjs/core/Label/Label.d.ts +31 -0
  18. package/cjs/core/Label/Label.js +53 -0
  19. package/cjs/core/Label/index.d.ts +4 -0
  20. package/cjs/core/Label/index.js +10 -0
  21. package/cjs/core/LabeledInput/LabeledInput.d.ts +2 -2
  22. package/cjs/core/LabeledTextarea/LabeledTextarea.d.ts +1 -1
  23. package/cjs/core/Menu/MenuItem.d.ts +1 -1
  24. package/cjs/core/Table/TablePaginator.d.ts +1 -1
  25. package/cjs/core/Table/TablePaginator.js +9 -4
  26. package/cjs/core/Tabs/Tabs.js +23 -29
  27. package/cjs/core/index.d.ts +6 -4
  28. package/cjs/core/index.js +6 -2
  29. package/cjs/core/utils/color/ColorValue.d.ts +1 -0
  30. package/cjs/core/utils/color/ColorValue.js +101 -85
  31. package/cjs/core/utils/components/MiddleTextTruncation.d.ts +21 -0
  32. package/cjs/core/utils/components/MiddleTextTruncation.js +56 -0
  33. package/cjs/core/utils/components/index.d.ts +1 -0
  34. package/cjs/core/utils/components/index.js +1 -0
  35. package/cjs/core/utils/hooks/index.d.ts +1 -0
  36. package/cjs/core/utils/hooks/index.js +1 -0
  37. package/cjs/core/utils/hooks/useContainerWidth.d.ts +17 -0
  38. package/cjs/core/utils/hooks/useContainerWidth.js +50 -0
  39. package/cjs/core/utils/hooks/useOverflow.d.ts +1 -1
  40. package/cjs/core/utils/hooks/useOverflow.js +30 -17
  41. package/esm/core/Buttons/Button/Button.d.ts +1 -1
  42. package/esm/core/ColorPicker/ColorBuilder.js +40 -15
  43. package/esm/core/ColorPicker/ColorInputPanel.js +125 -46
  44. package/esm/core/ColorPicker/ColorPicker.d.ts +5 -0
  45. package/esm/core/ColorPicker/ColorPicker.js +7 -6
  46. package/esm/core/ColorPicker/ColorPickerContext.d.ts +4 -2
  47. package/esm/core/ColorPicker/ColorSwatch.d.ts +1 -1
  48. package/esm/core/ColorPicker/ColorSwatch.js +10 -4
  49. package/esm/core/DatePicker/DatePicker.d.ts +1 -1
  50. package/esm/core/InformationPanel/InformationPanel.d.ts +4 -1
  51. package/esm/core/InformationPanel/InformationPanel.js +4 -1
  52. package/esm/core/InformationPanel/InformationPanelContent.d.ts +42 -0
  53. package/esm/core/InformationPanel/InformationPanelContent.js +59 -0
  54. package/esm/core/InformationPanel/index.d.ts +2 -0
  55. package/esm/core/InformationPanel/index.js +1 -0
  56. package/esm/core/Label/Label.d.ts +31 -0
  57. package/esm/core/Label/Label.js +46 -0
  58. package/esm/core/Label/index.d.ts +4 -0
  59. package/esm/core/Label/index.js +6 -0
  60. package/esm/core/LabeledInput/LabeledInput.d.ts +2 -2
  61. package/esm/core/LabeledTextarea/LabeledTextarea.d.ts +1 -1
  62. package/esm/core/Menu/MenuItem.d.ts +1 -1
  63. package/esm/core/Table/TablePaginator.d.ts +1 -1
  64. package/esm/core/Table/TablePaginator.js +9 -4
  65. package/esm/core/Tabs/Tabs.js +24 -30
  66. package/esm/core/index.d.ts +6 -4
  67. package/esm/core/index.js +3 -2
  68. package/esm/core/utils/color/ColorValue.d.ts +1 -0
  69. package/esm/core/utils/color/ColorValue.js +101 -85
  70. package/esm/core/utils/components/MiddleTextTruncation.d.ts +21 -0
  71. package/esm/core/utils/components/MiddleTextTruncation.js +49 -0
  72. package/esm/core/utils/components/index.d.ts +1 -0
  73. package/esm/core/utils/components/index.js +1 -0
  74. package/esm/core/utils/hooks/index.d.ts +1 -0
  75. package/esm/core/utils/hooks/index.js +1 -0
  76. package/esm/core/utils/hooks/useContainerWidth.d.ts +17 -0
  77. package/esm/core/utils/hooks/useContainerWidth.js +43 -0
  78. package/esm/core/utils/hooks/useOverflow.d.ts +1 -1
  79. package/esm/core/utils/hooks/useOverflow.js +30 -17
  80. package/package.json +2 -2
@@ -44,20 +44,24 @@ var getHorizontalPercentageOfRectangle = function (rect, pointer) {
44
44
  * and a set of sliders to adjust hue and alpha values.
45
45
  */
46
46
  export var ColorBuilder = React.forwardRef(function (props, ref) {
47
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
47
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
48
48
  var className = props.className, rest = __rest(props, ["className"]);
49
49
  var builderRef = React.useRef();
50
50
  var refs = useMergedRefs(builderRef, ref);
51
51
  useTheme();
52
- var _k = useColorPickerContext(), activeColor = _k.activeColor, hsvColor = _k.hsvColor, onChangeComplete = _k.onChangeComplete, applyHsvColorChange = _k.applyHsvColorChange;
52
+ var _o = useColorPickerContext(), activeColor = _o.activeColor, hsvColor = _o.hsvColor, onChangeComplete = _o.onChangeComplete, applyHsvColorChange = _o.applyHsvColorChange, showAlpha = _o.showAlpha;
53
53
  // Set values for slider
54
- var hueSliderColor = React.useMemo(function () { return ColorValue.create({ h: hsvColor.h, s: 100, v: 100 }); }, [hsvColor]);
54
+ var hueSliderColor = React.useMemo(function () { return ColorValue.create({ h: hsvColor.h, s: 100, v: 100 }); }, [hsvColor.h]);
55
55
  var sliderValue = React.useMemo(function () { return hsvColor.h; }, [hsvColor]);
56
+ var alphaValue = React.useMemo(function () { var _a; return (showAlpha ? (_a = hsvColor.a) !== null && _a !== void 0 ? _a : 1 : 1); }, [
57
+ hsvColor.a,
58
+ showAlpha,
59
+ ]);
56
60
  // Set values for color square and color dot
57
61
  var dotColorString = React.useMemo(function () { return activeColor.toHexString(); }, [
58
62
  activeColor,
59
63
  ]);
60
- var _l = React.useState(false), colorDotActive = _l[0], setColorDotActive = _l[1];
64
+ var _p = React.useState(false), colorDotActive = _p[0], setColorDotActive = _p[1];
61
65
  var hueColorString = hueSliderColor.toHexString();
62
66
  var colorSquareStyle = ((_c = (_b = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.CSS) === null || _b === void 0 ? void 0 : _b.supports) === null || _c === void 0 ? void 0 : _c.call(_b, "--hue:\u00A0" + hueColorString))
63
67
  ? {
@@ -65,9 +69,12 @@ export var ColorBuilder = React.forwardRef(function (props, ref) {
65
69
  '--selected-color': dotColorString,
66
70
  }
67
71
  : { backgroundColor: hueColorString };
72
+ var opacitySliderStyle = ((_f = (_e = (_d = getWindow()) === null || _d === void 0 ? void 0 : _d.CSS) === null || _e === void 0 ? void 0 : _e.supports) === null || _f === void 0 ? void 0 : _f.call(_e, "--selected-color:\u00A0" + hueColorString))
73
+ ? { '--selected-color': hueColorString }
74
+ : { backgroundColor: hueColorString };
68
75
  var squareTop = 100 - hsvColor.v;
69
76
  var squareLeft = hsvColor.s;
70
- var colorDotStyle = ((_f = (_e = (_d = getWindow()) === null || _d === void 0 ? void 0 : _d.CSS) === null || _e === void 0 ? void 0 : _e.supports) === null || _f === void 0 ? void 0 : _f.call(_e, "--top:\u00A0" + squareTop.toString() + "%"))
77
+ var colorDotStyle = ((_j = (_h = (_g = getWindow()) === null || _g === void 0 ? void 0 : _g.CSS) === null || _h === void 0 ? void 0 : _h.supports) === null || _j === void 0 ? void 0 : _j.call(_h, "--top:\u00A0" + squareTop.toString() + "%"))
71
78
  ? {
72
79
  '--top': squareTop.toString() + '%',
73
80
  '--left': squareLeft.toString() + '%',
@@ -78,15 +85,27 @@ export var ColorBuilder = React.forwardRef(function (props, ref) {
78
85
  left: squareLeft.toString() + '%',
79
86
  };
80
87
  // Update slider change
81
- var updateSlider = React.useCallback(function (huePercent, selectionChanged) {
82
- var hue = Math.round(huePercent);
88
+ var updateHueSlider = React.useCallback(function (huePercent, selectionChanged) {
89
+ var hue = Number(huePercent.toFixed(2));
83
90
  var newHsvColor = {
84
91
  h: hue,
85
92
  s: hsvColor.s,
86
93
  v: hsvColor.v,
94
+ a: hsvColor.a,
87
95
  };
88
96
  applyHsvColorChange(newHsvColor, selectionChanged);
89
- }, [applyHsvColorChange, hsvColor.s, hsvColor.v]);
97
+ }, [applyHsvColorChange, hsvColor]);
98
+ // Update opacity slider change
99
+ var updateOpacitySlider = React.useCallback(function (alphaPercent, selectionChanged) {
100
+ var alpha = Number(alphaPercent.toFixed(2));
101
+ var newHsvColor = {
102
+ h: hsvColor.h,
103
+ s: hsvColor.s,
104
+ v: hsvColor.v,
105
+ a: alpha,
106
+ };
107
+ applyHsvColorChange(newHsvColor, selectionChanged);
108
+ }, [applyHsvColorChange, hsvColor]);
90
109
  // Update Color field square change
91
110
  var squareRef = React.useRef(null);
92
111
  var colorDotRef = React.useRef(null);
@@ -95,9 +114,10 @@ export var ColorBuilder = React.forwardRef(function (props, ref) {
95
114
  h: hsvColor.h,
96
115
  s: x,
97
116
  v: 100 - y,
117
+ a: hsvColor.a,
98
118
  };
99
119
  applyHsvColorChange(newHsvColor, selectionChanged);
100
- }, [applyHsvColorChange, hsvColor.h]);
120
+ }, [applyHsvColorChange, hsvColor]);
101
121
  var updateSquareValue = React.useCallback(function (event, callbackType) {
102
122
  if ((squareRef.current && colorDotActive) ||
103
123
  (squareRef.current && callbackType === 'onClick')) {
@@ -117,18 +137,18 @@ export var ColorBuilder = React.forwardRef(function (props, ref) {
117
137
  event.preventDefault();
118
138
  event.stopPropagation();
119
139
  }, [updateSquareValue]);
120
- useEventListener('pointerup', handleSquarePointerUp, (_g = builderRef.current) === null || _g === void 0 ? void 0 : _g.ownerDocument);
140
+ useEventListener('pointerup', handleSquarePointerUp, (_k = builderRef.current) === null || _k === void 0 ? void 0 : _k.ownerDocument);
121
141
  var handleSquarePointerMove = React.useCallback(function (event) {
122
142
  event.preventDefault();
123
143
  event.stopPropagation();
124
144
  updateSquareValue(event, 'onUpdate');
125
145
  }, [updateSquareValue]);
126
- useEventListener('pointermove', handleSquarePointerMove, (_h = builderRef.current) === null || _h === void 0 ? void 0 : _h.ownerDocument);
146
+ useEventListener('pointermove', handleSquarePointerMove, (_l = builderRef.current) === null || _l === void 0 ? void 0 : _l.ownerDocument);
127
147
  var handleSquarePointerLeave = React.useCallback(function (event) {
128
148
  updateSquareValue(event, 'onChange');
129
149
  setColorDotActive(false);
130
150
  }, [updateSquareValue]);
131
- useEventListener('pointerleave', handleSquarePointerLeave, (_j = builderRef.current) === null || _j === void 0 ? void 0 : _j.ownerDocument);
151
+ useEventListener('pointerleave', handleSquarePointerLeave, (_m = builderRef.current) === null || _m === void 0 ? void 0 : _m.ownerDocument);
132
152
  var keysPressed = React.useRef({}); // keep track of which keys are currently pressed
133
153
  // Arrow key navigation for color dot
134
154
  var handleColorDotKeyDown = function (event) {
@@ -187,8 +207,13 @@ export var ColorBuilder = React.forwardRef(function (props, ref) {
187
207
  (_a = colorDotRef.current) === null || _a === void 0 ? void 0 : _a.focus();
188
208
  }, onKeyDown: handleColorDotKeyDown, onKeyUp: handleColorDotKeyUp, tabIndex: 0, ref: colorDotRef })),
189
209
  React.createElement(Slider, { minLabel: '', maxLabel: '', values: [sliderValue], className: 'iui-hue-slider', trackDisplayMode: 'none', tooltipProps: function () { return ({ visible: false }); }, onChange: function (values) {
190
- updateSlider(values[0], true);
210
+ updateHueSlider(values[0], true);
211
+ }, onUpdate: function (values) {
212
+ updateHueSlider(values[0], false);
213
+ }, min: 0, max: 359 }),
214
+ showAlpha && (React.createElement(Slider, { minLabel: '', maxLabel: '', values: [alphaValue], className: 'iui-opacity-slider', trackDisplayMode: 'none', tooltipProps: function () { return ({ visible: false }); }, onChange: function (values) {
215
+ updateOpacitySlider(values[0], true);
191
216
  }, onUpdate: function (values) {
192
- updateSlider(values[0], false);
193
- }, min: 0, max: 359 })));
217
+ updateOpacitySlider(values[0], false);
218
+ }, min: 0, max: 1, step: 0.01, style: opacitySliderStyle }))));
194
219
  });
@@ -41,43 +41,62 @@ import '@itwin/itwinui-css/css/color-picker.css';
41
41
  * </ColorPicker>
42
42
  */
43
43
  export var ColorInputPanel = React.forwardRef(function (props, ref) {
44
- var defaultColorFormat = props.defaultColorFormat, _a = props.allowedColorFormats, allowedColorFormats = _a === void 0 ? ['hsl', 'rgb', 'hex'] : _a, className = props.className, rest = __rest(props, ["defaultColorFormat", "allowedColorFormats", "className"]);
44
+ var _a, _b, _c, _d, _f, _g, _h, _j;
45
+ var defaultColorFormat = props.defaultColorFormat, _k = props.allowedColorFormats, allowedColorFormats = _k === void 0 ? ['hsl', 'rgb', 'hex'] : _k, className = props.className, rest = __rest(props, ["defaultColorFormat", "allowedColorFormats", "className"]);
45
46
  useTheme();
46
- var _b = useColorPickerContext(), activeColor = _b.activeColor, applyHsvColorChange = _b.applyHsvColorChange, hsvColor = _b.hsvColor;
47
- var _c = React.useState(defaultColorFormat), currentFormat = _c[0], setCurrentFormat = _c[1];
47
+ var inputsContainerRef = React.useRef(null);
48
+ var _l = useColorPickerContext(), activeColor = _l.activeColor, applyHsvColorChange = _l.applyHsvColorChange, hsvColor = _l.hsvColor, showAlpha = _l.showAlpha;
49
+ var _m = React.useState(defaultColorFormat), currentFormat = _m[0], setCurrentFormat = _m[1];
48
50
  React.useEffect(function () {
49
51
  setCurrentFormat(defaultColorFormat);
50
52
  }, [defaultColorFormat]);
51
53
  // need to use state since input may have parsing error
52
- var _d = React.useState([]), input = _d[0], setInput = _d[1];
54
+ var _o = React.useState(['', '', '', '']), input = _o[0], setInput = _o[1];
53
55
  React.useEffect(function () {
56
+ var _a, _b;
54
57
  if (currentFormat === 'hsl') {
55
58
  var hsl = activeColor.toHslColor();
56
- // use activeHue to preserve hue for 0,0,0 edge case
57
- setInput([hsvColor.h.toString(), hsl.s.toString(), hsl.l.toString()]);
59
+ setInput([
60
+ ColorValue.getFormattedColorNumber(hsvColor.h),
61
+ ColorValue.getFormattedColorNumber(hsl.s),
62
+ ColorValue.getFormattedColorNumber(hsl.l),
63
+ ColorValue.getFormattedColorNumber((_a = hsl.a) !== null && _a !== void 0 ? _a : activeColor.getAlpha() / 255, 2),
64
+ ]);
58
65
  }
59
66
  else if (currentFormat === 'rgb') {
60
67
  var rgb = activeColor.toRgbColor();
61
- setInput([rgb.r.toString(), rgb.g.toString(), rgb.b.toString()]);
68
+ setInput([
69
+ rgb.r.toString(),
70
+ rgb.g.toString(),
71
+ rgb.b.toString(),
72
+ ColorValue.getFormattedColorNumber((_b = rgb.a) !== null && _b !== void 0 ? _b : activeColor.getAlpha() / 255, 2),
73
+ ]);
62
74
  }
63
75
  else {
64
- setInput([activeColor.toHexString()]);
76
+ setInput([activeColor.toHexString(showAlpha)]);
77
+ setValidHexInput(true);
65
78
  }
66
- }, [activeColor, hsvColor.h, currentFormat]);
67
- var _f = React.useState(true), validHexInput = _f[0], setValidHexInput = _f[1];
79
+ }, [activeColor, hsvColor.h, currentFormat, showAlpha]);
80
+ var _p = React.useState(true), validHexInput = _p[0], setValidHexInput = _p[1];
68
81
  var swapColorFormat = React.useCallback(function () {
69
82
  var _a;
70
83
  var newFormat = (_a = allowedColorFormats[(allowedColorFormats.indexOf(currentFormat) + 1) %
71
84
  allowedColorFormats.length]) !== null && _a !== void 0 ? _a : allowedColorFormats[0];
72
85
  setCurrentFormat(newFormat);
73
86
  }, [currentFormat, allowedColorFormats]);
87
+ var isFocusInside = function (focused) {
88
+ return !!(focused &&
89
+ inputsContainerRef.current &&
90
+ inputsContainerRef.current.contains(focused));
91
+ };
74
92
  var handleColorInputChange = function () {
75
93
  var color;
76
94
  if (currentFormat === 'hex') {
77
95
  try {
78
- color = ColorValue.fromString(input[0]);
96
+ var value = input[0].replace(/ /g, '').toLowerCase(); // remove white space from input
97
+ color = ColorValue.create(value);
79
98
  setValidHexInput(true);
80
- if (activeColor.toHexString() === input[0]) {
99
+ if (activeColor.toHexString(showAlpha).toLowerCase() === value) {
81
100
  return;
82
101
  }
83
102
  }
@@ -87,33 +106,47 @@ export var ColorInputPanel = React.forwardRef(function (props, ref) {
87
106
  }
88
107
  }
89
108
  if (currentFormat === 'hsl') {
90
- var _a = input.map(Number), h = _a[0], s = _a[1], l = _a[2];
91
- if (h < 0 || h > 360 || s < 0 || s > 100 || l < 0 || l > 100) {
109
+ var _a = input.map(Number), h = _a[0], s = _a[1], l = _a[2], a = _a[3];
110
+ if (h < 0 ||
111
+ h > 360 ||
112
+ s < 0 ||
113
+ s > 100 ||
114
+ l < 0 ||
115
+ l > 100 ||
116
+ a < 0 ||
117
+ a > 1) {
92
118
  return;
93
119
  }
94
120
  var hsl = activeColor.toHslColor();
95
- if (hsl.h === h && hsl.s === s && hsl.l === l) {
121
+ if (hsl.h === h && hsl.s === s && hsl.l === l && hsl.a === a) {
96
122
  return;
97
123
  }
98
- color = ColorValue.create({ h: h, s: s, l: l });
124
+ color = ColorValue.create({ h: h, s: s, l: l, a: a });
99
125
  }
100
126
  if (currentFormat === 'rgb') {
101
- var _b = input.map(Number), r = _b[0], g = _b[1], b = _b[2];
102
- if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
127
+ var _b = input.map(Number), r = _b[0], g = _b[1], b = _b[2], a = _b[3];
128
+ if (r < 0 ||
129
+ r > 255 ||
130
+ g < 0 ||
131
+ g > 255 ||
132
+ b < 0 ||
133
+ b > 255 ||
134
+ a < 0 ||
135
+ a > 1) {
103
136
  return;
104
137
  }
105
138
  var rgb = activeColor.toRgbColor();
106
- if (rgb.r === r && rgb.g === g && rgb.b === b) {
139
+ if (rgb.r === r && rgb.g === g && rgb.b === b && rgb.a === a) {
107
140
  return;
108
141
  }
109
- color = ColorValue.create({ r: r, g: g, b: b });
142
+ color = ColorValue.create({ r: r, g: g, b: b, a: a });
110
143
  }
111
144
  if (color) {
112
- applyHsvColorChange(color.toHsvColor(), true);
145
+ applyHsvColorChange(color.toHsvColor(), true, color);
113
146
  }
114
147
  };
115
148
  var hexInputField = (React.createElement(InputContainer, { status: validHexInput ? undefined : 'negative' },
116
- React.createElement(Input, { size: 'small', maxLength: 7, minLength: 1, placeholder: 'HEX', value: input[0], onChange: function (event) {
149
+ React.createElement(Input, { size: 'small', maxLength: showAlpha ? 9 : 7, minLength: 1, placeholder: 'HEX', value: input[0], onChange: function (event) {
117
150
  var value = event.target.value.startsWith('#')
118
151
  ? event.target.value
119
152
  : "#" + event.target.value;
@@ -131,8 +164,8 @@ export var ColorInputPanel = React.forwardRef(function (props, ref) {
131
164
  React.createElement(InputContainer, { status: Number(input[0]) < 0 || Number(input[0]) > 360
132
165
  ? 'negative'
133
166
  : undefined },
134
- React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '359', placeholder: 'H', value: input[0], onChange: function (event) {
135
- setInput([event.target.value, input[1], input[2]]);
167
+ React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '359', step: '.1', placeholder: 'H', value: (_a = input[0]) !== null && _a !== void 0 ? _a : '', onChange: function (event) {
168
+ setInput([event.target.value, input[1], input[2], input[3]]);
136
169
  }, onKeyDown: function (event) {
137
170
  if (event.key === 'Enter') {
138
171
  event.preventDefault();
@@ -140,13 +173,15 @@ export var ColorInputPanel = React.forwardRef(function (props, ref) {
140
173
  }
141
174
  }, onBlur: function (event) {
142
175
  event.preventDefault();
143
- handleColorInputChange();
176
+ if (!isFocusInside(event.relatedTarget)) {
177
+ handleColorInputChange();
178
+ }
144
179
  } })),
145
180
  React.createElement(InputContainer, { status: Number(input[1]) < 0 || Number(input[1]) > 100
146
181
  ? 'negative'
147
182
  : undefined },
148
- React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '100', placeholder: 'S', value: input[1], onChange: function (event) {
149
- setInput([input[0], event.target.value, input[2]]);
183
+ React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '100', step: '.1', placeholder: 'S', value: (_b = input[1]) !== null && _b !== void 0 ? _b : '', onChange: function (event) {
184
+ setInput([input[0], event.target.value, input[2], input[3]]);
150
185
  }, onKeyDown: function (event) {
151
186
  if (event.key === 'Enter') {
152
187
  event.preventDefault();
@@ -154,13 +189,15 @@ export var ColorInputPanel = React.forwardRef(function (props, ref) {
154
189
  }
155
190
  }, onBlur: function (event) {
156
191
  event.preventDefault();
157
- handleColorInputChange();
192
+ if (!isFocusInside(event.relatedTarget)) {
193
+ handleColorInputChange();
194
+ }
158
195
  } })),
159
196
  React.createElement(InputContainer, { status: Number(input[2]) < 0 || Number(input[2]) > 100
160
197
  ? 'negative'
161
198
  : undefined },
162
- React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '100', placeholder: 'L', value: input[2], onChange: function (event) {
163
- setInput([input[0], input[1], event.target.value]);
199
+ React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '100', step: '.1', placeholder: 'L', value: (_c = input[2]) !== null && _c !== void 0 ? _c : '', onChange: function (event) {
200
+ setInput([input[0], input[1], event.target.value, input[3]]);
164
201
  }, onKeyDown: function (event) {
165
202
  if (event.key === 'Enter') {
166
203
  event.preventDefault();
@@ -168,14 +205,32 @@ export var ColorInputPanel = React.forwardRef(function (props, ref) {
168
205
  }
169
206
  }, onBlur: function (event) {
170
207
  event.preventDefault();
171
- handleColorInputChange();
172
- } }))));
208
+ if (!isFocusInside(event.relatedTarget)) {
209
+ handleColorInputChange();
210
+ }
211
+ } })),
212
+ showAlpha && (React.createElement(InputContainer, { status: Number(input[3]) < 0 || Number(input[3]) > 1
213
+ ? 'negative'
214
+ : undefined },
215
+ React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '1', step: '.01', placeholder: 'A', value: (_d = input[3]) !== null && _d !== void 0 ? _d : '', onChange: function (event) {
216
+ setInput([input[0], input[1], input[2], event.target.value]);
217
+ }, onKeyDown: function (event) {
218
+ if (event.key === 'Enter') {
219
+ event.preventDefault();
220
+ handleColorInputChange();
221
+ }
222
+ }, onBlur: function (event) {
223
+ event.preventDefault();
224
+ if (!isFocusInside(event.relatedTarget)) {
225
+ handleColorInputChange();
226
+ }
227
+ } })))));
173
228
  var rgbInputs = (React.createElement(React.Fragment, null,
174
229
  React.createElement(InputContainer, { status: Number(input[0]) < 0 || Number(input[0]) > 255
175
230
  ? 'negative'
176
231
  : undefined },
177
- React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'R', value: input[0], onChange: function (event) {
178
- setInput([event.target.value, input[1], input[2]]);
232
+ React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'R', value: (_f = input[0]) !== null && _f !== void 0 ? _f : '', onChange: function (event) {
233
+ setInput([event.target.value, input[1], input[2], input[3]]);
179
234
  }, onKeyDown: function (event) {
180
235
  if (event.key === 'Enter') {
181
236
  event.preventDefault();
@@ -183,13 +238,15 @@ export var ColorInputPanel = React.forwardRef(function (props, ref) {
183
238
  }
184
239
  }, onBlur: function (event) {
185
240
  event.preventDefault();
186
- handleColorInputChange();
241
+ if (!isFocusInside(event.relatedTarget)) {
242
+ handleColorInputChange();
243
+ }
187
244
  } })),
188
245
  React.createElement(InputContainer, { status: Number(input[1]) < 0 || Number(input[1]) > 255
189
246
  ? 'negative'
190
247
  : undefined },
191
- React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'G', value: input[1], onChange: function (event) {
192
- setInput([input[0], event.target.value, input[2]]);
248
+ React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'G', value: (_g = input[1]) !== null && _g !== void 0 ? _g : '', onChange: function (event) {
249
+ setInput([input[0], event.target.value, input[2], input[3]]);
193
250
  }, onKeyDown: function (event) {
194
251
  if (event.key === 'Enter') {
195
252
  event.preventDefault();
@@ -197,13 +254,15 @@ export var ColorInputPanel = React.forwardRef(function (props, ref) {
197
254
  }
198
255
  }, onBlur: function (event) {
199
256
  event.preventDefault();
200
- handleColorInputChange();
257
+ if (!isFocusInside(event.relatedTarget)) {
258
+ handleColorInputChange();
259
+ }
201
260
  } })),
202
261
  React.createElement(InputContainer, { status: Number(input[2]) < 0 || Number(input[2]) > 255
203
262
  ? 'negative'
204
263
  : undefined },
205
- React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'B', value: input[2], onChange: function (event) {
206
- setInput([input[0], input[1], event.target.value]);
264
+ React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '255', placeholder: 'B', value: (_h = input[2]) !== null && _h !== void 0 ? _h : '', onChange: function (event) {
265
+ setInput([input[0], input[1], event.target.value, input[3]]);
207
266
  }, onKeyDown: function (event) {
208
267
  if (event.key === 'Enter') {
209
268
  event.preventDefault();
@@ -211,17 +270,37 @@ export var ColorInputPanel = React.forwardRef(function (props, ref) {
211
270
  }
212
271
  }, onBlur: function (event) {
213
272
  event.preventDefault();
214
- handleColorInputChange();
215
- } }))));
273
+ if (!isFocusInside(event.relatedTarget)) {
274
+ handleColorInputChange();
275
+ }
276
+ } })),
277
+ showAlpha && (React.createElement(InputContainer, { status: Number(input[3]) < 0 || Number(input[3]) > 1
278
+ ? 'negative'
279
+ : undefined },
280
+ React.createElement(Input, { size: 'small', type: 'number', min: '0', max: '1', step: '.01', placeholder: 'A', value: (_j = input[3]) !== null && _j !== void 0 ? _j : '', onChange: function (event) {
281
+ setInput([input[0], input[1], input[2], event.target.value]);
282
+ }, onKeyDown: function (event) {
283
+ if (event.key === 'Enter') {
284
+ event.preventDefault();
285
+ handleColorInputChange();
286
+ }
287
+ }, onBlur: function (event) {
288
+ event.preventDefault();
289
+ if (!isFocusInside(event.relatedTarget)) {
290
+ handleColorInputChange();
291
+ }
292
+ } })))));
216
293
  return (React.createElement("div", __assign({ className: cx('iui-color-input-wrapper', className), ref: ref }, rest),
217
- React.createElement("div", { className: 'iui-color-picker-section-label' }, currentFormat.toUpperCase()),
294
+ React.createElement("div", { className: 'iui-color-picker-section-label' }, showAlpha && currentFormat != 'hex'
295
+ ? currentFormat.toUpperCase() + 'A'
296
+ : currentFormat.toUpperCase()),
218
297
  React.createElement("div", { className: 'iui-color-input' },
219
298
  allowedColorFormats.length > 1 && (React.createElement(IconButton, { styleType: 'borderless', onClick: swapColorFormat, size: 'small' },
220
299
  React.createElement("svg", { viewBox: '0 0 16 16', className: 'iui-icon', "aria-hidden": true },
221
300
  React.createElement("path", { d: 'm5 15-3.78125-3.5 3.78125-3.5v2h8v3h-8zm6-7 3.78125-3.5-3.78125-3.5v2h-8v3h8z' })))),
222
- React.createElement("div", { className: 'iui-color-input-fields' },
301
+ React.createElement("div", { ref: inputsContainerRef, className: 'iui-color-input-fields' },
223
302
  currentFormat === 'hex' && hexInputField,
224
- currentFormat === 'hsl' && hslInputs,
225
- currentFormat === 'rgb' && rgbInputs))));
303
+ currentFormat === 'rgb' && rgbInputs,
304
+ currentFormat === 'hsl' && hslInputs))));
226
305
  });
227
306
  export default ColorInputPanel;
@@ -30,6 +30,11 @@ export declare type ColorPickerProps = {
30
30
  * @default false
31
31
  */
32
32
  setFocus?: boolean;
33
+ /**
34
+ * If true, ColorBuilder will show the alpha slider and ColorInputPanel will show an alpha input.
35
+ * @default false
36
+ */
37
+ showAlpha?: boolean;
33
38
  } & Omit<CommonProps, 'title'>;
34
39
  /**
35
40
  * ColorPicker to display color builder options, color inputs, and a palette of ColorSwatches.
@@ -49,7 +49,7 @@ export var getColorValue = function (color) {
49
49
  * </ColorPicker>
50
50
  */
51
51
  export var ColorPicker = function (props) {
52
- var children = props.children, className = props.className, selectedColor = props.selectedColor, onChange = props.onChange, onChangeComplete = props.onChangeComplete, _a = props.setFocus, setFocus = _a === void 0 ? false : _a, rest = __rest(props, ["children", "className", "selectedColor", "onChange", "onChangeComplete", "setFocus"]);
52
+ var children = props.children, className = props.className, selectedColor = props.selectedColor, onChange = props.onChange, onChangeComplete = props.onChangeComplete, _a = props.setFocus, setFocus = _a === void 0 ? false : _a, _b = props.showAlpha, showAlpha = _b === void 0 ? false : _b, rest = __rest(props, ["children", "className", "selectedColor", "onChange", "onChangeComplete", "setFocus", "showAlpha"]);
53
53
  useTheme();
54
54
  var ref = React.useRef(null);
55
55
  // set focus on the first tabbable element
@@ -63,13 +63,13 @@ export var ColorPicker = function (props) {
63
63
  selectedColor,
64
64
  ]);
65
65
  var activeColorTbgr = React.useRef(inColor.toTbgr());
66
- var _b = React.useState(inColor), activeColor = _b[0], setActiveColor = _b[1]; // Color of colorDot or active ColorSwatch
66
+ var _c = React.useState(inColor), activeColor = _c[0], setActiveColor = _c[1]; // Color of colorDot or active ColorSwatch
67
67
  React.useEffect(function () {
68
68
  setActiveColor(inColor);
69
69
  }, [inColor]);
70
- var _c = React.useState(function () {
70
+ var _d = React.useState(function () {
71
71
  return activeColor.toHsvColor();
72
- }), hsvColor = _c[0], setHsvColor = _c[1];
72
+ }), hsvColor = _d[0], setHsvColor = _d[1];
73
73
  // The following code is used to preserve the Hue after initial mount. If the current HSV value produces the same rgb value
74
74
  // as the selectedColor prop then leave the HSV color unchanged. This prevents the jumping of HUE as the s/v values are changed
75
75
  // by user moving the pointer.
@@ -79,10 +79,10 @@ export var ColorPicker = function (props) {
79
79
  setHsvColor(inColor.toHsvColor());
80
80
  }
81
81
  }, [inColor]);
82
- var applyHsvColorChange = React.useCallback(function (newColor, selectionChanged) {
82
+ var applyHsvColorChange = React.useCallback(function (newColor, selectionChanged, newColorValue) {
83
83
  // save the HSV values
84
84
  setHsvColor(newColor);
85
- var newActiveColor = ColorValue.create(newColor);
85
+ var newActiveColor = newColorValue !== null && newColorValue !== void 0 ? newColorValue : ColorValue.create(newColor);
86
86
  // Only update selected color when dragging is done
87
87
  if (selectionChanged) {
88
88
  onChangeComplete === null || onChangeComplete === void 0 ? void 0 : onChangeComplete(newActiveColor);
@@ -101,6 +101,7 @@ export var ColorPicker = function (props) {
101
101
  hsvColor: hsvColor,
102
102
  applyHsvColorChange: applyHsvColorChange,
103
103
  onChangeComplete: onChangeComplete,
104
+ showAlpha: showAlpha,
104
105
  } }, children)));
105
106
  };
106
107
  export default ColorPicker;
@@ -5,12 +5,14 @@ export declare const ColorPickerContext: React.Context<{
5
5
  setActiveColor: (color: ColorValue | ((prevColor: ColorValue) => ColorValue)) => void;
6
6
  hsvColor: HsvColor;
7
7
  onChangeComplete?: ((color: ColorValue) => void) | undefined;
8
- applyHsvColorChange: (newColor: HsvColor, selectionChanged: boolean) => void;
8
+ applyHsvColorChange: (newColor: HsvColor, selectionChanged: boolean, newColorValue?: ColorValue | undefined) => void;
9
+ showAlpha: boolean;
9
10
  } | undefined>;
10
11
  export declare const useColorPickerContext: () => {
11
12
  activeColor: ColorValue;
12
13
  setActiveColor: (color: ColorValue | ((prevColor: ColorValue) => ColorValue)) => void;
13
14
  hsvColor: HsvColor;
14
15
  onChangeComplete?: ((color: ColorValue) => void) | undefined;
15
- applyHsvColorChange: (newColor: HsvColor, selectionChanged: boolean) => void;
16
+ applyHsvColorChange: (newColor: HsvColor, selectionChanged: boolean, newColorValue?: ColorValue | undefined) => void;
17
+ showAlpha: boolean;
16
18
  };
@@ -17,5 +17,5 @@ export declare type ColorSwatchProps = {
17
17
  * <ColorSwatch color='#23450b' onClick={onClick}/>
18
18
  * <ColorSwatch color={{ r: 255, g: 255, b: 0 }} onClick={onClick}/>
19
19
  */
20
- export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "role" | "children" | "className" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "isActive" | "key"> & React.RefAttributes<HTMLDivElement>>;
20
+ export declare const ColorSwatch: React.ForwardRefExoticComponent<Pick<ColorSwatchProps, "dir" | "slot" | "style" | "title" | "id" | "role" | "children" | "className" | "accessKey" | "draggable" | "hidden" | "lang" | "translate" | "prefix" | "contentEditable" | "inputMode" | "tabIndex" | "onFocus" | "color" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "contextMenu" | "placeholder" | "spellCheck" | "radioGroup" | "about" | "datatype" | "inlist" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "isActive" | "key"> & React.RefAttributes<HTMLDivElement>>;
21
21
  export default ColorSwatch;
@@ -36,12 +36,18 @@ import { getColorValue } from './ColorPicker';
36
36
  * <ColorSwatch color={{ r: 255, g: 255, b: 0 }} onClick={onClick}/>
37
37
  */
38
38
  export var ColorSwatch = React.forwardRef(function (props, ref) {
39
- var _a, _b, _c;
40
39
  var color = props.color, style = props.style, onClick = props.onClick, isActive = props.isActive, className = props.className, rest = __rest(props, ["color", "style", "onClick", "isActive", "className"]);
41
40
  useTheme();
42
- var c = typeof color === 'string' ? color : getColorValue(color).toHexString();
43
- var _style = color && ((_c = (_b = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.CSS) === null || _b === void 0 ? void 0 : _b.supports) === null || _c === void 0 ? void 0 : _c.call(_b, "--swatch-color: " + c))
44
- ? __assign({ '--swatch-color': c }, style) : __assign({ backgroundColor: c }, style);
41
+ var colorString = React.useMemo(function () {
42
+ return typeof color === 'string'
43
+ ? color
44
+ : getColorValue(color).toHslString(true);
45
+ }, [color]);
46
+ var _style = React.useMemo(function () {
47
+ var _a, _b, _c;
48
+ return ((_c = (_b = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.CSS) === null || _b === void 0 ? void 0 : _b.supports) === null || _c === void 0 ? void 0 : _c.call(_b, "--swatch-color: " + colorString))
49
+ ? __assign({ '--swatch-color': colorString }, style) : __assign({ backgroundColor: colorString }, style);
50
+ }, [colorString, style]);
45
51
  return (React.createElement("div", __assign({ className: cx('iui-color-swatch', { 'iui-active': isActive }, className), style: _style, onClick: onClick, tabIndex: isActive ? 0 : -1, "aria-selected": isActive, ref: ref }, rest)));
46
52
  });
47
53
  export default ColorSwatch;
@@ -18,7 +18,7 @@ export declare type DatePickerProps = {
18
18
  /**
19
19
  * Callback when date is changed.
20
20
  */
21
- onChange?: (date?: Date) => void;
21
+ onChange?: (date: Date) => void;
22
22
  /**
23
23
  * Pass localized week days (start from sunday) and months.
24
24
  * Use helper function `generateLocalizedStrings` to generate strings using `Intl.DateTimeFormat`.
@@ -35,7 +35,10 @@ export declare type InformationPanelProps = {
35
35
  * <Text variant='subheading'>InfoPanel heading</Text>
36
36
  * </InformationPanelHeader>
37
37
  * <InformationPanelBody>
38
- * <span>Info panel content</span>
38
+ * <Text>Metadata</Text>
39
+ * <InformationPanelContent ... />
40
+ * <Text>Attributes</Text>
41
+ * <InformationPanelContent ... />
39
42
  * </InformationPanelBody>
40
43
  * </InformationPanel>
41
44
  * </InformationPanelWrapper>
@@ -41,7 +41,10 @@ import '@itwin/itwinui-css/css/information-panel.css';
41
41
  * <Text variant='subheading'>InfoPanel heading</Text>
42
42
  * </InformationPanelHeader>
43
43
  * <InformationPanelBody>
44
- * <span>Info panel content</span>
44
+ * <Text>Metadata</Text>
45
+ * <InformationPanelContent ... />
46
+ * <Text>Attributes</Text>
47
+ * <InformationPanelContent ... />
45
48
  * </InformationPanelBody>
46
49
  * </InformationPanel>
47
50
  * </InformationPanelWrapper>