pyreportkit 0.1.0__py3-none-any.whl
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.
- pyreportkit-0.1.0.dist-info/METADATA +187 -0
- pyreportkit-0.1.0.dist-info/RECORD +222 -0
- pyreportkit-0.1.0.dist-info/WHEEL +5 -0
- pyreportkit-0.1.0.dist-info/licenses/LICENSE +21 -0
- pyreportkit-0.1.0.dist-info/top_level.txt +1 -0
- reportkit/__init__.py +0 -0
- reportkit/components/__init__.py +45 -0
- reportkit/components/document/__init__.py +6 -0
- reportkit/components/document/footer.py +12 -0
- reportkit/components/document/header.py +12 -0
- reportkit/components/document/page.py +18 -0
- reportkit/components/document/report.py +12 -0
- reportkit/components/information/__init__.py +4 -0
- reportkit/components/information/info_grid.py +23 -0
- reportkit/components/information/key_value.py +28 -0
- reportkit/components/layout/__init__.py +9 -0
- reportkit/components/layout/box.py +10 -0
- reportkit/components/layout/column.py +15 -0
- reportkit/components/layout/divider.py +10 -0
- reportkit/components/layout/grid.py +12 -0
- reportkit/components/layout/row.py +15 -0
- reportkit/components/layout/section.py +10 -0
- reportkit/components/layout/spacer.py +12 -0
- reportkit/components/media/__init__.py +4 -0
- reportkit/components/media/chart.py +14 -0
- reportkit/components/media/image.py +25 -0
- reportkit/components/pagination/__init__.py +5 -0
- reportkit/components/pagination/page_break.py +10 -0
- reportkit/components/pagination/page_count.py +10 -0
- reportkit/components/pagination/page_number.py +21 -0
- reportkit/components/table/__init__.py +7 -0
- reportkit/components/table/cell.py +27 -0
- reportkit/components/table/column.py +29 -0
- reportkit/components/table/row.py +25 -0
- reportkit/components/table/style.py +18 -0
- reportkit/components/table/table.py +27 -0
- reportkit/components/typography/__init__.py +6 -0
- reportkit/components/typography/heading.py +13 -0
- reportkit/components/typography/rich_text.py +23 -0
- reportkit/components/typography/text.py +12 -0
- reportkit/components/typography/text_span.py +24 -0
- reportkit/core/__init__.py +4 -0
- reportkit/core/component.py +12 -0
- reportkit/core/container.py +66 -0
- reportkit/core/exceptions.py +0 -0
- reportkit/core/factory.py +53 -0
- reportkit/core/registry.py +50 -0
- reportkit/core/serializer.py +90 -0
- reportkit/exporters/__init__.py +0 -0
- reportkit/exporters/base.py +17 -0
- reportkit/exporters/excel/__init__.py +8 -0
- reportkit/exporters/excel/exceptions.py +4 -0
- reportkit/exporters/excel/exporter.py +68 -0
- reportkit/exporters/excel/renderers/__init__.py +34 -0
- reportkit/exporters/excel/renderers/base.py +27 -0
- reportkit/exporters/excel/renderers/information.py +55 -0
- reportkit/exporters/excel/renderers/layout/__init__.py +7 -0
- reportkit/exporters/excel/renderers/layout/columns.py +48 -0
- reportkit/exporters/excel/renderers/layout/data.py +46 -0
- reportkit/exporters/excel/renderers/layout/page.py +24 -0
- reportkit/exporters/excel/renderers/layout/spacing.py +30 -0
- reportkit/exporters/excel/renderers/layout/stack.py +13 -0
- reportkit/exporters/excel/renderers/media.py +46 -0
- reportkit/exporters/excel/renderers/registry.py +22 -0
- reportkit/exporters/excel/renderers/table/__init__.py +4 -0
- reportkit/exporters/excel/renderers/table/cells.py +17 -0
- reportkit/exporters/excel/renderers/table/data.py +38 -0
- reportkit/exporters/excel/renderers/table/renderer.py +64 -0
- reportkit/exporters/excel/renderers/table/widths.py +29 -0
- reportkit/exporters/excel/renderers/text.py +40 -0
- reportkit/exporters/excel/styles.py +130 -0
- reportkit/exporters/excel/values/__init__.py +5 -0
- reportkit/exporters/excel/values/cells.py +60 -0
- reportkit/exporters/excel/values/components.py +16 -0
- reportkit/exporters/excel/values/formats.py +31 -0
- reportkit/exporters/excel/values/numbers.py +19 -0
- reportkit/exporters/excel/workbook/__init__.py +5 -0
- reportkit/exporters/excel/workbook/data.py +48 -0
- reportkit/exporters/excel/workbook/formatted.py +63 -0
- reportkit/exporters/excel/workbook/styles.py +27 -0
- reportkit/exporters/excel/workbook/workbook.py +65 -0
- reportkit/exporters/excel/worksheet/__init__.py +5 -0
- reportkit/exporters/excel/worksheet/borders.py +30 -0
- reportkit/exporters/excel/worksheet/cells.py +38 -0
- reportkit/exporters/excel/worksheet/constants.py +12 -0
- reportkit/exporters/excel/worksheet/data.py +51 -0
- reportkit/exporters/excel/worksheet/formatted.py +158 -0
- reportkit/exporters/excel/worksheet/page.py +23 -0
- reportkit/exporters/html/__init__.py +6 -0
- reportkit/exporters/html/assets.py +87 -0
- reportkit/exporters/html/direction.py +15 -0
- reportkit/exporters/html/engine.py +37 -0
- reportkit/exporters/html/exporter.py +38 -0
- reportkit/exporters/html/page/__init__.py +3 -0
- reportkit/exporters/html/page/components.py +47 -0
- reportkit/exporters/html/page/margins.py +24 -0
- reportkit/exporters/html/page/numbering.py +31 -0
- reportkit/exporters/html/page/resolver.py +37 -0
- reportkit/exporters/html/page/running.py +30 -0
- reportkit/exporters/html/page/styles.py +22 -0
- reportkit/exporters/html/page/validator.py +76 -0
- reportkit/exporters/html/registry.py +45 -0
- reportkit/exporters/html/renderers/__init__.py +37 -0
- reportkit/exporters/html/renderers/base.py +20 -0
- reportkit/exporters/html/renderers/document/__init__.py +6 -0
- reportkit/exporters/html/renderers/document/footer.py +18 -0
- reportkit/exporters/html/renderers/document/header.py +18 -0
- reportkit/exporters/html/renderers/document/page.py +17 -0
- reportkit/exporters/html/renderers/document/report.py +16 -0
- reportkit/exporters/html/renderers/information/__init__.py +4 -0
- reportkit/exporters/html/renderers/information/info_grid.py +26 -0
- reportkit/exporters/html/renderers/information/key_value.py +18 -0
- reportkit/exporters/html/renderers/layout/__init__.py +9 -0
- reportkit/exporters/html/renderers/layout/box.py +17 -0
- reportkit/exporters/html/renderers/layout/column.py +41 -0
- reportkit/exporters/html/renderers/layout/divider.py +16 -0
- reportkit/exporters/html/renderers/layout/grid.py +48 -0
- reportkit/exporters/html/renderers/layout/row.py +35 -0
- reportkit/exporters/html/renderers/layout/section.py +17 -0
- reportkit/exporters/html/renderers/layout/spacer.py +18 -0
- reportkit/exporters/html/renderers/media/__init__.py +3 -0
- reportkit/exporters/html/renderers/media/image.py +18 -0
- reportkit/exporters/html/renderers/pagination/__init__.py +4 -0
- reportkit/exporters/html/renderers/pagination/page_break.py +15 -0
- reportkit/exporters/html/renderers/pagination/page_number.py +15 -0
- reportkit/exporters/html/renderers/table/__init__.py +4 -0
- reportkit/exporters/html/renderers/table/cell.py +77 -0
- reportkit/exporters/html/renderers/table/table.py +69 -0
- reportkit/exporters/html/renderers/typography/__init__.py +5 -0
- reportkit/exporters/html/renderers/typography/heading.py +18 -0
- reportkit/exporters/html/renderers/typography/rich_text.py +28 -0
- reportkit/exporters/html/renderers/typography/text.py +16 -0
- reportkit/exporters/html/static/base.css +45 -0
- reportkit/exporters/html/static/information.css +83 -0
- reportkit/exporters/html/static/layout.css +81 -0
- reportkit/exporters/html/static/media.css +10 -0
- reportkit/exporters/html/static/pdf.css +96 -0
- reportkit/exporters/html/static/print.css +91 -0
- reportkit/exporters/html/static/table.css +222 -0
- reportkit/exporters/html/static/tokens.css +68 -0
- reportkit/exporters/html/static/typography.css +54 -0
- reportkit/exporters/html/styles.py +167 -0
- reportkit/exporters/html/templates/components/document/footer.html +3 -0
- reportkit/exporters/html/templates/components/document/header.html +3 -0
- reportkit/exporters/html/templates/components/document/page.html +8 -0
- reportkit/exporters/html/templates/components/document/report.html +3 -0
- reportkit/exporters/html/templates/components/information/info_grid.html +6 -0
- reportkit/exporters/html/templates/components/information/key_value.html +9 -0
- reportkit/exporters/html/templates/components/layout/box.html +3 -0
- reportkit/exporters/html/templates/components/layout/column.html +3 -0
- reportkit/exporters/html/templates/components/layout/divider.html +1 -0
- reportkit/exporters/html/templates/components/layout/grid.html +3 -0
- reportkit/exporters/html/templates/components/layout/row.html +3 -0
- reportkit/exporters/html/templates/components/layout/section.html +3 -0
- reportkit/exporters/html/templates/components/layout/spacer.html +1 -0
- reportkit/exporters/html/templates/components/media/image.html +8 -0
- reportkit/exporters/html/templates/components/pagination/page_break.html +1 -0
- reportkit/exporters/html/templates/components/pagination/page_number.html +4 -0
- reportkit/exporters/html/templates/components/table/cell.html +7 -0
- reportkit/exporters/html/templates/components/table/table.html +34 -0
- reportkit/exporters/html/templates/components/typography/heading.html +1 -0
- reportkit/exporters/html/templates/components/typography/rich_text.html +5 -0
- reportkit/exporters/html/templates/components/typography/text.html +1 -0
- reportkit/exporters/html/templates/document.html +17 -0
- reportkit/exporters/html/templates.py +30 -0
- reportkit/exporters/json.py +0 -0
- reportkit/exporters/pdf/__init__.py +8 -0
- reportkit/exporters/pdf/conversion.py +104 -0
- reportkit/exporters/pdf/dependencies.py +12 -0
- reportkit/exporters/pdf/exceptions.py +4 -0
- reportkit/exporters/pdf/exporter.py +16 -0
- reportkit/exporters/pdf/resources/__init__.py +4 -0
- reportkit/exporters/pdf/resources/fetcher.py +37 -0
- reportkit/exporters/pdf/resources/policy.py +60 -0
- reportkit/exporters/registry.py +50 -0
- reportkit/exporters/word/__init__.py +8 -0
- reportkit/exporters/word/document/__init__.py +4 -0
- reportkit/exporters/word/document/document.py +74 -0
- reportkit/exporters/word/document/engine.py +71 -0
- reportkit/exporters/word/exceptions.py +4 -0
- reportkit/exporters/word/exporter.py +32 -0
- reportkit/exporters/word/renderers/__init__.py +24 -0
- reportkit/exporters/word/renderers/base.py +56 -0
- reportkit/exporters/word/renderers/information.py +30 -0
- reportkit/exporters/word/renderers/layout/__init__.py +6 -0
- reportkit/exporters/word/renderers/layout/columns.py +82 -0
- reportkit/exporters/word/renderers/layout/page.py +38 -0
- reportkit/exporters/word/renderers/layout/spacing.py +33 -0
- reportkit/exporters/word/renderers/layout/stack.py +50 -0
- reportkit/exporters/word/renderers/media.py +49 -0
- reportkit/exporters/word/renderers/registry.py +22 -0
- reportkit/exporters/word/renderers/table/__init__.py +3 -0
- reportkit/exporters/word/renderers/table/cells.py +39 -0
- reportkit/exporters/word/renderers/table/renderer.py +95 -0
- reportkit/exporters/word/renderers/table/widths.py +12 -0
- reportkit/exporters/word/renderers/text.py +40 -0
- reportkit/exporters/word/styles/__init__.py +3 -0
- reportkit/exporters/word/styles/text.py +90 -0
- reportkit/exporters/word/styles/xml.py +147 -0
- reportkit/exporters/word/values.py +36 -0
- reportkit/formatting/__init__.py +0 -0
- reportkit/formatting/cell.py +12 -0
- reportkit/formatting/cells.py +41 -0
- reportkit/formatting/values.py +106 -0
- reportkit/rendering/__init__.py +0 -0
- reportkit/rendering/context.py +31 -0
- reportkit/rendering/table.py +56 -0
- reportkit/rendering/tracks.py +51 -0
- reportkit/rendering/visitor.py +55 -0
- reportkit/report.py +0 -0
- reportkit/styles/__init__.py +0 -0
- reportkit/styles/borders.py +6 -0
- reportkit/styles/style.py +117 -0
- reportkit/styles/table.py +37 -0
- reportkit/styles/theme.py +45 -0
- reportkit/styles/tokens.py +29 -0
- reportkit/validators/__init__.py +3 -0
- reportkit/validators/table/__init__.py +3 -0
- reportkit/validators/table/cell.py +38 -0
- reportkit/validators/table/column.py +62 -0
- reportkit/validators/table/row.py +37 -0
- reportkit/validators/table/table.py +63 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/* Container: wide tables scroll inside their frame on screen instead of widening the page. */
|
|
2
|
+
.rk-table-container {
|
|
3
|
+
width: 100%;
|
|
4
|
+
overflow-x: auto;
|
|
5
|
+
border: 1px solid var(--rk-table-frame-color);
|
|
6
|
+
border-radius: var(--rk-table-radius);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.rk-table {
|
|
10
|
+
width: 100%;
|
|
11
|
+
border-collapse: collapse;
|
|
12
|
+
table-layout: fixed;
|
|
13
|
+
font-size: var(--rk-font-sm);
|
|
14
|
+
text-align: start;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.rk-table--layout-auto {
|
|
18
|
+
table-layout: auto;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rk-table-caption {
|
|
22
|
+
padding: var(--rk-table-caption-padding);
|
|
23
|
+
font-size: var(--rk-font-lg);
|
|
24
|
+
font-weight: 700;
|
|
25
|
+
text-align: start;
|
|
26
|
+
caption-side: top;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Cells wrap at word boundaries and break a word only when it cannot fit at all. */
|
|
30
|
+
.rk-table th,
|
|
31
|
+
.rk-table td {
|
|
32
|
+
padding: var(--rk-table-cell-padding-y) var(--rk-table-cell-padding-x);
|
|
33
|
+
vertical-align: middle;
|
|
34
|
+
border-bottom: 1px solid var(--rk-table-divider-color);
|
|
35
|
+
color: var(--rk-table-cell-color);
|
|
36
|
+
white-space: normal;
|
|
37
|
+
word-break: normal;
|
|
38
|
+
overflow-wrap: break-word;
|
|
39
|
+
line-height: 1.5;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.rk-table thead th {
|
|
43
|
+
background: var(--rk-table-header-bg);
|
|
44
|
+
color: var(--rk-table-header-color);
|
|
45
|
+
font-weight: 800;
|
|
46
|
+
border-top: 1px solid var(--rk-table-header-accent);
|
|
47
|
+
border-bottom: 2px solid var(--rk-table-header-rule);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.rk-table-th__title,
|
|
51
|
+
.rk-table-th__subtitle {
|
|
52
|
+
display: block;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.rk-table-th__title {
|
|
56
|
+
white-space: pre-line;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.rk-table-th__subtitle {
|
|
60
|
+
margin-top: 2px;
|
|
61
|
+
color: var(--rk-table-subtitle-color);
|
|
62
|
+
font-size: 0.85em;
|
|
63
|
+
font-weight: 400;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Each line of a plain value is its own block with a resolved dir, so "12:47 AM" stays LTR in RTL tables. */
|
|
67
|
+
.rk-table-cell__line {
|
|
68
|
+
display: block;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* The resolved dir only orders the text; alignment still comes from the cell (base.css aligns every [dir]). */
|
|
72
|
+
.rk-table-cell__line,
|
|
73
|
+
.rk-table-th__title,
|
|
74
|
+
.rk-table-th__subtitle {
|
|
75
|
+
text-align: inherit;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* Custom cells only lay out their children; the children keep their own styles. */
|
|
79
|
+
.rk-table-cell__content {
|
|
80
|
+
display: flex;
|
|
81
|
+
flex-direction: column;
|
|
82
|
+
gap: 2px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.rk-table-cell__content > * {
|
|
86
|
+
margin: 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* No wrapping: auto layout widens the column, fixed layout clips with an ellipsis. */
|
|
90
|
+
.rk-table-th--nowrap .rk-table-th__title,
|
|
91
|
+
.rk-table-th--nowrap .rk-table-th__subtitle,
|
|
92
|
+
.rk-table--layout-auto .rk-table-th__title,
|
|
93
|
+
.rk-table--layout-auto .rk-table-th__subtitle,
|
|
94
|
+
.rk-table-cell--nowrap,
|
|
95
|
+
.rk-table-cell--nowrap .rk-table-cell__line {
|
|
96
|
+
white-space: nowrap;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.rk-table--layout-fixed .rk-table-cell--nowrap {
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
text-overflow: ellipsis;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.rk-table-cell--positive {
|
|
105
|
+
color: var(--rk-color-positive);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.rk-table-cell--negative {
|
|
109
|
+
color: var(--rk-color-negative);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.rk-table tbody tr:last-child td {
|
|
113
|
+
border-bottom: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* Options */
|
|
117
|
+
.rk-table--bordered th,
|
|
118
|
+
.rk-table--bordered td {
|
|
119
|
+
border: 1px solid var(--rk-table-divider-color);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.rk-table--striped tbody .rk-table-data:nth-child(even) {
|
|
123
|
+
background: var(--rk-table-stripe-bg);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.rk-table--hover tbody tr:hover {
|
|
127
|
+
background: var(--rk-table-hover-bg);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.rk-table--compact th,
|
|
131
|
+
.rk-table--compact td {
|
|
132
|
+
padding: var(--rk-table-compact-padding-y) var(--rk-table-compact-padding-x);
|
|
133
|
+
font-size: var(--rk-font-xs);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Row kinds */
|
|
137
|
+
.rk-table-group-header {
|
|
138
|
+
background: var(--rk-table-group-bg);
|
|
139
|
+
font-weight: 700;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.rk-table-subtotal {
|
|
143
|
+
background: var(--rk-table-subtotal-bg);
|
|
144
|
+
font-weight: 600;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.rk-table-subtotal td {
|
|
148
|
+
border-top: 1px solid var(--rk-table-divider-color);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.rk-table-total {
|
|
152
|
+
background: var(--rk-table-total-bg);
|
|
153
|
+
font-weight: 700;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.rk-table-total td {
|
|
157
|
+
border-top: 2px solid var(--rk-table-divider-color);
|
|
158
|
+
border-bottom: 0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/* Ruled: no frame or vertical lines; heavy rules around the header and above the total. */
|
|
162
|
+
.rk-table-container--ruled {
|
|
163
|
+
border: 0;
|
|
164
|
+
border-radius: 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.rk-table--ruled th,
|
|
168
|
+
.rk-table--ruled td {
|
|
169
|
+
border-left: 0;
|
|
170
|
+
border-right: 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.rk-table--ruled thead th {
|
|
174
|
+
border-top: 1px solid var(--rk-table-ruled-color);
|
|
175
|
+
border-bottom: 2px solid var(--rk-table-ruled-color);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.rk-table--ruled .rk-table-total {
|
|
179
|
+
background: transparent;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.rk-table--ruled .rk-table-total td {
|
|
183
|
+
border-top: 2px solid var(--rk-table-ruled-color);
|
|
184
|
+
color: var(--rk-table-header-color);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* Print follows the table options: the header repeats and rows stay whole only when asked. */
|
|
188
|
+
@media print {
|
|
189
|
+
/* Close the frame on every page instead of leaving it open down to the page edge. */
|
|
190
|
+
.rk-table-container {
|
|
191
|
+
overflow: visible;
|
|
192
|
+
border: 0;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.rk-table-container:not(.rk-table-container--ruled) > .rk-table {
|
|
196
|
+
border: 1px solid var(--rk-table-frame-color);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.rk-table thead,
|
|
200
|
+
.rk-table tfoot {
|
|
201
|
+
display: table-row-group;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.rk-table--repeat-header thead {
|
|
205
|
+
display: table-header-group;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.rk-table--avoid-row-break tr {
|
|
209
|
+
break-inside: avoid;
|
|
210
|
+
page-break-inside: avoid;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.rk-table-caption,
|
|
214
|
+
.rk-table-group-header {
|
|
215
|
+
break-after: avoid;
|
|
216
|
+
page-break-after: avoid;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.rk-table--hover tbody tr:hover {
|
|
220
|
+
background: transparent;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
/* Typography */
|
|
3
|
+
--rk-font-family: "Inter", "Noto Sans Arabic", Arial, sans-serif;
|
|
4
|
+
--rk-font-xs: 11px;
|
|
5
|
+
--rk-font-sm: 13px;
|
|
6
|
+
--rk-font-md: 14px;
|
|
7
|
+
--rk-font-lg: 18px;
|
|
8
|
+
--rk-font-xl: 24px;
|
|
9
|
+
--rk-font-2xl: 30px;
|
|
10
|
+
|
|
11
|
+
/* Base colors */
|
|
12
|
+
--rk-color-primary: #2563eb;
|
|
13
|
+
--rk-color-text: #172033;
|
|
14
|
+
--rk-color-muted: #64748b;
|
|
15
|
+
--rk-color-border: #e2e8f0;
|
|
16
|
+
--rk-color-surface: #ffffff;
|
|
17
|
+
--rk-color-subtle: #f8fafc;
|
|
18
|
+
--rk-color-positive: #059669;
|
|
19
|
+
--rk-color-negative: #dc2626;
|
|
20
|
+
|
|
21
|
+
/* Neutral scale used by tables */
|
|
22
|
+
--rk-gray-50: #f8f8f8;
|
|
23
|
+
--rk-gray-100: #f0f0f0;
|
|
24
|
+
--rk-gray-200: #e2e2e2;
|
|
25
|
+
--rk-gray-300: #dddddd;
|
|
26
|
+
--rk-gray-500: #8d8d8d;
|
|
27
|
+
--rk-gray-600: #555555;
|
|
28
|
+
--rk-gray-700: #444444;
|
|
29
|
+
--rk-gray-800: #333333;
|
|
30
|
+
--rk-gray-900: #262626;
|
|
31
|
+
--rk-accent: #53789d;
|
|
32
|
+
|
|
33
|
+
/* Spacing */
|
|
34
|
+
--rk-space-1: 4px;
|
|
35
|
+
--rk-space-2: 8px;
|
|
36
|
+
--rk-space-3: 12px;
|
|
37
|
+
--rk-space-4: 16px;
|
|
38
|
+
--rk-space-5: 24px;
|
|
39
|
+
--rk-space-6: 32px;
|
|
40
|
+
--rk-space-7: 48px;
|
|
41
|
+
|
|
42
|
+
/* Radius */
|
|
43
|
+
--rk-radius-sm: 6px;
|
|
44
|
+
--rk-radius-md: 10px;
|
|
45
|
+
--rk-radius-lg: 16px;
|
|
46
|
+
|
|
47
|
+
/* Tables */
|
|
48
|
+
--rk-table-radius: 0;
|
|
49
|
+
--rk-table-frame-color: var(--rk-gray-300);
|
|
50
|
+
--rk-table-divider-color: var(--rk-gray-200);
|
|
51
|
+
--rk-table-header-bg: var(--rk-gray-100);
|
|
52
|
+
--rk-table-header-color: var(--rk-gray-900);
|
|
53
|
+
--rk-table-header-accent: var(--rk-accent);
|
|
54
|
+
--rk-table-header-rule: var(--rk-gray-800);
|
|
55
|
+
--rk-table-subtitle-color: var(--rk-gray-500);
|
|
56
|
+
--rk-table-cell-color: var(--rk-gray-700);
|
|
57
|
+
--rk-table-stripe-bg: var(--rk-gray-50);
|
|
58
|
+
--rk-table-hover-bg: var(--rk-gray-100);
|
|
59
|
+
--rk-table-group-bg: var(--rk-gray-200);
|
|
60
|
+
--rk-table-subtotal-bg: var(--rk-gray-100);
|
|
61
|
+
--rk-table-total-bg: var(--rk-gray-200);
|
|
62
|
+
--rk-table-ruled-color: var(--rk-gray-600);
|
|
63
|
+
--rk-table-cell-padding-y: 8px;
|
|
64
|
+
--rk-table-cell-padding-x: 10px;
|
|
65
|
+
--rk-table-compact-padding-y: 5px;
|
|
66
|
+
--rk-table-compact-padding-x: 8px;
|
|
67
|
+
--rk-table-caption-padding: var(--rk-space-4);
|
|
68
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
.rk-text {
|
|
2
|
+
margin: 0 0 var(--rk-space-3);
|
|
3
|
+
color: var(--rk-color-text);
|
|
4
|
+
font-size: var(--rk-font-md);
|
|
5
|
+
line-height: 1.8;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.rk-heading {
|
|
9
|
+
margin: 0 0 var(--rk-space-4);
|
|
10
|
+
color: var(--rk-color-text);
|
|
11
|
+
font-weight: 700;
|
|
12
|
+
line-height: 1.35;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.rk-heading--1 {
|
|
16
|
+
font-size: var(--rk-font-2xl);
|
|
17
|
+
letter-spacing: -0.5px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.rk-heading--2 {
|
|
21
|
+
font-size: var(--rk-font-xl);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.rk-heading--3 {
|
|
25
|
+
font-size: var(--rk-font-lg);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.rk-muted {
|
|
29
|
+
color: var(--rk-color-muted);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.rk-label {
|
|
33
|
+
font-size: var(--rk-font-xs);
|
|
34
|
+
font-weight: 600;
|
|
35
|
+
color: var(--rk-color-muted);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.rk-rich-text {
|
|
39
|
+
margin: 0;
|
|
40
|
+
line-height: 1.7;
|
|
41
|
+
overflow-wrap: anywhere;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.rk-rich-text span {
|
|
45
|
+
unicode-bidi: isolate;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.rk-rich-text span[dir="rtl"] {
|
|
49
|
+
direction: rtl;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.rk-rich-text span[dir="ltr"] {
|
|
53
|
+
direction: ltr;
|
|
54
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from html import escape
|
|
3
|
+
from math import isfinite
|
|
4
|
+
from numbers import Real
|
|
5
|
+
|
|
6
|
+
from ...styles.style import Style
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class HtmlStyleResolver:
|
|
10
|
+
"""
|
|
11
|
+
Convert component styles into safe CSS declarations.
|
|
12
|
+
"""
|
|
13
|
+
PROPERTIES = {
|
|
14
|
+
"font_family": "font-family",
|
|
15
|
+
"font_size": "font-size",
|
|
16
|
+
"font_weight": "font-weight",
|
|
17
|
+
"font_style": "font-style",
|
|
18
|
+
"line_height": "line-height",
|
|
19
|
+
"letter_spacing": "letter-spacing",
|
|
20
|
+
"color": "color",
|
|
21
|
+
"text_align": "text-align",
|
|
22
|
+
"text_transform": "text-transform",
|
|
23
|
+
"text_decoration": "text-decoration",
|
|
24
|
+
"vertical_align": "vertical-align",
|
|
25
|
+
"direction": "direction",
|
|
26
|
+
"background_color": "background-color",
|
|
27
|
+
"opacity": "opacity",
|
|
28
|
+
"width": "width",
|
|
29
|
+
"min_width": "min-width",
|
|
30
|
+
"max_width": "max-width",
|
|
31
|
+
"height": "height",
|
|
32
|
+
"min_height": "min-height",
|
|
33
|
+
"max_height": "max-height",
|
|
34
|
+
"display": "display",
|
|
35
|
+
"flex_direction": "flex-direction",
|
|
36
|
+
"flex_wrap": "flex-wrap",
|
|
37
|
+
"flex": "flex",
|
|
38
|
+
"justify_content": "justify-content",
|
|
39
|
+
"align_items": "align-items",
|
|
40
|
+
"align_self": "align-self",
|
|
41
|
+
"gap": "gap",
|
|
42
|
+
"row_gap": "row-gap",
|
|
43
|
+
"column_gap": "column-gap",
|
|
44
|
+
"padding": "padding",
|
|
45
|
+
"padding_top": "padding-top",
|
|
46
|
+
"padding_right": "padding-right",
|
|
47
|
+
"padding_bottom": "padding-bottom",
|
|
48
|
+
"padding_left": "padding-left",
|
|
49
|
+
"margin": "margin",
|
|
50
|
+
"margin_top": "margin-top",
|
|
51
|
+
"margin_right": "margin-right",
|
|
52
|
+
"margin_bottom": "margin-bottom",
|
|
53
|
+
"margin_left": "margin-left",
|
|
54
|
+
"border_width": "border-width",
|
|
55
|
+
"border_color": "border-color",
|
|
56
|
+
"border_style": "border-style",
|
|
57
|
+
"border_radius": "border-radius",
|
|
58
|
+
"border_top": "border-top",
|
|
59
|
+
"border_right": "border-right",
|
|
60
|
+
"border_bottom": "border-bottom",
|
|
61
|
+
"border_left": "border-left",
|
|
62
|
+
"box_shadow": "box-shadow",
|
|
63
|
+
"overflow": "overflow",
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
DIMENSIONS = {
|
|
67
|
+
"font_size",
|
|
68
|
+
"letter_spacing",
|
|
69
|
+
"width",
|
|
70
|
+
"min_width",
|
|
71
|
+
"max_width",
|
|
72
|
+
"height",
|
|
73
|
+
"min_height",
|
|
74
|
+
"max_height",
|
|
75
|
+
"gap",
|
|
76
|
+
"row_gap",
|
|
77
|
+
"column_gap",
|
|
78
|
+
"padding",
|
|
79
|
+
"padding_top",
|
|
80
|
+
"padding_right",
|
|
81
|
+
"padding_bottom",
|
|
82
|
+
"padding_left",
|
|
83
|
+
"margin",
|
|
84
|
+
"margin_top",
|
|
85
|
+
"margin_right",
|
|
86
|
+
"margin_bottom",
|
|
87
|
+
"margin_left",
|
|
88
|
+
"border_width",
|
|
89
|
+
"border_radius",
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
SHORTHANDS = {"padding", "padding_top", "padding_right", "padding_bottom", "padding_left", "margin", "margin_top", "margin_right", "margin_bottom", "margin_left"}
|
|
93
|
+
|
|
94
|
+
KEYWORDS = {
|
|
95
|
+
"font_style": {"normal", "italic", "oblique"},
|
|
96
|
+
"text_align": {"start", "end", "left", "right", "center", "justify"},
|
|
97
|
+
"text_transform": {"none", "uppercase", "lowercase", "capitalize"},
|
|
98
|
+
"text_decoration": {"none", "underline", "overline", "line-through"},
|
|
99
|
+
"direction": {"ltr", "rtl"},
|
|
100
|
+
"display": {"block", "inline", "inline-block", "flex", "grid", "none"},
|
|
101
|
+
"flex_direction": {"row", "row-reverse", "column", "column-reverse"},
|
|
102
|
+
"flex_wrap": {"nowrap", "wrap", "wrap-reverse"},
|
|
103
|
+
"justify_content": {"start", "end", "center", "space-between", "space-around", "space-evenly", "flex-start", "flex-end"},
|
|
104
|
+
"align_items": {"start", "end", "center", "stretch", "baseline", "flex-start", "flex-end"},
|
|
105
|
+
"align_self": {"auto", "start", "end", "center", "stretch", "baseline", "flex-start", "flex-end"},
|
|
106
|
+
"vertical_align": {"baseline", "middle", "top", "bottom", "text-top", "text-bottom"},
|
|
107
|
+
"border_style": {"none", "solid", "dashed", "dotted", "double"},
|
|
108
|
+
"overflow": {"visible", "hidden", "auto", "scroll"},
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
DIMENSION_VALUE = re.compile(r"-?(?:\d+(?:\.\d+)?|\.\d+)(?:px|%|rem|em|mm|cm|in|pt|vw|vh)?$")
|
|
112
|
+
|
|
113
|
+
def resolve(self, style: Style) -> str:
|
|
114
|
+
"""
|
|
115
|
+
Convert a Style instance into CSS declarations.
|
|
116
|
+
"""
|
|
117
|
+
if not isinstance(style, Style):
|
|
118
|
+
raise TypeError("Expected a Style instance.")
|
|
119
|
+
|
|
120
|
+
declarations = []
|
|
121
|
+
for name, value in style.to_dict().items():
|
|
122
|
+
property_name = self.PROPERTIES.get(name)
|
|
123
|
+
if property_name is None or value is None:
|
|
124
|
+
continue
|
|
125
|
+
|
|
126
|
+
value = self.format_value(name, value)
|
|
127
|
+
declarations.append(f"{property_name}: {value}")
|
|
128
|
+
|
|
129
|
+
return "; ".join(declarations)
|
|
130
|
+
|
|
131
|
+
def format_value(self, name: str, value) -> str:
|
|
132
|
+
"""
|
|
133
|
+
Format and validate a CSS property value.
|
|
134
|
+
"""
|
|
135
|
+
if isinstance(value, bool):
|
|
136
|
+
raise ValueError(f"Invalid CSS value for '{name}'.")
|
|
137
|
+
|
|
138
|
+
if isinstance(value, Real):
|
|
139
|
+
if not isfinite(value):
|
|
140
|
+
raise ValueError(f"Invalid CSS value for '{name}'.")
|
|
141
|
+
|
|
142
|
+
if name == "opacity" and not 0 <= value <= 1:
|
|
143
|
+
raise ValueError(f"Invalid CSS value for '{name}'.")
|
|
144
|
+
|
|
145
|
+
return f"{value}px" if name in self.DIMENSIONS else str(value)
|
|
146
|
+
|
|
147
|
+
if not isinstance(value, str):
|
|
148
|
+
raise TypeError(f"Unsupported CSS value for '{name}'.")
|
|
149
|
+
|
|
150
|
+
if any(character in value for character in (";", "{", "}", "<", ">", "\n", "\r", "\\")):
|
|
151
|
+
raise ValueError(f"Invalid CSS value for '{name}'.")
|
|
152
|
+
|
|
153
|
+
if name in self.KEYWORDS and value not in self.KEYWORDS[name]:
|
|
154
|
+
raise ValueError(f"Invalid CSS value for '{name}'.")
|
|
155
|
+
|
|
156
|
+
if name in self.DIMENSIONS and not self.DIMENSION_VALUE.fullmatch(value):
|
|
157
|
+
if name in self.SHORTHANDS and all(self.DIMENSION_VALUE.fullmatch(part) for part in value.split()):
|
|
158
|
+
return value
|
|
159
|
+
raise ValueError(f"Invalid CSS value for '{name}'.")
|
|
160
|
+
|
|
161
|
+
return value
|
|
162
|
+
|
|
163
|
+
def to_attribute(self, style: Style) -> str:
|
|
164
|
+
"""
|
|
165
|
+
Return escaped CSS declarations for an HTML attribute.
|
|
166
|
+
"""
|
|
167
|
+
return escape(self.resolve(style), quote=True)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<div class="rk-key-value rk-key-value--{{ component.orientation }}"{% if style %} style="{{ style }}"{% endif %}>
|
|
2
|
+
<div class="rk-key-value__labels"{% if label_style %} style="{{ label_style }}"{% endif %}>
|
|
3
|
+
<span class="rk-key-value__label">{{ component.label }}</span>
|
|
4
|
+
{%- if component.secondary_label %}
|
|
5
|
+
<span class="rk-key-value__secondary">{{ component.secondary_label }}</span>
|
|
6
|
+
{%- endif %}
|
|
7
|
+
</div>
|
|
8
|
+
<div class="rk-key-value__value"{% if value_style %} style="{{ value_style }}"{% endif %}>{{ "" if component.value is none else component.value }}</div>
|
|
9
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<hr class="rk-divider"{% if style %} style="{{ style }}"{% endif %}>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div class="rk-spacer" aria-hidden="true" style="height: {{ height }}px;{% if style %} {{ style }}{% endif %}"></div>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<img
|
|
2
|
+
class="rk-image"
|
|
3
|
+
src="{{ source }}"
|
|
4
|
+
alt="{{ component.alt }}"
|
|
5
|
+
{% if component.width %}width="{{ component.width }}"{% endif %}
|
|
6
|
+
{% if component.height %}height="{{ component.height }}"{% endif %}
|
|
7
|
+
style="object-fit: {{ component.fit }};{% if component.width and component.width.isdigit() %} width: {{ component.width }}px;{% endif %}{% if component.height and component.height.isdigit() %} height: {{ component.height }}px;{% endif %}{% if style %} {{ style }}{% endif %}"
|
|
8
|
+
>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div class="rk-page-break" aria-hidden="true"></div>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<td class="{{ cell.css_class }}"{% if cell.colspan > 1 %} colspan="{{ cell.colspan }}"{% endif %}{% if cell.rowspan > 1 %} rowspan="{{ cell.rowspan }}"{% endif %}{% if cell.style %} style="{{ cell.style }}"{% endif %}>
|
|
2
|
+
{%- if cell.content is not none -%}
|
|
3
|
+
<div class="rk-table-cell__content">{{ cell.content | safe }}</div>
|
|
4
|
+
{%- else -%}
|
|
5
|
+
<span class="rk-table-cell__value">{% for line, direction in cell.lines %}<span class="rk-table-cell__line"{% if direction %} dir="{{ direction }}"{% endif %}>{{ line }}</span>{% endfor %}</span>
|
|
6
|
+
{%- endif -%}
|
|
7
|
+
</td>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<div class="{{ container_class }}">
|
|
2
|
+
<table class="{{ table_class }}"{% if style %} style="{{ style }}"{% endif %}>
|
|
3
|
+
{% if caption %}<caption class="rk-table-caption">{{ caption }}</caption>{% endif %}
|
|
4
|
+
<colgroup>
|
|
5
|
+
{% for column in columns %}<col{% if column.width %} style="width: {{ column.width }}"{% endif %}>{% endfor %}
|
|
6
|
+
</colgroup>
|
|
7
|
+
{% if show_header %}
|
|
8
|
+
<thead>
|
|
9
|
+
<tr>
|
|
10
|
+
{% for th in header %}
|
|
11
|
+
<th scope="col" class="rk-table-th{% if th.nowrap %} rk-table-th--nowrap{% endif %}" style="text-align: {{ th.align }}">
|
|
12
|
+
<span class="rk-table-th__title"{% if th.title_dir %} dir="{{ th.title_dir }}"{% endif %}>{{ th.title }}</span>
|
|
13
|
+
{%- if th.subtitle %}<span class="rk-table-th__subtitle"{% if th.subtitle_dir %} dir="{{ th.subtitle_dir }}"{% endif %}>{{ th.subtitle }}</span>{% endif %}
|
|
14
|
+
</th>
|
|
15
|
+
{% endfor %}
|
|
16
|
+
</tr>
|
|
17
|
+
</thead>
|
|
18
|
+
{% endif %}
|
|
19
|
+
<tbody>
|
|
20
|
+
{% for row in rows %}
|
|
21
|
+
<tr class="{{ row.css_class }}"{% if row.style %} style="{{ row.style }}"{% endif %}>
|
|
22
|
+
{% for cell in row.cells %}{% include "components/table/cell.html" %}{% endfor %}
|
|
23
|
+
</tr>
|
|
24
|
+
{% endfor %}
|
|
25
|
+
</tbody>
|
|
26
|
+
{% if footer %}
|
|
27
|
+
<tfoot>
|
|
28
|
+
<tr class="{{ footer.css_class }}"{% if footer.style %} style="{{ footer.style }}"{% endif %}>
|
|
29
|
+
{% for cell in footer.cells %}{% include "components/table/cell.html" %}{% endfor %}
|
|
30
|
+
</tr>
|
|
31
|
+
</tfoot>
|
|
32
|
+
{% endif %}
|
|
33
|
+
</table>
|
|
34
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h{{ component.level }} class="rk-heading rk-heading--{{ component.level }}"{% if style %} style="{{ style }}"{% endif %}>{{ component.value }}</h{{ component.level }}>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<p class="rk-rich-text" style="text-align: {{ align }};{% if style %} {{ style }}{% endif %}">
|
|
2
|
+
{%- for span in spans -%}
|
|
3
|
+
<span{% if span.language %} lang="{{ span.language }}"{% endif %}{% if span.direction %} dir="{{ span.direction }}"{% endif %}{% if span.style %} style="{{ span.style }}"{% endif %}>{{ span.value }}</span>
|
|
4
|
+
{%- endfor -%}
|
|
5
|
+
</p>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<p class="rk-text"{% if style %} style="{{ style }}"{% endif %}>{{ component.value }}</p>
|