Skip to content

Commit dc1183b

Browse files
authored
Merge branch 'main' into feat/ssr/slot-controller-has-slotted
2 parents fb45fb4 + 0fb28b6 commit dc1183b

File tree

26 files changed

+165
-103
lines changed

26 files changed

+165
-103
lines changed

.changeset/dull-stingrays-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@patternfly/create-element": patch
3+
---
4+
5+
Fixed type errors in create-element template

.changeset/olive-rivers-stick.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
"@patternfly/pfe-core": patch
3+
---
4+
`SlotController`: `hasContent`/`isEmpty` now respects text nodes

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- name: Configure node version
5353
uses: actions/setup-node@v4
5454
with:
55-
node-version-file: .nvmrc
55+
node-version-file: '.nvmrc'
5656
cache: npm
5757

5858
- name: Install dependencies
@@ -73,7 +73,7 @@ jobs:
7373
- name: Configure node version
7474
uses: actions/setup-node@v4
7575
with:
76-
node-version-file: .nvmrc
76+
node-version-file: '.nvmrc'
7777
cache: npm
7878

7979
- name: Install dependencies
@@ -100,7 +100,7 @@ jobs:
100100
- uses: actions/checkout@v4
101101
- uses: actions/setup-node@v4
102102
with:
103-
node-version-file: .nvmrc
103+
node-version-file: '.nvmrc'
104104
cache: npm
105105
- run: npm ci --prefer-offline
106106
- run: npm run build

core/pfe-core/CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# @patternfly/pfe-core
22

3+
## 4.0.4
4+
5+
### Patch Changes
6+
7+
- 4a03ced: SSR: add shim for `ResizeObserver`
8+
9+
## 4.0.3
10+
11+
### Patch Changes
12+
13+
- 7c855a6: `TabsARIAController`: improve SSR compatibility
14+
15+
## 4.0.2
16+
17+
### Patch Changes
18+
19+
- 0ec7338: `OverflowController`: prevent browser from locking up in some scenarios
20+
321
## 4.0.1
422

523
### Patch Changes

core/pfe-core/controllers/overflow-controller.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ export class OverflowController implements ReactiveController {
4545
});
4646

4747
#ro = new ResizeObserver(() => {
48-
this.#setOverflowState();
48+
requestAnimationFrame(() => {
49+
this.#setOverflowState();
50+
});
4951
});
5052

5153
showScrollButtons = false;

core/pfe-core/controllers/slot-controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ export class SlotController implements ReactiveController {
201201
?? this.#getChildrenForSlot(name);
202202
const selector = slotName ? `slot[name="${slotName}"]` : 'slot:not([name])';
203203
const slot = this.host.shadowRoot?.querySelector?.<HTMLSlotElement>(selector) ?? null;
204-
const hasContent = !!elements.length;
204+
const nodes = slot?.assignedNodes?.();
205+
const hasContent = !!elements.length || !!nodes?.filter(x => x.textContent?.trim()).length;
205206
this.#nodes.set(name, { elements, name: slotName ?? '', hasContent, slot });
206207
this.#logger.debug(slotName, hasContent);
207208
};

core/pfe-core/controllers/tabs-aria-controller.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ReactiveController, ReactiveControllerHost } from 'lit';
1+
import { isServer, type ReactiveController, type ReactiveControllerHost } from 'lit';
22

33
import { Logger } from '@patternfly/pfe-core/controllers/logger.js';
44

@@ -19,7 +19,7 @@ export class TabsAriaController<
1919

2020
#host: ReactiveControllerHost;
2121

22-
#element: HTMLElement;
22+
#element!: HTMLElement;
2323

2424
#tabPanelMap = new Map<Tab, Panel>();
2525

@@ -52,6 +52,10 @@ export class TabsAriaController<
5252
) {
5353
this.#options = options;
5454
this.#logger = new Logger(host);
55+
(this.#host = host).addController(this);
56+
if (isServer) {
57+
return;
58+
}
5559
if (host instanceof HTMLElement) {
5660
this.#element = host;
5761
} else {
@@ -63,7 +67,6 @@ export class TabsAriaController<
6367
}
6468
this.#element = element;
6569
}
66-
(this.#host = host).addController(this);
6770
this.#element.addEventListener('slotchange', this.#onSlotchange);
6871
if (this.#element.isConnected) {
6972
this.hostConnected();
@@ -93,7 +96,7 @@ export class TabsAriaController<
9396
this.#tabPanelMap.clear();
9497
const tabs = [];
9598
const panels = [];
96-
for (const child of this.#element.children) {
99+
for (const child of this.#element?.children ?? []) {
97100
if (this.#options.isTab(child)) {
98101
tabs.push(child);
99102
child.role ??= 'tab';

core/pfe-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@patternfly/pfe-core",
3-
"version": "4.0.1",
3+
"version": "4.0.4",
44
"license": "MIT",
55
"description": "PatternFly Elements Core Library",
66
"customElements": "custom-elements.json",

core/pfe-core/ssr-shims.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ globalThis.IntersectionObserver ??= ObserverShim;
4141
// @ts-expect-error: this runs in node
4242
globalThis.MutationObserver ??= ObserverShim;
4343
// @ts-expect-error: this runs in node
44+
globalThis.ResizeObserver ??= ObserverShim;
45+
// @ts-expect-error: this runs in node
4446
globalThis.getComputedStyle ??= function() {
4547
return {
4648
getPropertyPriority() {

docs/_data/importMap.cjs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ module.exports = async function() {
8585
const map = generator.getMap();
8686
map.imports['/docs/zero-md.js'] = '/zero-md.js';
8787
map.imports['@patternfly/elements'] = '/pfe.min.js';
88+
map.imports['@patternfly/pfe-core'] = '/pfe.min.js';
89+
map.imports['@patternfly/icons/'] = '/assets/@patternfly/icons/';
90+
map.imports['@patternfly/pfe-core/decorators.js'] = '/pfe.min.js';
91+
map.imports['@patternfly/pfe-tools/environment.js'] = '/tools/environment.js';
92+
map.imports['lit/'] = map.imports.lit.replace('index.js', '');
93+
map.scopes['https://cdn.jsdelivr.net/'].lit = map.imports.lit;
94+
map.scopes['https://cdn.jsdelivr.net/']['lit/'] = map.imports.lit.replace('index.js', '');
8895

8996
// add imports for imports under pfe-core
9097
const pfeCoreImports = (await glob('./{functions,controllers,decorators}/*.ts', {
@@ -110,20 +117,5 @@ module.exports = async function() {
110117
}
111118
}
112119
}
113-
114-
map.imports['@patternfly/pfe-tools/environment.js'] = '/tools/environment.js';
115-
116-
117-
// add imports for all icon files in /node_modules/@patternfly/icons/{far, fas, fab, patternfly}/
118-
const iconsImports = (await glob('./{far,fas,fab,patternfly}/*.js', {
119-
cwd: path.join(__dirname, '../../node_modules/@patternfly/icons'),
120-
}))
121-
.filter(x => !x.endsWith('.d.ts'))
122-
.map(x => x);
123-
124-
for (const icon of iconsImports) {
125-
map.imports[`@patternfly/icons/${icon}`] = `/assets/@patternfly/icons/${icon}`;
126-
}
127-
128120
return map;
129121
};

0 commit comments

Comments
 (0)