@teipublisher/pb-components 2.26.1-next.2 → 3.0.0-next-4.1

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.
Files changed (262) hide show
  1. package/.github/workflows/docker-cypress.yml +54 -0
  2. package/.github/workflows/main.yml +6 -4
  3. package/.github/workflows/node.js.yml +56 -21
  4. package/.github/workflows/release.js.yml +19 -17
  5. package/.releaserc.json +1 -1
  6. package/CHANGELOG.md +351 -9
  7. package/Dockerfile +78 -70
  8. package/README.md +112 -4
  9. package/css/components.css +5 -5
  10. package/css/gridjs/mermaid.min.css +1 -1
  11. package/css/leaflet/Control.Geocoder.css +1 -126
  12. package/css/leaflet/images/layers.png +0 -0
  13. package/css/tify/tify.css +6 -5
  14. package/css/tom-select/tom-select.bootstrap4.min.css +1 -1
  15. package/css/tom-select/tom-select.bootstrap5.min.css +1 -1
  16. package/css/tom-select/tom-select.default.min.css +1 -1
  17. package/css/tom-select/tom-select.default.min.css.map +1 -0
  18. package/css/tom-select/tom-select.min.css +1 -1
  19. package/cypress.config.js +84 -0
  20. package/dist/api.html +1 -1
  21. package/dist/css/design-system.css +607 -0
  22. package/dist/demo/bundle-test.html +4 -3
  23. package/dist/demo/components.css +46 -1
  24. package/dist/demo/design-system.html +710 -0
  25. package/dist/demo/dts-client.html +2 -2
  26. package/dist/demo/pb-autocomplete.html +23 -11
  27. package/dist/demo/pb-autocomplete2.html +66 -55
  28. package/dist/demo/pb-autocomplete3.html +17 -8
  29. package/dist/demo/pb-blacklab-highlight.html +28 -11
  30. package/dist/demo/pb-blacklab-results.html +3 -2
  31. package/dist/demo/pb-browse-docs.html +24 -24
  32. package/dist/demo/pb-browse-docs2.html +3 -3
  33. package/dist/demo/pb-clipboard.html +32 -28
  34. package/dist/demo/pb-code-editor.html +6 -6
  35. package/dist/demo/pb-code-highlight.html +63 -63
  36. package/dist/demo/pb-codepen.html +1 -1
  37. package/dist/demo/pb-collapse.html +1 -1
  38. package/dist/demo/pb-collapse2.html +2 -2
  39. package/dist/demo/pb-combo-box.html +135 -130
  40. package/dist/demo/pb-custom-form.html +64 -55
  41. package/dist/demo/pb-dialog.html +12 -6
  42. package/dist/demo/pb-document.html +1 -1
  43. package/dist/demo/pb-download.html +68 -59
  44. package/dist/demo/pb-drawer.html +67 -46
  45. package/dist/demo/pb-drawer2.html +65 -58
  46. package/dist/demo/pb-edit-app.html +2 -2
  47. package/dist/demo/pb-edit-xml.html +1 -1
  48. package/dist/demo/pb-facsimile-2.html +26 -11
  49. package/dist/demo/pb-facsimile-3.html +25 -10
  50. package/dist/demo/pb-facsimile-dedup-test-2.html +48 -0
  51. package/dist/demo/pb-facsimile-dedup-test.html +48 -0
  52. package/dist/demo/pb-facsimile.html +4 -4
  53. package/dist/demo/pb-formula.html +1 -1
  54. package/dist/demo/pb-grid.html +22 -8
  55. package/dist/demo/pb-highlight.html +2 -2
  56. package/dist/demo/pb-i18n-simple.html +1 -0
  57. package/dist/demo/pb-i18n.html +15 -5
  58. package/dist/demo/pb-image-strip-standalone.html +2 -2
  59. package/dist/demo/pb-image-strip-view.html +2 -2
  60. package/dist/demo/pb-leaflet-map.html +3 -3
  61. package/dist/demo/pb-leaflet-map2.html +2 -2
  62. package/dist/demo/pb-leaflet-map3.html +3 -3
  63. package/dist/demo/pb-link.html +1 -1
  64. package/dist/demo/pb-load.html +2 -6
  65. package/dist/demo/pb-login.html +1 -3
  66. package/dist/demo/pb-manage-odds.html +9 -4
  67. package/dist/demo/pb-markdown.html +1 -1
  68. package/dist/demo/pb-media-query.html +2 -2
  69. package/dist/demo/pb-mei.html +2 -2
  70. package/dist/demo/pb-mei2.html +2 -2
  71. package/dist/demo/pb-message.html +2 -3
  72. package/dist/demo/pb-odd-editor.html +54 -52
  73. package/dist/demo/pb-page-header.html +27 -0
  74. package/dist/demo/pb-popover.html +1 -1
  75. package/dist/demo/pb-print-preview.html +2 -2
  76. package/dist/demo/pb-progress.html +4 -4
  77. package/dist/demo/pb-repeat.html +32 -36
  78. package/dist/demo/pb-search.html +16 -5
  79. package/dist/demo/pb-search2.html +4 -4
  80. package/dist/demo/pb-search3.html +3 -3
  81. package/dist/demo/pb-search4.html +3 -3
  82. package/dist/demo/pb-select-feature.html +4 -4
  83. package/dist/demo/pb-select-feature2.html +4 -4
  84. package/dist/demo/pb-select-feature3.html +2 -2
  85. package/dist/demo/pb-select-i18n.html +58 -53
  86. package/dist/demo/pb-select-odd.html +1 -1
  87. package/dist/demo/pb-select.html +190 -75
  88. package/dist/demo/pb-select2.html +91 -37
  89. package/dist/demo/pb-select3.html +109 -41
  90. package/dist/demo/pb-svg.html +1 -1
  91. package/dist/demo/pb-table-grid.html +26 -15
  92. package/dist/demo/pb-tabs.html +15 -7
  93. package/dist/demo/pb-tify.html +7 -7
  94. package/dist/demo/pb-timeline.html +1 -1
  95. package/dist/demo/pb-timeline2.html +1 -1
  96. package/dist/demo/pb-toggle-feature.html +26 -23
  97. package/dist/demo/pb-toggle-feature2.html +4 -4
  98. package/dist/demo/pb-toggle-feature3.html +2 -2
  99. package/dist/demo/pb-toggle-feature4.html +56 -54
  100. package/dist/demo/pb-version.html +2 -2
  101. package/dist/demo/pb-view.html +78 -40
  102. package/dist/demo/pb-view2.html +69 -46
  103. package/dist/demo/pb-view3.html +53 -48
  104. package/dist/demo/pb-view4.html +70 -49
  105. package/dist/demo/pb-zoom.html +2 -2
  106. package/dist/{es-global-bridge-d8ce175d.js → es-global-bridge-D8ZcUcx_.js} +0 -4
  107. package/dist/focus-mixin-VCsFap6b.js +768 -0
  108. package/dist/images/icons.svg +217 -0
  109. package/dist/jinn-codemirror-DETLdm08.js +1 -0
  110. package/dist/lib/openseadragon.min.js +80 -0
  111. package/dist/lib/openseadragon.min.js.map +1 -0
  112. package/dist/pb-code-editor.js +25 -20
  113. package/dist/pb-component-docs.js +414 -3225
  114. package/dist/pb-components-bundle.js +3046 -4402
  115. package/dist/pb-dialog-tklYGWfc.js +121 -0
  116. package/dist/pb-edit-app.js +208 -107
  117. package/dist/pb-elements.json +716 -249
  118. package/dist/pb-facsimile.js +46 -0
  119. package/dist/pb-i18n-C0NDma4h.js +1 -0
  120. package/dist/pb-leaflet-map.js +23 -23
  121. package/dist/pb-mei.js +152 -134
  122. package/dist/pb-mixin-DHoWQheB.js +1 -0
  123. package/dist/pb-odd-editor.js +1671 -1231
  124. package/dist/pb-tify.js +1 -27
  125. package/dist/unsafe-html-D5VGo9Oq.js +1 -0
  126. package/dist/urls-BEONu_g4.js +1 -0
  127. package/eslint.config.mjs +92 -0
  128. package/gh-pages.js +5 -3
  129. package/i18n/common/en.json +6 -0
  130. package/i18n/common/pl.json +2 -2
  131. package/images/icons.svg +217 -0
  132. package/index.html +0 -5
  133. package/lib/leaflet-src.js.map +1 -0
  134. package/lib/leaflet.markercluster-src.js.map +1 -0
  135. package/lib/openseadragon.min.js +6 -6
  136. package/package.json +56 -81
  137. package/pb-elements.json +716 -249
  138. package/rollup.config.mjs +312 -0
  139. package/src/assets/components.css +5 -5
  140. package/src/assets/design-system.css +607 -0
  141. package/src/authority/airtable.js +20 -21
  142. package/src/authority/anton.js +129 -129
  143. package/src/authority/custom.js +70 -27
  144. package/src/authority/geonames.js +38 -32
  145. package/src/authority/gnd.js +50 -42
  146. package/src/authority/kbga.js +136 -134
  147. package/src/authority/metagrid.js +44 -46
  148. package/src/authority/reconciliation.js +66 -68
  149. package/src/authority/registry.js +4 -4
  150. package/src/docs/demo-utils.js +91 -0
  151. package/src/docs/pb-component-docs.js +287 -147
  152. package/src/docs/pb-component-view.js +380 -273
  153. package/src/docs/pb-components-list.js +115 -51
  154. package/src/docs/pb-demo-snippet.js +199 -174
  155. package/src/dts-client.js +306 -303
  156. package/src/dts-select-endpoint.js +125 -85
  157. package/src/parse-date-service.js +184 -135
  158. package/src/pb-ajax.js +175 -173
  159. package/src/pb-authority-lookup.js +198 -158
  160. package/src/pb-autocomplete.js +731 -313
  161. package/src/pb-blacklab-highlight.js +266 -260
  162. package/src/pb-blacklab-results.js +230 -225
  163. package/src/pb-browse-docs.js +601 -484
  164. package/src/pb-browse.js +68 -65
  165. package/src/pb-clipboard.js +97 -76
  166. package/src/pb-code-editor.js +111 -103
  167. package/src/pb-code-highlight.js +234 -204
  168. package/src/pb-codepen.js +81 -73
  169. package/src/pb-collapse.js +265 -152
  170. package/src/pb-combo-box.js +191 -191
  171. package/src/pb-components-bundle.js +1 -7
  172. package/src/pb-components.js +2 -6
  173. package/src/pb-custom-form.js +230 -141
  174. package/src/pb-dialog.js +99 -63
  175. package/src/pb-document.js +118 -91
  176. package/src/pb-download.js +214 -198
  177. package/src/pb-drawer.js +146 -149
  178. package/src/pb-edit-app.js +471 -240
  179. package/src/pb-edit-xml.js +101 -98
  180. package/src/pb-events.js +126 -107
  181. package/src/pb-facs-link.js +130 -101
  182. package/src/pb-facsimile.js +494 -410
  183. package/src/pb-fetch.js +389 -0
  184. package/src/pb-formula.js +152 -154
  185. package/src/pb-geolocation.js +130 -132
  186. package/src/pb-grid-action.js +59 -56
  187. package/src/pb-grid.js +388 -228
  188. package/src/pb-highlight.js +142 -142
  189. package/src/pb-hotkeys.js +40 -42
  190. package/src/pb-i18n.js +115 -127
  191. package/src/pb-icon-button.js +108 -0
  192. package/src/pb-icon.js +283 -0
  193. package/src/pb-image-strip.js +85 -79
  194. package/src/pb-lang.js +142 -57
  195. package/src/pb-leaflet-map.js +551 -483
  196. package/src/pb-link.js +132 -126
  197. package/src/pb-load.js +495 -428
  198. package/src/pb-login.js +303 -248
  199. package/src/pb-manage-odds.js +384 -338
  200. package/src/pb-map-icon.js +90 -90
  201. package/src/pb-map-layer.js +86 -86
  202. package/src/pb-markdown.js +107 -110
  203. package/src/pb-media-query.js +75 -73
  204. package/src/pb-mei.js +523 -303
  205. package/src/pb-message.js +144 -98
  206. package/src/pb-mixin.js +268 -265
  207. package/src/pb-navigation.js +83 -96
  208. package/src/pb-observable.js +39 -39
  209. package/src/pb-odd-editor.js +1209 -948
  210. package/src/pb-odd-elementspec-editor.js +375 -310
  211. package/src/pb-odd-model-editor.js +1189 -941
  212. package/src/pb-odd-parameter-editor.js +269 -170
  213. package/src/pb-odd-rendition-editor.js +184 -131
  214. package/src/pb-page.js +451 -422
  215. package/src/pb-paginate.js +260 -178
  216. package/src/pb-panel.js +217 -183
  217. package/src/pb-popover-themes.js +16 -9
  218. package/src/pb-popover.js +297 -288
  219. package/src/pb-print-preview.js +128 -128
  220. package/src/pb-progress.js +52 -52
  221. package/src/pb-repeat.js +141 -108
  222. package/src/pb-restricted.js +85 -78
  223. package/src/pb-search.js +258 -230
  224. package/src/pb-select-feature.js +210 -126
  225. package/src/pb-select-odd.js +184 -118
  226. package/src/pb-select-template.js +113 -78
  227. package/src/pb-select.js +330 -229
  228. package/src/pb-split-list.js +181 -176
  229. package/src/pb-svg.js +81 -80
  230. package/src/pb-table-column.js +55 -55
  231. package/src/pb-table-grid.js +334 -205
  232. package/src/pb-tabs.js +238 -61
  233. package/src/pb-tify.js +3331 -126
  234. package/src/pb-timeline.js +394 -255
  235. package/src/pb-toggle-feature.js +196 -188
  236. package/src/pb-upload.js +201 -176
  237. package/src/pb-version.js +22 -34
  238. package/src/pb-view-annotate.js +138 -102
  239. package/src/pb-view.js +1722 -1272
  240. package/src/pb-zoom.js +144 -46
  241. package/src/search-result-service.js +256 -223
  242. package/src/seed-element.js +14 -22
  243. package/src/settings.js +4 -4
  244. package/src/theming.js +98 -91
  245. package/src/urls.js +403 -289
  246. package/src/utils.js +53 -51
  247. package/vite.config.js +86 -0
  248. package/css/pb-styles.css +0 -51
  249. package/dist/iron-form-3b8dcaa7.js +0 -210
  250. package/dist/jinn-codemirror-da0e2d1f.js +0 -1
  251. package/dist/paper-checkbox-515a5284.js +0 -1597
  252. package/dist/paper-icon-button-b1d31571.js +0 -398
  253. package/dist/paper-listbox-a3b7175c.js +0 -1265
  254. package/dist/pb-i18n-0611135a.js +0 -1
  255. package/dist/pb-mixin-b1caa22e.js +0 -158
  256. package/dist/polymer-hack.js +0 -1
  257. package/dist/vaadin-element-mixin-6e4cee3a.js +0 -527
  258. package/lib/Control.Geocoder.min.js +0 -2
  259. package/lib/Control.Geocoder.min.js.map +0 -1
  260. package/src/assets/pb-styles.css +0 -51
  261. package/src/pb-light-dom.js +0 -40
  262. package/src/polymer-hack.js +0 -6
@@ -1,467 +1,524 @@
1
1
  // @ts-nocheck
2
- import { LitElement, html, css } from 'lit-element';
3
-
4
- import { repeat } from 'lit-html/directives/repeat';
5
- import { ifDefined } from 'lit-html/directives/if-defined';
6
-
7
- import '@polymer/paper-icon-button/paper-icon-button.js';
8
- import '@polymer/iron-icons/iron-icons.js';
9
- import '@polymer/iron-icon/iron-icon.js';
10
- import '@polymer/paper-input/paper-input.js';
11
- import '@polymer/paper-menu-button/paper-menu-button.js';
12
- import '@polymer/paper-dropdown-menu/paper-dropdown-menu.js';
13
- import '@polymer/paper-listbox/paper-listbox.js';
14
- import '@polymer/paper-item/paper-item.js';
15
- import '@polymer/paper-styles/color.js';
16
- import '@polymer/iron-collapse/iron-collapse.js';
17
- import "@jinntec/jinn-codemirror/dist/src/jinn-codemirror";
2
+ import { LitElement, html, css, nothing } from 'lit';
3
+
4
+ import { repeat } from 'lit/directives/repeat.js';
5
+ import { ifDefined } from 'lit/directives/if-defined.js';
6
+
7
+ import './pb-icon-button.js';
8
+
9
+ import '@jinntec/jinn-codemirror/dist/src/jinn-codemirror';
18
10
 
19
11
  import { cmpVersion } from './utils.js';
20
12
  import './pb-odd-rendition-editor.js';
21
13
  import './pb-odd-parameter-editor.js';
22
14
  import './pb-message.js';
23
15
 
24
- import { get as i18n, translate } from "./pb-i18n.js";
25
-
16
+ import { get as i18n, translate } from './pb-i18n.js';
26
17
 
27
18
  /**
28
19
  * represents an odd model element for editing
29
20
  *
30
21
  * @customElement
31
- *
32
- * @polymer
33
22
  */
34
23
  export class PbOddModelEditor extends LitElement {
35
-
36
- static get styles() {
37
- return css`
38
- :host {
39
- display: flex;
40
- flex-direction:column;
41
- }
42
- h1, h2, h3, h4, h5, h6 {
43
- font-family: "Oswald", Verdana, "Helvetica", sans-serif;
44
- font-weight: 400 !important;
45
- }
46
-
47
- form {
48
- margin-bottom: 8px;
49
- }
50
-
51
- paper-input, paper-autocomplete {
52
- margin-bottom: 16px;
53
- }
54
-
55
- .models {
56
- margin-left:20px;
57
- margin-top:10px;
58
- }
59
-
60
- .btn, .btn-group {
61
- margin-top: 0;
62
- margin-bottom: 0;
63
- }
64
-
65
- header {
66
- // background-color: #d1dae0;
67
- background:var(--paper-grey-300);
68
- margin:0;
69
- }
70
-
71
- header div {
72
- display: flex;
73
- flex-direction: row;
74
- justify-content: space-between;
75
- align-items: center;
76
- }
77
-
78
- header h4 {
79
- padding: 4px 8px;
80
- margin: 0;
81
- display: grid;
82
- grid-template-columns: 40px 40% auto;
83
- }
84
- h4 .btn-group{
85
- text-align: right;
86
- display: none;
87
- }
88
-
89
- #toggle, .modelType{
90
- align-self:center;
91
- }
92
-
93
- header div.info {
94
- padding: 0 16px 4px;
95
- margin: 0;
96
- font-size: 85%;
97
- display: block;
98
- margin:0 0 0 32px;
99
- }
100
- header div.info *{
101
- display: block;
102
- line-height: 1.2;
103
- }
104
-
105
- header .outputDisplay{
106
- text-transform: uppercase ;
107
- }
108
- header .description{
109
- font-style: italic;
110
- }
111
-
112
- header .predicate {
113
- color: #ff5722;
114
- }
115
-
116
- .predicate label, .template label {
117
- display: block;
118
- font-size: 12px;
119
- font-weight: 300;
120
- color: rgb(115, 115, 115);
121
- }
122
-
123
- .model-collapse {
124
- color: #000000;
125
- cursor: pointer;
126
- }
127
-
128
- .model-collapse:hover {
129
- text-decoration: none;
130
- }
131
-
132
- .behaviour {
133
- color: #ff5722;
134
- }
135
-
136
- .behaviour:before {
137
- content: ' [';
138
- }
139
-
140
- .behaviour:after {
141
- content: ']';
142
- }
143
-
144
- .behaviourWrapper{
145
- display:grid;
146
- grid-template-columns: 140px 40px 140px auto;
147
- }
148
- .behaviourWrapper > *{
149
- display:inline;
150
- align-self:stretch;
151
- }
152
-
153
- .group {
154
- margin: 0;
155
- font-size: 16px;
156
- font-weight: bold;
157
- }
158
-
159
- .group .title {
160
- /*text-decoration: underline;*/
161
- }
162
-
163
- .renditions, .parameters {
164
- padding-left: 16px;
165
- border-left: 3px solid #e0e0e0;
166
- margin-bottom:20px;
167
- }
168
-
169
- .renditions .group {
170
- display: flex;
171
- flex-direction: row;
172
- justify-content: space-between;
173
- align-items: center;
174
- }
175
-
176
- .predicate .form-control {
177
- width: 100%;
178
- }
179
-
180
- .source {
181
- text-decoration: none;
182
- margin-bottom: 8px;
183
- }
184
-
185
- .selectOutput {
186
- margin-right: 10px;
187
- }
188
-
189
- :host([currentselection]) > form > header{
190
- @apply --shadow-elevation-4dp;
191
- border-left:3px solid var(--paper-blue-500);
192
- }
193
-
194
- paper-menu-button paper-icon-button{
195
- margin-left:-10px;
196
- }
197
-
198
- /* need to play it save for FF */
199
- :host([currentselection]) > form > header > h4 > .btn-group{
200
- display: inline-block;
201
- }
202
- iron-collapse{
203
- }
204
-
205
- .renditions{
206
- margin-top:10px;
207
- }
208
-
209
- .details{
210
- padding:0px 50px 20px 20px;
211
- background:var(--paper-grey-200);
212
- }
213
-
214
- .editor {
215
- margin-bottom: 20px;
216
- }
217
-
218
- .editor label {
219
- margin-bottom:5px;
220
- font-size: 12px;
221
- font-weight: 400;
222
- color: var(--paper-grey-500);
223
- }
224
-
225
- .horizontal {
226
- display: flex;
227
- flex-wrap: wrap;
228
- justify-content: space-between;
229
- }
230
-
231
- #mode {
232
- min-width: 18em;
233
- }
234
- `;
24
+ static get styles() {
25
+ return css`
26
+ :host {
27
+ display: flex;
28
+ flex-direction: column;
29
+ }
30
+ h1,
31
+ h2,
32
+ h3,
33
+ h4,
34
+ h5,
35
+ h6 {
36
+ font-family: 'Oswald', Verdana, 'Helvetica', sans-serif;
37
+ font-weight: 400 !important;
38
+ }
39
+
40
+ form {
41
+ margin-bottom: 8px;
42
+ }
43
+
44
+ .pb-input,
45
+ .pb-select,
46
+ pb-autocomplete {
47
+ margin-bottom: 16px;
48
+ }
49
+
50
+ .models {
51
+ margin-left: 20px;
52
+ margin-top: 10px;
53
+ }
54
+
55
+ .btn,
56
+ .btn-group {
57
+ margin-top: 0;
58
+ margin-bottom: 0;
59
+ }
60
+
61
+ header {
62
+ // background-color: #d1dae0;
63
+ background: var(--paper-grey-300);
64
+ margin: 0;
65
+ }
66
+
67
+ header div {
68
+ display: flex;
69
+ flex-direction: row;
70
+ justify-content: space-between;
71
+ align-items: center;
72
+ }
73
+
74
+ header h4 {
75
+ padding: 4px 8px;
76
+ margin: 0;
77
+ display: grid;
78
+ grid-template-columns: 40px 40% auto;
79
+ }
80
+ h4 .btn-group {
81
+ text-align: right;
82
+ display: none;
83
+ }
84
+
85
+ #toggle,
86
+ .modelType {
87
+ align-self: center;
88
+ }
89
+
90
+ header div.info {
91
+ padding: 0 16px 4px;
92
+ margin: 0;
93
+ font-size: 85%;
94
+ display: block;
95
+ margin: 0 0 0 32px;
96
+ }
97
+ header div.info * {
98
+ display: block;
99
+ line-height: 1.2;
100
+ }
101
+
102
+ header .outputDisplay {
103
+ text-transform: uppercase;
104
+ }
105
+ header .description {
106
+ font-style: italic;
107
+ }
108
+
109
+ header .predicate {
110
+ color: #ff5722;
111
+ }
112
+
113
+ .predicate label,
114
+ .template label {
115
+ display: block;
116
+ font-size: 12px;
117
+ font-weight: 300;
118
+ color: rgb(115, 115, 115);
119
+ }
120
+
121
+ .model-collapse {
122
+ color: #000000;
123
+ cursor: pointer;
124
+ }
125
+
126
+ .model-collapse:hover {
127
+ text-decoration: none;
128
+ }
129
+
130
+ .behaviour {
131
+ color: #ff5722;
132
+ }
133
+
134
+ .behaviour:before {
135
+ content: ' [';
136
+ }
137
+
138
+ .behaviour:after {
139
+ content: ']';
140
+ }
141
+
142
+ .behaviourWrapper {
143
+ display: grid;
144
+ grid-template-columns: 140px 40px 140px auto;
145
+ }
146
+ .behaviourWrapper > * {
147
+ display: inline;
148
+ align-self: stretch;
149
+ }
150
+
151
+ .group {
152
+ margin: 0;
153
+ font-size: 16px;
154
+ font-weight: bold;
155
+ }
156
+
157
+ .group .title {
158
+ /*text-decoration: underline;*/
159
+ }
160
+
161
+ .renditions,
162
+ .parameters {
163
+ padding-left: 16px;
164
+ border-left: 3px solid #e0e0e0;
165
+ margin-bottom: 20px;
166
+ }
167
+
168
+ .renditions .group {
169
+ display: flex;
170
+ flex-direction: row;
171
+ justify-content: space-between;
172
+ align-items: center;
173
+ }
174
+
175
+ .predicate .form-control {
176
+ width: 100%;
177
+ }
178
+
179
+ .source {
180
+ text-decoration: none;
181
+ margin-bottom: 8px;
182
+ }
183
+
184
+ .selectOutput {
185
+ margin-right: 10px;
186
+ }
187
+
188
+ :host([currentselection]) > form > header {
189
+ @apply --shadow-elevation-4dp;
190
+ border-left: 3px solid var(--paper-blue-500);
191
+ }
192
+
193
+ .modelTypeMenu {
194
+ margin-left: 8px;
195
+ display: inline-flex;
196
+ align-items: center;
197
+ }
198
+
199
+ .sr-only {
200
+ position: absolute;
201
+ width: 1px;
202
+ height: 1px;
203
+ padding: 0;
204
+ margin: -1px;
205
+ overflow: hidden;
206
+ clip: rect(0, 0, 0, 0);
207
+ border: 0;
208
+ }
209
+
210
+ .pb-input,
211
+ .pb-select {
212
+ width: 100%;
213
+ height: var(--pb-input-height, 48px);
214
+ padding: 0.5rem 0.75rem;
215
+ border: 1px solid rgba(0, 0, 0, 0.16);
216
+ border-radius: 8px;
217
+ font: inherit;
218
+ color: inherit;
219
+ background: #fff;
220
+ transition: border-color 120ms ease, box-shadow 120ms ease;
221
+ }
222
+
223
+ .pb-input::placeholder {
224
+ color: rgba(0, 0, 0, 0.4);
225
+ }
226
+
227
+ .pb-select {
228
+ appearance: none;
229
+ background-image: linear-gradient(45deg, transparent 50%, rgba(0, 0, 0, 0.4) 50%),
230
+ linear-gradient(135deg, rgba(0, 0, 0, 0.4) 50%, transparent 50%),
231
+ linear-gradient(to right, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1));
232
+ background-position: calc(100% - 18px) calc(0.6em + 2px),
233
+ calc(100% - 13px) calc(0.6em + 2px), calc(100% - 2.5rem) 0.5em;
234
+ background-size: 5px 5px, 5px 5px, 1px 2.25em;
235
+ background-repeat: no-repeat;
236
+ }
237
+
238
+ .pb-input:focus,
239
+ .pb-select:focus {
240
+ outline: none;
241
+ border-color: #1976d2;
242
+ box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.16);
243
+ }
244
+
245
+ /* need to play it save for FF */
246
+ :host([currentselection]) > form > header > h4 > .btn-group {
247
+ display: inline-block;
248
+ }
249
+ details {
250
+ display: block;
251
+ }
252
+
253
+ details summary {
254
+ display: none;
255
+ }
256
+
257
+ .renditions {
258
+ margin-top: 10px;
259
+ }
260
+
261
+ .details {
262
+ padding: 0px 50px 20px 20px;
263
+ background: var(--paper-grey-200);
264
+ }
265
+
266
+ details:not([open]) {
267
+ padding: 0;
268
+ }
269
+
270
+ .editor label {
271
+ margin-bottom: 5px;
272
+ font-size: 12px;
273
+ font-weight: 400;
274
+ color: var(--paper-grey-500);
275
+ }
276
+
277
+ .horizontal {
278
+ display: flex;
279
+ flex-wrap: wrap;
280
+ justify-content: space-between;
281
+ }
282
+
283
+ #mode {
284
+ min-width: 18em;
285
+ }
286
+ `;
287
+ }
288
+
289
+ static get properties() {
290
+ return {
291
+ /**
292
+ * maps to ODD ´model` behaviour attribute
293
+ */
294
+ behaviour: {
295
+ type: String,
296
+ },
297
+ /**
298
+ * maps to ODD `model` predicate
299
+ */
300
+ predicate: {
301
+ type: String,
302
+ reflect: true,
303
+ converter: (value, type) => {
304
+ if (value.toLowerCase() === 'null') {
305
+ return '';
306
+ }
307
+ return value;
308
+ },
309
+ },
310
+ type: {
311
+ type: String,
312
+ reflect: true,
313
+ },
314
+ template: {
315
+ type: String,
316
+ reflect: true,
317
+ converter: (value, type) => {
318
+ if (value.toLowerCase() === 'null') {
319
+ return '';
320
+ }
321
+ return value;
322
+ },
323
+ },
324
+ output: {
325
+ type: String,
326
+ reflect: true,
327
+ converter: (value, type) => {
328
+ if (value.toLowerCase() === 'null') {
329
+ return '';
330
+ }
331
+ return value;
332
+ },
333
+ },
334
+ css: {
335
+ type: String,
336
+ converter: (value, type) => {
337
+ if (value.toLowerCase() === 'null') {
338
+ return '';
339
+ }
340
+ return value;
341
+ },
342
+ },
343
+ mode: {
344
+ type: String,
345
+ },
346
+ model: {
347
+ type: Object,
348
+ },
349
+ models: {
350
+ type: Array,
351
+ },
352
+ parameters: {
353
+ type: Array,
354
+ },
355
+ renditions: {
356
+ type: Array,
357
+ },
358
+ desc: {
359
+ type: String,
360
+ converter: (value, type) => {
361
+ if (value.toLowerCase() === 'null') {
362
+ return '';
363
+ }
364
+ return value;
365
+ },
366
+ },
367
+ sourcerend: {
368
+ type: String,
369
+ },
370
+ show: {
371
+ type: Boolean,
372
+ reflect: true,
373
+ },
374
+ outputs: {
375
+ type: Array,
376
+ },
377
+ behaviours: {
378
+ type: Array,
379
+ },
380
+ icon: {
381
+ type: String,
382
+ },
383
+ open: {
384
+ type: String,
385
+ },
386
+ hasCustomBehaviour: {
387
+ type: Boolean,
388
+ },
389
+ endpoint: {
390
+ type: String,
391
+ },
392
+ apiVersion: {
393
+ type: String,
394
+ },
395
+ };
396
+ }
397
+
398
+ constructor() {
399
+ super();
400
+ this.behaviour = 'inline';
401
+ this.predicate = '';
402
+ this.type = '';
403
+ this.template = '';
404
+ this.output = '';
405
+ this.css = '';
406
+ this.mode = '';
407
+ this.model = {};
408
+ this.model.models = [];
409
+ this.parameters = [];
410
+ this.renditions = [];
411
+ this.desc = '';
412
+ this.sourcerend = '';
413
+ this.show = false;
414
+
415
+ this.outputs = ['', 'web', 'print', 'epub', 'fo', 'latex', 'plain'];
416
+
417
+ this.parentModel = [];
418
+ this.behaviours = [
419
+ 'alternate',
420
+ 'anchor',
421
+ 'block',
422
+ 'body',
423
+ 'break',
424
+ 'cell',
425
+ 'cit',
426
+ 'document',
427
+ 'figure',
428
+ 'graphic',
429
+ 'heading',
430
+ 'inline',
431
+ 'link',
432
+ 'list',
433
+ 'listItem',
434
+ 'metadata',
435
+ 'note',
436
+ 'omit',
437
+ 'paragraph',
438
+ 'pass-through',
439
+ 'row',
440
+ 'section',
441
+ 'table',
442
+ 'text',
443
+ 'title',
444
+ 'webcomponent',
445
+ ];
446
+
447
+ this.icon = 'expand-more';
448
+ this.hasCustomBehaviour = false;
449
+ }
450
+
451
+ render() {
452
+ let tmplSyntax;
453
+ switch (this.output) {
454
+ case 'web':
455
+ case 'epub':
456
+ tmplSyntax = 'html';
457
+ break;
458
+ case 'latex':
459
+ tmplSyntax = 'tex';
460
+ break;
461
+ case 'plain':
462
+ tmplSyntax = 'default';
463
+ break;
464
+ case 'fo':
465
+ case 'print':
466
+ tmplSyntax = 'xml';
467
+ break;
468
+ default:
469
+ tmplSyntax = 'html';
470
+ break;
235
471
  }
236
-
237
- static get properties() {
238
- return {
239
- /**
240
- * maps to ODD ´model` behaviour attribute
241
- */
242
- behaviour: {
243
- type: String
244
- },
245
- /**
246
- * maps to ODD `model` predicate
247
- */
248
- predicate: {
249
- type: String,
250
- reflect: true,
251
- converter: (value, type) => {
252
- if (value.toLowerCase() === 'null') {
253
- return '';
254
- }
255
- return value;
256
- }
257
- },
258
- type: {
259
- type: String,
260
- reflect: true
261
- },
262
- template: {
263
- type: String,
264
- reflect: true,
265
- converter: (value, type) => {
266
- if (value.toLowerCase() === 'null') {
267
- return '';
268
- }
269
- return value;
270
- }
271
- },
272
- output: {
273
- type: String,
274
- reflect: true,
275
- converter: (value, type) => {
276
- if (value.toLowerCase() === 'null') {
277
- return '';
278
- }
279
- return value;
280
- }
281
- },
282
- css: {
283
- type: String,
284
- converter: (value, type) => {
285
- if (value.toLowerCase() === 'null') {
286
- return '';
287
- }
288
- return value;
289
- }
290
- },
291
- mode: {
292
- type: String
293
- },
294
- model: {
295
- type: Object
296
- },
297
- models: {
298
- type: Array
299
- },
300
- parameters: {
301
- type: Array
302
- },
303
- renditions: {
304
- type: Array
305
- },
306
- desc: {
307
- type: String,
308
- converter: (value, type) => {
309
- if (value.toLowerCase() === 'null') {
310
- return '';
311
- }
312
- return value;
313
- }
314
- },
315
- sourcerend: {
316
- type: String
317
- },
318
- show: {
319
- type: Boolean,
320
- reflect: true
321
- },
322
- outputs: {
323
- type: Array
324
- },
325
- behaviours: {
326
- type: Array
327
- },
328
- icon: {
329
- type: String
330
- },
331
- open: {
332
- type: String
333
- },
334
- hasCustomBehaviour: {
335
- type: Boolean
336
- },
337
- endpoint: {
338
- type: String
339
- },
340
- apiVersion: {
341
- type: String
342
- }
343
- };
344
- }
345
-
346
- constructor() {
347
- super();
348
- this.behaviour = 'inline';
349
- this.predicate = '';
350
- this.type = '';
351
- this.template = '';
352
- this.output = '';
353
- this.css = '';
354
- this.mode = '';
355
- this.model = {};
356
- this.model.models = [];
357
- this.parameters = [];
358
- this.renditions = [];
359
- this.desc = '';
360
- this.sourcerend = '';
361
- this.show = false;
362
-
363
- this.outputs = ["",
364
- "web",
365
- "print",
366
- "epub",
367
- "fo",
368
- "latex",
369
- "plain"];
370
-
371
- this.parentModel = [];
372
- this.behaviours = [
373
- "alternate",
374
- "anchor",
375
- "block",
376
- "body",
377
- "break",
378
- "cell",
379
- "cit",
380
- "document",
381
- "figure",
382
- "graphic",
383
- "heading",
384
- "inline",
385
- "link",
386
- "list",
387
- "listItem",
388
- "metadata",
389
- "note",
390
- "omit",
391
- "paragraph",
392
- "pass-through",
393
- "row",
394
- "section",
395
- "table",
396
- "text",
397
- "title",
398
- "webcomponent"
399
- ];
400
-
401
- this.icon = 'expand-more';
402
- this.hasCustomBehaviour = false;
403
- }
404
-
405
- render() {
406
- let tmplSyntax;
407
- switch (this.output) {
408
- case 'web':
409
- case 'epub':
410
- tmplSyntax = 'html';
411
- break;
412
- case 'latex':
413
- tmplSyntax = 'tex';
414
- break;
415
- case 'plain':
416
- tmplSyntax = 'default';
417
- break;
418
- case 'fo':
419
- case 'print':
420
- tmplSyntax = 'xml';
421
- break;
422
- default:
423
- tmplSyntax = 'html';
424
- break;
425
- }
426
- return html`
472
+ return html`
427
473
  <form>
428
- <header>
474
+ <header>
429
475
  <h4>
430
- <paper-icon-button id="toggle"
476
+ <pb-icon-button id="toggle"
431
477
  icon="${this.icon}" @click="${this.toggle}"
432
- class="model-collapse"></paper-icon-button>
433
-
434
- <span class="modelType">${this.type}<span class="behaviour" ?hidden="${this._isGroupOrSequence()}">${this.behaviour}</span></span>
478
+ class="model-collapse"></pb-icon-button>
479
+
480
+ <span class="modelType">${
481
+ this.type
482
+ }<span class="behaviour" ?hidden="${this._isGroupOrSequence()}">${
483
+ this.behaviour
484
+ }</span></span>
435
485
 
436
486
  <span class="btn-group">
437
- <paper-icon-button @click="${this._moveDown}" icon="arrow-downward"
438
- title="move down"></paper-icon-button>
439
- <paper-icon-button @click="${this._moveUp}" icon="arrow-upward"
440
- title="move up"></paper-icon-button>
441
- <paper-icon-button @click="${this._requestRemoval}" icon="delete" title="remove"></paper-icon-button>
442
- <paper-icon-button @click="${this._copy}" icon="content-copy" title="copy"></paper-icon-button>
443
- <paper-icon-button @click="${this._paste}" icon="content-paste"></paper-icon-button>
444
-
445
- ${this._isGroupOrSequence() ?
446
- html`
447
- <paper-menu-button horizontal-align="right">
448
- <paper-icon-button icon="add" slot="dropdown-trigger"></paper-icon-button>
449
- <paper-listbox id="modelType" slot="dropdown-content" @iron-select="${this._addNested}"
450
- attr-for-selected="value">
451
- ${this.type === 'modelSequence' ?
452
- html`
453
- <paper-item value="model">model</paper-item>
454
- `: ''
455
- }
456
- ${this.type === 'modelGrp' ?
457
- html`
458
- <paper-item value="modelSequence">modelSequence</paper-item>
459
- <paper-item value="model">model</paper-item>
460
- `: ''
461
- }
462
- </paper-listbox>
463
- </paper-menu-button>
464
- `: ''}
487
+ <pb-icon-button @click="${this._moveDown}" icon="arrow-downward"
488
+ title="move down"></pb-icon-button>
489
+ <pb-icon-button @click="${this._moveUp}" icon="arrow-upward"
490
+ title="move up"></pb-icon-button>
491
+ <pb-icon-button @click="${
492
+ this._requestRemoval
493
+ }" icon="delete" title="remove"></pb-icon-button>
494
+ <pb-icon-button @click="${
495
+ this._copy
496
+ }" icon="content-copy" title="copy"></pb-icon-button>
497
+ <pb-icon-button @click="${
498
+ this._paste
499
+ }" icon="content-paste"></pb-icon-button>
500
+
501
+ ${
502
+ this._isGroupOrSequence()
503
+ ? html`
504
+ <label class="modelTypeMenu">
505
+ <span class="sr-only">Add nested model</span>
506
+ <select class="pb-select" @change=${this._handleAddNested}>
507
+ <option value="">Add…</option>
508
+ ${this.type === 'modelSequence'
509
+ ? html`<option value="model">model</option>`
510
+ : nothing}
511
+ ${this.type === 'modelGrp'
512
+ ? html`
513
+ <option value="modelSequence">modelSequence</option>
514
+ <option value="model">model</option>
515
+ `
516
+ : nothing}
517
+ </select>
518
+ </label>
519
+ `
520
+ : nothing
521
+ }
465
522
  </span>
466
523
  </h4>
467
524
  <div class="info">
@@ -470,548 +527,739 @@ export class PbOddModelEditor extends LitElement {
470
527
  <div class="predicate">${this.predicate}</div>
471
528
  </p>
472
529
  </header>
473
- <iron-collapse id="details" ?opened="${this.show}" class="details">
530
+ <details ?open="${this.show}" class="details">
531
+ <summary style="display: none;"></summary>
474
532
  <div class="horizontal">
475
- <paper-dropdown-menu class="selectOutput" label="Output">
476
- <paper-listbox id="output" slot="dropdown-content" attr-for-selected="value"
477
- selected="${this.output}" @iron-select="${this._selectOutput}">
478
-
479
- ${this.outputs.map((item) =>
480
- html`
481
- <paper-item value="${item}">${item}</paper-item>
482
- `)}
483
-
484
- </paper-listbox>
485
- </paper-dropdown-menu>
486
- <paper-input id="mode" .value="${this.mode}"
533
+ <label class="pb-field selectOutput">
534
+ <span class="pb-field__label">${translate('odd.editor.model.output')}</span>
535
+ <select
536
+ id="output"
537
+ class="pb-select"
538
+ .value=${this.output || ''}
539
+ @change=${this._selectOutput}
540
+ >
541
+ ${this.outputs.map(item => html`<option value="${item}">${item}</option>`)}
542
+ </select>
543
+ </label>
544
+ <label class="pb-field">
545
+ <span class="pb-field__label">${translate(
546
+ 'odd.editor.model.mode-placeholder',
547
+ )}</span>
548
+ <input
549
+ id="mode"
550
+ class="pb-input"
551
+ .value=${this.mode || ''}
487
552
  placeholder="${translate('odd.editor.model.mode-placeholder')}"
488
- label="Mode"
489
- @change="${this._inputMode}"></paper-input>
553
+ @change=${this._inputMode}
554
+ />
555
+ </label>
490
556
  </div>
491
- <paper-input id="desc" .value="${this.desc}" placeholder="${translate('odd.editor.model.description-placeholder')}"
492
- label="Description" @change="${this._inputDesc}"></paper-input>
557
+ <label class="pb-field">
558
+ <span class="pb-field__label">${translate(
559
+ 'odd.editor.model.description-placeholder',
560
+ )}</span>
561
+ <input
562
+ id="desc"
563
+ class="pb-input"
564
+ .value=${this.desc || ''}
565
+ placeholder="${translate('odd.editor.model.description-placeholder')}"
566
+ @change=${this._inputDesc}
567
+ />
568
+ </label>
493
569
 
494
570
  <div class="editor">
495
571
  <label>Predicate</label>
496
572
  <jinn-codemirror id="predicate"
497
- code="${this.predicate}"
573
+ code="${this.predicate}"
498
574
  mode="xquery"
499
- linter="${this.endpoint}/${cmpVersion(this.apiVersion, '1.0.0') < 0 ? 'modules/editor.xql' : 'api/lint'}"
575
+ linter="${this.endpoint}/${
576
+ cmpVersion(this.apiVersion, '1.0.0') < 0 ? 'modules/editor.xql' : 'api/lint'
577
+ }"
500
578
  placeholder="${translate('odd.editor.model.predicate-placeholder')}"
501
579
  @update="${this._updatePredicate}"></jinn-codemirror>
502
580
  </div>
503
-
504
- ${this._isModel()
505
- ? html`
506
- <div>
507
- <div class="behaviourWrapper">
508
- <paper-dropdown-menu label="behaviour" id="behaviourMenu" ?disabled="${this.hasCustomBehaviour}">
509
- <paper-listbox id="behaviour" slot="dropdown-content" attr-for-selected="value"
510
- selected="${this.behaviour}" @iron-select="${this._selectBehaviour}">
511
- ${this.behaviours.map((item) =>
512
- html`
513
- <paper-item value="${item}">${item}</paper-item>
514
- `)}
515
- </paper-listbox>
516
- </paper-dropdown-menu>
517
- <span style="align-self:center;justify-self: center;"> ${translate('odd.editor.model.link-with-or')} </span>
518
- <paper-input id="custombehaviour" label="" @input="${this._handleCustomBehaviour}" placeHolder="${translate('odd.editor.model.custom-behaviour-placeholder')}"></paper-input>
519
- <span></span>
520
- </div>
521
581
 
522
-
523
-
524
- <paper-input id="css" .value="${this.css}"
525
- placeholder="${translate('odd.editor.model.css-class-placeholder')}"
526
- label="CSS Class"
527
- @change="${this._inputCss}"></paper-input>
528
-
529
- <div class="editor">
530
- <label>Template</label>
531
- <jinn-codemirror id="template"
532
- code="${this.template}"
533
- mode="${tmplSyntax}"
534
- placeholder="${translate('odd.editor.model.template-placeholder')}"
535
- @update="${this._updateTemplate}">
536
- <div slot="toolbar">
537
- <paper-button data-mode="xml" data-command="selectElement" data-key="mod-e mod-s"
538
- title="Select element around current cursor position">&lt;|></paper-button>
539
- <paper-button data-mode="xml" data-command="encloseWith" data-key="mod-e mod-e"
540
- title="Enclose selection in new element">&lt;...&gt;</paper-button>
541
- <paper-button data-mode="xml" data-command="removeEnclosing" title="Remove enclosing tags"
542
- data-key="mod-e mod-r" class="sep">&lt;X></paper-button>
543
- <paper-button data-mode="html" data-command="selectElement" data-key="mod-e mod-s"
544
- title="Select element around current cursor position">&lt;|></paper-button>
545
- <paper-button data-mode="html" data-command="encloseWith" data-key="mod-e mod-e"
546
- title="Enclose selection in new element">&lt;...&gt;</paper-button>
547
- <paper-button data-mode="html" data-command="removeEnclosing" title="Remove enclosing tags"
548
- data-key="mod-e mod-r" class="sep">&lt;X></paper-button>
549
- <paper-button data-key="mod-e mod-p" data-command="snippet" data-params="[[\${_}]]" title="Insert template variable">[[...]]</paper-button>
550
- </div>
551
- </jinn-codemirror>
552
- </div>
582
+ ${
583
+ this._isModel()
584
+ ? html`
585
+ <div>
586
+ <div class="behaviourWrapper">
587
+ <label class="pb-field">
588
+ <span class="pb-field__label"
589
+ >${translate('odd.editor.model.behaviour')}</span
590
+ >
591
+ <select
592
+ id="behaviour"
593
+ class="pb-select"
594
+ .value=${this.behaviour || ''}
595
+ ?disabled=${this.hasCustomBehaviour}
596
+ @change=${this._selectBehaviour}
597
+ >
598
+ ${this.behaviours.map(
599
+ item => html`<option value="${item}">${item}</option>`,
600
+ )}
601
+ </select>
602
+ </label>
603
+ <span style="align-self:center;justify-self: center;">
604
+ ${translate('odd.editor.model.link-with-or')}
605
+ </span>
606
+ <label class="pb-field">
607
+ <span class="pb-field__label"
608
+ >${translate('odd.editor.model.custom-behaviour-placeholder')}</span
609
+ >
610
+ <input
611
+ id="custombehaviour"
612
+ class="pb-input"
613
+ @input=${this._handleCustomBehaviour}
614
+ placeholder="${translate(
615
+ 'odd.editor.model.custom-behaviour-placeholder',
616
+ )}"
617
+ />
618
+ </label>
619
+ <span></span>
620
+ </div>
621
+
622
+ <label class="pb-field">
623
+ <span class="pb-field__label">CSS Class</span>
624
+ <input
625
+ id="css"
626
+ class="pb-input"
627
+ .value=${this.css || ''}
628
+ placeholder="${translate('odd.editor.model.css-class-placeholder')}"
629
+ @change=${this._inputCss}
630
+ />
631
+ </label>
632
+
633
+ <div class="editor">
634
+ <label>Template</label>
635
+ <jinn-codemirror
636
+ id="template"
637
+ code="${this.template}"
638
+ mode="${tmplSyntax}"
639
+ placeholder="${translate('odd.editor.model.template-placeholder')}"
640
+ @update="${this._updateTemplate}"
641
+ >
642
+ <div slot="toolbar">
643
+ <button
644
+ type="button"
645
+ class="pb-button pb-button--text"
646
+ data-mode="xml"
647
+ data-command="selectElement"
648
+ data-key="mod-e mod-s"
649
+ title="Select element around current cursor position"
650
+ >
651
+ &lt;|>
652
+ </button>
653
+ <button
654
+ type="button"
655
+ class="pb-button pb-button--text"
656
+ data-mode="xml"
657
+ data-command="encloseWith"
658
+ data-key="mod-e mod-e"
659
+ title="Enclose selection in new element"
660
+ >
661
+ &lt;...&gt;
662
+ </button>
663
+ <button
664
+ type="button"
665
+ class="pb-button pb-button--text sep"
666
+ data-mode="xml"
667
+ data-command="removeEnclosing"
668
+ title="Remove enclosing tags"
669
+ data-key="mod-e mod-r"
670
+ >
671
+ &lt;X>
672
+ </button>
673
+ <button
674
+ type="button"
675
+ class="pb-button pb-button--text"
676
+ data-mode="html"
677
+ data-command="selectElement"
678
+ data-key="mod-e mod-s"
679
+ title="Select element around current cursor position"
680
+ >
681
+ &lt;|>
682
+ </button>
683
+ <button
684
+ type="button"
685
+ class="pb-button pb-button--text"
686
+ data-mode="html"
687
+ data-command="encloseWith"
688
+ data-key="mod-e mod-e"
689
+ title="Enclose selection in new element"
690
+ >
691
+ &lt;...&gt;
692
+ </button>
693
+ <button
694
+ type="button"
695
+ class="pb-button pb-button--text sep"
696
+ data-mode="html"
697
+ data-command="removeEnclosing"
698
+ title="Remove enclosing tags"
699
+ data-key="mod-e mod-r"
700
+ >
701
+ &lt;X>
702
+ </button>
703
+ <button
704
+ type="button"
705
+ class="pb-button pb-button--text"
706
+ data-key="mod-e mod-p"
707
+ data-command="snippet"
708
+ data-params="[[\${_}]]"
709
+ title="Insert template variable"
710
+ >
711
+ [[...]]
712
+ </button>
713
+ </div>
714
+ </jinn-codemirror>
715
+ </div>
553
716
  </div>
554
-
717
+
555
718
  <div class="parameters">
556
- <div class="group">
557
- <span class="title">Parameters</span>
558
- <paper-icon-button icon="add"
559
- @click="${this._addParameter}"></paper-icon-button>
560
- </div>
561
- ${repeat(this.parameters, (parameter) => parameter.name, (parameter, index) =>
562
- html`
563
- <pb-odd-parameter-editor
564
- behaviour="${this.behaviour}"
565
- name="${parameter.name}"
566
- value="${parameter.value}"
567
- ?set="${parameter.set}"
568
- endpoint="${this.endpoint}"
569
- apiVersion="${this.apiVersion}"
570
- @parameter-remove="${(e) => this._removeParam(e, index)}"
571
- @parameter-changed="${(e) => this._updateParam(e, index)}"
572
- ></pb-odd-parameter-editor>
573
- `)}
719
+ <div class="group">
720
+ <span class="title">Parameters</span>
721
+ <pb-icon-button
722
+ icon="add"
723
+ @click="${this._addParameter}"
724
+ ></pb-icon-button>
725
+ </div>
726
+ ${repeat(
727
+ this.parameters || [],
728
+ parameter => parameter.name,
729
+ (parameter, index) =>
730
+ html`
731
+ <pb-odd-parameter-editor
732
+ behaviour="${this.behaviour}"
733
+ name="${parameter.name}"
734
+ value="${parameter.value}"
735
+ ?set="${parameter.set}"
736
+ endpoint="${this.endpoint}"
737
+ apiVersion="${this.apiVersion}"
738
+ @parameter-remove="${e => this._removeParam(e, index)}"
739
+ @parameter-changed="${e => this._updateParam(e, index)}"
740
+ ></pb-odd-parameter-editor>
741
+ `,
742
+ )}
574
743
  </div>
575
744
 
576
745
  <div class="renditions">
577
- <div class="group">
578
- <div>
579
- <span class="title">Renditions</span>
580
- <paper-icon-button icon="add" @click="${this._addRendition}"></paper-icon-button>
581
- </div>
582
- <div class="source">
583
- <paper-checkbox ?checked="${this.sourcerend}" id="sourcerend">Use source rendition</paper-checkbox>
584
- </div>
746
+ <div class="group">
747
+ <div>
748
+ <span class="title">Renditions</span>
749
+ <pb-icon-button
750
+ icon="add"
751
+ @click="${this._addRendition}"
752
+ ></pb-icon-button>
585
753
  </div>
586
-
587
- ${repeat(this.renditions, (rendition) => rendition.name, (rendition, index) =>
588
- html`
589
- <pb-odd-rendition-editor scope="${rendition.scope}"
590
- css="${rendition.css}"
591
- @remove-rendition="${(e) => this._removeRendition(e, index)}"
592
- @rendition-changed="${(e) => this._updateRendition(e, index)}"
593
- ></pb-odd-rendition-editor>
594
- `)}
595
-
754
+ <div class="source">
755
+ <paper-checkbox ?checked="${this.sourcerend}" id="sourcerend"
756
+ >Use source rendition</paper-checkbox
757
+ >
758
+ </div>
759
+ </div>
760
+
761
+ ${repeat(
762
+ this.renditions || [],
763
+ rendition => rendition.name,
764
+ (rendition, index) =>
765
+ html`
766
+ <pb-odd-rendition-editor
767
+ scope="${rendition.scope}"
768
+ css="${rendition.css}"
769
+ @remove-rendition="${e => this._removeRendition(e, index)}"
770
+ @rendition-changed="${e => this._updateRendition(e, index)}"
771
+ ></pb-odd-rendition-editor>
772
+ `,
773
+ )}
596
774
  </div>
597
- `
598
- : ''
599
- }
600
- </iron-collapse>
601
-
775
+ `
776
+ : ''
777
+ }
778
+ </details>
779
+
602
780
  <div class="models">
603
- ${repeat(this.model.models, (model, index) => html`
604
- <pb-odd-model-editor
605
- behaviour="${model.behaviour || 'inline'}"
606
- predicate="${model.predicate}"
607
- type="${model.type}"
608
- output="${model.output}"
609
- css="${model.css}"
610
- mode="${model.mode}"
611
- .model="${model}"
612
- .parameters="${model.parameters}"
613
- desc="${model.desc}"
614
- sourcerend="${model.sourcerend}"
615
- .renditions="${model.renditions}"
616
- .template="${model.template}"
617
- .show="${model.show}"
618
- endpoint="${this.endpoint}"
619
- apiVersion="${this.apiVersion}"
620
- @model-remove="${this._removeModel}"
621
- @model-move-down="${this._moveModelDown}"
622
- @model-move-up="${this._moveModelUp}"
623
- @model-changed="${this.handleModelChanged}"
624
- @click="${ (e) => this.setCurrentSelection(e, index)}"
625
- hasParent
781
+ ${repeat(
782
+ (this.model && this.model.models) || [],
783
+ (model, index) => html`
784
+ <pb-odd-model-editor
785
+ behaviour="${model.behaviour || 'inline'}"
786
+ predicate="${model.predicate}"
787
+ type="${model.type}"
788
+ output="${model.output}"
789
+ css="${model.css}"
790
+ mode="${model.mode}"
791
+ .model="${model}"
792
+ .parameters="${model.parameters}"
793
+ desc="${model.desc}"
794
+ sourcerend="${model.sourcerend}"
795
+ .renditions="${model.renditions}"
796
+ .template="${model.template}"
797
+ .show="${model.show}"
798
+ endpoint="${this.endpoint}"
799
+ apiVersion="${this.apiVersion}"
800
+ @model-remove="${this._removeModel}"
801
+ @model-move-down="${this._moveModelDown}"
802
+ @model-move-up="${this._moveModelUp}"
803
+ @model-changed="${this.handleModelChanged}"
804
+ @click="${e => this.setCurrentSelection(e, index)}"
805
+ hasParent
626
806
  ></pb-odd-model-editor>
627
- `)}
628
-
629
- </div>
630
- </form>
807
+ `,
808
+ )}
809
+
810
+ </div>
811
+ </form>
631
812
  <pb-message id="dialog"></pb-message>
632
813
  `;
633
- }
814
+ }
634
815
 
635
- firstUpdated() {
636
- super.firstUpdated();
816
+ firstUpdated() {
817
+ super.firstUpdated();
637
818
 
638
- this.hasCustomBehaviour = this.behaviours.indexOf(this.behaviour) < 0;
639
- if (this.hasCustomBehaviour) {
640
- this.shadowRoot.getElementById('custombehaviour').value = this.behaviour;
641
- }
819
+ this.hasCustomBehaviour = this.behaviours.indexOf(this.behaviour) < 0;
820
+ if (this.hasCustomBehaviour) {
821
+ this.shadowRoot.getElementById('custombehaviour').value = this.behaviour;
642
822
  }
823
+ }
643
824
 
644
- updated(_changedProperties) {
645
- if (_changedProperties.has('show') && this.show) {
646
- this.refreshEditors();
647
- }
825
+ updated(_changedProperties) {
826
+ if (_changedProperties.has('show') && this.show) {
827
+ this.refreshEditors();
648
828
  }
829
+ }
649
830
 
650
- refreshEditors() {
651
- console.log('refreshEditors');
652
- // this.shadowRoot.getElementById('predicate').refresh();
653
-
654
- if (this._isGroupOrSequence()) { return console.log("asfdfa"); }
655
-
656
- // this.shadowRoot.getElementById('template').refresh();
657
-
658
- const models = this.shadowRoot.querySelectorAll('pb-odd-model-editor');
659
- for (let i = 0; i < models.length; i++) {
660
- models[i].refreshEditors();
661
- }
662
- const renditions = this.shadowRoot.querySelectorAll('pb-odd-rendition-editor');
663
- for (let i = 0; i < renditions.length; i++) {
664
- renditions[i].refreshEditor();
665
- }
666
- const parameters = this.shadowRoot.querySelectorAll('pb-odd-parameter-editor');
667
- for (let i = 0; i < parameters.length; i++) {
668
- parameters[i].refreshEditor();
669
- }
670
- }
671
-
672
- toggle(e) {
673
- // e.stopPropagation()
674
- // e.preventDefault()
675
-
676
- this.show = !this.show;
677
- this.toggleButtonIcon();
831
+ refreshEditors() {
832
+ console.log('refreshEditors');
833
+ // this.shadowRoot.getElementById('predicate').refresh();
678
834
 
679
- const oldModel = this.model;
680
- const newModel = Object.assign({}, oldModel, { show: this.show });
681
- this.model = newModel;
682
- this.refreshEditors();
683
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel } }));
835
+ if (this._isGroupOrSequence()) {
836
+ return console.log('asfdfa');
684
837
  }
685
838
 
686
- toggleButtonIcon() {
687
- if (this.show) {
688
- this.icon = 'expand-less';
689
- }
690
- else {
691
- this.icon = 'expand-more';
692
- }
693
- }
694
-
695
- _isModel() {
696
- return this.type === 'model';
697
- }
839
+ // this.shadowRoot.getElementById('template').refresh();
698
840
 
699
- _isGroupOrSequence() {
700
- return this.type !== 'model';
841
+ const models = this.shadowRoot.querySelectorAll('pb-odd-model-editor');
842
+ for (let i = 0; i < models.length; i++) {
843
+ models[i].refreshEditors();
701
844
  }
702
-
703
- static _templateMode(output) {
704
- switch (output) {
705
- case 'latex':
706
- return 'latex';
707
- case 'web':
708
- default:
709
- return 'xml';
710
- }
845
+ const renditions = this.shadowRoot.querySelectorAll('pb-odd-rendition-editor');
846
+ for (let i = 0; i < renditions.length; i++) {
847
+ renditions[i].refreshEditor();
711
848
  }
712
-
713
- _changeSelection(e) {
714
- if (e.detail.target == this) return;
715
- e.preventDefault();
716
- e.stopPropagation();
717
- if (this.currentSelection != undefined) {
718
- this.currentSelection.removeAttribute('currentselection');
719
- }
720
- const newSelection = e.detail.target;
721
- newSelection.setAttribute('currentselection', 'true');
722
- this.currentSelection = newSelection;
849
+ const parameters = this.shadowRoot.querySelectorAll('pb-odd-parameter-editor');
850
+ for (let i = 0; i < parameters.length; i++) {
851
+ parameters[i].refreshEditor();
723
852
  }
724
-
725
- _requestRemoval(e) {
726
- e.preventDefault();
727
- this.dispatchEvent(new CustomEvent('model-remove'));
853
+ }
854
+
855
+ toggle(e) {
856
+ // e.stopPropagation()
857
+ // e.preventDefault()
858
+
859
+ this.show = !this.show;
860
+ this.toggleButtonIcon();
861
+
862
+ const oldModel = this.model;
863
+ const newModel = { ...oldModel, show: this.show };
864
+ this.model = newModel;
865
+ this.refreshEditors();
866
+ this.dispatchEvent(
867
+ new CustomEvent('model-changed', {
868
+ composed: true,
869
+ bubbles: true,
870
+ detail: { oldModel, newModel },
871
+ }),
872
+ );
873
+ }
874
+
875
+ toggleButtonIcon() {
876
+ if (this.show) {
877
+ this.icon = 'expand-less';
878
+ } else {
879
+ this.icon = 'expand-more';
728
880
  }
729
-
730
- /**
731
- * move model down in list
732
- *
733
- * @param e
734
- * @event model-move-down dispatched to request the model to move down
735
- */
736
- _moveDown(e) {
737
- e.preventDefault();
738
- e.stopPropagation();
739
- // this.dispatchEvent(new CustomEvent('model-move-down'));
740
- this.dispatchEvent(new CustomEvent('model-move-down', { composed: true, bubbles: true, detail: { model: this } }));
881
+ }
882
+
883
+ _isModel() {
884
+ return this.type === 'model';
885
+ }
886
+
887
+ _isGroupOrSequence() {
888
+ return this.type !== 'model';
889
+ }
890
+
891
+ static _templateMode(output) {
892
+ switch (output) {
893
+ case 'latex':
894
+ return 'latex';
895
+ case 'web':
896
+ default:
897
+ return 'xml';
741
898
  }
742
-
743
- /**
744
- * move model up in list
745
- *
746
- * @param e
747
- * @event model-move-up dispatched to request the model to move up
748
- */
749
- _moveUp(e) {
750
- e.preventDefault();
751
- e.stopPropagation();
752
- this.dispatchEvent(new CustomEvent('model-move-up'));
899
+ }
900
+
901
+ _changeSelection(e) {
902
+ if (e.detail.target == this) return;
903
+ e.preventDefault();
904
+ e.stopPropagation();
905
+ if (this.currentSelection != undefined) {
906
+ this.currentSelection.removeAttribute('currentselection');
753
907
  }
754
-
755
- _addNested(e) {
756
- const newNestedModel = {
757
- behaviour: 'inline',
758
- css: '',
759
- desc: '',
760
- predicate: '',
761
- type: e instanceof Event ? e.detail.item.getAttribute('value') : e,
762
- output: '',
763
- sourcerend: false,
764
- models: [],
765
- mode: '',
766
- parameters: [],
767
- renditions: [],
768
- template: '',
769
- show: true
770
- };
771
-
772
- const oldModel = this.model;
773
- const models = Array.from(this.model.models);
774
- models.unshift(newNestedModel);
775
- this.model = Object.assign({}, oldModel, { models });
776
-
777
- // important to reset the listbox - otherwise next attempt to use it will fail if value has not changed
778
- // use querySelector here instead of 'this.$' as listbox is in it's own <template>
779
- const modelTypeSelector = this.shadowRoot.querySelector('#modelType')
780
- modelTypeSelector.select("");
781
-
782
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel: this.model } }));
908
+ const newSelection = e.detail.target;
909
+ newSelection.setAttribute('currentselection', 'true');
910
+ this.currentSelection = newSelection;
911
+ }
912
+
913
+ _requestRemoval(e) {
914
+ e.preventDefault();
915
+ this.dispatchEvent(new CustomEvent('model-remove'));
916
+ }
917
+
918
+ /**
919
+ * move model down in list
920
+ *
921
+ * @param e
922
+ * @event model-move-down dispatched to request the model to move down
923
+ */
924
+ _moveDown(e) {
925
+ e.preventDefault();
926
+ e.stopPropagation();
927
+ // this.dispatchEvent(new CustomEvent('model-move-down'));
928
+ this.dispatchEvent(
929
+ new CustomEvent('model-move-down', {
930
+ composed: true,
931
+ bubbles: true,
932
+ detail: { model: this },
933
+ }),
934
+ );
935
+ }
936
+
937
+ /**
938
+ * move model up in list
939
+ *
940
+ * @param e
941
+ * @event model-move-up dispatched to request the model to move up
942
+ */
943
+ _moveUp(e) {
944
+ e.preventDefault();
945
+ e.stopPropagation();
946
+ this.dispatchEvent(new CustomEvent('model-move-up'));
947
+ }
948
+
949
+ _addNested(e) {
950
+ const newNestedModel = {
951
+ behaviour: 'inline',
952
+ css: '',
953
+ desc: '',
954
+ predicate: '',
955
+ type: e instanceof Event ? e.detail.item.getAttribute('value') : e,
956
+ output: '',
957
+ sourcerend: false,
958
+ models: [],
959
+ mode: '',
960
+ parameters: [],
961
+ renditions: [],
962
+ template: '',
963
+ show: true,
964
+ };
965
+
966
+ const oldModel = this.model;
967
+ const models = Array.from(this.model.models);
968
+ models.unshift(newNestedModel);
969
+ this.model = { ...oldModel, models };
970
+
971
+ // important to reset the listbox - otherwise next attempt to use it will fail if value has not changed
972
+ // use querySelector here instead of 'this.$' as listbox is in it's own <template>
973
+ const modelTypeSelector = this.shadowRoot.querySelector('#modelType');
974
+ modelTypeSelector.select('');
975
+
976
+ this.dispatchEvent(
977
+ new CustomEvent('model-changed', {
978
+ composed: true,
979
+ bubbles: true,
980
+ detail: { oldModel, newModel: this.model },
981
+ }),
982
+ );
983
+ }
984
+
985
+ _handleAddNested(event) {
986
+ const value = event.target.value;
987
+ if (!value) {
988
+ return;
783
989
  }
784
-
785
- addModel(newModel) {
786
- if (newModel.type !== 'model') {
787
- console.error('only models can be added to modelSequence or modelGrp');
788
- return;
789
- }
790
- this.model.models.unshift(newModel);
791
- this.requestUpdate();
990
+ this._addNested(value);
991
+ event.target.value = '';
992
+ }
993
+
994
+ addModel(newModel) {
995
+ if (newModel.type !== 'model') {
996
+ console.error('only models can be added to modelSequence or modelGrp');
997
+ return;
792
998
  }
793
-
794
- _removeModel(ev) {
795
- console.log('_removeModel ', ev);
796
- ev.stopPropagation();
797
- const { model } = ev.target;
798
- const index = this.model.models.indexOf(model)
799
-
800
- this.shadowRoot.getElementById('dialog')
801
- .confirm(i18n('odd.editor.model.delete-model-label'), i18n('odd.editor.model.delete-model-message'))
802
- .then(() => {
803
- const oldModel = this.model;
804
- const models = Array.from(this.model.models);
805
- models.splice(index, 1);
806
- this.model = Object.assign({}, oldModel, { models });
807
- this.models = models;
808
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel: this.model } }));
809
- }, () => null);
999
+ this.model.models.unshift(newModel);
1000
+ this.requestUpdate();
1001
+ }
1002
+
1003
+ _removeModel(ev) {
1004
+ console.log('_removeModel ', ev);
1005
+ ev.stopPropagation();
1006
+ const { model } = ev.target;
1007
+ const index = this.model.models.indexOf(model);
1008
+
1009
+ this.shadowRoot
1010
+ .getElementById('dialog')
1011
+ .confirm(
1012
+ i18n('odd.editor.model.delete-model-label'),
1013
+ i18n('odd.editor.model.delete-model-message'),
1014
+ )
1015
+ .then(
1016
+ () => {
1017
+ const oldModel = this.model;
1018
+ const models = Array.from(this.model.models);
1019
+ models.splice(index, 1);
1020
+ this.model = { ...oldModel, models };
1021
+ this.models = models;
1022
+ this.dispatchEvent(
1023
+ new CustomEvent('model-changed', {
1024
+ composed: true,
1025
+ bubbles: true,
1026
+ detail: { oldModel, newModel: this.model },
1027
+ }),
1028
+ );
1029
+ },
1030
+ () => null,
1031
+ );
1032
+ }
1033
+
1034
+ _moveModelDown(ev) {
1035
+ console.log('MODEL._moveModelDown ', ev);
1036
+ ev.stopPropagation();
1037
+ const { model } = ev.target;
1038
+ const index = this.model.models.indexOf(model);
1039
+ if (index === this.model.models.length) {
1040
+ return;
810
1041
  }
811
-
812
- _moveModelDown(ev) {
813
- console.log('MODEL._moveModelDown ', ev);
814
- ev.stopPropagation();
815
- const { model } = ev.target;
816
- const index = this.model.models.indexOf(model)
817
- if (index === this.model.models.length) {
818
- return;
819
- }
820
- const oldModel = this.model;
821
- const models = Array.from(this.model.models);
822
- models.splice(index, 1);
823
- models.splice(index + 1, 0, model);
824
- this.model = Object.assign({}, oldModel, { models });
825
-
826
- const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index + 1];
827
- this._setCurrentSelection(index + 1, targetModel);
828
-
829
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel: this.model } }));
830
- this.requestUpdate();
1042
+ const oldModel = this.model;
1043
+ const models = Array.from(this.model.models);
1044
+ models.splice(index, 1);
1045
+ models.splice(index + 1, 0, model);
1046
+ this.model = { ...oldModel, models };
1047
+
1048
+ const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index + 1];
1049
+ this._setCurrentSelection(index + 1, targetModel);
1050
+
1051
+ this.dispatchEvent(
1052
+ new CustomEvent('model-changed', {
1053
+ composed: true,
1054
+ bubbles: true,
1055
+ detail: { oldModel, newModel: this.model },
1056
+ }),
1057
+ );
1058
+ this.requestUpdate();
1059
+ }
1060
+
1061
+ _moveModelUp(ev) {
1062
+ ev.stopPropagation();
1063
+ const { model } = ev.target;
1064
+ const index = this.model.models.indexOf(model);
1065
+ if (index === 0) {
1066
+ return;
831
1067
  }
832
-
833
- _moveModelUp(ev) {
834
- ev.stopPropagation();
835
- const { model } = ev.target;
836
- const index = this.model.models.indexOf(model)
837
- if (index === 0) {
838
- return;
839
- }
840
- const oldModel = this.model;
841
- const models = Array.from(this.model.models);
842
- // remove element from models
843
- models.splice(index, 1);
844
- // add element to new index
845
- models.splice(index - 1, 0, model);
846
- this.model = Object.assign({}, oldModel, { models });
847
-
848
- const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index - 1];
849
- this._setCurrentSelection(index - 1, targetModel);
850
-
851
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel: this.model } }));
852
- // this.requestUpdate();
1068
+ const oldModel = this.model;
1069
+ const models = Array.from(this.model.models);
1070
+ // remove element from models
1071
+ models.splice(index, 1);
1072
+ // add element to new index
1073
+ models.splice(index - 1, 0, model);
1074
+ this.model = { ...oldModel, models };
1075
+
1076
+ const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index - 1];
1077
+ this._setCurrentSelection(index - 1, targetModel);
1078
+
1079
+ this.dispatchEvent(
1080
+ new CustomEvent('model-changed', {
1081
+ composed: true,
1082
+ bubbles: true,
1083
+ detail: { oldModel, newModel: this.model },
1084
+ }),
1085
+ );
1086
+ // this.requestUpdate();
1087
+ }
1088
+
1089
+ handleModelChanged(ev) {
1090
+ console.log('handleModelChanged ', ev, this);
1091
+ ev.stopPropagation();
1092
+ const oldModel = this.model;
1093
+ const index = this.model.models.indexOf(ev.detail.oldModel);
1094
+ const models = Array.from(this.model.models);
1095
+ models.splice(index, 1, ev.detail.newModel);
1096
+ this.model = { ...oldModel, models };
1097
+ this.dispatchEvent(
1098
+ new CustomEvent('model-changed', {
1099
+ composed: true,
1100
+ bubbles: true,
1101
+ detail: { oldModel, newModel: this.model },
1102
+ }),
1103
+ );
1104
+ }
1105
+
1106
+ // todo: setCurrentSelection functions are redundant in model and elementspec components - do better
1107
+ setCurrentSelection(e, index) {
1108
+ e.preventDefault();
1109
+ e.stopPropagation();
1110
+
1111
+ // prevent event if model is already the current one
1112
+ this._setCurrentSelection(index, e.target);
1113
+ }
1114
+
1115
+ _setCurrentSelection(index, target) {
1116
+ // console.log('_setCurrentSelection ', target);
1117
+ const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index];
1118
+
1119
+ if (!targetModel) {
1120
+ return;
853
1121
  }
854
1122
 
855
- handleModelChanged(ev) {
856
- console.log('handleModelChanged ', ev, this);
857
- ev.stopPropagation();
858
- const oldModel = this.model;
859
- const index = this.model.models.indexOf(ev.detail.oldModel);
860
- const models = Array.from(this.model.models);
861
- models.splice(index, 1, ev.detail.newModel);
862
- this.model = Object.assign({}, oldModel, { models });
863
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel: this.model } }));
1123
+ if (targetModel.hasAttribute('currentselection')) return;
1124
+
1125
+ this.dispatchEvent(
1126
+ new CustomEvent('current-changed', { composed: true, bubbles: true, detail: { target } }),
1127
+ );
1128
+ this.requestUpdate();
1129
+ }
1130
+
1131
+ _inputDesc(e) {
1132
+ this.desc = e.target.value;
1133
+ this._fireModelChanged('desc', this.desc);
1134
+ }
1135
+
1136
+ _selectOutput(e) {
1137
+ this.output = e.target.value;
1138
+ this._fireModelChanged('output', this.output);
1139
+ }
1140
+
1141
+ _updatePredicate() {
1142
+ this.predicate = this.shadowRoot.getElementById('predicate').value;
1143
+ console.log('_updatePredicate ', this.predicate);
1144
+ this._fireModelChanged('predicate', this.predicate);
1145
+ }
1146
+
1147
+ _selectBehaviour(ev) {
1148
+ this.behaviour = ev.target.value;
1149
+ this._fireModelChanged('behaviour', this.behaviour);
1150
+ }
1151
+
1152
+ _inputCss(ev) {
1153
+ this.css = ev.target.value;
1154
+ this._fireModelChanged('css', this.css);
1155
+ }
1156
+
1157
+ _inputMode(ev) {
1158
+ this.mode = ev.target.value;
1159
+ this._fireModelChanged('mode', this.mode);
1160
+ }
1161
+
1162
+ _updateTemplate(ev) {
1163
+ this.template = this.shadowRoot.getElementById('template').content;
1164
+ this._fireModelChanged('template', this.template);
1165
+ }
1166
+
1167
+ /**
1168
+ * add a model parameter
1169
+ *
1170
+ * @param e
1171
+ */
1172
+ _addParameter(e) {
1173
+ this.parameters.push({ name: '', value: '' });
1174
+ this._fireModelChanged('parameters', this.parameters);
1175
+ }
1176
+
1177
+ _updateParam(e, index) {
1178
+ this.parameters[index].name = e.detail.name;
1179
+ this.parameters[index].value = e.detail.value;
1180
+ this.parameters[index].set = e.detail.set;
1181
+ this._fireModelChanged('parameters', this.parameters);
1182
+ }
1183
+
1184
+ /**
1185
+ * remove a parameter
1186
+ * @param e
1187
+ * @param index
1188
+ * @private
1189
+ */
1190
+ _removeParam(e, index) {
1191
+ this.parameters.splice(index, 1);
1192
+ this._fireModelChanged('parameters', this.parameters);
1193
+ }
1194
+
1195
+ /**
1196
+ * add a rendition
1197
+ *
1198
+ * @param ev
1199
+ */
1200
+ _addRendition(ev) {
1201
+ this.renditions.push({
1202
+ scope: '',
1203
+ css: '',
1204
+ });
1205
+ this._fireModelChanged('renditions', this.renditions);
1206
+ }
1207
+
1208
+ _updateRendition(e, index) {
1209
+ this.renditions[index].css = e.detail.css;
1210
+ this.renditions[index].scope = e.detail.scope;
1211
+ this._fireModelChanged('renditions', this.renditions);
1212
+ }
1213
+
1214
+ _removeRendition(e, index) {
1215
+ this.renditions.splice(index, 1);
1216
+ this._fireModelChanged('renditions', this.renditions);
1217
+ }
1218
+
1219
+ _fireModelChanged(prop, value) {
1220
+ const oldModel = this.model;
1221
+ this.model = { ...this.model, [prop]: value };
1222
+ console.log('model changed for %s: %o - %o', prop, value, this.model);
1223
+ this.dispatchEvent(
1224
+ new CustomEvent('model-changed', {
1225
+ composed: true,
1226
+ bubbles: true,
1227
+ detail: { oldModel, newModel: this.model },
1228
+ }),
1229
+ );
1230
+ this.requestUpdate();
1231
+ }
1232
+
1233
+ _copy(ev) {
1234
+ ev.preventDefault();
1235
+ ev.stopPropagation();
1236
+ console.log('odd-model.copy ', ev);
1237
+ console.log('odd-model.copy data', this.model);
1238
+
1239
+ this.dispatchEvent(
1240
+ new CustomEvent('odd-copy', { composed: true, bubbles: true, detail: { model: this.model } }),
1241
+ );
1242
+ }
1243
+
1244
+ _paste(ev) {
1245
+ console.log('model _paste ', ev);
1246
+ this.dispatchEvent(
1247
+ new CustomEvent('odd-paste', { composed: true, bubbles: true, detail: { target: this } }),
1248
+ );
1249
+ }
1250
+
1251
+ _handleCustomBehaviour(e) {
1252
+ this.behaviour = e.composedPath()[0].value;
1253
+ this._fireModelChanged('behaviour', this.behaviour);
1254
+
1255
+ // en-/disable behaviour menu
1256
+ if (this.behaviour === '') {
1257
+ this.behaviour = 'inline';
1258
+ this.hasCustomBehaviour = false;
1259
+ } else {
1260
+ this.hasCustomBehaviour = true;
864
1261
  }
865
-
866
-
867
- //todo: setCurrentSelection functions are redundant in model and elementspec components - do better
868
- setCurrentSelection(e, index) {
869
- e.preventDefault();
870
- e.stopPropagation();
871
-
872
- //prevent event if model is already the current one
873
- this._setCurrentSelection(index, e.target);
874
- }
875
-
876
- _setCurrentSelection(index, target) {
877
- // console.log('_setCurrentSelection ', target);
878
- const targetModel = this.shadowRoot.querySelectorAll('pb-odd-model-editor')[index];
879
-
880
- if (!targetModel) { return; }
881
-
882
- if (targetModel.hasAttribute('currentselection')) return;
883
-
884
- this.dispatchEvent(new CustomEvent('current-changed', { composed: true, bubbles: true, detail: { target: target } }));
885
- this.requestUpdate();
886
- }
887
-
888
- _inputDesc(e) {
889
- this.desc = e.composedPath()[0].value;
890
- this._fireModelChanged('desc', this.desc);
891
- }
892
-
893
- _selectOutput(e) {
894
- this.output = e.composedPath()[0].selected;
895
- this._fireModelChanged('output', this.output);
896
- }
897
-
898
- _updatePredicate() {
899
- this.predicate = this.shadowRoot.getElementById('predicate').value;
900
- console.log('_updatePredicate ', this.predicate);
901
- this._fireModelChanged('predicate', this.predicate);
902
- }
903
-
904
- _selectBehaviour(ev) {
905
- this.behaviour = ev.composedPath()[0].selected;
906
- this._fireModelChanged('behaviour', this.behaviour);
907
- }
908
-
909
- _inputCss(ev) {
910
- this.css = ev.composedPath()[0].value;
911
- this._fireModelChanged('css', this.css);
912
- }
913
-
914
- _inputMode(ev) {
915
- this.mode = ev.composedPath()[0].value;
916
- this._fireModelChanged('mode', this.mode);
917
- }
918
-
919
- _updateTemplate(ev) {
920
- this.template = this.shadowRoot.getElementById('template').content;
921
- this._fireModelChanged('template', this.template);
922
- }
923
-
924
- /**
925
- * add a model parameter
926
- *
927
- * @param e
928
- */
929
- _addParameter(e) {
930
- this.parameters.push({ name: "", value: "" });
931
- this._fireModelChanged('parameters', this.parameters);
932
- }
933
-
934
- _updateParam(e, index) {
935
- this.parameters[index].name = e.detail.name;
936
- this.parameters[index].value = e.detail.value;
937
- this.parameters[index].set = e.detail.set;
938
- this._fireModelChanged('parameters', this.parameters);
939
- }
940
-
941
- /**
942
- * remove a parameter
943
- * @param e
944
- * @param index
945
- * @private
946
- */
947
- _removeParam(e, index) {
948
- this.parameters.splice(index, 1);
949
- this._fireModelChanged('parameters', this.parameters);
950
- }
951
-
952
- /**
953
- * add a rendition
954
- *
955
- * @param ev
956
- */
957
- _addRendition(ev) {
958
- this.renditions.push({
959
- scope: '',
960
- css: ''
961
- });
962
- this._fireModelChanged('renditions', this.renditions);
963
- }
964
-
965
- _updateRendition(e, index) {
966
- this.renditions[index].css = e.detail.css;
967
- this.renditions[index].scope = e.detail.scope;
968
- this._fireModelChanged('renditions', this.renditions);
969
- }
970
-
971
- _removeRendition(e, index) {
972
- this.renditions.splice(index, 1);
973
- this._fireModelChanged('renditions', this.renditions);
974
- }
975
-
976
- _fireModelChanged(prop, value) {
977
- const oldModel = this.model;
978
- this.model = Object.assign({}, this.model, { [prop]: value });
979
- console.log('model changed for %s: %o - %o', prop, value, this.model);
980
- this.dispatchEvent(new CustomEvent('model-changed', { composed: true, bubbles: true, detail: { oldModel, newModel: this.model } }));
981
- this.requestUpdate();
982
- }
983
-
984
- _copy(ev) {
985
- ev.preventDefault();
986
- ev.stopPropagation();
987
- console.log('odd-model.copy ', ev);
988
- console.log('odd-model.copy data', this.model);
989
-
990
- this.dispatchEvent(new CustomEvent('odd-copy', { composed: true, bubbles: true, detail: { model: this.model } }));
991
- }
992
-
993
- _paste(ev) {
994
- console.log('model _paste ', ev);
995
- this.dispatchEvent(new CustomEvent('odd-paste', { composed: true, bubbles: true, detail: { target: this } }));
996
- }
997
-
998
-
999
- _handleCustomBehaviour(e) {
1000
- this.behaviour = e.composedPath()[0].value;
1001
- this._fireModelChanged('behaviour', this.behaviour);
1002
-
1003
- // en-/disable behaviour menu
1004
- if (this.behaviour === '') {
1005
- this.behaviour = 'inline';
1006
- this.hasCustomBehaviour = false;
1007
- } else {
1008
- this.hasCustomBehaviour = true;
1009
- }
1010
- this.requestUpdate();
1011
-
1012
- }
1013
-
1014
-
1015
-
1262
+ this.requestUpdate();
1263
+ }
1016
1264
  }
1017
1265
  customElements.define('pb-odd-model-editor', PbOddModelEditor);