its-showtime 0.1.2 → 0.1.4
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/README.md +14 -0
- data/lib/showtime/components/alerts.rb +17 -1
- data/lib/showtime/components/charts.rb +42 -0
- data/lib/showtime/components/data.rb +18 -0
- data/lib/showtime/components/inputs.rb +93 -0
- data/lib/showtime/components/layout.rb +23 -1
- data/lib/showtime/components/media.rb +9 -0
- data/lib/showtime/components/sidebar.rb +3 -0
- data/lib/showtime/components/text.rb +43 -0
- data/lib/showtime/version.rb +1 -1
- data/lib/showtime.rb +23 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 834337794ce2ba312ccb6030482cc4d61fbaa0bd878754ca42d780ef57caa995
|
|
4
|
+
data.tar.gz: 5a8d5683a761f2148a4b690842f06677b467f8cc0deeb1ae2812d49f14990988
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e13f8f3b256f53ff551d2e0e4315335cf4eab6719ce0055896ffdca92a0d7e69053de804272900d020ac9a00dfaa068d1c402cac25bf36e148de198f0ac94404
|
|
7
|
+
data.tar.gz: f64b560bbb5c1e4f8f30c955e784e0fe4a67aa5a384ad1570946563b069d165cb79f6a3486b0c36db810a706d9b6b773544ec473011a1a7c4944b427dc876b36
|
data/README.md
CHANGED
|
@@ -113,6 +113,20 @@ Visit `http://localhost:8501` in your web browser to see your app in action.
|
|
|
113
113
|
|
|
114
114
|
Bug reports and pull requests are welcome on GitHub at https://github.com/glmaljkovich/showtime.
|
|
115
115
|
|
|
116
|
+
### Commit Conventions
|
|
117
|
+
|
|
118
|
+
This project uses Conventional Commits so `git-chglog` can generate changelogs. Configure hooks with:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
git config core.hooksPath .githooks
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Or run:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
bundle exec rake setup_hooks
|
|
128
|
+
```
|
|
129
|
+
|
|
116
130
|
### Development Requirements
|
|
117
131
|
|
|
118
132
|
For development, you'll need:
|
|
@@ -64,20 +64,36 @@ module Showtime
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
module St
|
|
67
|
+
# Add an info alert to the current session.
|
|
68
|
+
#
|
|
69
|
+
# @param text [String] alert message
|
|
70
|
+
# @return [Showtime::Components::Info] created component
|
|
67
71
|
def self.info(text)
|
|
68
72
|
Showtime::session.add_element(Showtime::Components::Info.new(text))
|
|
69
73
|
end
|
|
70
74
|
|
|
75
|
+
# Add a success alert to the current session.
|
|
76
|
+
#
|
|
77
|
+
# @param text [String] alert message
|
|
78
|
+
# @return [Showtime::Components::Success] created component
|
|
71
79
|
def self.success(text)
|
|
72
80
|
Showtime::session.add_element(Showtime::Components::Success.new(text))
|
|
73
81
|
end
|
|
74
82
|
|
|
83
|
+
# Add a warning alert to the current session.
|
|
84
|
+
#
|
|
85
|
+
# @param text [String] alert message
|
|
86
|
+
# @return [Showtime::Components::Warning] created component
|
|
75
87
|
def self.warning(text)
|
|
76
88
|
Showtime::session.add_element(Showtime::Components::Warning.new(text))
|
|
77
89
|
end
|
|
78
90
|
|
|
91
|
+
# Add an error alert to the current session.
|
|
92
|
+
#
|
|
93
|
+
# @param text [String] alert message
|
|
94
|
+
# @return [Showtime::Components::Error] created component
|
|
79
95
|
def self.error(text)
|
|
80
96
|
Showtime::session.add_element(Showtime::Components::Error.new(text))
|
|
81
97
|
end
|
|
82
98
|
end
|
|
83
|
-
end
|
|
99
|
+
end
|
|
@@ -80,36 +80,78 @@ module Showtime
|
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
module St
|
|
83
|
+
# Add a line chart to the current session.
|
|
84
|
+
#
|
|
85
|
+
# @param data [Object] data to chart
|
|
86
|
+
# @param options [Hash] encoding and chart options (includes standard Plotly options for line charts)
|
|
87
|
+
# @param key [Object, nil] component key
|
|
88
|
+
# @param help [String, nil] helper text shown in the UI
|
|
89
|
+
# @return [Hash, nil] chart spec payload
|
|
83
90
|
def self.line_chart(data, options = {}, key: nil, help: nil)
|
|
84
91
|
component = Showtime::Components::LineChart.new(data, options, key: key, help: help)
|
|
85
92
|
Showtime::session.add_element(component)
|
|
86
93
|
component.spec
|
|
87
94
|
end
|
|
88
95
|
|
|
96
|
+
# Add a bar chart to the current session.
|
|
97
|
+
#
|
|
98
|
+
# @param data [Object] data to chart
|
|
99
|
+
# @param options [Hash] encoding and chart options (includes standard Plotly options for bar charts)
|
|
100
|
+
# @param key [Object, nil] component key
|
|
101
|
+
# @param help [String, nil] helper text shown in the UI
|
|
102
|
+
# @return [Hash, nil] chart spec payload
|
|
89
103
|
def self.bar_chart(data, options = {}, key: nil, help: nil)
|
|
90
104
|
component = Showtime::Components::BarChart.new(data, options, key: key, help: help)
|
|
91
105
|
Showtime::session.add_element(component)
|
|
92
106
|
component.spec
|
|
93
107
|
end
|
|
94
108
|
|
|
109
|
+
# Add a column chart to the current session.
|
|
110
|
+
#
|
|
111
|
+
# @param data [Object] data to chart
|
|
112
|
+
# @param options [Hash] encoding and chart options (includes standard Plotly options for column charts)
|
|
113
|
+
# @param key [Object, nil] component key
|
|
114
|
+
# @param help [String, nil] helper text shown in the UI
|
|
115
|
+
# @return [Hash, nil] chart spec payload
|
|
95
116
|
def self.column_chart(data, options = {}, key: nil, help: nil)
|
|
96
117
|
component = Showtime::Components::ColumnChart.new(data, options, key: key, help: help)
|
|
97
118
|
Showtime::session.add_element(component)
|
|
98
119
|
component.spec
|
|
99
120
|
end
|
|
100
121
|
|
|
122
|
+
# Add an area chart to the current session.
|
|
123
|
+
#
|
|
124
|
+
# @param data [Object] data to chart
|
|
125
|
+
# @param options [Hash] encoding and chart options (includes standard Plotly options for area charts)
|
|
126
|
+
# @param key [Object, nil] component key
|
|
127
|
+
# @param help [String, nil] helper text shown in the UI
|
|
128
|
+
# @return [Hash, nil] chart spec payload
|
|
101
129
|
def self.area_chart(data, options = {}, key: nil, help: nil)
|
|
102
130
|
component = Showtime::Components::AreaChart.new(data, options, key: key, help: help)
|
|
103
131
|
Showtime::session.add_element(component)
|
|
104
132
|
component.spec
|
|
105
133
|
end
|
|
106
134
|
|
|
135
|
+
# Add a pie chart to the current session.
|
|
136
|
+
#
|
|
137
|
+
# @param data [Object] data to chart
|
|
138
|
+
# @param options [Hash] label/value mapping options (includes standard Plotly options for pie charts)
|
|
139
|
+
# @param key [Object, nil] component key
|
|
140
|
+
# @param help [String, nil] helper text shown in the UI
|
|
141
|
+
# @return [Hash, nil] chart spec payload
|
|
107
142
|
def self.pie_chart(data, options = { label: :label, value: :value }, key: nil, help: nil)
|
|
108
143
|
component = Showtime::Components::PieChart.new(data, options, key: key, help: help)
|
|
109
144
|
Showtime::session.add_element(component)
|
|
110
145
|
component.spec
|
|
111
146
|
end
|
|
112
147
|
|
|
148
|
+
# Add a scatter plot to the current session.
|
|
149
|
+
#
|
|
150
|
+
# @param data [Object] data to chart
|
|
151
|
+
# @param options [Hash] encoding and chart options (includes standard Plotly options for scatter charts)
|
|
152
|
+
# @param key [Object, nil] component key
|
|
153
|
+
# @param help [String, nil] helper text shown in the UI
|
|
154
|
+
# @return [Hash, nil] chart spec payload
|
|
113
155
|
def self.scatter_plot(data, options = {}, key: nil, help: nil)
|
|
114
156
|
component = Showtime::Components::ScatterPlot.new(data, options, key: key, help: help)
|
|
115
157
|
Showtime::session.add_element(component)
|
|
@@ -313,14 +313,32 @@ module Showtime
|
|
|
313
313
|
end
|
|
314
314
|
|
|
315
315
|
module St
|
|
316
|
+
# Add a JSON viewer element to the current session.
|
|
317
|
+
#
|
|
318
|
+
# @param data [Object] data to render as JSON
|
|
319
|
+
# @return [Showtime::Components::Json] created component
|
|
316
320
|
def self.json(data)
|
|
317
321
|
Showtime::session.add_element(Showtime::Components::Json.new(data))
|
|
318
322
|
end
|
|
319
323
|
|
|
324
|
+
# Add a table element to the current session.
|
|
325
|
+
#
|
|
326
|
+
# @param data [Object] table data
|
|
327
|
+
# @param page_size [Integer] number of rows per page
|
|
328
|
+
# @param current_page [Integer] initial page number
|
|
329
|
+
# @param key [Object, nil] component key
|
|
330
|
+
# @return [Showtime::Components::Table] created component
|
|
320
331
|
def self.table(data, page_size: 10, current_page: 1, key: nil)
|
|
321
332
|
Showtime::session.add_element(Showtime::Components::Table.new(data, page_size: page_size, current_page: current_page, key: key))
|
|
322
333
|
end
|
|
323
334
|
|
|
335
|
+
# Add a dataframe element to the current session.
|
|
336
|
+
#
|
|
337
|
+
# @param data [Object] dataframe data
|
|
338
|
+
# @param page_size [Integer] number of rows per page
|
|
339
|
+
# @param current_page [Integer] initial page number
|
|
340
|
+
# @param key [Object, nil] component key
|
|
341
|
+
# @return [Showtime::Components::DataFrame] created component
|
|
324
342
|
def self.dataframe(data, page_size: 10, current_page: 1, key: nil)
|
|
325
343
|
Showtime::session.add_element(Showtime::Components::DataFrame.new(data, page_size: page_size, current_page: current_page, key: key))
|
|
326
344
|
end
|
|
@@ -343,46 +343,139 @@ module Showtime
|
|
|
343
343
|
end
|
|
344
344
|
|
|
345
345
|
module St
|
|
346
|
+
# Add a button element to the current session.
|
|
347
|
+
#
|
|
348
|
+
# @param label [String] button label
|
|
349
|
+
# @param key [Object, nil] component key
|
|
350
|
+
# @param help [String, nil] helper text shown in the UI
|
|
351
|
+
# @return [Showtime::Components::Button] created component
|
|
346
352
|
def self.button(label, key: nil, help: nil)
|
|
347
353
|
Showtime::session.add_element(Showtime::Components::Button.new(label, key: key, help: help))
|
|
348
354
|
end
|
|
349
355
|
|
|
356
|
+
# Add a checkbox element to the current session.
|
|
357
|
+
#
|
|
358
|
+
# @param label [String] checkbox label
|
|
359
|
+
# @param value [Boolean] initial checked state
|
|
360
|
+
# @param key [Object, nil] component key
|
|
361
|
+
# @param help [String, nil] helper text shown in the UI
|
|
362
|
+
# @return [Showtime::Components::Checkbox] created component
|
|
350
363
|
def self.checkbox(label, value: false, key: nil, help: nil)
|
|
351
364
|
Showtime::session.add_element(Showtime::Components::Checkbox.new(label, value: value, key: key, help: help))
|
|
352
365
|
end
|
|
353
366
|
|
|
367
|
+
# Add a text input element to the current session.
|
|
368
|
+
#
|
|
369
|
+
# @param label [String] input label
|
|
370
|
+
# @param value [String] initial value
|
|
371
|
+
# @param key [Object, nil] component key
|
|
372
|
+
# @param help [String, nil] helper text shown in the UI
|
|
373
|
+
# @return [Showtime::Components::TextInput] created component
|
|
354
374
|
def self.text_input(label, value: "", key: nil, help: nil)
|
|
355
375
|
Showtime::session.add_element(Showtime::Components::TextInput.new(label, value: value, key: key, help: help))
|
|
356
376
|
end
|
|
357
377
|
|
|
378
|
+
# Add a number input element to the current session.
|
|
379
|
+
#
|
|
380
|
+
# @param label [String] input label
|
|
381
|
+
# @param min_value [Numeric, nil] minimum value
|
|
382
|
+
# @param max_value [Numeric, nil] maximum value
|
|
383
|
+
# @param value [Numeric, nil] initial value
|
|
384
|
+
# @param step [Numeric] step size
|
|
385
|
+
# @param key [Object, nil] component key
|
|
386
|
+
# @param help [String, nil] helper text shown in the UI
|
|
387
|
+
# @return [Showtime::Components::NumberInput] created component
|
|
358
388
|
def self.number_input(label, min_value: nil, max_value: nil, value: nil, step: 1, key: nil, help: nil)
|
|
359
389
|
Showtime::session.add_element(Showtime::Components::NumberInput.new(label, min_value: min_value, max_value: max_value, value: value, step: step, key: key, help: help))
|
|
360
390
|
end
|
|
361
391
|
|
|
392
|
+
# Add a text area element to the current session.
|
|
393
|
+
#
|
|
394
|
+
# @param label [String] input label
|
|
395
|
+
# @param value [String] initial value
|
|
396
|
+
# @param height [Integer, nil] height in pixels
|
|
397
|
+
# @param key [Object, nil] component key
|
|
398
|
+
# @param help [String, nil] helper text shown in the UI
|
|
399
|
+
# @param kwargs [Hash] additional component options
|
|
400
|
+
# @return [Showtime::Components::TextArea] created component
|
|
362
401
|
def self.text_area(label, value: "", height: nil, key: nil, help: nil, **kwargs)
|
|
363
402
|
Showtime::session.add_element(Showtime::Components::TextArea.new(label, value: value, height: height, key: key, help: help, **kwargs))
|
|
364
403
|
end
|
|
365
404
|
|
|
405
|
+
# Add a date input element to the current session.
|
|
406
|
+
#
|
|
407
|
+
# @param label [String] input label
|
|
408
|
+
# @param value [String, Date, nil] initial value
|
|
409
|
+
# @param min_value [String, Date, nil] minimum value
|
|
410
|
+
# @param max_value [String, Date, nil] maximum value
|
|
411
|
+
# @param format [String] display format string
|
|
412
|
+
# @param key [Object, nil] component key
|
|
413
|
+
# @param help [String, nil] helper text shown in the UI
|
|
414
|
+
# @return [Showtime::Components::DateInput] created component
|
|
366
415
|
def self.date_input(label, value: nil, min_value: nil, max_value: nil, format: 'YYYY-MM-DD', key: nil, help: nil)
|
|
367
416
|
Showtime::session.add_element(Showtime::Components::DateInput.new(label, value: value, min_value: min_value, max_value: max_value, format: format, key: key, help: help))
|
|
368
417
|
end
|
|
369
418
|
|
|
419
|
+
# Add a file uploader element to the current session.
|
|
420
|
+
#
|
|
421
|
+
# @param label [String] input label
|
|
422
|
+
# @param type [Array<String>, String, nil] allowed file extensions or mime types
|
|
423
|
+
# @param accept_multiple_files [Boolean] allow multiple file selection
|
|
424
|
+
# @param max_size [Integer] maximum file size in bytes
|
|
425
|
+
# @param key [Object, nil] component key
|
|
426
|
+
# @param help [String, nil] helper text shown in the UI
|
|
427
|
+
# @param wide [Boolean] render a full-width uploader when true
|
|
428
|
+
# @return [Showtime::Components::FileUploader] created component
|
|
370
429
|
def self.file_uploader(label, type: nil, accept_multiple_files: false, max_size: Showtime::Components::FileUploader::DEFAULT_MAX_SIZE, key: nil, help: nil, wide: false)
|
|
371
430
|
Showtime::session.add_element(Showtime::Components::FileUploader.new(label, type: type, accept_multiple_files: accept_multiple_files, max_size: max_size, key: key, help: help, wide: wide))
|
|
372
431
|
end
|
|
373
432
|
|
|
433
|
+
# Add a select element to the current session.
|
|
434
|
+
#
|
|
435
|
+
# @param label [String] input label
|
|
436
|
+
# @param options [Array<Object>] selectable options
|
|
437
|
+
# @param value [Object, nil] initial value
|
|
438
|
+
# @param key [Object, nil] component key
|
|
439
|
+
# @param help [String, nil] helper text shown in the UI
|
|
440
|
+
# @return [Showtime::Components::Select] created component
|
|
374
441
|
def self.select(label, options, value: nil, key: nil, help: nil)
|
|
375
442
|
Showtime::session.add_element(Showtime::Components::Select.new(label, options, value: value, key: key, help: help))
|
|
376
443
|
end
|
|
377
444
|
|
|
445
|
+
# Add a multiselect element to the current session.
|
|
446
|
+
#
|
|
447
|
+
# @param label [String] input label
|
|
448
|
+
# @param options [Array<Object>] selectable options
|
|
449
|
+
# @param default [Array<Object>] default selections
|
|
450
|
+
# @param key [Object, nil] component key
|
|
451
|
+
# @param help [String, nil] helper text shown in the UI
|
|
452
|
+
# @return [Showtime::Components::Multiselect] created component
|
|
378
453
|
def self.multiselect(label, options, default: [], key: nil, help: nil)
|
|
379
454
|
Showtime::session.add_element(Showtime::Components::Multiselect.new(label, options, default: default, key: key, help: help))
|
|
380
455
|
end
|
|
381
456
|
|
|
457
|
+
# Add a slider element to the current session.
|
|
458
|
+
#
|
|
459
|
+
# @param label [String] input label
|
|
460
|
+
# @param min_value [Numeric] minimum value
|
|
461
|
+
# @param max_value [Numeric] maximum value
|
|
462
|
+
# @param value [Numeric, nil] initial value
|
|
463
|
+
# @param step [Numeric] step size
|
|
464
|
+
# @param key [Object, nil] component key
|
|
465
|
+
# @param help [String, nil] helper text shown in the UI
|
|
466
|
+
# @return [Showtime::Components::Slider] created component
|
|
382
467
|
def self.slider(label, min_value: 0, max_value: 100, value: nil, step: 1, key: nil, help: nil)
|
|
383
468
|
Showtime::session.add_element(Showtime::Components::Slider.new(label, min_value: min_value, max_value: max_value, value: value, step: step, key: key, help: help))
|
|
384
469
|
end
|
|
385
470
|
|
|
471
|
+
# Add a radio group element to the current session.
|
|
472
|
+
#
|
|
473
|
+
# @param label [String] input label
|
|
474
|
+
# @param options [Array<Object>] selectable options
|
|
475
|
+
# @param index [Integer] default selected index
|
|
476
|
+
# @param key [Object, nil] component key
|
|
477
|
+
# @param help [String, nil] helper text shown in the UI
|
|
478
|
+
# @return [Showtime::Components::Radio] created component
|
|
386
479
|
def self.radio(label, options, index: 0, key: nil, help: nil)
|
|
387
480
|
Showtime::session.add_element(Showtime::Components::Radio.new(label, options, index: index, key: key, help: help))
|
|
388
481
|
end
|
|
@@ -81,6 +81,16 @@ module Showtime
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
module St
|
|
84
|
+
# Create a container and add any yielded elements as children.
|
|
85
|
+
#
|
|
86
|
+
# @param title [String, nil] optional heading for the container
|
|
87
|
+
# @param border [Boolean] render a border around the container when true
|
|
88
|
+
# @param grow [Boolean] allow the container to grow and fill space when true
|
|
89
|
+
# @param key [Object, nil] component key
|
|
90
|
+
# @param help [String, nil] helper text shown in the UI
|
|
91
|
+
# @yield block that builds the container's children
|
|
92
|
+
# @yieldreturn [void]
|
|
93
|
+
# @return [Showtime::Components::Container] created container
|
|
84
94
|
def self.container(title: nil, border: true, grow: false, key: nil, help: nil, &block)
|
|
85
95
|
container = Showtime::Components::Container.new(title: title, border: border, grow: grow, key: key, help: help)
|
|
86
96
|
element = Showtime::session.add_element(container)
|
|
@@ -104,8 +114,11 @@ module Showtime
|
|
|
104
114
|
# so sibling panels align; when omitted, equal distribution across 24 columns is used.
|
|
105
115
|
# @param height [Integer, String, nil] optional height for vertical layouts (number => px, string => CSS value)
|
|
106
116
|
# @param type [String] visual style for the container (card/ghost/success/info/warning/error)
|
|
107
|
-
# @param key [
|
|
117
|
+
# @param key [Object, nil] component key
|
|
108
118
|
# @param help [String, nil] optional tooltip/help text
|
|
119
|
+
# @yield block that builds the container's children
|
|
120
|
+
# @yieldreturn [void]
|
|
121
|
+
# @return [Showtime::Components::SplitLayout] created container
|
|
109
122
|
def self.split_layout(direction: 'horizontal', sizes: nil, height: nil, type: 'card', key: nil, help: nil, &block)
|
|
110
123
|
container = Showtime::Components::SplitLayout.new(direction: direction, sizes: sizes, height: height, ttype: type, key: key, help: help)
|
|
111
124
|
element = Showtime::session.add_element(container)
|
|
@@ -119,6 +132,15 @@ module Showtime
|
|
|
119
132
|
element
|
|
120
133
|
end
|
|
121
134
|
|
|
135
|
+
# Create a collapsible container and add any yielded elements as children.
|
|
136
|
+
#
|
|
137
|
+
# @param label [String] label displayed on the collapse header
|
|
138
|
+
# @param expanded [Boolean] initial expanded state
|
|
139
|
+
# @param key [Object, nil] component key
|
|
140
|
+
# @param help [String, nil] helper text shown in the UI
|
|
141
|
+
# @yield block that builds the container's children
|
|
142
|
+
# @yieldreturn [void]
|
|
143
|
+
# @return [Showtime::Components::Collapse] created container
|
|
122
144
|
def self.collapse(label, expanded: false, key: nil, help: nil, &block)
|
|
123
145
|
container = Showtime::Components::Collapse.new(label, expanded: expanded, key: key, help: help)
|
|
124
146
|
element = Showtime::session.add_element(container)
|
|
@@ -65,6 +65,15 @@ module Showtime
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
module St
|
|
68
|
+
# Add an image to the current session.
|
|
69
|
+
#
|
|
70
|
+
# @param src [String, Object] file path, URL, data URI, or binary data
|
|
71
|
+
# @param caption [String, nil] caption text displayed with the image
|
|
72
|
+
# @param width [Integer, nil] width in pixels
|
|
73
|
+
# @param use_column_width [Boolean] stretch to container width when true
|
|
74
|
+
# @param key [Object, nil] component key
|
|
75
|
+
# @param help [String, nil] helper text shown in the UI
|
|
76
|
+
# @return [Showtime::Components::Image] created component
|
|
68
77
|
def self.image(src, caption: nil, width: nil, use_column_width: false, key: nil, help: nil)
|
|
69
78
|
component = Components::Image.new(src, caption: caption, width: width, use_column_width: use_column_width, key: key, help: help)
|
|
70
79
|
Showtime.session.add_element(component)
|
|
@@ -120,33 +120,76 @@ module Showtime
|
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
module St
|
|
123
|
+
# Add a page title element to the current session.
|
|
124
|
+
#
|
|
125
|
+
# @param text [String] title text
|
|
126
|
+
# @param divider [Boolean] render a divider below the title when true
|
|
127
|
+
# @param help [String, nil] helper text shown in the UI
|
|
128
|
+
# @param anchor [Boolean] generate an anchor link when true
|
|
129
|
+
# @return [Showtime::Components::Title] created component
|
|
123
130
|
def self.title(text, divider: false, help: nil, anchor: true)
|
|
124
131
|
anchor_enabled = anchor && !Showtime::session.in_sidebar?
|
|
125
132
|
Showtime::session.add_element(Showtime::Components::Title.new(text, divider, help, anchor_enabled))
|
|
126
133
|
end
|
|
127
134
|
|
|
135
|
+
# Add a header element to the current session.
|
|
136
|
+
#
|
|
137
|
+
# @param text [String] header text
|
|
138
|
+
# @param divider [Boolean] render a divider below the header when true
|
|
139
|
+
# @param help [String, nil] helper text shown in the UI
|
|
140
|
+
# @param anchor [Boolean] generate an anchor link when true
|
|
141
|
+
# @return [Showtime::Components::Header] created component
|
|
128
142
|
def self.header(text, divider: false, help: nil, anchor: true)
|
|
129
143
|
anchor_enabled = anchor && !Showtime::session.in_sidebar?
|
|
130
144
|
Showtime::session.add_element(Showtime::Components::Header.new(text, divider, help, anchor_enabled))
|
|
131
145
|
end
|
|
132
146
|
|
|
147
|
+
# Add a subheader element to the current session.
|
|
148
|
+
#
|
|
149
|
+
# @param text [String] subheader text
|
|
150
|
+
# @param divider [Boolean] render a divider below the subheader when true
|
|
151
|
+
# @param help [String, nil] helper text shown in the UI
|
|
152
|
+
# @param anchor [Boolean] generate an anchor link when true
|
|
153
|
+
# @return [Showtime::Components::Subheader] created component
|
|
133
154
|
def self.subheader(text, divider: false, help: nil, anchor: true)
|
|
134
155
|
anchor_enabled = anchor && !Showtime::session.in_sidebar?
|
|
135
156
|
Showtime::session.add_element(Showtime::Components::Subheader.new(text, divider, help, anchor_enabled))
|
|
136
157
|
end
|
|
137
158
|
|
|
159
|
+
# Alias for {#text}.
|
|
160
|
+
#
|
|
161
|
+
# @param text [String] text content
|
|
162
|
+
# @return [Showtime::Components::Text] created component
|
|
138
163
|
def self.write(text)
|
|
139
164
|
self.text(text)
|
|
140
165
|
end
|
|
141
166
|
|
|
167
|
+
# Add a text element to the current session.
|
|
168
|
+
#
|
|
169
|
+
# @param text [String] text content
|
|
170
|
+
# @return [Showtime::Components::Text] created component
|
|
142
171
|
def self.text(text)
|
|
143
172
|
Showtime::session.add_element(Showtime::Components::Text.new(text))
|
|
144
173
|
end
|
|
145
174
|
|
|
175
|
+
# Add a markdown element to the current session.
|
|
176
|
+
#
|
|
177
|
+
# @param content [String] markdown content
|
|
178
|
+
# @return [Showtime::Components::Markdown] created component
|
|
146
179
|
def self.markdown(content)
|
|
147
180
|
Showtime::session.add_element(Showtime::Components::Markdown.new(content))
|
|
148
181
|
end
|
|
149
182
|
|
|
183
|
+
# Add a metric element to the current session.
|
|
184
|
+
#
|
|
185
|
+
# @param label [String] label displayed for the metric
|
|
186
|
+
# @param value [Object] main value shown
|
|
187
|
+
# @param delta [Object, nil] delta value shown alongside the metric
|
|
188
|
+
# @param prefix [String, nil] prefix for the value display
|
|
189
|
+
# @param suffix [String, nil] suffix for the value display
|
|
190
|
+
# @param key [Object, nil] component key
|
|
191
|
+
# @param help [String, nil] helper text shown in the UI
|
|
192
|
+
# @return [Showtime::Components::Metric] created component
|
|
150
193
|
def self.metric(label, value:, delta: nil, prefix: nil, suffix: nil, key: nil, help: nil)
|
|
151
194
|
Showtime::session.add_element(
|
|
152
195
|
Showtime::Components::Metric.new(label, value: value, delta: delta, prefix: prefix, suffix: suffix, key: key, help: help)
|
data/lib/showtime/version.rb
CHANGED
data/lib/showtime.rb
CHANGED
|
@@ -91,7 +91,11 @@ module Showtime
|
|
|
91
91
|
# The main module for streamlit-like API
|
|
92
92
|
module St
|
|
93
93
|
@@color = Pastel.new
|
|
94
|
-
# Get a value from the cache, recomputing only if dependencies changed
|
|
94
|
+
# Get a value from the cache, recomputing only if dependencies changed.
|
|
95
|
+
#
|
|
96
|
+
# @param key [Object] cache key for the computed value
|
|
97
|
+
# @yieldreturn [Object] value to compute when cache is missing or dirty
|
|
98
|
+
# @return [Object] cached or freshly computed value
|
|
95
99
|
def self.compute(key, &block)
|
|
96
100
|
session = Showtime.session
|
|
97
101
|
registry = session.component_registry
|
|
@@ -121,6 +125,12 @@ module Showtime
|
|
|
121
125
|
tracker.result
|
|
122
126
|
end
|
|
123
127
|
|
|
128
|
+
# Fetch a cached value, optionally computing it when missing.
|
|
129
|
+
#
|
|
130
|
+
# @param key [Object] cache key for the value
|
|
131
|
+
# @param default [Object] fallback value when not cached and no block is given
|
|
132
|
+
# @yieldreturn [Object] value to compute when missing
|
|
133
|
+
# @return [Object] cached value, computed value, or default
|
|
124
134
|
def self.get(key, default = nil, &block)
|
|
125
135
|
session = Showtime.session
|
|
126
136
|
|
|
@@ -139,14 +149,26 @@ module Showtime
|
|
|
139
149
|
default
|
|
140
150
|
end
|
|
141
151
|
|
|
152
|
+
# Store a value in the session cache.
|
|
153
|
+
#
|
|
154
|
+
# @param key [Object] cache key
|
|
155
|
+
# @param value [Object] value to store
|
|
156
|
+
# @return [void]
|
|
142
157
|
def self.set(key, value)
|
|
143
158
|
Showtime.session.update_value(key, value)
|
|
144
159
|
end
|
|
145
160
|
|
|
161
|
+
# Clear all cached values in the current session.
|
|
162
|
+
#
|
|
163
|
+
# @return [void]
|
|
146
164
|
def self.clear_session
|
|
147
165
|
Showtime.session.clear_values
|
|
148
166
|
end
|
|
149
167
|
|
|
168
|
+
# Resolve a path relative to the app root.
|
|
169
|
+
#
|
|
170
|
+
# @param relative_path [String] relative path from the app root
|
|
171
|
+
# @return [String] absolute path
|
|
150
172
|
def self.path(relative_path)
|
|
151
173
|
Showtime::Helpers.absolute_path(relative_path)
|
|
152
174
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: its-showtime
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gabriel L. Maljkovich
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-01-
|
|
11
|
+
date: 2026-01-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sinatra
|