@charcoal-ui/react 3.0.0-beta.0 → 3.0.0-beta.2
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/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/DropdownPopover.d.ts.map +1 -1
- package/dist/components/DropdownSelector/OptionItem.d.ts +7 -0
- package/dist/components/DropdownSelector/OptionItem.d.ts.map +1 -0
- package/dist/components/DropdownSelector/index.d.ts +22 -29
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.story.d.ts +5 -18
- package/dist/components/DropdownSelector/index.story.d.ts.map +1 -1
- package/dist/components/DropdownSelector/utils/focusIfHTMLLIElement.d.ts +6 -0
- package/dist/components/DropdownSelector/utils/focusIfHTMLLIElement.d.ts.map +1 -0
- package/dist/components/DropdownSelector/utils/handleFocusByKeyBoard.d.ts +6 -0
- package/dist/components/DropdownSelector/utils/handleFocusByKeyBoard.d.ts.map +1 -0
- package/dist/components/LoadingSpinner/index.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts +5 -2
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index.story.d.ts.map +1 -1
- package/dist/index.cjs.js +313 -336
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +296 -319
- package/dist/index.esm.js.map +1 -1
- package/package.json +6 -6
- package/src/components/DropdownSelector/DropdownPopover.tsx +9 -15
- package/src/components/DropdownSelector/OptionItem.tsx +85 -0
- package/src/components/DropdownSelector/index.story.tsx +69 -156
- package/src/components/DropdownSelector/index.tsx +110 -140
- package/src/components/DropdownSelector/utils/focusIfHTMLLIElement.tsx +12 -0
- package/src/components/DropdownSelector/utils/handleFocusByKeyBoard.tsx +20 -0
- package/src/components/LoadingSpinner/index.tsx +1 -0
- package/src/components/Modal/index.tsx +79 -61
- package/src/components/Radio/index.tsx +2 -0
- package/src/components/SegmentedControl/index.story.tsx +2 -0
- package/src/components/SegmentedControl/index.tsx +1 -0
- package/src/components/TextField/index.tsx +1 -0
- package/src/index.ts +7 -2
- package/src/components/DropdownSelector/ListBoxSection.tsx +0 -60
- package/src/components/DropdownSelector/Listbox.tsx +0 -67
- package/src/components/DropdownSelector/Option.tsx +0 -66
package/dist/index.esm.js
CHANGED
|
@@ -379,6 +379,8 @@ var RadioInput = styled5.input.attrs({ type: "radio" })`
|
|
|
379
379
|
width: 20px;
|
|
380
380
|
height: 20px;
|
|
381
381
|
|
|
382
|
+
cursor: pointer;
|
|
383
|
+
|
|
382
384
|
${({ hasError = false }) => theme((o) => [
|
|
383
385
|
o.borderRadius("oval"),
|
|
384
386
|
o.bg.surface1.hover.press,
|
|
@@ -1075,6 +1077,7 @@ var PrefixContainer = styled9.span`
|
|
|
1075
1077
|
top: 50%;
|
|
1076
1078
|
left: 8px;
|
|
1077
1079
|
transform: translateY(-50%);
|
|
1080
|
+
z-index: 1;
|
|
1078
1081
|
`;
|
|
1079
1082
|
var SuffixContainer = styled9.span`
|
|
1080
1083
|
position: absolute;
|
|
@@ -1302,7 +1305,7 @@ function Modal({
|
|
|
1302
1305
|
...underlayProps,
|
|
1303
1306
|
style: transitionEnabled ? { backgroundColor } : {}
|
|
1304
1307
|
},
|
|
1305
|
-
/* @__PURE__ */ React12.createElement(FocusScope, { contain: true, restoreFocus: true, autoFocus: true }, /* @__PURE__ */ React12.createElement(
|
|
1308
|
+
/* @__PURE__ */ React12.createElement(FocusScope, { contain: true, restoreFocus: true, autoFocus: true }, /* @__PURE__ */ React12.createElement(DialogContainer, { bottomSheet, size }, /* @__PURE__ */ React12.createElement(
|
|
1306
1309
|
ModalDialog,
|
|
1307
1310
|
{
|
|
1308
1311
|
ref,
|
|
@@ -1328,7 +1331,7 @@ function Modal({
|
|
|
1328
1331
|
}
|
|
1329
1332
|
)
|
|
1330
1333
|
)
|
|
1331
|
-
))
|
|
1334
|
+
)))
|
|
1332
1335
|
))
|
|
1333
1336
|
);
|
|
1334
1337
|
}
|
|
@@ -1340,6 +1343,8 @@ var ModalContext = React12.createContext({
|
|
|
1340
1343
|
});
|
|
1341
1344
|
var ModalBackground = animated(styled10.div`
|
|
1342
1345
|
z-index: ${({ zIndex }) => zIndex};
|
|
1346
|
+
overflow: scroll;
|
|
1347
|
+
display: flex;
|
|
1343
1348
|
position: fixed;
|
|
1344
1349
|
top: 0;
|
|
1345
1350
|
left: 0;
|
|
@@ -1348,34 +1353,52 @@ var ModalBackground = animated(styled10.div`
|
|
|
1348
1353
|
|
|
1349
1354
|
${theme((o) => [o.bg.surface4])}
|
|
1350
1355
|
`);
|
|
1356
|
+
var DialogContainer = styled10.div`
|
|
1357
|
+
position: relative;
|
|
1358
|
+
margin: auto;
|
|
1359
|
+
padding: 24px 0;
|
|
1360
|
+
width: ${(p) => {
|
|
1361
|
+
switch (p.size) {
|
|
1362
|
+
case "S": {
|
|
1363
|
+
return columnSystem(3, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2;
|
|
1364
|
+
}
|
|
1365
|
+
case "M": {
|
|
1366
|
+
return columnSystem(4, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2;
|
|
1367
|
+
}
|
|
1368
|
+
case "L": {
|
|
1369
|
+
return columnSystem(6, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2;
|
|
1370
|
+
}
|
|
1371
|
+
default: {
|
|
1372
|
+
return unreachable(p.size);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
}}px;
|
|
1376
|
+
|
|
1377
|
+
@media ${({ theme: theme4 }) => maxWidth(theme4.breakpoint.screen1)} {
|
|
1378
|
+
width: calc(100% - 48px);
|
|
1379
|
+
${(p) => p.bottomSheet !== false && css4`
|
|
1380
|
+
margin: 0;
|
|
1381
|
+
padding: 0;
|
|
1382
|
+
bottom: 0;
|
|
1383
|
+
position: absolute;
|
|
1384
|
+
width: 100%;
|
|
1385
|
+
${p.bottomSheet === "full" ? "height: 100%" : ""};
|
|
1386
|
+
`}
|
|
1387
|
+
}
|
|
1388
|
+
`;
|
|
1351
1389
|
var ModalDialog = animated(styled10.div`
|
|
1352
|
-
position:
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
transform: translate(-50%, -50%);
|
|
1356
|
-
width: ${(p) => p.size === "S" ? columnSystem(3, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2 : p.size === "M" ? columnSystem(4, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2 : p.size === "L" ? columnSystem(6, COLUMN_UNIT, GUTTER_UNIT) + GUTTER_UNIT * 2 : unreachable(p.size)}px;
|
|
1390
|
+
position: relative;
|
|
1391
|
+
margin: auto;
|
|
1392
|
+
padding: 24px 0;
|
|
1357
1393
|
|
|
1358
1394
|
${theme((o) => [o.bg.background1, o.borderRadius(24)])}
|
|
1359
|
-
|
|
1360
1395
|
@media ${({ theme: theme4 }) => maxWidth(theme4.breakpoint.screen1)} {
|
|
1361
|
-
${(p) => p.bottomSheet
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
width: 100%;
|
|
1368
|
-
height: 100%;
|
|
1369
|
-
` : p.bottomSheet ? css4`
|
|
1370
|
-
top: auto;
|
|
1371
|
-
bottom: 0;
|
|
1372
|
-
left: 0;
|
|
1373
|
-
transform: none;
|
|
1374
|
-
border-radius: 0;
|
|
1375
|
-
width: 100%;
|
|
1376
|
-
` : css4`
|
|
1377
|
-
width: calc(100% - 48px);
|
|
1378
|
-
`}
|
|
1396
|
+
${(p) => p.bottomSheet !== false && css4`
|
|
1397
|
+
border-radius: 0;
|
|
1398
|
+
${p.bottomSheet === "full" && css4`
|
|
1399
|
+
height: 100%;
|
|
1400
|
+
`}
|
|
1401
|
+
`}
|
|
1379
1402
|
}
|
|
1380
1403
|
`);
|
|
1381
1404
|
var ModalCrossButton = styled10(IconButton_default)`
|
|
@@ -1435,6 +1458,7 @@ function LoadingSpinner({
|
|
|
1435
1458
|
return /* @__PURE__ */ React14.createElement(LoadingSpinnerRoot, { size, padding, transparent }, /* @__PURE__ */ React14.createElement(LoadingSpinnerIcon, null));
|
|
1436
1459
|
}
|
|
1437
1460
|
var LoadingSpinnerRoot = styled12.div.attrs({ role: "progressbar" })`
|
|
1461
|
+
box-sizing: content-box;
|
|
1438
1462
|
margin: auto;
|
|
1439
1463
|
padding: ${(props) => props.padding}px;
|
|
1440
1464
|
border-radius: 8px;
|
|
@@ -1486,160 +1510,25 @@ var LoadingSpinnerIcon = React14.forwardRef(function LoadingSpinnerIcon2({ once
|
|
|
1486
1510
|
});
|
|
1487
1511
|
|
|
1488
1512
|
// src/components/DropdownSelector/index.tsx
|
|
1489
|
-
import
|
|
1490
|
-
import styled18 from "styled-components";
|
|
1491
|
-
import { Item, useSelectState } from "react-stately";
|
|
1492
|
-
import { disabledSelector as disabledSelector4 } from "@charcoal-ui/utils";
|
|
1493
|
-
import { useVisuallyHidden as useVisuallyHidden2 } from "@react-aria/visually-hidden";
|
|
1494
|
-
import { useSelect, HiddenSelect } from "@react-aria/select";
|
|
1495
|
-
import { useButton } from "@react-aria/button";
|
|
1496
|
-
|
|
1497
|
-
// src/components/DropdownSelector/Listbox.tsx
|
|
1498
|
-
import React17, { memo, useRef as useRef6, Fragment, useMemo as useMemo2 } from "react";
|
|
1499
|
-
import styled16 from "styled-components";
|
|
1500
|
-
import { useListBox } from "@react-aria/listbox";
|
|
1501
|
-
|
|
1502
|
-
// src/components/DropdownSelector/ListBoxSection.tsx
|
|
1503
|
-
import { useListBoxSection } from "@react-aria/listbox";
|
|
1504
|
-
import { useSeparator } from "@react-aria/separator";
|
|
1505
|
-
import React16 from "react";
|
|
1506
|
-
import styled15 from "styled-components";
|
|
1507
|
-
|
|
1508
|
-
// src/components/DropdownSelector/Option.tsx
|
|
1509
|
-
import React15, { useRef as useRef5 } from "react";
|
|
1510
|
-
import styled13, { css as css5 } from "styled-components";
|
|
1511
|
-
import { useOption } from "@react-aria/listbox";
|
|
1512
|
-
import { mergeProps } from "@react-aria/utils";
|
|
1513
|
-
import { useFocusRing } from "@react-aria/focus";
|
|
1514
|
-
import { px as px3 } from "@charcoal-ui/utils";
|
|
1515
|
-
function Option({ item, state, mode }) {
|
|
1516
|
-
const ref = useRef5(null);
|
|
1517
|
-
const { optionProps, isSelected } = useOption(item, state, ref);
|
|
1518
|
-
const { focusProps } = useFocusRing();
|
|
1519
|
-
return /* @__PURE__ */ React15.createElement(OptionRoot, { ...mergeProps(optionProps, focusProps), ref, mode }, /* @__PURE__ */ React15.createElement(OptionCheckIcon, { name: "16/Check", isSelected }), /* @__PURE__ */ React15.createElement(OptionText, null, item.rendered));
|
|
1520
|
-
}
|
|
1521
|
-
var OptionRoot = styled13.li`
|
|
1522
|
-
display: flex;
|
|
1523
|
-
align-items: center;
|
|
1524
|
-
gap: ${({ theme: theme4 }) => px3(theme4.spacing[4])};
|
|
1525
|
-
height: 40px;
|
|
1526
|
-
cursor: pointer;
|
|
1527
|
-
outline: none;
|
|
1528
|
-
|
|
1529
|
-
${({ mode }) => theme((o) => [
|
|
1530
|
-
o.padding.horizontal(8),
|
|
1531
|
-
mode === "separator" && o.padding.vertical(4)
|
|
1532
|
-
])}
|
|
1533
|
-
|
|
1534
|
-
&:focus {
|
|
1535
|
-
${theme((o) => [o.bg.surface3])}
|
|
1536
|
-
}
|
|
1537
|
-
`;
|
|
1538
|
-
var OptionCheckIcon = styled13(Icon_default)`
|
|
1539
|
-
visibility: hidden;
|
|
1540
|
-
${theme((o) => [o.font.text2])}
|
|
1541
|
-
|
|
1542
|
-
${({ isSelected }) => isSelected && css5`
|
|
1543
|
-
visibility: visible;
|
|
1544
|
-
`}
|
|
1545
|
-
`;
|
|
1546
|
-
var OptionText = styled13.span`
|
|
1547
|
-
display: block;
|
|
1548
|
-
${theme((o) => [o.typography(14), o.font.text2])}
|
|
1549
|
-
`;
|
|
1550
|
-
|
|
1551
|
-
// src/components/DropdownSelector/Divider.tsx
|
|
1513
|
+
import React16, { createContext as createContext2, useRef as useRef6 } from "react";
|
|
1552
1514
|
import styled14 from "styled-components";
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
&:before {
|
|
1557
|
-
content: '';
|
|
1558
|
-
display: block;
|
|
1559
|
-
width: 100%;
|
|
1560
|
-
height: 1px;
|
|
1561
|
-
background: #00000014;
|
|
1562
|
-
}
|
|
1563
|
-
`;
|
|
1564
|
-
|
|
1565
|
-
// src/components/DropdownSelector/ListBoxSection.tsx
|
|
1566
|
-
function ListBoxSection(props) {
|
|
1567
|
-
const { state } = props;
|
|
1568
|
-
const { itemProps, headingProps, groupProps } = useListBoxSection({
|
|
1569
|
-
heading: props.section.rendered,
|
|
1570
|
-
"aria-label": props.section["aria-label"]
|
|
1571
|
-
});
|
|
1572
|
-
const { separatorProps } = useSeparator({
|
|
1573
|
-
elementType: "li"
|
|
1574
|
-
});
|
|
1575
|
-
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, props.section.key !== props.state.collection.getFirstKey() && /* @__PURE__ */ React16.createElement(Divider, { ...separatorProps, role: "separator" }), /* @__PURE__ */ React16.createElement(StyledLi, { ...itemProps }, props.section.rendered != null && /* @__PURE__ */ React16.createElement(SectionSpan, { ...headingProps }, props.section.rendered), /* @__PURE__ */ React16.createElement(StyledUl, { ...groupProps }, [...props.section.childNodes].map((node) => /* @__PURE__ */ React16.createElement(Option, { key: node.key, item: node, state })))));
|
|
1576
|
-
}
|
|
1577
|
-
var SectionSpan = styled15.span`
|
|
1578
|
-
${theme((o) => [
|
|
1579
|
-
o.font.text3,
|
|
1580
|
-
o.typography(12).bold,
|
|
1581
|
-
o.margin.bottom(8).left(16).top(16)
|
|
1582
|
-
])}
|
|
1583
|
-
`;
|
|
1584
|
-
var StyledUl = styled15.ul`
|
|
1585
|
-
padding-left: 0;
|
|
1586
|
-
margin: 0;
|
|
1587
|
-
box-sizing: border-box;
|
|
1588
|
-
list-style: none;
|
|
1589
|
-
overflow: hidden;
|
|
1590
|
-
`;
|
|
1591
|
-
var StyledLi = styled15.li``;
|
|
1592
|
-
|
|
1593
|
-
// src/components/DropdownSelector/Listbox.tsx
|
|
1594
|
-
var Listbox = ({
|
|
1595
|
-
state,
|
|
1596
|
-
mode = "default",
|
|
1597
|
-
...props
|
|
1598
|
-
}) => {
|
|
1599
|
-
const ref = useRef6(null);
|
|
1600
|
-
const { listBoxProps } = useListBox(props, state, ref);
|
|
1601
|
-
const collection = useMemo2(
|
|
1602
|
-
() => [...state.collection].map((node, index, self) => ({
|
|
1603
|
-
node,
|
|
1604
|
-
first: index === 0,
|
|
1605
|
-
last: index === self.length - 1
|
|
1606
|
-
})),
|
|
1607
|
-
[state.collection]
|
|
1608
|
-
);
|
|
1609
|
-
return /* @__PURE__ */ React17.createElement(ListboxRoot, { ref, ...listBoxProps }, collection.map(({ node, last }) => /* @__PURE__ */ React17.createElement(Fragment, { key: node.key }, node.type === "section" ? /* @__PURE__ */ React17.createElement(ListBoxSection, { section: node, state }) : /* @__PURE__ */ React17.createElement(Option, { item: node, state, mode }), !last && mode === "separator" && /* @__PURE__ */ React17.createElement(Divider, null))));
|
|
1610
|
-
};
|
|
1611
|
-
var Listbox_default = memo(Listbox);
|
|
1612
|
-
var ListboxRoot = styled16.ul`
|
|
1613
|
-
padding-left: 0;
|
|
1614
|
-
margin: 0;
|
|
1615
|
-
box-sizing: border-box;
|
|
1616
|
-
list-style: none;
|
|
1617
|
-
overflow: auto;
|
|
1618
|
-
max-height: inherit;
|
|
1619
|
-
|
|
1620
|
-
${theme((o) => [
|
|
1621
|
-
o.bg.background1,
|
|
1622
|
-
o.border.default,
|
|
1623
|
-
o.borderRadius(8),
|
|
1624
|
-
o.padding.vertical(8),
|
|
1625
|
-
o.outline.default.focus
|
|
1626
|
-
])}
|
|
1627
|
-
`;
|
|
1515
|
+
import { useOverlayTriggerState } from "react-stately";
|
|
1516
|
+
import { disabledSelector as disabledSelector4 } from "@charcoal-ui/utils";
|
|
1628
1517
|
|
|
1629
1518
|
// src/components/DropdownSelector/DropdownPopover.tsx
|
|
1630
|
-
import
|
|
1519
|
+
import React15, { useEffect as useEffect2, useRef as useRef5 } from "react";
|
|
1631
1520
|
import {
|
|
1632
1521
|
DismissButton,
|
|
1633
1522
|
Overlay as Overlay2,
|
|
1634
1523
|
usePopover
|
|
1635
1524
|
} from "@react-aria/overlays";
|
|
1636
|
-
import
|
|
1637
|
-
var DropdownPopoverDiv =
|
|
1525
|
+
import styled13 from "styled-components";
|
|
1526
|
+
var DropdownPopoverDiv = styled13.div`
|
|
1638
1527
|
width: 100%;
|
|
1639
1528
|
${theme((o) => o.margin.top(4).bottom(4))}
|
|
1640
1529
|
`;
|
|
1641
1530
|
function DropdownPopover({ children, state, ...props }) {
|
|
1642
|
-
const ref =
|
|
1531
|
+
const ref = useRef5(null);
|
|
1643
1532
|
const { popoverProps, underlayProps } = usePopover(
|
|
1644
1533
|
{
|
|
1645
1534
|
...props,
|
|
@@ -1655,107 +1544,101 @@ function DropdownPopover({ children, state, ...props }) {
|
|
|
1655
1544
|
}, [props.triggerRef]);
|
|
1656
1545
|
useEffect2(() => {
|
|
1657
1546
|
if (state.isOpen && props.value !== void 0) {
|
|
1658
|
-
window.
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
selectedElement?.scrollIntoView({ block: "center" });
|
|
1667
|
-
window.scrollTo(windowScrollX, windowScrollY);
|
|
1668
|
-
});
|
|
1547
|
+
const windowScrollY = window.scrollY;
|
|
1548
|
+
const windowScrollX = window.scrollX;
|
|
1549
|
+
const selectedElement = document.querySelector(
|
|
1550
|
+
`[data-key="${props.value.toString()}"]`
|
|
1551
|
+
);
|
|
1552
|
+
selectedElement?.scrollIntoView({ block: "center" });
|
|
1553
|
+
selectedElement?.focus();
|
|
1554
|
+
window.scrollTo(windowScrollX, windowScrollY);
|
|
1669
1555
|
}
|
|
1670
1556
|
}, [props.value, state.isOpen]);
|
|
1671
|
-
return /* @__PURE__ */
|
|
1557
|
+
return /* @__PURE__ */ React15.createElement(Overlay2, { portalContainer: document.body }, /* @__PURE__ */ React15.createElement("div", { ...underlayProps, style: { position: "fixed", inset: 0 } }), /* @__PURE__ */ React15.createElement(DropdownPopoverDiv, { ...popoverProps, ref }, /* @__PURE__ */ React15.createElement(DismissButton, { onDismiss: () => state.close() }), children, /* @__PURE__ */ React15.createElement(DismissButton, { onDismiss: () => state.close() })));
|
|
1672
1558
|
}
|
|
1673
1559
|
|
|
1674
1560
|
// src/components/DropdownSelector/index.tsx
|
|
1675
|
-
var
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
isDisabled: disabled,
|
|
1698
|
-
isRequired: required,
|
|
1699
|
-
errorMessage: invalid && assertiveText,
|
|
1700
|
-
validationState: invalid ? "invalid" : "valid",
|
|
1701
|
-
onSelectionChange: props.onChange,
|
|
1702
|
-
selectedKey: props.value,
|
|
1703
|
-
defaultSelectedKey: props.defaultValue
|
|
1704
|
-
}),
|
|
1705
|
-
[assertiveText, disabled, invalid, label, open, props, required]
|
|
1706
|
-
);
|
|
1707
|
-
const state = useSelectState(selectProps);
|
|
1708
|
-
const {
|
|
1709
|
-
labelProps,
|
|
1710
|
-
triggerProps,
|
|
1711
|
-
valueProps,
|
|
1712
|
-
menuProps,
|
|
1713
|
-
errorMessageProps,
|
|
1714
|
-
descriptionProps
|
|
1715
|
-
} = useSelect(selectProps, state, triggerRef);
|
|
1716
|
-
const { buttonProps } = useButton(triggerProps, triggerRef);
|
|
1717
|
-
const hasAssertiveText = assertiveText !== void 0 && assertiveText.length > 0;
|
|
1718
|
-
return /* @__PURE__ */ React19.createElement(DropdownSelectorRoot, { "aria-disabled": disabled, className }, /* @__PURE__ */ React19.createElement(
|
|
1561
|
+
var DropdownSelectorContext = createContext2({
|
|
1562
|
+
value: "",
|
|
1563
|
+
setValue: (_v) => {
|
|
1564
|
+
}
|
|
1565
|
+
});
|
|
1566
|
+
var defaultRequiredText = "*\u5FC5\u9808";
|
|
1567
|
+
function DropdownSelector(props) {
|
|
1568
|
+
const triggerRef = useRef6(null);
|
|
1569
|
+
const state = useOverlayTriggerState({});
|
|
1570
|
+
let preview;
|
|
1571
|
+
const childArray = React16.Children.toArray(props.children);
|
|
1572
|
+
for (let i = 0; i < childArray.length; i++) {
|
|
1573
|
+
const child = childArray[i];
|
|
1574
|
+
if (React16.isValidElement(child) && "value" in child.props) {
|
|
1575
|
+
const find = child.props.value === props.value;
|
|
1576
|
+
if (find && "children" in child.props) {
|
|
1577
|
+
preview = child.props.children;
|
|
1578
|
+
break;
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
return /* @__PURE__ */ React16.createElement(DropdownSelectorRoot, { "aria-disabled": props.disabled }, props.showLabel === true && /* @__PURE__ */ React16.createElement(
|
|
1719
1583
|
DropdownFieldLabel,
|
|
1720
1584
|
{
|
|
1721
|
-
label,
|
|
1722
|
-
required,
|
|
1723
|
-
requiredText,
|
|
1724
|
-
subLabel
|
|
1725
|
-
...labelProps,
|
|
1726
|
-
...!showLabel ? visuallyHiddenProps : {}
|
|
1585
|
+
label: props.label,
|
|
1586
|
+
required: props.required,
|
|
1587
|
+
requiredText: props.requiredText ?? defaultRequiredText,
|
|
1588
|
+
subLabel: props.subLabel
|
|
1727
1589
|
}
|
|
1728
|
-
), /* @__PURE__ */
|
|
1729
|
-
|
|
1590
|
+
), /* @__PURE__ */ React16.createElement(
|
|
1591
|
+
DropdownButton,
|
|
1730
1592
|
{
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1593
|
+
invalid: props.invalid,
|
|
1594
|
+
disabled: props.disabled,
|
|
1595
|
+
onClick: () => {
|
|
1596
|
+
if (props.disabled === true)
|
|
1597
|
+
return;
|
|
1598
|
+
state.open();
|
|
1599
|
+
},
|
|
1600
|
+
ref: triggerRef
|
|
1601
|
+
},
|
|
1602
|
+
/* @__PURE__ */ React16.createElement(DropdownButtonText, null, props.placeholder !== void 0 && preview === void 0 ? props.placeholder : preview),
|
|
1603
|
+
/* @__PURE__ */ React16.createElement(DropdownButtonIcon, { name: "16/Menu" })
|
|
1604
|
+
), state.isOpen && /* @__PURE__ */ React16.createElement(
|
|
1739
1605
|
DropdownPopover,
|
|
1740
1606
|
{
|
|
1741
1607
|
state,
|
|
1742
1608
|
triggerRef,
|
|
1743
|
-
value: props.value
|
|
1609
|
+
value: props.value
|
|
1744
1610
|
},
|
|
1745
|
-
/* @__PURE__ */
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1611
|
+
/* @__PURE__ */ React16.createElement(ListboxRoot, null, /* @__PURE__ */ React16.createElement(
|
|
1612
|
+
DropdownSelectorContext.Provider,
|
|
1613
|
+
{
|
|
1614
|
+
value: {
|
|
1615
|
+
value: props.value,
|
|
1616
|
+
setValue: (v) => {
|
|
1617
|
+
props.onChange(v);
|
|
1618
|
+
state.close();
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
},
|
|
1622
|
+
props.children
|
|
1623
|
+
))
|
|
1624
|
+
), props.assistiveText !== void 0 && /* @__PURE__ */ React16.createElement(AssertiveText, { invalid: props.invalid }, props.assistiveText));
|
|
1625
|
+
}
|
|
1626
|
+
var ListboxRoot = styled14.ul`
|
|
1627
|
+
padding-left: 0;
|
|
1628
|
+
margin: 0;
|
|
1629
|
+
box-sizing: border-box;
|
|
1630
|
+
list-style: none;
|
|
1631
|
+
overflow: auto;
|
|
1632
|
+
max-height: inherit;
|
|
1633
|
+
|
|
1634
|
+
${theme((o) => [
|
|
1635
|
+
o.bg.background1,
|
|
1636
|
+
o.border.default,
|
|
1637
|
+
o.borderRadius(8),
|
|
1638
|
+
o.padding.vertical(8)
|
|
1639
|
+
])}
|
|
1640
|
+
`;
|
|
1641
|
+
var DropdownSelectorRoot = styled14.div`
|
|
1759
1642
|
display: inline-block;
|
|
1760
1643
|
width: 100%;
|
|
1761
1644
|
|
|
@@ -1764,15 +1647,12 @@ var DropdownSelectorRoot = styled18.div`
|
|
|
1764
1647
|
${theme((o) => o.disabled)}
|
|
1765
1648
|
}
|
|
1766
1649
|
`;
|
|
1767
|
-
var DropdownFieldLabel =
|
|
1650
|
+
var DropdownFieldLabel = styled14(FieldLabel_default)`
|
|
1768
1651
|
width: 100%;
|
|
1769
1652
|
|
|
1770
1653
|
${theme((o) => o.margin.bottom(8))}
|
|
1771
1654
|
`;
|
|
1772
|
-
var
|
|
1773
|
-
position: relative;
|
|
1774
|
-
`;
|
|
1775
|
-
var DropdownButton = styled18.button`
|
|
1655
|
+
var DropdownButton = styled14.button`
|
|
1776
1656
|
display: flex;
|
|
1777
1657
|
justify-content: space-between;
|
|
1778
1658
|
align-items: center;
|
|
@@ -1792,46 +1672,142 @@ var DropdownButton = styled18.button`
|
|
|
1792
1672
|
o.outline.default.focus,
|
|
1793
1673
|
o.bg.surface3,
|
|
1794
1674
|
o.borderRadius(4),
|
|
1795
|
-
invalid && o.outline.assertive
|
|
1675
|
+
invalid === true && o.outline.assertive
|
|
1796
1676
|
])}
|
|
1797
1677
|
`;
|
|
1798
|
-
var DropdownButtonText =
|
|
1678
|
+
var DropdownButtonText = styled14.span`
|
|
1799
1679
|
text-align: left;
|
|
1800
1680
|
|
|
1801
1681
|
${theme((o) => [o.typography(14), o.font.text2])}
|
|
1802
1682
|
`;
|
|
1803
|
-
var DropdownButtonIcon =
|
|
1683
|
+
var DropdownButtonIcon = styled14(Icon_default)`
|
|
1804
1684
|
${theme((o) => [o.font.text2])}
|
|
1805
1685
|
`;
|
|
1806
|
-
var AssertiveText =
|
|
1686
|
+
var AssertiveText = styled14.div`
|
|
1807
1687
|
${({ invalid }) => theme((o) => [
|
|
1808
1688
|
o.typography(14),
|
|
1809
1689
|
o.margin.top(8),
|
|
1810
|
-
invalid ? o.font.assertive : o.font.text2
|
|
1690
|
+
invalid === true ? o.font.assertive : o.font.text2
|
|
1811
1691
|
])}
|
|
1812
1692
|
`;
|
|
1813
1693
|
|
|
1694
|
+
// src/components/DropdownSelector/OptionItem.tsx
|
|
1695
|
+
import React17, { useContext as useContext5 } from "react";
|
|
1696
|
+
import styled15 from "styled-components";
|
|
1697
|
+
import { px as px3 } from "@charcoal-ui/utils";
|
|
1698
|
+
|
|
1699
|
+
// src/components/DropdownSelector/utils/handleFocusByKeyBoard.tsx
|
|
1700
|
+
function handleFocusByKeyBoard(element) {
|
|
1701
|
+
const parent = element.parentElement;
|
|
1702
|
+
if (!parent)
|
|
1703
|
+
return;
|
|
1704
|
+
const rect = element.getBoundingClientRect();
|
|
1705
|
+
const parentRect = parent.getBoundingClientRect();
|
|
1706
|
+
if (rect.bottom > parentRect.bottom) {
|
|
1707
|
+
parent.scrollTo({
|
|
1708
|
+
top: parent.scrollTop + rect.bottom - parentRect.bottom
|
|
1709
|
+
});
|
|
1710
|
+
} else if (rect.top < parentRect.top) {
|
|
1711
|
+
parent.scrollTo({
|
|
1712
|
+
top: parent.scrollTop - (parentRect.top - rect.top)
|
|
1713
|
+
});
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1717
|
+
// src/components/DropdownSelector/utils/focusIfHTMLLIElement.tsx
|
|
1718
|
+
function focusIfHTMLLIElement(element) {
|
|
1719
|
+
if (element instanceof HTMLLIElement) {
|
|
1720
|
+
element.focus({ preventScroll: true });
|
|
1721
|
+
handleFocusByKeyBoard(element);
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
// src/components/DropdownSelector/OptionItem.tsx
|
|
1726
|
+
function OptionItem(props) {
|
|
1727
|
+
const { value, setValue } = useContext5(DropdownSelectorContext);
|
|
1728
|
+
const isSelected = props.value === value;
|
|
1729
|
+
const onSelect = () => {
|
|
1730
|
+
setValue(props.value);
|
|
1731
|
+
};
|
|
1732
|
+
return /* @__PURE__ */ React17.createElement(
|
|
1733
|
+
OptionRoot,
|
|
1734
|
+
{
|
|
1735
|
+
"data-key": props.value,
|
|
1736
|
+
onMouseMove: (e) => {
|
|
1737
|
+
e.currentTarget.focus({ preventScroll: true });
|
|
1738
|
+
},
|
|
1739
|
+
onKeyDown: (e) => {
|
|
1740
|
+
if (e.key === "Enter") {
|
|
1741
|
+
onSelect();
|
|
1742
|
+
} else if (e.key === "ArrowUp") {
|
|
1743
|
+
e.preventDefault();
|
|
1744
|
+
const prev = e.currentTarget.previousElementSibling;
|
|
1745
|
+
if (prev === null) {
|
|
1746
|
+
focusIfHTMLLIElement(e.currentTarget.parentElement?.lastChild);
|
|
1747
|
+
}
|
|
1748
|
+
focusIfHTMLLIElement(prev);
|
|
1749
|
+
} else if (e.key === "ArrowDown") {
|
|
1750
|
+
e.preventDefault();
|
|
1751
|
+
const next = e.currentTarget.nextElementSibling;
|
|
1752
|
+
if (next === null) {
|
|
1753
|
+
focusIfHTMLLIElement(e.currentTarget.parentElement?.firstChild);
|
|
1754
|
+
}
|
|
1755
|
+
focusIfHTMLLIElement(next);
|
|
1756
|
+
} else if (e.key === " ") {
|
|
1757
|
+
e.preventDefault();
|
|
1758
|
+
}
|
|
1759
|
+
},
|
|
1760
|
+
onClick: onSelect,
|
|
1761
|
+
tabIndex: -1
|
|
1762
|
+
},
|
|
1763
|
+
isSelected && /* @__PURE__ */ React17.createElement(OptionCheckIcon, { name: "16/Check" }),
|
|
1764
|
+
/* @__PURE__ */ React17.createElement(OptionText, { isSelected }, props.children)
|
|
1765
|
+
);
|
|
1766
|
+
}
|
|
1767
|
+
var OptionRoot = styled15.li`
|
|
1768
|
+
display: flex;
|
|
1769
|
+
align-items: center;
|
|
1770
|
+
gap: ${({ theme: theme4 }) => px3(theme4.spacing[4])};
|
|
1771
|
+
height: 40px;
|
|
1772
|
+
cursor: pointer;
|
|
1773
|
+
outline: none;
|
|
1774
|
+
|
|
1775
|
+
${theme((o) => [o.padding.horizontal(8)])}
|
|
1776
|
+
|
|
1777
|
+
:focus {
|
|
1778
|
+
${theme((o) => [o.bg.surface3])}
|
|
1779
|
+
}
|
|
1780
|
+
`;
|
|
1781
|
+
var OptionCheckIcon = styled15(Icon_default)`
|
|
1782
|
+
${theme((o) => [o.font.text2])}
|
|
1783
|
+
`;
|
|
1784
|
+
var OptionText = styled15.span`
|
|
1785
|
+
display: block;
|
|
1786
|
+
${theme((o) => [o.typography(14), o.font.text2])}
|
|
1787
|
+
margin-left: ${({ isSelected }) => isSelected === true ? 0 : 20}px;
|
|
1788
|
+
`;
|
|
1789
|
+
|
|
1814
1790
|
// src/components/SegmentedControl/index.tsx
|
|
1815
|
-
import
|
|
1791
|
+
import React19, { forwardRef, memo, useMemo as useMemo2, useRef as useRef7 } from "react";
|
|
1816
1792
|
import { useRadioGroupState } from "react-stately";
|
|
1817
1793
|
import {
|
|
1818
1794
|
useRadio,
|
|
1819
1795
|
useRadioGroup
|
|
1820
1796
|
} from "@react-aria/radio";
|
|
1821
|
-
import
|
|
1797
|
+
import styled16 from "styled-components";
|
|
1822
1798
|
import { disabledSelector as disabledSelector5 } from "@charcoal-ui/utils";
|
|
1823
1799
|
|
|
1824
1800
|
// src/components/SegmentedControl/RadioGroupContext.tsx
|
|
1825
|
-
import
|
|
1826
|
-
var RadioContext =
|
|
1801
|
+
import React18, { createContext as createContext3, useContext as useContext6 } from "react";
|
|
1802
|
+
var RadioContext = createContext3(null);
|
|
1827
1803
|
var RadioProvider = ({
|
|
1828
1804
|
value,
|
|
1829
1805
|
children
|
|
1830
1806
|
}) => {
|
|
1831
|
-
return /* @__PURE__ */
|
|
1807
|
+
return /* @__PURE__ */ React18.createElement(RadioContext.Provider, { value }, children);
|
|
1832
1808
|
};
|
|
1833
1809
|
var useRadioContext = () => {
|
|
1834
|
-
const state =
|
|
1810
|
+
const state = useContext6(RadioContext);
|
|
1835
1811
|
if (state === null)
|
|
1836
1812
|
throw new Error("`<RadioProvider>` is not likely mounted.");
|
|
1837
1813
|
return state;
|
|
@@ -1840,23 +1816,24 @@ var useRadioContext = () => {
|
|
|
1840
1816
|
// src/components/SegmentedControl/index.tsx
|
|
1841
1817
|
var SegmentedControl = forwardRef(
|
|
1842
1818
|
function SegmentedControlInner(props, ref) {
|
|
1843
|
-
const ariaRadioGroupProps =
|
|
1819
|
+
const ariaRadioGroupProps = useMemo2(
|
|
1844
1820
|
() => ({
|
|
1845
1821
|
...props,
|
|
1846
1822
|
isDisabled: props.disabled,
|
|
1847
1823
|
isReadOnly: props.readonly,
|
|
1848
|
-
isRequired: props.required
|
|
1824
|
+
isRequired: props.required,
|
|
1825
|
+
"aria-label": props.name
|
|
1849
1826
|
}),
|
|
1850
1827
|
[props]
|
|
1851
1828
|
);
|
|
1852
1829
|
const state = useRadioGroupState(ariaRadioGroupProps);
|
|
1853
1830
|
const { radioGroupProps } = useRadioGroup(ariaRadioGroupProps, state);
|
|
1854
|
-
const segmentedControlItems =
|
|
1831
|
+
const segmentedControlItems = useMemo2(() => {
|
|
1855
1832
|
return props.data.map(
|
|
1856
1833
|
(d) => typeof d === "string" ? { value: d, label: d } : d
|
|
1857
1834
|
);
|
|
1858
1835
|
}, [props.data]);
|
|
1859
|
-
return /* @__PURE__ */
|
|
1836
|
+
return /* @__PURE__ */ React19.createElement(SegmentedControlRoot, { ref, ...radioGroupProps }, /* @__PURE__ */ React19.createElement(RadioProvider, { value: state }, segmentedControlItems.map((item) => /* @__PURE__ */ React19.createElement(
|
|
1860
1837
|
Segmented,
|
|
1861
1838
|
{
|
|
1862
1839
|
key: item.value,
|
|
@@ -1867,11 +1844,11 @@ var SegmentedControl = forwardRef(
|
|
|
1867
1844
|
))));
|
|
1868
1845
|
}
|
|
1869
1846
|
);
|
|
1870
|
-
var SegmentedControl_default =
|
|
1847
|
+
var SegmentedControl_default = memo(SegmentedControl);
|
|
1871
1848
|
var Segmented = ({ children, ...props }) => {
|
|
1872
1849
|
const state = useRadioContext();
|
|
1873
|
-
const ref =
|
|
1874
|
-
const ariaRadioProps =
|
|
1850
|
+
const ref = useRef7(null);
|
|
1851
|
+
const ariaRadioProps = useMemo2(
|
|
1875
1852
|
() => ({ ...props, isDisabled: props.disabled }),
|
|
1876
1853
|
[props]
|
|
1877
1854
|
);
|
|
@@ -1880,23 +1857,23 @@ var Segmented = ({ children, ...props }) => {
|
|
|
1880
1857
|
state,
|
|
1881
1858
|
ref
|
|
1882
1859
|
);
|
|
1883
|
-
return /* @__PURE__ */
|
|
1860
|
+
return /* @__PURE__ */ React19.createElement(
|
|
1884
1861
|
SegmentedRoot,
|
|
1885
1862
|
{
|
|
1886
1863
|
"aria-disabled": isDisabled || state.isReadOnly,
|
|
1887
1864
|
checked: isSelected
|
|
1888
1865
|
},
|
|
1889
|
-
/* @__PURE__ */
|
|
1890
|
-
/* @__PURE__ */
|
|
1866
|
+
/* @__PURE__ */ React19.createElement(SegmentedInput, { ...inputProps, ref }),
|
|
1867
|
+
/* @__PURE__ */ React19.createElement(RadioLabel2, null, /* @__PURE__ */ React19.createElement(SegmentedLabelInner, null, children))
|
|
1891
1868
|
);
|
|
1892
1869
|
};
|
|
1893
|
-
var SegmentedControlRoot =
|
|
1870
|
+
var SegmentedControlRoot = styled16.div`
|
|
1894
1871
|
display: inline-flex;
|
|
1895
1872
|
align-items: center;
|
|
1896
1873
|
|
|
1897
1874
|
${theme((o) => [o.bg.surface3, o.borderRadius(16)])}
|
|
1898
1875
|
`;
|
|
1899
|
-
var SegmentedRoot =
|
|
1876
|
+
var SegmentedRoot = styled16.label`
|
|
1900
1877
|
position: relative;
|
|
1901
1878
|
display: flex;
|
|
1902
1879
|
align-items: center;
|
|
@@ -1915,7 +1892,7 @@ var SegmentedRoot = styled19.label`
|
|
|
1915
1892
|
checked === true ? o.font.text5 : o.font.text2
|
|
1916
1893
|
])}
|
|
1917
1894
|
`;
|
|
1918
|
-
var SegmentedInput =
|
|
1895
|
+
var SegmentedInput = styled16.input`
|
|
1919
1896
|
position: absolute;
|
|
1920
1897
|
|
|
1921
1898
|
height: 0px;
|
|
@@ -1929,26 +1906,26 @@ var SegmentedInput = styled19.input`
|
|
|
1929
1906
|
white-space: nowrap;
|
|
1930
1907
|
opacity: 0;
|
|
1931
1908
|
`;
|
|
1932
|
-
var RadioLabel2 =
|
|
1909
|
+
var RadioLabel2 = styled16.div`
|
|
1933
1910
|
background: transparent;
|
|
1934
1911
|
display: flex;
|
|
1935
1912
|
align-items: center;
|
|
1936
1913
|
height: 22px;
|
|
1937
1914
|
`;
|
|
1938
|
-
var SegmentedLabelInner =
|
|
1915
|
+
var SegmentedLabelInner = styled16.div`
|
|
1939
1916
|
${theme((o) => [o.typography(14)])}
|
|
1940
1917
|
`;
|
|
1941
1918
|
|
|
1942
1919
|
// src/components/Checkbox/index.tsx
|
|
1943
|
-
import
|
|
1944
|
-
import
|
|
1920
|
+
import React20, { forwardRef as forwardRef2, memo as memo2, useMemo as useMemo3 } from "react";
|
|
1921
|
+
import styled17, { css as css5 } from "styled-components";
|
|
1945
1922
|
import { useCheckbox } from "@react-aria/checkbox";
|
|
1946
1923
|
import { useObjectRef } from "@react-aria/utils";
|
|
1947
1924
|
import { useToggleState as useToggleState2 } from "react-stately";
|
|
1948
1925
|
import { disabledSelector as disabledSelector6, px as px4 } from "@charcoal-ui/utils";
|
|
1949
1926
|
var Checkbox = forwardRef2(
|
|
1950
1927
|
function CheckboxInner(props, ref) {
|
|
1951
|
-
const ariaCheckboxProps =
|
|
1928
|
+
const ariaCheckboxProps = useMemo3(
|
|
1952
1929
|
() => ({
|
|
1953
1930
|
...props,
|
|
1954
1931
|
isSelected: props.checked,
|
|
@@ -1962,14 +1939,14 @@ var Checkbox = forwardRef2(
|
|
|
1962
1939
|
const objectRef = useObjectRef(ref);
|
|
1963
1940
|
const { inputProps } = useCheckbox(ariaCheckboxProps, state, objectRef);
|
|
1964
1941
|
const isDisabled = (props.disabled ?? false) || (props.readonly ?? false);
|
|
1965
|
-
return /* @__PURE__ */
|
|
1942
|
+
return /* @__PURE__ */ React20.createElement(InputRoot, { "aria-disabled": isDisabled }, /* @__PURE__ */ React20.createElement(CheckboxRoot, null, /* @__PURE__ */ React20.createElement(CheckboxInput, { type: "checkbox", ...inputProps }), /* @__PURE__ */ React20.createElement(CheckboxInputOverlay, { "aria-hidden": true, checked: inputProps.checked }, /* @__PURE__ */ React20.createElement(Icon_default, { name: "24/Check", unsafeNonGuidelineScale: 2 / 3 }))), "children" in props && /* @__PURE__ */ React20.createElement(InputLabel, null, props.children));
|
|
1966
1943
|
}
|
|
1967
1944
|
);
|
|
1968
|
-
var Checkbox_default =
|
|
1969
|
-
var hiddenCss =
|
|
1945
|
+
var Checkbox_default = memo2(Checkbox);
|
|
1946
|
+
var hiddenCss = css5`
|
|
1970
1947
|
visibility: hidden;
|
|
1971
1948
|
`;
|
|
1972
|
-
var InputRoot =
|
|
1949
|
+
var InputRoot = styled17.label`
|
|
1973
1950
|
position: relative;
|
|
1974
1951
|
display: flex;
|
|
1975
1952
|
|
|
@@ -1981,10 +1958,10 @@ var InputRoot = styled20.label`
|
|
|
1981
1958
|
gap: ${({ theme: theme4 }) => px4(theme4.spacing[4])};
|
|
1982
1959
|
${theme((o) => [o.disabled])}
|
|
1983
1960
|
`;
|
|
1984
|
-
var CheckboxRoot =
|
|
1961
|
+
var CheckboxRoot = styled17.div`
|
|
1985
1962
|
position: relative;
|
|
1986
1963
|
`;
|
|
1987
|
-
var CheckboxInput =
|
|
1964
|
+
var CheckboxInput = styled17.input`
|
|
1988
1965
|
&[type='checkbox'] {
|
|
1989
1966
|
appearance: none;
|
|
1990
1967
|
display: block;
|
|
@@ -2007,7 +1984,7 @@ var CheckboxInput = styled20.input`
|
|
|
2007
1984
|
transition: all 0.2s !important;
|
|
2008
1985
|
}
|
|
2009
1986
|
`;
|
|
2010
|
-
var CheckboxInputOverlay =
|
|
1987
|
+
var CheckboxInputOverlay = styled17.div`
|
|
2011
1988
|
position: absolute;
|
|
2012
1989
|
top: -2px;
|
|
2013
1990
|
left: -2px;
|
|
@@ -2020,7 +1997,7 @@ var CheckboxInputOverlay = styled20.div`
|
|
|
2020
1997
|
|
|
2021
1998
|
${({ checked }) => checked !== true && hiddenCss};
|
|
2022
1999
|
`;
|
|
2023
|
-
var InputLabel =
|
|
2000
|
+
var InputLabel = styled17.div`
|
|
2024
2001
|
${theme((o) => [o.font.text2])}
|
|
2025
2002
|
|
|
2026
2003
|
font-size: 14px;
|
|
@@ -2029,15 +2006,15 @@ var InputLabel = styled20.div`
|
|
|
2029
2006
|
`;
|
|
2030
2007
|
|
|
2031
2008
|
// src/components/TagItem/index.tsx
|
|
2032
|
-
import
|
|
2009
|
+
import React21, {
|
|
2033
2010
|
forwardRef as forwardRef3,
|
|
2034
|
-
memo as
|
|
2035
|
-
useMemo as
|
|
2011
|
+
memo as memo3,
|
|
2012
|
+
useMemo as useMemo4
|
|
2036
2013
|
} from "react";
|
|
2037
2014
|
import { useObjectRef as useObjectRef2 } from "@react-aria/utils";
|
|
2038
|
-
import
|
|
2015
|
+
import styled18, { css as css6 } from "styled-components";
|
|
2039
2016
|
import { disabledSelector as disabledSelector7, px as px5 } from "@charcoal-ui/utils";
|
|
2040
|
-
import { useButton
|
|
2017
|
+
import { useButton } from "@react-aria/button";
|
|
2041
2018
|
var sizeMap = {
|
|
2042
2019
|
S: 32,
|
|
2043
2020
|
M: 40
|
|
@@ -2055,7 +2032,7 @@ var TagItem = forwardRef3(
|
|
|
2055
2032
|
...props
|
|
2056
2033
|
}, _ref) {
|
|
2057
2034
|
const ref = useObjectRef2(_ref);
|
|
2058
|
-
const ariaButtonProps =
|
|
2035
|
+
const ariaButtonProps = useMemo4(
|
|
2059
2036
|
() => ({
|
|
2060
2037
|
elementType: "a",
|
|
2061
2038
|
isDisabled: disabled,
|
|
@@ -2063,9 +2040,9 @@ var TagItem = forwardRef3(
|
|
|
2063
2040
|
}),
|
|
2064
2041
|
[disabled, props]
|
|
2065
2042
|
);
|
|
2066
|
-
const { buttonProps } =
|
|
2043
|
+
const { buttonProps } = useButton(ariaButtonProps, ref);
|
|
2067
2044
|
const hasTranslatedLabel = translatedLabel !== void 0 && translatedLabel.length > 0;
|
|
2068
|
-
return /* @__PURE__ */
|
|
2045
|
+
return /* @__PURE__ */ React21.createElement(
|
|
2069
2046
|
TagItemRoot,
|
|
2070
2047
|
{
|
|
2071
2048
|
ref,
|
|
@@ -2074,13 +2051,13 @@ var TagItem = forwardRef3(
|
|
|
2074
2051
|
...buttonProps,
|
|
2075
2052
|
className
|
|
2076
2053
|
},
|
|
2077
|
-
/* @__PURE__ */
|
|
2078
|
-
/* @__PURE__ */
|
|
2054
|
+
/* @__PURE__ */ React21.createElement(Background, { bgColor, bgImage, status }),
|
|
2055
|
+
/* @__PURE__ */ React21.createElement(Inner, null, /* @__PURE__ */ React21.createElement(LabelWrapper, { isTranslate: hasTranslatedLabel }, hasTranslatedLabel && /* @__PURE__ */ React21.createElement(TranslatedLabel, null, /* @__PURE__ */ React21.createElement(Label3, null, translatedLabel)), /* @__PURE__ */ React21.createElement(Label3, null, label)), status === "active" && /* @__PURE__ */ React21.createElement(Icon_default, { name: "16/Remove" }))
|
|
2079
2056
|
);
|
|
2080
2057
|
}
|
|
2081
2058
|
);
|
|
2082
|
-
var TagItem_default =
|
|
2083
|
-
var TagItemRoot =
|
|
2059
|
+
var TagItem_default = memo3(TagItem);
|
|
2060
|
+
var TagItemRoot = styled18.a`
|
|
2084
2061
|
isolation: isolate;
|
|
2085
2062
|
position: relative;
|
|
2086
2063
|
height: ${({ size }) => sizeMap[size]}px;
|
|
@@ -2105,7 +2082,7 @@ var TagItemRoot = styled21.a`
|
|
|
2105
2082
|
cursor: default;
|
|
2106
2083
|
}
|
|
2107
2084
|
`;
|
|
2108
|
-
var Background =
|
|
2085
|
+
var Background = styled18.div`
|
|
2109
2086
|
position: absolute;
|
|
2110
2087
|
z-index: 1;
|
|
2111
2088
|
top: 0;
|
|
@@ -2116,7 +2093,7 @@ var Background = styled21.div`
|
|
|
2116
2093
|
background-color: ${({ bgColor }) => bgColor};
|
|
2117
2094
|
${({ status }) => status === "inactive" && theme((o) => o.bg.surface3)}
|
|
2118
2095
|
|
|
2119
|
-
${({ bgImage }) => bgImage !== void 0 &&
|
|
2096
|
+
${({ bgImage }) => bgImage !== void 0 && css6`
|
|
2120
2097
|
${theme((o) => [o.bg.surface4])}
|
|
2121
2098
|
&::before {
|
|
2122
2099
|
content: '';
|
|
@@ -2132,25 +2109,25 @@ var Background = styled21.div`
|
|
|
2132
2109
|
}
|
|
2133
2110
|
`}
|
|
2134
2111
|
`;
|
|
2135
|
-
var Inner =
|
|
2112
|
+
var Inner = styled18.div`
|
|
2136
2113
|
display: inline-flex;
|
|
2137
2114
|
gap: ${({ theme: theme4 }) => px5(theme4.spacing[8])};
|
|
2138
2115
|
align-items: center;
|
|
2139
2116
|
z-index: 2;
|
|
2140
2117
|
`;
|
|
2141
|
-
var labelCSS =
|
|
2118
|
+
var labelCSS = css6`
|
|
2142
2119
|
${theme((o) => [o.typography(14).bold])}
|
|
2143
2120
|
`;
|
|
2144
|
-
var translateLabelCSS =
|
|
2121
|
+
var translateLabelCSS = css6`
|
|
2145
2122
|
display: flex;
|
|
2146
2123
|
align-items: center;
|
|
2147
2124
|
flex-direction: column;
|
|
2148
2125
|
font-size: 10px;
|
|
2149
2126
|
`;
|
|
2150
|
-
var LabelWrapper =
|
|
2127
|
+
var LabelWrapper = styled18.div`
|
|
2151
2128
|
${({ isTranslate }) => isTranslate ?? false ? translateLabelCSS : labelCSS}
|
|
2152
2129
|
`;
|
|
2153
|
-
var Label3 =
|
|
2130
|
+
var Label3 = styled18.span`
|
|
2154
2131
|
max-width: 152px;
|
|
2155
2132
|
overflow: hidden;
|
|
2156
2133
|
text-overflow: ellipsis;
|
|
@@ -2159,7 +2136,7 @@ var Label3 = styled21.span`
|
|
|
2159
2136
|
color: inherit;
|
|
2160
2137
|
line-height: inherit;
|
|
2161
2138
|
`;
|
|
2162
|
-
var TranslatedLabel =
|
|
2139
|
+
var TranslatedLabel = styled18.div`
|
|
2163
2140
|
${theme((o) => [o.typography(12).bold])}
|
|
2164
2141
|
`;
|
|
2165
2142
|
export {
|
|
@@ -2168,8 +2145,7 @@ export {
|
|
|
2168
2145
|
Checkbox_default as Checkbox,
|
|
2169
2146
|
Clickable_default as Clickable,
|
|
2170
2147
|
ComponentAbstraction,
|
|
2171
|
-
|
|
2172
|
-
DropdownSelectorItem,
|
|
2148
|
+
DropdownSelector,
|
|
2173
2149
|
Icon_default as Icon,
|
|
2174
2150
|
IconButton_default as IconButton,
|
|
2175
2151
|
LoadingSpinner,
|
|
@@ -2181,6 +2157,7 @@ export {
|
|
|
2181
2157
|
ModalHeader,
|
|
2182
2158
|
MultiSelect,
|
|
2183
2159
|
MultiSelectGroup,
|
|
2160
|
+
OptionItem,
|
|
2184
2161
|
OverlayProvider,
|
|
2185
2162
|
Radio,
|
|
2186
2163
|
RadioGroup,
|