klods-ruby 1.5.1 → 1.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcb611f6ddc17e2a0e583696ec39bbde270cd6bbb4d67c6aa898f43b9b5001d2
4
- data.tar.gz: 733b3567eab74cfd33b1915624f7dbf0640026b8c531fb1b418d5c44d577ad3e
3
+ metadata.gz: 47ea1962ef70842eb6ff06eddfd1fb613084d8822a9d0ec349f460d55bb9522b
4
+ data.tar.gz: 767a196c5e55c20f78c6627b9d986681bc277e5ee0fbd5b9e917ccaa26a0d86f
5
5
  SHA512:
6
- metadata.gz: bcc2b4e811428f3988d0aa5a42b7158e5442bd8b199ca48fc7bc598812ee2a3d132f6ae363e0891c1105c12650af1ebf39e99f88e04e1133fb73268c17a4573e
7
- data.tar.gz: b634ffc4cb905b9ea570cb7847f58c6c18c6e9e69c019f683895f39ff0c3f20103a4abe7c37e36d9d7936eba42ce2100b09ff399709015736d78286eb203bd8f
6
+ metadata.gz: ecced1af8507084f5c24ea82cf191e9f16a6d73f14c14a36fc212d31b3a3c8f30057d96f653e0b91d245977436ed68bc7d52b5f1e9d5e0f2c88bbab5df684f00
7
+ data.tar.gz: ff12b0717047ea1ab43a23c4861e8849a23fda4f48fcc85b51798a5d5f0eb2ba35ba55f3233810ab30d0c3431e9c849bc59a758c613775db67b002bffb43f91e
@@ -19,6 +19,7 @@ module Klods
19
19
  include Klods::Components::Modal
20
20
  include Klods::Components::Nav
21
21
  include Klods::Components::Prose
22
+ include Klods::Components::Toc
22
23
  include Klods::Components::Table
23
24
  include Klods::Components::Tabs
24
25
  include Klods::Components::Toast
@@ -72,9 +72,20 @@ module Klods
72
72
  ])
73
73
  when "color"
74
74
  initial = props["value"] || "#000000"
75
+ user_oninput = props.delete("oninput")
76
+ color_oninput = "var h=this.closest('.klods-input--color').querySelector('.klods-color-hex');if(h)h.value=this.value;"
77
+ color_oninput += user_oninput if user_oninput
75
78
  Node.new("span", {"class" => cls.call("klods-input--color")}, [
76
- Node.new("input", props.merge("type" => "color"), nil),
77
- Core.el("output", {"for" => id}, initial.to_s)
79
+ Node.new("input", props.merge("type" => "color", "oninput" => color_oninput), nil),
80
+ Node.new("input", {
81
+ "type" => "text",
82
+ "class" => "klods-color-hex",
83
+ "value" => initial.to_s,
84
+ "maxlength" => "7",
85
+ "spellcheck" => "false",
86
+ "aria-label" => "Hex color value",
87
+ "oninput" => "if(/^#[0-9a-fA-F]{6}$/.test(this.value)){var c=this.closest('.klods-input--color').querySelector('[type=color]');if(c)c.value=this.value}"
88
+ }, nil)
78
89
  ])
79
90
  else
80
91
  Node.new("input", props.merge("type" => type, "class" => cls.call).compact)
@@ -44,28 +44,6 @@ module Klods
44
44
  default_icon = Core.el("span", {"aria-hidden" => "true", "class" => "klods-icon"}, Core.raw(MENU_SVG))
45
45
  Core.el("button", props, children || default_icon)
46
46
  end
47
-
48
- def toc(a = nil, b = nil, &block)
49
- props, children = Core.normalize_args(a, b)
50
- children = klods_capture(&block) if block
51
- Core.build(
52
- tag: "ul", base: "klods-toc",
53
- modifiers: {sub: "klods-toc--sub"},
54
- props: props, children: children
55
- )
56
- end
57
-
58
- def toc_item(a = nil, b = nil, &block)
59
- props, children = Core.normalize_args(a, b)
60
- children = klods_capture(&block) if block
61
- Core.el("li", props, children)
62
- end
63
-
64
- def toc_link(a = nil, b = nil, &block)
65
- props, children = Core.normalize_args(a, b)
66
- children = klods_capture(&block) if block
67
- Core.el("a", props, children)
68
- end
69
47
  end
70
48
  end
71
49
  end
@@ -0,0 +1,31 @@
1
+ module Klods
2
+ module Components
3
+ module Toc
4
+ def toc(a = nil, b = nil, &block)
5
+ props, children = Core.normalize_args(a, b)
6
+ children = klods_capture(&block) if block
7
+ Core.build(
8
+ tag: "ul", base: "klods-toc",
9
+ modifiers: {sub: "klods-toc--sub"},
10
+ props: props, children: children
11
+ )
12
+ end
13
+
14
+ def toc_item(a = nil, b = nil, &block)
15
+ props, children = Core.normalize_args(a, b)
16
+ children = klods_capture(&block) if block
17
+ Core.el("li", props, children)
18
+ end
19
+
20
+ def toc_link(a = nil, b = nil, &block)
21
+ props, children = Core.normalize_args(a, b)
22
+ children = klods_capture(&block) if block
23
+ Core.build(
24
+ tag: "a", base: "klods-toc__link",
25
+ modifiers: {active: "klods-toc__link--active"},
26
+ props: props, children: children
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
@@ -16,5 +16,6 @@ require_relative "components/nav"
16
16
  require_relative "components/prose"
17
17
  require_relative "components/table"
18
18
  require_relative "components/tabs"
19
+ require_relative "components/toc"
19
20
  require_relative "components/toast"
20
21
  require_relative "components/tooltip"
data/lib/klods/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Klods
2
- VERSION = "1.5.1"
2
+ VERSION = "1.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klods-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drue Wilding
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-28 00:00:00.000000000 Z
11
+ date: 2026-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -96,6 +96,7 @@ files:
96
96
  - lib/klods/components/table.rb
97
97
  - lib/klods/components/tabs.rb
98
98
  - lib/klods/components/toast.rb
99
+ - lib/klods/components/toc.rb
99
100
  - lib/klods/components/tooltip.rb
100
101
  - lib/klods/core.rb
101
102
  - lib/klods/form_builder.rb