tramway 2.3.1 → 2.3.1.2

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: 0062ba6e33495a79ef0d2dc0fcca348e7de9ed5a892855d800bc7de45022205d
4
- data.tar.gz: 350731c7514a5b6f3d513635c2397f65a52f81cb50a05ff0e198af191a09b75d
3
+ metadata.gz: afb266e8ff0e57296500fc2181b623ef4abffbe184be90bbb3a6a61431cfcbc8
4
+ data.tar.gz: 7e23e932ff24c6f5c93bbc3a3cd2365c2f66e7b121a690f9c56e51cfe5c3ac60
5
5
  SHA512:
6
- metadata.gz: 4c5ad624bc5aa06c742ac6a02cbaea4accfe21028ec422f5818514a3bb87b854f06e830986f35d767a2fe82f06f0d3ab433e615651522e8ab332d46925e54c58
7
- data.tar.gz: ffd97ea24ee55e590368a3a34beafcb440010358a65db27d0e231629225bcd05f0d0f22987c38f6dc7ebf97193ebc6f26ba76628280b2e1e92169f1b20dd69fa
6
+ metadata.gz: 48eca5f7a2a9c24681f73f164b997e59b21e75efd761fd99f8f765752ed16b226d8823ee124c60fca08c2944c49b91b38d2e8b4808faf424fc804dfb0b8aec40
7
+ data.tar.gz: 11835fac94f5d47052e64a8a6de159eb53385b1ee9dc78f1a0500c8a7b4329eb1f0f607ff8e84c078a66becd1387f0403d78f3b9fe6e43dd6c905ab695c3b50b
data/README.md CHANGED
@@ -863,6 +863,9 @@ the Tailwind color family explicitly.
863
863
  that receives new messages. Each message must include an `:id` and a `:type` (either `:sent` or `:received`). Additional
864
864
  message fields like `text`, `data`, or `sent_at` are forwarded to `tramway/chats/message_component`.
865
865
 
866
+ Use `send_messages_enabled:` to control whether users can send new messages from the rendered form. It defaults to `true`.
867
+ When set to `false`, the text field is disabled and the waiting placeholder is shown.
868
+
866
869
  ```haml
867
870
  -# Haml example
868
871
  - messages = [
@@ -872,7 +875,8 @@ message fields like `text`, `data`, or `sent_at` are forwarded to `tramway/chats
872
875
  = tramway_chat chat_id: 'support-chat',
873
876
  messages: messages,
874
877
  message_form: @message_form,
875
- send_message_path: chat_messages_path
878
+ send_message_path: chat_messages_path,
879
+ send_messages_enabled: @chat.open?
876
880
  ```
877
881
 
878
882
  ```erb
@@ -881,7 +885,8 @@ message fields like `text`, `data`, or `sent_at` are forwarded to `tramway/chats
881
885
  <%= tramway_chat chat_id: 'support-chat',
882
886
  messages: messages,
883
887
  message_form: @message_form,
884
- send_message_path: chat_messages_path %>
888
+ send_message_path: chat_messages_path,
889
+ send_messages_enabled: @chat.open? %>
885
890
  ```
886
891
 
887
892
 
@@ -13,7 +13,7 @@
13
13
  - waiting_placeholder = t('tramway.chat.placeholders.waiting')
14
14
  - typing_placeholder = t('tramway.chat.placeholders.type')
15
15
  = f.text_field :text,
16
- class: 'flex-1 md:rounded-full rounded-bl-2xl md:border border-gray-300 px-4 py-2 text-sm text-gray-900 shadow-sm placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:cursor-not-allowed disabled:bg-gray-100 border-gray-600 bg-gray-800 text-white focus:border-blue-400 focus:ring-blue-500/30',
16
+ class: 'flex-1 md:rounded-full rounded-bl-2xl md:border border-gray-300 px-4 py-2 text-sm text-gray-900 shadow-sm placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200 disabled:cursor-not-allowed border-gray-600 bg-gray-800 text-white focus:border-blue-400 focus:ring-blue-500/30',
17
17
  placeholder: send_messages_enabled ? typing_placeholder : waiting_placeholder,
18
18
  disabled: !send_messages_enabled
19
19
 
@@ -16,11 +16,11 @@
16
16
 
17
17
  - if pending?
18
18
  .pb-1
19
- = inline_svg 'icons/spinner.svg', class: 'w-4 h-4 text-white animate-spin'
19
+ -# = inline_svg 'icons/spinner.svg', class: 'w-4 h-4 text-white animate-spin'
20
20
 
21
21
  - if failed?
22
22
  .pb-1
23
- = inline_svg 'icons/cross.svg', class: 'w-6 h-6 text-red-200'
23
+ -# = inline_svg 'icons/cross.svg', class: 'w-6 h-6 text-red-200'
24
24
 
25
25
  - if data_view == :table
26
26
  = component 'tramway/chats/messages/table', data:
data/docs/AGENTS.md CHANGED
@@ -131,6 +131,8 @@ Inherit all components from Tramway::BaseComponent
131
131
  When you need chat UI, use the `tramway_chat` helper. Pass `chat_id`, `messages`, `message_form`, and `send_message_path`.
132
132
  Each message must include `:id` and a `:type` of `:sent` or `:received`, and other keys (like `:text`, `:data`, `:sent_at`)
133
133
  are forwarded to `tramway/chats/message_component`. Use `message_form: nil` when you only need read-only chat rendering.
134
+ Use `send_messages_enabled:` (defaults to `true`) to control whether the message input is enabled. Set it to `false`
135
+ when chat should be visible but sending is temporarily unavailable.
134
136
 
135
137
  For live updates to a rendered `tramway_chat`, use `tramway_chat_append_message(chat_id:, message_type:, text:, sent_at:)`.
136
138
  This method is included in all controllers and ActiveRecord models. `message_type` must be `:sent` or `:received`, otherwise
@@ -77,7 +77,7 @@ module Tramway
77
77
  component 'tramway/flash', text:, type:, options:
78
78
  end
79
79
 
80
- def tramway_chat(chat_id:, messages:, message_form:, send_message_path:)
80
+ def tramway_chat(chat_id:, messages:, message_form:, send_message_path:, **)
81
81
  unless messages.all? { _1[:id].present? && _1[:type].present? }
82
82
  raise ArgumentError, 'Each message must have :id and :type keys'
83
83
  end
@@ -86,7 +86,7 @@ module Tramway
86
86
  raise ArgumentError, 'Message :type must be either :sent or :received'
87
87
  end
88
88
 
89
- component 'tramway/chat', chat_id:, messages:, message_form:, send_message_path:
89
+ component 'tramway/chat', chat_id:, messages:, message_form:, send_message_path:, **
90
90
  end
91
91
 
92
92
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tramway
4
- VERSION = '2.3.1'
4
+ VERSION = '2.3.1.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kalashnikovisme