orcs-design-system 3.3.34 → 3.3.35

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.
@@ -484,6 +484,7 @@ const Avatar = _ref7 => {
484
484
  width: "fit-content",
485
485
  $shape: shape,
486
486
  text: shape === "circle" ? "Upload profile picture" : "Change image",
487
+ headerAvatarSizing: sizing,
487
488
  children: /*#__PURE__*/_jsxs(HeaderAvatarAction, {
488
489
  onClick: onClick,
489
490
  "aria-label": "Edit avatar",
@@ -21,6 +21,7 @@ export default {
21
21
  };
22
22
  export const defaultPopover = () => /*#__PURE__*/_jsx(Popover, {
23
23
  text: "Description that explains child element",
24
+ width: "fit-content",
24
25
  children: /*#__PURE__*/_jsx(Button, {
25
26
  onClick: () => alert("Maintains original click"),
26
27
  children: "Hover Me!"
@@ -38,6 +39,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
38
39
  children: [/*#__PURE__*/_jsx(Popover, {
39
40
  direction: "topLeft",
40
41
  text: "Description that explains child element",
42
+ width: "fit-content",
41
43
  children: /*#__PURE__*/_jsx(Button, {
42
44
  width: "125px",
43
45
  children: "Top left"
@@ -45,6 +47,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
45
47
  }), /*#__PURE__*/_jsx(Popover, {
46
48
  direction: "top",
47
49
  text: "Description that explains child element",
50
+ width: "fit-content",
48
51
  children: /*#__PURE__*/_jsx(Button, {
49
52
  width: "125px",
50
53
  children: "Top"
@@ -52,6 +55,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
52
55
  }), /*#__PURE__*/_jsx(Popover, {
53
56
  direction: "topRight",
54
57
  text: "Description that explains child element",
58
+ width: "fit-content",
55
59
  children: /*#__PURE__*/_jsx(Button, {
56
60
  width: "125px",
57
61
  children: "Top right"
@@ -59,6 +63,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
59
63
  }), /*#__PURE__*/_jsx(Popover, {
60
64
  direction: "left",
61
65
  text: "Description that explains child element",
66
+ width: "fit-content",
62
67
  children: /*#__PURE__*/_jsx(Button, {
63
68
  width: "125px",
64
69
  children: "Left"
@@ -70,6 +75,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
70
75
  }), /*#__PURE__*/_jsx(Popover, {
71
76
  direction: "right",
72
77
  text: "Description that explains child element",
78
+ width: "fit-content",
73
79
  children: /*#__PURE__*/_jsx(Button, {
74
80
  width: "125px",
75
81
  children: "Right"
@@ -77,6 +83,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
77
83
  }), /*#__PURE__*/_jsx(Popover, {
78
84
  direction: "bottomLeft",
79
85
  text: "Description that explains child element",
86
+ width: "fit-content",
80
87
  children: /*#__PURE__*/_jsx(Button, {
81
88
  width: "125px",
82
89
  children: "Bottom left"
@@ -84,6 +91,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
84
91
  }), /*#__PURE__*/_jsx(Popover, {
85
92
  direction: "bottom",
86
93
  text: "Description that explains child element",
94
+ width: "fit-content",
87
95
  children: /*#__PURE__*/_jsx(Button, {
88
96
  width: "125px",
89
97
  children: "Bottom"
@@ -91,6 +99,7 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
91
99
  }), /*#__PURE__*/_jsx(Popover, {
92
100
  direction: "bottomRight",
93
101
  text: "Description that explains child element",
102
+ width: "fit-content",
94
103
  children: /*#__PURE__*/_jsx(Button, {
95
104
  width: "125px",
96
105
  children: "Bottom right"
@@ -100,8 +109,8 @@ export const direction = () => /*#__PURE__*/_jsx(Box, {
100
109
  });
101
110
  direction.storyName = "Direction";
102
111
  export const specifiedWidth = () => /*#__PURE__*/_jsx(Popover, {
103
- text: "Description that explains child element",
104
- width: "240px",
112
+ text: "Long description that you might not want to show on one line, and instead would like it to wrap",
113
+ width: "200px",
105
114
  children: /*#__PURE__*/_jsx(Button, {
106
115
  children: "Hover Me"
107
116
  })
@@ -109,6 +118,7 @@ export const specifiedWidth = () => /*#__PURE__*/_jsx(Popover, {
109
118
  export const textAlignment = () => /*#__PURE__*/_jsx(Popover, {
110
119
  textAlign: "center",
111
120
  text: "Centered description that explains child element",
121
+ width: "fit-content",
112
122
  children: /*#__PURE__*/_jsx(Button, {
113
123
  children: "Hover Me"
114
124
  })
@@ -120,23 +130,27 @@ export const DisplayInlineBlock = () => /*#__PURE__*/_jsx(Flex, {
120
130
  children: [/*#__PURE__*/_jsx(Popover, {
121
131
  text: "Description that explains child element",
122
132
  inlineBlock: true,
133
+ width: "fit-content",
123
134
  children: /*#__PURE__*/_jsx(Button, {
124
135
  children: "Inline Block Set"
125
136
  })
126
137
  }), /*#__PURE__*/_jsx(Popover, {
127
138
  text: "Description that explains child element",
128
139
  inlineBlock: true,
140
+ width: "fit-content",
129
141
  children: /*#__PURE__*/_jsx(Button, {
130
142
  children: "Inline Block Set"
131
143
  })
132
144
  }), /*#__PURE__*/_jsx(Popover, {
133
145
  text: "Because it is display: block, the triggering container is wider than the button",
146
+ width: "fit-content",
134
147
  children: /*#__PURE__*/_jsx(Button, {
135
148
  children: "Not Inline"
136
149
  })
137
150
  }), /*#__PURE__*/_jsx(Popover, {
138
151
  direction: "top",
139
152
  text: "Description that explains child element",
153
+ width: "fit-content",
140
154
  children: /*#__PURE__*/_jsx(Button, {
141
155
  children: "Not Inline"
142
156
  })
@@ -146,7 +160,8 @@ export const DisplayInlineBlock = () => /*#__PURE__*/_jsx(Flex, {
146
160
  export const tooltipExample = () => /*#__PURE__*/_jsx(Popover, {
147
161
  text: "This tooltip helps explain stuff",
148
162
  direction: "top",
149
- variant: "tooltip"
163
+ variant: "tooltip",
164
+ width: "fit-content"
150
165
  });
151
166
  tooltipExample.storyName = "Tooltip Example";
152
167
  export const tooltipWithLinkExample = () => /*#__PURE__*/_jsx(Popover, {
@@ -160,7 +175,8 @@ export const tooltipWithLinkExample = () => /*#__PURE__*/_jsx(Popover, {
160
175
  arialLabel: "Link to TeamForm",
161
176
  direction: "right",
162
177
  variant: "tooltip",
163
- enableSelectAll: false
178
+ enableSelectAll: false,
179
+ width: "fit-content"
164
180
  });
165
181
  tooltipWithLinkExample.storyName = "Tooltip with link Example";
166
182
  export const iconExample = () => /*#__PURE__*/_jsx(Popover, {
@@ -179,12 +195,90 @@ export const keepInViewExample = () => /*#__PURE__*/_jsx(Flex, {
179
195
  width: "100%",
180
196
  children: /*#__PURE__*/_jsx(Popover, {
181
197
  text: "Description that explains child element",
198
+ width: "fit-content",
182
199
  children: /*#__PURE__*/_jsx(Button, {
183
200
  children: "Hover Me!"
184
201
  })
185
202
  })
186
203
  });
187
204
  keepInViewExample.storyName = "Keep In View Example";
205
+ export const customOffset = () => /*#__PURE__*/_jsx("div", {
206
+ children: /*#__PURE__*/_jsxs(Spacer, {
207
+ mb: "r",
208
+ children: [/*#__PURE__*/_jsx(Popover, {
209
+ text: "Default offset (10px mainAxis)",
210
+ direction: "right",
211
+ width: "fit-content",
212
+ inlineBlock: true,
213
+ children: /*#__PURE__*/_jsx(Button, {
214
+ height: "130px",
215
+ children: "Default Offset"
216
+ })
217
+ }), /*#__PURE__*/_jsx(Popover, {
218
+ text: "Custom offset: 30px mainAxis (moved further away)",
219
+ direction: "right",
220
+ offset: {
221
+ mainAxis: 30
222
+ },
223
+ width: "fit-content",
224
+ inlineBlock: true,
225
+ children: /*#__PURE__*/_jsx(Button, {
226
+ height: "130px",
227
+ children: "30px Main Axis (Right)"
228
+ })
229
+ }), /*#__PURE__*/_jsx(Popover, {
230
+ text: "Custom offset: -10px mainAxis (moved closer)",
231
+ direction: "right",
232
+ offset: {
233
+ mainAxis: -10
234
+ },
235
+ width: "fit-content",
236
+ inlineBlock: true,
237
+ children: /*#__PURE__*/_jsx(Button, {
238
+ height: "130px",
239
+ children: "-10px Main Axis (Left)"
240
+ })
241
+ }), /*#__PURE__*/_jsx(Popover, {
242
+ text: "Custom offset: 20px alignmentAxis (moved down)",
243
+ direction: "right",
244
+ offset: {
245
+ alignmentAxis: 20
246
+ },
247
+ width: "fit-content",
248
+ inlineBlock: true,
249
+ children: /*#__PURE__*/_jsx(Button, {
250
+ height: "130px",
251
+ children: "20px Alignment Axis (Down)"
252
+ })
253
+ }), /*#__PURE__*/_jsx(Popover, {
254
+ text: "Custom offset: -20px alignmentAxis (moved up)",
255
+ direction: "right",
256
+ offset: {
257
+ alignmentAxis: -20
258
+ },
259
+ width: "fit-content",
260
+ inlineBlock: true,
261
+ children: /*#__PURE__*/_jsx(Button, {
262
+ height: "130px",
263
+ children: "-20px Alignment Axis (Up)"
264
+ })
265
+ }), /*#__PURE__*/_jsx(Popover, {
266
+ text: "Custom offset: both axes combined",
267
+ direction: "right",
268
+ offset: {
269
+ mainAxis: 25,
270
+ alignmentAxis: -25
271
+ },
272
+ width: "fit-content",
273
+ inlineBlock: true,
274
+ children: /*#__PURE__*/_jsx(Button, {
275
+ height: "130px",
276
+ children: "Combined Axes (right and up)"
277
+ })
278
+ })]
279
+ })
280
+ });
281
+ customOffset.storyName = "Custom Offset";
188
282
  defaultPopover.__docgenInfo = {
189
283
  "description": "",
190
284
  "methods": [],
@@ -229,4 +323,9 @@ keepInViewExample.__docgenInfo = {
229
323
  "description": "",
230
324
  "methods": [],
231
325
  "displayName": "keepInViewExample"
326
+ };
327
+ customOffset.__docgenInfo = {
328
+ "description": "",
329
+ "methods": [],
330
+ "displayName": "customOffset"
232
331
  };
@@ -84,9 +84,39 @@ export default function Popover(_ref) {
84
84
  ariaLabel,
85
85
  inlineBlock,
86
86
  withFocusControl = true,
87
+ offset: customOffset,
88
+ headerAvatarSizing,
87
89
  ...props
88
90
  } = _ref;
89
91
  const [visible, setVisible] = useState(false);
92
+ const middleware = useMemo(() => [offset(_ref2 => {
93
+ let {
94
+ rects
95
+ } = _ref2;
96
+ const defaultOffset = {
97
+ mainAxis: 10,
98
+ alignmentAxis: -rects.floating.width
99
+ };
100
+ if (customOffset) {
101
+ // For simple placements (right, left, top, bottom), use crossAxis instead of alignmentAxis
102
+ const placement = DIRECTIONS_MAP[direction] || direction || "right";
103
+ const isSimplePlacement = !placement.includes("-");
104
+ if (isSimplePlacement && customOffset.alignmentAxis !== undefined) {
105
+ return {
106
+ ...defaultOffset,
107
+ mainAxis: customOffset.mainAxis !== undefined ? customOffset.mainAxis : defaultOffset.mainAxis,
108
+ crossAxis: customOffset.alignmentAxis
109
+ };
110
+ }
111
+ return {
112
+ ...defaultOffset,
113
+ ...customOffset
114
+ };
115
+ }
116
+ return defaultOffset;
117
+ }), flip({
118
+ fallbackAxisSideDirection: "start"
119
+ }), shift()], [direction, customOffset]);
90
120
  const {
91
121
  refs,
92
122
  floatingStyles,
@@ -96,17 +126,7 @@ export default function Popover(_ref) {
96
126
  onOpenChange: setVisible,
97
127
  placement: DIRECTIONS_MAP[direction] || direction || "right",
98
128
  whileElementsMounted: autoUpdate,
99
- middleware: [offset(_ref2 => {
100
- let {
101
- rects
102
- } = _ref2;
103
- return {
104
- mainAxis: 10,
105
- alignmentAxis: -rects.floating.width
106
- };
107
- }), flip({
108
- fallbackAxisSideDirection: "start"
109
- }), shift()]
129
+ middleware
110
130
  });
111
131
  const hover = useHover(context, {
112
132
  move: false,
@@ -132,10 +152,19 @@ export default function Popover(_ref) {
132
152
  tabIndex: "0"
133
153
  }), [getReferenceProps, refs.setReference]);
134
154
  const directionClass = useMemo(() => context.placement === DIRECTIONS_MAP[direction] ? direction : context.placement, [context.placement, direction]);
135
- const style = useMemo(() => ({
136
- ...floatingStyles,
137
- zIndex: getFloatingUiZIndex(context.refs.reference)
138
- }), [floatingStyles, context.refs.reference]);
155
+ const style = useMemo(() => {
156
+ const baseStyle = {
157
+ ...floatingStyles,
158
+ zIndex: getFloatingUiZIndex(context.refs.reference)
159
+ };
160
+
161
+ // Add CSS-based positioning for Header Avatar sizing changes
162
+ if (headerAvatarSizing) {
163
+ const translateY = headerAvatarSizing === "large" ? -56 : -3;
164
+ baseStyle.transform = `${baseStyle.transform || ""} translateY(${translateY}px)`;
165
+ }
166
+ return baseStyle;
167
+ }, [floatingStyles, context.refs.reference, headerAvatarSizing]);
139
168
  const containsLinks = withFocusControl && refs.floating?.current?.querySelectorAll("a").length;
140
169
  const visiblePopoverClassName = useMemo(() => `Tooltip popover visible ${directionClass}`, [directionClass]);
141
170
  const floatingProps = useMemo(() => getFloatingProps({
@@ -230,7 +259,11 @@ Popover.propTypes = {
230
259
  tabIndex: PropTypes.number,
231
260
  className: PropTypes.string,
232
261
  /** Render tooltip with focus control when there is link inside, defaults to true */
233
- withFocusControl: PropTypes.bool
262
+ withFocusControl: PropTypes.bool,
263
+ /** Custom offset configuration for the popover positioning. Can be an object with mainAxis and/or alignmentAxis properties, or a function that returns an offset object. */
264
+ offset: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
265
+ /** Special prop for Header Avatar to apply CSS-based positioning adjustments when sizing changes dynamically */
266
+ headerAvatarSizing: PropTypes.oneOf(["large", "default", "small"])
234
267
  };
235
268
  Popover.__docgenInfo = {
236
269
  "description": "",
@@ -356,6 +389,35 @@ Popover.__docgenInfo = {
356
389
  "name": "string"
357
390
  },
358
391
  "required": false
392
+ },
393
+ "offset": {
394
+ "description": "Custom offset configuration for the popover positioning. Can be an object with mainAxis and/or alignmentAxis properties, or a function that returns an offset object.",
395
+ "type": {
396
+ "name": "union",
397
+ "value": [{
398
+ "name": "object"
399
+ }, {
400
+ "name": "func"
401
+ }]
402
+ },
403
+ "required": false
404
+ },
405
+ "headerAvatarSizing": {
406
+ "description": "Special prop for Header Avatar to apply CSS-based positioning adjustments when sizing changes dynamically",
407
+ "type": {
408
+ "name": "enum",
409
+ "value": [{
410
+ "value": "\"large\"",
411
+ "computed": false
412
+ }, {
413
+ "value": "\"default\"",
414
+ "computed": false
415
+ }, {
416
+ "value": "\"small\"",
417
+ "computed": false
418
+ }]
419
+ },
420
+ "required": false
359
421
  }
360
422
  }
361
423
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orcs-design-system",
3
- "version": "3.3.34",
3
+ "version": "3.3.35",
4
4
  "engines": {
5
5
  "node": "20.12.2"
6
6
  },