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
|
@@ -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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.ColorSwatch--indicator{border:var(--borderWidth-thin) solid var(--borderColor-default);border-radius:var(--borderRadius-small);height:var(--base-size-12);width:var(--base-size-12)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["color_swatch.pcss"],"names":[],"mappings":"AAEA,wBACE,+DAAgE,CAChE,uCAAwC,CACxC,0BAA2B,CAC3B,yBACF","file":"color_swatch.css","sourcesContent":["/* CSS for ColorSwatch */\n\n.ColorSwatch--indicator {\n border: var(--borderWidth-thin) solid var(--borderColor-default);\n border-radius: var(--borderRadius-small);\n height: var(--base-size-12);\n width: var(--base-size-12);\n}\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Primer
|
|
4
|
+
module OpenProject
|
|
5
|
+
# Displays a small colored indicator for a given hex color code, optionally
|
|
6
|
+
# showing the hex value next to it.
|
|
7
|
+
class ColorSwatch < Primer::Component
|
|
8
|
+
status :open_project
|
|
9
|
+
|
|
10
|
+
# @param hexcode [String] The hex color code to display, e.g. `#FF0000`.
|
|
11
|
+
# @param show_value [Boolean] Whether to display the hex value next to the swatch.
|
|
12
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
|
13
|
+
def initialize(hexcode:, show_value: false, **system_arguments)
|
|
14
|
+
@hexcode = hexcode
|
|
15
|
+
@show_value = show_value
|
|
16
|
+
@system_arguments = system_arguments
|
|
17
|
+
@system_arguments[:align_items] ||= :center
|
|
18
|
+
|
|
19
|
+
@system_arguments[:classes] = class_names(
|
|
20
|
+
@system_arguments[:classes],
|
|
21
|
+
"ColorSwatch"
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def call
|
|
26
|
+
render(Primer::OpenProject::FlexLayout.new(**@system_arguments)) do |flex|
|
|
27
|
+
flex.with_column do
|
|
28
|
+
render(Primer::BaseComponent.new(**swatch_arguments))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
if show_value?
|
|
32
|
+
flex.with_column do
|
|
33
|
+
render(Primer::Beta::Text.new(tag: :span, ml: 2)) { hexcode }
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
attr_reader :hexcode
|
|
42
|
+
|
|
43
|
+
def show_value?
|
|
44
|
+
@show_value
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def swatch_arguments
|
|
48
|
+
{
|
|
49
|
+
tag: :div,
|
|
50
|
+
classes: "ColorSwatch--indicator",
|
|
51
|
+
aria: { hidden: true },
|
|
52
|
+
style: "background-color: #{hexcode}"
|
|
53
|
+
}
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -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 @@
|
|
|
1
|
+
.InsetBox--title-container{display:flex;align-items:center;gap:var(--base-size-8);margin-bottom:var(--base-size-8)}.InsetBox--body{display:grid;grid-template-areas:"content clip_board_copy" "actions actions";grid-template-columns:1fr auto;grid-template-rows:auto auto auto;align-items:center}.InsetBox--body--clip_board_copy{align-self:flex-start}.InsetBox--actions{gap:var(--base-size-8)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["inset_box.pcss"],"names":[],"mappings":"AAEA,2BACE,YAAa,CACb,kBAAmB,CACnB,sBAAuB,CACvB,gCACF,CAEA,gBACE,YAAa,CACb,+DAAgE,CAChE,8BAA+B,CAC/B,iCAAkC,CAClC,kBACF,CAEA,iCACE,qBACF,CAEA,mBACE,sBACF","file":"inset_box.css","sourcesContent":["/* CSS for InsetBox */\n\n.InsetBox--title-container {\n display: flex;\n align-items: center;\n gap: var(--base-size-8);\n margin-bottom: var(--base-size-8);\n}\n\n.InsetBox--body {\n display: grid;\n grid-template-areas: \"content clip_board_copy\" \"actions actions\";\n grid-template-columns: 1fr auto;\n grid-template-rows: auto auto auto;\n align-items: center;\n}\n\n.InsetBox--body--clip_board_copy {\n align-self: flex-start;\n}\n\n.InsetBox--actions {\n gap: var(--base-size-8);\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<%= render(
|
|
2
|
+
Primer::Box.new(
|
|
3
|
+
border: @border,
|
|
4
|
+
border_radius: 2,
|
|
5
|
+
p: 3,
|
|
6
|
+
**@scheme_arguments,
|
|
7
|
+
**@system_arguments
|
|
8
|
+
)
|
|
9
|
+
) do %>
|
|
10
|
+
<% if title? || title_icon? %>
|
|
11
|
+
<div class="InsetBox--title-container">
|
|
12
|
+
<%= title_icon %>
|
|
13
|
+
<%= title %>
|
|
14
|
+
</div>
|
|
15
|
+
<% end %>
|
|
16
|
+
|
|
17
|
+
<%= render(Primer::OpenProject::GridLayout.new(css_class: "InsetBox--body", tag: :div)) do |grid| %>
|
|
18
|
+
<% if clipboard_copy_button?
|
|
19
|
+
grid.with_area(:clip_board_copy) do
|
|
20
|
+
render(clipboard_copy_button)
|
|
21
|
+
end
|
|
22
|
+
end %>
|
|
23
|
+
|
|
24
|
+
<% grid.with_area(:content, overflow: :hidden) do
|
|
25
|
+
content
|
|
26
|
+
end %>
|
|
27
|
+
|
|
28
|
+
<% if actions.any? %>
|
|
29
|
+
<% grid.with_area(:actions) do %>
|
|
30
|
+
<%= render(
|
|
31
|
+
Primer::Box.new(
|
|
32
|
+
display: :flex,
|
|
33
|
+
align_items: :center,
|
|
34
|
+
flex_wrap: :wrap,
|
|
35
|
+
mt: 2,
|
|
36
|
+
classes: "InsetBox--actions"
|
|
37
|
+
)
|
|
38
|
+
) do %>
|
|
39
|
+
<% actions.each do |action| %>
|
|
40
|
+
<%= action %>
|
|
41
|
+
<% end %>
|
|
42
|
+
<% end %>
|
|
43
|
+
<% end %>
|
|
44
|
+
<% end %>
|
|
45
|
+
<% end %>
|
|
46
|
+
<% end %>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* CSS for InsetBox */
|
|
2
|
+
|
|
3
|
+
.InsetBox--title-container {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
gap: var(--base-size-8);
|
|
7
|
+
margin-bottom: var(--base-size-8);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.InsetBox--body {
|
|
11
|
+
display: grid;
|
|
12
|
+
grid-template-areas: "content clip_board_copy" "actions actions";
|
|
13
|
+
grid-template-columns: 1fr auto;
|
|
14
|
+
grid-template-rows: auto auto auto;
|
|
15
|
+
align-items: center;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.InsetBox--body--clip_board_copy {
|
|
19
|
+
align-self: flex-start;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.InsetBox--actions {
|
|
23
|
+
gap: var(--base-size-8);
|
|
24
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Primer
|
|
4
|
+
module OpenProject
|
|
5
|
+
# A box with an inset background, used to call out a piece of content such
|
|
6
|
+
# as a tip, a warning, or a code snippet, optionally with a title, icon and actions.
|
|
7
|
+
class InsetBox < Primer::Component
|
|
8
|
+
status :open_project
|
|
9
|
+
|
|
10
|
+
DEFAULT_SCHEME = :default
|
|
11
|
+
SCHEME_MAPPINGS = {
|
|
12
|
+
DEFAULT_SCHEME => { bg: :inset },
|
|
13
|
+
info: { bg: :accent, border_color: :accent },
|
|
14
|
+
warning: { bg: :attention, border_color: :attention },
|
|
15
|
+
danger: { bg: :danger, border_color: :danger },
|
|
16
|
+
success: { bg: :success, border_color: :success }
|
|
17
|
+
}.freeze
|
|
18
|
+
|
|
19
|
+
attr_reader :border, :scheme_arguments, :system_arguments
|
|
20
|
+
|
|
21
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
|
22
|
+
renders_one :title_icon, Primer::Beta::Octicon
|
|
23
|
+
|
|
24
|
+
# @param tag [Symbol] <%= one_of(Primer::Beta::Heading::TAG_OPTIONS) %>
|
|
25
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
|
26
|
+
renders_one :title, lambda { |tag: :h3, **system_arguments|
|
|
27
|
+
Primer::Beta::Heading.new(tag: tag, font_size: 5, font_weight: :semibold, **system_arguments)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
|
31
|
+
renders_many :actions, types: {
|
|
32
|
+
button: lambda { |**system_arguments|
|
|
33
|
+
Primer::Beta::Button.new(**system_arguments)
|
|
34
|
+
},
|
|
35
|
+
menu: lambda { |**system_arguments|
|
|
36
|
+
Primer::Alpha::ActionMenu.new(**system_arguments)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
|
41
|
+
renders_one :clipboard_copy_button, lambda { |**system_arguments|
|
|
42
|
+
system_arguments[:scheme] ||= :invisible
|
|
43
|
+
system_arguments[:size] = :small
|
|
44
|
+
system_arguments[:ml] = 2
|
|
45
|
+
Primer::Beta::ClipboardCopyButton.new(**system_arguments)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# @param border [Boolean] Whether to render a border around the box.
|
|
49
|
+
# @param scheme [Symbol] <%= one_of(Primer::OpenProject::InsetBox::SCHEME_MAPPINGS.keys) %>
|
|
50
|
+
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
|
|
51
|
+
def initialize(border: true, scheme: DEFAULT_SCHEME, **system_arguments)
|
|
52
|
+
@border = border
|
|
53
|
+
@scheme_arguments = SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_MAPPINGS.keys, scheme, DEFAULT_SCHEME)]
|
|
54
|
+
@system_arguments = system_arguments
|
|
55
|
+
|
|
56
|
+
@system_arguments[:classes] = class_names(
|
|
57
|
+
@system_arguments[:classes],
|
|
58
|
+
"InsetBox"
|
|
59
|
+
)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -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();
|