phlex-cmdk 0.1.0 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +16 -1
- data/assets/js/cmdk_controller.js +1 -1
- data/lib/cmdk/base.rb +6 -0
- data/lib/cmdk/empty.rb +1 -1
- data/lib/cmdk/footer.rb +1 -5
- data/lib/cmdk/group.rb +12 -6
- data/lib/cmdk/item.rb +1 -1
- data/lib/cmdk/list.rb +1 -1
- data/lib/cmdk/loading.rb +1 -1
- data/lib/cmdk/root.rb +1 -5
- data/lib/cmdk/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9c7f8212512b7ffc57adcf7d2428fb10994947b10cc82e920ff8b08d034255eb
|
|
4
|
+
data.tar.gz: 2ec4b781453015d628ff1976b0047a85195980b3584c7eaddc9e2672051e3586
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f2bba3534f26915215bb0fea83fc2e5c5126d4ad34510997d932125693921c2374749d921043a6a65de8f0a9d3ef6082d8053224ca2fc6fc090d71010bb92db6
|
|
7
|
+
data.tar.gz: 6e1623684909b42f34634bd5bc037aa14266544b88b2ede7733d4899e878e843b415a1dd1a1d31ffb407f43bd925787f77e5839cf12551ac71952823fbfe840f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.1 — 2026-06-15
|
|
4
|
+
|
|
5
|
+
- docs: correct the Stimulus base controller import (the bare `cmdk`
|
|
6
|
+
specifier, not `./cmdk.js`); document `dialog_attributes:` and the
|
|
7
|
+
`cmdk-dialog-frame` theme class
|
|
8
|
+
- internal: idiomatic Phlex content-block forwarding; deterministic group
|
|
9
|
+
heading ids (monotonic, replacing a random suffix). No markup or API changes.
|
|
10
|
+
|
|
3
11
|
## 0.1.0 — 2026-06-15
|
|
4
12
|
|
|
5
13
|
Initial release: a feature-parity Phlex port of the cmdk React command menu.
|
data/README.md
CHANGED
|
@@ -147,6 +147,20 @@ Renders a native `<dialog cmdk-dialog>`: Escape and backdrop clicks close it, an
|
|
|
147
147
|
`Cmdk.openDialog(el)` / `Cmdk.closeDialog(el)` toggle it programmatically. Style the
|
|
148
148
|
backdrop with `dialog[cmdk-dialog]::backdrop` (replaces Radix's `[cmdk-overlay]`).
|
|
149
149
|
|
|
150
|
+
Extra attributes on `Cmdk::Dialog(...)` go to the inner `Cmdk::Root`; to set
|
|
151
|
+
attributes on the `<dialog>` element itself, pass `dialog_attributes:`. The
|
|
152
|
+
shipped themes style the dialog frame (transparent border, entry animation)
|
|
153
|
+
behind a `cmdk-dialog-frame` class, opt in the same way you opt into the menu
|
|
154
|
+
theme - by asking for the class:
|
|
155
|
+
|
|
156
|
+
```ruby
|
|
157
|
+
Cmdk::Dialog(label: 'Command Menu', hotkey: 'k', class: 'cmdk',
|
|
158
|
+
dialog_attributes: { class: 'cmdk-dialog-frame' }) do
|
|
159
|
+
Cmdk::Input()
|
|
160
|
+
Cmdk::List() { ... }
|
|
161
|
+
end
|
|
162
|
+
```
|
|
163
|
+
|
|
150
164
|
By default the dialog renders as a top-third, horizontally centered palette; on
|
|
151
165
|
viewports ≤640px it becomes a top-anchored, full-width sheet (the GitHub/Jira
|
|
152
166
|
pattern - the software keyboard owns the bottom of the screen, so the input
|
|
@@ -280,7 +294,8 @@ The bubbling events work with plain action descriptors - no controller required:
|
|
|
280
294
|
|
|
281
295
|
For more structure, the gem ships an optional base controller
|
|
282
296
|
(`Cmdk.stimulus_controller_path`; serve it next to the runtime, it imports
|
|
283
|
-
|
|
297
|
+
the runtime as the bare specifier `cmdk` and `@hotwired/stimulus`). Extend it
|
|
298
|
+
and override the hooks:
|
|
284
299
|
|
|
285
300
|
```js
|
|
286
301
|
import CmdkController from 'cmdk_controller' // pin to Cmdk.stimulus_controller_path
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Extend it and override the hooks you care about:
|
|
10
10
|
*
|
|
11
|
-
* import CmdkController from '
|
|
11
|
+
* import CmdkController from 'cmdk_controller' // pin to Cmdk.stimulus_controller_path
|
|
12
12
|
*
|
|
13
13
|
* export default class extends CmdkController {
|
|
14
14
|
* itemSelected({ detail: { value } }) { this.runCommand(value) }
|
data/lib/cmdk/base.rb
CHANGED
|
@@ -10,6 +10,12 @@ module Cmdk
|
|
|
10
10
|
# Merge user-supplied attributes into the component's defaults.
|
|
11
11
|
# User values win, except `class` and `style` which are concatenated
|
|
12
12
|
# and `data` hashes which are merged.
|
|
13
|
+
#
|
|
14
|
+
# Deliberately not Phlex's `mix`: `mix` treats *every* attribute as a
|
|
15
|
+
# token list (e.g. `mix({role: 'option'}, {role: 'button'})` yields
|
|
16
|
+
# `role: 'option button'`), which is wrong for scalar attributes like
|
|
17
|
+
# `role`/`type`/`tabindex`/`aria-selected` that should be replaced, not
|
|
18
|
+
# appended. Here only `class`/`style`/`data` combine; other scalars override.
|
|
13
19
|
def merged(defaults, overrides)
|
|
14
20
|
defaults.merge(overrides) do |key, default, override|
|
|
15
21
|
case key
|
data/lib/cmdk/empty.rb
CHANGED
data/lib/cmdk/footer.rb
CHANGED
data/lib/cmdk/group.rb
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
require 'securerandom'
|
|
2
|
-
|
|
3
1
|
module Cmdk
|
|
4
2
|
# Groups items together with an optional heading. Port of `<Command.Group>`.
|
|
5
3
|
# Provide `value:` when there is no heading (it is used for sorting groups);
|
|
6
4
|
# with a string heading the value is inferred from it, matching React cmdk.
|
|
7
5
|
class Group < Base
|
|
6
|
+
# Monotonic id source for `aria-labelledby` (the analog of React's useId,
|
|
7
|
+
# which this port mirrors). Deterministic and collision-free, unlike a
|
|
8
|
+
# random suffix; the mutex keeps it correct under threaded servers.
|
|
9
|
+
@heading_seq = 0
|
|
10
|
+
@heading_mutex = Mutex.new
|
|
11
|
+
|
|
12
|
+
def self.next_heading_id
|
|
13
|
+
@heading_mutex.synchronize { "cmdk-heading-#{@heading_seq += 1}" }
|
|
14
|
+
end
|
|
15
|
+
|
|
8
16
|
def initialize(heading: nil, value: nil, force_mount: false, scope: nil, scope_only: false,
|
|
9
17
|
server_filtered: false, **attributes)
|
|
10
18
|
@heading = heading
|
|
@@ -17,15 +25,13 @@ module Cmdk
|
|
|
17
25
|
end
|
|
18
26
|
|
|
19
27
|
def view_template(&block)
|
|
20
|
-
heading_id = @heading ?
|
|
28
|
+
heading_id = @heading ? Group.next_heading_id : nil
|
|
21
29
|
|
|
22
30
|
div(**merged(group_attributes, @attributes)) do
|
|
23
31
|
if @heading
|
|
24
32
|
div('cmdk-group-heading' => '', aria_hidden: 'true', id: heading_id) { @heading }
|
|
25
33
|
end
|
|
26
|
-
div('cmdk-group-items' => '', role: 'group', aria_labelledby: heading_id)
|
|
27
|
-
block ? block.call : nil
|
|
28
|
-
end
|
|
34
|
+
div('cmdk-group-items' => '', role: 'group', aria_labelledby: heading_id, &block)
|
|
29
35
|
end
|
|
30
36
|
end
|
|
31
37
|
|
data/lib/cmdk/item.rb
CHANGED
data/lib/cmdk/list.rb
CHANGED
|
@@ -10,7 +10,7 @@ module Cmdk
|
|
|
10
10
|
|
|
11
11
|
def view_template(&block)
|
|
12
12
|
div(**merged({ 'cmdk-list' => '', role: 'listbox', tabindex: '-1', aria_label: @label }, @attributes)) do
|
|
13
|
-
div('cmdk-list-sizer' => ''
|
|
13
|
+
div('cmdk-list-sizer' => '', &block)
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
end
|
data/lib/cmdk/loading.rb
CHANGED
data/lib/cmdk/root.rb
CHANGED
|
@@ -33,16 +33,12 @@ module Cmdk
|
|
|
33
33
|
def view_template(&block)
|
|
34
34
|
div(**merged(root_attributes, @attributes)) do
|
|
35
35
|
label('cmdk-label' => '', style: SR_ONLY_STYLE) { @label }
|
|
36
|
-
|
|
36
|
+
block&.call
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
private
|
|
41
41
|
|
|
42
|
-
def yield_content(&block)
|
|
43
|
-
block ? block.call : nil
|
|
44
|
-
end
|
|
45
|
-
|
|
46
42
|
def root_attributes
|
|
47
43
|
data = {}
|
|
48
44
|
data[:cmdk_should_filter] = 'false' unless @should_filter
|
data/lib/cmdk/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: phlex-cmdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Leon Gieser
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: bin
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-06-15 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: phlex
|
|
@@ -67,6 +68,7 @@ metadata:
|
|
|
67
68
|
source_code_uri: https://github.com/leongieser/phlex-cmdk
|
|
68
69
|
changelog_uri: https://github.com/leongieser/phlex-cmdk/blob/main/CHANGELOG.md
|
|
69
70
|
rubygems_mfa_required: 'true'
|
|
71
|
+
post_install_message:
|
|
70
72
|
rdoc_options: []
|
|
71
73
|
require_paths:
|
|
72
74
|
- lib
|
|
@@ -81,7 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
81
83
|
- !ruby/object:Gem::Version
|
|
82
84
|
version: '0'
|
|
83
85
|
requirements: []
|
|
84
|
-
rubygems_version:
|
|
86
|
+
rubygems_version: 3.0.3.1
|
|
87
|
+
signing_key:
|
|
85
88
|
specification_version: 4
|
|
86
89
|
summary: 'Fast, composable command menu for Phlex: a port of cmdk (React).'
|
|
87
90
|
test_files: []
|