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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["timeline_item.pcss"],"names":[],"mappings":"AAEA,cACE,iBAAkB,CAClB,YAAa,CACb,qCAAsC,CACtC,mCAoBF,CAjBE,qBACE,iBAAkB,CAClB,KAAM,CACN,QAAS,CACT,MAAO,CACP,aAAc,CACd,8BAA+B,CAC/B,UAAW,CAEX,yCACF,CAEA,yCACE,+CAAgD,CAEhD,mDACF,CAGF,oBACE,iBAAkB,CAClB,SAAU,CACV,YAAa,CACb,gCAAiC,CACjC,iCAAkC,CAClC,qDAAsD,CAEtD,
|
|
1
|
+
{"version":3,"sources":["timeline_item.pcss"],"names":[],"mappings":"AAEA,cACE,iBAAkB,CAClB,YAAa,CACb,qCAAsC,CACtC,mCAoBF,CAjBE,qBACE,iBAAkB,CAClB,KAAM,CACN,QAAS,CACT,MAAO,CACP,aAAc,CACd,8BAA+B,CAC/B,UAAW,CAEX,yCACF,CAEA,yCACE,+CAAgD,CAEhD,mDACF,CAGF,oBACE,iBAAkB,CAClB,SAAU,CACV,YAAa,CACb,gCAAiC,CACjC,iCAAkC,CAClC,qDAAsD,CAEtD,uDAAwD,CACxD,0BAA2B,CAC3B,kBAAmB,CACnB,6CAA8C,CAE9C,4DAA6D,CAC7D,iBAAkB,CAClB,sBAAuB,CACvB,aACF,CAEA,6BACE,+BAAgC,CAChC,gDAAiD,CACjD,0CACF,CAEA,mBACE,WAAY,CACZ,cAAe,CAEf,yCAA0C,CAC1C,0BAA2B,CAC3B,SACF,CAEA,qBACE,iBAAkB,CAElB,UAAW,CACX,SACF,CAEA,oBACE,iBAAkB,CAClB,SAAU,CACV,gCAAiC,CACjC,QAAS,CACT,gDAAiD,CAEjD,iBAAkB,CAClB,uCAAwC,CACxC,QAAS,CACT,sEACF,CAEA,yBACE,8BAA+B,CAC/B,gBAeF,CAZE,oCACE,sCACF,CAEA,6CACE,0BAA2B,CAC3B,6BAA8B,CAC9B,gCAAiC,CACjC,0BAA2B,CAC3B,uCAAwC,CACxC,QACF","file":"timeline_item.css","sourcesContent":["/* TimelineItem */\n\n.TimelineItem {\n position: relative;\n display: flex;\n padding: var(--stack-padding-normal) 0;\n margin-left: var(--stack-gap-normal);\n\n /* The Timeline */\n &::before {\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n display: block;\n width: var(--borderWidth-thick);\n content: '';\n /* stylelint-disable-next-line primer/colors */\n background-color: var(--borderColor-muted);\n }\n\n &:target .TimelineItem-badge {\n border-color: var(--borderColor-accent-emphasis);\n /* stylelint-disable-next-line primer/box-shadow */\n box-shadow: 0 0 0.2em var(--borderColor-accent-muted);\n }\n}\n\n.TimelineItem-badge {\n position: relative;\n z-index: 1;\n display: flex;\n width: var(--control-medium-size);\n height: var(--control-medium-size);\n margin-right: var(--controlStack-medium-gap-condensed);\n /* stylelint-disable-next-line primer/spacing */\n margin-left: calc(var(--control-medium-size) / -2 + 1px);\n color: var(--fgColor-muted);\n align-items: center;\n background-color: var(--timelineBadge-bgColor);\n /* stylelint-disable-next-line primer/colors */\n border: var(--borderWidth-thick) solid var(--bgColor-default);\n border-radius: 50%;\n justify-content: center;\n flex-shrink: 0;\n}\n\n.TimelineItem-badge--success {\n color: var(--fgColor-onEmphasis);\n background-color: var(--bgColor-success-emphasis);\n border: var(--borderWidth-thin) solid transparent;\n}\n\n.TimelineItem-body {\n min-width: 0;\n max-width: 100%;\n /* stylelint-disable-next-line primer/spacing */\n margin-top: calc(var(--base-size-4) + 1px);\n color: var(--fgColor-muted);\n flex: auto;\n}\n\n.TimelineItem-avatar {\n position: absolute;\n /* stylelint-disable-next-line primer/spacing */\n left: -72px;\n z-index: 1;\n}\n\n.TimelineItem-break {\n position: relative;\n z-index: 1;\n height: var(--stack-gap-spacious);\n margin: 0;\n margin-bottom: calc(var(--stack-gap-normal) * -1);\n /* stylelint-disable-next-line primer/spacing */\n margin-left: -56px;\n background-color: var(--bgColor-default);\n border: 0;\n border-top: var(--borderWidth-thicker) solid var(--borderColor-default);\n}\n\n.TimelineItem--condensed {\n padding-top: var(--base-size-4);\n padding-bottom: 0;\n\n /* TimelineItem--condensed is often grouped. (commits) */\n &:last-child {\n padding-bottom: var(--stack-gap-normal);\n }\n\n & .TimelineItem-badge {\n height: var(--base-size-16);\n margin-top: var(--base-size-8);\n margin-bottom: var(--base-size-8);\n color: var(--fgColor-muted);\n background-color: var(--bgColor-default);\n border: 0;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.BorderGrid{display:table;width:100%;margin-top:calc(var(--base-size-16)
|
|
1
|
+
.BorderGrid{display:table;width:100%;margin-top:calc(-1 * var(--base-size-16));margin-bottom:calc(-1 * var(--base-size-16));table-layout:fixed;border-collapse:collapse;border-style:hidden}.BorderGrid .BorderGrid-cell{padding-top:var(--base-size-16);padding-bottom:var(--base-size-16)}.BorderGrid--spacious{margin-top:calc(-1 * var(--base-size-24));margin-bottom:calc(-1 * var(--base-size-24))}.BorderGrid--spacious .BorderGrid-cell{padding-top:var(--base-size-24);padding-bottom:var(--base-size-24)}.BorderGrid-row{display:table-row}.BorderGrid-cell{display:table-cell;border:var(--borderWidth-thin) solid var(--borderColor-muted)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["border_grid.pcss"],"names":[],"mappings":"AAEA,YACI,aAAc,CACd,UAAW,CACX,
|
|
1
|
+
{"version":3,"sources":["border_grid.pcss"],"names":[],"mappings":"AAEA,YACI,aAAc,CACd,UAAW,CACX,yCAA0C,CAC1C,4CAA6C,CAC7C,kBAAmB,CAEnB,wBAAyB,CAEzB,mBACJ,CAEA,6BACI,+BAAgC,CAChC,kCACJ,CAEA,sBACI,yCAA0C,CAC1C,4CACJ,CAEA,uCACI,+BAAgC,CAChC,kCACJ,CAEA,gBACI,iBACJ,CAEA,iBACI,kBAAmB,CACnB,6DACJ","file":"border_grid.css","sourcesContent":["/* CSS for BorderGrid */\n\n.BorderGrid {\n display: table;\n width: 100%;\n margin-top: calc(-1 * var(--base-size-16));\n margin-bottom: calc(-1 * var(--base-size-16));\n table-layout: fixed;\n /* stylelint-disable-next-line primer/borders -- table border-collapse keyword, not a border size */\n border-collapse: collapse;\n /* stylelint-disable-next-line primer/borders -- table border-style keyword, not a border size */\n border-style: hidden\n}\n\n.BorderGrid .BorderGrid-cell {\n padding-top: var(--base-size-16);\n padding-bottom: var(--base-size-16)\n}\n\n.BorderGrid--spacious {\n margin-top: calc(-1 * var(--base-size-24));\n margin-bottom: calc(-1 * var(--base-size-24))\n}\n\n.BorderGrid--spacious .BorderGrid-cell {\n padding-top: var(--base-size-24);\n padding-bottom: var(--base-size-24)\n}\n\n.BorderGrid-row {\n display: table-row\n}\n\n.BorderGrid-cell {\n display: table-cell;\n border: var(--borderWidth-thin) solid var(--borderColor-muted)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ColorField{display:block}.ColorField .ColorField-wrap .FormControl-input{padding-inline-start:calc(var(--base-size-4) + var(--base-size-24) + var(--base-size-8))}.ColorField .ColorField-swatch{position:absolute;inset-block:0;inset-inline-start:var(--base-size-4);display:flex;align-items:center}.ColorField .ColorField-picker{width:var(--base-size-24);height:var(--base-size-24);padding:0;cursor:pointer;background-color:var(--bgColor-muted);border:0;border-radius:var(--borderRadius-small);outline:var(--borderWidth-thin) solid var(--borderColor-translucent);outline-offset:calc(var(--borderWidth-thin)
|
|
1
|
+
.ColorField{display:block}.ColorField .ColorField-wrap .FormControl-input{padding-inline-start:calc(var(--base-size-4) + var(--base-size-24) + var(--base-size-8))}.ColorField .ColorField-swatch{position:absolute;inset-block:0;inset-inline-start:var(--base-size-4);display:flex;align-items:center}.ColorField .ColorField-picker{width:var(--base-size-24);height:var(--base-size-24);padding:0;cursor:pointer;background-color:var(--bgColor-muted);border:0;border-radius:var(--borderRadius-small);outline:var(--borderWidth-thin) solid var(--borderColor-translucent);outline-offset:calc(var(--borderWidth-thin) * -1);appearance:none;forced-color-adjust:none}:is(.ColorField .ColorField-picker):disabled{cursor:default}:is(.ColorField .ColorField-picker):focus-visible{outline:2px solid var(--focus-outlineColor);outline-offset:-2px;box-shadow:none}:is(.ColorField .ColorField-picker)::-webkit-color-swatch-wrapper{padding:0}:is(.ColorField .ColorField-picker)::-webkit-color-swatch{border:0;border-radius:var(--borderRadius-small)}:is(.ColorField .ColorField-picker)::-moz-color-swatch{border:0;border-radius:var(--borderRadius-small)}.ColorField[data-blank] .ColorField-picker{outline-style:dashed}.ColorField[data-empty] .ColorField-picker::-webkit-color-swatch{opacity:0}.ColorField[data-empty] .ColorField-picker::-moz-color-swatch{opacity:0}.ColorField:not(:defined) .ColorField-picker:disabled{opacity:1}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["color_field.pcss","../../../../lib/postcss_mixins/focusOutline.pcss"],"names":[],"mappings":"AAAA,YACE,aAoEF,CAlEE,gDACE,wFACF,CAEA,+BACE,iBAAkB,CAClB,aAAc,CACd,qCAAsC,CACtC,YAAa,CACb,kBACF,CAEA,+BACE,yBAA0B,CAC1B,0BAA2B,CAC3B,SAAU,CACV,cAAe,CACf,qCAAsC,CACtC,QAAS,CACT,uCAAwC,CAIxC,oEAAqE,CACrE
|
|
1
|
+
{"version":3,"sources":["color_field.pcss","../../../../lib/postcss_mixins/focusOutline.pcss"],"names":[],"mappings":"AAAA,YACE,aAoEF,CAlEE,gDACE,wFACF,CAEA,+BACE,iBAAkB,CAClB,aAAc,CACd,qCAAsC,CACtC,YAAa,CACb,kBACF,CAEA,+BACE,yBAA0B,CAC1B,0BAA2B,CAC3B,SAAU,CACV,cAAe,CACf,qCAAsC,CACtC,QAAS,CACT,uCAAwC,CAIxC,oEAAqE,CACrE,iDAAkD,CAClD,eAAgB,CAChB,wBAuBF,CArBE,6CACE,cACF,CAEA,kDClCF,2CAAgC,CAChC,mBAA8B,CAC9B,eDkCE,CAEA,kEACE,SACF,CAEA,0DACE,QAAS,CACT,uCACF,CAEA,uDACE,QAAS,CACT,uCACF,CAGF,2CACE,oBACF,CAEA,iEACE,SACF,CAEA,8DACE,SACF,CAEA,sDACE,SACF","file":"color_field.css","sourcesContent":[".ColorField {\n display: block;\n\n & .ColorField-wrap .FormControl-input {\n padding-inline-start: calc(var(--base-size-4) + var(--base-size-24) + var(--base-size-8));\n }\n\n & .ColorField-swatch {\n position: absolute;\n inset-block: 0;\n inset-inline-start: var(--base-size-4);\n display: flex;\n align-items: center;\n }\n\n & .ColorField-picker {\n width: var(--base-size-24);\n height: var(--base-size-24);\n padding: 0;\n cursor: pointer;\n background-color: var(--bgColor-muted);\n border: 0;\n border-radius: var(--borderRadius-small);\n\n /* An outline, not a border: it is painted over the native swatch, so\n the color fills the whole box and the border sits on top of it. */\n outline: var(--borderWidth-thin) solid var(--borderColor-translucent);\n outline-offset: calc(var(--borderWidth-thin) * -1);\n appearance: none;\n forced-color-adjust: none;\n\n &:disabled {\n cursor: default;\n }\n\n &:focus-visible {\n @mixin focusOutline;\n }\n\n &::-webkit-color-swatch-wrapper {\n padding: 0;\n }\n\n &::-webkit-color-swatch {\n border: 0;\n border-radius: var(--borderRadius-small);\n }\n\n &::-moz-color-swatch {\n border: 0;\n border-radius: var(--borderRadius-small);\n }\n }\n\n &[data-blank] .ColorField-picker {\n outline-style: dashed;\n }\n\n &[data-empty] .ColorField-picker::-webkit-color-swatch {\n opacity: 0;\n }\n\n &[data-empty] .ColorField-picker::-moz-color-swatch {\n opacity: 0;\n }\n\n &:not(:defined) .ColorField-picker:disabled {\n opacity: 1;\n }\n}\n","@define-mixin focusOutline $outlineOffset: -2px, $outlineColor: var(--focus-outlineColor) {\n outline: 2px solid $outlineColor;\n outline-offset: $outlineOffset;\n box-shadow: none;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.InlineMessage{display:grid;font-size:var(--inline-message-fontSize);line-height:var(--inline-message-lineHeight);color:var(--inline-message-fgColor);column-gap:.5rem;grid-template-columns:auto 1fr;align-items:start}.InlineMessage[data-size=small]{--inline-message-fontSize:var(--text-body-size-small);--inline-message-lineHeight:var(--text-body-lineHeight-small,1.6666)}.InlineMessage[data-size=medium]{--inline-message-fontSize:var(--text-body-size-medium);--inline-message-lineHeight:var(--text-body-lineHeight-medium,1.4285)}.InlineMessage[data-variant=warning]{--inline-message-fgColor:var(--fgColor-attention)}.InlineMessage[data-variant=critical]{--inline-message-fgColor:var(--fgColor-danger)}.InlineMessage[data-variant=success]{--inline-message-fgColor:var(--fgColor-success)}.InlineMessage[data-variant=unavailable]{--inline-message-fgColor:var(--fgColor-muted)}.InlineMessageIcon{min-height:calc(var(--inline-message-lineHeight)*var(--inline-message-fontSize))}
|
|
1
|
+
.InlineMessage{display:grid;font-size:var(--inline-message-fontSize);line-height:var(--inline-message-lineHeight);color:var(--inline-message-fgColor);column-gap:.5rem;grid-template-columns:auto 1fr;align-items:start}.InlineMessage[data-size=small]{--inline-message-fontSize:var(--text-body-size-small);--inline-message-lineHeight:var(--text-body-lineHeight-small, 1.6666)}.InlineMessage[data-size=medium]{--inline-message-fontSize:var(--text-body-size-medium);--inline-message-lineHeight:var(--text-body-lineHeight-medium, 1.4285)}.InlineMessage[data-variant=warning]{--inline-message-fgColor:var(--fgColor-attention)}.InlineMessage[data-variant=critical]{--inline-message-fgColor:var(--fgColor-danger)}.InlineMessage[data-variant=success]{--inline-message-fgColor:var(--fgColor-success)}.InlineMessage[data-variant=unavailable]{--inline-message-fgColor:var(--fgColor-muted)}.InlineMessageIcon{min-height:calc(var(--inline-message-lineHeight) * var(--inline-message-fontSize))}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["inline_message.pcss"],"names":[],"mappings":"AAAA,eACE,YAAa,CAEb,wCAAyC,CAEzC,4CAA6C,CAE7C,mCAAoC,CACpC,gBAAkB,CAClB,8BAA+B,CAC/B,iBA2BF,CAzBE,gCACE,qDAAsD,CACtD,
|
|
1
|
+
{"version":3,"sources":["inline_message.pcss"],"names":[],"mappings":"AAAA,eACE,YAAa,CAEb,wCAAyC,CAEzC,4CAA6C,CAE7C,mCAAoC,CACpC,gBAAkB,CAClB,8BAA+B,CAC/B,iBA2BF,CAzBE,gCACE,qDAAsD,CACtD,qEACF,CAEA,iCACE,sDAAuD,CACvD,sEACF,CAEA,qCACE,iDACF,CAEA,sCACE,8CACF,CAEA,qCACE,+CACF,CAEA,yCACE,6CACF,CAGF,mBACE,kFACF","file":"inline_message.css","sourcesContent":[".InlineMessage {\n display: grid;\n /* stylelint-disable-next-line primer/typography */\n font-size: var(--inline-message-fontSize);\n /* stylelint-disable-next-line primer/typography */\n line-height: var(--inline-message-lineHeight);\n /* stylelint-disable-next-line primer/colors */\n color: var(--inline-message-fgColor);\n column-gap: 0.5rem;\n grid-template-columns: auto 1fr;\n align-items: start;\n\n &[data-size='small'] {\n --inline-message-fontSize: var(--text-body-size-small);\n --inline-message-lineHeight: var(--text-body-lineHeight-small, 1.6666);\n }\n\n &[data-size='medium'] {\n --inline-message-fontSize: var(--text-body-size-medium);\n --inline-message-lineHeight: var(--text-body-lineHeight-medium, 1.4285);\n }\n\n &[data-variant='warning'] {\n --inline-message-fgColor: var(--fgColor-attention);\n }\n\n &[data-variant='critical'] {\n --inline-message-fgColor: var(--fgColor-danger);\n }\n\n &[data-variant='success'] {\n --inline-message-fgColor: var(--fgColor-success);\n }\n\n &[data-variant='unavailable'] {\n --inline-message-fgColor: var(--fgColor-muted);\n }\n}\n\n.InlineMessageIcon {\n min-height: calc(var(--inline-message-lineHeight) * var(--inline-message-fontSize));\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.InputGroup.InputGroup-input-width--auto{width:auto}.InputGroup.InputGroup-input-width--xsmall{max-width:min(144px,100vw - 2rem)}.InputGroup.InputGroup-input-width--small{max-width:min(256px,100vw - 2rem)}.InputGroup.InputGroup-input-width--medium{max-width:min(320px,100vw - 2rem)}.InputGroup.InputGroup-input-width--large{max-width:min(480px,100vw - 2rem)}.InputGroup.InputGroup-input-width--xlarge{max-width:min(680px,100vw - 2rem)}.InputGroup.InputGroup-input-width--xxlarge{max-width:min(960px,100vw - 2rem)}
|
|
1
|
+
.InputGroup.InputGroup-input-width--auto{width:auto}.InputGroup.InputGroup-input-width--xsmall{max-width:calc(min(144px,100vw - 2rem))}.InputGroup.InputGroup-input-width--small{max-width:calc(min(256px,100vw - 2rem))}.InputGroup.InputGroup-input-width--medium{max-width:calc(min(320px,100vw - 2rem))}.InputGroup.InputGroup-input-width--large{max-width:calc(min(480px,100vw - 2rem))}.InputGroup.InputGroup-input-width--xlarge{max-width:calc(min(680px,100vw - 2rem))}.InputGroup.InputGroup-input-width--xxlarge{max-width:calc(min(960px,100vw - 2rem))}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["input_group.pcss"],"names":[],"mappings":"AACI,yCACI,UACJ,CAEA,2CACI,
|
|
1
|
+
{"version":3,"sources":["input_group.pcss"],"names":[],"mappings":"AACI,yCACI,UACJ,CAEA,2CACI,uCACJ,CAEA,0CACI,uCACJ,CAEA,2CACI,uCACJ,CAEA,0CACI,uCACJ,CAEA,2CACI,uCACJ,CAEA,4CACI,uCACJ","file":"input_group.css","sourcesContent":[".InputGroup {\n &.InputGroup-input-width--auto {\n width: auto;\n }\n\n &.InputGroup-input-width--xsmall {\n max-width: min(144px, 100vw - 2rem);\n }\n\n &.InputGroup-input-width--small {\n max-width: min(256px, 100vw - 2rem);\n }\n\n &.InputGroup-input-width--medium {\n max-width: min(320px, 100vw - 2rem);\n }\n\n &.InputGroup-input-width--large {\n max-width: min(480px, 100vw - 2rem);\n }\n\n &.InputGroup-input-width--xlarge {\n max-width: min(680px, 100vw - 2rem);\n }\n\n &.InputGroup-input-width--xxlarge {\n max-width: min(960px, 100vw - 2rem);\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Platform } from './platform';
|
|
2
|
+
/** Split a chord into lowercase, sorted key names. Empty tokens are dropped. */
|
|
3
|
+
export declare const splitChord: (chord: string, platform: Platform) => string[];
|
|
4
|
+
/** Split a sequence into chords. Repeated whitespace and empty chords are dropped. */
|
|
5
|
+
export declare const splitSequence: (sequence: string, platform: Platform) => string[][];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Modifier order. Non-modifiers sort last; there is at most one per chord. */
|
|
2
|
+
const keySortPriorities = {
|
|
3
|
+
control: 1,
|
|
4
|
+
meta: 2,
|
|
5
|
+
alt: 3,
|
|
6
|
+
option: 4,
|
|
7
|
+
shift: 5,
|
|
8
|
+
function: 6,
|
|
9
|
+
};
|
|
10
|
+
const keySortPriority = (key) => keySortPriorities[key] ?? Infinity;
|
|
11
|
+
/**
|
|
12
|
+
* Deviation from primer-react: `mod` is resolved to the platform's modifier
|
|
13
|
+
* before sorting so it takes that modifier's slot. Upstream leaves `mod`
|
|
14
|
+
* unprioritised, which renders "Mod+Shift+p" as ⇧⌘P.
|
|
15
|
+
*/
|
|
16
|
+
const resolveMod = (key, platform) => key === 'mod' ? (platform === 'apple' ? 'meta' : 'control') : key;
|
|
17
|
+
/** Split a chord into lowercase, sorted key names. Empty tokens are dropped. */
|
|
18
|
+
export const splitChord = (chord, platform) => chord
|
|
19
|
+
.split('+')
|
|
20
|
+
.filter(key => key !== '')
|
|
21
|
+
.map(key => resolveMod(key.toLowerCase(), platform))
|
|
22
|
+
.sort((a, b) => keySortPriority(a) - keySortPriority(b));
|
|
23
|
+
/** Split a sequence into chords. Repeated whitespace and empty chords are dropped. */
|
|
24
|
+
export const splitSequence = (sequence, platform) => sequence
|
|
25
|
+
.trim()
|
|
26
|
+
.split(/\s+/)
|
|
27
|
+
.filter(chord => chord !== '')
|
|
28
|
+
.map(chord => splitChord(chord, platform))
|
|
29
|
+
.filter(keys => keys.length > 0);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type {Platform} from './platform'
|
|
2
|
+
|
|
3
|
+
/** Modifier order. Non-modifiers sort last; there is at most one per chord. */
|
|
4
|
+
const keySortPriorities: Partial<Record<string, number>> = {
|
|
5
|
+
control: 1,
|
|
6
|
+
meta: 2,
|
|
7
|
+
alt: 3,
|
|
8
|
+
option: 4,
|
|
9
|
+
shift: 5,
|
|
10
|
+
function: 6,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const keySortPriority = (key: string) => keySortPriorities[key] ?? Infinity
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Deviation from primer-react: `mod` is resolved to the platform's modifier
|
|
17
|
+
* before sorting so it takes that modifier's slot. Upstream leaves `mod`
|
|
18
|
+
* unprioritised, which renders "Mod+Shift+p" as ⇧⌘P.
|
|
19
|
+
*/
|
|
20
|
+
const resolveMod = (key: string, platform: Platform) =>
|
|
21
|
+
key === 'mod' ? (platform === 'apple' ? 'meta' : 'control') : key
|
|
22
|
+
|
|
23
|
+
/** Split a chord into lowercase, sorted key names. Empty tokens are dropped. */
|
|
24
|
+
export const splitChord = (chord: string, platform: Platform): string[] =>
|
|
25
|
+
chord
|
|
26
|
+
.split('+')
|
|
27
|
+
.filter(key => key !== '')
|
|
28
|
+
.map(key => resolveMod(key.toLowerCase(), platform))
|
|
29
|
+
.sort((a, b) => keySortPriority(a) - keySortPriority(b))
|
|
30
|
+
|
|
31
|
+
/** Split a sequence into chords. Repeated whitespace and empty chords are dropped. */
|
|
32
|
+
export const splitSequence = (sequence: string, platform: Platform): string[][] =>
|
|
33
|
+
sequence
|
|
34
|
+
.trim()
|
|
35
|
+
.split(/\s+/)
|
|
36
|
+
.filter(chord => chord !== '')
|
|
37
|
+
.map(chord => splitChord(chord, platform))
|
|
38
|
+
.filter(keys => keys.length > 0)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Platform } from './platform';
|
|
2
|
+
/**
|
|
3
|
+
* Short-form iconic versions of keys. These should be intuitive (not archaic) and match icons on keyboards.
|
|
4
|
+
*/
|
|
5
|
+
export declare const condensedKeyName: (key: string, platform: Platform) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Specific key displays for 'full' format. We still do show some icons (ie punctuation)
|
|
8
|
+
* because that's more intuitive, but for the rest of keys we show the standard key name.
|
|
9
|
+
*/
|
|
10
|
+
export declare const fullKeyName: (key: string, platform: Platform) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Accessible key names intended to be read by a screen reader. This prevents screen
|
|
13
|
+
* readers from expressing punctuation in speech, ie, reading a long pause instead of the
|
|
14
|
+
* word "period".
|
|
15
|
+
*/
|
|
16
|
+
export declare const accessibleKeyName: (key: string, platform: Platform) => string;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/** Converts the first character of the string to upper case and the remaining to lower case. */
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
3
|
+
const capitalize = ([first, ...rest]) => (first?.toUpperCase() ?? '') + rest.join('').toLowerCase();
|
|
4
|
+
// In the below records, we don't intend to cover every single possible key - only those that
|
|
5
|
+
// would be realistically used in shortcuts. For example, the Pause/Break key is not necessary
|
|
6
|
+
// because it is not found on many keyboards.
|
|
7
|
+
/**
|
|
8
|
+
* Short-form iconic versions of keys. These should be intuitive (not archaic) and match icons on keyboards.
|
|
9
|
+
*/
|
|
10
|
+
export const condensedKeyName = (key, platform) => ({
|
|
11
|
+
alt: platform === 'apple' ? '⌥' : 'Alt', // the alt key _is_ the option key on MacOS - in the browser there is no "option" key
|
|
12
|
+
control: '⌃',
|
|
13
|
+
shift: '⇧',
|
|
14
|
+
meta: platform === 'apple' ? '⌘' : platform === 'windows' ? 'Win' : 'Meta',
|
|
15
|
+
mod: platform === 'apple' ? '⌘' : '⌃',
|
|
16
|
+
pageup: 'PgUp',
|
|
17
|
+
pagedown: 'PgDn',
|
|
18
|
+
arrowup: '↑',
|
|
19
|
+
arrowdown: '↓',
|
|
20
|
+
arrowleft: '←',
|
|
21
|
+
arrowright: '→',
|
|
22
|
+
plus: '+', // needed to allow +-separated chords
|
|
23
|
+
backspace: '⌫',
|
|
24
|
+
delete: 'Del',
|
|
25
|
+
space: '␣', // needed to allow space-separated sequences
|
|
26
|
+
tab: '⇥',
|
|
27
|
+
enter: '⏎',
|
|
28
|
+
escape: 'Esc',
|
|
29
|
+
function: 'Fn',
|
|
30
|
+
capslock: 'CapsLock',
|
|
31
|
+
insert: 'Ins',
|
|
32
|
+
printscreen: 'PrtScn',
|
|
33
|
+
})[key] ?? capitalize(key);
|
|
34
|
+
/**
|
|
35
|
+
* Specific key displays for 'full' format. We still do show some icons (ie punctuation)
|
|
36
|
+
* because that's more intuitive, but for the rest of keys we show the standard key name.
|
|
37
|
+
*/
|
|
38
|
+
export const fullKeyName = (key, platform) => ({
|
|
39
|
+
alt: platform === 'apple' ? 'Option' : 'Alt',
|
|
40
|
+
meta: platform === 'apple' ? 'Command' : platform === 'windows' ? 'Windows' : 'Meta',
|
|
41
|
+
mod: platform === 'apple' ? 'Command' : 'Control',
|
|
42
|
+
'+': 'Plus',
|
|
43
|
+
pageup: 'Page Up',
|
|
44
|
+
pagedown: 'Page Down',
|
|
45
|
+
arrowup: 'Up Arrow',
|
|
46
|
+
arrowdown: 'Down Arrow',
|
|
47
|
+
arrowleft: 'Left Arrow',
|
|
48
|
+
arrowright: 'Right Arrow',
|
|
49
|
+
capslock: 'Caps Lock',
|
|
50
|
+
printscreen: 'Print Screen',
|
|
51
|
+
})[key] ?? capitalize(key);
|
|
52
|
+
/**
|
|
53
|
+
* Accessible key names intended to be read by a screen reader. This prevents screen
|
|
54
|
+
* readers from expressing punctuation in speech, ie, reading a long pause instead of the
|
|
55
|
+
* word "period".
|
|
56
|
+
*/
|
|
57
|
+
export const accessibleKeyName = (key, platform) => ({
|
|
58
|
+
alt: platform === 'apple' ? 'option' : 'alt',
|
|
59
|
+
meta: platform === 'apple' ? 'command' : platform === 'windows' ? 'Windows' : 'meta',
|
|
60
|
+
mod: platform === 'apple' ? 'command' : 'control',
|
|
61
|
+
// Screen readers may not be able to pronounce concatenated words - this provides a better experience
|
|
62
|
+
pageup: 'page up',
|
|
63
|
+
pagedown: 'page down',
|
|
64
|
+
arrowup: 'up arrow',
|
|
65
|
+
arrowdown: 'down arrow',
|
|
66
|
+
arrowleft: 'left arrow',
|
|
67
|
+
arrowright: 'right arrow',
|
|
68
|
+
capslock: 'caps lock',
|
|
69
|
+
printscreen: 'print screen',
|
|
70
|
+
// We don't need to represent _every_ symbol - only those found on standard keyboards.
|
|
71
|
+
// Other symbols should be avoided as keyboard shortcuts anyway.
|
|
72
|
+
// These should match the colloquial names of the keys, not the names of the symbols. Ie,
|
|
73
|
+
// "Equals" not "Equal Sign", "Dash" not "Minus", "Period" not "Dot", etc.
|
|
74
|
+
'`': 'backtick',
|
|
75
|
+
'~': 'tilde',
|
|
76
|
+
'!': 'exclamation point',
|
|
77
|
+
'@': 'at',
|
|
78
|
+
'#': 'hash',
|
|
79
|
+
$: 'dollar sign',
|
|
80
|
+
'%': 'percent',
|
|
81
|
+
'^': 'caret',
|
|
82
|
+
'&': 'ampersand',
|
|
83
|
+
'*': 'asterisk',
|
|
84
|
+
'(': 'left parenthesis',
|
|
85
|
+
')': 'right parenthesis',
|
|
86
|
+
_: 'underscore',
|
|
87
|
+
'-': 'dash',
|
|
88
|
+
'+': 'plus',
|
|
89
|
+
'=': 'equals',
|
|
90
|
+
'[': 'left bracket',
|
|
91
|
+
'{': 'left curly brace',
|
|
92
|
+
']': 'right bracket',
|
|
93
|
+
'}': 'right curly brace',
|
|
94
|
+
'\\': 'backslash',
|
|
95
|
+
'|': 'pipe',
|
|
96
|
+
';': 'semicolon',
|
|
97
|
+
':': 'colon',
|
|
98
|
+
"'": 'single quote',
|
|
99
|
+
'"': 'double quote',
|
|
100
|
+
',': 'comma',
|
|
101
|
+
'<': 'left angle bracket',
|
|
102
|
+
'.': 'period',
|
|
103
|
+
'>': 'right angle bracket',
|
|
104
|
+
'/': 'forward slash',
|
|
105
|
+
'?': 'question mark',
|
|
106
|
+
' ': 'space',
|
|
107
|
+
})[key] ?? key.toLowerCase();
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type {Platform} from './platform'
|
|
2
|
+
|
|
3
|
+
/** Converts the first character of the string to upper case and the remaining to lower case. */
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
5
|
+
const capitalize = ([first, ...rest]: string) => (first?.toUpperCase() ?? '') + rest.join('').toLowerCase()
|
|
6
|
+
|
|
7
|
+
// In the below records, we don't intend to cover every single possible key - only those that
|
|
8
|
+
// would be realistically used in shortcuts. For example, the Pause/Break key is not necessary
|
|
9
|
+
// because it is not found on many keyboards.
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Short-form iconic versions of keys. These should be intuitive (not archaic) and match icons on keyboards.
|
|
13
|
+
*/
|
|
14
|
+
export const condensedKeyName = (key: string, platform: Platform) =>
|
|
15
|
+
({
|
|
16
|
+
alt: platform === 'apple' ? '⌥' : 'Alt', // the alt key _is_ the option key on MacOS - in the browser there is no "option" key
|
|
17
|
+
control: '⌃',
|
|
18
|
+
shift: '⇧',
|
|
19
|
+
meta: platform === 'apple' ? '⌘' : platform === 'windows' ? 'Win' : 'Meta',
|
|
20
|
+
mod: platform === 'apple' ? '⌘' : '⌃',
|
|
21
|
+
pageup: 'PgUp',
|
|
22
|
+
pagedown: 'PgDn',
|
|
23
|
+
arrowup: '↑',
|
|
24
|
+
arrowdown: '↓',
|
|
25
|
+
arrowleft: '←',
|
|
26
|
+
arrowright: '→',
|
|
27
|
+
plus: '+', // needed to allow +-separated chords
|
|
28
|
+
backspace: '⌫',
|
|
29
|
+
delete: 'Del',
|
|
30
|
+
space: '␣', // needed to allow space-separated sequences
|
|
31
|
+
tab: '⇥',
|
|
32
|
+
enter: '⏎',
|
|
33
|
+
escape: 'Esc',
|
|
34
|
+
function: 'Fn',
|
|
35
|
+
capslock: 'CapsLock',
|
|
36
|
+
insert: 'Ins',
|
|
37
|
+
printscreen: 'PrtScn',
|
|
38
|
+
})[key] ?? capitalize(key)
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Specific key displays for 'full' format. We still do show some icons (ie punctuation)
|
|
42
|
+
* because that's more intuitive, but for the rest of keys we show the standard key name.
|
|
43
|
+
*/
|
|
44
|
+
export const fullKeyName = (key: string, platform: Platform) =>
|
|
45
|
+
({
|
|
46
|
+
alt: platform === 'apple' ? 'Option' : 'Alt',
|
|
47
|
+
meta: platform === 'apple' ? 'Command' : platform === 'windows' ? 'Windows' : 'Meta',
|
|
48
|
+
mod: platform === 'apple' ? 'Command' : 'Control',
|
|
49
|
+
'+': 'Plus',
|
|
50
|
+
pageup: 'Page Up',
|
|
51
|
+
pagedown: 'Page Down',
|
|
52
|
+
arrowup: 'Up Arrow',
|
|
53
|
+
arrowdown: 'Down Arrow',
|
|
54
|
+
arrowleft: 'Left Arrow',
|
|
55
|
+
arrowright: 'Right Arrow',
|
|
56
|
+
capslock: 'Caps Lock',
|
|
57
|
+
printscreen: 'Print Screen',
|
|
58
|
+
})[key] ?? capitalize(key)
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Accessible key names intended to be read by a screen reader. This prevents screen
|
|
62
|
+
* readers from expressing punctuation in speech, ie, reading a long pause instead of the
|
|
63
|
+
* word "period".
|
|
64
|
+
*/
|
|
65
|
+
export const accessibleKeyName = (key: string, platform: Platform) =>
|
|
66
|
+
({
|
|
67
|
+
alt: platform === 'apple' ? 'option' : 'alt',
|
|
68
|
+
meta: platform === 'apple' ? 'command' : platform === 'windows' ? 'Windows' : 'meta',
|
|
69
|
+
mod: platform === 'apple' ? 'command' : 'control',
|
|
70
|
+
// Screen readers may not be able to pronounce concatenated words - this provides a better experience
|
|
71
|
+
pageup: 'page up',
|
|
72
|
+
pagedown: 'page down',
|
|
73
|
+
arrowup: 'up arrow',
|
|
74
|
+
arrowdown: 'down arrow',
|
|
75
|
+
arrowleft: 'left arrow',
|
|
76
|
+
arrowright: 'right arrow',
|
|
77
|
+
capslock: 'caps lock',
|
|
78
|
+
printscreen: 'print screen',
|
|
79
|
+
// We don't need to represent _every_ symbol - only those found on standard keyboards.
|
|
80
|
+
// Other symbols should be avoided as keyboard shortcuts anyway.
|
|
81
|
+
// These should match the colloquial names of the keys, not the names of the symbols. Ie,
|
|
82
|
+
// "Equals" not "Equal Sign", "Dash" not "Minus", "Period" not "Dot", etc.
|
|
83
|
+
'`': 'backtick',
|
|
84
|
+
'~': 'tilde',
|
|
85
|
+
'!': 'exclamation point',
|
|
86
|
+
'@': 'at',
|
|
87
|
+
'#': 'hash',
|
|
88
|
+
$: 'dollar sign',
|
|
89
|
+
'%': 'percent',
|
|
90
|
+
'^': 'caret',
|
|
91
|
+
'&': 'ampersand',
|
|
92
|
+
'*': 'asterisk',
|
|
93
|
+
'(': 'left parenthesis',
|
|
94
|
+
')': 'right parenthesis',
|
|
95
|
+
_: 'underscore',
|
|
96
|
+
'-': 'dash',
|
|
97
|
+
'+': 'plus',
|
|
98
|
+
'=': 'equals',
|
|
99
|
+
'[': 'left bracket',
|
|
100
|
+
'{': 'left curly brace',
|
|
101
|
+
']': 'right bracket',
|
|
102
|
+
'}': 'right curly brace',
|
|
103
|
+
'\\': 'backslash',
|
|
104
|
+
'|': 'pipe',
|
|
105
|
+
';': 'semicolon',
|
|
106
|
+
':': 'colon',
|
|
107
|
+
"'": 'single quote',
|
|
108
|
+
'"': 'double quote',
|
|
109
|
+
',': 'comma',
|
|
110
|
+
'<': 'left angle bracket',
|
|
111
|
+
'.': 'period',
|
|
112
|
+
'>': 'right angle bracket',
|
|
113
|
+
'/': 'forward slash',
|
|
114
|
+
'?': 'question mark',
|
|
115
|
+
' ': 'space',
|
|
116
|
+
})[key] ?? key.toLowerCase()
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Platform } from './platform';
|
|
2
|
+
export type NameFormat = 'condensed' | 'full' | 'accessible';
|
|
3
|
+
type PlatformNames = Partial<Record<Platform, string>>;
|
|
4
|
+
/** `separator` is the JSON `then` (the word spoken between chords). */
|
|
5
|
+
export type KeyNames = {
|
|
6
|
+
separator?: string;
|
|
7
|
+
keys: Record<string, Partial<Record<NameFormat, PlatformNames>>>;
|
|
8
|
+
};
|
|
9
|
+
/** Same notion of blank as Ruby's `String#blank?` (`[[:space:]]`, i.e. Unicode White_Space). */
|
|
10
|
+
export declare const nonBlank: (value: unknown) => string | undefined;
|
|
11
|
+
/** Parses the `data-names` attribute; anything malformed yields no names. */
|
|
12
|
+
export declare function parseKeyNames(json: string): KeyNames;
|
|
13
|
+
/** Exact platform, then `other`; `undefined` when no usable name was given. */
|
|
14
|
+
export declare function localizedKeyName(names: KeyNames, key: string, format: NameFormat, platform: Platform): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Upstream's English name. The mirrored tables index plain object literals, so
|
|
17
|
+
* a key such as `constructor` would return an `Object.prototype` member;
|
|
18
|
+
* those keys get upstream's default spelling instead.
|
|
19
|
+
*/
|
|
20
|
+
export declare function englishKeyName(key: string, format: NameFormat, platform: Platform): string;
|
|
21
|
+
export declare function keyName(names: KeyNames, key: string, format: NameFormat, platform: Platform): string;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { accessibleKeyName, condensedKeyName, fullKeyName } from './key_names';
|
|
2
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
3
|
+
const own = (record, key) => Object.hasOwn(record, key) ? record[key] : undefined;
|
|
4
|
+
/** Same notion of blank as Ruby's `String#blank?` (`[[:space:]]`, i.e. Unicode White_Space). */
|
|
5
|
+
export const nonBlank = (value) => typeof value === 'string' && !/^\p{White_Space}*$/u.test(value) ? value : undefined;
|
|
6
|
+
/** Parses the `data-names` attribute; anything malformed yields no names. */
|
|
7
|
+
export function parseKeyNames(json) {
|
|
8
|
+
try {
|
|
9
|
+
const parsed = JSON.parse(json);
|
|
10
|
+
if (isRecord(parsed) && isRecord(parsed.keys)) {
|
|
11
|
+
return { separator: nonBlank(parsed['then']), keys: parsed.keys };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// Fall through to no names: upstream English applies.
|
|
16
|
+
}
|
|
17
|
+
return { keys: {} };
|
|
18
|
+
}
|
|
19
|
+
/** Exact platform, then `other`; `undefined` when no usable name was given. */
|
|
20
|
+
export function localizedKeyName(names, key, format, platform) {
|
|
21
|
+
const entry = own(names.keys, key);
|
|
22
|
+
if (!isRecord(entry))
|
|
23
|
+
return undefined;
|
|
24
|
+
const platforms = own(entry, format);
|
|
25
|
+
if (!isRecord(platforms))
|
|
26
|
+
return undefined;
|
|
27
|
+
return nonBlank(own(platforms, platform)) ?? nonBlank(own(platforms, 'other'));
|
|
28
|
+
}
|
|
29
|
+
const upstreamNames = {
|
|
30
|
+
condensed: condensedKeyName,
|
|
31
|
+
full: fullKeyName,
|
|
32
|
+
accessible: accessibleKeyName,
|
|
33
|
+
};
|
|
34
|
+
const capitalize = (key) => key.charAt(0).toUpperCase() + key.slice(1).toLowerCase();
|
|
35
|
+
/**
|
|
36
|
+
* Upstream's English name. The mirrored tables index plain object literals, so
|
|
37
|
+
* a key such as `constructor` would return an `Object.prototype` member;
|
|
38
|
+
* those keys get upstream's default spelling instead.
|
|
39
|
+
*/
|
|
40
|
+
export function englishKeyName(key, format, platform) {
|
|
41
|
+
if (key in Object.prototype)
|
|
42
|
+
return format === 'accessible' ? key.toLowerCase() : capitalize(key);
|
|
43
|
+
return upstreamNames[format](key, platform);
|
|
44
|
+
}
|
|
45
|
+
export function keyName(names, key, format, platform) {
|
|
46
|
+
return localizedKeyName(names, key, format, platform) ?? englishKeyName(key, format, platform);
|
|
47
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type {Platform} from './platform'
|
|
2
|
+
import {accessibleKeyName, condensedKeyName, fullKeyName} from './key_names'
|
|
3
|
+
|
|
4
|
+
export type NameFormat = 'condensed' | 'full' | 'accessible'
|
|
5
|
+
|
|
6
|
+
type PlatformNames = Partial<Record<Platform, string>>
|
|
7
|
+
|
|
8
|
+
/** `separator` is the JSON `then` (the word spoken between chords). */
|
|
9
|
+
export type KeyNames = {
|
|
10
|
+
separator?: string
|
|
11
|
+
keys: Record<string, Partial<Record<NameFormat, PlatformNames>>>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
15
|
+
typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
16
|
+
|
|
17
|
+
const own = (record: Record<string, unknown>, key: string): unknown =>
|
|
18
|
+
Object.hasOwn(record, key) ? record[key] : undefined
|
|
19
|
+
|
|
20
|
+
/** Same notion of blank as Ruby's `String#blank?` (`[[:space:]]`, i.e. Unicode White_Space). */
|
|
21
|
+
export const nonBlank = (value: unknown): string | undefined =>
|
|
22
|
+
typeof value === 'string' && !/^\p{White_Space}*$/u.test(value) ? value : undefined
|
|
23
|
+
|
|
24
|
+
/** Parses the `data-names` attribute; anything malformed yields no names. */
|
|
25
|
+
export function parseKeyNames(json: string): KeyNames {
|
|
26
|
+
try {
|
|
27
|
+
const parsed: unknown = JSON.parse(json)
|
|
28
|
+
if (isRecord(parsed) && isRecord(parsed.keys)) {
|
|
29
|
+
return {separator: nonBlank(parsed['then']), keys: parsed.keys as KeyNames['keys']}
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
// Fall through to no names: upstream English applies.
|
|
33
|
+
}
|
|
34
|
+
return {keys: {}}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Exact platform, then `other`; `undefined` when no usable name was given. */
|
|
38
|
+
export function localizedKeyName(
|
|
39
|
+
names: KeyNames,
|
|
40
|
+
key: string,
|
|
41
|
+
format: NameFormat,
|
|
42
|
+
platform: Platform,
|
|
43
|
+
): string | undefined {
|
|
44
|
+
const entry = own(names.keys, key)
|
|
45
|
+
if (!isRecord(entry)) return undefined
|
|
46
|
+
const platforms = own(entry, format)
|
|
47
|
+
if (!isRecord(platforms)) return undefined
|
|
48
|
+
return nonBlank(own(platforms, platform)) ?? nonBlank(own(platforms, 'other'))
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const upstreamNames: Record<NameFormat, (key: string, platform: Platform) => string> = {
|
|
52
|
+
condensed: condensedKeyName,
|
|
53
|
+
full: fullKeyName,
|
|
54
|
+
accessible: accessibleKeyName,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const capitalize = (key: string) => key.charAt(0).toUpperCase() + key.slice(1).toLowerCase()
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Upstream's English name. The mirrored tables index plain object literals, so
|
|
61
|
+
* a key such as `constructor` would return an `Object.prototype` member;
|
|
62
|
+
* those keys get upstream's default spelling instead.
|
|
63
|
+
*/
|
|
64
|
+
export function englishKeyName(key: string, format: NameFormat, platform: Platform): string {
|
|
65
|
+
if (key in Object.prototype) return format === 'accessible' ? key.toLowerCase() : capitalize(key)
|
|
66
|
+
return upstreamNames[format](key, platform)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function keyName(names: KeyNames, key: string, format: NameFormat, platform: Platform): string {
|
|
70
|
+
return localizedKeyName(names, key, format, platform) ?? englishKeyName(key, format, platform)
|
|
71
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Primer
|
|
4
|
+
module OpenProject
|
|
5
|
+
class KeybindingHint < Primer::Component
|
|
6
|
+
# Translated key names for the keys of one hint, in the shape
|
|
7
|
+
# `<keybinding-hint>` reads from its `data-names` attribute:
|
|
8
|
+
#
|
|
9
|
+
# { "then" => "dann", "keys" => { "control" => { "condensed" => { "other" => "Strg" } } } }
|
|
10
|
+
#
|
|
11
|
+
# Entries come from the `keybinding_hint` locale scope. Missing
|
|
12
|
+
# translations fall back to the English defaults in PVC's `en.yml`.
|
|
13
|
+
module Names
|
|
14
|
+
module_function
|
|
15
|
+
|
|
16
|
+
FORMATS = %w[condensed full accessible].freeze
|
|
17
|
+
PLATFORMS = %w[apple windows other].freeze
|
|
18
|
+
|
|
19
|
+
def for(keys)
|
|
20
|
+
english = scope_for(:en)
|
|
21
|
+
locale = I18n.locale == :en ? {} : scope_for(I18n.locale)
|
|
22
|
+
index = token_index(english["keys"])
|
|
23
|
+
|
|
24
|
+
{
|
|
25
|
+
"then" => present(locale["then"]) || english["then"],
|
|
26
|
+
"keys" => tokens(keys).each_with_object({}) do |token, names|
|
|
27
|
+
entry = index[token]
|
|
28
|
+
next unless entry
|
|
29
|
+
|
|
30
|
+
names[token] = entry_names(english["keys"][entry], hash_at(locale, "keys", entry))
|
|
31
|
+
end
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def tokens(keys)
|
|
36
|
+
keys.to_s.split(/\s+/)
|
|
37
|
+
.flat_map { |chord| chord.split("+") }
|
|
38
|
+
.reject(&:empty?)
|
|
39
|
+
.map(&:downcase)
|
|
40
|
+
.flat_map { |token| token == "mod" ? %w[control meta] : [token] }
|
|
41
|
+
.uniq
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# I18n keys cannot contain `.`, so punctuation entries carry their
|
|
45
|
+
# literal key in a `key` field. Built from English only: the field is
|
|
46
|
+
# not translatable.
|
|
47
|
+
def token_index(entries)
|
|
48
|
+
entries.each_with_object({}) do |(name, entry), index|
|
|
49
|
+
index[entry.fetch("key", name)] = name if entry.is_a?(Hash)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Locale data comes from translators; anything that is not a
|
|
54
|
+
# non-blank string in the expected place is ignored, and symbols such
|
|
55
|
+
# as ⌘ cannot be replaced.
|
|
56
|
+
def entry_names(english_entry, locale_entry)
|
|
57
|
+
FORMATS.each_with_object({}) do |format, names|
|
|
58
|
+
english = platform_names(english_entry[format])
|
|
59
|
+
translated = platform_names(hash_at(locale_entry, format)).reject { |platform, _| symbol?(english[platform]) }
|
|
60
|
+
platforms = english.merge(translated)
|
|
61
|
+
names[format] = platforms if platforms.any?
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def symbol?(name)
|
|
66
|
+
name.present? && !name.match?(/\p{L}/)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def platform_names(value)
|
|
70
|
+
return {} unless value.is_a?(Hash)
|
|
71
|
+
|
|
72
|
+
value.each_with_object({}) do |(platform, name), names|
|
|
73
|
+
names[platform] = name if PLATFORMS.include?(platform) && present(name)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def hash_at(hash, *path)
|
|
78
|
+
path.reduce(hash) { |node, key| node.is_a?(Hash) ? node[key] : nil }.then { |node| node.is_a?(Hash) ? node : {} }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def present(value)
|
|
82
|
+
value if value.is_a?(String) && value.present?
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def scope_for(locale)
|
|
86
|
+
scope = I18n.t(:keybinding_hint, locale: locale, default: {})
|
|
87
|
+
scope.is_a?(Hash) ? scope.deep_stringify_keys : {}
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|