openproject-primer_view_components 0.94.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 +26 -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/color_swatch.css +1 -0
- data/app/components/primer/open_project/color_swatch.css.json +6 -0
- data/app/components/primer/open_project/color_swatch.css.map +1 -0
- data/app/components/primer/open_project/color_swatch.pcss +8 -0
- data/app/components/primer/open_project/color_swatch.rb +57 -0
- 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/inset_box.css +1 -0
- data/app/components/primer/open_project/inset_box.css.json +9 -0
- data/app/components/primer/open_project/inset_box.css.map +1 -0
- data/app/components/primer/open_project/inset_box.html.erb +46 -0
- data/app/components/primer/open_project/inset_box.pcss +24 -0
- data/app/components/primer/open_project/inset_box.rb +63 -0
- 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 +3 -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/color_swatch_preview.rb +27 -0
- data/previews/primer/open_project/inset_box_preview.rb +85 -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 +109 -1
- data/static/audited_at.json +3 -0
- data/static/classes.json +27 -0
- data/static/classnames.cjs +9 -0
- data/static/classnames.js +9 -0
- data/static/constants.json +63 -0
- data/static/info_arch.json +523 -8
- data/static/previews.json +310 -0
- data/static/statuses.json +3 -0
- metadata +55 -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,4 @@
|
|
|
1
|
+
<%= render(Primer::BaseComponent.new(**@system_arguments)) do %>
|
|
2
|
+
<%# Keep the <kbd> on one line: the only whitespace text node allowed is the single space between chord spans (visible separator and screen-reader word boundary). %>
|
|
3
|
+
<kbd class="KeybindingHint-kbd"><% fallback_chords.each_with_index do |chord, index| %><%= " " if index.positive? %><span class="<%= @chord_classes %>" data-kbd-chord><%= chord %></span><% end %></kbd>
|
|
4
|
+
<% end %>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* KeybindingHint (port of Primer React KeybindingHint at 6794582843) */
|
|
2
|
+
|
|
3
|
+
/* The host carries no semantics; let the <kbd> be the flex/grid item, as in React. */
|
|
4
|
+
/* stylelint-disable-next-line selector-max-type */
|
|
5
|
+
keybinding-hint {
|
|
6
|
+
display: contents;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* Reset user-agent <kbd> styling; matches KeybindingHint.module.css */
|
|
10
|
+
.KeybindingHint-kbd {
|
|
11
|
+
position: relative;
|
|
12
|
+
padding: 0;
|
|
13
|
+
overflow: visible;
|
|
14
|
+
font-family: inherit;
|
|
15
|
+
font-size: inherit;
|
|
16
|
+
/* stylelint-disable-next-line primer/typography */
|
|
17
|
+
line-height: unset;
|
|
18
|
+
color: inherit;
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
vertical-align: baseline;
|
|
21
|
+
background: none;
|
|
22
|
+
border: none;
|
|
23
|
+
box-shadow: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* One bordered box per chord; matches Chord.module.css */
|
|
27
|
+
.KeybindingHint-chord {
|
|
28
|
+
display: inline-flex;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
min-width: var(--base-size-20);
|
|
31
|
+
padding: var(--base-size-4);
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
font-size: var(--text-body-size-small);
|
|
34
|
+
font-weight: var(--base-text-weight-normal);
|
|
35
|
+
/* stylelint-disable-next-line primer/typography */
|
|
36
|
+
line-height: 10px;
|
|
37
|
+
color: var(--fgColor-muted);
|
|
38
|
+
vertical-align: baseline;
|
|
39
|
+
background: var(--bgColor-transparent);
|
|
40
|
+
border: var(--borderWidth-thin) solid var(--borderColor-default);
|
|
41
|
+
border-radius: var(--borderRadius-medium);
|
|
42
|
+
box-shadow: none;
|
|
43
|
+
gap: 0.5ch;
|
|
44
|
+
transition: 80ms ease-in;
|
|
45
|
+
transition-property: color, background-color, border-color;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.KeybindingHint-chord--emphasis {
|
|
49
|
+
color: var(--fgColor-onEmphasis);
|
|
50
|
+
background: var(--counter-bgColor-emphasis);
|
|
51
|
+
border-color: transparent;
|
|
52
|
+
/* React applies the medium radius and the 20px floor only to the default scheme */
|
|
53
|
+
border-radius: var(--borderRadius-default);
|
|
54
|
+
min-width: auto;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.KeybindingHint-chord--small {
|
|
58
|
+
min-width: var(--base-size-16);
|
|
59
|
+
padding: var(--base-size-2);
|
|
60
|
+
/* stylelint-disable-next-line primer/typography */
|
|
61
|
+
font-size: 11px;
|
|
62
|
+
/* stylelint-disable-next-line primer/typography */
|
|
63
|
+
line-height: var(--base-size-8);
|
|
64
|
+
border-radius: var(--borderRadius-small);
|
|
65
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Primer
|
|
4
|
+
module OpenProject
|
|
5
|
+
# Displays a keyboard shortcut as a visible, screen-reader-friendly hint.
|
|
6
|
+
# Port of Primer React's `KeybindingHint`.
|
|
7
|
+
#
|
|
8
|
+
# The server renders a plain-text fallback inside the styled chord box.
|
|
9
|
+
# The `<keybinding-hint>` custom element replaces it with platform-specific
|
|
10
|
+
# names (for example ⌘ on Apple platforms, Ctrl elsewhere) and visually
|
|
11
|
+
# hidden accessible key names ("command", "shift", …).
|
|
12
|
+
#
|
|
13
|
+
# ## Translation
|
|
14
|
+
#
|
|
15
|
+
# Key names follow the current locale: visible condensed and full names,
|
|
16
|
+
# accessible names and the "then" spoken between chords of a sequence.
|
|
17
|
+
# The component looks them up in the `keybinding_hint` locale scope
|
|
18
|
+
# (English defaults in PVC's `config/locales/en.yml`) and passes the names
|
|
19
|
+
# for its keys to the element as JSON in `data-names`. Each name is looked
|
|
20
|
+
# up for the exact platform, then `other`, then Primer React's English
|
|
21
|
+
# tables. Glyphs such as ↑, ⇧ and ⏎ are not translated.
|
|
22
|
+
#
|
|
23
|
+
# ## Key syntax
|
|
24
|
+
#
|
|
25
|
+
# Use the key names `KeyboardEvent.key` reports ("Control", "Shift",
|
|
26
|
+
# "ArrowUp", "a", …), matching the github/hotkey format:
|
|
27
|
+
#
|
|
28
|
+
# - Join keys with `+` to form a chord pressed together: `"Mod+Shift+p"`.
|
|
29
|
+
# - Join chords with a space to form a sequence pressed one after the
|
|
30
|
+
# other: `"g i"` (g, then i).
|
|
31
|
+
# - Use `Plus` for the `+` key and `Space` for the space bar.
|
|
32
|
+
# - `Mod` means Command on Apple platforms and Control everywhere else.
|
|
33
|
+
#
|
|
34
|
+
# Comma-separated alternatives (`"s,/"`) are not supported. The component only
|
|
35
|
+
# displays hints; it does not register the shortcut.
|
|
36
|
+
#
|
|
37
|
+
# ## Terminology
|
|
38
|
+
#
|
|
39
|
+
# Primer React's `variant` is `scheme:` here (`normal` → `:default`,
|
|
40
|
+
# `onEmphasis` → `:emphasis`) and its `size="normal"` is `size: :medium`.
|
|
41
|
+
class KeybindingHint < Primer::Component
|
|
42
|
+
status :open_project
|
|
43
|
+
|
|
44
|
+
DEFAULT_FORMAT = :condensed
|
|
45
|
+
FORMAT_OPTIONS = [DEFAULT_FORMAT, :full].freeze
|
|
46
|
+
|
|
47
|
+
DEFAULT_SCHEME = :default
|
|
48
|
+
SCHEME_MAPPINGS = {
|
|
49
|
+
DEFAULT_SCHEME => "",
|
|
50
|
+
:emphasis => "KeybindingHint-chord--emphasis"
|
|
51
|
+
}.freeze
|
|
52
|
+
SCHEME_OPTIONS = SCHEME_MAPPINGS.keys.freeze
|
|
53
|
+
|
|
54
|
+
DEFAULT_SIZE = :medium
|
|
55
|
+
SIZE_MAPPINGS = {
|
|
56
|
+
DEFAULT_SIZE => "",
|
|
57
|
+
:small => "KeybindingHint-chord--small"
|
|
58
|
+
}.freeze
|
|
59
|
+
SIZE_OPTIONS = SIZE_MAPPINGS.keys.freeze
|
|
60
|
+
|
|
61
|
+
# @param keys [String] The keys of the shortcut, e.g. `"Mod+Shift+p"` or `"g i"`. See the class documentation for the syntax.
|
|
62
|
+
# @param format [Symbol] <%= one_of(Primer::OpenProject::KeybindingHint::FORMAT_OPTIONS) %> `:condensed` shows symbols (⌘⇧P) and suits menus and buttons; `:full` spells keys out (Command + Shift + P) and suits prose.
|
|
63
|
+
# @param scheme [Symbol] <%= one_of(Primer::OpenProject::KeybindingHint::SCHEME_OPTIONS) %> Use `:emphasis` on emphasis-coloured backgrounds.
|
|
64
|
+
# @param size [Symbol] <%= one_of(Primer::OpenProject::KeybindingHint::SIZE_OPTIONS) %>
|
|
65
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
|
66
|
+
def initialize(keys:, format: DEFAULT_FORMAT, scheme: DEFAULT_SCHEME, size: DEFAULT_SIZE, **system_arguments)
|
|
67
|
+
@keys = keys.to_s.strip
|
|
68
|
+
@format = fetch_or_fallback(FORMAT_OPTIONS, format, DEFAULT_FORMAT)
|
|
69
|
+
@scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)
|
|
70
|
+
@size = fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE)
|
|
71
|
+
|
|
72
|
+
@system_arguments = deny_tag_argument(**system_arguments)
|
|
73
|
+
@system_arguments[:tag] = "keybinding-hint"
|
|
74
|
+
@system_arguments[:classes] = class_names(@system_arguments[:classes], "KeybindingHint")
|
|
75
|
+
@system_arguments[:data] = merge_data(
|
|
76
|
+
@system_arguments,
|
|
77
|
+
{ data: { keys: @keys, format: @format, scheme: @scheme, size: @size } }
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
@chord_classes = class_names("KeybindingHint-chord", SCHEME_MAPPINGS[@scheme], SIZE_MAPPINGS[@size])
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def render?
|
|
84
|
+
@keys.present?
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Translations depend on the locale at render time, not at construction.
|
|
88
|
+
def before_render
|
|
89
|
+
@names = Names.for(@keys)
|
|
90
|
+
@system_arguments[:data][:names] = @names.to_json
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
private
|
|
94
|
+
|
|
95
|
+
# Readable degraded output for no-JS and the pre-upgrade frame. Uses the
|
|
96
|
+
# translated condensed name for non-Apple platforms where one exists
|
|
97
|
+
# (`Mod` as Control); other keys keep their spelling with the first
|
|
98
|
+
# letter upcased, so `ArrowUp` stays `ArrowUp` and `p` becomes `P`.
|
|
99
|
+
def fallback_chords
|
|
100
|
+
@keys.split(/\s+/).compact_blank.map do |chord|
|
|
101
|
+
chord.split("+").compact_blank.map { |key| fallback_key_name(key) }.join("+")
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def fallback_key_name(key)
|
|
106
|
+
token = key.downcase
|
|
107
|
+
token = "control" if token == "mod"
|
|
108
|
+
@names.dig("keys", token, "condensed", "other") || key.upcase_first
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -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 };
|
|
@@ -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)}}
|