solid_litequeen 0.17.1 → 0.18.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: 2682d0adf95eb9a8276baa100bfbfcf34ec3bfcb732d258bf3039374b3fe6ca9
4
- data.tar.gz: 904b347032c83841d782b5bbecc950ebe3c3c71bfbcf23a2787c7dd984fa8ca7
3
+ metadata.gz: 916bcf8973a0feb19689908e0745142ec3fbc2b006c3cfb19a5fc961d6395643
4
+ data.tar.gz: c2dd68e7ae0c589fc4bf25c879316973485b0c2aed15a9cc7f0d07fec4d023c5
5
5
  SHA512:
6
- metadata.gz: 1b1e9a083ac3ba78a8674b27971035f780b575f44af89e8211d10aab59198bdce9d97fe284ea83fad8ed4f3181cba86a41eee3249a335cc4f2cdea338b08552c
7
- data.tar.gz: a7250db5da377b7cbf2c2532388d77c97e3f99409ae3b5ed170ffa9db1d08a6284a9b9633ad0e18b67294b8fb81a3f990c6d1fdc6c16db8f8eea163f68d34df3
6
+ metadata.gz: a2dc53956b2b4193373436dad827fb45dac587f7393a84bc23b34d23531043cf498578e107e0325743c91c6ebe006f79422633c564d0fce53d2b501f6101fcaf
7
+ data.tar.gz: dc6cdf559a7481e5e478c3f5c945d6bad36bf5a99563beaae4ef58838bac91e4f50f3319c34b879b6b437e0af79e632cd53ee8b610e4004891be81c1d59cfd75
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clipboard-copy"><rect width="8" height="4" x="8" y="2" rx="1" ry="1"></rect><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"></path><path d="M16 4h2a2 2 0 0 1 2 2v4"></path><path d="M21 14H11"></path><path d="m15 10-4 4 4 4"></path></svg>
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Clipboard copy function
3
+ *
4
+ * eg:
5
+ *
6
+ <div data-controller="clipboard" class="relative">
7
+ <button title="Copy" data-action="clipboard#copy" class="absolute top-2 right-2 hover:cursor-pointer">
8
+ <%= image_tag "solid_litequeen/icons/copy-clipboard.svg", class: "in-data-copied:hidden size-5 dark:filter-white" %>
9
+ <span class="hidden in-data-copied:block">Copied!</span>
10
+ </button>
11
+
12
+ <p data-clipboard-target="source"> Potato </p>
13
+ </div>
14
+ *
15
+ *
16
+ * */
17
+
18
+
19
+ import { Controller } from "@hotwired/stimulus";
20
+
21
+ // Connects to data-controller="clipboard"
22
+ export default class extends Controller {
23
+ // data-clipboard-target="source"
24
+ static targets = ["source"];
25
+
26
+ // data-action="clipboard#copy"
27
+ copy() {
28
+ if (this.sourceTarget) {
29
+ const text = this.sourceTarget.value || this.sourceTarget.textContent;
30
+ navigator.clipboard.writeText(text);
31
+
32
+ const button = this.element.querySelector("button");
33
+
34
+ button.setAttribute("data-copied", true)
35
+
36
+ setTimeout(() => {
37
+ button.removeAttribute("data-copied")
38
+ }, 2000);
39
+ }
40
+ }
41
+ }
@@ -105,9 +105,10 @@ export default class extends Controller {
105
105
  }).then((result) => {
106
106
  if (result.ok) {
107
107
  // Get all rows in the table body
108
- const tbody = this.element.querySelector("tbody");
108
+ const tbody = this.element.querySelector("tbody.main");
109
109
  const rows = Array.from(tbody.querySelectorAll("tr"));
110
110
 
111
+
111
112
  // Reorder cells in each row to match new column order
112
113
  for (const row of rows) {
113
114
  const cells = Array.from(row.querySelectorAll("td"));
@@ -48,6 +48,7 @@
48
48
  filter: invert(32%) sepia(65%) saturate(6380%) hue-rotate(219deg) brightness(98%) contrast(102%);
49
49
  }
50
50
 
51
+
51
52
  @utility filter-cyan{
52
53
  filter: invert(67%) sepia(62%) saturate(4644%) hue-rotate(156deg) brightness(97%) contrast(101%);
53
54
  }
@@ -1,3 +1,19 @@
1
+ <%
2
+ # Try to parse the data as JSON if possible
3
+ begin
4
+ parsed_json = JSON.parse(data) if data.is_a?(String)
5
+
6
+ # in case the json string is doubly encoded
7
+ if parsed_json.is_a?(String)
8
+ parsed_json = JSON.parse(parsed_json)
9
+ end
10
+
11
+ is_json = parsed_json.present?
12
+ rescue JSON::ParserError
13
+ is_json = false
14
+ end
15
+ %>
16
+
1
17
  <dialog id="<%= dialog_id %>" data-controller="dialog" class="bg-[var(--color-background-light)] dark:border dark:rounded dark:border-gray-50/20 w-[800px] m-auto overscroll-y-contain">
2
18
  <div class="flex flex-row-reverse">
3
19
  <button data-action="click->dialog#close" class="cursor-pointer mr-4 mt-2 outline-none">
@@ -6,10 +22,20 @@
6
22
  </div>
7
23
 
8
24
  <h1 class="text-lg font-semibold text-center"><%= column_name %></h1>
25
+
26
+ <div data-controller="clipboard" class="relative flex items-center max-w-[90%] h-80 max-h-80 mx-auto my-4 p-2 dark:bg-transparent bg-gray-100 dark:border dark:border-gray-50/50 rounded ">
27
+
28
+ <button title="Copy" data-action="clipboard#copy" class="absolute top-2 right-2 hover:cursor-pointer">
29
+ <%= image_tag "solid_litequeen/icons/copy-clipboard.svg", class: "in-data-copied:hidden size-5 dark:filter-white opacity-50" %>
30
+ <span class="hidden in-data-copied:block">Copied!</span>
31
+ </button>
9
32
 
10
- <div class="flex items-center max-w-[90%] h-80 max-h-80 mx-auto my-4 p-2 dark:bg-transparent bg-gray-100 dark:border dark:border-gray-50/50 rounded ">
11
- <p class="text-wrap overflow-auto w-[inherit] h-[inherit] p-2">
12
- <%= data %>
13
- </p>
33
+ <% if is_json %>
34
+ <pre data-clipboard-target="source" class="text-wrap overflow-auto w-full h-[inherit] p-2"><%= JSON.pretty_generate(parsed_json) %></pre>
35
+ <% else %>
36
+ <p data-clipboard-target="source" class="text-wrap overflow-auto w-[inherit] h-[inherit] p-2">
37
+ <%= data %>
38
+ </p>
39
+ <% end %>
14
40
  </div>
15
41
  </dialog>
@@ -149,7 +149,7 @@
149
149
  </tr>
150
150
  </thead>
151
151
 
152
- <tbody class="divide-y divide-gray-200 dark:divide-gray-200/50">
152
+ <tbody class="main divide-y divide-gray-200 dark:divide-gray-200/50">
153
153
  <% @data.rows.each do |row| %>
154
154
  <tr class="hover:bg-gray-50 dark:hover:bg-[var(--color-background-light)]/50" >
155
155
  <% row.each_with_index do |item, index| %>
@@ -181,7 +181,7 @@
181
181
 
182
182
  <% end %>
183
183
 
184
-
184
+
185
185
  <%# TODO: we can use one dynamic modal instead and fetch the data. for now this works and is (s)crapy! %>
186
186
  <% if truncated_item&.to_s&.ends_with?("...") %>
187
187
  <% dialog_id = "#{column_name}_#{SecureRandom.hex(8)}_context_dialog" %>
@@ -1,3 +1,3 @@
1
1
  module SolidLitequeen
2
- VERSION = "0.17.1"
2
+ VERSION = "0.18.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_litequeen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vik Borges
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-02 00:00:00.000000000 Z
11
+ date: 2025-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -166,6 +166,7 @@ files:
166
166
  - app/assets/images/solid_litequeen/icons/chevron-left.svg
167
167
  - app/assets/images/solid_litequeen/icons/chevron-right.svg
168
168
  - app/assets/images/solid_litequeen/icons/circle-elipsis.svg
169
+ - app/assets/images/solid_litequeen/icons/copy-clipboard.svg
169
170
  - app/assets/images/solid_litequeen/icons/database.svg
170
171
  - app/assets/images/solid_litequeen/icons/info.svg
171
172
  - app/assets/images/solid_litequeen/icons/spline.svg
@@ -178,6 +179,7 @@ files:
178
179
  - app/helpers/solid_litequeen/databases_helper.rb
179
180
  - app/javascript/solid_litequeen/application.js
180
181
  - app/javascript/solid_litequeen/controllers/application.js
182
+ - app/javascript/solid_litequeen/controllers/clipboard_controller.js
181
183
  - app/javascript/solid_litequeen/controllers/dialog_controller.js
182
184
  - app/javascript/solid_litequeen/controllers/index.js
183
185
  - app/javascript/solid_litequeen/controllers/table_controller.js