@dafaz-ui/react 6.0.5 → 7.0.1
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/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +12 -0
- package/dist/index.js +78 -71
- package/dist/index.mjs +78 -71
- package/package.json +1 -1
- package/src/components/MultiSelect/index.tsx +24 -21
- package/src/components/MultiSelect/styles.ts +48 -18
- package/src/components/Select/index.tsx +1 -1
- package/src/components/Select/styles.ts +2 -0
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> @dafaz-ui/react@
|
2
|
+
> @dafaz-ui/react@7.0.1 build
|
3
3
|
> tsup src/index.tsx --format esm,cjs --dts --external react
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: src/index.tsx
|
@@ -8,11 +8,11 @@
|
|
8
8
|
[34mCLI[39m Target: es6
|
9
9
|
[34mESM[39m Build start
|
10
10
|
[34mCJS[39m Build start
|
11
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
12
|
-
[32mCJS[39m ⚡️ Build success in
|
13
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m35.
|
14
|
-
[32mESM[39m ⚡️ Build success in
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m38.97 KB[39m
|
12
|
+
[32mCJS[39m ⚡️ Build success in 46ms
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m35.70 KB[39m
|
14
|
+
[32mESM[39m ⚡️ Build success in 46ms
|
15
15
|
[34mDTS[39m Build start
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
16
|
+
[32mDTS[39m ⚡️ Build success in 4727ms
|
17
17
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m121.54 KB[39m
|
18
18
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m121.54 KB[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
@@ -55,26 +55,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
55
55
|
mod
|
56
56
|
));
|
57
57
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
58
|
-
var __async = (__this, __arguments, generator) => {
|
59
|
-
return new Promise((resolve, reject) => {
|
60
|
-
var fulfilled = (value) => {
|
61
|
-
try {
|
62
|
-
step(generator.next(value));
|
63
|
-
} catch (e) {
|
64
|
-
reject(e);
|
65
|
-
}
|
66
|
-
};
|
67
|
-
var rejected = (value) => {
|
68
|
-
try {
|
69
|
-
step(generator.throw(value));
|
70
|
-
} catch (e) {
|
71
|
-
reject(e);
|
72
|
-
}
|
73
|
-
};
|
74
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
75
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
76
|
-
});
|
77
|
-
};
|
78
58
|
|
79
59
|
// src/index.tsx
|
80
60
|
var src_exports = {};
|
@@ -904,6 +884,7 @@ var SelectUI = styled("select", {
|
|
904
884
|
maxWidth: "24.5rem",
|
905
885
|
margin: 0,
|
906
886
|
padding: "$1 $1",
|
887
|
+
marginLeft: "$1",
|
907
888
|
"&:disabled": {
|
908
889
|
opacity: 0.5
|
909
890
|
},
|
@@ -988,7 +969,7 @@ var Select = (0, import_react8.forwardRef)(
|
|
988
969
|
display: "flex",
|
989
970
|
alignItems: "center",
|
990
971
|
paddingLeft: "1rem",
|
991
|
-
marginRight: "0.
|
972
|
+
marginRight: "0.7rem",
|
992
973
|
marginLeft: "-3rem"
|
993
974
|
},
|
994
975
|
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react7.CaretDown, { size: 24, weight: "bold" })
|
@@ -1353,7 +1334,38 @@ TextInput.displayName = "TextInput";
|
|
1353
1334
|
var import_react12 = require("@phosphor-icons/react");
|
1354
1335
|
|
1355
1336
|
// src/components/MultiSelect/styles.ts
|
1337
|
+
var Button2 = styled("button", {
|
1338
|
+
backgroundColor: "transparent",
|
1339
|
+
border: "none",
|
1340
|
+
display: "flex",
|
1341
|
+
alignItems: "center",
|
1342
|
+
justifyContent: "center",
|
1343
|
+
color: "white",
|
1344
|
+
marginBottom: "-3px",
|
1345
|
+
cursor: "pointer",
|
1346
|
+
zIndex: 5,
|
1347
|
+
variants: {
|
1348
|
+
size: {
|
1349
|
+
lg: {
|
1350
|
+
height: "$10",
|
1351
|
+
width: "$10"
|
1352
|
+
},
|
1353
|
+
md: {
|
1354
|
+
height: "$8",
|
1355
|
+
width: "$8"
|
1356
|
+
},
|
1357
|
+
sm: {
|
1358
|
+
height: "$6",
|
1359
|
+
width: "$6"
|
1360
|
+
}
|
1361
|
+
}
|
1362
|
+
},
|
1363
|
+
defaultVariants: {
|
1364
|
+
size: "lg"
|
1365
|
+
}
|
1366
|
+
});
|
1356
1367
|
var SelectUI2 = styled("div", {
|
1368
|
+
zIndex: 3,
|
1357
1369
|
width: "100%",
|
1358
1370
|
maxWidth: "24.5rem",
|
1359
1371
|
position: "relative",
|
@@ -1368,21 +1380,12 @@ var SelectUI2 = styled("div", {
|
|
1368
1380
|
borderRadius: "$md",
|
1369
1381
|
boxSizing: "border-box",
|
1370
1382
|
transition: "border 0.2s linear",
|
1371
|
-
padding: "$1 $2",
|
1372
1383
|
boxShadow: "0 3px 2px -2px $colors$gray400",
|
1373
1384
|
"&:hover": {
|
1374
1385
|
borderBottom: "2px solid $dafaz400"
|
1375
1386
|
},
|
1376
1387
|
"&.clicked": {
|
1377
|
-
borderBottom: "2px solid $dafaz400"
|
1378
|
-
"&:hover": {
|
1379
|
-
"> div": {
|
1380
|
-
display: "flex",
|
1381
|
-
flexDirection: "column",
|
1382
|
-
alignItems: "start",
|
1383
|
-
gap: "$3"
|
1384
|
-
}
|
1385
|
-
}
|
1388
|
+
borderBottom: "2px solid $dafaz400"
|
1386
1389
|
},
|
1387
1390
|
variants: {
|
1388
1391
|
disabled: {
|
@@ -1421,15 +1424,13 @@ var SelectUI2 = styled("div", {
|
|
1421
1424
|
}
|
1422
1425
|
});
|
1423
1426
|
var SelectContainerUI = styled("div", {
|
1424
|
-
marginTop: "0.4rem",
|
1425
|
-
marginLeft: "-0.5rem",
|
1426
1427
|
padding: "$3 $2",
|
1428
|
+
marginTop: "2px",
|
1427
1429
|
border: "1px solid $gray400",
|
1428
1430
|
boxSizing: "border-box",
|
1429
1431
|
borderRadius: "$md",
|
1430
|
-
display: "none",
|
1431
1432
|
position: "absolute",
|
1432
|
-
zIndex:
|
1433
|
+
zIndex: 2,
|
1433
1434
|
minWidth: "100%",
|
1434
1435
|
maxWidth: "24.5rem",
|
1435
1436
|
background: "$gray800",
|
@@ -1437,10 +1438,12 @@ var SelectContainerUI = styled("div", {
|
|
1437
1438
|
color: "$white",
|
1438
1439
|
fontWeight: "$regular",
|
1439
1440
|
cursor: "pointer",
|
1440
|
-
"
|
1441
|
+
"&.closed": {
|
1442
|
+
display: "none"
|
1443
|
+
},
|
1444
|
+
"&.opened": {
|
1441
1445
|
display: "flex",
|
1442
1446
|
flexDirection: "column",
|
1443
|
-
alignItems: "start",
|
1444
1447
|
gap: "$3"
|
1445
1448
|
}
|
1446
1449
|
});
|
@@ -1456,6 +1459,7 @@ var MultiSelect = (0, import_react13.forwardRef)(
|
|
1456
1459
|
]);
|
1457
1460
|
const [selectedValue, setSelectedValue] = (0, import_react13.useState)([""]);
|
1458
1461
|
const [clickClass, setClickClass] = (0, import_react13.useState)(false);
|
1462
|
+
const [isClose, setIsClosed] = (0, import_react13.useState)(true);
|
1459
1463
|
(0, import_react13.useEffect)(() => {
|
1460
1464
|
items.map(
|
1461
1465
|
(item) => setValues((state) => {
|
@@ -1493,7 +1497,6 @@ var MultiSelect = (0, import_react13.forwardRef)(
|
|
1493
1497
|
});
|
1494
1498
|
}, [values, items, setValues]);
|
1495
1499
|
function handleOnValueChange(id2) {
|
1496
|
-
setClickClass(() => false);
|
1497
1500
|
setValues((state) => {
|
1498
1501
|
const items2 = state.filter((item2) => item2.id !== id2);
|
1499
1502
|
const item = state.find((item2) => item2.id === id2);
|
@@ -1530,8 +1533,10 @@ var MultiSelect = (0, import_react13.forwardRef)(
|
|
1530
1533
|
}
|
1531
1534
|
function handleOnClick() {
|
1532
1535
|
setClickClass((state) => !state);
|
1536
|
+
setIsClosed((state) => !state);
|
1533
1537
|
}
|
1534
1538
|
function handleRemoveItem(e, id2) {
|
1539
|
+
setIsClosed(true);
|
1535
1540
|
handleOnValueChange(id2);
|
1536
1541
|
}
|
1537
1542
|
function updateSelectComponent(item) {
|
@@ -1552,35 +1557,27 @@ var MultiSelect = (0, import_react13.forwardRef)(
|
|
1552
1557
|
id,
|
1553
1558
|
size,
|
1554
1559
|
onClick: handleOnClick,
|
1555
|
-
onBlur: handleOnClick,
|
1556
1560
|
value: selectedValue,
|
1557
1561
|
onChange,
|
1558
1562
|
className: clickClass ? "clicked" : ""
|
1559
1563
|
}, props), {
|
1560
1564
|
children: [
|
1561
|
-
itemsChecked.length > 0 && itemsChecked.map((item) => {
|
1565
|
+
isClose && itemsChecked.length > 0 && itemsChecked.map((item) => {
|
1562
1566
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
1563
1567
|
"div",
|
1564
1568
|
{
|
1565
1569
|
style: {
|
1566
1570
|
display: "flex",
|
1567
|
-
|
1568
|
-
|
1569
|
-
marginTop: "0.2rem",
|
1570
|
-
alignItems: "center"
|
1571
|
+
alignItems: "center",
|
1572
|
+
justifyContent: "space-between"
|
1571
1573
|
},
|
1572
1574
|
children: [
|
1573
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: item.label }),
|
1575
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { marginLeft: "0.5rem" }, children: item.label }),
|
1574
1576
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
1575
|
-
|
1577
|
+
Button2,
|
1576
1578
|
{
|
1577
|
-
style: {
|
1578
|
-
all: "unset",
|
1579
|
-
display: "flex",
|
1580
|
-
alignItems: "center",
|
1581
|
-
paddingLeft: "1rem"
|
1582
|
-
},
|
1583
1579
|
type: "button",
|
1580
|
+
size,
|
1584
1581
|
onClick: (e) => handleRemoveItem(e, item.id),
|
1585
1582
|
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.X, { size: 24, weight: "bold" })
|
1586
1583
|
}
|
@@ -1588,24 +1585,25 @@ var MultiSelect = (0, import_react13.forwardRef)(
|
|
1588
1585
|
]
|
1589
1586
|
}
|
1590
1587
|
) }, `opt:${item.id}`);
|
1591
|
-
}) || itemsChecked.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
1588
|
+
}) || (itemsChecked.length === 0 || !isClose) && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
1592
1589
|
"div",
|
1593
1590
|
{
|
1594
1591
|
style: {
|
1595
1592
|
display: "flex",
|
1596
1593
|
justifyContent: "space-between",
|
1597
1594
|
width: "100%",
|
1598
|
-
alignItems: "center"
|
1595
|
+
alignItems: "center",
|
1596
|
+
padding: "4px 0px"
|
1599
1597
|
},
|
1600
1598
|
children: [
|
1601
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { opacity: 0.75 }, children: placeholder }),
|
1599
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { opacity: 0.75, marginLeft: "0.5rem" }, children: placeholder }),
|
1602
1600
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
1603
1601
|
"span",
|
1604
1602
|
{
|
1605
1603
|
style: {
|
1606
1604
|
display: "flex",
|
1607
1605
|
alignItems: "center",
|
1608
|
-
|
1606
|
+
marginRight: "0.7rem"
|
1609
1607
|
},
|
1610
1608
|
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.CaretDown, { size: 24, weight: "bold" })
|
1611
1609
|
}
|
@@ -1613,22 +1611,31 @@ var MultiSelect = (0, import_react13.forwardRef)(
|
|
1613
1611
|
]
|
1614
1612
|
}
|
1615
1613
|
) }),
|
1616
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
label: item.label,
|
1623
|
-
checked: item.isChecked,
|
1624
|
-
value: updateSelectComponent(item.value),
|
1625
|
-
handleOnChange: () => __async(void 0, null, function* () {
|
1626
|
-
handleOnValueChange(item.id);
|
1627
|
-
})
|
1614
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
1615
|
+
SelectContainerUI,
|
1616
|
+
{
|
1617
|
+
className: isClose ? "closed" : "opened",
|
1618
|
+
onMouseLeave: () => {
|
1619
|
+
setIsClosed(true);
|
1628
1620
|
},
|
1629
|
-
item
|
1630
|
-
|
1631
|
-
|
1621
|
+
children: values.map((item) => {
|
1622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
1623
|
+
CheckBox,
|
1624
|
+
{
|
1625
|
+
name: `chk${item.id}`,
|
1626
|
+
size,
|
1627
|
+
label: item.label,
|
1628
|
+
checked: item.isChecked,
|
1629
|
+
value: updateSelectComponent(item.value),
|
1630
|
+
handleOnChange: () => {
|
1631
|
+
handleOnValueChange(item.id);
|
1632
|
+
}
|
1633
|
+
},
|
1634
|
+
item.id
|
1635
|
+
);
|
1636
|
+
})
|
1637
|
+
}
|
1638
|
+
)
|
1632
1639
|
]
|
1633
1640
|
})
|
1634
1641
|
);
|
package/dist/index.mjs
CHANGED
@@ -29,26 +29,6 @@ var __objRest = (source, exclude) => {
|
|
29
29
|
}
|
30
30
|
return target;
|
31
31
|
};
|
32
|
-
var __async = (__this, __arguments, generator) => {
|
33
|
-
return new Promise((resolve, reject) => {
|
34
|
-
var fulfilled = (value) => {
|
35
|
-
try {
|
36
|
-
step(generator.next(value));
|
37
|
-
} catch (e) {
|
38
|
-
reject(e);
|
39
|
-
}
|
40
|
-
};
|
41
|
-
var rejected = (value) => {
|
42
|
-
try {
|
43
|
-
step(generator.throw(value));
|
44
|
-
} catch (e) {
|
45
|
-
reject(e);
|
46
|
-
}
|
47
|
-
};
|
48
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
49
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
50
|
-
});
|
51
|
-
};
|
52
32
|
|
53
33
|
// ../tokens/dist/index.mjs
|
54
34
|
var colors = {
|
@@ -853,6 +833,7 @@ var SelectUI = styled("select", {
|
|
853
833
|
maxWidth: "24.5rem",
|
854
834
|
margin: 0,
|
855
835
|
padding: "$1 $1",
|
836
|
+
marginLeft: "$1",
|
856
837
|
"&:disabled": {
|
857
838
|
opacity: 0.5
|
858
839
|
},
|
@@ -937,7 +918,7 @@ var Select = forwardRef3(
|
|
937
918
|
display: "flex",
|
938
919
|
alignItems: "center",
|
939
920
|
paddingLeft: "1rem",
|
940
|
-
marginRight: "0.
|
921
|
+
marginRight: "0.7rem",
|
941
922
|
marginLeft: "-3rem"
|
942
923
|
},
|
943
924
|
children: /* @__PURE__ */ jsx7(CaretDown, { size: 24, weight: "bold" })
|
@@ -1305,7 +1286,38 @@ TextInput.displayName = "TextInput";
|
|
1305
1286
|
import { CaretDown as CaretDown2, X } from "@phosphor-icons/react";
|
1306
1287
|
|
1307
1288
|
// src/components/MultiSelect/styles.ts
|
1289
|
+
var Button2 = styled("button", {
|
1290
|
+
backgroundColor: "transparent",
|
1291
|
+
border: "none",
|
1292
|
+
display: "flex",
|
1293
|
+
alignItems: "center",
|
1294
|
+
justifyContent: "center",
|
1295
|
+
color: "white",
|
1296
|
+
marginBottom: "-3px",
|
1297
|
+
cursor: "pointer",
|
1298
|
+
zIndex: 5,
|
1299
|
+
variants: {
|
1300
|
+
size: {
|
1301
|
+
lg: {
|
1302
|
+
height: "$10",
|
1303
|
+
width: "$10"
|
1304
|
+
},
|
1305
|
+
md: {
|
1306
|
+
height: "$8",
|
1307
|
+
width: "$8"
|
1308
|
+
},
|
1309
|
+
sm: {
|
1310
|
+
height: "$6",
|
1311
|
+
width: "$6"
|
1312
|
+
}
|
1313
|
+
}
|
1314
|
+
},
|
1315
|
+
defaultVariants: {
|
1316
|
+
size: "lg"
|
1317
|
+
}
|
1318
|
+
});
|
1308
1319
|
var SelectUI2 = styled("div", {
|
1320
|
+
zIndex: 3,
|
1309
1321
|
width: "100%",
|
1310
1322
|
maxWidth: "24.5rem",
|
1311
1323
|
position: "relative",
|
@@ -1320,21 +1332,12 @@ var SelectUI2 = styled("div", {
|
|
1320
1332
|
borderRadius: "$md",
|
1321
1333
|
boxSizing: "border-box",
|
1322
1334
|
transition: "border 0.2s linear",
|
1323
|
-
padding: "$1 $2",
|
1324
1335
|
boxShadow: "0 3px 2px -2px $colors$gray400",
|
1325
1336
|
"&:hover": {
|
1326
1337
|
borderBottom: "2px solid $dafaz400"
|
1327
1338
|
},
|
1328
1339
|
"&.clicked": {
|
1329
|
-
borderBottom: "2px solid $dafaz400"
|
1330
|
-
"&:hover": {
|
1331
|
-
"> div": {
|
1332
|
-
display: "flex",
|
1333
|
-
flexDirection: "column",
|
1334
|
-
alignItems: "start",
|
1335
|
-
gap: "$3"
|
1336
|
-
}
|
1337
|
-
}
|
1340
|
+
borderBottom: "2px solid $dafaz400"
|
1338
1341
|
},
|
1339
1342
|
variants: {
|
1340
1343
|
disabled: {
|
@@ -1373,15 +1376,13 @@ var SelectUI2 = styled("div", {
|
|
1373
1376
|
}
|
1374
1377
|
});
|
1375
1378
|
var SelectContainerUI = styled("div", {
|
1376
|
-
marginTop: "0.4rem",
|
1377
|
-
marginLeft: "-0.5rem",
|
1378
1379
|
padding: "$3 $2",
|
1380
|
+
marginTop: "2px",
|
1379
1381
|
border: "1px solid $gray400",
|
1380
1382
|
boxSizing: "border-box",
|
1381
1383
|
borderRadius: "$md",
|
1382
|
-
display: "none",
|
1383
1384
|
position: "absolute",
|
1384
|
-
zIndex:
|
1385
|
+
zIndex: 2,
|
1385
1386
|
minWidth: "100%",
|
1386
1387
|
maxWidth: "24.5rem",
|
1387
1388
|
background: "$gray800",
|
@@ -1389,10 +1390,12 @@ var SelectContainerUI = styled("div", {
|
|
1389
1390
|
color: "$white",
|
1390
1391
|
fontWeight: "$regular",
|
1391
1392
|
cursor: "pointer",
|
1392
|
-
"
|
1393
|
+
"&.closed": {
|
1394
|
+
display: "none"
|
1395
|
+
},
|
1396
|
+
"&.opened": {
|
1393
1397
|
display: "flex",
|
1394
1398
|
flexDirection: "column",
|
1395
|
-
alignItems: "start",
|
1396
1399
|
gap: "$3"
|
1397
1400
|
}
|
1398
1401
|
});
|
@@ -1412,6 +1415,7 @@ var MultiSelect = forwardRef6(
|
|
1412
1415
|
]);
|
1413
1416
|
const [selectedValue, setSelectedValue] = useState3([""]);
|
1414
1417
|
const [clickClass, setClickClass] = useState3(false);
|
1418
|
+
const [isClose, setIsClosed] = useState3(true);
|
1415
1419
|
useEffect(() => {
|
1416
1420
|
items.map(
|
1417
1421
|
(item) => setValues((state) => {
|
@@ -1449,7 +1453,6 @@ var MultiSelect = forwardRef6(
|
|
1449
1453
|
});
|
1450
1454
|
}, [values, items, setValues]);
|
1451
1455
|
function handleOnValueChange(id2) {
|
1452
|
-
setClickClass(() => false);
|
1453
1456
|
setValues((state) => {
|
1454
1457
|
const items2 = state.filter((item2) => item2.id !== id2);
|
1455
1458
|
const item = state.find((item2) => item2.id === id2);
|
@@ -1486,8 +1489,10 @@ var MultiSelect = forwardRef6(
|
|
1486
1489
|
}
|
1487
1490
|
function handleOnClick() {
|
1488
1491
|
setClickClass((state) => !state);
|
1492
|
+
setIsClosed((state) => !state);
|
1489
1493
|
}
|
1490
1494
|
function handleRemoveItem(e, id2) {
|
1495
|
+
setIsClosed(true);
|
1491
1496
|
handleOnValueChange(id2);
|
1492
1497
|
}
|
1493
1498
|
function updateSelectComponent(item) {
|
@@ -1508,35 +1513,27 @@ var MultiSelect = forwardRef6(
|
|
1508
1513
|
id,
|
1509
1514
|
size,
|
1510
1515
|
onClick: handleOnClick,
|
1511
|
-
onBlur: handleOnClick,
|
1512
1516
|
value: selectedValue,
|
1513
1517
|
onChange,
|
1514
1518
|
className: clickClass ? "clicked" : ""
|
1515
1519
|
}, props), {
|
1516
1520
|
children: [
|
1517
|
-
itemsChecked.length > 0 && itemsChecked.map((item) => {
|
1521
|
+
isClose && itemsChecked.length > 0 && itemsChecked.map((item) => {
|
1518
1522
|
return /* @__PURE__ */ jsx12("div", { children: /* @__PURE__ */ jsxs5(
|
1519
1523
|
"div",
|
1520
1524
|
{
|
1521
1525
|
style: {
|
1522
1526
|
display: "flex",
|
1523
|
-
|
1524
|
-
|
1525
|
-
marginTop: "0.2rem",
|
1526
|
-
alignItems: "center"
|
1527
|
+
alignItems: "center",
|
1528
|
+
justifyContent: "space-between"
|
1527
1529
|
},
|
1528
1530
|
children: [
|
1529
|
-
/* @__PURE__ */ jsx12("span", { children: item.label }),
|
1531
|
+
/* @__PURE__ */ jsx12("span", { style: { marginLeft: "0.5rem" }, children: item.label }),
|
1530
1532
|
/* @__PURE__ */ jsx12(
|
1531
|
-
|
1533
|
+
Button2,
|
1532
1534
|
{
|
1533
|
-
style: {
|
1534
|
-
all: "unset",
|
1535
|
-
display: "flex",
|
1536
|
-
alignItems: "center",
|
1537
|
-
paddingLeft: "1rem"
|
1538
|
-
},
|
1539
1535
|
type: "button",
|
1536
|
+
size,
|
1540
1537
|
onClick: (e) => handleRemoveItem(e, item.id),
|
1541
1538
|
children: /* @__PURE__ */ jsx12(X, { size: 24, weight: "bold" })
|
1542
1539
|
}
|
@@ -1544,24 +1541,25 @@ var MultiSelect = forwardRef6(
|
|
1544
1541
|
]
|
1545
1542
|
}
|
1546
1543
|
) }, `opt:${item.id}`);
|
1547
|
-
}) || itemsChecked.length === 0 && /* @__PURE__ */ jsx12("div", { children: /* @__PURE__ */ jsxs5(
|
1544
|
+
}) || (itemsChecked.length === 0 || !isClose) && /* @__PURE__ */ jsx12("div", { children: /* @__PURE__ */ jsxs5(
|
1548
1545
|
"div",
|
1549
1546
|
{
|
1550
1547
|
style: {
|
1551
1548
|
display: "flex",
|
1552
1549
|
justifyContent: "space-between",
|
1553
1550
|
width: "100%",
|
1554
|
-
alignItems: "center"
|
1551
|
+
alignItems: "center",
|
1552
|
+
padding: "4px 0px"
|
1555
1553
|
},
|
1556
1554
|
children: [
|
1557
|
-
/* @__PURE__ */ jsx12("span", { style: { opacity: 0.75 }, children: placeholder }),
|
1555
|
+
/* @__PURE__ */ jsx12("span", { style: { opacity: 0.75, marginLeft: "0.5rem" }, children: placeholder }),
|
1558
1556
|
/* @__PURE__ */ jsx12(
|
1559
1557
|
"span",
|
1560
1558
|
{
|
1561
1559
|
style: {
|
1562
1560
|
display: "flex",
|
1563
1561
|
alignItems: "center",
|
1564
|
-
|
1562
|
+
marginRight: "0.7rem"
|
1565
1563
|
},
|
1566
1564
|
children: /* @__PURE__ */ jsx12(CaretDown2, { size: 24, weight: "bold" })
|
1567
1565
|
}
|
@@ -1569,22 +1567,31 @@ var MultiSelect = forwardRef6(
|
|
1569
1567
|
]
|
1570
1568
|
}
|
1571
1569
|
) }),
|
1572
|
-
/* @__PURE__ */ jsx12(
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
label: item.label,
|
1579
|
-
checked: item.isChecked,
|
1580
|
-
value: updateSelectComponent(item.value),
|
1581
|
-
handleOnChange: () => __async(void 0, null, function* () {
|
1582
|
-
handleOnValueChange(item.id);
|
1583
|
-
})
|
1570
|
+
/* @__PURE__ */ jsx12(
|
1571
|
+
SelectContainerUI,
|
1572
|
+
{
|
1573
|
+
className: isClose ? "closed" : "opened",
|
1574
|
+
onMouseLeave: () => {
|
1575
|
+
setIsClosed(true);
|
1584
1576
|
},
|
1585
|
-
item
|
1586
|
-
|
1587
|
-
|
1577
|
+
children: values.map((item) => {
|
1578
|
+
return /* @__PURE__ */ jsx12(
|
1579
|
+
CheckBox,
|
1580
|
+
{
|
1581
|
+
name: `chk${item.id}`,
|
1582
|
+
size,
|
1583
|
+
label: item.label,
|
1584
|
+
checked: item.isChecked,
|
1585
|
+
value: updateSelectComponent(item.value),
|
1586
|
+
handleOnChange: () => {
|
1587
|
+
handleOnValueChange(item.id);
|
1588
|
+
}
|
1589
|
+
},
|
1590
|
+
item.id
|
1591
|
+
);
|
1592
|
+
})
|
1593
|
+
}
|
1594
|
+
)
|
1588
1595
|
]
|
1589
1596
|
})
|
1590
1597
|
);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { CaretDown, X } from '@phosphor-icons/react'
|
2
2
|
import { CheckBox } from '../CheckBox'
|
3
|
-
import { SelectUI, SelectContainerUI, SelectUIProps } from './styles'
|
3
|
+
import { SelectUI, SelectContainerUI, SelectUIProps, Button } from './styles'
|
4
4
|
|
5
5
|
import {
|
6
6
|
forwardRef,
|
@@ -39,6 +39,7 @@ export const MultiSelect = forwardRef<
|
|
39
39
|
])
|
40
40
|
const [selectedValue, setSelectedValue] = useState([''])
|
41
41
|
const [clickClass, setClickClass] = useState(false)
|
42
|
+
const [isClose, setIsClosed] = useState(true)
|
42
43
|
|
43
44
|
useEffect(() => {
|
44
45
|
items.map((item) =>
|
@@ -79,7 +80,6 @@ export const MultiSelect = forwardRef<
|
|
79
80
|
}, [values, items, setValues])
|
80
81
|
|
81
82
|
function handleOnValueChange(id: string) {
|
82
|
-
setClickClass(() => false)
|
83
83
|
setValues((state) => {
|
84
84
|
const items = state.filter((item) => item.id !== id)
|
85
85
|
const item = state.find((item) => item.id === id)
|
@@ -119,9 +119,11 @@ export const MultiSelect = forwardRef<
|
|
119
119
|
|
120
120
|
function handleOnClick() {
|
121
121
|
setClickClass((state) => !state)
|
122
|
+
setIsClosed((state) => !state)
|
122
123
|
}
|
123
124
|
|
124
125
|
function handleRemoveItem(e: MouseEvent<HTMLElement>, id: string) {
|
126
|
+
setIsClosed(true)
|
125
127
|
handleOnValueChange(id)
|
126
128
|
}
|
127
129
|
|
@@ -147,43 +149,36 @@ export const MultiSelect = forwardRef<
|
|
147
149
|
id={id}
|
148
150
|
size={size}
|
149
151
|
onClick={handleOnClick}
|
150
|
-
onBlur={handleOnClick}
|
151
152
|
value={selectedValue}
|
152
153
|
onChange={onChange}
|
153
154
|
className={clickClass ? 'clicked' : ''}
|
154
155
|
{...props}
|
155
156
|
>
|
156
|
-
{(
|
157
|
+
{(isClose &&
|
158
|
+
itemsChecked.length > 0 &&
|
157
159
|
itemsChecked.map((item) => {
|
158
160
|
return (
|
159
161
|
<div key={`opt:${item.id}`}>
|
160
162
|
<div
|
161
163
|
style={{
|
162
164
|
display: 'flex',
|
163
|
-
justifyContent: 'space-between',
|
164
|
-
width: '100%',
|
165
|
-
marginTop: '0.2rem',
|
166
165
|
alignItems: 'center',
|
166
|
+
justifyContent: 'space-between',
|
167
167
|
}}
|
168
168
|
>
|
169
|
-
<span>{item.label}</span>
|
170
|
-
<
|
171
|
-
style={{
|
172
|
-
all: 'unset',
|
173
|
-
display: 'flex',
|
174
|
-
alignItems: 'center',
|
175
|
-
paddingLeft: '1rem',
|
176
|
-
}}
|
169
|
+
<span style={{ marginLeft: '0.5rem' }}>{item.label}</span>
|
170
|
+
<Button
|
177
171
|
type="button"
|
172
|
+
size={size}
|
178
173
|
onClick={(e) => handleRemoveItem(e, item.id)}
|
179
174
|
>
|
180
175
|
<X size={24} weight="bold" />
|
181
|
-
</
|
176
|
+
</Button>
|
182
177
|
</div>
|
183
178
|
</div>
|
184
179
|
)
|
185
180
|
})) ||
|
186
|
-
(itemsChecked.length === 0 && (
|
181
|
+
((itemsChecked.length === 0 || !isClose) && (
|
187
182
|
<div>
|
188
183
|
<div
|
189
184
|
style={{
|
@@ -191,14 +186,17 @@ export const MultiSelect = forwardRef<
|
|
191
186
|
justifyContent: 'space-between',
|
192
187
|
width: '100%',
|
193
188
|
alignItems: 'center',
|
189
|
+
padding: '4px 0px',
|
194
190
|
}}
|
195
191
|
>
|
196
|
-
<span style={{ opacity: 0.75 }}>
|
192
|
+
<span style={{ opacity: 0.75, marginLeft: '0.5rem' }}>
|
193
|
+
{placeholder}
|
194
|
+
</span>
|
197
195
|
<span
|
198
196
|
style={{
|
199
197
|
display: 'flex',
|
200
198
|
alignItems: 'center',
|
201
|
-
|
199
|
+
marginRight: '0.7rem',
|
202
200
|
}}
|
203
201
|
>
|
204
202
|
<CaretDown size={24} weight="bold" />
|
@@ -207,7 +205,12 @@ export const MultiSelect = forwardRef<
|
|
207
205
|
</div>
|
208
206
|
))}
|
209
207
|
|
210
|
-
<SelectContainerUI
|
208
|
+
<SelectContainerUI
|
209
|
+
className={isClose ? 'closed' : 'opened'}
|
210
|
+
onMouseLeave={() => {
|
211
|
+
setIsClosed(true)
|
212
|
+
}}
|
213
|
+
>
|
211
214
|
{values.map((item) => {
|
212
215
|
return (
|
213
216
|
<CheckBox
|
@@ -217,7 +220,7 @@ export const MultiSelect = forwardRef<
|
|
217
220
|
label={item.label}
|
218
221
|
checked={item.isChecked}
|
219
222
|
value={updateSelectComponent(item.value)}
|
220
|
-
handleOnChange={
|
223
|
+
handleOnChange={() => {
|
221
224
|
handleOnValueChange(item.id)
|
222
225
|
}}
|
223
226
|
/>
|
@@ -1,7 +1,42 @@
|
|
1
1
|
import { styled } from '../../styles'
|
2
2
|
import type { ComponentProps, CSSProperties } from 'react'
|
3
3
|
|
4
|
+
export const Button = styled('button', {
|
5
|
+
backgroundColor: 'transparent',
|
6
|
+
border: 'none',
|
7
|
+
display: 'flex',
|
8
|
+
alignItems: 'center',
|
9
|
+
justifyContent: 'center',
|
10
|
+
color: 'white',
|
11
|
+
marginBottom: '-3px',
|
12
|
+
|
13
|
+
cursor: 'pointer',
|
14
|
+
|
15
|
+
zIndex: 5,
|
16
|
+
|
17
|
+
variants: {
|
18
|
+
size: {
|
19
|
+
lg: {
|
20
|
+
height: '$10',
|
21
|
+
width: '$10',
|
22
|
+
},
|
23
|
+
md: {
|
24
|
+
height: '$8',
|
25
|
+
width: '$8',
|
26
|
+
},
|
27
|
+
sm: {
|
28
|
+
height: '$6',
|
29
|
+
width: '$6',
|
30
|
+
},
|
31
|
+
},
|
32
|
+
},
|
33
|
+
defaultVariants: {
|
34
|
+
size: 'lg',
|
35
|
+
},
|
36
|
+
})
|
37
|
+
|
4
38
|
export const SelectUI = styled('div', {
|
39
|
+
zIndex: 3,
|
5
40
|
width: '100%',
|
6
41
|
maxWidth: '24.5rem',
|
7
42
|
|
@@ -20,8 +55,6 @@ export const SelectUI = styled('div', {
|
|
20
55
|
boxSizing: 'border-box',
|
21
56
|
transition: 'border 0.2s linear',
|
22
57
|
|
23
|
-
padding: '$1 $2',
|
24
|
-
|
25
58
|
boxShadow: '0 3px 2px -2px $colors$gray400',
|
26
59
|
|
27
60
|
'&:hover': {
|
@@ -30,15 +63,6 @@ export const SelectUI = styled('div', {
|
|
30
63
|
|
31
64
|
'&.clicked': {
|
32
65
|
borderBottom: '2px solid $dafaz400',
|
33
|
-
|
34
|
-
'&:hover': {
|
35
|
-
'> div': {
|
36
|
-
display: 'flex',
|
37
|
-
flexDirection: 'column',
|
38
|
-
alignItems: 'start',
|
39
|
-
gap: '$3',
|
40
|
-
},
|
41
|
-
},
|
42
66
|
},
|
43
67
|
|
44
68
|
variants: {
|
@@ -85,18 +109,15 @@ export interface SelectUIProps extends ComponentProps<typeof SelectUI> {
|
|
85
109
|
}
|
86
110
|
|
87
111
|
export const SelectContainerUI = styled('div', {
|
88
|
-
marginTop: '0.4rem',
|
89
|
-
marginLeft: '-0.5rem',
|
90
112
|
padding: '$3 $2',
|
113
|
+
marginTop: '2px',
|
91
114
|
|
92
115
|
border: '1px solid $gray400',
|
93
116
|
boxSizing: 'border-box',
|
94
117
|
borderRadius: '$md',
|
95
118
|
|
96
|
-
display: 'none',
|
97
|
-
|
98
119
|
position: 'absolute',
|
99
|
-
zIndex:
|
120
|
+
zIndex: 2,
|
100
121
|
minWidth: '100%',
|
101
122
|
maxWidth: '24.5rem',
|
102
123
|
|
@@ -107,10 +128,19 @@ export const SelectContainerUI = styled('div', {
|
|
107
128
|
fontWeight: '$regular',
|
108
129
|
cursor: 'pointer',
|
109
130
|
|
110
|
-
'
|
131
|
+
'&.closed': {
|
132
|
+
display: 'none',
|
133
|
+
},
|
134
|
+
|
135
|
+
'&.opened': {
|
111
136
|
display: 'flex',
|
112
137
|
flexDirection: 'column',
|
113
|
-
alignItems: 'start',
|
114
138
|
gap: '$3',
|
115
139
|
},
|
116
140
|
})
|
141
|
+
|
142
|
+
export interface SelectContainerUIProps
|
143
|
+
extends ComponentProps<typeof SelectContainerUI> {
|
144
|
+
className?: string
|
145
|
+
style?: CSSProperties
|
146
|
+
}
|