Skip to content

Commit 4215808

Browse files
committed
Merge branch 'Add-Figma-Changelog-entry-for-4.15.0' of https://github.com/hashicorp/design-system into Add-Figma-Changelog-entry-for-4.15.0
2 parents 47be9a5 + fa0ab60 commit 4215808

File tree

285 files changed

+12082
-10646
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+12082
-10646
lines changed

.changeset/cold-humans-mix.md

-5
This file was deleted.

.changeset/gorgeous-days-call.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hashicorp/design-system-components": minor
3+
---
4+
5+
`Table` - Updated the visual design of `Table` cells by adding borders, making them more distinguishable when spanning rows or columns.

.changeset/lovely-goats-work.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hashicorp/design-system-components": patch
3+
---
4+
5+
`Table` - fixed the aria-labels for select row and select all checkboxes so they do not change based on the state of the checkbox.

.changeset/smart-seahorses-cough.md

-5
This file was deleted.

.changeset/sweet-penguins-shave.md

-5
This file was deleted.

.changeset/thin-games-doubt.md

-5
This file was deleted.

.yarn/releases/yarn-4.4.0.cjs

-925
This file was deleted.

.yarn/releases/yarn-4.5.3.cjs

+934
Large diffs are not rendered by default.

.yarnrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ enableGlobalCache: false
44

55
nodeLinker: node-modules
66

7-
yarnPath: .yarn/releases/yarn-4.4.0.cjs
7+
yarnPath: .yarn/releases/yarn-4.5.3.cjs

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Note: If you want to ignore a changeset bump in terminal (e.g. major bump for se
9090

9191
## Releasing
9292

93-
See the [release docs](packages/components/RELEASE.md) for the process we follow to publish a new package version.
93+
See the [release docs](https://hashicorp.atlassian.net/wiki/x/HIBT0Q) for the process we follow to publish a new package version.
9494

9595
## License
9696

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"release-packages": "yarn changeset publish",
1717
"version-packages": "yarn changeset version && yarn install --mode update-lockfile && yarn workspace website generate-changelog-markdown-files"
1818
},
19-
"packageManager": "yarn@4.4.0",
19+
"packageManager": "yarn@4.5.3",
2020
"resolutions": {
2121
"broccoli-asset-rewrite@^2.0.0": "patch:broccoli-asset-rewrite@npm%3A2.0.0#./.yarn/patches/broccoli-asset-rewrite-npm-2.0.0-c4ce42084a.patch",
2222
"@glint/environment-ember-loose": "patch:@glint/environment-ember-loose@npm%3A1.4.0#~/.yarn/patches/@glint-environment-ember-loose-npm-1.4.0-31c2f31bcb.patch"

packages/codemods/CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# @hashicorp/design-system-codemods
22

3+
## 0.5.0
4+
5+
### Minor Changes
6+
7+
Update `v4/dropdown-list-item-interactive` codemod to successfully parse nested content blocks such as conditionals
8+
9+
<small class="doc-whats-new-changelog-metadata">[#2575](https://github.com/hashicorp/design-system/pull/2575)</small>
10+
11+
<div class="doc-whats-new-changelog-separator"></div>
12+
313
## 0.4.0
414

515
### Minor Changes

packages/codemods/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ node ./packages/codemods/bin/cli.js v3/dropdown path/to/some/glob/**/*.hbs
3030
### v4
3131
<!--TRANSFORMS_START-->
3232
* [v4/contextual-components](transforms/v4/contextual-components/README.md)
33+
* [v4/dropdown-list-item-interactive](transforms/v4/dropdown-list-item-interactive/README.md)
3334
* [v4/table](transforms/v4/table/README.md)
3435
* [v4/icon](transforms/v4/icon/README.md)
3536
<!--TRANSFORMS_END-->

packages/codemods/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@hashicorp/design-system-codemods",
33
"description": "Helios Design System codemods",
4-
"version": "0.4.0",
4+
"version": "0.5.0",
55
"scripts": {
66
"lint": "eslint --cache .",
77
"lint:fix": "eslint . --fix",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{!
2+
Copyright (c) HashiCorp, Inc.
3+
SPDX-License-Identifier: MPL-2.0
4+
}}
5+
<Hds::Dropdown as |dd|>
6+
<dd.Title @text='Title text' />
7+
{{#if this.conditional}}
8+
<dd.Interactive @href='#' @text='Test' />
9+
{{/if}}
10+
</Hds::Dropdown>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{!
2+
Copyright (c) HashiCorp, Inc.
3+
SPDX-License-Identifier: MPL-2.0
4+
}}
5+
<Hds::Dropdown as |dd|>
6+
<dd.Title @text='Title text' />
7+
{{#if this.conditional}}
8+
<dd.Interactive @href='#'>Test</dd.Interactive>
9+
{{/if}}
10+
</Hds::Dropdown>

packages/codemods/transforms/v4/dropdown-list-item-interactive/index.js

+99-72
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,85 @@
55

66
const CODEMOD_ANALYSIS = process.env.CODEMOD_ANALYSIS;
77

8+
function processChildren(children, asPrefix, b) {
9+
let hasUpdatedChildren = false;
10+
let processedChildren = [];
11+
12+
children.forEach((child) => {
13+
let updatedChild;
14+
let isProcessed = false;
15+
16+
// Check if the child is an ElementNode with the specified tag
17+
if (child.type === 'ElementNode' && child.tag === `${asPrefix}.Interactive`) {
18+
const textAttr = child.attributes.find((a) => a.name === '@text');
19+
20+
if (textAttr) {
21+
const childOutputAttributes = child.attributes.filter((a) => a.name !== '@text');
22+
23+
const isHandlebarsAttr = textAttr.value.type === 'MustacheStatement';
24+
25+
let children = [];
26+
27+
// Handle different types of MustacheStatement values
28+
if (isHandlebarsAttr) {
29+
if (textAttr.value.path.type === 'NumberLiteral') {
30+
children = [b.mustache(b.number(textAttr.value.path.value))];
31+
} else if (textAttr.value.path.type === 'StringLiteral') {
32+
children = [b.mustache(b.string(textAttr.value.path.value))];
33+
} else {
34+
children = [
35+
b.mustache(
36+
textAttr.value.path.original,
37+
[...textAttr.value.params],
38+
textAttr.value.hash
39+
),
40+
];
41+
}
42+
} else {
43+
children = [b.text(textAttr.value.chars)];
44+
}
45+
46+
// Create a new element with the updated children and attributes
47+
updatedChild = b.element(
48+
{ name: child.tag, selfClosing: false },
49+
{
50+
children,
51+
attrs: childOutputAttributes,
52+
modifiers: child.modifiers,
53+
blockParams: child.blockParams,
54+
}
55+
);
56+
57+
isProcessed = true;
58+
} else {
59+
updatedChild = child;
60+
}
61+
} else if (child.type === 'BlockStatement') {
62+
// Recursively process children of BlockStatement nodes
63+
const { hasUpdatedChildren: nestedHasUpdated, processedChildren: nestedProcessed } =
64+
processChildren(child.program.body, asPrefix, b);
65+
66+
if (nestedHasUpdated) {
67+
updatedChild = b.block(
68+
child.path,
69+
child.params,
70+
child.hash,
71+
b.program(nestedProcessed, child.program.blockParams),
72+
child.inverse
73+
);
74+
isProcessed = true;
75+
} else {
76+
updatedChild = child;
77+
}
78+
}
79+
80+
processedChildren.push(updatedChild || child);
81+
hasUpdatedChildren = hasUpdatedChildren || isProcessed;
82+
});
83+
84+
return { hasUpdatedChildren, processedChildren };
85+
}
86+
887
module.exports = function ({ source /*, path*/ }, { parse, visit }) {
988
const ast = parse(source);
1089

@@ -13,85 +92,33 @@ module.exports = function ({ source /*, path*/ }, { parse, visit }) {
1392

1493
return {
1594
ElementNode(node) {
95+
// Check if the node is an Hds::Dropdown element
1696
if (node.type === 'ElementNode' && node.tag === 'Hds::Dropdown') {
17-
let hasUpdatedChildren = false;
18-
let processedChildren;
19-
2097
if (node.blockParams && node.blockParams.length > 0) {
2198
const asPrefix = node.blockParams[0];
2299

23-
processedChildren = [];
24-
25-
if (node.children) {
26-
node.children.forEach((child) => {
27-
let updatedChild;
28-
let isProcessed = false;
29-
30-
if (child.type === 'ElementNode' && child.tag === `${asPrefix}.Interactive`) {
31-
const textAttr = child.attributes.find((a) => a.name === '@text');
32-
33-
if (textAttr) {
34-
const childOutputAttributes = child.attributes.filter(
35-
(a) => a.name !== '@text'
36-
);
37-
38-
const isHandlebarsAttr = textAttr.value.type === 'MustacheStatement';
39-
40-
let children = [];
41-
42-
if (isHandlebarsAttr) {
43-
if (textAttr.value.path.type === 'NumberLiteral') {
44-
children = [b.mustache(b.number(textAttr.value.path.value))];
45-
} else if (textAttr.value.path.type === 'StringLiteral') {
46-
children = [b.mustache(b.string(textAttr.value.path.value))];
47-
} else {
48-
children = [
49-
b.mustache(
50-
textAttr.value.path.original,
51-
[...textAttr.value.params],
52-
textAttr.value.hash
53-
),
54-
];
55-
}
56-
} else {
57-
children = [b.text(textAttr.value.chars)];
58-
}
59-
60-
updatedChild = b.element(
61-
{ name: child.tag, selfClosing: false },
62-
{
63-
children,
64-
attrs: childOutputAttributes,
65-
modifiers: child.modifiers,
66-
blockParams: child.blockParams,
67-
}
68-
);
69-
70-
isProcessed = true;
71-
} else {
72-
updatedChild = child;
100+
// Process the children of the Hds::Dropdown element
101+
const { hasUpdatedChildren, processedChildren } = processChildren(
102+
node.children,
103+
asPrefix,
104+
b
105+
);
106+
107+
// Return the updated element if any children were updated
108+
if (hasUpdatedChildren && !CODEMOD_ANALYSIS) {
109+
return [
110+
b.element(
111+
{ name: node.tag, selfClosing: false },
112+
{
113+
attrs: node.attributes,
114+
children: processedChildren,
115+
modifiers: node.modifiers,
116+
blockParams: node.blockParams,
73117
}
74-
}
75-
76-
processedChildren.push(updatedChild || child);
77-
hasUpdatedChildren = hasUpdatedChildren || isProcessed;
78-
});
118+
),
119+
];
79120
}
80121
}
81-
82-
if (hasUpdatedChildren && !CODEMOD_ANALYSIS) {
83-
return [
84-
b.element(
85-
{ name: node.tag, selfClosing: false },
86-
{
87-
attrs: node.attributes,
88-
children: processedChildren || node.children,
89-
modifiers: node.modifiers,
90-
blockParams: node.blockParams,
91-
}
92-
),
93-
];
94-
}
95122
}
96123
},
97124
};

0 commit comments

Comments
 (0)