@simai-studio/mail 0.0.0-stage → 1.0.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.
- package/LICENSE.md +188 -0
- package/README.md +79 -2
- package/dist/package-receipt.json +1176 -0
- package/dist/set.json +97 -0
- package/dist/smart/mail-canvas/component.json +562 -0
- package/dist/smart/mail-canvas/component.json.gz +0 -0
- package/dist/smart/mail-canvas/css/mail-canvas.css +85 -0
- package/dist/smart/mail-canvas/css/mail-canvas.css.gz +0 -0
- package/dist/smart/mail-canvas/css/mail-canvas.min.css +2 -0
- package/dist/smart/mail-canvas/css/mail-canvas.min.css.gz +0 -0
- package/dist/smart/mail-canvas/examples.json +731 -0
- package/dist/smart/mail-canvas/examples.json.gz +0 -0
- package/dist/smart/mail-canvas/js/mail-canvas.js +1039 -0
- package/dist/smart/mail-canvas/js/mail-canvas.js.gz +0 -0
- package/dist/smart/mail-canvas/js/mail-canvas.min.js +22 -0
- package/dist/smart/mail-canvas/js/mail-canvas.min.js.gz +0 -0
- package/dist/smart/mail-canvas/lang/en.json +25 -0
- package/dist/smart/mail-canvas/lang/en.json.gz +0 -0
- package/dist/smart/mail-canvas/lang/ru.json +25 -0
- package/dist/smart/mail-canvas/lang/ru.json.gz +0 -0
- package/dist/smart/mail-canvas/probe.json +465 -0
- package/dist/smart/mail-canvas/probe.json.gz +0 -0
- package/dist/smart/mail-canvas/smart.manifest.json +550 -0
- package/dist/smart/mail-canvas/smart.manifest.json.gz +0 -0
- package/dist/smart/mail-canvas/static/default/notes.html +43 -0
- package/dist/smart/mail-canvas/static/default/notes.html.gz +0 -0
- package/dist/smart/mail-canvas/static/default/phone.html +43 -0
- package/dist/smart/mail-canvas/static/default/phone.html.gz +0 -0
- package/dist/smart/mail-canvas/static/default/reference.html +48 -0
- package/dist/smart/mail-canvas/static/default/reference.html.gz +0 -0
- package/dist/smart/mail-canvas/static/sheets.json +132 -0
- package/dist/smart/mail-canvas/static/sheets.json.gz +0 -0
- package/dist/smart/mail-canvas/studio.fixture.json +63 -0
- package/dist/smart/mail-canvas/studio.fixture.json.gz +0 -0
- package/dist/smart/mail-canvas/studio.scenario.json +39 -0
- package/dist/smart/mail-canvas/studio.scenario.json.gz +0 -0
- package/dist/smart/mail-canvas/template/default.css +73 -0
- package/dist/smart/mail-canvas/template/default.css.gz +0 -0
- package/dist/smart/mail-canvas/template/default.js +38 -0
- package/dist/smart/mail-canvas/template/default.js.gz +0 -0
- package/dist/smart/mail-inspector/component.json +768 -0
- package/dist/smart/mail-inspector/component.json.gz +0 -0
- package/dist/smart/mail-inspector/css/mail-inspector.css +194 -0
- package/dist/smart/mail-inspector/css/mail-inspector.css.gz +0 -0
- package/dist/smart/mail-inspector/css/mail-inspector.min.css +2 -0
- package/dist/smart/mail-inspector/css/mail-inspector.min.css.gz +0 -0
- package/dist/smart/mail-inspector/examples.json +1301 -0
- package/dist/smart/mail-inspector/examples.json.gz +0 -0
- package/dist/smart/mail-inspector/js/mail-inspector.js +1619 -0
- package/dist/smart/mail-inspector/js/mail-inspector.js.gz +0 -0
- package/dist/smart/mail-inspector/js/mail-inspector.min.js +103 -0
- package/dist/smart/mail-inspector/js/mail-inspector.min.js.gz +0 -0
- package/dist/smart/mail-inspector/lang/en.json +29 -0
- package/dist/smart/mail-inspector/lang/en.json.gz +0 -0
- package/dist/smart/mail-inspector/lang/ru.json +29 -0
- package/dist/smart/mail-inspector/lang/ru.json.gz +0 -0
- package/dist/smart/mail-inspector/probe.json +648 -0
- package/dist/smart/mail-inspector/probe.json.gz +0 -0
- package/dist/smart/mail-inspector/smart.manifest.json +920 -0
- package/dist/smart/mail-inspector/smart.manifest.json.gz +0 -0
- package/dist/smart/mail-inspector/static/default/item.html +189 -0
- package/dist/smart/mail-inspector/static/default/item.html.gz +0 -0
- package/dist/smart/mail-inspector/static/default/letter.html +247 -0
- package/dist/smart/mail-inspector/static/default/letter.html.gz +0 -0
- package/dist/smart/mail-inspector/static/default/reference.html +545 -0
- package/dist/smart/mail-inspector/static/default/reference.html.gz +0 -0
- package/dist/smart/mail-inspector/static/sheets.json +226 -0
- package/dist/smart/mail-inspector/static/sheets.json.gz +0 -0
- package/dist/smart/mail-inspector/studio.fixture.json +232 -0
- package/dist/smart/mail-inspector/studio.fixture.json.gz +0 -0
- package/dist/smart/mail-inspector/studio.scenario.json +43 -0
- package/dist/smart/mail-inspector/studio.scenario.json.gz +0 -0
- package/dist/smart/mail-inspector/template/default.css +190 -0
- package/dist/smart/mail-inspector/template/default.css.gz +0 -0
- package/dist/smart/mail-inspector/template/default.js +249 -0
- package/dist/smart/mail-inspector/template/default.js.gz +0 -0
- package/dist/smart/mail-letters/component.json +455 -0
- package/dist/smart/mail-letters/component.json.gz +0 -0
- package/dist/smart/mail-letters/css/mail-letters.css +72 -0
- package/dist/smart/mail-letters/css/mail-letters.css.gz +0 -0
- package/dist/smart/mail-letters/css/mail-letters.min.css +2 -0
- package/dist/smart/mail-letters/css/mail-letters.min.css.gz +0 -0
- package/dist/smart/mail-letters/examples.json +477 -0
- package/dist/smart/mail-letters/examples.json.gz +0 -0
- package/dist/smart/mail-letters/js/mail-letters.js +1772 -0
- package/dist/smart/mail-letters/js/mail-letters.js.gz +0 -0
- package/dist/smart/mail-letters/js/mail-letters.min.js +35 -0
- package/dist/smart/mail-letters/js/mail-letters.min.js.gz +0 -0
- package/dist/smart/mail-letters/lang/en.json +29 -0
- package/dist/smart/mail-letters/lang/en.json.gz +0 -0
- package/dist/smart/mail-letters/lang/ru.json +31 -0
- package/dist/smart/mail-letters/lang/ru.json.gz +0 -0
- package/dist/smart/mail-letters/probe.json +290 -0
- package/dist/smart/mail-letters/probe.json.gz +0 -0
- package/dist/smart/mail-letters/smart.manifest.json +476 -0
- package/dist/smart/mail-letters/smart.manifest.json.gz +0 -0
- package/dist/smart/mail-letters/static/default/by-title.html +177 -0
- package/dist/smart/mail-letters/static/default/by-title.html.gz +0 -0
- package/dist/smart/mail-letters/static/default/empty.html +88 -0
- package/dist/smart/mail-letters/static/default/empty.html.gz +0 -0
- package/dist/smart/mail-letters/static/default/nothing-found.html +88 -0
- package/dist/smart/mail-letters/static/default/nothing-found.html.gz +0 -0
- package/dist/smart/mail-letters/static/default/reference.html +168 -0
- package/dist/smart/mail-letters/static/default/reference.html.gz +0 -0
- package/dist/smart/mail-letters/static/sheets.json +245 -0
- package/dist/smart/mail-letters/static/sheets.json.gz +0 -0
- package/dist/smart/mail-letters/studio.fixture.json +41 -0
- package/dist/smart/mail-letters/studio.fixture.json.gz +0 -0
- package/dist/smart/mail-letters/studio.scenario.json +41 -0
- package/dist/smart/mail-letters/studio.scenario.json.gz +0 -0
- package/dist/smart/mail-letters/template/default.css +79 -0
- package/dist/smart/mail-letters/template/default.css.gz +0 -0
- package/dist/smart/mail-letters/template/default.js +61 -0
- package/dist/smart/mail-letters/template/default.js.gz +0 -0
- package/dist/smart/mail-library/component.json +512 -0
- package/dist/smart/mail-library/component.json.gz +0 -0
- package/dist/smart/mail-library/css/mail-library.css +149 -0
- package/dist/smart/mail-library/css/mail-library.css.gz +0 -0
- package/dist/smart/mail-library/css/mail-library.min.css +2 -0
- package/dist/smart/mail-library/css/mail-library.min.css.gz +0 -0
- package/dist/smart/mail-library/examples.json +616 -0
- package/dist/smart/mail-library/examples.json.gz +0 -0
- package/dist/smart/mail-library/js/mail-library.js +559 -0
- package/dist/smart/mail-library/js/mail-library.js.gz +0 -0
- package/dist/smart/mail-library/js/mail-library.min.js +52 -0
- package/dist/smart/mail-library/js/mail-library.min.js.gz +0 -0
- package/dist/smart/mail-library/lang/en.json +21 -0
- package/dist/smart/mail-library/lang/en.json.gz +0 -0
- package/dist/smart/mail-library/lang/ru.json +21 -0
- package/dist/smart/mail-library/lang/ru.json.gz +0 -0
- package/dist/smart/mail-library/probe.json +275 -0
- package/dist/smart/mail-library/probe.json.gz +0 -0
- package/dist/smart/mail-library/smart.manifest.json +512 -0
- package/dist/smart/mail-library/smart.manifest.json.gz +0 -0
- package/dist/smart/mail-library/static/default/category.html +85 -0
- package/dist/smart/mail-library/static/default/category.html.gz +0 -0
- package/dist/smart/mail-library/static/default/nothing-found.html +81 -0
- package/dist/smart/mail-library/static/default/nothing-found.html.gz +0 -0
- package/dist/smart/mail-library/static/default/one-group.html +67 -0
- package/dist/smart/mail-library/static/default/one-group.html.gz +0 -0
- package/dist/smart/mail-library/static/default/reference.html +135 -0
- package/dist/smart/mail-library/static/default/reference.html.gz +0 -0
- package/dist/smart/mail-library/static/sheets.json +180 -0
- package/dist/smart/mail-library/static/sheets.json.gz +0 -0
- package/dist/smart/mail-library/studio.fixture.json +75 -0
- package/dist/smart/mail-library/studio.fixture.json.gz +0 -0
- package/dist/smart/mail-library/studio.scenario.json +41 -0
- package/dist/smart/mail-library/studio.scenario.json.gz +0 -0
- package/dist/smart/mail-library/template/default.css +133 -0
- package/dist/smart/mail-library/template/default.css.gz +0 -0
- package/dist/smart/mail-library/template/default.js +83 -0
- package/dist/smart/mail-library/template/default.js.gz +0 -0
- package/dist/smart/mail-structure/component.json +497 -0
- package/dist/smart/mail-structure/component.json.gz +0 -0
- package/dist/smart/mail-structure/css/mail-structure.css +106 -0
- package/dist/smart/mail-structure/css/mail-structure.css.gz +0 -0
- package/dist/smart/mail-structure/css/mail-structure.min.css +2 -0
- package/dist/smart/mail-structure/css/mail-structure.min.css.gz +0 -0
- package/dist/smart/mail-structure/examples.json +286 -0
- package/dist/smart/mail-structure/examples.json.gz +0 -0
- package/dist/smart/mail-structure/js/mail-structure.js +767 -0
- package/dist/smart/mail-structure/js/mail-structure.js.gz +0 -0
- package/dist/smart/mail-structure/js/mail-structure.min.js +48 -0
- package/dist/smart/mail-structure/js/mail-structure.min.js.gz +0 -0
- package/dist/smart/mail-structure/lang/en.json +22 -0
- package/dist/smart/mail-structure/lang/en.json.gz +0 -0
- package/dist/smart/mail-structure/lang/ru.json +22 -0
- package/dist/smart/mail-structure/lang/ru.json.gz +0 -0
- package/dist/smart/mail-structure/probe.json +112 -0
- package/dist/smart/mail-structure/probe.json.gz +0 -0
- package/dist/smart/mail-structure/smart.manifest.json +495 -0
- package/dist/smart/mail-structure/smart.manifest.json.gz +0 -0
- package/dist/smart/mail-structure/static/default/empty.html +76 -0
- package/dist/smart/mail-structure/static/default/empty.html.gz +0 -0
- package/dist/smart/mail-structure/static/default/reference.html +98 -0
- package/dist/smart/mail-structure/static/default/reference.html.gz +0 -0
- package/dist/smart/mail-structure/static/default/settings.html +98 -0
- package/dist/smart/mail-structure/static/default/settings.html.gz +0 -0
- package/dist/smart/mail-structure/static/sheets.json +142 -0
- package/dist/smart/mail-structure/static/sheets.json.gz +0 -0
- package/dist/smart/mail-structure/studio.fixture.json +45 -0
- package/dist/smart/mail-structure/studio.fixture.json.gz +0 -0
- package/dist/smart/mail-structure/studio.scenario.json +42 -0
- package/dist/smart/mail-structure/studio.scenario.json.gz +0 -0
- package/dist/smart/mail-structure/template/default.css +100 -0
- package/dist/smart/mail-structure/template/default.css.gz +0 -0
- package/dist/smart/mail-structure/template/default.js +80 -0
- package/dist/smart/mail-structure/template/default.js.gz +0 -0
- package/dist/smart/rule.js +161 -0
- package/dist/smart/rule.js.gz +0 -0
- package/package.json +29 -4
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
@layer sf.reset, sf.tokens, sf.base, sf.paint, sf.utilities, sf.components, sf.overrides, sf.states;
|
|
2
|
+
@layer sf.components {
|
|
3
|
+
/* sf-mail-inspector, the right panel of SIMAI Email Editor: the heading and
|
|
4
|
+
the path, tabs, flush sections with no side inset (the fields line up with
|
|
5
|
+
the heading), the lists of items and the groups in pairs. The host is
|
|
6
|
+
display: contents; .sf-mail-inspector is what a page places. Every value is
|
|
7
|
+
a Framework token. */
|
|
8
|
+
.sf-mail-inspector {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
gap: var(--sf-space-1\/2);
|
|
12
|
+
min-inline-size: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.sf-mail-inspector-head {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
gap: var(--sf-space-1\/4);
|
|
19
|
+
min-inline-size: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.sf-mail-inspector-title-row {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
gap: var(--sf-space-1\/2);
|
|
26
|
+
min-inline-size: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.sf-mail-inspector-title {
|
|
30
|
+
flex-grow: 1;
|
|
31
|
+
min-inline-size: 0;
|
|
32
|
+
margin: 0;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
color: var(--sf-on-surface);
|
|
35
|
+
font-size: var(--sf-text--size-1);
|
|
36
|
+
font-weight: var(--sf-font-weight-bold);
|
|
37
|
+
text-overflow: ellipsis;
|
|
38
|
+
white-space: nowrap;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.sf-mail-inspector-notice {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
align-items: flex-start;
|
|
45
|
+
gap: var(--sf-space-1\/4);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.sf-mail-inspector-notice-text {
|
|
49
|
+
color: var(--sf-on-surface-variant);
|
|
50
|
+
font-size: var(--sf-text--size-1\/2);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.sf-mail-inspector-panel {
|
|
54
|
+
padding-block-start: var(--sf-space-1\/2);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sf-mail-inspector-sections {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Only the side padding goes, so the fields line up with the heading. */
|
|
63
|
+
.sf-mail-inspector-sections .sf-accordion {
|
|
64
|
+
--sf-accordion--content-padding: var(--sf-space-1\/4) 0 var(--sf-space-1);
|
|
65
|
+
--sf-accordion--trigger-padding-inline: 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.sf-mail-inspector-sections .sf-accordion-title {
|
|
69
|
+
font-weight: var(--sf-font-weight-medium);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.sf-mail-inspector-tabs {
|
|
73
|
+
--sf-tabs-gap: var(--sf-space-1\/3);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.sf-mail-inspector-fields,
|
|
77
|
+
.sf-mail-inspector-group,
|
|
78
|
+
.sf-mail-inspector-row,
|
|
79
|
+
.sf-mail-inspector-image,
|
|
80
|
+
.sf-mail-inspector-items {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-direction: column;
|
|
83
|
+
gap: var(--sf-space-1\/2);
|
|
84
|
+
min-inline-size: 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.sf-mail-inspector-image {
|
|
88
|
+
gap: var(--sf-space-1\/4);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.sf-mail-inspector-pair {
|
|
92
|
+
display: grid;
|
|
93
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
94
|
+
gap: var(--sf-space-1\/2);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.sf-mail-inspector-list {
|
|
98
|
+
display: flex;
|
|
99
|
+
flex-direction: column;
|
|
100
|
+
gap: var(--sf-space-1\/4);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.sf-mail-inspector-item {
|
|
104
|
+
border: var(--sf-px) solid var(--sf-outline-variant);
|
|
105
|
+
border-radius: var(--sf-radius--ui);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.sf-mail-inspector-item.is-open {
|
|
109
|
+
border-color: var(--sf-primary);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* The row's disclosure and its ⋯ are neighbours of one action row, not a
|
|
113
|
+
toolbar: --sf-space-1/3 apart, 8 and 4 under compact density (C105 H5,
|
|
114
|
+
C144; RG-S2-44). They stood 4 apart. */
|
|
115
|
+
.sf-mail-inspector-item-head {
|
|
116
|
+
display: flex;
|
|
117
|
+
align-items: center;
|
|
118
|
+
gap: var(--sf-space-1\/3);
|
|
119
|
+
padding: var(--sf-space-1\/4);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.sf-mail-inspector-handle {
|
|
123
|
+
display: inline-flex;
|
|
124
|
+
flex-shrink: 0;
|
|
125
|
+
inline-size: var(--sf-icon-size-1);
|
|
126
|
+
color: var(--sf-on-surface-variant);
|
|
127
|
+
cursor: grab;
|
|
128
|
+
opacity: 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.sf-mail-inspector-item:hover .sf-mail-inspector-handle,
|
|
132
|
+
.sf-mail-inspector-item:focus-within .sf-mail-inspector-handle {
|
|
133
|
+
opacity: 1;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@media (hover: none) {
|
|
137
|
+
.sf-mail-inspector-handle {
|
|
138
|
+
opacity: 1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.sf-mail-inspector-toggle {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-grow: 1;
|
|
145
|
+
align-items: center;
|
|
146
|
+
gap: var(--sf-space-1\/4);
|
|
147
|
+
min-inline-size: 0;
|
|
148
|
+
min-block-size: var(--sf-ui-1\/2--control-height);
|
|
149
|
+
padding-inline: var(--sf-space-1\/4);
|
|
150
|
+
border: 0;
|
|
151
|
+
border-radius: var(--sf-radius--ui);
|
|
152
|
+
background: transparent;
|
|
153
|
+
color: inherit;
|
|
154
|
+
font: inherit;
|
|
155
|
+
font-size: var(--sf-text--size-1\/2);
|
|
156
|
+
text-align: start;
|
|
157
|
+
cursor: pointer;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.sf-mail-inspector-toggle:focus-visible {
|
|
161
|
+
outline: var(--sf-focus--width) var(--sf-focus--style) var(--sf-focus--color);
|
|
162
|
+
outline-offset: calc(var(--sf-focus--width) * -1);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.sf-mail-inspector-item-label {
|
|
166
|
+
overflow: hidden;
|
|
167
|
+
text-overflow: ellipsis;
|
|
168
|
+
white-space: nowrap;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.sf-mail-inspector-item.has-problem .sf-mail-inspector-item-label {
|
|
172
|
+
color: var(--sf-error);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.sf-mail-inspector-item-body {
|
|
176
|
+
display: flex;
|
|
177
|
+
flex-direction: column;
|
|
178
|
+
gap: var(--sf-space-1\/2);
|
|
179
|
+
padding: var(--sf-space-1\/2);
|
|
180
|
+
border-block-start: var(--sf-px) solid var(--sf-outline-variant);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.sf-mail-inspector-item-body[hidden] {
|
|
184
|
+
display: none;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.sf-mail-inspector-add {
|
|
188
|
+
align-self: flex-start;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import {html, nothing} from "lit";
|
|
2
|
+
import {keyed} from "lit/directives/keyed.js";
|
|
3
|
+
import {repeat} from "lit/directives/repeat.js";
|
|
4
|
+
import "./default.css";
|
|
5
|
+
|
|
6
|
+
const ICONS = {duplicate: "content_copy", delete: "delete", replace: "swap_horiz"};
|
|
7
|
+
|
|
8
|
+
// A text-like field. `value` holds still while there is typed text (see
|
|
9
|
+
// index.js), and the same element stays under a redraw, so the focus and the
|
|
10
|
+
// caret stay in it.
|
|
11
|
+
function renderText(context, field) {
|
|
12
|
+
const {component} = context;
|
|
13
|
+
const error = component.errorOf(field);
|
|
14
|
+
const onLeave = () => component.onFieldLeave(field.path);
|
|
15
|
+
const onInput = (event) => component.onFieldInput(field.path, event.currentTarget);
|
|
16
|
+
if (field.kind === "multiline") {
|
|
17
|
+
return html`<sf-input-textarea class="sf-mail-inspector-field" size="1/2" auto-grow data-path=${field.path}
|
|
18
|
+
label=${field.label || nothing} aria-label=${field.ariaLabel || nothing}
|
|
19
|
+
value=${component.valueAttribute(field)} placeholder=${field.placeholder || nothing} hint=${field.hint || nothing}
|
|
20
|
+
inherited-value=${field.inheritedValue || nothing} ?required=${field.required} ?disabled=${field.disabled}
|
|
21
|
+
?invalid=${Boolean(error)} error-message=${error || nothing} data-draft=${component.isDraft(field) ? "true" : nothing}
|
|
22
|
+
@input=${onInput} @focusout=${onLeave}></sf-input-textarea>`;
|
|
23
|
+
}
|
|
24
|
+
return html`<sf-input class="sf-mail-inspector-field" size="1/2" data-path=${field.path}
|
|
25
|
+
label=${field.label || nothing} aria-label=${field.ariaLabel || nothing}
|
|
26
|
+
value=${component.valueAttribute(field)} placeholder=${field.placeholder || nothing} hint=${field.hint || nothing}
|
|
27
|
+
input-type=${field.kind === "link" ? "url" : nothing} inputmode=${field.inputmode || (field.kind === "number" ? "numeric" : nothing)}
|
|
28
|
+
inherited-value=${field.inheritedValue || nothing} ?required=${field.required} ?disabled=${field.disabled}
|
|
29
|
+
?invalid=${Boolean(error)} error-message=${error || nothing} data-draft=${component.isDraft(field) ? "true" : nothing}
|
|
30
|
+
@input=${onInput} @focusout=${onLeave}></sf-input>`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function renderSelect(context, field) {
|
|
34
|
+
const {component} = context;
|
|
35
|
+
const options = Array.isArray(field.options) ? field.options : [];
|
|
36
|
+
// A value of nothing reads as the choice that means it.
|
|
37
|
+
const none = options.find((option) => option.value === "")?.text;
|
|
38
|
+
return html`<sf-dropdown class="sf-mail-inspector-field" size="1/2" mode="select" data-path=${field.path} label=${field.label || nothing}
|
|
39
|
+
value=${field.value ?? ""} placeholder=${field.placeholder || none || nothing} hint=${field.hint || nothing}
|
|
40
|
+
?required=${field.required} ?disabled=${field.disabled} ?invalid=${Boolean(field.error)} error-message=${field.error || nothing}
|
|
41
|
+
.options=${options} @change=${(event) => component.onChoice(field.path, event)}></sf-dropdown>`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function renderSwitch(context, field) {
|
|
45
|
+
const {component} = context;
|
|
46
|
+
return html`<sf-switch class="sf-mail-inspector-field" size="1/2" data-path=${field.path} label=${field.label || nothing}
|
|
47
|
+
?checked=${field.value === true} ?disabled=${field.disabled}
|
|
48
|
+
@change=${(event) => component.onSwitch(field.path, event.currentTarget)}></sf-switch>`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// A group of fields under one name, row by row: a price is its amount and old
|
|
52
|
+
// price, its currency and unit, then its note.
|
|
53
|
+
function renderGroup(context, field) {
|
|
54
|
+
const rows = Array.isArray(field.rows) ? field.rows : [];
|
|
55
|
+
return html`<div class="sf-mail-inspector-group" data-group=${field.path} role="group" aria-label=${field.label || nothing}>
|
|
56
|
+
${rows.map((row) => html`<div class=${row.length > 1 ? "sf-mail-inspector-pair" : "sf-mail-inspector-row"}>${row.map((part) => renderField(context, part))}</div>`)}
|
|
57
|
+
</div>`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// One image as sf-input-image: the picture, its name and size, «Заменить…» and
|
|
61
|
+
// «Убрать»; a file dropped on it replaces it. Under it, what the host offers to
|
|
62
|
+
// choose again. The field uploads nothing: the host stores the file.
|
|
63
|
+
function renderImage(context, field) {
|
|
64
|
+
const {component} = context;
|
|
65
|
+
const error = component.errorOf(field);
|
|
66
|
+
const choices = Array.isArray(field.choices) ? field.choices : [];
|
|
67
|
+
return html`<div class="sf-mail-inspector-image" data-path=${field.path}>
|
|
68
|
+
<sf-input-image size="1/2" label=${field.label || nothing} aria-label=${field.label ? nothing : field.ariaLabel || nothing}
|
|
69
|
+
accept=${field.accept || nothing} empty-text=${field.emptyText || context.words.imageEmpty} hint=${field.hint || nothing}
|
|
70
|
+
value=${field.value ? JSON.stringify(field.value) : nothing} ?required=${field.required} ?disabled=${field.disabled}
|
|
71
|
+
?invalid=${Boolean(error)} error-message=${error || nothing}
|
|
72
|
+
@sf-input-image-attach=${(event) => component.onAttach(field.path, event)}
|
|
73
|
+
@sf-input-image-detach=${(event) => component.onDetach(field.path, event)}
|
|
74
|
+
@sf-input-image-rejected=${(event) => component.onRejected(field.path, event)}></sf-input-image>
|
|
75
|
+
${choices.length
|
|
76
|
+
? html`<sf-dropdown class="sf-mail-inspector-choose" size="1/2" mode="select" data-choose=${field.path} label=${field.chooseLabel || nothing}
|
|
77
|
+
placeholder=${field.choosePlaceholder || nothing} value="" .options=${choices}
|
|
78
|
+
@change=${(event) => component.onImageChoice(field.path, event)}></sf-dropdown>`
|
|
79
|
+
: nothing}
|
|
80
|
+
</div>`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// A row: its handle, a disclosure with the item's label, and ⋯. One item is open
|
|
84
|
+
// at a time and shows its fields. `slot` marks the row as the list's content, not
|
|
85
|
+
// as sf-sortable's own first paint: sf-sortable may arrive first and would drop it.
|
|
86
|
+
function renderItem(context, field, item, index) {
|
|
87
|
+
const {component} = context;
|
|
88
|
+
const isOpen = field.open === index;
|
|
89
|
+
const label = String(item.label ?? "");
|
|
90
|
+
const actions = context.itemActionsLabel(label);
|
|
91
|
+
const bodyId = context.partOf(`${context.groupOf(field.path)}-item-${index}`);
|
|
92
|
+
return html`
|
|
93
|
+
<div slot="item" class=${["sf-mail-inspector-item", isOpen ? "is-open" : "", item.problem ? "has-problem" : ""].filter(Boolean).join(" ")}
|
|
94
|
+
data-sf-sortable-item=${`item-${index}`} data-item=${index} tabindex="-1">
|
|
95
|
+
<div class="sf-mail-inspector-item-head" @contextmenu=${(event) => component.onItemContextMenu(field.path, index, event)}>
|
|
96
|
+
<span class="sf-mail-inspector-handle" data-sf-sortable-handle aria-hidden="true"><sf-icon icon="drag_indicator" size="1"></sf-icon></span>
|
|
97
|
+
<button type="button" class="sf-mail-inspector-toggle" aria-expanded=${isOpen ? "true" : "false"} aria-controls=${bodyId} data-toggle=${index}
|
|
98
|
+
@click=${() => component.itemToggle({path: field.path, index})}
|
|
99
|
+
@keydown=${(event) => component.onToggleKeydown(field.path, index, event)}>
|
|
100
|
+
<sf-icon icon=${isOpen ? "expand_more" : "chevron_right"} size="1" aria-hidden="true"></sf-icon>
|
|
101
|
+
<span class="sf-mail-inspector-item-label">${label}</span>
|
|
102
|
+
</button>
|
|
103
|
+
<sf-button-icon class="sf-mail-inspector-item-more" appearance="ghost" scheme="on-surface" size="1/2" icon="more_horiz"
|
|
104
|
+
aria-label=${actions} title=${actions} data-item-menu=${index}
|
|
105
|
+
@click=${(event) => component.openItemMenu(field.path, index, event.currentTarget)}></sf-button-icon>
|
|
106
|
+
</div>
|
|
107
|
+
<div id=${bodyId} class="sf-mail-inspector-item-body" role="group" aria-label=${label} data-item-body=${index} data-item-list=${field.path} ?hidden=${!isOpen}>
|
|
108
|
+
${isOpen ? renderFields(context, item.fields) : nothing}
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function renderItems(context, field) {
|
|
115
|
+
const {component} = context;
|
|
116
|
+
const items = component.itemsOf(field);
|
|
117
|
+
return html`<div class="sf-mail-inspector-items" data-items=${field.path}>
|
|
118
|
+
<sf-sortable class="sf-mail-inspector-list" group=${context.groupOf(field.path)} label=${field.label || nothing}
|
|
119
|
+
@sf-sortable-move=${(event) => component.onSortableMove(field.path, event)}>
|
|
120
|
+
${repeat(items, (_, index) => index, (item, index) => renderItem(context, field, item, index))}
|
|
121
|
+
</sf-sortable>
|
|
122
|
+
<sf-button class="sf-mail-inspector-add" appearance="ghost" scheme="on-surface" size="1/2" icon-start="add" text=${context.words.add}
|
|
123
|
+
data-item-add=${field.path} ?disabled=${component.isFull(field)}
|
|
124
|
+
@click=${() => component.itemAdd({path: field.path})}></sf-button>
|
|
125
|
+
</div>`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function renderField(context, field) {
|
|
129
|
+
switch (field?.kind) {
|
|
130
|
+
case "text":
|
|
131
|
+
case "multiline":
|
|
132
|
+
case "link":
|
|
133
|
+
case "number":
|
|
134
|
+
return renderText(context, field);
|
|
135
|
+
case "select":
|
|
136
|
+
return renderSelect(context, field);
|
|
137
|
+
case "switch":
|
|
138
|
+
return renderSwitch(context, field);
|
|
139
|
+
case "group":
|
|
140
|
+
return renderGroup(context, field);
|
|
141
|
+
case "image":
|
|
142
|
+
return renderImage(context, field);
|
|
143
|
+
case "items":
|
|
144
|
+
return renderItems(context, field);
|
|
145
|
+
default:
|
|
146
|
+
return nothing;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function renderFields(context, fields) {
|
|
151
|
+
return html`<div class="sf-mail-inspector-fields">${repeat(Array.isArray(fields) ? fields : [], (field) => field.path, (field) => renderField(context, field))}</div>`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// One flush section of the class accordion. The element owns its state, so the
|
|
155
|
+
// class runtime leaves it alone (data-sf-accordion-init).
|
|
156
|
+
function renderSection(context, section) {
|
|
157
|
+
const {component} = context;
|
|
158
|
+
return html`
|
|
159
|
+
<article class=${["sf-accordion", "sf-accordion--flush", "sf-accordion--size-1/2", section.isOpen ? "active" : ""].filter(Boolean).join(" ")}
|
|
160
|
+
data-sf-accordion-init="1" data-section=${section.key}>
|
|
161
|
+
<h3 class="sf-accordion-heading">
|
|
162
|
+
<button class="sf-accordion-trigger" type="button" id=${section.triggerId} aria-expanded=${section.isOpen ? "true" : "false"} aria-controls=${section.panelId}
|
|
163
|
+
@click=${() => component.toggleSection({key: section.key})}>
|
|
164
|
+
<span class="sf-accordion-title">${section.title}</span>
|
|
165
|
+
<i class="sf-icon" aria-hidden="true">chevron_right</i>
|
|
166
|
+
</button>
|
|
167
|
+
</h3>
|
|
168
|
+
<div class="sf-accordion-content" id=${section.panelId} role="region" aria-labelledby=${section.triggerId} ?hidden=${!section.isOpen}>${renderFields(context, section.fields)}</div>
|
|
169
|
+
</article>
|
|
170
|
+
`;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// One section needs no disclosure: its fields stand on their own.
|
|
174
|
+
function renderForm(context) {
|
|
175
|
+
const {sections} = context;
|
|
176
|
+
if (sections.length === 1) return renderFields(context, sections[0].fields);
|
|
177
|
+
return html`<div class="sf-accordion-group sf-mail-inspector-sections">${repeat(sections, (section) => section.key, (section) => renderSection(context, section))}</div>`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// The tabs: one panel per tab, the form in those without a slot, the host's own
|
|
181
|
+
// panel in those with one. sf-tabs takes the panels as it connects, so a new list
|
|
182
|
+
// of tabs is a new sf-tabs (keyed in the caller).
|
|
183
|
+
function renderTabs(context) {
|
|
184
|
+
const {component} = context;
|
|
185
|
+
return html`<sf-tabs class="sf-mail-inspector-tabs" type="underline" size="1/2" aria-label=${context.heading || nothing}
|
|
186
|
+
active-index=${context.tabIndex} items=${context.tabs.map((tab) => tab.label).join("|")}
|
|
187
|
+
@sf-tabs-change=${(event) => component.onTabChange(event)}>
|
|
188
|
+
${repeat(context.tabs, (tab) => tab.id, (tab, index) => html`
|
|
189
|
+
<div slot=${`panel-${index}`} class="sf-mail-inspector-panel" data-tab=${tab.id}>
|
|
190
|
+
${tab.slot ? (component.hasSlotContent(tab.slot) ? component.getSlotContent(tab.slot) : nothing) : renderForm(context)}
|
|
191
|
+
</div>`)}
|
|
192
|
+
</sf-tabs>`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function renderHead(context) {
|
|
196
|
+
const {component} = context;
|
|
197
|
+
return html`
|
|
198
|
+
<div class="sf-mail-inspector-head">
|
|
199
|
+
${context.levels.length > 1
|
|
200
|
+
? html`<sf-breadcrumbs class="sf-mail-inspector-path" aria-label=${context.words.path}
|
|
201
|
+
items=${JSON.stringify(context.levels.map((level, index) => (index === context.levels.length - 1 ? {text: level.text, current: true} : {text: level.text, href: `#level-${index}`})))}
|
|
202
|
+
@sf-breadcrumbs-press=${(event) => component.onLevelPress(event)}
|
|
203
|
+
@click=${(event) => event.preventDefault()}></sf-breadcrumbs>`
|
|
204
|
+
: nothing}
|
|
205
|
+
${context.heading
|
|
206
|
+
? html`<div class="sf-mail-inspector-title-row">
|
|
207
|
+
${context.headingIcon ? html`<sf-icon icon=${context.headingIcon} size="2" aria-hidden="true"></sf-icon>` : nothing}
|
|
208
|
+
<h2 class="sf-mail-inspector-title">${context.heading}</h2>
|
|
209
|
+
${context.actions.map((name) => html`<sf-button-icon class="sf-mail-inspector-action" appearance="ghost" scheme="on-surface" size="1/2" icon=${ICONS[name] || "more_horiz"}
|
|
210
|
+
aria-label=${context.words[name] || name} title=${context.words[name] || name} data-action=${name}
|
|
211
|
+
@click=${() => component[name]?.()}></sf-button-icon>`)}
|
|
212
|
+
</div>`
|
|
213
|
+
: nothing}
|
|
214
|
+
</div>
|
|
215
|
+
`;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function renderNotice(context) {
|
|
219
|
+
const {component, notice} = context;
|
|
220
|
+
if (!notice) return nothing;
|
|
221
|
+
return html`<div class="sf-mail-inspector-notice">
|
|
222
|
+
<span class="sf-mail-inspector-notice-text">${notice.text}</span>
|
|
223
|
+
${notice.action
|
|
224
|
+
? html`<sf-button appearance="outline" size="1/2" text=${notice.action} data-notice-action @click=${() => component.sfEmit("notice-action", {})}></sf-button>`
|
|
225
|
+
: nothing}
|
|
226
|
+
</div>`;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// The panel: heading and path, what the host has to say, then the form -- in
|
|
230
|
+
// tabs when there are tabs -- and one ⋯ menu for every list. The fields' own
|
|
231
|
+
// input and change stop at the root: the change the host hears is the element's,
|
|
232
|
+
// sent on the host itself. A press on the path is a level, so its link goes nowhere.
|
|
233
|
+
export function renderMailInspectorTemplate(context) {
|
|
234
|
+
const {component} = context;
|
|
235
|
+
return html`
|
|
236
|
+
<div class=${["sf-mail-inspector", context.rootClass].filter(Boolean).join(" ")} @keydown=${(event) => component.onKeydown(event)}
|
|
237
|
+
@input=${(event) => event.stopPropagation()} @change=${(event) => event.stopPropagation()}>
|
|
238
|
+
${renderHead(context)}
|
|
239
|
+
${renderNotice(context)}
|
|
240
|
+
${keyed(`${context.formKey}\n${context.tabsKey}`, context.tabs.length ? renderTabs(context) : renderForm(context))}
|
|
241
|
+
<span class="sf-mail-inspector-said sr-only" role="status">${context.said}</span>
|
|
242
|
+
<sf-menu-context class="sf-mail-inspector-menu" popup size="1/2" aria-label=${context.words.itemMenu}
|
|
243
|
+
@sf-menu-context-select=${(event) => {
|
|
244
|
+
event.stopPropagation();
|
|
245
|
+
component.onMenuSelect(event.detail);
|
|
246
|
+
}}></sf-menu-context>
|
|
247
|
+
</div>
|
|
248
|
+
`;
|
|
249
|
+
}
|
|
Binary file
|