@kubex/zinc 1.1.112 → 1.1.114
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/dist/custom-elements.json +74 -74
- package/dist/vscode.html-custom-data.json +11 -11
- package/dist/web-types.json +23 -23
- package/dist/zn.min.css +1 -1
- package/dist/zn.min.js +241 -241
- package/package.json +1 -1
- package/scss/shared/_form-elements.scss +1 -1
- package/scss/shared/layout.scss +5 -5
- package/src/components/priority-list/priority-list.component.ts +9 -6
- package/src/components/priority-list/priority-list.test.ts +34 -0
- package/src/wc.scss +9 -6
package/package.json
CHANGED
package/scss/shared/layout.scss
CHANGED
|
@@ -254,27 +254,27 @@
|
|
|
254
254
|
|
|
255
255
|
.zn-border {
|
|
256
256
|
border-style: solid;
|
|
257
|
-
border-width: 1px
|
|
257
|
+
border-width: 1px;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
.zn-bt {
|
|
261
261
|
border-top-style: solid;
|
|
262
|
-
border-top-width: 1px
|
|
262
|
+
border-top-width: 1px;
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
.zn-bb {
|
|
266
266
|
border-bottom-style: solid;
|
|
267
|
-
border-bottom-width: 1px
|
|
267
|
+
border-bottom-width: 1px;
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
.zn-bl {
|
|
271
271
|
border-left-style: solid;
|
|
272
|
-
border-left-width: 1px
|
|
272
|
+
border-left-width: 1px;
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
.zn-br {
|
|
276
276
|
border-right-style: solid;
|
|
277
|
-
border-right-width: 1px
|
|
277
|
+
border-right-width: 1px;
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
.unifi-action {
|
|
@@ -297,15 +297,16 @@ export default class ZnPriorityList extends ZincElement implements ZincFormContr
|
|
|
297
297
|
|
|
298
298
|
const form = this.getForm();
|
|
299
299
|
if (form) {
|
|
300
|
-
|
|
300
|
+
// Submitting through the controller announces the form before it is
|
|
301
|
+
// submitted, which is what lets a host intercept the submit: a submit
|
|
302
|
+
// event raised on a form inside a shadow root never reaches the document,
|
|
303
|
+
// so submitting it directly navigates the page instead.
|
|
304
|
+
const submitter = document.createElement('input');
|
|
301
305
|
submitter.type = 'submit';
|
|
302
|
-
submitter.hidden = true;
|
|
303
306
|
if (this.formAction) {
|
|
304
307
|
submitter.setAttribute('formaction', this.formAction);
|
|
305
308
|
}
|
|
306
|
-
|
|
307
|
-
form.requestSubmit(submitter);
|
|
308
|
-
submitter.remove();
|
|
309
|
+
this.formControlController.submit(submitter);
|
|
309
310
|
} else if (this.formAction) {
|
|
310
311
|
// No parent form — create a temporary one to submit the priority data
|
|
311
312
|
const tempForm = document.createElement('form');
|
|
@@ -324,7 +325,9 @@ export default class ZnPriorityList extends ZincElement implements ZincFormContr
|
|
|
324
325
|
});
|
|
325
326
|
|
|
326
327
|
document.body.appendChild(tempForm);
|
|
327
|
-
|
|
328
|
+
// requestSubmit raises a cancellable submit event, so a host can handle
|
|
329
|
+
// the submission rather than the browser navigating to formaction.
|
|
330
|
+
tempForm.requestSubmit();
|
|
328
331
|
tempForm.remove();
|
|
329
332
|
}
|
|
330
333
|
}
|
|
@@ -179,4 +179,38 @@ describe('<zn-priority-list>', () => {
|
|
|
179
179
|
expect(item.getAttribute('draggable')).to.equal('false');
|
|
180
180
|
expect(item.getAttribute('tabindex')).to.equal('-1');
|
|
181
181
|
});
|
|
182
|
+
|
|
183
|
+
it('should announce its form before submitting a reorder, so a host can intercept it', async () => {
|
|
184
|
+
const form = await fixture(html`
|
|
185
|
+
<form action="/save" method="post">
|
|
186
|
+
<zn-priority-list name="sections" formaction="/save">
|
|
187
|
+
<div value="a">A</div>
|
|
188
|
+
<div value="b">B</div>
|
|
189
|
+
</zn-priority-list>
|
|
190
|
+
</form>
|
|
191
|
+
`) as HTMLFormElement;
|
|
192
|
+
|
|
193
|
+
const el = form.querySelector('zn-priority-list') as any;
|
|
194
|
+
await el.updateComplete;
|
|
195
|
+
|
|
196
|
+
const announced: Element[] = [];
|
|
197
|
+
const onRegister = (e: Event) => announced.push((e as CustomEvent).detail.element);
|
|
198
|
+
document.addEventListener('zn-register-element', onRegister);
|
|
199
|
+
|
|
200
|
+
let submitter: HTMLElement | null = null;
|
|
201
|
+
form.addEventListener('submit', (e: SubmitEvent) => {
|
|
202
|
+
submitter = e.submitter;
|
|
203
|
+
e.preventDefault();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const item = el.shadowRoot.querySelector('.priority-list__item');
|
|
207
|
+
item.dispatchEvent(new KeyboardEvent('keydown', {key: 'ArrowDown', bubbles: true, composed: true, cancelable: true}));
|
|
208
|
+
await el.updateComplete;
|
|
209
|
+
|
|
210
|
+
document.removeEventListener('zn-register-element', onRegister);
|
|
211
|
+
|
|
212
|
+
expect(announced).to.include(form);
|
|
213
|
+
expect(submitter).to.exist;
|
|
214
|
+
expect(submitter!.getAttribute('formaction')).to.equal('/save');
|
|
215
|
+
});
|
|
182
216
|
});
|
package/src/wc.scss
CHANGED
|
@@ -13,13 +13,16 @@
|
|
|
13
13
|
-webkit-font-smoothing: antialiased;
|
|
14
14
|
-moz-osx-font-smoothing: grayscale;
|
|
15
15
|
text-transform: none;
|
|
16
|
+
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
// Must stay at zero specificity: shadow roots that re-adopt the global sheet
|
|
19
|
+
// (zn-tabs, zn-data-table, editor toolbar) load it before this one, so a `:host *`
|
|
20
|
+
// reset would win the tie and strip borders off every global class.
|
|
21
|
+
*, *::before, *::after {
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
border-width: 0;
|
|
24
|
+
border-style: solid;
|
|
25
|
+
border-color: rgb(var(--zn-border-color));
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
[hidden] {
|