openproject-primer_view_components 0.41.0 → 0.42.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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/app/assets/javascripts/app/components/primer/alpha/select_panel_element.d.ts +0 -1
  4. data/app/assets/javascripts/primer_view_components.js +1 -1
  5. data/app/assets/javascripts/primer_view_components.js.map +1 -1
  6. data/app/assets/styles/primer_view_components.css +1 -1
  7. data/app/assets/styles/primer_view_components.css.map +1 -1
  8. data/app/components/primer/alpha/action_list/item.html.erb +1 -5
  9. data/app/components/primer/alpha/action_list/item.rb +10 -3
  10. data/app/components/primer/alpha/segmented_control.css +1 -1
  11. data/app/components/primer/alpha/segmented_control.css.map +1 -1
  12. data/app/components/primer/alpha/segmented_control.pcss +1 -0
  13. data/app/components/primer/alpha/select_panel.rb +2 -1
  14. data/app/components/primer/alpha/select_panel_element.d.ts +0 -1
  15. data/app/components/primer/alpha/select_panel_element.js +38 -19
  16. data/app/components/primer/alpha/select_panel_element.ts +36 -22
  17. data/app/components/primer/alpha/tool_tip.js +2 -2
  18. data/app/components/primer/alpha/tool_tip.ts +2 -2
  19. data/app/components/primer/beta/relative_time.rb +4 -4
  20. data/app/components/primer/beta/state.css +1 -1
  21. data/app/components/primer/beta/state.css.map +1 -1
  22. data/app/components/primer/beta/state.pcss +4 -0
  23. data/lib/primer/forms/text_area.rb +7 -1
  24. data/lib/primer/view_components/linters/details_menu_migration.rb +30 -1
  25. data/lib/primer/view_components/linters/tooltipped_migration.rb +1 -1
  26. data/lib/primer/view_components/version.rb +1 -1
  27. data/previews/primer/alpha/action_list_preview.rb +1 -1
  28. data/previews/primer/alpha/select_panel_preview/list_of_links.html.erb +16 -0
  29. data/previews/primer/alpha/select_panel_preview/playground.html.erb +2 -1
  30. data/previews/primer/alpha/select_panel_preview.rb +12 -1
  31. data/previews/primer/alpha/text_area_preview.rb +5 -2
  32. data/previews/primer/forms_preview/custom_width_fields_form.html.erb +34 -2
  33. data/static/arguments.json +5 -5
  34. data/static/info_arch.json +57 -11
  35. data/static/previews.json +13 -0
  36. metadata +3 -3
  37. data/app/forms/custom_width_fields_form.rb +0 -26
@@ -14,6 +14,13 @@ module ERBLint
14
14
  " https://primer.style/design/components/action-menu/rails/alpha"
15
15
  DETAILS_MENU_RUBY_PATTERN = /tag:?\s+:"details-menu"/.freeze
16
16
 
17
+ # Allow custom pattern matching for ERB nodes
18
+ class ConfigSchema < LinterConfig
19
+ property :custom_erb_pattern, accepts: array_of?(Regexp),
20
+ default: -> { [] }
21
+ end
22
+ self.config_schema = ConfigSchema
23
+
17
24
  def run(processed_source)
18
25
  # HTML tags
19
26
  tags(processed_source).each do |tag|
@@ -25,9 +32,31 @@ module ERBLint
25
32
  # ERB nodes
26
33
  erb_nodes(processed_source).each do |node|
27
34
  code = extract_ruby_from_erb_node(node)
28
- generate_node_offense(self.class, processed_source, node, MIGRATE_FROM_DETAILS_MENU) if code.match?(DETAILS_MENU_RUBY_PATTERN)
35
+
36
+ if contains_offense?(code)
37
+ generate_node_offense(self.class, processed_source, node, MIGRATE_FROM_DETAILS_MENU)
38
+ end
29
39
  end
30
40
  end
41
+
42
+ def contains_offense?(code)
43
+ return true if code.match?(DETAILS_MENU_RUBY_PATTERN)
44
+ return code.match?(custom_erb_pattern) if custom_erb_pattern
45
+ false
46
+ end
47
+
48
+ def custom_erb_pattern
49
+ unless defined?(@custom_erb_pattern)
50
+ @custom_erb_pattern =
51
+ if @config.custom_erb_pattern.empty?
52
+ nil
53
+ else
54
+ Regexp.new(@config.custom_erb_pattern.join("|"), true)
55
+ end
56
+ end
57
+
58
+ @custom_erb_pattern
59
+ end
31
60
  end
32
61
  end
33
62
  end
@@ -10,7 +10,7 @@ module ERBLint
10
10
  include LinterRegistry
11
11
  include Helpers::RuleHelpers
12
12
 
13
- MIGRATE_TO_NEWER_TOOLTIP = ".tooltipped has been deprecated. There are major accessibility concerns with using this tooltip so please take action. See https://primer.style/guides/rails/migration-guides/primer-css-tooltipped."
13
+ MIGRATE_TO_NEWER_TOOLTIP = ".tooltipped has been deprecated. Due to major accessibility concerns with using this tooltip, please migrate to a Primer Tooltip component or rework the design to eliminate the tooltip. See https://primer.style/guides/rails/migration-guides/primer-css-tooltipped."
14
14
  TOOLTIPPED_RUBY_PATTERN = /classes:.*tooltipped|class:.*tooltipped/.freeze
15
15
 
16
16
  def run(processed_source)
@@ -5,7 +5,7 @@ module Primer
5
5
  module ViewComponents
6
6
  module VERSION
7
7
  MAJOR = 0
8
- MINOR = 41
8
+ MINOR = 42
9
9
  PATCH = 0
10
10
 
11
11
  STRING = [MAJOR, MINOR, PATCH].join(".")
@@ -380,7 +380,7 @@ module Primer
380
380
  aria: { label: "List heading" }
381
381
  )) do |component|
382
382
  component.with_item(label: "Default item", href: "/") do |item|
383
- item.with_description.with_content("This is a description")
383
+ item.with_description(test_selector: "some-selector").with_content("This is a description")
384
384
  end
385
385
  end
386
386
  end
@@ -0,0 +1,16 @@
1
+ <% subject_id = SecureRandom.hex %>
2
+
3
+ <%= render(Primer::Alpha::SelectPanel.new(
4
+ data: { interaction_subject: subject_id },
5
+ select_variant: :single,
6
+ fetch_strategy: :local,
7
+ open_on_load: open_on_load
8
+ )) do |panel| %>
9
+ <% panel.with_show_button { "Panel" } %>
10
+ <% panel.with_item(label: "GitHub", href: "https://github.com") %>
11
+ <% panel.with_item(label: "Microsoft", href: "https://microsoft.com") %>
12
+ <% panel.with_item(label: "Primer", href: "https://primer.style") %>
13
+ <% panel.with_item(label: "Catalyst", href: "https://catalyst.rocks") %>
14
+ <% end %>
15
+
16
+ <%= render partial: "primer/alpha/select_panel_preview/interaction_subject_js", locals: { subject_id: subject_id } %>
@@ -8,7 +8,8 @@
8
8
  src: select_panel_items_path(
9
9
  select_variant: :single,
10
10
  show_results: !simulate_no_results,
11
- fail: simulate_failure
11
+ fail: simulate_failure,
12
+ select_items: select_items
12
13
  ),
13
14
  select_variant: :single,
14
15
  fetch_strategy: :remote,
@@ -18,6 +18,7 @@ module Primer
18
18
  # @param open_on_load toggle
19
19
  # @param anchor_align [Symbol] select [start, center, end]
20
20
  # @param anchor_side [Symbol] select [outside_bottom, outside_top, outside_left, outside_right]
21
+ # @param select_items toggle
21
22
  def playground(
22
23
  title: "Sci-fi equipment",
23
24
  subtitle: "Various tools from your favorite shows",
@@ -31,10 +32,12 @@ module Primer
31
32
  show_filter: true,
32
33
  open_on_load: false,
33
34
  anchor_align: :start,
34
- anchor_side: :outside_bottom
35
+ anchor_side: :outside_bottom,
36
+ select_items: true
35
37
  )
36
38
  render_with_template(locals: {
37
39
  subtitle: subtitle,
40
+ select_items: select_items,
38
41
  system_arguments: {
39
42
  title: title,
40
43
  size: size,
@@ -234,6 +237,14 @@ module Primer
234
237
  def multiselect_form(open_on_load: false, route_format: :html)
235
238
  render_with_template(locals: { open_on_load: open_on_load, route_format: route_format })
236
239
  end
240
+
241
+ # @label List of links
242
+ #
243
+ # @snapshot interactive
244
+ # @param open_on_load toggle
245
+ def list_of_links(open_on_load: false)
246
+ render_with_template(locals: { open_on_load: open_on_load })
247
+ end
237
248
  end
238
249
  end
239
250
  end
@@ -16,6 +16,7 @@ module Primer
16
16
  # @param disabled toggle
17
17
  # @param invalid toggle
18
18
  # @param validation_message text
19
+ # @param input_width [Symbol] select [auto, small, medium, large, xlarge, xxlarge]
19
20
  def playground(
20
21
  name: "my-text-area",
21
22
  id: "my-text-area",
@@ -26,7 +27,8 @@ module Primer
26
27
  full_width: true,
27
28
  disabled: false,
28
29
  invalid: false,
29
- validation_message: nil
30
+ validation_message: nil,
31
+ input_width: nil
30
32
  )
31
33
  system_arguments = {
32
34
  name: name,
@@ -38,7 +40,8 @@ module Primer
38
40
  full_width: full_width,
39
41
  disabled: disabled,
40
42
  invalid: invalid,
41
- validation_message: validation_message
43
+ validation_message: validation_message,
44
+ input_width: input_width
42
45
  }
43
46
 
44
47
  render(Primer::Alpha::TextArea.new(**system_arguments))
@@ -1,5 +1,37 @@
1
- <!-- Look at the "Assets" tab for the definition of the `CustomWidthFieldsForm` -->
1
+ <%
2
+ custom_width_form = Class.new(ApplicationForm) do
3
+ form do |f|
4
+ f.text_field(
5
+ name: :ultimate_answer,
6
+ label: "Ultimate answer",
7
+ required: true,
8
+ caption: "The answer to life, the universe, and everything",
9
+ input_width: :medium
10
+ )
11
+
12
+ f.select_list(
13
+ name: "cities",
14
+ label: "Cool cities",
15
+ caption: "Select your favorite!",
16
+ include_blank: true,
17
+ input_width: :small
18
+ ) do |city_list|
19
+ city_list.option(label: "Lopez Island", value: "lopez_island")
20
+ city_list.option(label: "Bellevue", value: "bellevue")
21
+ city_list.option(label: "Seattle", value: "seattle")
22
+ end
23
+
24
+ f.text_field(
25
+ name: :lots_of_text,
26
+ label: "Lots of text",
27
+ required: true,
28
+ caption: "What else do you need?",
29
+ input_width: :small
30
+ )
31
+ end
32
+ end
33
+ %>
2
34
 
3
35
  <%= primer_form_with(url: "/foo") do |f| %>
4
- <%= render(CustomWidthFieldsForm.new(f)) %>
36
+ <%= render(custom_width_form.new(f)) %>
5
37
  <% end %>
@@ -4336,9 +4336,9 @@
4336
4336
  },
4337
4337
  {
4338
4338
  "name": "prefix",
4339
- "type": "sring",
4339
+ "type": "String",
4340
4340
  "default": "`nil`",
4341
- "description": "What to prefix the relative ime display with."
4341
+ "description": "What to prefix the relative time display with."
4342
4342
  },
4343
4343
  {
4344
4344
  "name": "second",
@@ -4390,7 +4390,7 @@
4390
4390
  },
4391
4391
  {
4392
4392
  "name": "threshold",
4393
- "type": "string",
4393
+ "type": "String",
4394
4394
  "default": "`nil`",
4395
4395
  "description": "The threshold, in ISO-8601 'durations' format, at which relative time displays become absolute."
4396
4396
  },
@@ -4414,13 +4414,13 @@
4414
4414
  },
4415
4415
  {
4416
4416
  "name": "lang",
4417
- "type": "string",
4417
+ "type": "String",
4418
4418
  "default": "`nil`",
4419
4419
  "description": "The language to use."
4420
4420
  },
4421
4421
  {
4422
4422
  "name": "title",
4423
- "type": "string",
4423
+ "type": "String",
4424
4424
  "default": "`nil`",
4425
4425
  "description": "Provide a custom title to the element."
4426
4426
  },
@@ -989,9 +989,20 @@
989
989
  "slots": [
990
990
  {
991
991
  "name": "description",
992
- "description": "Description content that complements the item's label. See `ActionList`'s `description_scheme` argument\nfor layout options.",
992
+ "description": "Description content that complements the item's label, with optional test_selector.\nSee `ActionList`'s `description_scheme` argument for layout options.",
993
993
  "parameters": [
994
-
994
+ {
995
+ "name": "legacy_content",
996
+ "type": "String",
997
+ "default": "N/A",
998
+ "description": "Slot content, provided for backwards-compatibility. Pass a content block instead, or call `with_content`, eg. `component.with_description { \"My description\" }` or `component.with_description.with_content(\"My description\")`."
999
+ },
1000
+ {
1001
+ "name": "test_selector",
1002
+ "type": "String",
1003
+ "default": "N/A",
1004
+ "description": "The value of this argument is set as the value of a `data-test-selector` HTML attribute on the description element."
1005
+ }
995
1006
  ]
996
1007
  },
997
1008
  {
@@ -5547,9 +5558,20 @@
5547
5558
  },
5548
5559
  {
5549
5560
  "name": "description",
5550
- "description": "Description content that complements the item's label. See `ActionList`'s `description_scheme` argument\nfor layout options.",
5561
+ "description": "Description content that complements the item's label, with optional test_selector.\nSee `ActionList`'s `description_scheme` argument for layout options.",
5551
5562
  "parameters": [
5552
-
5563
+ {
5564
+ "name": "legacy_content",
5565
+ "type": "String",
5566
+ "default": "N/A",
5567
+ "description": "Slot content, provided for backwards-compatibility. Pass a content block instead, or call `with_content`, eg. `component.with_description { \"My description\" }` or `component.with_description.with_content(\"My description\")`."
5568
+ },
5569
+ {
5570
+ "name": "test_selector",
5571
+ "type": "String",
5572
+ "default": "N/A",
5573
+ "description": "The value of this argument is set as the value of a `data-test-selector` HTML attribute on the description element."
5574
+ }
5553
5575
  ]
5554
5576
  },
5555
5577
  {
@@ -8083,6 +8105,19 @@
8083
8105
  "color-contrast"
8084
8106
  ]
8085
8107
  }
8108
+ },
8109
+ {
8110
+ "preview_path": "primer/alpha/select_panel/list_of_links",
8111
+ "name": "list_of_links",
8112
+ "snapshot": "interactive",
8113
+ "skip_rules": {
8114
+ "wont_fix": [
8115
+ "region"
8116
+ ],
8117
+ "will_fix": [
8118
+ "color-contrast"
8119
+ ]
8120
+ }
8086
8121
  }
8087
8122
  ],
8088
8123
  "subcomponents": [
@@ -14687,9 +14722,20 @@
14687
14722
  },
14688
14723
  {
14689
14724
  "name": "description",
14690
- "description": "Description content that complements the item's label. See `ActionList`'s `description_scheme` argument\nfor layout options.",
14725
+ "description": "Description content that complements the item's label, with optional test_selector.\nSee `ActionList`'s `description_scheme` argument for layout options.",
14691
14726
  "parameters": [
14692
-
14727
+ {
14728
+ "name": "legacy_content",
14729
+ "type": "String",
14730
+ "default": "N/A",
14731
+ "description": "Slot content, provided for backwards-compatibility. Pass a content block instead, or call `with_content`, eg. `component.with_description { \"My description\" }` or `component.with_description.with_content(\"My description\")`."
14732
+ },
14733
+ {
14734
+ "name": "test_selector",
14735
+ "type": "String",
14736
+ "default": "N/A",
14737
+ "description": "The value of this argument is set as the value of a `data-test-selector` HTML attribute on the description element."
14738
+ }
14693
14739
  ]
14694
14740
  },
14695
14741
  {
@@ -15349,9 +15395,9 @@
15349
15395
  },
15350
15396
  {
15351
15397
  "name": "prefix",
15352
- "type": "sring",
15398
+ "type": "String",
15353
15399
  "default": "`nil`",
15354
- "description": "What to prefix the relative ime display with."
15400
+ "description": "What to prefix the relative time display with."
15355
15401
  },
15356
15402
  {
15357
15403
  "name": "second",
@@ -15403,7 +15449,7 @@
15403
15449
  },
15404
15450
  {
15405
15451
  "name": "threshold",
15406
- "type": "string",
15452
+ "type": "String",
15407
15453
  "default": "`nil`",
15408
15454
  "description": "The threshold, in ISO-8601 'durations' format, at which relative time displays become absolute."
15409
15455
  },
@@ -15427,13 +15473,13 @@
15427
15473
  },
15428
15474
  {
15429
15475
  "name": "lang",
15430
- "type": "string",
15476
+ "type": "String",
15431
15477
  "default": "`nil`",
15432
15478
  "description": "The language to use."
15433
15479
  },
15434
15480
  {
15435
15481
  "name": "title",
15436
- "type": "string",
15482
+ "type": "String",
15437
15483
  "default": "`nil`",
15438
15484
  "description": "Provide a custom title to the element."
15439
15485
  },
data/static/previews.json CHANGED
@@ -6624,6 +6624,19 @@
6624
6624
  "color-contrast"
6625
6625
  ]
6626
6626
  }
6627
+ },
6628
+ {
6629
+ "preview_path": "primer/alpha/select_panel/list_of_links",
6630
+ "name": "list_of_links",
6631
+ "snapshot": "interactive",
6632
+ "skip_rules": {
6633
+ "wont_fix": [
6634
+ "region"
6635
+ ],
6636
+ "will_fix": [
6637
+ "color-contrast"
6638
+ ]
6639
+ }
6627
6640
  }
6628
6641
  ]
6629
6642
  },
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openproject-primer_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.41.0
4
+ version: 0.42.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-08-06 00:00:00.000000000 Z
12
+ date: 2024-08-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionview
@@ -568,7 +568,6 @@ files:
568
568
  - app/forms/check_box_group_form.rb
569
569
  - app/forms/check_box_with_nested_form.rb
570
570
  - app/forms/composed_form.rb
571
- - app/forms/custom_width_fields_form.rb
572
571
  - app/forms/example_toggle_switch_form.rb
573
572
  - app/forms/example_toggle_switch_form/example_field_caption.html.erb
574
573
  - app/forms/first_name_form.rb
@@ -856,6 +855,7 @@ files:
856
855
  - previews/primer/alpha/select_panel_preview/eventually_local_fetch_initial_failure.html.erb
857
856
  - previews/primer/alpha/select_panel_preview/eventually_local_fetch_no_results.html.erb
858
857
  - previews/primer/alpha/select_panel_preview/footer_buttons.html.erb
858
+ - previews/primer/alpha/select_panel_preview/list_of_links.html.erb
859
859
  - previews/primer/alpha/select_panel_preview/local_fetch.html.erb
860
860
  - previews/primer/alpha/select_panel_preview/local_fetch_no_results.html.erb
861
861
  - previews/primer/alpha/select_panel_preview/multiselect.html.erb
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nodoc:
4
- class CustomWidthFieldsForm < ApplicationForm
5
- form do |f|
6
- f.text_field(
7
- name: :ultimate_answer,
8
- label: "Ultimate answer",
9
- required: true,
10
- caption: "The answer to life, the universe, and everything",
11
- input_width: :medium
12
- )
13
-
14
- f.select_list(
15
- name: "cities",
16
- label: "Cool cities",
17
- caption: "Select your favorite!",
18
- include_blank: true,
19
- input_width: :small
20
- ) do |city_list|
21
- city_list.option(label: "Lopez Island", value: "lopez_island")
22
- city_list.option(label: "Bellevue", value: "bellevue")
23
- city_list.option(label: "Seattle", value: "seattle")
24
- end
25
- end
26
- end