@kubex/zinc 1.1.127 → 1.1.129
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 +811 -791
- package/dist/vscode.html-custom-data.json +102 -102
- package/dist/web-types.json +214 -214
- package/dist/zn.d.ts +6 -0
- package/dist/zn.min.css +1 -1
- package/dist/zn.min.js +60 -60
- package/package.json +1 -1
- package/scss/themes/_light.scss +3 -0
- package/src/components/button/button.scss +2 -1
- package/src/components/header/header.scss +1 -2
- package/src/components/page-builder/page-builder.component.ts +15 -2
- package/src/components/page-builder/page-builder.test.ts +32 -0
- package/src/components/page-builder/page.types.ts +2 -1
package/package.json
CHANGED
package/scss/themes/_light.scss
CHANGED
|
@@ -191,6 +191,9 @@
|
|
|
191
191
|
--zn-focus-ring-width: 3px;
|
|
192
192
|
--zn-focus-ring: var(--zn-focus-ring-style) var(--zn-focus-ring-width) var(--zn-focus-ring-color);
|
|
193
193
|
--zn-focus-ring-offset: 1px;
|
|
194
|
+
// Space a focus ring needs outside a control's box, for boxes that clip around
|
|
195
|
+
// one. Must stay a plain length: overflow-clip-margin rejects calc(), silently 0.
|
|
196
|
+
--zn-focus-ring-outset: 4px;
|
|
194
197
|
|
|
195
198
|
/**************************************************************
|
|
196
199
|
* Forms
|
|
@@ -114,7 +114,8 @@
|
|
|
114
114
|
|
|
115
115
|
.button:focus-visible {
|
|
116
116
|
outline: 2px solid rgb(var(--btn-color));
|
|
117
|
-
|
|
117
|
+
// the token is a total (width + offset), not the offset itself
|
|
118
|
+
outline-offset: calc(var(--zn-focus-ring-outset) - 2px);
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
[disabled] {
|
|
@@ -131,8 +131,7 @@
|
|
|
131
131
|
flex-grow: 1;
|
|
132
132
|
flex-shrink: 1;
|
|
133
133
|
overflow-x: clip;
|
|
134
|
-
|
|
135
|
-
overflow-clip-margin: var(--zn-focus-ring-width);
|
|
134
|
+
overflow-clip-margin: var(--zn-focus-ring-outset);
|
|
136
135
|
overflow-y: visible;
|
|
137
136
|
min-width: 20px;
|
|
138
137
|
}
|
|
@@ -666,6 +666,19 @@ export default class ZnPageBuilder extends ZincElement {
|
|
|
666
666
|
this._commit({ sections: this._patchSection(id, s => ({ ...s, columns: next })) });
|
|
667
667
|
}
|
|
668
668
|
|
|
669
|
+
/**
|
|
670
|
+
* Snaps the field back to the width the container will use. A re-render alone
|
|
671
|
+
* would not: once the state already sits at a bound, an out-of-range entry
|
|
672
|
+
* changes nothing to re-render from.
|
|
673
|
+
*/
|
|
674
|
+
private _onColumnsEntered(section: PageSection, input: ZnInput) {
|
|
675
|
+
const type = this.registry.get(section.type);
|
|
676
|
+
if (type?.slotsMax === undefined) return;
|
|
677
|
+
const next = slotColumns({...section, columns: Number(input.value)}, type);
|
|
678
|
+
input.value = String(next);
|
|
679
|
+
this.setSectionColumns(section.id, next);
|
|
680
|
+
}
|
|
681
|
+
|
|
669
682
|
private _removeSection(id: string) {
|
|
670
683
|
if (this._isPinned(id)) return;
|
|
671
684
|
const [removed, sections] = this._extract(id);
|
|
@@ -1229,9 +1242,9 @@ export default class ZnPageBuilder extends ZincElement {
|
|
|
1229
1242
|
label="Slots per row"
|
|
1230
1243
|
min="${type.slotsMin ?? 1}"
|
|
1231
1244
|
max="${type.slotsMax}"
|
|
1232
|
-
help-text="A new row is added as the last one fills."
|
|
1245
|
+
help-text="Between ${type.slotsMin ?? 1} and ${type.slotsMax}. A new row is added as the last one fills."
|
|
1233
1246
|
.value="${String(slotColumns(section, type))}"
|
|
1234
|
-
@zn-change="${(e: Event) => this.
|
|
1247
|
+
@zn-change="${(e: Event) => this._onColumnsEntered(section, e.target as ZnInput)}"></zn-input>`}
|
|
1235
1248
|
${type?.renderConfig
|
|
1236
1249
|
? type.renderConfig(section, data => this._updateSectionData(section.id, data))
|
|
1237
1250
|
: this._form}
|
|
@@ -476,6 +476,38 @@ describe('<zn-page-builder>', () => {
|
|
|
476
476
|
.to.have.length(6);
|
|
477
477
|
});
|
|
478
478
|
|
|
479
|
+
it('should snap an out-of-range width back on every entry and state the range', async () => {
|
|
480
|
+
const el = await fixture<ZnPageBuilder>(html`
|
|
481
|
+
<zn-page-builder config='{"sections":[{"id":"row","type":"category-row","data":{}}]}'>
|
|
482
|
+
<template type="category-row" slot="config" label="Category Row" slots="3" slots-max="4"></template>
|
|
483
|
+
</zn-page-builder>`);
|
|
484
|
+
await el.updateComplete;
|
|
485
|
+
|
|
486
|
+
el.shadowRoot?.querySelector('.canvas zn-page-section-card')?.dispatchEvent(new Event('click'));
|
|
487
|
+
await el.updateComplete;
|
|
488
|
+
|
|
489
|
+
const width = el.shadowRoot!.querySelector<HTMLInputElement>('.inspector__slots')!;
|
|
490
|
+
expect(width.getAttribute('help-text'), 'the control names its range').to.contain('1 and 4');
|
|
491
|
+
|
|
492
|
+
const enter = async (value: string) => {
|
|
493
|
+
width.value = value;
|
|
494
|
+
width.dispatchEvent(new Event('zn-change', {bubbles: true}));
|
|
495
|
+
await el.updateComplete;
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
await enter('9');
|
|
499
|
+
expect(el.state.sections[0].columns, 'clamped to the max').to.equal(4);
|
|
500
|
+
expect(width.value, 'and shown clamped').to.equal('4');
|
|
501
|
+
|
|
502
|
+
await enter('9');
|
|
503
|
+
expect(width.value, 'a second over-max entry snaps back too').to.equal('4');
|
|
504
|
+
expect(el.state.sections[0].columns).to.equal(4);
|
|
505
|
+
|
|
506
|
+
await enter('0');
|
|
507
|
+
expect(el.state.sections[0].columns, 'clamped to the min').to.equal(1);
|
|
508
|
+
expect(width.value).to.equal('1');
|
|
509
|
+
});
|
|
510
|
+
|
|
479
511
|
it('should clamp a container width to the declared bounds', async () => {
|
|
480
512
|
const el = await fixture<ZnPageBuilder>(html`
|
|
481
513
|
<zn-page-builder config='{"sections":[{"id":"row","type":"category-row","data":{},"columns":99}]}'>
|
|
@@ -64,7 +64,8 @@ export const MAX_SLOTS = 24;
|
|
|
64
64
|
export function slotColumns(section: PageSection, type: PageSectionType): number {
|
|
65
65
|
const columns = type.slots ?? 0;
|
|
66
66
|
if (type.slotsMax === undefined) return columns;
|
|
67
|
-
|
|
67
|
+
const chosen = Math.round(Number(section.columns ?? NaN));
|
|
68
|
+
return Math.min(Math.max(Number.isFinite(chosen) ? chosen : columns, type.slotsMin ?? 1), type.slotsMax);
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
/**
|