playbook_ui 12.24.0 → 12.25.0.pre.alpha.PLAY818multilevelrebuild770

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_swift.md +82 -1
  3. data/app/pb_kits/playbook/pb_date/_date.tsx +96 -42
  4. data/app/pb_kits/playbook/pb_date/date.html.erb +22 -2
  5. data/app/pb_kits/playbook/pb_date/date.rb +2 -0
  6. data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.html.erb +30 -0
  7. data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.jsx +47 -0
  8. data/app/pb_kits/playbook/pb_date/docs/_date_unstyled.md +1 -0
  9. data/app/pb_kits/playbook/pb_date/docs/example.yml +4 -4
  10. data/app/pb_kits/playbook/pb_date/docs/index.js +1 -0
  11. data/app/pb_kits/playbook/pb_docs/kit_example.html.erb +14 -13
  12. data/app/pb_kits/playbook/pb_docs/kit_example.rb +0 -2
  13. data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +3 -2
  14. data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +212 -0
  15. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +53 -98
  16. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +340 -86
  17. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.md +1 -1
  18. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_return_all_selected.html.erb +1 -0
  19. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.test.jsx +1 -1
  20. data/app/pb_kits/playbook/pb_time/_time.tsx +71 -35
  21. data/app/pb_kits/playbook/pb_time/docs/_time_unstyled.html.erb +37 -0
  22. data/app/pb_kits/playbook/pb_time/docs/_time_unstyled.jsx +58 -0
  23. data/app/pb_kits/playbook/pb_time/docs/_time_unstyled.md +1 -0
  24. data/app/pb_kits/playbook/pb_time/docs/example.yml +2 -0
  25. data/app/pb_kits/playbook/pb_time/docs/index.js +1 -0
  26. data/app/pb_kits/playbook/pb_time/time.html.erb +26 -7
  27. data/app/pb_kits/playbook/pb_time/time.rb +2 -0
  28. data/app/pb_kits/playbook/pb_title/_title.scss +2 -1
  29. data/app/pb_kits/playbook/pb_title/_title.tsx +3 -2
  30. data/app/pb_kits/playbook/pb_title/title.rb +10 -3
  31. data/app/pb_kits/playbook/pb_title/title.test.js +3 -3
  32. data/dist/playbook-rails.js +51 -0
  33. data/lib/playbook/version.rb +2 -2
  34. data/lib/playbook.rb +1 -2
  35. metadata +19 -43
  36. data/app/pb_kits/playbook/pb_docs/kit_api.html.erb +0 -311
  37. data/app/pb_kits/playbook/pb_docs/kit_api.rb +0 -149
  38. data/app/pb_kits/playbook/pb_multi_level_select/_multi_select_helper.tsx +0 -31
  39. data/app/pb_kits/playbook/pb_multi_level_select/helper_functions.ts +0 -87
  40. data/lib/playbook/markdown/helper.rb +0 -132
  41. data/lib/playbook/markdown.rb +0 -3
@@ -1,87 +0,0 @@
1
- export const findItemById = (
2
- items: { [key: string]: any }[],
3
- id: string
4
- ): any => {
5
- for (const item of items) {
6
- if (item.id === id) {
7
- return item;
8
- }
9
- if (item.children) {
10
- const found = findItemById(item.children, id);
11
- if (found) {
12
- return found;
13
- }
14
- }
15
- }
16
- return null;
17
- };
18
-
19
- export const checkIt = (
20
- foundItem: { [key: string]: any },
21
- selectedItems: any[],
22
- setSelectedItems: Function,
23
- expand: boolean
24
- ) => {
25
- if (!foundItem) {
26
- return;
27
- }
28
-
29
- foundItem.checked = true;
30
- foundItem.expanded = expand;
31
- selectedItems.push(foundItem);
32
-
33
- if (foundItem.children) {
34
- foundItem.children.map((x: any) => {
35
- checkIt(x, selectedItems, setSelectedItems, expand);
36
- });
37
- }
38
-
39
- setSelectedItems([...selectedItems]);
40
- };
41
-
42
- export const unCheckIt = (
43
- foundItem: { [key: string]: any },
44
- selectedItems: any,
45
- setSelectedItems: any,
46
- expand: boolean
47
- ) => {
48
- if (!foundItem) {
49
- return;
50
- }
51
-
52
- foundItem.checked = false;
53
- foundItem.expanded = false;
54
- const newSelectedItems = selectedItems.filter(
55
- (item: any) => item.id !== foundItem.id
56
- );
57
- if (foundItem.children) {
58
- foundItem.children.map((x: any) => {
59
- unCheckIt(x, selectedItems, setSelectedItems, expand);
60
- });
61
- }
62
- setSelectedItems([...newSelectedItems]);
63
- };
64
-
65
-
66
- export const getParentAndAncestorsIds = (itemId:string, items:{ [key: string]: string; }[], ancestors:string[] = []):any => {
67
- for (let i = 0; i < items.length; i++) {
68
- const item:any = items[i];
69
- if (item.id === itemId) {
70
- // item found in current level of items array
71
- return [...ancestors, item.id];
72
- }
73
- if (item.children && item.children.length > 0) {
74
- // recursively search through children
75
- const foundAncestors = getParentAndAncestorsIds(
76
- itemId,
77
- item.children,
78
- [...ancestors, item.id]
79
- );
80
- if (foundAncestors) {
81
- return foundAncestors;
82
- }
83
- }
84
- }
85
- // item not found in this level of items array or its children
86
- return null;
87
- }
@@ -1,132 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "redcarpet"
4
- require "rouge"
5
- require "rouge/plugins/redcarpet"
6
- require "action_view"
7
-
8
- module Playbook
9
- module Markdown
10
- module Helper
11
- def self.call(template, _source)
12
- markdown(template.source)
13
- end
14
-
15
- def render_markdown(text)
16
- # rubocop:disable Security/Eval
17
- eval(Playbook::Markdown::Helper.markdown(text))
18
- # rubocop:enable Security/Eval
19
- end
20
-
21
- def self.markdown(text)
22
- options = {
23
- filter_html: false,
24
- hard_wrap: true,
25
- link_attributes: { rel: "nofollow", target: "_blank" },
26
- space_after_headers: true,
27
- fenced_code_blocks: true,
28
- no_styles: false,
29
- safe_links_only: true,
30
- }
31
-
32
- extensions = {
33
- lax_spacing: true,
34
- no_intra_emphasis: true,
35
- autolink: true,
36
- superscript: true,
37
- fenced_code_blocks: true,
38
- tables: true,
39
- disable_indented_code_blocks: false,
40
- strikethrough: true,
41
- underline: true,
42
- highlight: true,
43
- footnotes: true,
44
- with_toc_data: true,
45
- }
46
-
47
- renderer = HTMLBlockCode.new(options)
48
- # toc_renderer = Redcarpet::Render::HTML_TOC.new(with_toc_data: true)
49
- # @TOC = Redcarpet::Markdown.new(toc_renderer)
50
- # puts "TOC: #{@TOC.inspect}"
51
- markdown = Redcarpet::Markdown.new(renderer, extensions)
52
- "#{markdown.render(text).inspect}.html_safe;"
53
- end
54
-
55
- def rouge(text, language)
56
- formatter = Rouge::Formatters::HTML.new(scope: ".highlight")
57
- lexer = Rouge::Lexer.find(language)
58
- formatter.format(lexer.lex(text))
59
- end
60
-
61
- class HTML < Redcarpet::Render::HTML
62
- include Rouge::Plugins::Redcarpet
63
- end
64
-
65
- def rouge_markdown(text)
66
- render_options = {
67
- filter_html: true,
68
- hard_wrap: true,
69
- link_attributes: { rel: "nofollow" },
70
- }
71
- renderer = HTML.new(render_options)
72
-
73
- extensions = {
74
- autolink: true,
75
- fenced_code_blocks: true,
76
- lax_spacing: true,
77
- no_intra_emphasis: true,
78
- strikethrough: true,
79
- superscript: true,
80
- }
81
- markdown = Redcarpet::Markdown.new(renderer, extensions)
82
- markdown.render(text)
83
- end
84
- end
85
-
86
- class HTMLWithPants < Redcarpet::Render::HTML
87
- include Redcarpet::Render::SmartyPants
88
- end
89
-
90
- class HTML < Redcarpet::Render::HTML
91
- include Rouge::Plugins::Redcarpet
92
- end
93
-
94
- class HTMLBlockCode < Redcarpet::Render::HTML
95
- include ActionView::Helpers::AssetTagHelper
96
-
97
- # def block_code(code, language)
98
- # "\n.nf\n#{normal_text(rouge(code, language))}\n.fi\n"
99
- # end
100
-
101
- def table(header, body)
102
- "<table class='pb_table table-sm table-responsive-collapse table-card table-collapse-sm'>" \
103
- "<thead>#{header}</thead>" \
104
- "<tbody>#{body}</tbody>" \
105
- "</table>"
106
- end
107
-
108
- def header(title, level)
109
- @headers ||= []
110
- permalink = title.gsub(/\W+/, "-")
111
- if @headers.include?(permalink)
112
- permalink += "_1"
113
- loop do
114
- break unless @headers.include?(permalink)
115
-
116
- permalink.gsub!(/_(\d+)$/, "_#{Regexp.last_match(1).to_i + 1}")
117
- end
118
- end
119
- @headers << permalink
120
- permalink_markup = %(<a name="#{permalink}" class="markdown-header-anchor" )
121
- permalink_markup += %(href="##{permalink}"><span class="far fa-link markdown-header-anchor-icon"></span></a>)
122
- %(\n<h#{level} id="#{permalink}">#{title} #{permalink_markup}</h#{level}>\n)
123
- end
124
-
125
- def image(link, title, alt_text)
126
- return nil if link.nil?
127
-
128
- %(<a href="#{link}" target="_blank">#{image_tag(link, title: title, alt: alt_text, class: 'imageloader lazyload')}</a>)
129
- end
130
- end
131
- end
132
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "playbook/markdown/helper"