@dafaz-ui/react 6.0.5 → 7.0.0
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 +6 -0
- package/dist/index.js +76 -70
- package/dist/index.mjs +76 -70
- package/package.json +1 -1
- package/src/components/MultiSelect/index.tsx +23 -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.0 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.94 KB[39m
|
12
|
+
[32mCJS[39m ⚡️ Build success in 48ms
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m35.66 KB[39m
|
14
|
+
[32mESM[39m ⚡️ Build success in 49ms
|
15
15
|
[34mDTS[39m Build start
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
16
|
+
[32mDTS[39m ⚡️ Build success in 4622ms
|
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,7 +1585,7 @@ 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: {
|
@@ -1598,14 +1595,14 @@ var MultiSelect = (0, import_react13.forwardRef)(
|
|
1598
1595
|
alignItems: "center"
|
1599
1596
|
},
|
1600
1597
|
children: [
|
1601
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { opacity: 0.75 }, children: placeholder }),
|
1598
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { style: { opacity: 0.75, marginLeft: "0.5rem" }, children: placeholder }),
|
1602
1599
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
1603
1600
|
"span",
|
1604
1601
|
{
|
1605
1602
|
style: {
|
1606
1603
|
display: "flex",
|
1607
1604
|
alignItems: "center",
|
1608
|
-
|
1605
|
+
marginRight: "0.7rem"
|
1609
1606
|
},
|
1610
1607
|
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.CaretDown, { size: 24, weight: "bold" })
|
1611
1608
|
}
|
@@ -1613,22 +1610,31 @@ var MultiSelect = (0, import_react13.forwardRef)(
|
|
1613
1610
|
]
|
1614
1611
|
}
|
1615
1612
|
) }),
|
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
|
-
})
|
1613
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
1614
|
+
SelectContainerUI,
|
1615
|
+
{
|
1616
|
+
className: isClose ? "closed" : "opened",
|
1617
|
+
onMouseLeave: () => {
|
1618
|
+
setIsClosed(true);
|
1628
1619
|
},
|
1629
|
-
item
|
1630
|
-
|
1631
|
-
|
1620
|
+
children: values.map((item) => {
|
1621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
1622
|
+
CheckBox,
|
1623
|
+
{
|
1624
|
+
name: `chk${item.id}`,
|
1625
|
+
size,
|
1626
|
+
label: item.label,
|
1627
|
+
checked: item.isChecked,
|
1628
|
+
value: updateSelectComponent(item.value),
|
1629
|
+
handleOnChange: () => {
|
1630
|
+
handleOnValueChange(item.id);
|
1631
|
+
}
|
1632
|
+
},
|
1633
|
+
item.id
|
1634
|
+
);
|
1635
|
+
})
|
1636
|
+
}
|
1637
|
+
)
|
1632
1638
|
]
|
1633
1639
|
})
|
1634
1640
|
);
|
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,7 +1541,7 @@ 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: {
|
@@ -1554,14 +1551,14 @@ var MultiSelect = forwardRef6(
|
|
1554
1551
|
alignItems: "center"
|
1555
1552
|
},
|
1556
1553
|
children: [
|
1557
|
-
/* @__PURE__ */ jsx12("span", { style: { opacity: 0.75 }, children: placeholder }),
|
1554
|
+
/* @__PURE__ */ jsx12("span", { style: { opacity: 0.75, marginLeft: "0.5rem" }, children: placeholder }),
|
1558
1555
|
/* @__PURE__ */ jsx12(
|
1559
1556
|
"span",
|
1560
1557
|
{
|
1561
1558
|
style: {
|
1562
1559
|
display: "flex",
|
1563
1560
|
alignItems: "center",
|
1564
|
-
|
1561
|
+
marginRight: "0.7rem"
|
1565
1562
|
},
|
1566
1563
|
children: /* @__PURE__ */ jsx12(CaretDown2, { size: 24, weight: "bold" })
|
1567
1564
|
}
|
@@ -1569,22 +1566,31 @@ var MultiSelect = forwardRef6(
|
|
1569
1566
|
]
|
1570
1567
|
}
|
1571
1568
|
) }),
|
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
|
-
})
|
1569
|
+
/* @__PURE__ */ jsx12(
|
1570
|
+
SelectContainerUI,
|
1571
|
+
{
|
1572
|
+
className: isClose ? "closed" : "opened",
|
1573
|
+
onMouseLeave: () => {
|
1574
|
+
setIsClosed(true);
|
1584
1575
|
},
|
1585
|
-
item
|
1586
|
-
|
1587
|
-
|
1576
|
+
children: values.map((item) => {
|
1577
|
+
return /* @__PURE__ */ jsx12(
|
1578
|
+
CheckBox,
|
1579
|
+
{
|
1580
|
+
name: `chk${item.id}`,
|
1581
|
+
size,
|
1582
|
+
label: item.label,
|
1583
|
+
checked: item.isChecked,
|
1584
|
+
value: updateSelectComponent(item.value),
|
1585
|
+
handleOnChange: () => {
|
1586
|
+
handleOnValueChange(item.id);
|
1587
|
+
}
|
1588
|
+
},
|
1589
|
+
item.id
|
1590
|
+
);
|
1591
|
+
})
|
1592
|
+
}
|
1593
|
+
)
|
1588
1594
|
]
|
1589
1595
|
})
|
1590
1596
|
);
|
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={{
|
@@ -193,12 +188,14 @@ export const MultiSelect = forwardRef<
|
|
193
188
|
alignItems: 'center',
|
194
189
|
}}
|
195
190
|
>
|
196
|
-
<span style={{ opacity: 0.75 }}>
|
191
|
+
<span style={{ opacity: 0.75, marginLeft: '0.5rem' }}>
|
192
|
+
{placeholder}
|
193
|
+
</span>
|
197
194
|
<span
|
198
195
|
style={{
|
199
196
|
display: 'flex',
|
200
197
|
alignItems: 'center',
|
201
|
-
|
198
|
+
marginRight: '0.7rem',
|
202
199
|
}}
|
203
200
|
>
|
204
201
|
<CaretDown size={24} weight="bold" />
|
@@ -207,7 +204,12 @@ export const MultiSelect = forwardRef<
|
|
207
204
|
</div>
|
208
205
|
))}
|
209
206
|
|
210
|
-
<SelectContainerUI
|
207
|
+
<SelectContainerUI
|
208
|
+
className={isClose ? 'closed' : 'opened'}
|
209
|
+
onMouseLeave={() => {
|
210
|
+
setIsClosed(true)
|
211
|
+
}}
|
212
|
+
>
|
211
213
|
{values.map((item) => {
|
212
214
|
return (
|
213
215
|
<CheckBox
|
@@ -217,7 +219,7 @@ export const MultiSelect = forwardRef<
|
|
217
219
|
label={item.label}
|
218
220
|
checked={item.isChecked}
|
219
221
|
value={updateSelectComponent(item.value)}
|
220
|
-
handleOnChange={
|
222
|
+
handleOnChange={() => {
|
221
223
|
handleOnValueChange(item.id)
|
222
224
|
}}
|
223
225
|
/>
|
@@ -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
|
+
}
|