@openproject/primer-view-components 0.95.0 → 0.96.0-rc.0d6e19868
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.
- package/app/assets/javascripts/primer_view_components.js +11 -1
- package/app/assets/javascripts/primer_view_components.js.map +1 -1
- package/app/assets/styles/primer_view_components.css +1 -1
- package/app/assets/styles/primer_view_components.css.map +1 -1
- package/app/components/primer/alpha/action_list.css +1 -1
- package/app/components/primer/alpha/action_list.css.json +2 -0
- package/app/components/primer/alpha/action_menu/action_menu_element.js +38 -21
- package/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.d.ts +1 -1
- package/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.js +6 -7
- package/app/components/primer/beta/button.css +1 -1
- package/app/components/primer/beta/button.css.json +16 -1
- package/app/components/primer/open_project/keybinding_hint/chords.d.ts +5 -0
- package/app/components/primer/open_project/keybinding_hint/chords.js +29 -0
- package/app/components/primer/open_project/keybinding_hint/key_names.d.ts +16 -0
- package/app/components/primer/open_project/keybinding_hint/key_names.js +107 -0
- package/app/components/primer/open_project/keybinding_hint/localized_names.d.ts +22 -0
- package/app/components/primer/open_project/keybinding_hint/localized_names.js +47 -0
- package/app/components/primer/open_project/keybinding_hint/names_from_scope.d.ts +21 -0
- package/app/components/primer/open_project/keybinding_hint/names_from_scope.js +81 -0
- package/app/components/primer/open_project/keybinding_hint/platform.d.ts +10 -0
- package/app/components/primer/open_project/keybinding_hint/platform.js +24 -0
- package/app/components/primer/open_project/keybinding_hint/platform_override.d.ts +2 -0
- package/app/components/primer/open_project/keybinding_hint/platform_override.js +4 -0
- package/app/components/primer/open_project/keybinding_hint.css +1 -0
- package/app/components/primer/open_project/keybinding_hint.css.json +10 -0
- package/app/components/primer/open_project/keybinding_hint_element.d.ts +31 -0
- package/app/components/primer/open_project/keybinding_hint_element.js +183 -0
- package/app/components/primer/primer.d.ts +1 -0
- package/app/components/primer/primer.js +1 -0
- package/package.json +6 -5
- package/static/arguments.json +40 -0
- package/static/audited_at.json +1 -0
- package/static/classes.json +12 -0
- package/static/classnames.cjs +4 -0
- package/static/classnames.js +4 -0
- package/static/constants.json +27 -0
- package/static/info_arch.json +194 -6
- package/static/previews.json +138 -0
- package/static/statuses.json +1 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { nonBlank } from './localized_names';
|
|
2
|
+
const FORMATS = ['condensed', 'full', 'accessible'];
|
|
3
|
+
const PLATFORMS = ['apple', 'windows', 'other'];
|
|
4
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
5
|
+
const own = (value, key) => isRecord(value) && Object.hasOwn(value, key) ? value[key] : undefined;
|
|
6
|
+
const isSymbol = (name) => name !== undefined && !/\p{L}/u.test(name);
|
|
7
|
+
/**
|
|
8
|
+
* Keys as Ruby tokenises them: the server cannot know the platform, so `mod`
|
|
9
|
+
* contributes both `control` and `meta`. Whitespace matches Ruby's `\s`.
|
|
10
|
+
*/
|
|
11
|
+
export const tokens = (keys) => [
|
|
12
|
+
...new Set(keys
|
|
13
|
+
.split(/[ \t\r\n\f\v]+/)
|
|
14
|
+
.flatMap(chord => chord.split('+'))
|
|
15
|
+
.filter(token => token !== '')
|
|
16
|
+
.map(token => token.toLowerCase())
|
|
17
|
+
.flatMap(token => (token === 'mod' ? ['control', 'meta'] : [token]))),
|
|
18
|
+
];
|
|
19
|
+
/** I18n keys cannot contain `.`, so punctuation entries carry their key in `key`. */
|
|
20
|
+
const tokenIndex = (entries) => {
|
|
21
|
+
const index = new Map();
|
|
22
|
+
if (!isRecord(entries))
|
|
23
|
+
return index;
|
|
24
|
+
for (const [name, entry] of Object.entries(entries)) {
|
|
25
|
+
if (!isRecord(entry))
|
|
26
|
+
continue;
|
|
27
|
+
const key = own(entry, 'key');
|
|
28
|
+
index.set(typeof key === 'string' ? key : name, name);
|
|
29
|
+
}
|
|
30
|
+
return index;
|
|
31
|
+
};
|
|
32
|
+
const platformNames = (value) => {
|
|
33
|
+
const names = {};
|
|
34
|
+
for (const platform of PLATFORMS) {
|
|
35
|
+
const name = nonBlank(own(value, platform));
|
|
36
|
+
if (name !== undefined)
|
|
37
|
+
names[platform] = name;
|
|
38
|
+
}
|
|
39
|
+
return names;
|
|
40
|
+
};
|
|
41
|
+
const entryNames = (englishEntry, localeEntry) => {
|
|
42
|
+
const names = {};
|
|
43
|
+
for (const format of FORMATS) {
|
|
44
|
+
const english = platformNames(own(englishEntry, format));
|
|
45
|
+
const translated = platformNames(own(localeEntry, format));
|
|
46
|
+
for (const platform of PLATFORMS) {
|
|
47
|
+
if (isSymbol(english[platform]))
|
|
48
|
+
delete translated[platform];
|
|
49
|
+
}
|
|
50
|
+
const merged = { ...english, ...translated };
|
|
51
|
+
if (Object.keys(merged).length > 0)
|
|
52
|
+
names[format] = merged;
|
|
53
|
+
}
|
|
54
|
+
return names;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Builds `data-names` for `keys` from the `keybinding_hint` locale scopes, as
|
|
58
|
+
* i18n-js returns them. Translator data is untrusted: only non-blank strings in
|
|
59
|
+
* the expected place are used, and symbols such as ⌘ cannot be replaced.
|
|
60
|
+
*/
|
|
61
|
+
export function buildKeyNames(keys, localeScope, englishScope) {
|
|
62
|
+
const englishKeys = own(englishScope, 'keys');
|
|
63
|
+
const index = tokenIndex(englishKeys);
|
|
64
|
+
const result = {
|
|
65
|
+
then: nonBlank(own(localeScope, 'then')) ?? nonBlank(own(englishScope, 'then')),
|
|
66
|
+
keys: {},
|
|
67
|
+
};
|
|
68
|
+
for (const token of tokens(keys)) {
|
|
69
|
+
const entry = index.get(token);
|
|
70
|
+
if (entry === undefined)
|
|
71
|
+
continue;
|
|
72
|
+
// defineProperty, not assignment: a `__proto__` token must stay an own key.
|
|
73
|
+
Object.defineProperty(result.keys, token, {
|
|
74
|
+
value: entryNames(own(englishKeys, entry), own(own(localeScope, 'keys'), entry)),
|
|
75
|
+
enumerable: true,
|
|
76
|
+
writable: true,
|
|
77
|
+
configurable: true,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The platform categories that affect how keyboard shortcut keys are displayed.
|
|
3
|
+
*
|
|
4
|
+
* - `apple`: Apple platforms (macOS and iOS/iPadOS), which use the Command and Option keys.
|
|
5
|
+
* - `windows`: Windows, which uses the Windows (Meta) key.
|
|
6
|
+
* - `other`: Any other platform (e.g. Linux, Android), where the Meta key does not map to a
|
|
7
|
+
* consistent label.
|
|
8
|
+
*/
|
|
9
|
+
export type Platform = 'apple' | 'windows' | 'other';
|
|
10
|
+
export declare const detectPlatform: () => Platform;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Mirrors primer-react `KeybindingHint/platform.ts`. The React-only parts are
|
|
2
|
+
// replaced: `getSnapshot` is exported as `detectPlatform`, and the element's
|
|
3
|
+
// `data-platform` attribute takes the place of `PlatformOverrideProvider`.
|
|
4
|
+
import { isMacOS as ssrUnsafeIsMacOS } from '@primer/behaviors/utils';
|
|
5
|
+
/** SSR-unsafe detection of iOS/iPadOS (in addition to macOS, which is detected separately). */
|
|
6
|
+
const ssrUnsafeIsIOS = () => {
|
|
7
|
+
if (typeof navigator === 'undefined')
|
|
8
|
+
return false;
|
|
9
|
+
return /iphone|ipad|ipod/i.test(navigator.platform) || /iphone|ipad|ipod/i.test(navigator.userAgent);
|
|
10
|
+
};
|
|
11
|
+
/** SSR-unsafe detection of Windows. */
|
|
12
|
+
const ssrUnsafeIsWindows = () => {
|
|
13
|
+
if (typeof navigator === 'undefined')
|
|
14
|
+
return false;
|
|
15
|
+
return /^win/i.test(navigator.platform);
|
|
16
|
+
};
|
|
17
|
+
const getSnapshot = () => {
|
|
18
|
+
if (ssrUnsafeIsMacOS() || ssrUnsafeIsIOS())
|
|
19
|
+
return 'apple';
|
|
20
|
+
if (ssrUnsafeIsWindows())
|
|
21
|
+
return 'windows';
|
|
22
|
+
return 'other';
|
|
23
|
+
};
|
|
24
|
+
export const detectPlatform = getSnapshot;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
keybinding-hint{display:contents}.KeybindingHint-kbd{position:relative;padding:0;overflow:visible;font-family:inherit;font-size:inherit;line-height:unset;color:inherit;white-space:nowrap;vertical-align:initial;background:none;border:none;box-shadow:none}.KeybindingHint-chord{display:inline-flex;justify-content:center;min-width:var(--base-size-20);padding:var(--base-size-4);overflow:hidden;font-size:var(--text-body-size-small);font-weight:var(--base-text-weight-normal);line-height:10px;color:var(--fgColor-muted);vertical-align:initial;background:var(--bgColor-transparent);border:var(--borderWidth-thin) solid var(--borderColor-default);border-radius:var(--borderRadius-medium);box-shadow:none;gap:.5ch;transition:80ms ease-in;transition-property:color,background-color,border-color}.KeybindingHint-chord--emphasis{color:var(--fgColor-onEmphasis);background:var(--counter-bgColor-emphasis);border-color:#0000;border-radius:var(--borderRadius-default);min-width:auto}.KeybindingHint-chord--small{min-width:var(--base-size-16);padding:var(--base-size-2);font-size:11px;line-height:var(--base-size-8);border-radius:var(--borderRadius-small)}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { buildKeyNames } from './keybinding_hint/names_from_scope';
|
|
2
|
+
/**
|
|
3
|
+
* Renders keyboard shortcut hints client-side, because only the browser knows
|
|
4
|
+
* the platform (⌘ vs ⌃). The server renders a plain-text fallback inside the
|
|
5
|
+
* chord box; this element replaces it once, then owns a <kbd> mount that
|
|
6
|
+
* lit-html renders into.
|
|
7
|
+
*
|
|
8
|
+
* Attributes (Catalyst `@attr`, so `data-*`): keys, format, scheme, size,
|
|
9
|
+
* platform ('' = detect; 'apple' | 'windows' | 'other' overrides, used by
|
|
10
|
+
* previews and tests), names (JSON of translated key names; see
|
|
11
|
+
* localized_names.ts).
|
|
12
|
+
*/
|
|
13
|
+
export declare class KeybindingHintElement extends HTMLElement {
|
|
14
|
+
#private;
|
|
15
|
+
/** Builds `data-names` from i18n-js scopes, for hosts that render hints client-side. */
|
|
16
|
+
static buildNames: typeof buildKeyNames;
|
|
17
|
+
keys: string;
|
|
18
|
+
format: string;
|
|
19
|
+
scheme: string;
|
|
20
|
+
size: string;
|
|
21
|
+
platform: string;
|
|
22
|
+
names: string;
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
disconnectedCallback(): void;
|
|
25
|
+
attributeChangedCallback(): void;
|
|
26
|
+
}
|
|
27
|
+
declare global {
|
|
28
|
+
interface Window {
|
|
29
|
+
KeybindingHintElement: typeof KeybindingHintElement;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
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");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
15
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
16
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
|
+
};
|
|
18
|
+
var _KeybindingHintElement_instances, _KeybindingHintElement_mount, _KeybindingHintElement_signature, _KeybindingHintElement_owned, _KeybindingHintElement_observer, _KeybindingHintElement_update, _KeybindingHintElement_resolvedPlatform, _KeybindingHintElement_resolvedFormat, _KeybindingHintElement_chordClass, _KeybindingHintElement_template, _KeybindingHintElement_keyTemplate;
|
|
19
|
+
import { attr, controller } from '@github/catalyst';
|
|
20
|
+
import { html, render, nothing } from 'lit-html';
|
|
21
|
+
import { detectPlatform } from './keybinding_hint/platform';
|
|
22
|
+
import { isPlatform } from './keybinding_hint/platform_override';
|
|
23
|
+
import { keyName, parseKeyNames } from './keybinding_hint/localized_names';
|
|
24
|
+
import { buildKeyNames } from './keybinding_hint/names_from_scope';
|
|
25
|
+
import { splitSequence } from './keybinding_hint/chords';
|
|
26
|
+
/**
|
|
27
|
+
* Renders keyboard shortcut hints client-side, because only the browser knows
|
|
28
|
+
* the platform (⌘ vs ⌃). The server renders a plain-text fallback inside the
|
|
29
|
+
* chord box; this element replaces it once, then owns a <kbd> mount that
|
|
30
|
+
* lit-html renders into.
|
|
31
|
+
*
|
|
32
|
+
* Attributes (Catalyst `@attr`, so `data-*`): keys, format, scheme, size,
|
|
33
|
+
* platform ('' = detect; 'apple' | 'windows' | 'other' overrides, used by
|
|
34
|
+
* previews and tests), names (JSON of translated key names; see
|
|
35
|
+
* localized_names.ts).
|
|
36
|
+
*/
|
|
37
|
+
let KeybindingHintElement = class KeybindingHintElement extends HTMLElement {
|
|
38
|
+
constructor() {
|
|
39
|
+
super(...arguments);
|
|
40
|
+
_KeybindingHintElement_instances.add(this);
|
|
41
|
+
this.keys = '';
|
|
42
|
+
this.format = 'condensed';
|
|
43
|
+
this.scheme = 'default';
|
|
44
|
+
this.size = 'medium';
|
|
45
|
+
this.platform = '';
|
|
46
|
+
this.names = '';
|
|
47
|
+
_KeybindingHintElement_mount.set(this, null);
|
|
48
|
+
_KeybindingHintElement_signature.set(this, ''
|
|
49
|
+
// Whether the mount still holds exactly what lit last rendered. Any
|
|
50
|
+
// mutation we did not make (Turbo morph, stream update, manual innerHTML,
|
|
51
|
+
// even inside a single chord) revokes it, because lit would otherwise
|
|
52
|
+
// update detached markers and leave the foreign content on screen.
|
|
53
|
+
);
|
|
54
|
+
// Whether the mount still holds exactly what lit last rendered. Any
|
|
55
|
+
// mutation we did not make (Turbo morph, stream update, manual innerHTML,
|
|
56
|
+
// even inside a single chord) revokes it, because lit would otherwise
|
|
57
|
+
// update detached markers and leave the foreign content on screen.
|
|
58
|
+
_KeybindingHintElement_owned.set(this, false
|
|
59
|
+
// Every mutation we make is drained with takeRecords() straight after, so
|
|
60
|
+
// any record that is delivered here or still queued in #update is external.
|
|
61
|
+
);
|
|
62
|
+
// Every mutation we make is drained with takeRecords() straight after, so
|
|
63
|
+
// any record that is delivered here or still queued in #update is external.
|
|
64
|
+
_KeybindingHintElement_observer.set(this, new MutationObserver(() => {
|
|
65
|
+
__classPrivateFieldSet(this, _KeybindingHintElement_owned, false, "f");
|
|
66
|
+
__classPrivateFieldGet(this, _KeybindingHintElement_instances, "m", _KeybindingHintElement_update).call(this);
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
connectedCallback() {
|
|
70
|
+
__classPrivateFieldGet(this, _KeybindingHintElement_observer, "f").observe(this, { childList: true, subtree: true, characterData: true });
|
|
71
|
+
__classPrivateFieldGet(this, _KeybindingHintElement_instances, "m", _KeybindingHintElement_update).call(this);
|
|
72
|
+
}
|
|
73
|
+
disconnectedCallback() {
|
|
74
|
+
// Mutations while detached go unobserved, so re-render on reconnect.
|
|
75
|
+
__classPrivateFieldGet(this, _KeybindingHintElement_observer, "f").disconnect();
|
|
76
|
+
__classPrivateFieldSet(this, _KeybindingHintElement_owned, false, "f");
|
|
77
|
+
}
|
|
78
|
+
attributeChangedCallback() {
|
|
79
|
+
// Catalyst fires this for every observed attribute before connectedCallback
|
|
80
|
+
// and once more for each default it writes; #update is idempotent and cheap.
|
|
81
|
+
__classPrivateFieldGet(this, _KeybindingHintElement_instances, "m", _KeybindingHintElement_update).call(this);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
_KeybindingHintElement_mount = new WeakMap();
|
|
85
|
+
_KeybindingHintElement_signature = new WeakMap();
|
|
86
|
+
_KeybindingHintElement_owned = new WeakMap();
|
|
87
|
+
_KeybindingHintElement_observer = new WeakMap();
|
|
88
|
+
_KeybindingHintElement_instances = new WeakSet();
|
|
89
|
+
_KeybindingHintElement_update = function _KeybindingHintElement_update() {
|
|
90
|
+
if (!this.isConnected)
|
|
91
|
+
return;
|
|
92
|
+
const platform = __classPrivateFieldGet(this, _KeybindingHintElement_instances, "m", _KeybindingHintElement_resolvedPlatform).call(this);
|
|
93
|
+
const chords = splitSequence(this.keys, platform);
|
|
94
|
+
const signature = [this.keys, this.format, this.scheme, this.size, platform, this.names].join('\u0000');
|
|
95
|
+
// Catches an external mutation made in the same task as an attribute
|
|
96
|
+
// change, before the observer callback has run.
|
|
97
|
+
if (__classPrivateFieldGet(this, _KeybindingHintElement_observer, "f").takeRecords().length > 0)
|
|
98
|
+
__classPrivateFieldSet(this, _KeybindingHintElement_owned, false, "f");
|
|
99
|
+
const owned = __classPrivateFieldGet(this, _KeybindingHintElement_owned, "f") && __classPrivateFieldGet(this, _KeybindingHintElement_mount, "f") !== null;
|
|
100
|
+
if (owned && signature === __classPrivateFieldGet(this, _KeybindingHintElement_signature, "f"))
|
|
101
|
+
return;
|
|
102
|
+
if (chords.length === 0) {
|
|
103
|
+
// Blank keys: render nothing, drop the fallback and any previous mount.
|
|
104
|
+
if (this.hasChildNodes())
|
|
105
|
+
this.replaceChildren();
|
|
106
|
+
__classPrivateFieldGet(this, _KeybindingHintElement_observer, "f").takeRecords();
|
|
107
|
+
__classPrivateFieldSet(this, _KeybindingHintElement_mount, null, "f");
|
|
108
|
+
__classPrivateFieldSet(this, _KeybindingHintElement_owned, false, "f");
|
|
109
|
+
__classPrivateFieldSet(this, _KeybindingHintElement_signature, signature, "f");
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (!owned) {
|
|
113
|
+
// First render, or something (Turbo morph, manual innerHTML) replaced our
|
|
114
|
+
// content with fresh server markup. A new mount gives lit a fresh
|
|
115
|
+
// container; reusing the old one would hit lit's detached markers.
|
|
116
|
+
__classPrivateFieldSet(this, _KeybindingHintElement_mount, document.createElement('kbd'), "f");
|
|
117
|
+
__classPrivateFieldGet(this, _KeybindingHintElement_mount, "f").className = 'KeybindingHint-kbd';
|
|
118
|
+
this.replaceChildren(__classPrivateFieldGet(this, _KeybindingHintElement_mount, "f"));
|
|
119
|
+
}
|
|
120
|
+
const target = __classPrivateFieldGet(this, _KeybindingHintElement_mount, "f");
|
|
121
|
+
render(__classPrivateFieldGet(this, _KeybindingHintElement_instances, "m", _KeybindingHintElement_template).call(this, chords, platform, parseKeyNames(this.names)), target);
|
|
122
|
+
// Drop the records of our own render so they cannot re-enter #update.
|
|
123
|
+
__classPrivateFieldGet(this, _KeybindingHintElement_observer, "f").takeRecords();
|
|
124
|
+
__classPrivateFieldSet(this, _KeybindingHintElement_owned, true, "f");
|
|
125
|
+
__classPrivateFieldSet(this, _KeybindingHintElement_signature, signature, "f");
|
|
126
|
+
};
|
|
127
|
+
_KeybindingHintElement_resolvedPlatform = function _KeybindingHintElement_resolvedPlatform() {
|
|
128
|
+
return isPlatform(this.platform) ? this.platform : detectPlatform();
|
|
129
|
+
};
|
|
130
|
+
_KeybindingHintElement_resolvedFormat = function _KeybindingHintElement_resolvedFormat() {
|
|
131
|
+
return this.format === 'full' ? 'full' : 'condensed';
|
|
132
|
+
};
|
|
133
|
+
_KeybindingHintElement_chordClass = function _KeybindingHintElement_chordClass() {
|
|
134
|
+
const classes = ['KeybindingHint-chord'];
|
|
135
|
+
if (this.scheme === 'emphasis')
|
|
136
|
+
classes.push('KeybindingHint-chord--emphasis');
|
|
137
|
+
if (this.size === 'small')
|
|
138
|
+
classes.push('KeybindingHint-chord--small');
|
|
139
|
+
return classes.join(' ');
|
|
140
|
+
};
|
|
141
|
+
_KeybindingHintElement_template = function _KeybindingHintElement_template(chords, platform, names) {
|
|
142
|
+
const format = __classPrivateFieldGet(this, _KeybindingHintElement_instances, "m", _KeybindingHintElement_resolvedFormat).call(this);
|
|
143
|
+
const chordClass = __classPrivateFieldGet(this, _KeybindingHintElement_instances, "m", _KeybindingHintElement_chordClass).call(this);
|
|
144
|
+
// Whitespace text nodes are deliberate: they give screen readers word
|
|
145
|
+
// boundaries between hidden labels. Inside the inline-flex chord they do
|
|
146
|
+
// not render; between chords the two around "then" collapse into the one
|
|
147
|
+
// visible separator (as in React).
|
|
148
|
+
return chords.map((keys, chordIndex) => html `${chordIndex > 0 ? html ` <span class="sr-only">${names.separator ?? 'then'}</span> ` : nothing}<span
|
|
149
|
+
class="${chordClass}"
|
|
150
|
+
data-kbd-chord
|
|
151
|
+
>${keys.map((key, keyIndex) => __classPrivateFieldGet(this, _KeybindingHintElement_instances, "m", _KeybindingHintElement_keyTemplate).call(this, key, keyIndex, format, platform, names))}</span
|
|
152
|
+
>`);
|
|
153
|
+
};
|
|
154
|
+
_KeybindingHintElement_keyTemplate = function _KeybindingHintElement_keyTemplate(key, index, format, platform, names) {
|
|
155
|
+
const visible = keyName(names, key, format, platform);
|
|
156
|
+
const separator = index === 0 ? nothing : format === 'full' ? html ` <span aria-hidden="true"> + </span> ` : ' ';
|
|
157
|
+
return html `${separator}<span class="sr-only">${keyName(names, key, 'accessible', platform)}</span
|
|
158
|
+
><span aria-hidden="true">${visible}</span>`;
|
|
159
|
+
};
|
|
160
|
+
/** Builds `data-names` from i18n-js scopes, for hosts that render hints client-side. */
|
|
161
|
+
KeybindingHintElement.buildNames = buildKeyNames;
|
|
162
|
+
__decorate([
|
|
163
|
+
attr
|
|
164
|
+
], KeybindingHintElement.prototype, "keys", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
attr
|
|
167
|
+
], KeybindingHintElement.prototype, "format", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
attr
|
|
170
|
+
], KeybindingHintElement.prototype, "scheme", void 0);
|
|
171
|
+
__decorate([
|
|
172
|
+
attr
|
|
173
|
+
], KeybindingHintElement.prototype, "size", void 0);
|
|
174
|
+
__decorate([
|
|
175
|
+
attr
|
|
176
|
+
], KeybindingHintElement.prototype, "platform", void 0);
|
|
177
|
+
__decorate([
|
|
178
|
+
attr
|
|
179
|
+
], KeybindingHintElement.prototype, "names", void 0);
|
|
180
|
+
KeybindingHintElement = __decorate([
|
|
181
|
+
controller('keybinding-hint')
|
|
182
|
+
], KeybindingHintElement);
|
|
183
|
+
export { KeybindingHintElement };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openproject/primer-view-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.0-rc.0d6e19868",
|
|
4
4
|
"description": "ViewComponents of the Primer Design System for OpenProject",
|
|
5
5
|
"main": "app/assets/javascripts/primer_view_components.js",
|
|
6
6
|
"module": "app/components/primer/primer.js",
|
|
@@ -75,10 +75,11 @@
|
|
|
75
75
|
"@github/tab-container-element": "^3.1.2",
|
|
76
76
|
"@oddbird/popover-polyfill": "^0.5.2",
|
|
77
77
|
"@primer/behaviors": "^1.3.4",
|
|
78
|
-
"@primer/live-region-element": "^0.8.0"
|
|
78
|
+
"@primer/live-region-element": "^0.8.0",
|
|
79
|
+
"lit-html": "^3.3.3"
|
|
79
80
|
},
|
|
80
81
|
"peerDependencies": {
|
|
81
|
-
"@primer/primitives": "
|
|
82
|
+
"@primer/primitives": "^11.5.1"
|
|
82
83
|
},
|
|
83
84
|
"devDependencies": {
|
|
84
85
|
"@changesets/changelog-github": "^0.5.0",
|
|
@@ -87,7 +88,7 @@
|
|
|
87
88
|
"@github/browserslist-config": "^1.0.0",
|
|
88
89
|
"@github/markdownlint-github": "^0.8.0",
|
|
89
90
|
"@github/prettier-config": "0.0.6",
|
|
90
|
-
"@playwright/test": "^1.
|
|
91
|
+
"@playwright/test": "^1.64.1",
|
|
91
92
|
"@primer/css": "22.3.0",
|
|
92
93
|
"@primer/primitives": "^11.9.0",
|
|
93
94
|
"@primer/stylelint-config": "^13.6.0",
|
|
@@ -101,7 +102,7 @@
|
|
|
101
102
|
"glob": "^11.0.2",
|
|
102
103
|
"markdownlint-cli2": "^0.23.0",
|
|
103
104
|
"mocha": "^11.0.1",
|
|
104
|
-
"playwright": "^1.
|
|
105
|
+
"playwright": "^1.64.1",
|
|
105
106
|
"postcss": "^8.4.16",
|
|
106
107
|
"postcss-cli": "^11.0.0",
|
|
107
108
|
"postcss-import": "^16.0.0",
|
package/static/arguments.json
CHANGED
|
@@ -6599,6 +6599,46 @@
|
|
|
6599
6599
|
}
|
|
6600
6600
|
]
|
|
6601
6601
|
},
|
|
6602
|
+
{
|
|
6603
|
+
"component": "OpenProject::KeybindingHint",
|
|
6604
|
+
"status": "open_project",
|
|
6605
|
+
"a11y_reviewed": false,
|
|
6606
|
+
"short_name": "OpenProjectKeybindingHint",
|
|
6607
|
+
"source": "https://github.com/primer/view_components/tree/main/app/components/primer/open_project/keybinding_hint.rb",
|
|
6608
|
+
"lookbook": "https://primer.style/view-components/lookbook/inspect/primer/open_project/keybinding_hint/default/",
|
|
6609
|
+
"parameters": [
|
|
6610
|
+
{
|
|
6611
|
+
"name": "keys",
|
|
6612
|
+
"type": "String",
|
|
6613
|
+
"default": "N/A",
|
|
6614
|
+
"description": "The keys of the shortcut, e.g. `\"Mod+Shift+p\"` or `\"g i\"`. See the class documentation for the syntax."
|
|
6615
|
+
},
|
|
6616
|
+
{
|
|
6617
|
+
"name": "format",
|
|
6618
|
+
"type": "Symbol",
|
|
6619
|
+
"default": "`:condensed`",
|
|
6620
|
+
"description": "One of `:condensed` or `:full`. `:condensed` shows symbols (⌘⇧P) and suits menus and buttons; `:full` spells keys out (Command + Shift + P) and suits prose."
|
|
6621
|
+
},
|
|
6622
|
+
{
|
|
6623
|
+
"name": "scheme",
|
|
6624
|
+
"type": "Symbol",
|
|
6625
|
+
"default": "`:default`",
|
|
6626
|
+
"description": "One of `:default` or `:emphasis`. Use `:emphasis` on emphasis-coloured backgrounds."
|
|
6627
|
+
},
|
|
6628
|
+
{
|
|
6629
|
+
"name": "size",
|
|
6630
|
+
"type": "Symbol",
|
|
6631
|
+
"default": "`:medium`",
|
|
6632
|
+
"description": "One of `:medium` or `:small`."
|
|
6633
|
+
},
|
|
6634
|
+
{
|
|
6635
|
+
"name": "system_arguments",
|
|
6636
|
+
"type": "Hash",
|
|
6637
|
+
"default": "N/A",
|
|
6638
|
+
"description": "[System arguments](/system-arguments)"
|
|
6639
|
+
}
|
|
6640
|
+
]
|
|
6641
|
+
},
|
|
6602
6642
|
{
|
|
6603
6643
|
"component": "OpenProject::PageHeader",
|
|
6604
6644
|
"status": "open_project",
|
package/static/audited_at.json
CHANGED
|
@@ -165,6 +165,7 @@
|
|
|
165
165
|
"Primer::OpenProject::InlineMessage": "",
|
|
166
166
|
"Primer::OpenProject::InputGroup": "",
|
|
167
167
|
"Primer::OpenProject::InsetBox": "",
|
|
168
|
+
"Primer::OpenProject::KeybindingHint": "",
|
|
168
169
|
"Primer::OpenProject::PageHeader": "",
|
|
169
170
|
"Primer::OpenProject::PageHeader::Dialog": "",
|
|
170
171
|
"Primer::OpenProject::PageHeader::Menu": "",
|
package/static/classes.json
CHANGED
|
@@ -403,6 +403,18 @@
|
|
|
403
403
|
"InsetBox--title-container": [
|
|
404
404
|
"Primer::OpenProject::InsetBox"
|
|
405
405
|
],
|
|
406
|
+
"KeybindingHint-chord": [
|
|
407
|
+
"Primer::OpenProject::KeybindingHint"
|
|
408
|
+
],
|
|
409
|
+
"KeybindingHint-chord--emphasis": [
|
|
410
|
+
"Primer::OpenProject::KeybindingHint"
|
|
411
|
+
],
|
|
412
|
+
"KeybindingHint-chord--small": [
|
|
413
|
+
"Primer::OpenProject::KeybindingHint"
|
|
414
|
+
],
|
|
415
|
+
"KeybindingHint-kbd": [
|
|
416
|
+
"Primer::OpenProject::KeybindingHint"
|
|
417
|
+
],
|
|
406
418
|
"Label": [
|
|
407
419
|
"Primer::Beta::Label"
|
|
408
420
|
],
|
package/static/classnames.cjs
CHANGED
|
@@ -201,6 +201,10 @@ module.exports = new Set([
|
|
|
201
201
|
'InsetBox--body',
|
|
202
202
|
'InsetBox--body--clip_board_copy',
|
|
203
203
|
'InsetBox--title-container',
|
|
204
|
+
'KeybindingHint-chord',
|
|
205
|
+
'KeybindingHint-chord--emphasis',
|
|
206
|
+
'KeybindingHint-chord--small',
|
|
207
|
+
'KeybindingHint-kbd',
|
|
204
208
|
'Label',
|
|
205
209
|
'Label--accent',
|
|
206
210
|
'Label--attention',
|
package/static/classnames.js
CHANGED
|
@@ -201,6 +201,10 @@ const classNames = new Set([
|
|
|
201
201
|
'InsetBox--body',
|
|
202
202
|
'InsetBox--body--clip_board_copy',
|
|
203
203
|
'InsetBox--title-container',
|
|
204
|
+
'KeybindingHint-chord',
|
|
205
|
+
'KeybindingHint-chord--emphasis',
|
|
206
|
+
'KeybindingHint-chord--small',
|
|
207
|
+
'KeybindingHint-kbd',
|
|
204
208
|
'Label',
|
|
205
209
|
'Label--accent',
|
|
206
210
|
'Label--attention',
|
package/static/constants.json
CHANGED
|
@@ -1928,6 +1928,33 @@
|
|
|
1928
1928
|
}
|
|
1929
1929
|
}
|
|
1930
1930
|
},
|
|
1931
|
+
"Primer::OpenProject::KeybindingHint": {
|
|
1932
|
+
"DEFAULT_FORMAT": "condensed",
|
|
1933
|
+
"DEFAULT_SCHEME": "default",
|
|
1934
|
+
"DEFAULT_SIZE": "medium",
|
|
1935
|
+
"FORMAT_OPTIONS": [
|
|
1936
|
+
"condensed",
|
|
1937
|
+
"full"
|
|
1938
|
+
],
|
|
1939
|
+
"GeneratedSlotMethods": "Primer::OpenProject::KeybindingHint::GeneratedSlotMethods",
|
|
1940
|
+
"Names": "Primer::OpenProject::KeybindingHint::Names",
|
|
1941
|
+
"SCHEME_MAPPINGS": {
|
|
1942
|
+
"default": "",
|
|
1943
|
+
"emphasis": "KeybindingHint-chord--emphasis"
|
|
1944
|
+
},
|
|
1945
|
+
"SCHEME_OPTIONS": [
|
|
1946
|
+
"default",
|
|
1947
|
+
"emphasis"
|
|
1948
|
+
],
|
|
1949
|
+
"SIZE_MAPPINGS": {
|
|
1950
|
+
"medium": "",
|
|
1951
|
+
"small": "KeybindingHint-chord--small"
|
|
1952
|
+
},
|
|
1953
|
+
"SIZE_OPTIONS": [
|
|
1954
|
+
"medium",
|
|
1955
|
+
"small"
|
|
1956
|
+
]
|
|
1957
|
+
},
|
|
1931
1958
|
"Primer::OpenProject::PageHeader": {
|
|
1932
1959
|
"BACK_BUTTON_ICON_OPTIONS": [
|
|
1933
1960
|
"arrow-left",
|