@charcoal-ui/react 2.4.0 → 2.6.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/dist/_lib/compat.d.ts +1 -1
- package/dist/_lib/compat.d.ts.map +1 -1
- package/dist/components/Button/index.d.ts +3 -3
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.d.ts +2 -2
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.story.d.ts +1 -1
- package/dist/components/Checkbox/index.story.d.ts.map +1 -1
- package/dist/components/Clickable/index.d.ts +2 -2
- package/dist/components/Clickable/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Divider.d.ts +4 -0
- package/dist/components/DropdownSelector/Divider.d.ts.map +1 -0
- package/dist/components/DropdownSelector/DropdownPopover.d.ts +1 -1
- package/dist/components/DropdownSelector/DropdownPopover.d.ts.map +1 -1
- package/dist/components/DropdownSelector/ListBoxSection.d.ts +7 -0
- package/dist/components/DropdownSelector/ListBoxSection.d.ts.map +1 -0
- package/dist/components/DropdownSelector/Listbox.d.ts +2 -2
- package/dist/components/DropdownSelector/Listbox.d.ts.map +1 -1
- package/dist/components/DropdownSelector/Option.d.ts +11 -0
- package/dist/components/DropdownSelector/Option.d.ts.map +1 -0
- package/dist/components/DropdownSelector/index.d.ts +3 -3
- package/dist/components/DropdownSelector/index.d.ts.map +1 -1
- package/dist/components/DropdownSelector/index.story.d.ts +5 -5
- package/dist/components/DropdownSelector/index.story.d.ts.map +1 -1
- package/dist/components/Icon/index.story.d.ts +8 -3
- package/dist/components/Icon/index.story.d.ts.map +1 -1
- package/dist/components/IconButton/index.d.ts +3 -3
- package/dist/components/IconButton/index.d.ts.map +1 -1
- package/dist/components/IconButton/index.story.d.ts +1 -1
- package/dist/components/IconButton/index.story.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/context.d.ts +1 -1
- package/dist/components/MultiSelect/context.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.d.ts +2 -2
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/MultiSelect/index.story.d.ts +2 -2
- package/dist/components/MultiSelect/index.story.d.ts.map +1 -1
- package/dist/components/Radio/index.d.ts +2 -2
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.d.ts +1 -1
- package/dist/components/SegmentedControl/RadioGroupContext.d.ts.map +1 -1
- package/dist/components/SegmentedControl/index.d.ts +2 -2
- package/dist/components/SegmentedControl/index.d.ts.map +1 -1
- package/dist/components/Switch/index.d.ts +1 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/TagItem/index.d.ts +1 -1
- package/dist/components/TagItem/index.d.ts.map +1 -1
- package/dist/components/TextField/index.d.ts +2 -2
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/core/CharcoalProvider.d.ts +1 -1
- package/dist/core/CharcoalProvider.d.ts.map +1 -1
- package/dist/core/ComponentAbstraction.d.ts +1 -1
- package/dist/core/ComponentAbstraction.d.ts.map +1 -1
- package/dist/index.cjs.js +171 -127
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +155 -111
- package/dist/index.esm.js.map +1 -1
- package/dist/styled.d.ts +77 -75
- package/dist/styled.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/components/DropdownSelector/Divider.tsx +13 -0
- package/src/components/DropdownSelector/DropdownPopover.tsx +1 -1
- package/src/components/DropdownSelector/ListBoxSection.tsx +60 -0
- package/src/components/DropdownSelector/Listbox.tsx +11 -74
- package/src/components/DropdownSelector/Option.tsx +66 -0
- package/src/components/DropdownSelector/index.story.tsx +9 -14
- package/src/components/Icon/index.story.tsx +6 -2
- package/src/components/TagItem/index.tsx +5 -3
package/dist/index.esm.js
CHANGED
|
@@ -1459,8 +1459,8 @@ var LoadingSpinnerIcon = React14.forwardRef(function LoadingSpinnerIcon2({ once
|
|
|
1459
1459
|
});
|
|
1460
1460
|
|
|
1461
1461
|
// src/components/DropdownSelector/index.tsx
|
|
1462
|
-
import
|
|
1463
|
-
import
|
|
1462
|
+
import React19, { useMemo as useMemo3, useRef as useRef8 } from "react";
|
|
1463
|
+
import styled18 from "styled-components";
|
|
1464
1464
|
import { Item, useSelectState } from "react-stately";
|
|
1465
1465
|
import { disabledSelector as disabledSelector4 } from "@charcoal-ui/utils";
|
|
1466
1466
|
import { useVisuallyHidden as useVisuallyHidden2 } from "@react-aria/visually-hidden";
|
|
@@ -1468,18 +1468,108 @@ import { useSelect, HiddenSelect } from "@react-aria/select";
|
|
|
1468
1468
|
import { useButton } from "@react-aria/button";
|
|
1469
1469
|
|
|
1470
1470
|
// src/components/DropdownSelector/Listbox.tsx
|
|
1471
|
-
import
|
|
1472
|
-
import
|
|
1473
|
-
import { useListBox
|
|
1471
|
+
import React17, { memo, useRef as useRef6, Fragment, useMemo as useMemo2 } from "react";
|
|
1472
|
+
import styled16 from "styled-components";
|
|
1473
|
+
import { useListBox } from "@react-aria/listbox";
|
|
1474
|
+
|
|
1475
|
+
// src/components/DropdownSelector/ListBoxSection.tsx
|
|
1476
|
+
import { useListBoxSection } from "@react-aria/listbox";
|
|
1477
|
+
import { useSeparator } from "@react-aria/separator";
|
|
1478
|
+
import React16 from "react";
|
|
1479
|
+
import styled15 from "styled-components";
|
|
1480
|
+
|
|
1481
|
+
// src/components/DropdownSelector/Option.tsx
|
|
1482
|
+
import React15, { useRef as useRef5 } from "react";
|
|
1483
|
+
import styled13, { css as css5 } from "styled-components";
|
|
1484
|
+
import { useOption } from "@react-aria/listbox";
|
|
1474
1485
|
import { mergeProps } from "@react-aria/utils";
|
|
1475
1486
|
import { useFocusRing } from "@react-aria/focus";
|
|
1476
1487
|
import { px as px3 } from "@charcoal-ui/utils";
|
|
1488
|
+
function Option({ item, state, mode }) {
|
|
1489
|
+
const ref = useRef5(null);
|
|
1490
|
+
const { optionProps, isSelected } = useOption(item, state, ref);
|
|
1491
|
+
const { focusProps } = useFocusRing();
|
|
1492
|
+
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));
|
|
1493
|
+
}
|
|
1494
|
+
var OptionRoot = styled13.li`
|
|
1495
|
+
display: flex;
|
|
1496
|
+
align-items: center;
|
|
1497
|
+
gap: ${({ theme: theme4 }) => px3(theme4.spacing[4])};
|
|
1498
|
+
height: 40px;
|
|
1499
|
+
cursor: pointer;
|
|
1500
|
+
outline: none;
|
|
1501
|
+
|
|
1502
|
+
${({ mode }) => theme((o) => [
|
|
1503
|
+
o.padding.horizontal(8),
|
|
1504
|
+
mode === "separator" && o.padding.vertical(4)
|
|
1505
|
+
])}
|
|
1506
|
+
|
|
1507
|
+
&:focus {
|
|
1508
|
+
${theme((o) => [o.bg.surface3])}
|
|
1509
|
+
}
|
|
1510
|
+
`;
|
|
1511
|
+
var OptionCheckIcon = styled13(Icon_default)`
|
|
1512
|
+
visibility: hidden;
|
|
1513
|
+
${theme((o) => [o.font.text2])}
|
|
1514
|
+
|
|
1515
|
+
${({ isSelected }) => isSelected && css5`
|
|
1516
|
+
visibility: visible;
|
|
1517
|
+
`}
|
|
1518
|
+
`;
|
|
1519
|
+
var OptionText = styled13.span`
|
|
1520
|
+
display: block;
|
|
1521
|
+
${theme((o) => [o.typography(14), o.font.text2])}
|
|
1522
|
+
`;
|
|
1523
|
+
|
|
1524
|
+
// src/components/DropdownSelector/Divider.tsx
|
|
1525
|
+
import styled14 from "styled-components";
|
|
1526
|
+
var Divider = styled14.div.attrs({ role: "separator" })`
|
|
1527
|
+
display: flex;
|
|
1528
|
+
|
|
1529
|
+
&:before {
|
|
1530
|
+
content: '';
|
|
1531
|
+
display: block;
|
|
1532
|
+
width: 100%;
|
|
1533
|
+
height: 1px;
|
|
1534
|
+
background: #00000014;
|
|
1535
|
+
}
|
|
1536
|
+
`;
|
|
1537
|
+
|
|
1538
|
+
// src/components/DropdownSelector/ListBoxSection.tsx
|
|
1539
|
+
function ListBoxSection(props) {
|
|
1540
|
+
const { state } = props;
|
|
1541
|
+
const { itemProps, headingProps, groupProps } = useListBoxSection({
|
|
1542
|
+
heading: props.section.rendered,
|
|
1543
|
+
"aria-label": props.section["aria-label"]
|
|
1544
|
+
});
|
|
1545
|
+
const { separatorProps } = useSeparator({
|
|
1546
|
+
elementType: "li"
|
|
1547
|
+
});
|
|
1548
|
+
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 })))));
|
|
1549
|
+
}
|
|
1550
|
+
var SectionSpan = styled15.span`
|
|
1551
|
+
${theme((o) => [
|
|
1552
|
+
o.font.text3,
|
|
1553
|
+
o.typography(12).bold,
|
|
1554
|
+
o.margin.bottom(8).left(16).top(16)
|
|
1555
|
+
])}
|
|
1556
|
+
`;
|
|
1557
|
+
var StyledUl = styled15.ul`
|
|
1558
|
+
padding-left: 0;
|
|
1559
|
+
margin: 0;
|
|
1560
|
+
box-sizing: border-box;
|
|
1561
|
+
list-style: none;
|
|
1562
|
+
overflow: hidden;
|
|
1563
|
+
`;
|
|
1564
|
+
var StyledLi = styled15.li``;
|
|
1565
|
+
|
|
1566
|
+
// src/components/DropdownSelector/Listbox.tsx
|
|
1477
1567
|
var Listbox = ({
|
|
1478
1568
|
state,
|
|
1479
1569
|
mode = "default",
|
|
1480
1570
|
...props
|
|
1481
1571
|
}) => {
|
|
1482
|
-
const ref =
|
|
1572
|
+
const ref = useRef6(null);
|
|
1483
1573
|
const { listBoxProps } = useListBox(props, state, ref);
|
|
1484
1574
|
const collection = useMemo2(
|
|
1485
1575
|
() => [...state.collection].map((node, index, self) => ({
|
|
@@ -1489,10 +1579,10 @@ var Listbox = ({
|
|
|
1489
1579
|
})),
|
|
1490
1580
|
[state.collection]
|
|
1491
1581
|
);
|
|
1492
|
-
return /* @__PURE__ */
|
|
1582
|
+
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))));
|
|
1493
1583
|
};
|
|
1494
1584
|
var Listbox_default = memo(Listbox);
|
|
1495
|
-
var ListboxRoot =
|
|
1585
|
+
var ListboxRoot = styled16.ul`
|
|
1496
1586
|
padding-left: 0;
|
|
1497
1587
|
margin: 0;
|
|
1498
1588
|
box-sizing: border-box;
|
|
@@ -1504,71 +1594,25 @@ var ListboxRoot = styled13.ul`
|
|
|
1504
1594
|
o.bg.background1,
|
|
1505
1595
|
o.border.default,
|
|
1506
1596
|
o.borderRadius(8),
|
|
1597
|
+
o.padding.vertical(8),
|
|
1507
1598
|
o.outline.default.focus
|
|
1508
1599
|
])}
|
|
1509
1600
|
`;
|
|
1510
|
-
var Divider = styled13.div.attrs({ role: "separator" })`
|
|
1511
|
-
display: flex;
|
|
1512
|
-
${theme((o) => [o.padding.horizontal(8)])}
|
|
1513
|
-
|
|
1514
|
-
&:before {
|
|
1515
|
-
content: '';
|
|
1516
|
-
display: block;
|
|
1517
|
-
width: 100%;
|
|
1518
|
-
height: 1px;
|
|
1519
|
-
background: #00000014;
|
|
1520
|
-
}
|
|
1521
|
-
`;
|
|
1522
|
-
var Option = ({ item, state, mode }) => {
|
|
1523
|
-
const ref = useRef5(null);
|
|
1524
|
-
const { optionProps, isSelected } = useOption(item, state, ref);
|
|
1525
|
-
const { focusProps } = useFocusRing();
|
|
1526
|
-
return /* @__PURE__ */ React15.createElement(OptionRoot, { ...mergeProps(optionProps, focusProps), ref, mode }, isSelected && /* @__PURE__ */ React15.createElement(OptionCheckIcon, { name: "16/Check" }), /* @__PURE__ */ React15.createElement(OptionText, { isSelected }, item.rendered));
|
|
1527
|
-
};
|
|
1528
|
-
var OptionRoot = styled13.li`
|
|
1529
|
-
display: flex;
|
|
1530
|
-
align-items: center;
|
|
1531
|
-
gap: ${({ theme: theme4 }) => px3(theme4.spacing[4])};
|
|
1532
|
-
height: 40px;
|
|
1533
|
-
cursor: pointer;
|
|
1534
|
-
outline: none;
|
|
1535
|
-
|
|
1536
|
-
${({ mode }) => theme((o) => [
|
|
1537
|
-
o.padding.horizontal(8),
|
|
1538
|
-
mode === "separator" && o.padding.vertical(4)
|
|
1539
|
-
])}
|
|
1540
|
-
|
|
1541
|
-
&:focus {
|
|
1542
|
-
${theme((o) => [o.bg.surface3])}
|
|
1543
|
-
}
|
|
1544
|
-
`;
|
|
1545
|
-
var OptionCheckIcon = styled13(Icon_default)`
|
|
1546
|
-
${theme((o) => [o.font.text2])}
|
|
1547
|
-
`;
|
|
1548
|
-
var OptionText = styled13.span`
|
|
1549
|
-
display: block;
|
|
1550
|
-
${({ isSelected }) => theme((o) => [
|
|
1551
|
-
o.typography(14),
|
|
1552
|
-
o.font.text2,
|
|
1553
|
-
isSelected ? void 0 : o.margin.left(16),
|
|
1554
|
-
isSelected ? void 0 : o.padding.left(4)
|
|
1555
|
-
])}
|
|
1556
|
-
`;
|
|
1557
1601
|
|
|
1558
1602
|
// src/components/DropdownSelector/DropdownPopover.tsx
|
|
1559
|
-
import
|
|
1603
|
+
import React18, { useEffect as useEffect2, useRef as useRef7 } from "react";
|
|
1560
1604
|
import {
|
|
1561
1605
|
DismissButton,
|
|
1562
1606
|
Overlay as Overlay2,
|
|
1563
1607
|
usePopover
|
|
1564
1608
|
} from "@react-aria/overlays";
|
|
1565
|
-
import
|
|
1566
|
-
var DropdownPopoverDiv =
|
|
1609
|
+
import styled17 from "styled-components";
|
|
1610
|
+
var DropdownPopoverDiv = styled17.div`
|
|
1567
1611
|
width: 100%;
|
|
1568
1612
|
${theme((o) => o.margin.top(4).bottom(4))}
|
|
1569
1613
|
`;
|
|
1570
1614
|
function DropdownPopover({ children, state, ...props }) {
|
|
1571
|
-
const ref =
|
|
1615
|
+
const ref = useRef7(null);
|
|
1572
1616
|
const { popoverProps, underlayProps } = usePopover(
|
|
1573
1617
|
{
|
|
1574
1618
|
...props,
|
|
@@ -1597,7 +1641,7 @@ function DropdownPopover({ children, state, ...props }) {
|
|
|
1597
1641
|
});
|
|
1598
1642
|
}
|
|
1599
1643
|
}, [props.value, state.isOpen]);
|
|
1600
|
-
return /* @__PURE__ */
|
|
1644
|
+
return /* @__PURE__ */ React18.createElement(Overlay2, { portalContainer: document.body }, /* @__PURE__ */ React18.createElement("div", { ...underlayProps, style: { position: "fixed", inset: 0 } }), /* @__PURE__ */ React18.createElement(DropdownPopoverDiv, { ...popoverProps, ref }, /* @__PURE__ */ React18.createElement(DismissButton, { onDismiss: () => state.close() }), children, /* @__PURE__ */ React18.createElement(DismissButton, { onDismiss: () => state.close() })));
|
|
1601
1645
|
}
|
|
1602
1646
|
|
|
1603
1647
|
// src/components/DropdownSelector/index.tsx
|
|
@@ -1617,7 +1661,7 @@ var DropdownSelector = ({
|
|
|
1617
1661
|
...props
|
|
1618
1662
|
}) => {
|
|
1619
1663
|
const { visuallyHiddenProps } = useVisuallyHidden2();
|
|
1620
|
-
const triggerRef =
|
|
1664
|
+
const triggerRef = useRef8(null);
|
|
1621
1665
|
const selectProps = useMemo3(
|
|
1622
1666
|
() => ({
|
|
1623
1667
|
...props,
|
|
@@ -1644,7 +1688,7 @@ var DropdownSelector = ({
|
|
|
1644
1688
|
} = useSelect(selectProps, state, triggerRef);
|
|
1645
1689
|
const { buttonProps } = useButton(triggerProps, triggerRef);
|
|
1646
1690
|
const hasAssertiveText = assertiveText !== void 0 && assertiveText.length > 0;
|
|
1647
|
-
return /* @__PURE__ */
|
|
1691
|
+
return /* @__PURE__ */ React19.createElement(DropdownSelectorRoot, { "aria-disabled": disabled, className }, /* @__PURE__ */ React19.createElement(
|
|
1648
1692
|
DropdownFieldLabel,
|
|
1649
1693
|
{
|
|
1650
1694
|
label,
|
|
@@ -1654,7 +1698,7 @@ var DropdownSelector = ({
|
|
|
1654
1698
|
...labelProps,
|
|
1655
1699
|
...!showLabel ? visuallyHiddenProps : {}
|
|
1656
1700
|
}
|
|
1657
|
-
), /* @__PURE__ */
|
|
1701
|
+
), /* @__PURE__ */ React19.createElement(
|
|
1658
1702
|
HiddenSelect,
|
|
1659
1703
|
{
|
|
1660
1704
|
state,
|
|
@@ -1664,15 +1708,15 @@ var DropdownSelector = ({
|
|
|
1664
1708
|
isDisabled: disabled,
|
|
1665
1709
|
autoComplete
|
|
1666
1710
|
}
|
|
1667
|
-
), /* @__PURE__ */
|
|
1711
|
+
), /* @__PURE__ */ React19.createElement(DropdownButtonWrapper, null, /* @__PURE__ */ React19.createElement(DropdownButton, { ...buttonProps, ref: triggerRef, invalid }, /* @__PURE__ */ React19.createElement(DropdownButtonText, { ...valueProps }, state.selectedItem ? state.selectedItem.rendered : props.placeholder), /* @__PURE__ */ React19.createElement(DropdownButtonIcon, { name: "16/Menu" })), state.isOpen && /* @__PURE__ */ React19.createElement(
|
|
1668
1712
|
DropdownPopover,
|
|
1669
1713
|
{
|
|
1670
1714
|
state,
|
|
1671
1715
|
triggerRef,
|
|
1672
1716
|
value: props.value ?? props.defaultValue
|
|
1673
1717
|
},
|
|
1674
|
-
/* @__PURE__ */
|
|
1675
|
-
)), hasAssertiveText && /* @__PURE__ */
|
|
1718
|
+
/* @__PURE__ */ React19.createElement(Listbox_default, { ...menuProps, state, mode })
|
|
1719
|
+
)), hasAssertiveText && /* @__PURE__ */ React19.createElement(
|
|
1676
1720
|
AssertiveText,
|
|
1677
1721
|
{
|
|
1678
1722
|
invalid,
|
|
@@ -1683,7 +1727,7 @@ var DropdownSelector = ({
|
|
|
1683
1727
|
};
|
|
1684
1728
|
var DropdownSelector_default = DropdownSelector;
|
|
1685
1729
|
var DropdownSelectorItem = Item;
|
|
1686
|
-
var DropdownSelectorRoot =
|
|
1730
|
+
var DropdownSelectorRoot = styled18.div`
|
|
1687
1731
|
position: relative;
|
|
1688
1732
|
display: inline-block;
|
|
1689
1733
|
width: 100%;
|
|
@@ -1693,15 +1737,15 @@ var DropdownSelectorRoot = styled15.div`
|
|
|
1693
1737
|
${theme((o) => o.disabled)}
|
|
1694
1738
|
}
|
|
1695
1739
|
`;
|
|
1696
|
-
var DropdownFieldLabel =
|
|
1740
|
+
var DropdownFieldLabel = styled18(FieldLabel_default)`
|
|
1697
1741
|
width: 100%;
|
|
1698
1742
|
|
|
1699
1743
|
${theme((o) => o.margin.bottom(8))}
|
|
1700
1744
|
`;
|
|
1701
|
-
var DropdownButtonWrapper =
|
|
1745
|
+
var DropdownButtonWrapper = styled18.div`
|
|
1702
1746
|
position: relative;
|
|
1703
1747
|
`;
|
|
1704
|
-
var DropdownButton =
|
|
1748
|
+
var DropdownButton = styled18.button`
|
|
1705
1749
|
display: flex;
|
|
1706
1750
|
justify-content: space-between;
|
|
1707
1751
|
align-items: center;
|
|
@@ -1724,15 +1768,15 @@ var DropdownButton = styled15.button`
|
|
|
1724
1768
|
invalid && o.outline.assertive
|
|
1725
1769
|
])}
|
|
1726
1770
|
`;
|
|
1727
|
-
var DropdownButtonText =
|
|
1771
|
+
var DropdownButtonText = styled18.span`
|
|
1728
1772
|
text-align: left;
|
|
1729
1773
|
|
|
1730
1774
|
${theme((o) => [o.typography(14), o.font.text2])}
|
|
1731
1775
|
`;
|
|
1732
|
-
var DropdownButtonIcon =
|
|
1776
|
+
var DropdownButtonIcon = styled18(Icon_default)`
|
|
1733
1777
|
${theme((o) => [o.font.text2])}
|
|
1734
1778
|
`;
|
|
1735
|
-
var AssertiveText =
|
|
1779
|
+
var AssertiveText = styled18.div`
|
|
1736
1780
|
${({ invalid }) => theme((o) => [
|
|
1737
1781
|
o.typography(14),
|
|
1738
1782
|
o.margin.top(8),
|
|
@@ -1741,23 +1785,23 @@ var AssertiveText = styled15.div`
|
|
|
1741
1785
|
`;
|
|
1742
1786
|
|
|
1743
1787
|
// src/components/SegmentedControl/index.tsx
|
|
1744
|
-
import
|
|
1788
|
+
import React21, { forwardRef, memo as memo2, useMemo as useMemo4, useRef as useRef9 } from "react";
|
|
1745
1789
|
import { useRadioGroupState } from "react-stately";
|
|
1746
1790
|
import {
|
|
1747
1791
|
useRadio,
|
|
1748
1792
|
useRadioGroup
|
|
1749
1793
|
} from "@react-aria/radio";
|
|
1750
|
-
import
|
|
1794
|
+
import styled19 from "styled-components";
|
|
1751
1795
|
import { disabledSelector as disabledSelector5 } from "@charcoal-ui/utils";
|
|
1752
1796
|
|
|
1753
1797
|
// src/components/SegmentedControl/RadioGroupContext.tsx
|
|
1754
|
-
import
|
|
1798
|
+
import React20, { createContext as createContext2, useContext as useContext5 } from "react";
|
|
1755
1799
|
var RadioContext = createContext2(null);
|
|
1756
1800
|
var RadioProvider = ({
|
|
1757
1801
|
value,
|
|
1758
1802
|
children
|
|
1759
1803
|
}) => {
|
|
1760
|
-
return /* @__PURE__ */
|
|
1804
|
+
return /* @__PURE__ */ React20.createElement(RadioContext.Provider, { value }, children);
|
|
1761
1805
|
};
|
|
1762
1806
|
var useRadioContext = () => {
|
|
1763
1807
|
const state = useContext5(RadioContext);
|
|
@@ -1785,7 +1829,7 @@ var SegmentedControl = forwardRef(
|
|
|
1785
1829
|
(d) => typeof d === "string" ? { value: d, label: d } : d
|
|
1786
1830
|
);
|
|
1787
1831
|
}, [props.data]);
|
|
1788
|
-
return /* @__PURE__ */
|
|
1832
|
+
return /* @__PURE__ */ React21.createElement(SegmentedControlRoot, { ref, ...radioGroupProps }, /* @__PURE__ */ React21.createElement(RadioProvider, { value: state }, segmentedControlItems.map((item) => /* @__PURE__ */ React21.createElement(
|
|
1789
1833
|
Segmented,
|
|
1790
1834
|
{
|
|
1791
1835
|
key: item.value,
|
|
@@ -1799,7 +1843,7 @@ var SegmentedControl = forwardRef(
|
|
|
1799
1843
|
var SegmentedControl_default = memo2(SegmentedControl);
|
|
1800
1844
|
var Segmented = ({ children, ...props }) => {
|
|
1801
1845
|
const state = useRadioContext();
|
|
1802
|
-
const ref =
|
|
1846
|
+
const ref = useRef9(null);
|
|
1803
1847
|
const ariaRadioProps = useMemo4(
|
|
1804
1848
|
() => ({ ...props, isDisabled: props.disabled }),
|
|
1805
1849
|
[props]
|
|
@@ -1809,23 +1853,23 @@ var Segmented = ({ children, ...props }) => {
|
|
|
1809
1853
|
state,
|
|
1810
1854
|
ref
|
|
1811
1855
|
);
|
|
1812
|
-
return /* @__PURE__ */
|
|
1856
|
+
return /* @__PURE__ */ React21.createElement(
|
|
1813
1857
|
SegmentedRoot,
|
|
1814
1858
|
{
|
|
1815
1859
|
"aria-disabled": isDisabled || state.isReadOnly,
|
|
1816
1860
|
checked: isSelected
|
|
1817
1861
|
},
|
|
1818
|
-
/* @__PURE__ */
|
|
1819
|
-
/* @__PURE__ */
|
|
1862
|
+
/* @__PURE__ */ React21.createElement(SegmentedInput, { ...inputProps, ref }),
|
|
1863
|
+
/* @__PURE__ */ React21.createElement(RadioLabel2, null, /* @__PURE__ */ React21.createElement(SegmentedLabelInner, null, children))
|
|
1820
1864
|
);
|
|
1821
1865
|
};
|
|
1822
|
-
var SegmentedControlRoot =
|
|
1866
|
+
var SegmentedControlRoot = styled19.div`
|
|
1823
1867
|
display: inline-flex;
|
|
1824
1868
|
align-items: center;
|
|
1825
1869
|
|
|
1826
1870
|
${theme((o) => [o.bg.surface3, o.borderRadius(16)])}
|
|
1827
1871
|
`;
|
|
1828
|
-
var SegmentedRoot =
|
|
1872
|
+
var SegmentedRoot = styled19.label`
|
|
1829
1873
|
position: relative;
|
|
1830
1874
|
display: flex;
|
|
1831
1875
|
align-items: center;
|
|
@@ -1844,7 +1888,7 @@ var SegmentedRoot = styled16.label`
|
|
|
1844
1888
|
checked === true ? o.font.text5 : o.font.text2
|
|
1845
1889
|
])}
|
|
1846
1890
|
`;
|
|
1847
|
-
var SegmentedInput =
|
|
1891
|
+
var SegmentedInput = styled19.input`
|
|
1848
1892
|
position: absolute;
|
|
1849
1893
|
|
|
1850
1894
|
height: 0px;
|
|
@@ -1858,19 +1902,19 @@ var SegmentedInput = styled16.input`
|
|
|
1858
1902
|
white-space: nowrap;
|
|
1859
1903
|
opacity: 0;
|
|
1860
1904
|
`;
|
|
1861
|
-
var RadioLabel2 =
|
|
1905
|
+
var RadioLabel2 = styled19.div`
|
|
1862
1906
|
background: transparent;
|
|
1863
1907
|
display: flex;
|
|
1864
1908
|
align-items: center;
|
|
1865
1909
|
height: 22px;
|
|
1866
1910
|
`;
|
|
1867
|
-
var SegmentedLabelInner =
|
|
1911
|
+
var SegmentedLabelInner = styled19.div`
|
|
1868
1912
|
${theme((o) => [o.typography(14)])}
|
|
1869
1913
|
`;
|
|
1870
1914
|
|
|
1871
1915
|
// src/components/Checkbox/index.tsx
|
|
1872
|
-
import
|
|
1873
|
-
import
|
|
1916
|
+
import React22, { forwardRef as forwardRef2, memo as memo3, useMemo as useMemo5 } from "react";
|
|
1917
|
+
import styled20, { css as css6 } from "styled-components";
|
|
1874
1918
|
import { useCheckbox } from "@react-aria/checkbox";
|
|
1875
1919
|
import { useObjectRef } from "@react-aria/utils";
|
|
1876
1920
|
import { useToggleState as useToggleState2 } from "react-stately";
|
|
@@ -1891,14 +1935,14 @@ var Checkbox = forwardRef2(
|
|
|
1891
1935
|
const objectRef = useObjectRef(ref);
|
|
1892
1936
|
const { inputProps } = useCheckbox(ariaCheckboxProps, state, objectRef);
|
|
1893
1937
|
const isDisabled = (props.disabled ?? false) || (props.readonly ?? false);
|
|
1894
|
-
return /* @__PURE__ */
|
|
1938
|
+
return /* @__PURE__ */ React22.createElement(InputRoot, { "aria-disabled": isDisabled }, /* @__PURE__ */ React22.createElement(CheckboxRoot, null, /* @__PURE__ */ React22.createElement(CheckboxInput, { type: "checkbox", ...inputProps }), /* @__PURE__ */ React22.createElement(CheckboxInputOverlay, { "aria-hidden": true, checked: inputProps.checked }, /* @__PURE__ */ React22.createElement(Icon_default, { name: "24/Check", unsafeNonGuidelineScale: 2 / 3 }))), "children" in props && /* @__PURE__ */ React22.createElement(InputLabel, null, props.children));
|
|
1895
1939
|
}
|
|
1896
1940
|
);
|
|
1897
1941
|
var Checkbox_default = memo3(Checkbox);
|
|
1898
|
-
var hiddenCss =
|
|
1942
|
+
var hiddenCss = css6`
|
|
1899
1943
|
visibility: hidden;
|
|
1900
1944
|
`;
|
|
1901
|
-
var InputRoot =
|
|
1945
|
+
var InputRoot = styled20.label`
|
|
1902
1946
|
position: relative;
|
|
1903
1947
|
display: flex;
|
|
1904
1948
|
|
|
@@ -1910,10 +1954,10 @@ var InputRoot = styled17.label`
|
|
|
1910
1954
|
gap: ${({ theme: theme4 }) => px4(theme4.spacing[4])};
|
|
1911
1955
|
${theme((o) => [o.disabled])}
|
|
1912
1956
|
`;
|
|
1913
|
-
var CheckboxRoot =
|
|
1957
|
+
var CheckboxRoot = styled20.div`
|
|
1914
1958
|
position: relative;
|
|
1915
1959
|
`;
|
|
1916
|
-
var CheckboxInput =
|
|
1960
|
+
var CheckboxInput = styled20.input`
|
|
1917
1961
|
&[type='checkbox'] {
|
|
1918
1962
|
appearance: none;
|
|
1919
1963
|
display: block;
|
|
@@ -1933,7 +1977,7 @@ var CheckboxInput = styled17.input`
|
|
|
1933
1977
|
${theme((o) => [o.outline.default.focus, o.borderRadius(4)])}
|
|
1934
1978
|
}
|
|
1935
1979
|
`;
|
|
1936
|
-
var CheckboxInputOverlay =
|
|
1980
|
+
var CheckboxInputOverlay = styled20.div`
|
|
1937
1981
|
position: absolute;
|
|
1938
1982
|
top: -2px;
|
|
1939
1983
|
left: -2px;
|
|
@@ -1946,7 +1990,7 @@ var CheckboxInputOverlay = styled17.div`
|
|
|
1946
1990
|
|
|
1947
1991
|
${({ checked }) => checked !== true && hiddenCss};
|
|
1948
1992
|
`;
|
|
1949
|
-
var InputLabel =
|
|
1993
|
+
var InputLabel = styled20.div`
|
|
1950
1994
|
${theme((o) => [o.font.text2])}
|
|
1951
1995
|
|
|
1952
1996
|
font-size: 14px;
|
|
@@ -1955,13 +1999,13 @@ var InputLabel = styled17.div`
|
|
|
1955
1999
|
`;
|
|
1956
2000
|
|
|
1957
2001
|
// src/components/TagItem/index.tsx
|
|
1958
|
-
import
|
|
2002
|
+
import React23, {
|
|
1959
2003
|
forwardRef as forwardRef3,
|
|
1960
2004
|
memo as memo4,
|
|
1961
2005
|
useMemo as useMemo6
|
|
1962
2006
|
} from "react";
|
|
1963
2007
|
import { useObjectRef as useObjectRef2 } from "@react-aria/utils";
|
|
1964
|
-
import
|
|
2008
|
+
import styled21, { css as css7 } from "styled-components";
|
|
1965
2009
|
import { disabledSelector as disabledSelector7, px as px5 } from "@charcoal-ui/utils";
|
|
1966
2010
|
import { useButton as useButton2 } from "@react-aria/button";
|
|
1967
2011
|
var sizeMap = {
|
|
@@ -1990,7 +2034,7 @@ var TagItem = forwardRef3(
|
|
|
1990
2034
|
);
|
|
1991
2035
|
const { buttonProps } = useButton2(ariaButtonProps, ref);
|
|
1992
2036
|
const hasTranslatedLabel = translatedLabel !== void 0 && translatedLabel.length > 0;
|
|
1993
|
-
return /* @__PURE__ */
|
|
2037
|
+
return /* @__PURE__ */ React23.createElement(
|
|
1994
2038
|
TagItemRoot,
|
|
1995
2039
|
{
|
|
1996
2040
|
ref,
|
|
@@ -1998,13 +2042,13 @@ var TagItem = forwardRef3(
|
|
|
1998
2042
|
status,
|
|
1999
2043
|
...buttonProps
|
|
2000
2044
|
},
|
|
2001
|
-
/* @__PURE__ */
|
|
2002
|
-
/* @__PURE__ */
|
|
2045
|
+
/* @__PURE__ */ React23.createElement(Background, { bgColor, bgImage, status }),
|
|
2046
|
+
/* @__PURE__ */ React23.createElement(Inner, null, /* @__PURE__ */ React23.createElement(LabelWrapper, { isTranslate: hasTranslatedLabel }, hasTranslatedLabel && /* @__PURE__ */ React23.createElement(TranslatedLabel, null, /* @__PURE__ */ React23.createElement(Label3, null, translatedLabel)), /* @__PURE__ */ React23.createElement(Label3, null, label)), status === "active" && /* @__PURE__ */ React23.createElement(Icon_default, { name: "16/Remove" }))
|
|
2003
2047
|
);
|
|
2004
2048
|
}
|
|
2005
2049
|
);
|
|
2006
2050
|
var TagItem_default = memo4(TagItem);
|
|
2007
|
-
var TagItemRoot =
|
|
2051
|
+
var TagItemRoot = styled21.a`
|
|
2008
2052
|
isolation: isolate;
|
|
2009
2053
|
position: relative;
|
|
2010
2054
|
height: ${({ size }) => sizeMap[size]}px;
|
|
@@ -2020,7 +2064,6 @@ var TagItemRoot = styled18.a`
|
|
|
2020
2064
|
o.borderRadius(4),
|
|
2021
2065
|
status !== "active" && size === "M" && o.padding.horizontal(24),
|
|
2022
2066
|
status !== "active" && size === "S" && o.padding.horizontal(16),
|
|
2023
|
-
status === "inactive" && o.bg.surface3,
|
|
2024
2067
|
status === "inactive" ? o.font.text2 : o.font.text5,
|
|
2025
2068
|
...status === "active" ? [o.padding.left(16), o.padding.right(8)] : []
|
|
2026
2069
|
])}
|
|
@@ -2030,7 +2073,7 @@ var TagItemRoot = styled18.a`
|
|
|
2030
2073
|
cursor: default;
|
|
2031
2074
|
}
|
|
2032
2075
|
`;
|
|
2033
|
-
var Background =
|
|
2076
|
+
var Background = styled21.div`
|
|
2034
2077
|
position: absolute;
|
|
2035
2078
|
z-index: 1;
|
|
2036
2079
|
top: 0;
|
|
@@ -2039,8 +2082,9 @@ var Background = styled18.div`
|
|
|
2039
2082
|
height: 100%;
|
|
2040
2083
|
|
|
2041
2084
|
background-color: ${({ bgColor }) => bgColor};
|
|
2085
|
+
${({ status }) => status === "inactive" && theme((o) => o.bg.surface3)}
|
|
2042
2086
|
|
|
2043
|
-
${({ bgImage }) => bgImage !== void 0 &&
|
|
2087
|
+
${({ bgImage }) => bgImage !== void 0 && css7`
|
|
2044
2088
|
${theme((o) => [o.bg.surface4])}
|
|
2045
2089
|
&::before {
|
|
2046
2090
|
content: '';
|
|
@@ -2056,25 +2100,25 @@ var Background = styled18.div`
|
|
|
2056
2100
|
}
|
|
2057
2101
|
`}
|
|
2058
2102
|
`;
|
|
2059
|
-
var Inner =
|
|
2103
|
+
var Inner = styled21.div`
|
|
2060
2104
|
display: inline-flex;
|
|
2061
2105
|
gap: ${({ theme: theme4 }) => px5(theme4.spacing[8])};
|
|
2062
2106
|
align-items: center;
|
|
2063
2107
|
z-index: 2;
|
|
2064
2108
|
`;
|
|
2065
|
-
var labelCSS =
|
|
2109
|
+
var labelCSS = css7`
|
|
2066
2110
|
${theme((o) => [o.typography(14).bold])}
|
|
2067
2111
|
`;
|
|
2068
|
-
var translateLabelCSS =
|
|
2112
|
+
var translateLabelCSS = css7`
|
|
2069
2113
|
display: flex;
|
|
2070
2114
|
align-items: center;
|
|
2071
2115
|
flex-direction: column;
|
|
2072
2116
|
font-size: 10px;
|
|
2073
2117
|
`;
|
|
2074
|
-
var LabelWrapper =
|
|
2118
|
+
var LabelWrapper = styled21.div`
|
|
2075
2119
|
${({ isTranslate }) => isTranslate ?? false ? translateLabelCSS : labelCSS}
|
|
2076
2120
|
`;
|
|
2077
|
-
var Label3 =
|
|
2121
|
+
var Label3 = styled21.span`
|
|
2078
2122
|
max-width: 152px;
|
|
2079
2123
|
overflow: hidden;
|
|
2080
2124
|
text-overflow: ellipsis;
|
|
@@ -2083,7 +2127,7 @@ var Label3 = styled18.span`
|
|
|
2083
2127
|
color: inherit;
|
|
2084
2128
|
line-height: inherit;
|
|
2085
2129
|
`;
|
|
2086
|
-
var TranslatedLabel =
|
|
2130
|
+
var TranslatedLabel = styled21.div`
|
|
2087
2131
|
${theme((o) => [o.typography(12).bold])}
|
|
2088
2132
|
`;
|
|
2089
2133
|
export {
|