@lion/ui 0.5.5 → 0.5.6
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/components/core/src/SlotMixin.js +5 -0
- package/components/core/test/SlotMixin.test.js +78 -1
- package/components/core/types/SlotMixinTypes.ts +8 -1
- package/custom-elements.json +479 -479
- package/dist-types/components/core/src/SlotMixin.d.ts.map +1 -1
- package/dist-types/components/core/types/SlotMixinTypes.d.ts +8 -1
- package/dist-types/components/core/types/SlotMixinTypes.d.ts.map +1 -1
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/checkbox-group/overview.md +2 -2
- package/docs/components/collapsible/overview.md +1 -1
- package/docs/components/combobox/overview.md +1 -1
- package/docs/components/combobox/use-cases.md +1 -1
- package/docs/components/dialog/overview.md +1 -1
- package/docs/components/fieldset/overview.md +5 -5
- package/docs/components/form/overview.md +3 -3
- package/docs/components/icon/use-cases.md +1 -1
- package/docs/components/input/overview.md +1 -1
- package/docs/components/input-amount/overview.md +3 -3
- package/docs/components/input-date/overview.md +3 -3
- package/docs/components/input-datepicker/overview.md +5 -5
- package/docs/components/input-email/overview.md +2 -2
- package/docs/components/input-file/overview.md +1 -1
- package/docs/components/input-iban/overview.md +2 -2
- package/docs/components/input-range/overview.md +2 -2
- package/docs/components/input-stepper/overview.md +1 -1
- package/docs/components/input-tel/overview.md +1 -1
- package/docs/components/input-tel/use-cases.md +6 -6
- package/docs/components/input-tel-dropdown/overview.md +1 -1
- package/docs/components/listbox/use-cases.md +1 -1
- package/docs/components/radio-group/overview.md +3 -3
- package/docs/components/select/use-cases.md +1 -1
- package/docs/components/select-rich/use-cases.md +1 -1
- package/docs/components/tabs/examples.md +1 -1
- package/docs/fundamentals/index.md +4 -4
- package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/overview.md +3 -3
- package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
- package/docs/fundamentals/rationales/accessibility.md +1 -1
- package/docs/fundamentals/systems/core/SlotMixin.md +8 -1
- package/docs/fundamentals/systems/core/overview.md +1 -1
- package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
- package/docs/fundamentals/systems/form/model-value.md +1 -1
- package/docs/fundamentals/systems/form/overview.md +28 -28
- package/docs/fundamentals/systems/form/validate.md +2 -2
- package/docs/fundamentals/systems/localize/overview.md +4 -4
- package/docs/fundamentals/systems/overlays/configuration.md +2 -2
- package/docs/fundamentals/systems/overlays/overview.md +5 -5
- package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
- package/docs/fundamentals/tools/helpers/overview.md +1 -1
- package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
- package/docs/guides/how-to/create-a-custom-field.md +5 -5
- package/docs/guides/how-to/create-a-form.md +4 -4
- package/docs/guides/how-to/extend-a-native-input.md +2 -2
- package/docs/guides/index.md +8 -8
- package/docs/guides/principles/index.md +5 -5
- package/docs/guides/principles/styling.md +1 -1
- package/package.json +2 -2
|
@@ -195,6 +195,11 @@ const SlotMixinImplementation = superclass =>
|
|
|
195
195
|
} else if (isRerenderConfig(slotFunctionResult)) {
|
|
196
196
|
// Rerenderable slots are scheduled in the "updated loop"
|
|
197
197
|
this.__slotsThatNeedRerender.add(slotName);
|
|
198
|
+
|
|
199
|
+
// For backw. compat, we allow a first render on connectedCallback
|
|
200
|
+
if (slotFunctionResult.firstRenderOnConnected) {
|
|
201
|
+
this.__rerenderSlot(slotName);
|
|
202
|
+
}
|
|
198
203
|
} else {
|
|
199
204
|
throw new Error(
|
|
200
205
|
`Slot "${slotName}" configured inside "get slots()" (in prototype) of ${this.constructor.name} may return these types: TemplateResult | Node | {template:TemplateResult, afterRender?:function} | undefined.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import sinon from 'sinon';
|
|
2
|
-
import { defineCE, expect, fixture, unsafeStatic, html } from '@open-wc/testing';
|
|
2
|
+
import { defineCE, expect, fixture, fixtureSync, unsafeStatic, html } from '@open-wc/testing';
|
|
3
3
|
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
|
|
4
4
|
import { SlotMixin } from '@lion/ui/core.js';
|
|
5
5
|
import { LitElement } from 'lit';
|
|
@@ -300,6 +300,83 @@ describe('SlotMixin', () => {
|
|
|
300
300
|
expect(document.activeElement).to.equal(el._focusableNode);
|
|
301
301
|
expect(el._focusableNode.shadowRoot.activeElement).to.equal(el._focusableNode._buttonNode);
|
|
302
302
|
});
|
|
303
|
+
|
|
304
|
+
describe('firstRenderOnConnected (for backwards compatibility)', () => {
|
|
305
|
+
it('does render on connected when firstRenderOnConnected:true', async () => {
|
|
306
|
+
// Start with elem that does not render on connectedCallback
|
|
307
|
+
const tag = defineCE(
|
|
308
|
+
// @ts-expect-error
|
|
309
|
+
class extends SlotMixin(LitElement) {
|
|
310
|
+
static properties = { currentValue: Number };
|
|
311
|
+
|
|
312
|
+
constructor() {
|
|
313
|
+
super();
|
|
314
|
+
this.currentValue = 0;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
get slots() {
|
|
318
|
+
return {
|
|
319
|
+
...super.slots,
|
|
320
|
+
template: () => ({
|
|
321
|
+
firstRenderOnConnected: true,
|
|
322
|
+
template: html`<span>${this.currentValue}</span> `,
|
|
323
|
+
}),
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
render() {
|
|
328
|
+
return html`<slot name="template"></slot>`;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
get _templateNode() {
|
|
332
|
+
return /** @type HTMLSpanElement */ (
|
|
333
|
+
Array.from(this.children).find(elm => elm.slot === 'template')
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
);
|
|
338
|
+
const el = /** @type {* & SlotHost} */ (fixtureSync(`<${tag}></${tag}>`));
|
|
339
|
+
expect(el._templateNode.slot).to.equal('template');
|
|
340
|
+
expect(el._templateNode.textContent?.trim()).to.equal('0');
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
it('does not render on connected when firstRenderOnConnected:false', async () => {
|
|
344
|
+
// Start with elem that does not render on connectedCallback
|
|
345
|
+
const tag = defineCE(
|
|
346
|
+
// @ts-expect-error
|
|
347
|
+
class extends SlotMixin(LitElement) {
|
|
348
|
+
static properties = { currentValue: Number };
|
|
349
|
+
|
|
350
|
+
constructor() {
|
|
351
|
+
super();
|
|
352
|
+
this.currentValue = 0;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
get slots() {
|
|
356
|
+
return {
|
|
357
|
+
...super.slots,
|
|
358
|
+
template: () => ({ template: html`<span>${this.currentValue}</span> ` }),
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
render() {
|
|
363
|
+
return html`<slot name="template"></slot>`;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
get _templateNode() {
|
|
367
|
+
return /** @type HTMLSpanElement */ (
|
|
368
|
+
Array.from(this.children).find(elm => elm.slot === 'template')
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
);
|
|
373
|
+
const el = /** @type {* & SlotHost} */ (fixtureSync(`<${tag}></${tag}>`));
|
|
374
|
+
expect(el._templateNode).to.be.undefined;
|
|
375
|
+
await el.updateComplete;
|
|
376
|
+
expect(el._templateNode.slot).to.equal('template');
|
|
377
|
+
expect(el._templateNode.textContent?.trim()).to.equal('0');
|
|
378
|
+
});
|
|
379
|
+
});
|
|
303
380
|
});
|
|
304
381
|
|
|
305
382
|
describe('SlotFunctionResult types', () => {
|
|
@@ -8,9 +8,16 @@ export type SlotRerenderObject = {
|
|
|
8
8
|
template: TemplateResult;
|
|
9
9
|
/**
|
|
10
10
|
* Add logic that will be performed after the render
|
|
11
|
-
* @deprecated
|
|
11
|
+
* @deprecated use regular ReactiveElement/LitElement reactive cycle callbacks instead
|
|
12
12
|
*/
|
|
13
13
|
afterRender?: Function;
|
|
14
|
+
/**
|
|
15
|
+
* For backward compat with traditional light render methods,
|
|
16
|
+
* it might be needed to have slot contents available in `connectedCallback`.
|
|
17
|
+
* Only enable this for existing components that rely on light content availability in connectedCallback.
|
|
18
|
+
* For new components, please align with ReactiveElement/LitElement reactive cycle callbacks.
|
|
19
|
+
*/
|
|
20
|
+
firstRenderOnConnected?: boolean;
|
|
14
21
|
};
|
|
15
22
|
|
|
16
23
|
export type SlotFunctionResult = TemplateResult | Element | SlotRerenderObject | undefined;
|