orcs-design-system 3.3.31 → 3.3.33

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.
@@ -285,6 +285,7 @@ const HeaderAvatarWrapper = styled("div").withConfig({
285
285
  justifyContent: "center",
286
286
  width: $size,
287
287
  height: $size,
288
+ transition: "width 200ms ease-in-out, height 200ms ease-in-out",
288
289
  boxShadow: "0px 3px 6px rgba(0,0,0,0.15)",
289
290
  borderRadius: $shape === "circle" || !$shape ? "50%" : $shape === "square" ? "6px" : "0",
290
291
  background: "transparent"
@@ -302,6 +303,7 @@ const HeaderAvatarBorder = styled("div").withConfig({
302
303
  return {
303
304
  width: $size,
304
305
  height: $size,
306
+ transition: "width 200ms ease-in-out, height 200ms ease-in-out, border-width 200ms ease-in-out",
305
307
  border: $sizing === "large" ? "6px solid #fff" : "4px solid #fff",
306
308
  borderRadius: $shape === "circle" || !$shape ? "50%" : $shape === "square" ? "6px" : "0",
307
309
  overflow: "hidden",
@@ -322,6 +324,7 @@ const HeaderAvatarImage = styled("img").withConfig({
322
324
  return {
323
325
  width: $size,
324
326
  height: $size,
327
+ transition: "width 200ms ease-in-out, height 200ms ease-in-out",
325
328
  objectFit: "cover",
326
329
  objectPosition: "center",
327
330
  objectRepeat: "no-repeat",
@@ -340,6 +343,7 @@ const HeaderAvatarShape = styled("div").withConfig({
340
343
  return {
341
344
  width: $size,
342
345
  height: $size,
346
+ transition: "width 200ms ease-in-out, height 200ms ease-in-out",
343
347
  display: "flex",
344
348
  alignItems: "center",
345
349
  justifyContent: "center",
@@ -0,0 +1,70 @@
1
+ import React, { useState } from "react";
2
+ import Box from "../Box";
3
+ import Button from "../Button";
4
+ import Popover from "../Popover";
5
+ import Icon from "../Icon";
6
+ import Flex from "../Flex";
7
+ import ColorPicker from "./index";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ export default {
10
+ title: "Components/ColorPicker",
11
+ component: ColorPicker,
12
+ parameters: {
13
+ docs: {
14
+ description: {
15
+ component: "A reusable color picker component that can be triggered by any element passed as children."
16
+ }
17
+ }
18
+ }
19
+ };
20
+ export const Default = () => {
21
+ const [color, setColor] = useState("linear-gradient(90deg,rgb(56, 136, 255) 0%,rgb(148, 81, 255) 100%)");
22
+ return /*#__PURE__*/_jsx(Box, {
23
+ p: "l",
24
+ position: "relative",
25
+ children: /*#__PURE__*/_jsx(Flex, {
26
+ width: "100%",
27
+ height: "150px",
28
+ justifyContent: "flex-end",
29
+ alignItems: "flex-start",
30
+ background: color,
31
+ borderRadius: "2",
32
+ p: "r",
33
+ children: /*#__PURE__*/_jsx(ColorPicker, {
34
+ value: color,
35
+ onChange: setColor,
36
+ position: "bottom-start",
37
+ children: _ref => {
38
+ let {
39
+ toggleColorPicker
40
+ } = _ref;
41
+ return /*#__PURE__*/_jsx(Popover, {
42
+ direction: "left",
43
+ height: "35px",
44
+ width: "fit-content",
45
+ text: "Change background colour",
46
+ ml: "auto",
47
+ children: /*#__PURE__*/_jsx(Button, {
48
+ height: "35px",
49
+ width: "35px",
50
+ borderRadius: "35px",
51
+ borderColor: "white30",
52
+ bg: "white30",
53
+ ariaLabel: "Change background colour",
54
+ onClick: toggleColorPicker,
55
+ children: /*#__PURE__*/_jsx(Icon, {
56
+ icon: ["fas", "palette"],
57
+ color: "white"
58
+ })
59
+ })
60
+ });
61
+ }
62
+ })
63
+ })
64
+ });
65
+ };
66
+ Default.__docgenInfo = {
67
+ "description": "",
68
+ "methods": [],
69
+ "displayName": "Default"
70
+ };
@@ -0,0 +1,471 @@
1
+ import React, { useState, useEffect, useRef } from "react";
2
+ import PropTypes from "prop-types";
3
+ import Box from "../Box";
4
+ import ColorPickerLib from "react-best-gradient-color-picker";
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ const ColorPicker = _ref => {
7
+ let {
8
+ value,
9
+ onChange,
10
+ children,
11
+ position = "bottom-start",
12
+ zIndex = 20,
13
+ bg = "#202020",
14
+ p = "s",
15
+ borderRadius = "2",
16
+ // Set defaults for commonly used library props
17
+ width = 250,
18
+ height = 250,
19
+ hidePresets = true,
20
+ hideInputs = false,
21
+ hideControls = false,
22
+ hideOpacity = true,
23
+ hideEyeDrop = true,
24
+ hideAdvancedSliders = true,
25
+ hideColorGuide = true,
26
+ hideInputType = true,
27
+ hideColorTypeBtns = false,
28
+ hideGradientType = false,
29
+ hideGradientAngle = false,
30
+ hideGradientStop = false,
31
+ hideGradientControls = false,
32
+ // Spread all other props to the underlying library
33
+ ...colorPickerProps
34
+ } = _ref;
35
+ const [isOpen, setIsOpen] = useState(false);
36
+ const colorPickerRef = useRef(null);
37
+ const triggerRef = useRef(null);
38
+
39
+ // Handle clicks outside to close
40
+ useEffect(() => {
41
+ function handleClickOutside(event) {
42
+ if (colorPickerRef.current && !colorPickerRef.current.contains(event.target) && triggerRef.current && !triggerRef.current.contains(event.target)) {
43
+ setIsOpen(false);
44
+ }
45
+ }
46
+ if (isOpen) {
47
+ document.addEventListener("mousedown", handleClickOutside);
48
+ return () => {
49
+ document.removeEventListener("mousedown", handleClickOutside);
50
+ };
51
+ }
52
+ return undefined;
53
+ }, [isOpen]);
54
+ const toggleColorPicker = () => setIsOpen(!isOpen);
55
+
56
+ // Calculate position based on position prop
57
+ const getPositionStyles = () => {
58
+ const baseStyles = {
59
+ position: "absolute",
60
+ zIndex,
61
+ bg,
62
+ p,
63
+ borderRadius
64
+ };
65
+ switch (position) {
66
+ case "top-start":
67
+ return {
68
+ ...baseStyles,
69
+ bottom: "100%",
70
+ right: "0",
71
+ mb: "s"
72
+ };
73
+ case "top-end":
74
+ return {
75
+ ...baseStyles,
76
+ bottom: "100%",
77
+ left: "0",
78
+ mb: "s"
79
+ };
80
+ case "bottom-start":
81
+ return {
82
+ ...baseStyles,
83
+ top: "100%",
84
+ right: "0",
85
+ mt: "s"
86
+ };
87
+ case "bottom-end":
88
+ return {
89
+ ...baseStyles,
90
+ top: "100%",
91
+ left: "0",
92
+ mt: "s"
93
+ };
94
+ case "left-start":
95
+ return {
96
+ ...baseStyles,
97
+ right: "100%",
98
+ top: "0",
99
+ mr: "s"
100
+ };
101
+ case "left-end":
102
+ return {
103
+ ...baseStyles,
104
+ right: "100%",
105
+ bottom: "0",
106
+ mr: "s"
107
+ };
108
+ case "right-start":
109
+ return {
110
+ ...baseStyles,
111
+ left: "100%",
112
+ top: "0",
113
+ ml: "s"
114
+ };
115
+ case "right-end":
116
+ return {
117
+ ...baseStyles,
118
+ left: "100%",
119
+ bottom: "0",
120
+ ml: "s"
121
+ };
122
+ default:
123
+ return {
124
+ ...baseStyles,
125
+ top: "100%",
126
+ right: "0",
127
+ mt: "s"
128
+ };
129
+ }
130
+ };
131
+ return /*#__PURE__*/_jsxs(Box, {
132
+ position: "relative",
133
+ children: [/*#__PURE__*/_jsx(Box, {
134
+ ref: triggerRef,
135
+ children: typeof children === "function" ? children({
136
+ isOpen,
137
+ toggleColorPicker
138
+ }) : children
139
+ }), isOpen && /*#__PURE__*/_jsx(Box, {
140
+ ref: colorPickerRef,
141
+ ...getPositionStyles(),
142
+ children: /*#__PURE__*/_jsx(ColorPickerLib, {
143
+ value: value,
144
+ onChange: onChange,
145
+ width: width,
146
+ height: height,
147
+ hidePresets: hidePresets,
148
+ hideInputs: hideInputs,
149
+ hideControls: hideControls,
150
+ hideOpacity: hideOpacity,
151
+ hideEyeDrop: hideEyeDrop,
152
+ hideAdvancedSliders: hideAdvancedSliders,
153
+ hideColorGuide: hideColorGuide,
154
+ hideInputType: hideInputType,
155
+ hideColorTypeBtns: hideColorTypeBtns,
156
+ hideGradientType: hideGradientType,
157
+ hideGradientAngle: hideGradientAngle,
158
+ hideGradientStop: hideGradientStop,
159
+ hideGradientControls: hideGradientControls,
160
+ ...colorPickerProps
161
+ })
162
+ })]
163
+ });
164
+ };
165
+ ColorPicker.propTypes = {
166
+ value: PropTypes.string.isRequired,
167
+ onChange: PropTypes.func.isRequired,
168
+ children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
169
+ position: PropTypes.oneOf(["top-start", "top-end", "bottom-start", "bottom-end", "left-start", "left-end", "right-start", "right-end"]),
170
+ zIndex: PropTypes.number,
171
+ bg: PropTypes.string,
172
+ p: PropTypes.string,
173
+ borderRadius: PropTypes.string,
174
+ // Default props for the underlying library
175
+ width: PropTypes.number,
176
+ height: PropTypes.number,
177
+ hidePresets: PropTypes.bool,
178
+ hideInputs: PropTypes.bool,
179
+ hideControls: PropTypes.bool,
180
+ hideOpacity: PropTypes.bool,
181
+ hideEyeDrop: PropTypes.bool,
182
+ hideAdvancedSliders: PropTypes.bool,
183
+ hideColorGuide: PropTypes.bool,
184
+ hideInputType: PropTypes.bool,
185
+ hideColorTypeBtns: PropTypes.bool,
186
+ hideGradientType: PropTypes.bool,
187
+ hideGradientAngle: PropTypes.bool,
188
+ hideGradientStop: PropTypes.bool,
189
+ hideGradientControls: PropTypes.bool
190
+ // Note: We don't need to define PropTypes for the spread props
191
+ // as they'll be passed directly to the underlying library
192
+ };
193
+ ColorPicker.__docgenInfo = {
194
+ "description": "",
195
+ "methods": [],
196
+ "displayName": "ColorPicker",
197
+ "props": {
198
+ "position": {
199
+ "defaultValue": {
200
+ "value": "\"bottom-start\"",
201
+ "computed": false
202
+ },
203
+ "description": "",
204
+ "type": {
205
+ "name": "enum",
206
+ "value": [{
207
+ "value": "\"top-start\"",
208
+ "computed": false
209
+ }, {
210
+ "value": "\"top-end\"",
211
+ "computed": false
212
+ }, {
213
+ "value": "\"bottom-start\"",
214
+ "computed": false
215
+ }, {
216
+ "value": "\"bottom-end\"",
217
+ "computed": false
218
+ }, {
219
+ "value": "\"left-start\"",
220
+ "computed": false
221
+ }, {
222
+ "value": "\"left-end\"",
223
+ "computed": false
224
+ }, {
225
+ "value": "\"right-start\"",
226
+ "computed": false
227
+ }, {
228
+ "value": "\"right-end\"",
229
+ "computed": false
230
+ }]
231
+ },
232
+ "required": false
233
+ },
234
+ "zIndex": {
235
+ "defaultValue": {
236
+ "value": "20",
237
+ "computed": false
238
+ },
239
+ "description": "",
240
+ "type": {
241
+ "name": "number"
242
+ },
243
+ "required": false
244
+ },
245
+ "bg": {
246
+ "defaultValue": {
247
+ "value": "\"#202020\"",
248
+ "computed": false
249
+ },
250
+ "description": "",
251
+ "type": {
252
+ "name": "string"
253
+ },
254
+ "required": false
255
+ },
256
+ "p": {
257
+ "defaultValue": {
258
+ "value": "\"s\"",
259
+ "computed": false
260
+ },
261
+ "description": "",
262
+ "type": {
263
+ "name": "string"
264
+ },
265
+ "required": false
266
+ },
267
+ "borderRadius": {
268
+ "defaultValue": {
269
+ "value": "\"2\"",
270
+ "computed": false
271
+ },
272
+ "description": "",
273
+ "type": {
274
+ "name": "string"
275
+ },
276
+ "required": false
277
+ },
278
+ "width": {
279
+ "defaultValue": {
280
+ "value": "250",
281
+ "computed": false
282
+ },
283
+ "description": "",
284
+ "type": {
285
+ "name": "number"
286
+ },
287
+ "required": false
288
+ },
289
+ "height": {
290
+ "defaultValue": {
291
+ "value": "250",
292
+ "computed": false
293
+ },
294
+ "description": "",
295
+ "type": {
296
+ "name": "number"
297
+ },
298
+ "required": false
299
+ },
300
+ "hidePresets": {
301
+ "defaultValue": {
302
+ "value": "true",
303
+ "computed": false
304
+ },
305
+ "description": "",
306
+ "type": {
307
+ "name": "bool"
308
+ },
309
+ "required": false
310
+ },
311
+ "hideInputs": {
312
+ "defaultValue": {
313
+ "value": "false",
314
+ "computed": false
315
+ },
316
+ "description": "",
317
+ "type": {
318
+ "name": "bool"
319
+ },
320
+ "required": false
321
+ },
322
+ "hideControls": {
323
+ "defaultValue": {
324
+ "value": "false",
325
+ "computed": false
326
+ },
327
+ "description": "",
328
+ "type": {
329
+ "name": "bool"
330
+ },
331
+ "required": false
332
+ },
333
+ "hideOpacity": {
334
+ "defaultValue": {
335
+ "value": "true",
336
+ "computed": false
337
+ },
338
+ "description": "",
339
+ "type": {
340
+ "name": "bool"
341
+ },
342
+ "required": false
343
+ },
344
+ "hideEyeDrop": {
345
+ "defaultValue": {
346
+ "value": "true",
347
+ "computed": false
348
+ },
349
+ "description": "",
350
+ "type": {
351
+ "name": "bool"
352
+ },
353
+ "required": false
354
+ },
355
+ "hideAdvancedSliders": {
356
+ "defaultValue": {
357
+ "value": "true",
358
+ "computed": false
359
+ },
360
+ "description": "",
361
+ "type": {
362
+ "name": "bool"
363
+ },
364
+ "required": false
365
+ },
366
+ "hideColorGuide": {
367
+ "defaultValue": {
368
+ "value": "true",
369
+ "computed": false
370
+ },
371
+ "description": "",
372
+ "type": {
373
+ "name": "bool"
374
+ },
375
+ "required": false
376
+ },
377
+ "hideInputType": {
378
+ "defaultValue": {
379
+ "value": "true",
380
+ "computed": false
381
+ },
382
+ "description": "",
383
+ "type": {
384
+ "name": "bool"
385
+ },
386
+ "required": false
387
+ },
388
+ "hideColorTypeBtns": {
389
+ "defaultValue": {
390
+ "value": "false",
391
+ "computed": false
392
+ },
393
+ "description": "",
394
+ "type": {
395
+ "name": "bool"
396
+ },
397
+ "required": false
398
+ },
399
+ "hideGradientType": {
400
+ "defaultValue": {
401
+ "value": "false",
402
+ "computed": false
403
+ },
404
+ "description": "",
405
+ "type": {
406
+ "name": "bool"
407
+ },
408
+ "required": false
409
+ },
410
+ "hideGradientAngle": {
411
+ "defaultValue": {
412
+ "value": "false",
413
+ "computed": false
414
+ },
415
+ "description": "",
416
+ "type": {
417
+ "name": "bool"
418
+ },
419
+ "required": false
420
+ },
421
+ "hideGradientStop": {
422
+ "defaultValue": {
423
+ "value": "false",
424
+ "computed": false
425
+ },
426
+ "description": "",
427
+ "type": {
428
+ "name": "bool"
429
+ },
430
+ "required": false
431
+ },
432
+ "hideGradientControls": {
433
+ "defaultValue": {
434
+ "value": "false",
435
+ "computed": false
436
+ },
437
+ "description": "",
438
+ "type": {
439
+ "name": "bool"
440
+ },
441
+ "required": false
442
+ },
443
+ "value": {
444
+ "description": "",
445
+ "type": {
446
+ "name": "string"
447
+ },
448
+ "required": true
449
+ },
450
+ "onChange": {
451
+ "description": "",
452
+ "type": {
453
+ "name": "func"
454
+ },
455
+ "required": true
456
+ },
457
+ "children": {
458
+ "description": "",
459
+ "type": {
460
+ "name": "union",
461
+ "value": [{
462
+ "name": "node"
463
+ }, {
464
+ "name": "func"
465
+ }]
466
+ },
467
+ "required": true
468
+ }
469
+ }
470
+ };
471
+ export default ColorPicker;
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect, useMemo, useState } from "react";
1
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
2
  import ReactDOM from "react-dom";
3
3
  import PropTypes from "prop-types";
4
4
  import styled, { keyframes, ThemeProvider } from "styled-components";
@@ -72,6 +72,8 @@ const Modal = _ref => {
72
72
  ...restProps
73
73
  } = _ref;
74
74
  const [lastActiveElement, setLastActiveElement] = useState(null);
75
+ const [isSelectingText, setIsSelectingText] = useState(false);
76
+ const isSelectingTextRef = useRef(false);
75
77
  const ariaLabel = useMemo(() => {
76
78
  if (restProps.ariaLabel) {
77
79
  return restProps.ariaLabel;
@@ -101,28 +103,51 @@ const Modal = _ref => {
101
103
  focusLastActiveElement();
102
104
  }
103
105
  }, [visible, focusLastActiveElement, lastActiveElement]);
106
+ useEffect(() => {
107
+ isSelectingTextRef.current = isSelectingText;
108
+ }, [isSelectingText]);
104
109
  useEffect(() => {
105
110
  if (!visible) return;
106
111
 
107
112
  /* Adding onClick handler on the Overlay does not work.
108
113
  * So we add a global listener and check if the element clicked is the
109
- * overlay vida overlayID.
114
+ * overlay via overlayID.
110
115
  */
111
- const handler = e => {
116
+ const handleMouseDown = e => {
117
+ // Check if the user is starting to select text
118
+ if (e.target.closest(`#${modalID}`)) {
119
+ setIsSelectingText(true);
120
+ }
121
+ };
122
+ const handleMouseUp = () => {
123
+ // Reset text selection state after a short delay
124
+ setTimeout(() => {
125
+ setIsSelectingText(false);
126
+ }, 100);
127
+ };
128
+ const handleClick = e => {
129
+ if (e.target.id === overlayID && !isSelectingTextRef.current) {
130
+ onClose();
131
+ }
132
+ };
133
+ const handleTouchStart = e => {
112
134
  if (e.target.id === overlayID) {
113
135
  onClose();
114
136
  }
115
137
  };
116
- const eventTypes = ["touchstart", "click"];
117
- eventTypes.map(type => {
118
- window.addEventListener(type, handler, true);
119
- });
138
+
139
+ // Add event listeners
140
+ window.addEventListener("mousedown", handleMouseDown, true);
141
+ window.addEventListener("mouseup", handleMouseUp, true);
142
+ window.addEventListener("click", handleClick, true);
143
+ window.addEventListener("touchstart", handleTouchStart, true);
120
144
  return () => {
121
- eventTypes.map(type => {
122
- window.removeEventListener(type, handler, true);
123
- });
145
+ window.removeEventListener("mousedown", handleMouseDown, true);
146
+ window.removeEventListener("mouseup", handleMouseUp, true);
147
+ window.removeEventListener("click", handleClick, true);
148
+ window.removeEventListener("touchstart", handleTouchStart, true);
124
149
  };
125
- }, [visible, onClose, overlayID]);
150
+ }, [visible, onClose, overlayID, modalID]);
126
151
  if (!visible) return null;
127
152
  const component = /*#__PURE__*/_jsx(Overlay, {
128
153
  alignItems: "center",
@@ -17,6 +17,7 @@ test("all components exported", () => {
17
17
  "Card",
18
18
  "Checkbox",
19
19
  "Code",
20
+ "ColorPicker",
20
21
  "DatePicker",
21
22
  "Divider",
22
23
  "Expandable",
package/es/index.js CHANGED
@@ -15,6 +15,7 @@ export { default as Breadcrumbs } from "./components/Breadcrumbs";
15
15
  export { default as Button, ButtonLink, VARIANT_COLORS } from "./components/Button";
16
16
  export { ButtonGroupContainer, ButtonGroupItem } from "./components/ButtonGroup";
17
17
  export { default as Card } from "./components/Card";
18
+ export { default as ColorPicker } from "./components/ColorPicker";
18
19
  export { default as Checkbox } from "./components/Checkbox";
19
20
  export { default as DatePicker } from "./components/DatePicker";
20
21
  export { default as Divider } from "./components/Divider";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orcs-design-system",
3
- "version": "3.3.31",
3
+ "version": "3.3.33",
4
4
  "engines": {
5
5
  "node": "20.12.2"
6
6
  },
@@ -60,6 +60,7 @@
60
60
  "prop-types": "^15.6.2",
61
61
  "react-app-polyfill": "^2.0.0",
62
62
  "react-arborist": "^3.4.0",
63
+ "react-best-gradient-color-picker": "^3.0.14",
63
64
  "react-cool-onclickoutside": "^1.5.9",
64
65
  "react-dates": "^21.8.0",
65
66
  "react-intersection-observer": "^9.4.3",