@bpmn-io/element-template-changelog 0.1.0 → 0.2.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/README.md CHANGED
@@ -43,6 +43,20 @@ elementTemplates.applyTemplate(element, update.template);
43
43
  ```
44
44
 
45
45
 
46
+ ### Configuration
47
+
48
+ The changelog renders into `document.body`. Configure a `container` (element or selector) to render it elsewhere, e.g. within your application's theme scope:
49
+
50
+ ```javascript
51
+ const modeler = new BpmnModeler({
52
+ elementTemplateChangelog: {
53
+ container: '#properties-panel'
54
+ },
55
+ ...
56
+ });
57
+ ```
58
+
59
+
46
60
  ## Build and Run
47
61
 
48
62
  Prepare the project by installing all dependencies:
@@ -8,10 +8,17 @@
8
8
  */
9
9
  .bio-theme-parent {
10
10
  --bio-surface-overlay: hsl(0, 0%, 100%);
11
+ --bio-surface-subtle: hsl(225, 10%, 97%);
11
12
  --bio-text: hsl(225, 10%, 15%);
13
+ --bio-text-on-primary: hsl(0, 0%, 100%);
14
+ --bio-border: hsl(225, 10%, 75%);
12
15
  --bio-border-subtle: hsl(225, 10%, 85%);
16
+ --bio-primary: hsl(205, 100%, 40%);
17
+ --bio-primary-hover: hsl(205, 100%, 35%);
13
18
  --bio-info: hsl(205, 100%, 40%);
19
+ --bio-focus-ring: hsla(205, 100%, 40%, 0.35);
14
20
  --bio-shadow: hsla(0, 0%, 0%, 30%);
21
+ --bio-radius-md: 3px;
15
22
  --bio-radius-lg: 4px;
16
23
  }
17
24
 
@@ -24,17 +31,28 @@
24
31
  --changelog-shadow-color: var(--bio-shadow);
25
32
  --changelog-border-radius: var(--bio-radius-lg);
26
33
  --changelog-spacing: 16px;
34
+ --changelog-font-family: Helvetica, Arial, sans-serif;
35
+ --changelog-focus-ring-color: var(--bio-focus-ring);
36
+ --changelog-action-background-color: var(--bio-surface-overlay);
37
+ --changelog-action-hover-background-color: var(--bio-surface-subtle);
38
+ --changelog-action-border-color: var(--bio-border);
39
+ --changelog-action-border-radius: var(--bio-radius-md);
40
+ --changelog-action-color: var(--bio-text);
41
+ --changelog-primary-action-background-color: var(--bio-primary);
42
+ --changelog-primary-action-hover-background-color: var(--bio-primary-hover);
43
+ --changelog-primary-action-color: var(--bio-text-on-primary);
27
44
 
28
45
  flex-direction: column;
29
46
  width: min(640px, calc(100vw - 40px));
30
47
  max-height: 80vh;
48
+ margin: auto;
31
49
  padding: 0;
32
50
  border: none;
33
51
  background: var(--changelog-background-color);
34
52
  color: var(--changelog-color);
35
53
  border-radius: var(--changelog-border-radius);
36
54
  box-shadow: 0 1px 4px var(--changelog-shadow-color);
37
- font-family: Helvetica, Arial, sans-serif;
55
+ font-family: var(--changelog-font-family);
38
56
  font-size: 14px;
39
57
  line-height: 1.3;
40
58
  }
@@ -47,36 +65,84 @@
47
65
  background: var(--changelog-backdrop-color);
48
66
  }
49
67
 
50
- .element-template-changelog > * {
68
+ .element-template-changelog-title {
51
69
  margin: 0;
52
70
  padding: var(--changelog-spacing);
71
+ font-size: 16px;
72
+ font-weight: bold;
53
73
  }
54
74
 
55
- .element-template-changelog .changes {
75
+ .element-template-changelog-changes {
56
76
  display: flex;
57
77
  flex-direction: column;
58
78
  gap: var(--changelog-spacing);
59
79
  min-height: 0;
80
+ margin: 0;
81
+ padding: var(--changelog-spacing);
60
82
  overflow: auto;
61
83
  border-block: solid 1px var(--changelog-border-color);
62
84
  }
63
85
 
64
- .element-template-changelog h4 {
86
+ .element-template-changelog-change-title {
65
87
  margin: 0;
88
+ font-size: 14px;
89
+ font-weight: bold;
66
90
  }
67
91
 
68
- .element-template-changelog pre {
92
+ .element-template-changelog-change-text {
69
93
  margin: 4px 0 0;
94
+ font-family: monospace;
95
+ font-size: 13px;
70
96
  white-space: pre-wrap;
71
97
  overflow-wrap: anywhere;
72
98
  }
73
99
 
74
- .element-template-changelog a {
100
+ .element-template-changelog-link {
75
101
  color: var(--changelog-link-color);
102
+ text-decoration: underline;
76
103
  }
77
104
 
78
- .element-template-changelog .actions {
105
+ .element-template-changelog-actions {
79
106
  display: flex;
80
107
  gap: 8px;
81
108
  justify-content: flex-end;
109
+ margin: 0;
110
+ padding: var(--changelog-spacing);
111
+ }
112
+
113
+ .element-template-changelog-action {
114
+ padding: 6px 12px;
115
+ border: solid 1px var(--changelog-action-border-color);
116
+ border-radius: var(--changelog-action-border-radius);
117
+ background: var(--changelog-action-background-color);
118
+ color: var(--changelog-action-color);
119
+ font: inherit;
120
+ cursor: pointer;
121
+ }
122
+
123
+ .element-template-changelog-action:hover {
124
+ background: var(--changelog-action-hover-background-color);
125
+ }
126
+
127
+ .element-template-changelog-action-primary {
128
+ border-color: var(--changelog-primary-action-background-color);
129
+ background: var(--changelog-primary-action-background-color);
130
+ color: var(--changelog-primary-action-color);
131
+ }
132
+
133
+ .element-template-changelog-action-primary:hover {
134
+ border-color: var(--changelog-primary-action-hover-background-color);
135
+ background: var(--changelog-primary-action-hover-background-color);
136
+ }
137
+
138
+ .element-template-changelog-action:focus-visible {
139
+ outline: none;
140
+ box-shadow: 0 0 0 2px var(--changelog-focus-ring-color);
141
+ }
142
+
143
+ /* keep focus visible where box-shadow is dropped (e.g. Windows High Contrast) */
144
+ @media (forced-colors: active) {
145
+ .element-template-changelog-action:focus-visible {
146
+ outline: 2px solid Highlight;
147
+ }
82
148
  }
@@ -14,6 +14,10 @@ import {
14
14
  * } } Change
15
15
  *
16
16
  * @typedef { {
17
+ * container?: HTMLElement | string
18
+ * } } ElementTemplateChangelogConfig
19
+ *
20
+ * @typedef { {
17
21
  * oldTemplate: Object,
18
22
  * newTemplate: Object,
19
23
  * changes: Change[]
@@ -25,11 +29,15 @@ import {
25
29
  * via `elementTemplates.reviewChanges`, and applies the new template once
26
30
  * confirmed.
27
31
  *
32
+ * Renders into `config.container` (element or selector), or `document.body`.
33
+ *
34
+ * @param {ElementTemplateChangelogConfig} config
28
35
  * @param {EventBus} eventBus
29
36
  * @param {ElementTemplates} elementTemplates
30
37
  * @param {Function} translate
31
38
  */
32
- export default function ElementTemplateChangelog(eventBus, elementTemplates, translate) {
39
+ export default function ElementTemplateChangelog(config, eventBus, elementTemplates, translate) {
40
+ this._config = config || {};
33
41
  this._translate = translate;
34
42
  this._cancels = new Set();
35
43
 
@@ -54,6 +62,7 @@ export default function ElementTemplateChangelog(eventBus, elementTemplates, tra
54
62
  }
55
63
 
56
64
  ElementTemplateChangelog.$inject = [
65
+ 'config.elementTemplateChangelog',
57
66
  'eventBus',
58
67
  'elementTemplates',
59
68
  'translate'
@@ -91,7 +100,7 @@ ElementTemplateChangelog.prototype.open = function(context) {
91
100
 
92
101
  this._cancels.add(onCancel);
93
102
 
94
- document.body.appendChild(container);
103
+ getContainer(this._config.container).appendChild(container);
95
104
 
96
105
  render(html`
97
106
  <${ Changelog }
@@ -127,21 +136,21 @@ function Changelog({ oldTemplate, newTemplate, changes, translate, onConfirm, on
127
136
  <dialog
128
137
  ref=${ dialogRef }
129
138
  class="element-template-changelog bio-theme-parent"
130
- aria-labelledby="element-template-changelog-title"
139
+ aria-label=${ title }
131
140
  onCancel=${ onCancel }
132
141
  onClick=${ onBackdropClick }>
133
- <h3 id="element-template-changelog-title">${ title }</h3>
134
- <div class="changes">
142
+ <h3 class="element-template-changelog-title">${ title }</h3>
143
+ <div class="element-template-changelog-changes">
135
144
  ${ changes.map(change => html`
136
- <section class="change">
137
- <h4>${ getChangeTitle(change, oldTemplate, translate) }</h4>
138
- <pre>${ renderText(change.text) }</pre>
145
+ <section class="element-template-changelog-change">
146
+ <h4 class="element-template-changelog-change-title">${ getChangeTitle(change, oldTemplate, translate) }</h4>
147
+ <pre class="element-template-changelog-change-text">${ renderText(change.text) }</pre>
139
148
  </section>
140
149
  `) }
141
150
  </div>
142
- <div class="actions">
143
- <button onClick=${ onCancel }>${ translate('Cancel') }</button>
144
- <button autofocus onClick=${ onConfirm }>
151
+ <div class="element-template-changelog-actions">
152
+ <button class="element-template-changelog-action" onClick=${ onCancel }>${ translate('Cancel') }</button>
153
+ <button class="element-template-changelog-action element-template-changelog-action-primary" autofocus onClick=${ onConfirm }>
145
154
  ${ isUpdate ? translate('Update') : translate('Migrate') }
146
155
  </button>
147
156
  </div>
@@ -149,6 +158,14 @@ function Changelog({ oldTemplate, newTemplate, changes, translate, onConfirm, on
149
158
  `;
150
159
  }
151
160
 
161
+ function getContainer(container) {
162
+ if (typeof container === 'string') {
163
+ return document.querySelector(container);
164
+ }
165
+
166
+ return container || document.body;
167
+ }
168
+
152
169
  /**
153
170
  * Title a change by the step that contributes it.
154
171
  */
@@ -177,7 +194,7 @@ function renderText(text) {
177
194
  for (const match of text.matchAll(/https?:\/\/[^\s()<>"']+/g)) {
178
195
  parts.push(
179
196
  text.slice(index, match.index),
180
- html`<a href=${ match[0] } target="_blank" rel="noopener noreferrer">${ match[0] }</a>`
197
+ html`<a class="element-template-changelog-link" href=${ match[0] } target="_blank" rel="noopener noreferrer">${ match[0] }</a>`
181
198
  );
182
199
 
183
200
  index = match.index + match[0].length;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpmn-io/element-template-changelog",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Review the changes of element template updates and migrations",
5
5
  "type": "module",
6
6
  "exports": {
@@ -39,7 +39,7 @@
39
39
  "@bpmn-io/properties-panel": "^3.60.2",
40
40
  "@bpmn-io/theme": "^0.3.0",
41
41
  "bpmn-js": "^18.33.1",
42
- "bpmn-js-element-templates": "^2.40.3",
42
+ "bpmn-js-element-templates": "^2.41.0",
43
43
  "bpmn-js-properties-panel": "^5.65.4",
44
44
  "camunda-bpmn-js-behaviors": "^1.18.0",
45
45
  "chai": "^6.3.0",