Skip to content

Commit 3fccbfd

Browse files
committed
Merge branch 'main' into feat-components
2 parents 8a3b9a8 + e0777f5 commit 3fccbfd

25 files changed

+605
-15
lines changed

bindings/devup-ui-wasm/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @devup-ui/wasm
22

3+
## 1.0.10
4+
5+
### Patch Changes
6+
7+
- f6d3f0a: Support nested selector
8+
- 373fb4e: Fix className issue (multiple selectors)
9+
310
## 1.0.9
411

512
### Patch Changes

bindings/devup-ui-wasm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"react",
1818
"wasm"
1919
],
20-
"version": "1.0.9",
20+
"version": "1.0.10",
2121
"scripts": {
2222
"build": "wasm-pack build --target nodejs --out-dir ./pkg --out-name index && node script.js",
2323
"test": "wasm-pack test --node"

libs/extractor/src/lib.rs

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,204 @@ import clsx from 'clsx'
13511351
)
13521352
.unwrap()
13531353
));
1354+
1355+
reset_class_map();
1356+
assert_debug_snapshot!(ToBTreeSet::from(
1357+
extract(
1358+
"test.tsx",
1359+
r"import {Center} from '@devup-ui/core'
1360+
<Center
1361+
_active={
1362+
variant !== 'disabled' && {
1363+
boxShadow: 'none',
1364+
transform: 'scale(0.95)',
1365+
}
1366+
}
1367+
_hover={
1368+
variant !== 'disabled' && {
1369+
boxShadow: [
1370+
'0px 1px 3px 0px rgba(0, 0, 0, 0.25)',
1371+
null,
1372+
'0px 0px 15px 0px rgba(0, 0, 0, 0.25)',
1373+
],
1374+
}
1375+
}
1376+
{...props}
1377+
>
1378+
{children}
1379+
</Center>
1380+
",
1381+
ExtractOption {
1382+
package: "@devup-ui/core".to_string(),
1383+
css_file: None
1384+
}
1385+
)
1386+
.unwrap()
1387+
));
1388+
}
1389+
1390+
#[test]
1391+
#[serial]
1392+
fn extract_nested_selector() {
1393+
reset_class_map();
1394+
assert_debug_snapshot!(ToBTreeSet::from(
1395+
extract(
1396+
"test.tsx",
1397+
r#"import {Box} from '@devup-ui/core'
1398+
<Box _hover={{
1399+
_placeholder: {
1400+
color: "red"
1401+
}
1402+
}} />
1403+
"#,
1404+
ExtractOption {
1405+
package: "@devup-ui/core".to_string(),
1406+
css_file: None
1407+
}
1408+
)
1409+
.unwrap()
1410+
));
1411+
1412+
reset_class_map();
1413+
assert_debug_snapshot!(ToBTreeSet::from(
1414+
extract(
1415+
"test.tsx",
1416+
r#"import {Box} from '@devup-ui/core'
1417+
<Box _hover={{
1418+
selectors: {
1419+
"&::placeholder, &:active": {
1420+
color: "blue"
1421+
}
1422+
},
1423+
}} />
1424+
"#,
1425+
ExtractOption {
1426+
package: "@devup-ui/core".to_string(),
1427+
css_file: None
1428+
}
1429+
)
1430+
.unwrap()
1431+
));
1432+
1433+
reset_class_map();
1434+
assert_debug_snapshot!(ToBTreeSet::from(
1435+
extract(
1436+
"test.tsx",
1437+
r#"import {Box} from '@devup-ui/core'
1438+
<Box _hover={{
1439+
selectors: {
1440+
"&::placeholder": {
1441+
color: "red"
1442+
},
1443+
"&::placeholder, &:active": {
1444+
color: "blue"
1445+
}
1446+
},
1447+
}} />
1448+
"#,
1449+
ExtractOption {
1450+
package: "@devup-ui/core".to_string(),
1451+
css_file: None
1452+
}
1453+
)
1454+
.unwrap()
1455+
));
1456+
1457+
reset_class_map();
1458+
assert_debug_snapshot!(ToBTreeSet::from(
1459+
extract(
1460+
"test.tsx",
1461+
r#"import {Box} from '@devup-ui/core'
1462+
<Box _hover={{
1463+
selectors: {
1464+
"&::placeholder": {
1465+
_active: {
1466+
color: "red",
1467+
}
1468+
},
1469+
},
1470+
}} />
1471+
"#,
1472+
ExtractOption {
1473+
package: "@devup-ui/core".to_string(),
1474+
css_file: None
1475+
}
1476+
)
1477+
.unwrap()
1478+
));
1479+
1480+
reset_class_map();
1481+
assert_debug_snapshot!(ToBTreeSet::from(
1482+
extract(
1483+
"test.tsx",
1484+
r#"import {Box} from '@devup-ui/core'
1485+
<Box
1486+
selectors={{
1487+
"&::placeholder": {
1488+
_active: {
1489+
color: "red",
1490+
}
1491+
},
1492+
}} />
1493+
"#,
1494+
ExtractOption {
1495+
package: "@devup-ui/core".to_string(),
1496+
css_file: None
1497+
}
1498+
)
1499+
.unwrap()
1500+
));
1501+
1502+
reset_class_map();
1503+
assert_debug_snapshot!(ToBTreeSet::from(
1504+
extract(
1505+
"test.tsx",
1506+
r#"import {Box} from '@devup-ui/core'
1507+
<Box
1508+
selectors={{
1509+
"&::placeholder": {
1510+
selectors: {
1511+
"&:active": {
1512+
selectors: {
1513+
"&:hover": {
1514+
color: "red",
1515+
}
1516+
}
1517+
}
1518+
}
1519+
},
1520+
}} />
1521+
"#,
1522+
ExtractOption {
1523+
package: "@devup-ui/core".to_string(),
1524+
css_file: None
1525+
}
1526+
)
1527+
.unwrap()
1528+
));
1529+
1530+
reset_class_map();
1531+
assert_debug_snapshot!(ToBTreeSet::from(
1532+
extract(
1533+
"test.tsx",
1534+
r#"import {Box} from '@devup-ui/core'
1535+
<Box
1536+
_placeholder={{
1537+
_active: {
1538+
_hover: {
1539+
color: "blue",
1540+
},
1541+
color: "red",
1542+
},
1543+
}} />
1544+
"#,
1545+
ExtractOption {
1546+
package: "@devup-ui/core".to_string(),
1547+
css_file: None
1548+
}
1549+
)
1550+
.unwrap()
1551+
));
13541552
}
13551553

13561554
#[test]
@@ -2802,6 +3000,37 @@ import {Button} from '@devup/ui'
28023000
));
28033001
}
28043002

3003+
#[test]
3004+
#[serial]
3005+
fn nested_theme_props() {
3006+
reset_class_map();
3007+
assert_debug_snapshot!(ToBTreeSet::from(
3008+
extract(
3009+
"test.jsx",
3010+
r#"import {Box} from '@devup-ui/core'
3011+
<Box _themeDark={{
3012+
selectors: {
3013+
"&:hover": {
3014+
color: "red",
3015+
}
3016+
},
3017+
_active: {
3018+
color: "blue",
3019+
_placeholder: {
3020+
color: "green",
3021+
},
3022+
},
3023+
}} />
3024+
"#,
3025+
ExtractOption {
3026+
package: "@devup-ui/core".to_string(),
3027+
css_file: None
3028+
}
3029+
)
3030+
.unwrap()
3031+
));
3032+
}
3033+
28053034
#[test]
28063035
#[serial]
28073036
fn template_literal_props() {

libs/extractor/src/prop_modify_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ fn merge_string_expressions<'a>(
325325
}
326326
} else {
327327
let prefix = if idx == 0 { "" } else { " " };
328-
let suffix = if string_literals.len() == other_expressions.len() {
328+
let suffix = if string_literals.len() <= other_expressions.len() {
329329
" "
330330
} else {
331331
""
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import {Box} from '@devup-ui/core'\n <Box _hover={{\n selectors: {\n \"&::placeholder, &:active\": {\n color: \"blue\"\n }\n },\n }} />\n \"#,\nExtractOption\n{ package: \"@devup-ui/core\".to_string(), css_file: None }).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {
7+
Static(
8+
ExtractStaticStyle {
9+
property: "color",
10+
value: "blue",
11+
level: 0,
12+
selector: Some(
13+
Selector(
14+
"&:hover::placeholder, &:hover:active",
15+
),
16+
),
17+
style_order: None,
18+
},
19+
),
20+
},
21+
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"d0\" />;\n",
22+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import {Box} from '@devup-ui/core'\n <Box _hover={{\n selectors: {\n \"&::placeholder\": {\n color: \"red\"\n },\n \"&::placeholder, &:active\": {\n color: \"blue\"\n }\n },\n }} />\n \"#,\nExtractOption\n{ package: \"@devup-ui/core\".to_string(), css_file: None }).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {
7+
Static(
8+
ExtractStaticStyle {
9+
property: "color",
10+
value: "blue",
11+
level: 0,
12+
selector: Some(
13+
Selector(
14+
"&:hover::placeholder, &:hover:active",
15+
),
16+
),
17+
style_order: None,
18+
},
19+
),
20+
Static(
21+
ExtractStaticStyle {
22+
property: "color",
23+
value: "red",
24+
level: 0,
25+
selector: Some(
26+
Selector(
27+
"&:hover::placeholder",
28+
),
29+
),
30+
style_order: None,
31+
},
32+
),
33+
},
34+
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"d0 d1\" />;\n",
35+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import {Box} from '@devup-ui/core'\n <Box _hover={{\n selectors: {\n \"&::placeholder\": {\n _active: {\n color: \"red\",\n }\n },\n },\n }} />\n \"#,\nExtractOption\n{ package: \"@devup-ui/core\".to_string(), css_file: None }).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {
7+
Static(
8+
ExtractStaticStyle {
9+
property: "color",
10+
value: "red",
11+
level: 0,
12+
selector: Some(
13+
Selector(
14+
"&:hover::placeholder:active",
15+
),
16+
),
17+
style_order: None,
18+
},
19+
),
20+
},
21+
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"d0\" />;\n",
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
source: libs/extractor/src/lib.rs
3+
expression: "ToBTreeSet::from(extract(\"test.tsx\",\nr#\"import {Box} from '@devup-ui/core'\n <Box \n selectors={{\n \"&::placeholder\": {\n _active: {\n color: \"red\",\n }\n },\n }} />\n \"#,\nExtractOption\n{ package: \"@devup-ui/core\".to_string(), css_file: None }).unwrap())"
4+
---
5+
ToBTreeSet {
6+
styles: {
7+
Static(
8+
ExtractStaticStyle {
9+
property: "color",
10+
value: "red",
11+
level: 0,
12+
selector: Some(
13+
Selector(
14+
"&::placeholder:active",
15+
),
16+
),
17+
style_order: None,
18+
},
19+
),
20+
},
21+
code: "import \"@devup-ui/core/devup-ui.css\";\n<div className=\"d0\" />;\n",
22+
}

0 commit comments

Comments
 (0)