@charcoal-ui/react 2.7.0 → 3.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/components/Button/index.d.ts +1 -1
  2. package/dist/components/Button/index.d.ts.map +1 -1
  3. package/dist/components/DropdownSelector/DropdownPopover.d.ts.map +1 -1
  4. package/dist/components/DropdownSelector/OptionItem.d.ts +7 -0
  5. package/dist/components/DropdownSelector/OptionItem.d.ts.map +1 -0
  6. package/dist/components/DropdownSelector/OptionLi.d.ts +11 -0
  7. package/dist/components/DropdownSelector/OptionLi.d.ts.map +1 -0
  8. package/dist/components/DropdownSelector/index.d.ts +22 -29
  9. package/dist/components/DropdownSelector/index.d.ts.map +1 -1
  10. package/dist/components/DropdownSelector/index.story.d.ts +5 -18
  11. package/dist/components/DropdownSelector/index.story.d.ts.map +1 -1
  12. package/dist/components/DropdownSelector/utils/focusIfHTMLLIElement.d.ts +6 -0
  13. package/dist/components/DropdownSelector/utils/focusIfHTMLLIElement.d.ts.map +1 -0
  14. package/dist/components/DropdownSelector/utils/handleFocusByKeyBoard.d.ts +6 -0
  15. package/dist/components/DropdownSelector/utils/handleFocusByKeyBoard.d.ts.map +1 -0
  16. package/dist/index.cjs.js +265 -313
  17. package/dist/index.cjs.js.map +1 -1
  18. package/dist/index.d.ts +2 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.esm.js +248 -296
  21. package/dist/index.esm.js.map +1 -1
  22. package/package.json +6 -6
  23. package/src/components/Button/index.story.tsx +6 -6
  24. package/src/components/Button/index.tsx +5 -5
  25. package/src/components/DropdownSelector/DropdownPopover.tsx +9 -15
  26. package/src/components/DropdownSelector/OptionItem.tsx +85 -0
  27. package/src/components/DropdownSelector/index.story.tsx +69 -156
  28. package/src/components/DropdownSelector/index.tsx +110 -140
  29. package/src/components/DropdownSelector/utils/focusIfHTMLLIElement.tsx +12 -0
  30. package/src/components/DropdownSelector/utils/handleFocusByKeyBoard.tsx +20 -0
  31. package/src/components/Modal/index.story.tsx +5 -5
  32. package/src/components/Modal/index.tsx +1 -1
  33. package/src/index.ts +6 -1
  34. package/src/components/DropdownSelector/ListBoxSection.tsx +0 -60
  35. package/src/components/DropdownSelector/Listbox.tsx +0 -67
  36. package/src/components/DropdownSelector/Option.tsx +0 -66
package/dist/index.esm.js CHANGED
@@ -147,7 +147,7 @@ var Button2 = React4.forwardRef(function Button3({
147
147
  children,
148
148
  variant = "Default",
149
149
  size = "M",
150
- fixed = false,
150
+ fullWidth: fixed = false,
151
151
  disabled = false,
152
152
  ...rest
153
153
  }, ref) {
@@ -158,7 +158,7 @@ var Button2 = React4.forwardRef(function Button3({
158
158
  disabled,
159
159
  variant,
160
160
  size,
161
- fixed,
161
+ fullWidth: fixed,
162
162
  ref
163
163
  },
164
164
  children
@@ -167,10 +167,10 @@ var Button2 = React4.forwardRef(function Button3({
167
167
  var Button_default = Button2;
168
168
  var StyledButton = styled3(Clickable_default).withConfig({
169
169
  shouldForwardProp(prop) {
170
- return prop !== "fixed";
170
+ return prop !== "fullWidth";
171
171
  }
172
172
  }).attrs(styledProps)`
173
- width: ${(p) => p.fixed ? "stretch" : "min-content"};
173
+ width: ${(p) => p.fullWidth ? "stretch" : "min-content"};
174
174
  display: inline-grid;
175
175
  align-items: center;
176
176
  justify-content: center;
@@ -1486,160 +1486,25 @@ var LoadingSpinnerIcon = React14.forwardRef(function LoadingSpinnerIcon2({ once
1486
1486
  });
1487
1487
 
1488
1488
  // src/components/DropdownSelector/index.tsx
1489
- import React19, { useMemo as useMemo3, useRef as useRef8 } from "react";
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
1489
+ import React16, { createContext as createContext2, useRef as useRef6 } from "react";
1552
1490
  import styled14 from "styled-components";
1553
- var Divider = styled14.div.attrs({ role: "separator" })`
1554
- display: flex;
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
- `;
1491
+ import { useOverlayTriggerState } from "react-stately";
1492
+ import { disabledSelector as disabledSelector4 } from "@charcoal-ui/utils";
1628
1493
 
1629
1494
  // src/components/DropdownSelector/DropdownPopover.tsx
1630
- import React18, { useEffect as useEffect2, useRef as useRef7 } from "react";
1495
+ import React15, { useEffect as useEffect2, useRef as useRef5 } from "react";
1631
1496
  import {
1632
1497
  DismissButton,
1633
1498
  Overlay as Overlay2,
1634
1499
  usePopover
1635
1500
  } from "@react-aria/overlays";
1636
- import styled17 from "styled-components";
1637
- var DropdownPopoverDiv = styled17.div`
1501
+ import styled13 from "styled-components";
1502
+ var DropdownPopoverDiv = styled13.div`
1638
1503
  width: 100%;
1639
1504
  ${theme((o) => o.margin.top(4).bottom(4))}
1640
1505
  `;
1641
1506
  function DropdownPopover({ children, state, ...props }) {
1642
- const ref = useRef7(null);
1507
+ const ref = useRef5(null);
1643
1508
  const { popoverProps, underlayProps } = usePopover(
1644
1509
  {
1645
1510
  ...props,
@@ -1655,107 +1520,101 @@ function DropdownPopover({ children, state, ...props }) {
1655
1520
  }, [props.triggerRef]);
1656
1521
  useEffect2(() => {
1657
1522
  if (state.isOpen && props.value !== void 0) {
1658
- window.requestAnimationFrame(() => {
1659
- if (props.value === void 0)
1660
- return;
1661
- const windowScrollY = window.scrollY;
1662
- const windowScrollX = window.scrollX;
1663
- const selectedElement = document.querySelector(
1664
- `[data-key="${props.value.toString()}"]`
1665
- );
1666
- selectedElement?.scrollIntoView({ block: "center" });
1667
- window.scrollTo(windowScrollX, windowScrollY);
1668
- });
1523
+ const windowScrollY = window.scrollY;
1524
+ const windowScrollX = window.scrollX;
1525
+ const selectedElement = document.querySelector(
1526
+ `[data-key="${props.value.toString()}"]`
1527
+ );
1528
+ selectedElement?.scrollIntoView({ block: "center" });
1529
+ selectedElement?.focus();
1530
+ window.scrollTo(windowScrollX, windowScrollY);
1669
1531
  }
1670
1532
  }, [props.value, state.isOpen]);
1671
- 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() })));
1533
+ 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
1534
  }
1673
1535
 
1674
1536
  // src/components/DropdownSelector/index.tsx
1675
- var DropdownSelector = ({
1676
- open,
1677
- className,
1678
- label = "",
1679
- requiredText = "",
1680
- subLabel,
1681
- assertiveText,
1682
- autoComplete,
1683
- invalid = false,
1684
- disabled = false,
1685
- required = false,
1686
- showLabel = false,
1687
- mode = "default",
1688
- ...props
1689
- }) => {
1690
- const { visuallyHiddenProps } = useVisuallyHidden2();
1691
- const triggerRef = useRef8(null);
1692
- const selectProps = useMemo3(
1693
- () => ({
1694
- ...props,
1695
- label,
1696
- isOpen: open,
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(
1537
+ var DropdownSelectorContext = createContext2({
1538
+ value: "",
1539
+ setValue: (_v) => {
1540
+ }
1541
+ });
1542
+ var defaultRequiredText = "*\u5FC5\u9808";
1543
+ function DropdownSelector(props) {
1544
+ const triggerRef = useRef6(null);
1545
+ const state = useOverlayTriggerState({});
1546
+ let preview;
1547
+ const childArray = React16.Children.toArray(props.children);
1548
+ for (let i = 0; i < childArray.length; i++) {
1549
+ const child = childArray[i];
1550
+ if (React16.isValidElement(child) && "value" in child.props) {
1551
+ const find = child.props.value === props.value;
1552
+ if (find && "children" in child.props) {
1553
+ preview = child.props.children;
1554
+ break;
1555
+ }
1556
+ }
1557
+ }
1558
+ return /* @__PURE__ */ React16.createElement(DropdownSelectorRoot, { "aria-disabled": props.disabled }, props.showLabel === true && /* @__PURE__ */ React16.createElement(
1719
1559
  DropdownFieldLabel,
1720
1560
  {
1721
- label,
1722
- required,
1723
- requiredText,
1724
- subLabel,
1725
- ...labelProps,
1726
- ...!showLabel ? visuallyHiddenProps : {}
1561
+ label: props.label,
1562
+ required: props.required,
1563
+ requiredText: props.requiredText ?? defaultRequiredText,
1564
+ subLabel: props.subLabel
1727
1565
  }
1728
- ), /* @__PURE__ */ React19.createElement(
1729
- HiddenSelect,
1566
+ ), /* @__PURE__ */ React16.createElement(
1567
+ DropdownButton,
1730
1568
  {
1731
- state,
1732
- triggerRef,
1733
- label,
1734
- name: props.name,
1735
- isDisabled: disabled,
1736
- autoComplete
1737
- }
1738
- ), /* @__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(
1569
+ invalid: props.invalid,
1570
+ disabled: props.disabled,
1571
+ onClick: () => {
1572
+ if (props.disabled === true)
1573
+ return;
1574
+ state.open();
1575
+ },
1576
+ ref: triggerRef
1577
+ },
1578
+ /* @__PURE__ */ React16.createElement(DropdownButtonText, null, props.placeholder !== void 0 && preview === void 0 ? props.placeholder : preview),
1579
+ /* @__PURE__ */ React16.createElement(DropdownButtonIcon, { name: "16/Menu" })
1580
+ ), state.isOpen && /* @__PURE__ */ React16.createElement(
1739
1581
  DropdownPopover,
1740
1582
  {
1741
1583
  state,
1742
1584
  triggerRef,
1743
- value: props.value ?? props.defaultValue
1744
- },
1745
- /* @__PURE__ */ React19.createElement(Listbox_default, { ...menuProps, state, mode })
1746
- )), hasAssertiveText && /* @__PURE__ */ React19.createElement(
1747
- AssertiveText,
1748
- {
1749
- invalid,
1750
- ...invalid ? errorMessageProps : descriptionProps
1585
+ value: props.value
1751
1586
  },
1752
- assertiveText
1753
- ));
1754
- };
1755
- var DropdownSelector_default = DropdownSelector;
1756
- var DropdownSelectorItem = Item;
1757
- var DropdownSelectorRoot = styled18.div`
1758
- position: relative;
1587
+ /* @__PURE__ */ React16.createElement(ListboxRoot, null, /* @__PURE__ */ React16.createElement(
1588
+ DropdownSelectorContext.Provider,
1589
+ {
1590
+ value: {
1591
+ value: props.value,
1592
+ setValue: (v) => {
1593
+ props.onChange(v);
1594
+ state.close();
1595
+ }
1596
+ }
1597
+ },
1598
+ props.children
1599
+ ))
1600
+ ), props.assistiveText !== void 0 && /* @__PURE__ */ React16.createElement(AssertiveText, { invalid: props.invalid }, props.assistiveText));
1601
+ }
1602
+ var ListboxRoot = styled14.ul`
1603
+ padding-left: 0;
1604
+ margin: 0;
1605
+ box-sizing: border-box;
1606
+ list-style: none;
1607
+ overflow: auto;
1608
+ max-height: inherit;
1609
+
1610
+ ${theme((o) => [
1611
+ o.bg.background1,
1612
+ o.border.default,
1613
+ o.borderRadius(8),
1614
+ o.padding.vertical(8)
1615
+ ])}
1616
+ `;
1617
+ var DropdownSelectorRoot = styled14.div`
1759
1618
  display: inline-block;
1760
1619
  width: 100%;
1761
1620
 
@@ -1764,15 +1623,12 @@ var DropdownSelectorRoot = styled18.div`
1764
1623
  ${theme((o) => o.disabled)}
1765
1624
  }
1766
1625
  `;
1767
- var DropdownFieldLabel = styled18(FieldLabel_default)`
1626
+ var DropdownFieldLabel = styled14(FieldLabel_default)`
1768
1627
  width: 100%;
1769
1628
 
1770
1629
  ${theme((o) => o.margin.bottom(8))}
1771
1630
  `;
1772
- var DropdownButtonWrapper = styled18.div`
1773
- position: relative;
1774
- `;
1775
- var DropdownButton = styled18.button`
1631
+ var DropdownButton = styled14.button`
1776
1632
  display: flex;
1777
1633
  justify-content: space-between;
1778
1634
  align-items: center;
@@ -1792,46 +1648,142 @@ var DropdownButton = styled18.button`
1792
1648
  o.outline.default.focus,
1793
1649
  o.bg.surface3,
1794
1650
  o.borderRadius(4),
1795
- invalid && o.outline.assertive
1651
+ invalid === true && o.outline.assertive
1796
1652
  ])}
1797
1653
  `;
1798
- var DropdownButtonText = styled18.span`
1654
+ var DropdownButtonText = styled14.span`
1799
1655
  text-align: left;
1800
1656
 
1801
1657
  ${theme((o) => [o.typography(14), o.font.text2])}
1802
1658
  `;
1803
- var DropdownButtonIcon = styled18(Icon_default)`
1659
+ var DropdownButtonIcon = styled14(Icon_default)`
1804
1660
  ${theme((o) => [o.font.text2])}
1805
1661
  `;
1806
- var AssertiveText = styled18.div`
1662
+ var AssertiveText = styled14.div`
1807
1663
  ${({ invalid }) => theme((o) => [
1808
1664
  o.typography(14),
1809
1665
  o.margin.top(8),
1810
- invalid ? o.font.assertive : o.font.text2
1666
+ invalid === true ? o.font.assertive : o.font.text2
1811
1667
  ])}
1812
1668
  `;
1813
1669
 
1670
+ // src/components/DropdownSelector/OptionItem.tsx
1671
+ import React17, { useContext as useContext5 } from "react";
1672
+ import styled15 from "styled-components";
1673
+ import { px as px3 } from "@charcoal-ui/utils";
1674
+
1675
+ // src/components/DropdownSelector/utils/handleFocusByKeyBoard.tsx
1676
+ function handleFocusByKeyBoard(element) {
1677
+ const parent = element.parentElement;
1678
+ if (!parent)
1679
+ return;
1680
+ const rect = element.getBoundingClientRect();
1681
+ const parentRect = parent.getBoundingClientRect();
1682
+ if (rect.bottom > parentRect.bottom) {
1683
+ parent.scrollTo({
1684
+ top: parent.scrollTop + rect.bottom - parentRect.bottom
1685
+ });
1686
+ } else if (rect.top < parentRect.top) {
1687
+ parent.scrollTo({
1688
+ top: parent.scrollTop - (parentRect.top - rect.top)
1689
+ });
1690
+ }
1691
+ }
1692
+
1693
+ // src/components/DropdownSelector/utils/focusIfHTMLLIElement.tsx
1694
+ function focusIfHTMLLIElement(element) {
1695
+ if (element instanceof HTMLLIElement) {
1696
+ element.focus({ preventScroll: true });
1697
+ handleFocusByKeyBoard(element);
1698
+ }
1699
+ }
1700
+
1701
+ // src/components/DropdownSelector/OptionItem.tsx
1702
+ function OptionItem(props) {
1703
+ const { value, setValue } = useContext5(DropdownSelectorContext);
1704
+ const isSelected = props.value === value;
1705
+ const onSelect = () => {
1706
+ setValue(props.value);
1707
+ };
1708
+ return /* @__PURE__ */ React17.createElement(
1709
+ OptionRoot,
1710
+ {
1711
+ "data-key": props.value,
1712
+ onMouseMove: (e) => {
1713
+ e.currentTarget.focus({ preventScroll: true });
1714
+ },
1715
+ onKeyDown: (e) => {
1716
+ if (e.key === "Enter") {
1717
+ onSelect();
1718
+ } else if (e.key === "ArrowUp") {
1719
+ e.preventDefault();
1720
+ const prev = e.currentTarget.previousElementSibling;
1721
+ if (prev === null) {
1722
+ focusIfHTMLLIElement(e.currentTarget.parentElement?.lastChild);
1723
+ }
1724
+ focusIfHTMLLIElement(prev);
1725
+ } else if (e.key === "ArrowDown") {
1726
+ e.preventDefault();
1727
+ const next = e.currentTarget.nextElementSibling;
1728
+ if (next === null) {
1729
+ focusIfHTMLLIElement(e.currentTarget.parentElement?.firstChild);
1730
+ }
1731
+ focusIfHTMLLIElement(next);
1732
+ } else if (e.key === " ") {
1733
+ e.preventDefault();
1734
+ }
1735
+ },
1736
+ onClick: onSelect,
1737
+ tabIndex: -1
1738
+ },
1739
+ isSelected && /* @__PURE__ */ React17.createElement(OptionCheckIcon, { name: "16/Check" }),
1740
+ /* @__PURE__ */ React17.createElement(OptionText, { isSelected }, props.children)
1741
+ );
1742
+ }
1743
+ var OptionRoot = styled15.li`
1744
+ display: flex;
1745
+ align-items: center;
1746
+ gap: ${({ theme: theme4 }) => px3(theme4.spacing[4])};
1747
+ height: 40px;
1748
+ cursor: pointer;
1749
+ outline: none;
1750
+
1751
+ ${theme((o) => [o.padding.horizontal(8)])}
1752
+
1753
+ :focus {
1754
+ ${theme((o) => [o.bg.surface3])}
1755
+ }
1756
+ `;
1757
+ var OptionCheckIcon = styled15(Icon_default)`
1758
+ ${theme((o) => [o.font.text2])}
1759
+ `;
1760
+ var OptionText = styled15.span`
1761
+ display: block;
1762
+ ${theme((o) => [o.typography(14), o.font.text2])}
1763
+ margin-left: ${({ isSelected }) => isSelected === true ? 0 : 20}px;
1764
+ `;
1765
+
1814
1766
  // src/components/SegmentedControl/index.tsx
1815
- import React21, { forwardRef, memo as memo2, useMemo as useMemo4, useRef as useRef9 } from "react";
1767
+ import React19, { forwardRef, memo, useMemo as useMemo2, useRef as useRef7 } from "react";
1816
1768
  import { useRadioGroupState } from "react-stately";
1817
1769
  import {
1818
1770
  useRadio,
1819
1771
  useRadioGroup
1820
1772
  } from "@react-aria/radio";
1821
- import styled19 from "styled-components";
1773
+ import styled16 from "styled-components";
1822
1774
  import { disabledSelector as disabledSelector5 } from "@charcoal-ui/utils";
1823
1775
 
1824
1776
  // src/components/SegmentedControl/RadioGroupContext.tsx
1825
- import React20, { createContext as createContext2, useContext as useContext5 } from "react";
1826
- var RadioContext = createContext2(null);
1777
+ import React18, { createContext as createContext3, useContext as useContext6 } from "react";
1778
+ var RadioContext = createContext3(null);
1827
1779
  var RadioProvider = ({
1828
1780
  value,
1829
1781
  children
1830
1782
  }) => {
1831
- return /* @__PURE__ */ React20.createElement(RadioContext.Provider, { value }, children);
1783
+ return /* @__PURE__ */ React18.createElement(RadioContext.Provider, { value }, children);
1832
1784
  };
1833
1785
  var useRadioContext = () => {
1834
- const state = useContext5(RadioContext);
1786
+ const state = useContext6(RadioContext);
1835
1787
  if (state === null)
1836
1788
  throw new Error("`<RadioProvider>` is not likely mounted.");
1837
1789
  return state;
@@ -1840,7 +1792,7 @@ var useRadioContext = () => {
1840
1792
  // src/components/SegmentedControl/index.tsx
1841
1793
  var SegmentedControl = forwardRef(
1842
1794
  function SegmentedControlInner(props, ref) {
1843
- const ariaRadioGroupProps = useMemo4(
1795
+ const ariaRadioGroupProps = useMemo2(
1844
1796
  () => ({
1845
1797
  ...props,
1846
1798
  isDisabled: props.disabled,
@@ -1851,12 +1803,12 @@ var SegmentedControl = forwardRef(
1851
1803
  );
1852
1804
  const state = useRadioGroupState(ariaRadioGroupProps);
1853
1805
  const { radioGroupProps } = useRadioGroup(ariaRadioGroupProps, state);
1854
- const segmentedControlItems = useMemo4(() => {
1806
+ const segmentedControlItems = useMemo2(() => {
1855
1807
  return props.data.map(
1856
1808
  (d) => typeof d === "string" ? { value: d, label: d } : d
1857
1809
  );
1858
1810
  }, [props.data]);
1859
- return /* @__PURE__ */ React21.createElement(SegmentedControlRoot, { ref, ...radioGroupProps }, /* @__PURE__ */ React21.createElement(RadioProvider, { value: state }, segmentedControlItems.map((item) => /* @__PURE__ */ React21.createElement(
1811
+ return /* @__PURE__ */ React19.createElement(SegmentedControlRoot, { ref, ...radioGroupProps }, /* @__PURE__ */ React19.createElement(RadioProvider, { value: state }, segmentedControlItems.map((item) => /* @__PURE__ */ React19.createElement(
1860
1812
  Segmented,
1861
1813
  {
1862
1814
  key: item.value,
@@ -1867,11 +1819,11 @@ var SegmentedControl = forwardRef(
1867
1819
  ))));
1868
1820
  }
1869
1821
  );
1870
- var SegmentedControl_default = memo2(SegmentedControl);
1822
+ var SegmentedControl_default = memo(SegmentedControl);
1871
1823
  var Segmented = ({ children, ...props }) => {
1872
1824
  const state = useRadioContext();
1873
- const ref = useRef9(null);
1874
- const ariaRadioProps = useMemo4(
1825
+ const ref = useRef7(null);
1826
+ const ariaRadioProps = useMemo2(
1875
1827
  () => ({ ...props, isDisabled: props.disabled }),
1876
1828
  [props]
1877
1829
  );
@@ -1880,23 +1832,23 @@ var Segmented = ({ children, ...props }) => {
1880
1832
  state,
1881
1833
  ref
1882
1834
  );
1883
- return /* @__PURE__ */ React21.createElement(
1835
+ return /* @__PURE__ */ React19.createElement(
1884
1836
  SegmentedRoot,
1885
1837
  {
1886
1838
  "aria-disabled": isDisabled || state.isReadOnly,
1887
1839
  checked: isSelected
1888
1840
  },
1889
- /* @__PURE__ */ React21.createElement(SegmentedInput, { ...inputProps, ref }),
1890
- /* @__PURE__ */ React21.createElement(RadioLabel2, null, /* @__PURE__ */ React21.createElement(SegmentedLabelInner, null, children))
1841
+ /* @__PURE__ */ React19.createElement(SegmentedInput, { ...inputProps, ref }),
1842
+ /* @__PURE__ */ React19.createElement(RadioLabel2, null, /* @__PURE__ */ React19.createElement(SegmentedLabelInner, null, children))
1891
1843
  );
1892
1844
  };
1893
- var SegmentedControlRoot = styled19.div`
1845
+ var SegmentedControlRoot = styled16.div`
1894
1846
  display: inline-flex;
1895
1847
  align-items: center;
1896
1848
 
1897
1849
  ${theme((o) => [o.bg.surface3, o.borderRadius(16)])}
1898
1850
  `;
1899
- var SegmentedRoot = styled19.label`
1851
+ var SegmentedRoot = styled16.label`
1900
1852
  position: relative;
1901
1853
  display: flex;
1902
1854
  align-items: center;
@@ -1915,7 +1867,7 @@ var SegmentedRoot = styled19.label`
1915
1867
  checked === true ? o.font.text5 : o.font.text2
1916
1868
  ])}
1917
1869
  `;
1918
- var SegmentedInput = styled19.input`
1870
+ var SegmentedInput = styled16.input`
1919
1871
  position: absolute;
1920
1872
 
1921
1873
  height: 0px;
@@ -1929,26 +1881,26 @@ var SegmentedInput = styled19.input`
1929
1881
  white-space: nowrap;
1930
1882
  opacity: 0;
1931
1883
  `;
1932
- var RadioLabel2 = styled19.div`
1884
+ var RadioLabel2 = styled16.div`
1933
1885
  background: transparent;
1934
1886
  display: flex;
1935
1887
  align-items: center;
1936
1888
  height: 22px;
1937
1889
  `;
1938
- var SegmentedLabelInner = styled19.div`
1890
+ var SegmentedLabelInner = styled16.div`
1939
1891
  ${theme((o) => [o.typography(14)])}
1940
1892
  `;
1941
1893
 
1942
1894
  // src/components/Checkbox/index.tsx
1943
- import React22, { forwardRef as forwardRef2, memo as memo3, useMemo as useMemo5 } from "react";
1944
- import styled20, { css as css6 } from "styled-components";
1895
+ import React20, { forwardRef as forwardRef2, memo as memo2, useMemo as useMemo3 } from "react";
1896
+ import styled17, { css as css5 } from "styled-components";
1945
1897
  import { useCheckbox } from "@react-aria/checkbox";
1946
1898
  import { useObjectRef } from "@react-aria/utils";
1947
1899
  import { useToggleState as useToggleState2 } from "react-stately";
1948
1900
  import { disabledSelector as disabledSelector6, px as px4 } from "@charcoal-ui/utils";
1949
1901
  var Checkbox = forwardRef2(
1950
1902
  function CheckboxInner(props, ref) {
1951
- const ariaCheckboxProps = useMemo5(
1903
+ const ariaCheckboxProps = useMemo3(
1952
1904
  () => ({
1953
1905
  ...props,
1954
1906
  isSelected: props.checked,
@@ -1962,14 +1914,14 @@ var Checkbox = forwardRef2(
1962
1914
  const objectRef = useObjectRef(ref);
1963
1915
  const { inputProps } = useCheckbox(ariaCheckboxProps, state, objectRef);
1964
1916
  const isDisabled = (props.disabled ?? false) || (props.readonly ?? false);
1965
- 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));
1917
+ 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
1918
  }
1967
1919
  );
1968
- var Checkbox_default = memo3(Checkbox);
1969
- var hiddenCss = css6`
1920
+ var Checkbox_default = memo2(Checkbox);
1921
+ var hiddenCss = css5`
1970
1922
  visibility: hidden;
1971
1923
  `;
1972
- var InputRoot = styled20.label`
1924
+ var InputRoot = styled17.label`
1973
1925
  position: relative;
1974
1926
  display: flex;
1975
1927
 
@@ -1981,10 +1933,10 @@ var InputRoot = styled20.label`
1981
1933
  gap: ${({ theme: theme4 }) => px4(theme4.spacing[4])};
1982
1934
  ${theme((o) => [o.disabled])}
1983
1935
  `;
1984
- var CheckboxRoot = styled20.div`
1936
+ var CheckboxRoot = styled17.div`
1985
1937
  position: relative;
1986
1938
  `;
1987
- var CheckboxInput = styled20.input`
1939
+ var CheckboxInput = styled17.input`
1988
1940
  &[type='checkbox'] {
1989
1941
  appearance: none;
1990
1942
  display: block;
@@ -2007,7 +1959,7 @@ var CheckboxInput = styled20.input`
2007
1959
  transition: all 0.2s !important;
2008
1960
  }
2009
1961
  `;
2010
- var CheckboxInputOverlay = styled20.div`
1962
+ var CheckboxInputOverlay = styled17.div`
2011
1963
  position: absolute;
2012
1964
  top: -2px;
2013
1965
  left: -2px;
@@ -2020,7 +1972,7 @@ var CheckboxInputOverlay = styled20.div`
2020
1972
 
2021
1973
  ${({ checked }) => checked !== true && hiddenCss};
2022
1974
  `;
2023
- var InputLabel = styled20.div`
1975
+ var InputLabel = styled17.div`
2024
1976
  ${theme((o) => [o.font.text2])}
2025
1977
 
2026
1978
  font-size: 14px;
@@ -2029,15 +1981,15 @@ var InputLabel = styled20.div`
2029
1981
  `;
2030
1982
 
2031
1983
  // src/components/TagItem/index.tsx
2032
- import React23, {
1984
+ import React21, {
2033
1985
  forwardRef as forwardRef3,
2034
- memo as memo4,
2035
- useMemo as useMemo6
1986
+ memo as memo3,
1987
+ useMemo as useMemo4
2036
1988
  } from "react";
2037
1989
  import { useObjectRef as useObjectRef2 } from "@react-aria/utils";
2038
- import styled21, { css as css7 } from "styled-components";
1990
+ import styled18, { css as css6 } from "styled-components";
2039
1991
  import { disabledSelector as disabledSelector7, px as px5 } from "@charcoal-ui/utils";
2040
- import { useButton as useButton2 } from "@react-aria/button";
1992
+ import { useButton } from "@react-aria/button";
2041
1993
  var sizeMap = {
2042
1994
  S: 32,
2043
1995
  M: 40
@@ -2055,7 +2007,7 @@ var TagItem = forwardRef3(
2055
2007
  ...props
2056
2008
  }, _ref) {
2057
2009
  const ref = useObjectRef2(_ref);
2058
- const ariaButtonProps = useMemo6(
2010
+ const ariaButtonProps = useMemo4(
2059
2011
  () => ({
2060
2012
  elementType: "a",
2061
2013
  isDisabled: disabled,
@@ -2063,9 +2015,9 @@ var TagItem = forwardRef3(
2063
2015
  }),
2064
2016
  [disabled, props]
2065
2017
  );
2066
- const { buttonProps } = useButton2(ariaButtonProps, ref);
2018
+ const { buttonProps } = useButton(ariaButtonProps, ref);
2067
2019
  const hasTranslatedLabel = translatedLabel !== void 0 && translatedLabel.length > 0;
2068
- return /* @__PURE__ */ React23.createElement(
2020
+ return /* @__PURE__ */ React21.createElement(
2069
2021
  TagItemRoot,
2070
2022
  {
2071
2023
  ref,
@@ -2074,13 +2026,13 @@ var TagItem = forwardRef3(
2074
2026
  ...buttonProps,
2075
2027
  className
2076
2028
  },
2077
- /* @__PURE__ */ React23.createElement(Background, { bgColor, bgImage, status }),
2078
- /* @__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" }))
2029
+ /* @__PURE__ */ React21.createElement(Background, { bgColor, bgImage, status }),
2030
+ /* @__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
2031
  );
2080
2032
  }
2081
2033
  );
2082
- var TagItem_default = memo4(TagItem);
2083
- var TagItemRoot = styled21.a`
2034
+ var TagItem_default = memo3(TagItem);
2035
+ var TagItemRoot = styled18.a`
2084
2036
  isolation: isolate;
2085
2037
  position: relative;
2086
2038
  height: ${({ size }) => sizeMap[size]}px;
@@ -2105,7 +2057,7 @@ var TagItemRoot = styled21.a`
2105
2057
  cursor: default;
2106
2058
  }
2107
2059
  `;
2108
- var Background = styled21.div`
2060
+ var Background = styled18.div`
2109
2061
  position: absolute;
2110
2062
  z-index: 1;
2111
2063
  top: 0;
@@ -2116,7 +2068,7 @@ var Background = styled21.div`
2116
2068
  background-color: ${({ bgColor }) => bgColor};
2117
2069
  ${({ status }) => status === "inactive" && theme((o) => o.bg.surface3)}
2118
2070
 
2119
- ${({ bgImage }) => bgImage !== void 0 && css7`
2071
+ ${({ bgImage }) => bgImage !== void 0 && css6`
2120
2072
  ${theme((o) => [o.bg.surface4])}
2121
2073
  &::before {
2122
2074
  content: '';
@@ -2132,25 +2084,25 @@ var Background = styled21.div`
2132
2084
  }
2133
2085
  `}
2134
2086
  `;
2135
- var Inner = styled21.div`
2087
+ var Inner = styled18.div`
2136
2088
  display: inline-flex;
2137
2089
  gap: ${({ theme: theme4 }) => px5(theme4.spacing[8])};
2138
2090
  align-items: center;
2139
2091
  z-index: 2;
2140
2092
  `;
2141
- var labelCSS = css7`
2093
+ var labelCSS = css6`
2142
2094
  ${theme((o) => [o.typography(14).bold])}
2143
2095
  `;
2144
- var translateLabelCSS = css7`
2096
+ var translateLabelCSS = css6`
2145
2097
  display: flex;
2146
2098
  align-items: center;
2147
2099
  flex-direction: column;
2148
2100
  font-size: 10px;
2149
2101
  `;
2150
- var LabelWrapper = styled21.div`
2102
+ var LabelWrapper = styled18.div`
2151
2103
  ${({ isTranslate }) => isTranslate ?? false ? translateLabelCSS : labelCSS}
2152
2104
  `;
2153
- var Label3 = styled21.span`
2105
+ var Label3 = styled18.span`
2154
2106
  max-width: 152px;
2155
2107
  overflow: hidden;
2156
2108
  text-overflow: ellipsis;
@@ -2159,7 +2111,7 @@ var Label3 = styled21.span`
2159
2111
  color: inherit;
2160
2112
  line-height: inherit;
2161
2113
  `;
2162
- var TranslatedLabel = styled21.div`
2114
+ var TranslatedLabel = styled18.div`
2163
2115
  ${theme((o) => [o.typography(12).bold])}
2164
2116
  `;
2165
2117
  export {
@@ -2168,8 +2120,7 @@ export {
2168
2120
  Checkbox_default as Checkbox,
2169
2121
  Clickable_default as Clickable,
2170
2122
  ComponentAbstraction,
2171
- DropdownSelector_default as DropdownSelector,
2172
- DropdownSelectorItem,
2123
+ DropdownSelector,
2173
2124
  Icon_default as Icon,
2174
2125
  IconButton_default as IconButton,
2175
2126
  LoadingSpinner,
@@ -2181,6 +2132,7 @@ export {
2181
2132
  ModalHeader,
2182
2133
  MultiSelect,
2183
2134
  MultiSelectGroup,
2135
+ OptionItem,
2184
2136
  OverlayProvider,
2185
2137
  Radio,
2186
2138
  RadioGroup,