@primer/view-components 0.8.0 → 0.9.0-rc.17ac5d05

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.
@@ -1 +1 @@
1
- anchored-position[popover]{border-width:0;inset:auto;min-width:192px;overflow:visible;padding:0;position:absolute}.Overlay{display:flex}anchored-position[popover]:not(.\:popover-open){display:none}@supports selector(:popover-open){anchored-position[popover]:not(.\:popover-open){display:revert}}@supports selector(:open){anchored-position[popover]:not(.\:popover-open){display:revert}}
1
+ anchored-position[popover]{border-width:0;inset:auto;min-width:192px;overflow:visible;padding:0;position:absolute}.Overlay{display:flex}anchored-position[popover]:not(.\:popover-open){display:none}anchored-position.not-anchored::-webkit-backdrop{background-color:var(--overlay-backdrop-bgColor,var(--color-neutral-muted))}anchored-position.not-anchored::backdrop{background-color:var(--overlay-backdrop-bgColor,var(--color-neutral-muted))}@supports selector(:popover-open){anchored-position[popover]:not(.\:popover-open){display:revert}}@supports selector(:open){anchored-position[popover]:not(.\:popover-open){display:revert}}
@@ -3,6 +3,8 @@
3
3
  "selectors": [
4
4
  "anchored-position[popover]",
5
5
  ".Overlay",
6
- "anchored-position[popover]:not(.\\:popover-open)"
6
+ "anchored-position[popover]:not(.\\:popover-open)",
7
+ "anchored-position.not-anchored::-webkit-backdrop",
8
+ "anchored-position.not-anchored::backdrop"
7
9
  ]
8
10
  }
@@ -12,6 +12,26 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
12
12
  var _ToolTipElement_instances, _ToolTipElement_abortController, _ToolTipElement_align, _ToolTipElement_side, _ToolTipElement_allowUpdatePosition, _ToolTipElement_update, _ToolTipElement_updateControlReference, _ToolTipElement_updateDirection, _ToolTipElement_updatePosition;
13
13
  import '@oddbird/popover-polyfill';
14
14
  import { getAnchoredPosition } from '@primer/behaviors';
15
+ const isPopoverOpen = (() => {
16
+ let selector;
17
+ function setSelector(el) {
18
+ try {
19
+ selector = ':popover-open';
20
+ return el.matches(selector);
21
+ }
22
+ catch (_a) {
23
+ try {
24
+ selector = ':open';
25
+ return el.matches(':open');
26
+ }
27
+ catch (_b) {
28
+ selector = '.\\:popover-open';
29
+ return el.matches('.\\:popover-open');
30
+ }
31
+ }
32
+ }
33
+ return (el) => (selector ? el.matches(selector) : setSelector(el));
34
+ })();
15
35
  const TOOLTIP_ARROW_EDGE_OFFSET = 6;
16
36
  const TOOLTIP_SR_ONLY_CLASS = 'sr-only';
17
37
  const TOOLTIP_OFFSET = 10;
@@ -29,7 +49,7 @@ function closeOpenTooltips(except) {
29
49
  for (const tooltip of openTooltips) {
30
50
  if (tooltip === except)
31
51
  continue;
32
- if (tooltip.matches(':popover-open')) {
52
+ if (isPopoverOpen(tooltip)) {
33
53
  tooltip.hidePopover();
34
54
  }
35
55
  else {
@@ -207,16 +227,16 @@ class ToolTipElement extends HTMLElement {
207
227
  }
208
228
  /* @deprecated */
209
229
  set hiddenFromView(value) {
210
- if (value && this.matches(':popover-open')) {
230
+ if (value && isPopoverOpen(this)) {
211
231
  this.hidePopover();
212
232
  }
213
- else if (!value && this.matches(':not(:popover-open)')) {
233
+ else if (!value && !isPopoverOpen(this)) {
214
234
  this.showPopover();
215
235
  }
216
236
  }
217
237
  /* @deprecated */
218
238
  get hiddenFromView() {
219
- return !this.matches(':popover-open');
239
+ return !isPopoverOpen(this);
220
240
  }
221
241
  connectedCallback() {
222
242
  var _a, _b;
@@ -260,7 +280,7 @@ class ToolTipElement extends HTMLElement {
260
280
  async handleEvent(event) {
261
281
  if (!this.control)
262
282
  return;
263
- const showing = this.matches(':popover-open');
283
+ const showing = isPopoverOpen(this);
264
284
  // Ensures that tooltip stays open when hovering between tooltip and element
265
285
  // WCAG Success Criterion 1.4.13 Hoverable
266
286
  const shouldShow = event.type === 'mouseenter' || event.type === 'focus';
@@ -272,10 +292,10 @@ class ToolTipElement extends HTMLElement {
272
292
  const isOpeningOtherPopover = event.type === 'beforetoggle' && event.currentTarget !== this;
273
293
  const shouldHide = isMouseLeaveFromButton || isEscapeKeydown || isMouseDownOnButton || isOpeningOtherPopover;
274
294
  await Promise.resolve();
275
- if (!showing && shouldShow && this.matches(':not(:popover-open)')) {
295
+ if (!showing && shouldShow && !isPopoverOpen(this)) {
276
296
  this.showPopover();
277
297
  }
278
- else if (showing && shouldHide && this.matches(':popover-open')) {
298
+ else if (showing && shouldHide && isPopoverOpen(this)) {
279
299
  this.hidePopover();
280
300
  }
281
301
  if (event.type === 'toggle') {
@@ -378,7 +398,7 @@ _ToolTipElement_abortController = new WeakMap(), _ToolTipElement_align = new Wea
378
398
  }, _ToolTipElement_updatePosition = function _ToolTipElement_updatePosition() {
379
399
  if (!this.control)
380
400
  return;
381
- if (!__classPrivateFieldGet(this, _ToolTipElement_allowUpdatePosition, "f") || !this.matches(':popover-open'))
401
+ if (!__classPrivateFieldGet(this, _ToolTipElement_allowUpdatePosition, "f") || !isPopoverOpen(this))
382
402
  return;
383
403
  const position = getAnchoredPosition(this, this.control, {
384
404
  side: __classPrivateFieldGet(this, _ToolTipElement_side, "f"),
@@ -131,11 +131,20 @@ export default class AnchoredPositionElement extends HTMLElement {
131
131
  cancelAnimationFrame(__classPrivateFieldGet(this, _AnchoredPositionElement_animationFrame, "f"));
132
132
  __classPrivateFieldSet(this, _AnchoredPositionElement_animationFrame, requestAnimationFrame(() => {
133
133
  const anchor = this.anchorElement;
134
- if (!anchor)
135
- return;
136
- const { left, top } = getAnchoredPosition(this, anchor, this);
137
- this.style.top = `${top}px`;
138
- this.style.left = `${left}px`;
134
+ this.classList.toggle('not-anchored', !anchor);
135
+ if (anchor) {
136
+ const { left, top } = getAnchoredPosition(this, anchor, this);
137
+ this.style.top = `${top}px`;
138
+ this.style.left = `${left}px`;
139
+ this.style.bottom = 'auto';
140
+ this.style.right = 'auto';
141
+ }
142
+ else {
143
+ this.style.top = '0';
144
+ this.style.left = '0';
145
+ this.style.bottom = '0';
146
+ this.style.right = '0';
147
+ }
139
148
  }), "f");
140
149
  }
141
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.8.0",
3
+ "version": "0.9.0-rc.17ac5d05",
4
4
  "description": "ViewComponents for the Primer Design System",
5
5
  "main": "app/assets/javascripts/primer_view_components.js",
6
6
  "module": "app/components/primer/primer.js",
@@ -5910,6 +5910,19 @@
5910
5910
  ]
5911
5911
  }
5912
5912
  },
5913
+ {
5914
+ "preview_path": "primer/alpha/overlay/in_an_action_menu",
5915
+ "name": "in_an_action_menu",
5916
+ "snapshot": "false",
5917
+ "skip_rules": {
5918
+ "wont_fix": [
5919
+ "region"
5920
+ ],
5921
+ "will_fix": [
5922
+ "color-contrast"
5923
+ ]
5924
+ }
5925
+ },
5913
5926
  {
5914
5927
  "preview_path": "primer/alpha/overlay/dialog_with_header_footer",
5915
5928
  "name": "dialog_with_header_footer",
@@ -4417,6 +4417,19 @@
4417
4417
  ]
4418
4418
  }
4419
4419
  },
4420
+ {
4421
+ "preview_path": "primer/alpha/overlay/in_an_action_menu",
4422
+ "name": "in_an_action_menu",
4423
+ "snapshot": "false",
4424
+ "skip_rules": {
4425
+ "wont_fix": [
4426
+ "region"
4427
+ ],
4428
+ "will_fix": [
4429
+ "color-contrast"
4430
+ ]
4431
+ }
4432
+ },
4420
4433
  {
4421
4434
  "preview_path": "primer/alpha/overlay/dialog_with_header_footer",
4422
4435
  "name": "dialog_with_header_footer",