daisyui 2.2.4 → 2.2.5

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: e5b1aef3857af3a5ad3d0219e498a2ec51e8f57801a9dd5f42ec420cb63934f8
4
- data.tar.gz: b80b3f2c4c0b3863364a12246c62d42f31668a63f91fcfd4ced9e4cfcbeaf5e5
3
+ metadata.gz: e5426db516b2301ab0215c1692f1abff5d948f92e27744482efe7d0bdd704f67
4
+ data.tar.gz: df7483725238a8f3687ae9de19d8efefb7467ce049158ac14f6ad53d844b3d13
5
5
  SHA512:
6
- metadata.gz: 23b87a9d555d2bbf256d0e45444c10251618dc491746f7a7eecbc265b57799ebde4a46f6a6e50d3a8e194ec20eb45382791d03b007440063dd3facfb852841dc
7
- data.tar.gz: 494c414242227f80a4c2e51cd2c354d023ac0c37618bc397120fa28c8f31bdb9a302694f58a53ccddedcfca93cf14a45aacc5760de8b53a220484002f13c6e17
6
+ metadata.gz: e9afb92515be4fbce941d8c6d9f38fdc09cfe141c5dc1ddac1c52bc0a21467d20eaa9f7c3486274b8af78f1989236484f7c412e0b0f64e1239ac62cc60f28dc0
7
+ data.tar.gz: e84861fc1768a9905de25d9c15447ebd9b143462e494b5fc3b129f8d5647232b1a43c826c9b8d88641392fd909115570c76353b649682f09ac8a6441d1f24e04
data/CHANGELOG.md CHANGED
@@ -8,6 +8,16 @@
8
8
  examples, the docs site builds on daisyUI 5.7, and the docs CSS makes
9
9
  `.otp > input` inherit its font-size, which `@tailwindcss/forms` had reset
10
10
  to 1rem so typed digits drifted out of their boxes (#78).
11
+ - A component's modifier map is built once per class and published
12
+ configuration and shared by every instance, instead of merged anew on each
13
+ lookup (five times for `Button.new(:primary, :sm, :outline)`). Rendering that
14
+ button allocates about 60% fewer objects. The cache needs a published
15
+ configuration: under Rails the engine finalizes DaisyUI at boot; elsewhere
16
+ call `DaisyUI.configure` or `DaisyUI.finalize!` once at boot, or the map is
17
+ still built per lookup. The map is now frozen: a subclass that overrides the
18
+ private `modifier_map` and mutates `super`'s Hash must `dup` it first. The
19
+ private instance method `configured_modifiers` is gone; overriding it no
20
+ longer changes the map (#80).
11
21
 
12
22
  ### Fixed
13
23
 
data/lib/daisy_ui/base.rb CHANGED
@@ -201,8 +201,42 @@ module DaisyUI
201
201
 
202
202
  subclass.component_class = @component_class
203
203
  end
204
+
205
+ # @api private Every modifier an instance accepts, built once per
206
+ # configuration and modifiers registry and shared by every instance.
207
+ # Both are replaced, never mutated, once frozen (configure publishes a
208
+ # new configuration, register_modifiers assigns a new registry), so a
209
+ # cache keyed on their identity misses after either change; the class
210
+ # is in the key too, as Class#dup copies the ivar. Remembered on the
211
+ # main Ractor only, and only for a frozen (published) configuration;
212
+ # otherwise built per call.
213
+ def modifier_map_for(configuration)
214
+ cacheable = configuration.frozen? && Store.main_ractor?
215
+ registry = modifiers
216
+ if cacheable && (cached = @modifier_map_cache) &&
217
+ cached[0].equal?(self) && cached[1].equal?(configuration) && cached[2].equal?(registry)
218
+ return cached[3]
219
+ end
220
+
221
+ map = {
222
+ skeleton: "skeleton",
223
+ **(registry || {}),
224
+ **configured_modifiers_for(configuration),
225
+ **configuration.modifiers.for(component: nil)
226
+ }.freeze
227
+ @modifier_map_cache = [self, configuration, registry, map].freeze if cacheable
228
+ map
229
+ end
204
230
  # rubocop:enable ThreadSafety/ClassInstanceVariable
205
231
 
232
+ # @api private Modifiers added with `config.modifiers.add(component:)`
233
+ # for this class or any DaisyUI ancestor; the closest class wins.
234
+ def configured_modifiers_for(configuration)
235
+ ancestors.take_while { |klass| klass != Base }.reverse.reduce({}) do |result, klass|
236
+ result.merge(configuration.modifiers.for(component: klass))
237
+ end
238
+ end
239
+
206
240
  # Registers modifiers. A Hash value declares a group of alternatives:
207
241
  #
208
242
  # register_modifiers(
@@ -341,21 +375,9 @@ module DaisyUI
341
375
  end.compact
342
376
  end
343
377
 
378
+ # Frozen and shared by every instance (see .modifier_map_for).
344
379
  def modifier_map
345
- {
346
- skeleton: "skeleton",
347
- **(self.class.modifiers || {}),
348
- **configured_modifiers,
349
- **DaisyUI.configuration.modifiers.for(component: nil)
350
- }
351
- end
352
-
353
- # Modifiers added with `config.modifiers.add(component:)` for this class or
354
- # any DaisyUI ancestor; the closest class wins.
355
- def configured_modifiers
356
- self.class.ancestors.take_while { |klass| klass != Base }.reverse.reduce({}) do |result, klass|
357
- result.merge(DaisyUI.configuration.modifiers.for(component: klass))
358
- end
380
+ self.class.modifier_map_for(DaisyUI.configuration)
359
381
  end
360
382
 
361
383
  # Reports positional modifiers that are neither in modifier_map nor a
@@ -3,5 +3,5 @@
3
3
  module DaisyUI
4
4
  # This timestamp is automatically updated when releasing a new version
5
5
  # Format: YYYY-MM-DD HH:MM:SS UTC
6
- UPDATED_AT = "2026-11-09 17:11:55 UTC"
6
+ UPDATED_AT = "2026-11-18 08:03:12 UTC"
7
7
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DaisyUI
4
- VERSION = "2.2.4"
4
+ VERSION = "2.2.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daisyui
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson