lilac-extras 0.2.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ed2a7bd8d4bfa52b2446a8a6c781550eae8bbb6daee7e3ab7d9c8f2aaf94a0df
4
+ data.tar.gz: 2d2f7d90306b81b05a3a22908917e5f8fccaa81570cdfcec7585dad63fc78488
5
+ SHA512:
6
+ metadata.gz: efbcaed0fa2d882f4b7000d275313ee69ac6451399fab4816ff0dd22e0a316e587b7609f2cf882f5da0061f470f3a063bc177a138def7b6cf4e997b837e7f16b
7
+ data.tar.gz: c5f1b76a5fe835b05ec1343e7553ae57dc372c4483471f697b9156004a2b7daa35976c0a54ce3820ef598a632afed524a5cc0174afec8d0236b632ee0a738114
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "lilac-extras"
5
+ spec.version = "0.2.0"
6
+ spec.authors = ["takahashim"]
7
+
8
+ spec.summary = "Lilac package: `data-tooltip` and `data-autofocus` directives"
9
+ spec.description = "Adds `data-tooltip` (bind the `title` attribute to a " \
10
+ "signal) and `data-autofocus` (focus the element after " \
11
+ "mount) to apps built with the lilac-compiled wasm " \
12
+ "variant. Picked up automatically by `lilac build` via " \
13
+ "Bundler when the gem appears in the project's Gemfile."
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.2.0"
16
+
17
+ # mrblib `.rb` source is the canonical distribution. `lilac build`
18
+ # compiles it to mruby bytecode at the user's build time so the
19
+ # produced `.mrb` matches the locally-vendored core wasm's mruby
20
+ # version — no peer-dep dance required.
21
+ spec.files = Dir["mrblib/**/*.rb", "*.gemspec"]
22
+
23
+ spec.metadata = {
24
+ # Sentinel for `Lilac::CLI::PackageDiscovery`. lilac-cli walks
25
+ # `Bundler.load.specs` and selects entries where this is "true",
26
+ # then reads `mrblib/*.rb` to feed `lilac package-build`.
27
+ "lilac_package" => "true",
28
+ "source_code_uri" => "https://github.com/takahashim/lilac",
29
+ "rubygems_mfa_required" => "true",
30
+ }
31
+ end
@@ -0,0 +1,13 @@
1
+ # Lilac::Extras — small directive packages demonstrating the
2
+ # Scanner extension API. Each directive lives in its own file:
3
+ #
4
+ # - lilac_extras_tooltip.rb → data-tooltip="@msg"
5
+ # - lilac_extras_focus.rb → data-focus="@signal" + data-autofocus
6
+ #
7
+ # These also serve as the worked examples for the directive package
8
+ # protocol (see docs/lilac-package-spec.md).
9
+
10
+ module Lilac
11
+ module Extras
12
+ end
13
+ end
@@ -0,0 +1,23 @@
1
+ # data-autofocus — value-less flag directive. Calls element.focus()
2
+ # on mount (Scanner runs after the component's DOM subtree is in the
3
+ # live tree, so direct focus is safe).
4
+ #
5
+ # Equivalent to HTML's `autofocus` attribute, but framework-driven:
6
+ # component remounts (route changes, bind_list re-renders) re-fire the
7
+ # focus, where HTML's autofocus is honoured only at initial page load.
8
+ #
9
+ # Class-first Handler form (ADR-0027).
10
+
11
+ module Lilac
12
+ module Extras
13
+ class AutofocusDirective < Lilac::Directives::Handler
14
+ attribute "data-autofocus"
15
+
16
+ def wire(ctx)
17
+ ctx.element.to_js.call(:focus)
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ Lilac::Directives::Scanner.register("Lilac::Extras::AutofocusDirective")
@@ -0,0 +1,29 @@
1
+ # data-tooltip="@msg" / data-tooltip="field_name" — reactive title-attribute
2
+ # binding. Mirrors the data-text shape but writes the `title` attribute
3
+ # instead of textContent. Inside data-each scopes, a bare identifier
4
+ # refers to a field of the current iteration item; outside iteration,
5
+ # bare identifiers silent-skip (matching data-text semantics).
6
+ #
7
+ # Class-first Handler form (ADR-0027). Registration is by class-name
8
+ # String so the `Lilac::Directives::Scanner.register` call works
9
+ # regardless of which file is loaded first.
10
+
11
+ module Lilac
12
+ module Extras
13
+ class TooltipDirective < Lilac::Directives::Handler
14
+ attribute "data-tooltip"
15
+
16
+ def wire(ctx)
17
+ v = ctx.value
18
+ unless v.is_a?(Lilac::Directives::Value)
19
+ raise Lilac::Error,
20
+ "Invalid value for data-tooltip: #{ctx.raw_value.inspect} " \
21
+ "(expected `@ivar` or bare identifier)"
22
+ end
23
+ ctx.bind_attribute("title", to: v)
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ Lilac::Directives::Scanner.register("Lilac::Extras::TooltipDirective")
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lilac-extras
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - takahashim
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Adds `data-tooltip` (bind the `title` attribute to a signal) and `data-autofocus`
13
+ (focus the element after mount) to apps built with the lilac-compiled wasm variant.
14
+ Picked up automatically by `lilac build` via Bundler when the gem appears in the
15
+ project's Gemfile.
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lilac-extras.gemspec
21
+ - mrblib/lilac_extras.rb
22
+ - mrblib/lilac_extras_focus.rb
23
+ - mrblib/lilac_extras_tooltip.rb
24
+ licenses:
25
+ - MIT
26
+ metadata:
27
+ lilac_package: 'true'
28
+ source_code_uri: https://github.com/takahashim/lilac
29
+ rubygems_mfa_required: 'true'
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: 3.2.0
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubygems_version: 3.6.9
45
+ specification_version: 4
46
+ summary: 'Lilac package: `data-tooltip` and `data-autofocus` directives'
47
+ test_files: []