openproject-primer_view_components 0.95.0 → 0.96.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/app/assets/javascripts/primer_view_components.js +11 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +1 -1
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_bar.css +1 -1
- data/app/components/primer/alpha/action_bar.css.map +1 -1
- data/app/components/primer/alpha/action_list/item.rb +5 -1
- data/app/components/primer/alpha/action_list.css +1 -1
- data/app/components/primer/alpha/action_list.css.json +13 -11
- data/app/components/primer/alpha/action_list.css.map +1 -1
- data/app/components/primer/alpha/action_list.pcss +12 -0
- data/app/components/primer/alpha/action_menu/action_menu_element.d.ts +6 -0
- data/app/components/primer/alpha/action_menu/action_menu_element.js +389 -84
- data/app/components/primer/alpha/action_menu/action_menu_element.ts +439 -78
- data/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.d.ts +4 -1
- data/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.js +37 -13
- data/app/components/primer/alpha/action_menu/action_menu_focus_zone_stack.ts +41 -12
- data/app/components/primer/alpha/action_menu/menu.html.erb +27 -19
- data/app/components/primer/alpha/action_menu/menu.rb +7 -0
- data/app/components/primer/alpha/action_menu/primary_menu.rb +15 -0
- data/app/components/primer/alpha/action_menu.rb +55 -0
- data/app/components/primer/alpha/auto_complete.css +1 -1
- data/app/components/primer/alpha/auto_complete.css.map +1 -1
- data/app/components/primer/alpha/banner.css +1 -1
- data/app/components/primer/alpha/banner.css.map +1 -1
- data/app/components/primer/alpha/button_marketing.css +1 -1
- data/app/components/primer/alpha/button_marketing.css.map +1 -1
- data/app/components/primer/alpha/dialog.css +1 -1
- data/app/components/primer/alpha/dialog.css.map +1 -1
- data/app/components/primer/alpha/dropdown/menu.rb +1 -1
- data/app/components/primer/alpha/dropdown.css +1 -1
- data/app/components/primer/alpha/dropdown.css.json +1 -1
- data/app/components/primer/alpha/dropdown.css.map +1 -1
- data/app/components/primer/alpha/layout.css +1 -1
- data/app/components/primer/alpha/layout.css.json +3 -3
- data/app/components/primer/alpha/layout.css.map +1 -1
- data/app/components/primer/alpha/menu.css +1 -1
- data/app/components/primer/alpha/menu.css.json +3 -3
- data/app/components/primer/alpha/menu.css.map +1 -1
- data/app/components/primer/alpha/overlay.css +1 -1
- data/app/components/primer/alpha/overlay.css.map +1 -1
- data/app/components/primer/alpha/segmented_control.css +1 -1
- data/app/components/primer/alpha/segmented_control.css.json +1 -1
- data/app/components/primer/alpha/segmented_control.css.map +1 -1
- data/app/components/primer/alpha/select_panel.css +1 -1
- data/app/components/primer/alpha/select_panel.css.map +1 -1
- data/app/components/primer/alpha/skeleton_box.css +1 -1
- data/app/components/primer/alpha/skeleton_box.css.map +1 -1
- data/app/components/primer/alpha/stack.css +1 -1
- data/app/components/primer/alpha/stack.css.map +1 -1
- data/app/components/primer/alpha/stack_item.css +1 -1
- data/app/components/primer/alpha/stack_item.css.map +1 -1
- data/app/components/primer/alpha/tab_nav.css +1 -1
- data/app/components/primer/alpha/tab_nav.css.map +1 -1
- data/app/components/primer/alpha/text_field.css +1 -1
- data/app/components/primer/alpha/text_field.css.map +1 -1
- data/app/components/primer/alpha/toggle_switch.css +1 -1
- data/app/components/primer/alpha/toggle_switch.css.map +1 -1
- data/app/components/primer/alpha/tree_view.css +1 -1
- data/app/components/primer/alpha/tree_view.css.json +3 -3
- data/app/components/primer/alpha/tree_view.css.map +1 -1
- data/app/components/primer/alpha/underline_nav.css +1 -1
- data/app/components/primer/alpha/underline_nav.css.map +1 -1
- data/app/components/primer/beta/border_box.css +1 -1
- data/app/components/primer/beta/border_box.css.json +5 -5
- data/app/components/primer/beta/border_box.css.map +1 -1
- data/app/components/primer/beta/button.css +1 -1
- data/app/components/primer/beta/button.css.map +1 -1
- data/app/components/primer/beta/button.pcss +97 -0
- data/app/components/primer/beta/button.rb +15 -3
- data/app/components/primer/beta/counter.css +1 -1
- data/app/components/primer/beta/counter.css.map +1 -1
- data/app/components/primer/beta/flash.css +1 -1
- data/app/components/primer/beta/flash.css.map +1 -1
- data/app/components/primer/beta/link.css +1 -1
- data/app/components/primer/beta/link.css.json +1 -1
- data/app/components/primer/beta/link.css.map +1 -1
- data/app/components/primer/beta/popover.css +1 -1
- data/app/components/primer/beta/popover.css.map +1 -1
- data/app/components/primer/beta/progress_bar.css +1 -1
- data/app/components/primer/beta/progress_bar.css.map +1 -1
- data/app/components/primer/beta/relative_time.rb +7 -1
- data/app/components/primer/beta/state.css +1 -1
- data/app/components/primer/beta/state.css.json +2 -2
- data/app/components/primer/beta/state.css.map +1 -1
- data/app/components/primer/beta/timeline_item.css +1 -1
- data/app/components/primer/beta/timeline_item.css.map +1 -1
- data/app/components/primer/open_project/border_grid.css +1 -1
- data/app/components/primer/open_project/border_grid.css.map +1 -1
- data/app/components/primer/open_project/color_field.css +1 -1
- data/app/components/primer/open_project/color_field.css.map +1 -1
- data/app/components/primer/open_project/inline_message.css +1 -1
- data/app/components/primer/open_project/inline_message.css.map +1 -1
- data/app/components/primer/open_project/input_group.css +1 -1
- data/app/components/primer/open_project/input_group.css.map +1 -1
- data/app/components/primer/open_project/keybinding_hint/chords.d.ts +5 -0
- data/app/components/primer/open_project/keybinding_hint/chords.js +29 -0
- data/app/components/primer/open_project/keybinding_hint/chords.ts +38 -0
- data/app/components/primer/open_project/keybinding_hint/key_names.d.ts +16 -0
- data/app/components/primer/open_project/keybinding_hint/key_names.js +107 -0
- data/app/components/primer/open_project/keybinding_hint/key_names.ts +116 -0
- data/app/components/primer/open_project/keybinding_hint/localized_names.d.ts +22 -0
- data/app/components/primer/open_project/keybinding_hint/localized_names.js +47 -0
- data/app/components/primer/open_project/keybinding_hint/localized_names.ts +71 -0
- data/app/components/primer/open_project/keybinding_hint/names.rb +92 -0
- data/app/components/primer/open_project/keybinding_hint/names_from_scope.d.ts +21 -0
- data/app/components/primer/open_project/keybinding_hint/names_from_scope.js +81 -0
- data/app/components/primer/open_project/keybinding_hint/names_from_scope.ts +96 -0
- data/app/components/primer/open_project/keybinding_hint/platform.d.ts +10 -0
- data/app/components/primer/open_project/keybinding_hint/platform.js +24 -0
- data/app/components/primer/open_project/keybinding_hint/platform.ts +34 -0
- data/app/components/primer/open_project/keybinding_hint/platform_override.d.ts +2 -0
- data/app/components/primer/open_project/keybinding_hint/platform_override.js +4 -0
- data/app/components/primer/open_project/keybinding_hint/platform_override.ts +7 -0
- data/app/components/primer/open_project/keybinding_hint.css +1 -0
- data/app/components/primer/open_project/keybinding_hint.css.json +10 -0
- data/app/components/primer/open_project/keybinding_hint.css.map +1 -0
- data/app/components/primer/open_project/keybinding_hint.html.erb +4 -0
- data/app/components/primer/open_project/keybinding_hint.pcss +65 -0
- data/app/components/primer/open_project/keybinding_hint.rb +112 -0
- data/app/components/primer/open_project/keybinding_hint_element.d.ts +31 -0
- data/app/components/primer/open_project/keybinding_hint_element.js +183 -0
- data/app/components/primer/open_project/keybinding_hint_element.ts +152 -0
- data/app/components/primer/open_project/page_header.css +1 -1
- data/app/components/primer/open_project/page_header.css.json +2 -2
- data/app/components/primer/open_project/page_header.css.map +1 -1
- data/app/components/primer/open_project/pagination.css +1 -1
- data/app/components/primer/open_project/pagination.css.json +1 -1
- data/app/components/primer/open_project/pagination.css.map +1 -1
- data/app/components/primer/open_project/sub_header.css +1 -1
- data/app/components/primer/open_project/sub_header.css.map +1 -1
- data/app/components/primer/primer.d.ts +1 -0
- data/app/components/primer/primer.js +1 -0
- data/app/components/primer/primer.pcss +1 -0
- data/app/components/primer/primer.ts +1 -0
- data/app/components/primer/truncate.css +1 -1
- data/app/components/primer/truncate.css.json +3 -4
- data/app/components/primer/truncate.css.map +1 -1
- data/app/controllers/primer/view_components/action_menu_controller.rb +35 -0
- data/app/views/primer/view_components/action_menu/deferred.html.erb +25 -11
- data/app/views/primer/view_components/action_menu/deferred_form.html.erb +10 -0
- data/app/views/primer/view_components/action_menu/deferred_preload.html.erb +7 -1
- data/config/locales/en.yml +179 -0
- data/config/routes.rb +1 -0
- data/lib/primer/accessibility.rb +1 -2
- data/lib/primer/classify.rb +1 -2
- data/lib/primer/view_components/version.rb +1 -1
- data/previews/primer/alpha/action_menu_preview/deferred_refresh.html.erb +34 -0
- data/previews/primer/alpha/action_menu_preview/deferred_refresh_form.html.erb +9 -0
- data/previews/primer/alpha/action_menu_preview.rb +14 -0
- data/previews/primer/open_project/keybinding_hint_preview/full_format.html.erb +3 -0
- data/previews/primer/open_project/keybinding_hint_preview/in_action_list.html.erb +12 -0
- data/previews/primer/open_project/keybinding_hint_preview/in_button.html.erb +24 -0
- data/previews/primer/open_project/keybinding_hint_preview/platforms.html.erb +8 -0
- data/previews/primer/open_project/keybinding_hint_preview/playground.html.erb +4 -0
- data/previews/primer/open_project/keybinding_hint_preview/prose.html.erb +3 -0
- data/previews/primer/open_project/keybinding_hint_preview/schemes.html.erb +6 -0
- data/previews/primer/open_project/keybinding_hint_preview/sequence.html.erb +1 -0
- data/previews/primer/open_project/keybinding_hint_preview/sizes.html.erb +4 -0
- data/previews/primer/open_project/keybinding_hint_preview.rb +71 -0
- data/static/arguments.json +53 -1
- data/static/audited_at.json +1 -0
- data/static/classes.json +12 -0
- data/static/classnames.cjs +4 -0
- data/static/classnames.js +4 -0
- data/static/constants.json +35 -0
- data/static/info_arch.json +234 -8
- data/static/previews.json +164 -0
- data/static/statuses.json +1 -0
- metadata +42 -5
- data/app/components/primer/alpha/text_field.css.json +0 -134
- data/app/components/primer/alpha/toggle_switch.css.json +0 -40
- data/app/components/primer/alpha/underline_nav.css.json +0 -26
- data/app/components/primer/beta/button.css.json +0 -86
|
@@ -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 };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import {attr, controller} from '@github/catalyst'
|
|
2
|
+
import {html, render, nothing} from 'lit-html'
|
|
3
|
+
import type {TemplateResult} from 'lit-html'
|
|
4
|
+
import {detectPlatform} from './keybinding_hint/platform'
|
|
5
|
+
import {isPlatform} from './keybinding_hint/platform_override'
|
|
6
|
+
import type {Platform} from './keybinding_hint/platform'
|
|
7
|
+
import {keyName, parseKeyNames} from './keybinding_hint/localized_names'
|
|
8
|
+
import type {KeyNames} from './keybinding_hint/localized_names'
|
|
9
|
+
import {buildKeyNames} from './keybinding_hint/names_from_scope'
|
|
10
|
+
import {splitSequence} from './keybinding_hint/chords'
|
|
11
|
+
|
|
12
|
+
type Format = 'condensed' | 'full'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Renders keyboard shortcut hints client-side, because only the browser knows
|
|
16
|
+
* the platform (⌘ vs ⌃). The server renders a plain-text fallback inside the
|
|
17
|
+
* chord box; this element replaces it once, then owns a <kbd> mount that
|
|
18
|
+
* lit-html renders into.
|
|
19
|
+
*
|
|
20
|
+
* Attributes (Catalyst `@attr`, so `data-*`): keys, format, scheme, size,
|
|
21
|
+
* platform ('' = detect; 'apple' | 'windows' | 'other' overrides, used by
|
|
22
|
+
* previews and tests), names (JSON of translated key names; see
|
|
23
|
+
* localized_names.ts).
|
|
24
|
+
*/
|
|
25
|
+
@controller('keybinding-hint')
|
|
26
|
+
export class KeybindingHintElement extends HTMLElement {
|
|
27
|
+
/** Builds `data-names` from i18n-js scopes, for hosts that render hints client-side. */
|
|
28
|
+
static buildNames = buildKeyNames
|
|
29
|
+
|
|
30
|
+
@attr keys = ''
|
|
31
|
+
@attr format = 'condensed'
|
|
32
|
+
@attr scheme = 'default'
|
|
33
|
+
@attr size = 'medium'
|
|
34
|
+
@attr platform = ''
|
|
35
|
+
@attr names = ''
|
|
36
|
+
|
|
37
|
+
#mount: HTMLElement | null = null
|
|
38
|
+
#signature = ''
|
|
39
|
+
// Whether the mount still holds exactly what lit last rendered. Any
|
|
40
|
+
// mutation we did not make (Turbo morph, stream update, manual innerHTML,
|
|
41
|
+
// even inside a single chord) revokes it, because lit would otherwise
|
|
42
|
+
// update detached markers and leave the foreign content on screen.
|
|
43
|
+
#owned = false
|
|
44
|
+
// Every mutation we make is drained with takeRecords() straight after, so
|
|
45
|
+
// any record that is delivered here or still queued in #update is external.
|
|
46
|
+
#observer = new MutationObserver(() => {
|
|
47
|
+
this.#owned = false
|
|
48
|
+
this.#update()
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
connectedCallback() {
|
|
52
|
+
this.#observer.observe(this, {childList: true, subtree: true, characterData: true})
|
|
53
|
+
this.#update()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
disconnectedCallback() {
|
|
57
|
+
// Mutations while detached go unobserved, so re-render on reconnect.
|
|
58
|
+
this.#observer.disconnect()
|
|
59
|
+
this.#owned = false
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
attributeChangedCallback() {
|
|
63
|
+
// Catalyst fires this for every observed attribute before connectedCallback
|
|
64
|
+
// and once more for each default it writes; #update is idempotent and cheap.
|
|
65
|
+
this.#update()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#update() {
|
|
69
|
+
if (!this.isConnected) return
|
|
70
|
+
|
|
71
|
+
const platform = this.#resolvedPlatform()
|
|
72
|
+
const chords = splitSequence(this.keys, platform)
|
|
73
|
+
const signature = [this.keys, this.format, this.scheme, this.size, platform, this.names].join('\u0000')
|
|
74
|
+
// Catches an external mutation made in the same task as an attribute
|
|
75
|
+
// change, before the observer callback has run.
|
|
76
|
+
if (this.#observer.takeRecords().length > 0) this.#owned = false
|
|
77
|
+
const owned = this.#owned && this.#mount !== null
|
|
78
|
+
|
|
79
|
+
if (owned && signature === this.#signature) return
|
|
80
|
+
|
|
81
|
+
if (chords.length === 0) {
|
|
82
|
+
// Blank keys: render nothing, drop the fallback and any previous mount.
|
|
83
|
+
if (this.hasChildNodes()) this.replaceChildren()
|
|
84
|
+
this.#observer.takeRecords()
|
|
85
|
+
this.#mount = null
|
|
86
|
+
this.#owned = false
|
|
87
|
+
this.#signature = signature
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!owned) {
|
|
92
|
+
// First render, or something (Turbo morph, manual innerHTML) replaced our
|
|
93
|
+
// content with fresh server markup. A new mount gives lit a fresh
|
|
94
|
+
// container; reusing the old one would hit lit's detached markers.
|
|
95
|
+
this.#mount = document.createElement('kbd')
|
|
96
|
+
this.#mount.className = 'KeybindingHint-kbd'
|
|
97
|
+
this.replaceChildren(this.#mount)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const target = this.#mount as HTMLElement
|
|
101
|
+
render(this.#template(chords, platform, parseKeyNames(this.names)), target)
|
|
102
|
+
// Drop the records of our own render so they cannot re-enter #update.
|
|
103
|
+
this.#observer.takeRecords()
|
|
104
|
+
this.#owned = true
|
|
105
|
+
this.#signature = signature
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
#resolvedPlatform(): Platform {
|
|
109
|
+
return isPlatform(this.platform) ? this.platform : detectPlatform()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#resolvedFormat(): Format {
|
|
113
|
+
return this.format === 'full' ? 'full' : 'condensed'
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
#chordClass(): string {
|
|
117
|
+
const classes = ['KeybindingHint-chord']
|
|
118
|
+
if (this.scheme === 'emphasis') classes.push('KeybindingHint-chord--emphasis')
|
|
119
|
+
if (this.size === 'small') classes.push('KeybindingHint-chord--small')
|
|
120
|
+
return classes.join(' ')
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
#template(chords: string[][], platform: Platform, names: KeyNames): TemplateResult[] {
|
|
124
|
+
const format = this.#resolvedFormat()
|
|
125
|
+
const chordClass = this.#chordClass()
|
|
126
|
+
// Whitespace text nodes are deliberate: they give screen readers word
|
|
127
|
+
// boundaries between hidden labels. Inside the inline-flex chord they do
|
|
128
|
+
// not render; between chords the two around "then" collapse into the one
|
|
129
|
+
// visible separator (as in React).
|
|
130
|
+
return chords.map(
|
|
131
|
+
(keys, chordIndex) =>
|
|
132
|
+
html`${chordIndex > 0 ? html` <span class="sr-only">${names.separator ?? 'then'}</span> ` : nothing}<span
|
|
133
|
+
class="${chordClass}"
|
|
134
|
+
data-kbd-chord
|
|
135
|
+
>${keys.map((key, keyIndex) => this.#keyTemplate(key, keyIndex, format, platform, names))}</span
|
|
136
|
+
>`,
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
#keyTemplate(key: string, index: number, format: Format, platform: Platform, names: KeyNames): TemplateResult {
|
|
141
|
+
const visible = keyName(names, key, format, platform)
|
|
142
|
+
const separator = index === 0 ? nothing : format === 'full' ? html` <span aria-hidden="true"> + </span> ` : ' '
|
|
143
|
+
return html`${separator}<span class="sr-only">${keyName(names, key, 'accessible', platform)}</span
|
|
144
|
+
><span aria-hidden="true">${visible}</span>`
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
declare global {
|
|
149
|
+
interface Window {
|
|
150
|
+
KeybindingHintElement: typeof KeybindingHintElement
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.PageHeader{display:flex;padding-bottom:var(--base-size-8);margin-bottom:var(--base-size-16);border-bottom:var(--borderWidth-thin) solid var(--borderColor-muted);flex-flow:column}.PageHeader--withTabNav{border-bottom:none;padding-bottom:0;margin-bottom:0}.PageHeader-contextBar{height:var(--control-small-size)}.PageHeader-contextBar,.PageHeader-titleBar{display:flex;flex-flow:row;justify-content:flex-end;align-items:center;margin-bottom:var(--base-size-8)}.PageHeader-title{font-size:var(--text-title-size-medium);flex:1 1 auto}.PageHeader-title--large{font-size:var(--text-title-size-large)}.PageHeader-description{font-size:var(--text-body-size-medium);color:var(--fgColor-muted);flex:1 auto}.PageHeader-description--underlined-links a{-webkit-text-decoration:underline;text-decoration:underline}.PageHeader-tabNavBar{overflow:auto}.PageHeader-tabNavBar .PageHeader-tabNav{min-width:max-content}.PageHeader--withTabNav .PageHeader-description{margin-bottom:var(--base-size-16)}.PageHeader-actions{justify-content:flex-end;display:flex;align-items:center}.PageHeader-breadcrumbs{display:block;width:100%}.PageHeader-leadingAction{margin-top:var(--base-size-2);margin-right:var(--base-size-4)}.PageHeader-parentLink{flex:1 1 auto}@media screen and (min-width:543.98px){.PageHeader--noBreadcrumb .PageHeader-contextBar{display:none}}.PageHeader--noBreadcrumb .PageHeader-titleBar{line-height:var(--control-small-size)}
|
|
1
|
+
.PageHeader{display:flex;padding-bottom:var(--base-size-8);margin-bottom:var(--base-size-16);border-bottom:var(--borderWidth-thin) solid var(--borderColor-muted);flex-flow:column}.PageHeader--withTabNav{border-bottom:none;padding-bottom:0;margin-bottom:0}.PageHeader--noBreadcrumb .PageHeader-actions,.PageHeader-contextBar{height:var(--control-small-size)}.PageHeader-contextBar,.PageHeader-titleBar{display:flex;flex-flow:row;justify-content:flex-end;align-items:center;margin-bottom:var(--base-size-8)}.PageHeader-title{font-size:var(--text-title-size-medium);flex:1 1 auto}.PageHeader-title--large{font-size:var(--text-title-size-large)}.PageHeader-description{font-size:var(--text-body-size-medium);color:var(--fgColor-muted);flex:1 auto}.PageHeader-description--underlined-links a{-webkit-text-decoration:underline;text-decoration:underline}.PageHeader-tabNavBar{overflow:auto}.PageHeader-tabNavBar .PageHeader-tabNav{min-width:max-content}.PageHeader--withTabNav .PageHeader-description{margin-bottom:var(--base-size-16)}.PageHeader-actions{justify-content:flex-end;display:flex;align-items:center}.PageHeader-breadcrumbs{display:block;width:100%}.PageHeader-leadingAction{margin-top:var(--base-size-2);margin-right:var(--base-size-4)}.PageHeader-parentLink{flex:1 1 auto}@media screen and (min-width:543.98px){.PageHeader--noBreadcrumb .PageHeader-contextBar{display:none}}.PageHeader--noBreadcrumb .PageHeader-titleBar{line-height:var(--control-small-size)}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
"selectors": [
|
|
4
4
|
".PageHeader",
|
|
5
5
|
".PageHeader--withTabNav",
|
|
6
|
+
".PageHeader--noBreadcrumb .PageHeader-actions",
|
|
6
7
|
".PageHeader-contextBar",
|
|
7
8
|
".PageHeader-titleBar",
|
|
8
9
|
".PageHeader-title",
|
|
@@ -17,7 +18,6 @@
|
|
|
17
18
|
".PageHeader-leadingAction",
|
|
18
19
|
".PageHeader-parentLink",
|
|
19
20
|
".PageHeader--noBreadcrumb .PageHeader-contextBar",
|
|
20
|
-
".PageHeader--noBreadcrumb .PageHeader-titleBar"
|
|
21
|
-
".PageHeader--noBreadcrumb .PageHeader-actions"
|
|
21
|
+
".PageHeader--noBreadcrumb .PageHeader-titleBar"
|
|
22
22
|
]
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["page_header.pcss"],"names":[],"mappings":"AAEA,YACE,YAAa,CACb,iCAAkC,CAClC,iCAAkC,CAClC,oEAAqE,CACrE,gBACF,CAEA,wBACE,kBAAmB,CACnB,gBAAiB,CACjB,eACF,CAEA,
|
|
1
|
+
{"version":3,"sources":["page_header.pcss"],"names":[],"mappings":"AAEA,YACE,YAAa,CACb,iCAAkC,CAClC,iCAAkC,CAClC,oEAAqE,CACrE,gBACF,CAEA,wBACE,kBAAmB,CACnB,gBAAiB,CACjB,eACF,CAEA,qEAME,gCACF,CAEA,4CARE,YAAa,CACb,aAAc,CACd,wBAAyB,CACzB,kBAAmB,CACnB,gCAUF,CAEA,kBACE,uCAAwC,CACxC,aACF,CAEA,yBACE,sCACF,CAGA,wBACE,sCAAuC,CACvC,0BAA2B,CAC3B,WACF,CAGA,4CAEE,iCAA0B,CAA1B,yBACF,CAEA,sBACE,aACF,CAEA,yCACE,qBACF,CAEA,gDACE,iCACF,CAEA,oBACE,wBAAyB,CACzB,YAAa,CACb,kBACF,CAEA,wBACE,aAAc,CACd,UACF,CAEA,0BACE,6BAA8B,CAC9B,+BACF,CAEA,uBACE,aACF,CAGA,uCACE,iDACE,YACF,CACF,CAIE,+CAEE,qCACF","file":"page_header.css","sourcesContent":["/* OP PageHeader */\n\n.PageHeader {\n display: flex;\n padding-bottom: var(--base-size-8);\n margin-bottom: var(--base-size-16);\n border-bottom: var(--borderWidth-thin) solid var(--borderColor-muted);\n flex-flow: column;\n}\n\n.PageHeader--withTabNav {\n border-bottom: none;\n padding-bottom: 0;\n margin-bottom: 0;\n}\n\n.PageHeader-contextBar {\n display: flex;\n flex-flow: row;\n justify-content: flex-end;\n align-items: center;\n margin-bottom: var(--base-size-8);\n height: var(--control-small-size);\n}\n\n.PageHeader-titleBar {\n display: flex;\n flex-flow: row;\n justify-content: flex-end;\n align-items: center; /* Keep back button vertically aligned. */\n margin-bottom: var(--base-size-8);\n}\n\n.PageHeader-title {\n font-size: var(--text-title-size-medium);\n flex: 1 1 auto;\n}\n\n.PageHeader-title--large {\n font-size: var(--text-title-size-large);\n}\n\n/* One-liner of supporting text */\n.PageHeader-description {\n font-size: var(--text-body-size-medium);\n color: var(--fgColor-muted);\n flex: 1 auto;\n}\n\n/* stylelint-disable-next-line selector-max-type -- description holds rich text; links can only be targeted by the `a` type selector */\n.PageHeader-description--underlined-links a {\n /* Ensure the accessibility is met, given that the description is written in light grey */\n text-decoration: underline;\n}\n\n.PageHeader-tabNavBar {\n overflow: auto;\n}\n\n.PageHeader-tabNavBar .PageHeader-tabNav {\n min-width: max-content;\n}\n\n.PageHeader--withTabNav .PageHeader-description {\n margin-bottom: var(--base-size-16);\n}\n\n.PageHeader-actions {\n justify-content: flex-end;\n display: flex;\n align-items: center;\n}\n\n.PageHeader-breadcrumbs {\n display: block;\n width: 100%;\n}\n\n.PageHeader-leadingAction {\n margin-top: var(--base-size-2); /* to center align with label */\n margin-right: var(--base-size-4);\n}\n\n.PageHeader-parentLink {\n flex: 1 1 auto;\n}\n\n/* Hide the context bar on desktop when no breadcrumb is visible */\n@media screen and (min-width: 543.98px) {\n .PageHeader--noBreadcrumb .PageHeader-contextBar {\n display: none;\n }\n}\n\n/* Match the title bar and actions height with the toggle menu button for proper vertical alignment */\n.PageHeader--noBreadcrumb {\n & .PageHeader-titleBar {\n /* stylelint-disable-next-line primer/typography -- control size var intentionally matches the toggle-menu button height for vertical alignment */\n line-height: var(--control-small-size);\n }\n\n & .PageHeader-actions {\n height: var(--control-small-size);\n }\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.Page{min-width:var(--base-size-32);height:var(--base-size-32);padding:var(--base-size-8) var(--base-size-6);margin-right:var(--base-size-4);color:var(--fgColor-default);white-space:nowrap;vertical-align:middle;cursor:pointer;border-radius:var(--borderRadius-medium);transition:background-color .2s cubic-bezier(.3,0,.5,1);display:inline-flex;align-items:center;justify-content:center}.Page[rel=next]>svg,.Page[rel=prev]>svg{height:var(--base-size-16);width:var(--base-size-16)}.Page[rel=prev]>svg{margin-inline-end:var(--base-size-4)}.Page[rel=next]>svg{margin-inline-start:var(--base-size-4)}.Page:last-child{margin-right:0}.Page:focus,.Page:hover{-webkit-text-decoration:none;text-decoration:none;background-color:var(--control-transparent-bgColor-hover);outline:0;transition-duration:.1s}.Page:focus-visible{outline:2px solid var(--bgColor-accent-emphasis)}.Page:active{border-color:var(--borderColor-muted)}.Page[rel=next],.Page[rel=prev]{color:var(--fgColor-accent)}.Page[aria-current],.Page[aria-current]:hover{color:var(--fgColor-onEmphasis);background-color:var(--bgColor-accent-emphasis);border-color:#0000}.Page[aria-current]:focus-visible{
|
|
1
|
+
.Page{min-width:var(--base-size-32);height:var(--base-size-32);padding:var(--base-size-8) var(--base-size-6);margin-right:var(--base-size-4);color:var(--fgColor-default);white-space:nowrap;vertical-align:middle;cursor:pointer;border-radius:var(--borderRadius-medium);transition:background-color .2s cubic-bezier(.3,0,.5,1);display:inline-flex;align-items:center;justify-content:center}.Page[rel=next]>svg,.Page[rel=prev]>svg{height:var(--base-size-16);width:var(--base-size-16)}.Page[rel=prev]>svg{margin-inline-end:var(--base-size-4)}.Page[rel=next]>svg{margin-inline-start:var(--base-size-4)}.Page:last-child{margin-right:0}.Page:focus,.Page:hover{-webkit-text-decoration:none;text-decoration:none;background-color:var(--control-transparent-bgColor-hover);outline:0;transition-duration:.1s}.Page:focus-visible,.Page[aria-current]:focus-visible{outline:2px solid var(--bgColor-accent-emphasis)}.Page:active{border-color:var(--borderColor-muted)}.Page[rel=next],.Page[rel=prev]{color:var(--fgColor-accent)}.Page[aria-current],.Page[aria-current]:hover{color:var(--fgColor-onEmphasis);background-color:var(--bgColor-accent-emphasis);border-color:#0000}.Page[aria-current]:focus-visible{box-shadow:inset 0 0 0 var(--base-size-2) var(--fgColor-onEmphasis)}.Page[aria-hidden],.Page[aria-hidden]:hover,.Page[role=presentation],.Page[role=presentation]:hover{color:var(--fgColor-disabled);cursor:default;background-color:initial}.PaginationContainer{margin:var(--base-size-16) 0;text-align:center}@media(max-width:543.98px){.Page:not([rel=prev]):not([rel=next]){display:none}}
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
".Page:focus",
|
|
9
9
|
".Page:hover",
|
|
10
10
|
".Page:focus-visible",
|
|
11
|
+
".Page[aria-current]:focus-visible",
|
|
11
12
|
".Page:active",
|
|
12
13
|
".Page[rel=next]",
|
|
13
14
|
".Page[rel=prev]",
|
|
14
15
|
".Page[aria-current]",
|
|
15
16
|
".Page[aria-current]:hover",
|
|
16
|
-
".Page[aria-current]:focus-visible",
|
|
17
17
|
".Page[aria-hidden]",
|
|
18
18
|
".Page[aria-hidden]:hover",
|
|
19
19
|
".Page[role=presentation]",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["pagination.pcss"],"names":[],"mappings":"AAEA,MACE,6BAA8B,CAC9B,0BAA2B,CAC3B,6CAA8C,CAC9C,+BAAgC,CAChC,4BAA6B,CAC7B,kBAAmB,CACnB,qBAAsB,CACtB,cAAe,CACf,wCAAyC,CACzC,uDAA8D,CAC9D,mBAAoB,CACpB,kBAAmB,CACnB,sBACF,CAEA,wCAEE,0BAA2B,CAC3B,yBACF,CAEA,oBACE,oCACF,CAEA,oBACE,sCACF,CAEA,iBACE,cACF,CAEA,wBAEE,4BAAqB,CAArB,oBAAqB,CACrB,yDAA0D,CAC1D,SAAU,CACV,uBACF,CAEA,
|
|
1
|
+
{"version":3,"sources":["pagination.pcss"],"names":[],"mappings":"AAEA,MACE,6BAA8B,CAC9B,0BAA2B,CAC3B,6CAA8C,CAC9C,+BAAgC,CAChC,4BAA6B,CAC7B,kBAAmB,CACnB,qBAAsB,CACtB,cAAe,CACf,wCAAyC,CACzC,uDAA8D,CAC9D,mBAAoB,CACpB,kBAAmB,CACnB,sBACF,CAEA,wCAEE,0BAA2B,CAC3B,yBACF,CAEA,oBACE,oCACF,CAEA,oBACE,sCACF,CAEA,iBACE,cACF,CAEA,wBAEE,4BAAqB,CAArB,oBAAqB,CACrB,yDAA0D,CAC1D,SAAU,CACV,uBACF,CAEA,sDACE,gDACF,CAEA,aACE,qCACF,CAEA,gCAEE,2BACF,CAEA,8CAEE,+BAAgC,CAChC,+CAAgD,CAChD,kBACF,CAEA,kCAGE,mEACF,CAEA,oGAIE,6BAA8B,CAC9B,cAAe,CACf,wBACF,CAEA,qBACE,4BAA6B,CAC7B,iBACF,CAEA,2BACE,sCACE,YACF,CACF","file":"pagination.css","sourcesContent":["/* stylelint-disable selector-max-type -- pagination arrows are styled via `.Page[rel] > svg`; the svg icon can only be targeted by its type selector */\n\n.Page {\n min-width: var(--base-size-32);\n height: var(--base-size-32);\n padding: var(--base-size-8) var(--base-size-6);\n margin-right: var(--base-size-4);\n color: var(--fgColor-default);\n white-space: nowrap;\n vertical-align: middle;\n cursor: pointer;\n border-radius: var(--borderRadius-medium);\n transition: background-color 0.2s cubic-bezier(0.3, 0, 0.5, 1);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n}\n\n.Page[rel='prev'] > svg,\n.Page[rel='next'] > svg {\n height: var(--base-size-16);\n width: var(--base-size-16);\n}\n\n.Page[rel='prev'] > svg {\n margin-inline-end: var(--base-size-4);\n}\n\n.Page[rel='next'] > svg {\n margin-inline-start: var(--base-size-4);\n}\n\n.Page:last-child {\n margin-right: 0;\n}\n\n.Page:hover,\n.Page:focus {\n text-decoration: none;\n background-color: var(--control-transparent-bgColor-hover);\n outline: 0;\n transition-duration: 0.1s;\n}\n\n.Page:focus-visible {\n outline: 2px solid var(--bgColor-accent-emphasis);\n}\n\n.Page:active {\n border-color: var(--borderColor-muted);\n}\n\n.Page[rel='prev'],\n.Page[rel='next'] {\n color: var(--fgColor-accent);\n}\n\n.Page[aria-current],\n.Page[aria-current]:hover {\n color: var(--fgColor-onEmphasis);\n background-color: var(--bgColor-accent-emphasis);\n border-color: transparent;\n}\n\n.Page[aria-current]:focus-visible {\n outline: 2px solid var(--bgColor-accent-emphasis);\n /* stylelint-disable-next-line primer/box-shadow -- custom focus-ring built from Primer size/color primitives; no single Primer box-shadow token matches */\n box-shadow: inset 0 0 0 var(--base-size-2) var(--fgColor-onEmphasis);\n}\n\n.Page[aria-hidden],\n.Page[aria-hidden]:hover,\n.Page[role='presentation'],\n.Page[role='presentation']:hover {\n color: var(--fgColor-disabled);\n cursor: default;\n background-color: transparent;\n}\n\n.PaginationContainer {\n margin: var(--base-size-16) 0;\n text-align: center;\n}\n\n@media (max-width: 543.98px){\n .Page:not([rel='prev']):not([rel='next']) {\n display: none;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.SubHeader{display:grid;grid-template-areas:"left middle right" "bottom bottom bottom";grid-template-columns:auto 1fr auto;align-items:baseline;margin-bottom:var(--base-size-16)}.SubHeader-rightPane{grid-area:right;display:flex;align-items:center;column-gap:12px}.SubHeader-middlePane{grid-area:middle;text-align:center;white-space:nowrap}.SubHeader-bottomPane{grid-area:bottom}.SubHeader-leftPane{grid-area:left;display:flex;align-items:center;flex-wrap:wrap;row-gap:var(--base-size-16);width:100%}:is(.SubHeader-leftPane [class*=FormControl-input-width--]):not(.FormControl-input-width--auto){width:100vw}.SubHeader-filterContainer{display:flex;flex-basis:max-content;width:100%;gap:8px}.SubHeader-filterInput_hiddenClearButton+.FormControl-input-trailingAction{display:none}@media
|
|
1
|
+
.SubHeader{display:grid;grid-template-areas:"left middle right" "bottom bottom bottom";grid-template-columns:auto 1fr auto;align-items:baseline;margin-bottom:var(--base-size-16)}.SubHeader-rightPane{grid-area:right;display:flex;align-items:center;column-gap:12px}.SubHeader-middlePane{grid-area:middle;text-align:center;white-space:nowrap}.SubHeader-bottomPane{grid-area:bottom}.SubHeader-leftPane{grid-area:left;display:flex;align-items:center;flex-wrap:wrap;row-gap:var(--base-size-16);width:100%}:is(.SubHeader-leftPane [class*=FormControl-input-width--]):not(.FormControl-input-width--auto){width:100vw}.SubHeader-filterContainer{display:flex;flex-basis:max-content;width:100%;gap:8px}.SubHeader-filterInput_hiddenClearButton+.FormControl-input-trailingAction{display:none}@media(max-width:767.98px){.SubHeader{grid-template-areas:"left right" "middle middle" "bottom bottom";grid-template-columns:1fr auto}.SubHeader--expandedSearch{grid-template-areas:"left left" "middle middle" "bottom bottom"}.SubHeader--expandedSearch .SubHeader-hiddenOnExpand{display:none!important}.SubHeader--emptyLeftPane{grid-template-areas:"middle middle right" "bottom bottom bottom";grid-template-columns:auto 1fr auto}.SubHeader--emptyLeftPane .SubHeader-middlePane{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.SubHeader-middlePane{text-align:left}.SubHeader-middlePane:has(>*){margin-top:var(--base-size-16)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["sub_header.pcss"],"names":[],"mappings":"AAEA,WACI,YAAa,CACb,8DAA+D,CAC/D,mCAAoC,CACpC,oBAAqB,CACrB,iCACJ,CAEA,qBACI,eAAgB,CAChB,YAAa,CACb,kBAAmB,CACnB,eACJ,CAEA,sBACI,gBAAiB,CACjB,iBAAkB,CAClB,kBACJ,CAEA,sBACI,gBACJ,CAEA,oBACI,cAAe,CACf,YAAa,CACb,kBAAmB,CACnB,cAAe,CACf,2BAA4B,CAC5B,UASJ,CAJQ,gGACI,WACJ,CAIR,2BACI,YAAa,CACb,sBAAuB,CACvB,UAAW,CACX,OACJ,CAEA,2EACE,YACF,CAEA,
|
|
1
|
+
{"version":3,"sources":["sub_header.pcss"],"names":[],"mappings":"AAEA,WACI,YAAa,CACb,8DAA+D,CAC/D,mCAAoC,CACpC,oBAAqB,CACrB,iCACJ,CAEA,qBACI,eAAgB,CAChB,YAAa,CACb,kBAAmB,CACnB,eACJ,CAEA,sBACI,gBAAiB,CACjB,iBAAkB,CAClB,kBACJ,CAEA,sBACI,gBACJ,CAEA,oBACI,cAAe,CACf,YAAa,CACb,kBAAmB,CACnB,cAAe,CACf,2BAA4B,CAC5B,UASJ,CAJQ,gGACI,WACJ,CAIR,2BACI,YAAa,CACb,sBAAuB,CACvB,UAAW,CACX,OACJ,CAEA,2EACE,YACF,CAEA,2BACI,WACI,gEAAiE,CACjE,8BACJ,CAEA,2BACI,+DACJ,CAEA,qDACI,sBACJ,CAEA,0BACI,gEAAiE,CACjE,mCACJ,CAEA,gDACI,kBAAmB,CACnB,sBAAuB,CACvB,eACJ,CAEA,sBACI,eACJ,CAEA,8BACI,8BACJ,CACJ","file":"sub_header.css","sourcesContent":["/* CSS for SubHeader */\n\n.SubHeader {\n display: grid;\n grid-template-areas: \"left middle right\" \"bottom bottom bottom\";\n grid-template-columns: auto 1fr auto;\n align-items: baseline;\n margin-bottom: var(--base-size-16);\n}\n\n.SubHeader-rightPane {\n grid-area: right;\n display: flex;\n align-items: center;\n column-gap: 12px;\n}\n\n.SubHeader-middlePane {\n grid-area: middle;\n text-align: center;\n white-space: nowrap;\n}\n\n.SubHeader-bottomPane {\n grid-area: bottom;\n}\n\n.SubHeader-leftPane {\n grid-area: left;\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n row-gap: var(--base-size-16);\n width: 100%;\n\n /* Since the container is not full width (due to the grid around it)\n we want it to grow, and then be limited by the max-width of the \"FormControl-input-width--xy\" class */\n & [class*='FormControl-input-width--'] {\n &:not(.FormControl-input-width--auto) {\n width: 100vw;\n }\n }\n}\n\n.SubHeader-filterContainer {\n display: flex;\n flex-basis: max-content;\n width: 100%;\n gap: 8px;\n}\n\n.SubHeader-filterInput_hiddenClearButton + .FormControl-input-trailingAction {\n display: none;\n}\n\n@media (max-width: 767.98px) {\n .SubHeader {\n grid-template-areas: \"left right\" \"middle middle\" \"bottom bottom\";\n grid-template-columns: 1fr auto;\n }\n\n .SubHeader--expandedSearch {\n grid-template-areas: \"left left\" \"middle middle\" \"bottom bottom\";\n }\n\n .SubHeader--expandedSearch .SubHeader-hiddenOnExpand {\n display: none !important;\n }\n\n .SubHeader--emptyLeftPane {\n grid-template-areas: \"middle middle right\" \"bottom bottom bottom\";\n grid-template-columns: auto 1fr auto;\n }\n\n .SubHeader--emptyLeftPane .SubHeader-middlePane {\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n }\n\n .SubHeader-middlePane {\n text-align: left;\n }\n\n .SubHeader-middlePane:has(> *) {\n margin-top: var(--base-size-16);\n }\n}\n"]}
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
@import "./open_project/input_group.pcss";
|
|
53
53
|
@import "./open_project/color_field.pcss";
|
|
54
54
|
@import "./open_project/inline_message.pcss";
|
|
55
|
+
@import "./open_project/keybinding_hint.pcss";
|
|
55
56
|
@import "./open_project/sub_header.pcss";
|
|
56
57
|
@import "./open_project/side_panel/section.pcss";
|
|
57
58
|
@import "./open_project/border_box/collapsible_header.pcss";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.css-truncate .css-truncate-overflow,.css-truncate
|
|
1
|
+
.css-truncate :is(.css-truncate-overflow,.css-truncate-target),.css-truncate.css-truncate-overflow,.css-truncate.css-truncate-target{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.css-truncate .css-truncate-target,.css-truncate.css-truncate-target{display:inline-block;max-width:125px;vertical-align:top}.css-truncate.expandable.css-truncate-target:hover,.css-truncate.expandable.zeroclipboard-is-hover.css-truncate-target,:is(.css-truncate.expandable.zeroclipboard-is-hover,.css-truncate.expandable:hover) .css-truncate-target{max-width:1e4px!important}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "truncate",
|
|
3
3
|
"selectors": [
|
|
4
|
-
".css-truncate .css-truncate-overflow",
|
|
5
|
-
".css-truncate .css-truncate-target",
|
|
4
|
+
".css-truncate :is(.css-truncate-overflow,.css-truncate-target)",
|
|
6
5
|
".css-truncate.css-truncate-overflow",
|
|
7
6
|
".css-truncate.css-truncate-target",
|
|
7
|
+
".css-truncate .css-truncate-target",
|
|
8
8
|
".css-truncate.expandable.css-truncate-target:hover",
|
|
9
|
-
".css-truncate.expandable.zeroclipboard-is-hover .css-truncate-target",
|
|
10
9
|
".css-truncate.expandable.zeroclipboard-is-hover.css-truncate-target",
|
|
11
|
-
".css-truncate.expandable:hover .css-truncate-target"
|
|
10
|
+
":is(.css-truncate.expandable.zeroclipboard-is-hover,.css-truncate.expandable:hover) .css-truncate-target"
|
|
12
11
|
]
|
|
13
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["truncate.pcss"],"names":[],"mappings":"AAME,
|
|
1
|
+
{"version":3,"sources":["truncate.pcss"],"names":[],"mappings":"AAME,qIAIE,eAAgB,CAChB,sBAAuB,CACvB,kBACF,CAGA,qEAEE,oBAAqB,CACrB,eAAgB,CAChB,kBACF,CAEA,gOAIE,yBACF","file":"truncate.css","sourcesContent":["/* CSS truncate */\n\n/* css-truncate will shorten text with an ellipsis. */\n\n.css-truncate {\n /* css-truncate-overflow will shorten text with an ellipsis when overflowing */\n &.css-truncate-overflow,\n & .css-truncate-overflow,\n &.css-truncate-target,\n & .css-truncate-target {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n /* css-truncate-target will shorten text with an ellipsis and a max width */\n &.css-truncate-target,\n & .css-truncate-target {\n display: inline-block;\n max-width: 125px;\n vertical-align: top;\n }\n\n &.expandable.zeroclipboard-is-hover .css-truncate-target,\n &.expandable.zeroclipboard-is-hover.css-truncate-target,\n &.expandable:hover .css-truncate-target,\n &.expandable:hover.css-truncate-target {\n max-width: 10000px !important;\n }\n}\n"]}
|
|
@@ -11,13 +11,33 @@ module Primer
|
|
|
11
11
|
|
|
12
12
|
def deferred
|
|
13
13
|
sleep params[:delay].to_f if params[:delay].present?
|
|
14
|
+
status = request_gate_status
|
|
15
|
+
return head(status) unless status == 200
|
|
16
|
+
return render(html: "") if params[:empty].present?
|
|
17
|
+
|
|
18
|
+
assign_deferred_params
|
|
14
19
|
render "primer/view_components/action_menu/deferred"
|
|
15
20
|
end
|
|
16
21
|
|
|
17
22
|
def deferred_preload
|
|
23
|
+
status = request_gate_status
|
|
24
|
+
return head(status) unless status == 200
|
|
25
|
+
|
|
26
|
+
assign_deferred_params
|
|
18
27
|
render "primer/view_components/action_menu/deferred_preload"
|
|
19
28
|
end
|
|
20
29
|
|
|
30
|
+
def deferred_form
|
|
31
|
+
status = request_gate_status
|
|
32
|
+
return head(status) unless status == 200
|
|
33
|
+
|
|
34
|
+
@label = params[:label].presence
|
|
35
|
+
@name = params[:name].presence || "foo"
|
|
36
|
+
@variant = params[:variant].presence || "multiple"
|
|
37
|
+
@checked = params.key?(:checked) ? params[:checked].to_s.split(",") : ["ours"]
|
|
38
|
+
render "primer/view_components/action_menu/deferred_form"
|
|
39
|
+
end
|
|
40
|
+
|
|
21
41
|
def form_action
|
|
22
42
|
respond_to do |format|
|
|
23
43
|
format.html do
|
|
@@ -33,6 +53,21 @@ module Primer
|
|
|
33
53
|
|
|
34
54
|
private
|
|
35
55
|
|
|
56
|
+
# Test-only: holds the request until the test releases it and returns
|
|
57
|
+
# the status it was released with (see test/test_helpers/request_gate.rb).
|
|
58
|
+
def request_gate_status
|
|
59
|
+
return 200 unless params[:gate].present? && defined?(Primer::RequestGate)
|
|
60
|
+
|
|
61
|
+
Primer::RequestGate.pass(params[:gate])
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def assign_deferred_params
|
|
65
|
+
@label = params[:label].presence
|
|
66
|
+
@deferred_sub = params[:deferred_sub].present?
|
|
67
|
+
@with_sub_menu = params[:with_sub_menu].present?
|
|
68
|
+
@empty_list = params[:empty_list].present?
|
|
69
|
+
end
|
|
70
|
+
|
|
36
71
|
def form_action_selected_value
|
|
37
72
|
params.permit(:foo)[:foo] || params.permit(foo: [])[:foo]
|
|
38
73
|
end
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
<%= render(Primer::Alpha::ActionMenu::List.new(menu_id: "deferred")) do |list| %>
|
|
2
|
-
<%
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
label: "
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
<% unless @empty_list %>
|
|
3
|
+
<% if @label.present? %>
|
|
4
|
+
<% list.with_item(label: @label, value: "", autofocus: true) %>
|
|
5
|
+
<% end %>
|
|
6
|
+
<% list.with_item(label: "Copy link", value: "", autofocus: @label.blank?) %>
|
|
7
|
+
<% list.with_item(label: "Quote reply", value: "") %>
|
|
8
|
+
<% list.with_item(label: "Reference in new issue", value: "") %>
|
|
9
|
+
<% list.with_item(
|
|
10
|
+
label: "Show dialog",
|
|
11
|
+
tag: :button,
|
|
12
|
+
# this dialog is rendered by demo/app/views/action_menu/deferred.html.erb
|
|
13
|
+
content_arguments: { "data-show-dialog-id": "my-dialog" },
|
|
14
|
+
value: "",
|
|
15
|
+
scheme: :danger
|
|
16
|
+
) %>
|
|
17
|
+
<% if @with_sub_menu %>
|
|
18
|
+
<% list.with_item(component_klass: Primer::Alpha::ActionMenu::SubMenuItem, label: "More") do |sub_menu| %>
|
|
19
|
+
<% sub_menu.with_item(label: "Sub one") %>
|
|
20
|
+
<% sub_menu.with_item(label: "Sub two") %>
|
|
21
|
+
<% end %>
|
|
22
|
+
<% end %>
|
|
23
|
+
<% if @deferred_sub %>
|
|
24
|
+
<% list.with_item(component_klass: Primer::Alpha::ActionMenu::SubMenuItem, label: "Deferred more", src: primer_view_components.action_menu_deferred_path) %>
|
|
25
|
+
<% end %>
|
|
26
|
+
<% end %>
|
|
13
27
|
<% end %>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<%= fields do |f| %>
|
|
2
|
+
<%= render(Primer::Alpha::ActionMenu::List.new(menu_id: "deferred-form", select_variant: @variant.to_sym, form_arguments: { builder: f, name: @name })) do |list| %>
|
|
3
|
+
<% list.with_group do |group| %>
|
|
4
|
+
<% group.with_heading(title: "Strategy") %>
|
|
5
|
+
<% [["Fast forward", "fast_forward"], ["Recursive", "recursive"], ["Ours", "ours"]].each do |name, value| %>
|
|
6
|
+
<% group.with_item(label: [name, @label].compact.join(" "), content_arguments: { data: { value: value } }, active: @checked.include?(value)) %>
|
|
7
|
+
<% end %>
|
|
8
|
+
<% end %>
|
|
9
|
+
<% end %>
|
|
10
|
+
<% end %>
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
<%= render(Primer::Alpha::ActionMenu::List.new(menu_id: "deferred-preload")) do |list| %>
|
|
2
|
-
<%
|
|
2
|
+
<% if @label.present? %>
|
|
3
|
+
<% list.with_item(label: @label, value: "", autofocus: true) %>
|
|
4
|
+
<% end %>
|
|
5
|
+
<% list.with_item(label: "Copy link", value: "", autofocus: @label.blank?) %>
|
|
3
6
|
<% list.with_item(label: "Quote reply", value: "") %>
|
|
4
7
|
<% list.with_item(label: "Reference in new issue", value: "") %>
|
|
8
|
+
<% if @deferred_sub %>
|
|
9
|
+
<% list.with_item(component_klass: Primer::Alpha::ActionMenu::SubMenuItem, label: "Deferred more", src: primer_view_components.action_menu_deferred_path) %>
|
|
10
|
+
<% end %>
|
|
5
11
|
<% end %>
|