@primer/view-components 0.26.0-rc.f9301560 → 0.26.0-rc.fa97526e
Sign up to get free protection for your applications and to get access to all the features.
- package/app/assets/javascripts/lib/primer/forms/primer_text_field.d.ts +0 -27
- package/app/assets/javascripts/primer_view_components.js +1 -1
- package/app/assets/javascripts/primer_view_components.js.map +1 -1
- package/app/components/primer/alpha/action_menu/action_menu_element.js +43 -13
- package/lib/primer/forms/primer_text_field.d.ts +0 -27
- package/lib/primer/forms/primer_text_field.js +5 -17
- package/package.json +2 -2
@@ -15,7 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
15
15
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
16
16
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
17
17
|
};
|
18
|
-
var _ActionMenuElement_instances, _ActionMenuElement_abortController, _ActionMenuElement_originalLabel, _ActionMenuElement_inputName, _ActionMenuElement_invokerBeingClicked, _ActionMenuElement_softDisableItems, _ActionMenuElement_potentiallyDisallowActivation,
|
18
|
+
var _ActionMenuElement_instances, _ActionMenuElement_abortController, _ActionMenuElement_originalLabel, _ActionMenuElement_inputName, _ActionMenuElement_invokerBeingClicked, _ActionMenuElement_softDisableItems, _ActionMenuElement_potentiallyDisallowActivation, _ActionMenuElement_isKeyboardActivation, _ActionMenuElement_isKeyboardActivationViaEnter, _ActionMenuElement_isKeyboardActivationViaSpace, _ActionMenuElement_isMouseActivation, _ActionMenuElement_isActivation, _ActionMenuElement_handleInvokerActivated, _ActionMenuElement_handleDialogItemActivated, _ActionMenuElement_handleItemActivated, _ActionMenuElement_activateItem, _ActionMenuElement_handleIncludeFragmentReplaced, _ActionMenuElement_handleFocusOut, _ActionMenuElement_show, _ActionMenuElement_hide, _ActionMenuElement_isOpen, _ActionMenuElement_setDynamicLabel, _ActionMenuElement_updateInput, _ActionMenuElement_firstItem_get;
|
19
19
|
import { controller, target } from '@github/catalyst';
|
20
20
|
import '@oddbird/popover-polyfill';
|
21
21
|
const validSelectors = ['[role="menuitem"]', '[role="menuitemcheckbox"]', '[role="menuitemradio"]'];
|
@@ -152,13 +152,18 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
152
152
|
return;
|
153
153
|
}
|
154
154
|
}
|
155
|
-
|
156
|
-
|
157
|
-
|
155
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_activateItem).call(this, event, item);
|
156
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_handleItemActivated).call(this, item);
|
157
|
+
// Pressing the space key on a button or link will cause the page to scroll unless preventDefault()
|
158
|
+
// is called. While calling preventDefault() appears to have no effect on link navigation, it skips
|
159
|
+
// form submission. The code below therefore only calls preventDefault() if the button has been
|
160
|
+
// activated by the space key, and manually submits the form if the button is a submit button.
|
161
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isKeyboardActivationViaSpace).call(this, event)) {
|
158
162
|
event.preventDefault();
|
159
|
-
item.
|
163
|
+
if (item.getAttribute('type') === 'submit') {
|
164
|
+
item.closest('form')?.submit();
|
165
|
+
}
|
160
166
|
}
|
161
|
-
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_handleItemActivated).call(this, item);
|
162
167
|
return;
|
163
168
|
}
|
164
169
|
if (event.type === 'include-fragment-replaced') {
|
@@ -264,18 +269,26 @@ _ActionMenuElement_potentiallyDisallowActivation = function _ActionMenuElement_p
|
|
264
269
|
}
|
265
270
|
return false;
|
266
271
|
};
|
267
|
-
|
268
|
-
return (
|
269
|
-
|
272
|
+
_ActionMenuElement_isKeyboardActivation = function _ActionMenuElement_isKeyboardActivation(event) {
|
273
|
+
return __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isKeyboardActivationViaEnter).call(this, event) || __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isKeyboardActivationViaSpace).call(this, event);
|
274
|
+
};
|
275
|
+
_ActionMenuElement_isKeyboardActivationViaEnter = function _ActionMenuElement_isKeyboardActivationViaEnter(event) {
|
276
|
+
return (event instanceof KeyboardEvent &&
|
277
|
+
event.type === 'keydown' &&
|
278
|
+
!(event.ctrlKey || event.altKey || event.metaKey || event.shiftKey) &&
|
279
|
+
event.key === 'Enter');
|
280
|
+
};
|
281
|
+
_ActionMenuElement_isKeyboardActivationViaSpace = function _ActionMenuElement_isKeyboardActivationViaSpace(event) {
|
282
|
+
return (event instanceof KeyboardEvent &&
|
270
283
|
event.type === 'keydown' &&
|
271
284
|
!(event.ctrlKey || event.altKey || event.metaKey || event.shiftKey) &&
|
272
285
|
event.key === ' ');
|
273
286
|
};
|
287
|
+
_ActionMenuElement_isMouseActivation = function _ActionMenuElement_isMouseActivation(event) {
|
288
|
+
return event instanceof MouseEvent && event.type === 'click';
|
289
|
+
};
|
274
290
|
_ActionMenuElement_isActivation = function _ActionMenuElement_isActivation(event) {
|
275
|
-
|
276
|
-
// enter or space counterintuitively fires one of these rather than a KeyboardEvent. Since PointerEvent
|
277
|
-
// inherits from MouseEvent, it is enough to check for MouseEvent here.
|
278
|
-
return (event instanceof MouseEvent && event.type === 'click') || __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isAnchorActivationViaSpace).call(this, event);
|
291
|
+
return __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isMouseActivation).call(this, event) || __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isKeyboardActivation).call(this, event);
|
279
292
|
};
|
280
293
|
_ActionMenuElement_handleInvokerActivated = function _ActionMenuElement_handleInvokerActivated(event) {
|
281
294
|
event.preventDefault();
|
@@ -350,6 +363,23 @@ _ActionMenuElement_handleItemActivated = function _ActionMenuElement_handleItemA
|
|
350
363
|
detail: { item: item.parentElement, checked: this.isItemChecked(item.parentElement) },
|
351
364
|
}));
|
352
365
|
};
|
366
|
+
_ActionMenuElement_activateItem = function _ActionMenuElement_activateItem(event, item) {
|
367
|
+
const eventWillActivateByDefault = (event instanceof MouseEvent && event.type === 'click') ||
|
368
|
+
(event instanceof KeyboardEvent &&
|
369
|
+
event.type === 'keydown' &&
|
370
|
+
!(event.ctrlKey || event.altKey || event.metaKey || event.shiftKey) &&
|
371
|
+
event.key === 'Enter');
|
372
|
+
// if the event will result in activating the current item by default, i.e. is a
|
373
|
+
// mouse click or keyboard enter, bail out
|
374
|
+
if (eventWillActivateByDefault)
|
375
|
+
return;
|
376
|
+
// otherwise, event will not result in activation by default, so we stop it and
|
377
|
+
// simulate a click
|
378
|
+
/* eslint-disable-next-line no-restricted-syntax */
|
379
|
+
event.stopPropagation();
|
380
|
+
const elem = item;
|
381
|
+
elem.click();
|
382
|
+
};
|
353
383
|
_ActionMenuElement_handleIncludeFragmentReplaced = function _ActionMenuElement_handleIncludeFragmentReplaced() {
|
354
384
|
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_firstItem_get))
|
355
385
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_firstItem_get).focus();
|
@@ -1,28 +1 @@
|
|
1
1
|
import '@github/auto-check-element';
|
2
|
-
import type { AutoCheckErrorEvent, AutoCheckSuccessEvent } from '@github/auto-check-element';
|
3
|
-
declare global {
|
4
|
-
interface HTMLElementEventMap {
|
5
|
-
'auto-check-success': AutoCheckSuccessEvent;
|
6
|
-
'auto-check-error': AutoCheckErrorEvent;
|
7
|
-
}
|
8
|
-
}
|
9
|
-
export declare class PrimerTextFieldElement extends HTMLElement {
|
10
|
-
#private;
|
11
|
-
inputElement: HTMLInputElement;
|
12
|
-
validationElement: HTMLElement;
|
13
|
-
validationMessageElement: HTMLElement;
|
14
|
-
validationSuccessIcon: HTMLElement;
|
15
|
-
validationErrorIcon: HTMLElement;
|
16
|
-
leadingVisual: HTMLElement;
|
17
|
-
leadingSpinner: HTMLElement;
|
18
|
-
connectedCallback(): void;
|
19
|
-
disconnectedCallback(): void;
|
20
|
-
clearContents(): void;
|
21
|
-
clearError(): void;
|
22
|
-
setValidationMessage(message: string): void;
|
23
|
-
toggleValidationStyling(isError: boolean): void;
|
24
|
-
setSuccess(message: string): void;
|
25
|
-
setError(message: string): void;
|
26
|
-
showLeadingSpinner(): void;
|
27
|
-
hideLeadingSpinner(): void;
|
28
|
-
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
/* eslint-disable custom-elements/expose-class-on-global */
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
@@ -19,7 +18,10 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
19
18
|
var _PrimerTextFieldElement_abortController;
|
20
19
|
import '@github/auto-check-element';
|
21
20
|
import { controller, target } from '@github/catalyst';
|
22
|
-
|
21
|
+
// eslint-disable-next-line custom-elements/expose-class-on-global
|
22
|
+
let PrimerTextFieldElement =
|
23
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
24
|
+
class PrimerTextFieldElement extends HTMLElement {
|
23
25
|
constructor() {
|
24
26
|
super(...arguments);
|
25
27
|
_PrimerTextFieldElement_abortController.set(this, void 0);
|
@@ -81,14 +83,6 @@ let PrimerTextFieldElement = class PrimerTextFieldElement extends HTMLElement {
|
|
81
83
|
this.setValidationMessage(message);
|
82
84
|
this.validationElement.hidden = false;
|
83
85
|
}
|
84
|
-
showLeadingSpinner() {
|
85
|
-
this.leadingSpinner?.removeAttribute('hidden');
|
86
|
-
this.leadingVisual?.setAttribute('hidden', '');
|
87
|
-
}
|
88
|
-
hideLeadingSpinner() {
|
89
|
-
this.leadingSpinner?.setAttribute('hidden', '');
|
90
|
-
this.leadingVisual?.removeAttribute('hidden');
|
91
|
-
}
|
92
86
|
};
|
93
87
|
_PrimerTextFieldElement_abortController = new WeakMap();
|
94
88
|
__decorate([
|
@@ -106,13 +100,7 @@ __decorate([
|
|
106
100
|
__decorate([
|
107
101
|
target
|
108
102
|
], PrimerTextFieldElement.prototype, "validationErrorIcon", void 0);
|
109
|
-
__decorate([
|
110
|
-
target
|
111
|
-
], PrimerTextFieldElement.prototype, "leadingVisual", void 0);
|
112
|
-
__decorate([
|
113
|
-
target
|
114
|
-
], PrimerTextFieldElement.prototype, "leadingSpinner", void 0);
|
115
103
|
PrimerTextFieldElement = __decorate([
|
116
104
|
controller
|
105
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
117
106
|
], PrimerTextFieldElement);
|
118
|
-
export { PrimerTextFieldElement };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@primer/view-components",
|
3
|
-
"version": "0.26.0-rc.
|
3
|
+
"version": "0.26.0-rc.fa97526e",
|
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",
|
@@ -84,7 +84,7 @@
|
|
84
84
|
"postcss-import": "^16.0.0",
|
85
85
|
"postcss-mixins": "^10.0.0",
|
86
86
|
"postcss-preset-env": "^9.3.0",
|
87
|
-
"prettier": "3.3.
|
87
|
+
"prettier": "3.3.0",
|
88
88
|
"rollup": "^2.79.1",
|
89
89
|
"rollup-plugin-terser": "^7.0.2",
|
90
90
|
"stylelint": "^16.1.0",
|