@trellixio/roaster-react 2.1.1 → 2.1.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.
Files changed (118) hide show
  1. package/cjs/components/ActionList/components/ActionListDropdown.js +6 -5
  2. package/cjs/components/ActionList/components/ActionListDropdown.js.map +1 -1
  3. package/cjs/components/ActionList/components/ActionListItem.js +7 -6
  4. package/cjs/components/ActionList/components/ActionListItem.js.map +1 -1
  5. package/cjs/components/ActionList/components/ActionListSearch.js +24 -6
  6. package/cjs/components/ActionList/components/ActionListSearch.js.map +1 -1
  7. package/cjs/components/ActionList/components/ActionListSubmenu.js +4 -3
  8. package/cjs/components/ActionList/components/ActionListSubmenu.js.map +1 -1
  9. package/cjs/components/ActionList/components/ActionListSwitchItem.js +6 -5
  10. package/cjs/components/ActionList/components/ActionListSwitchItem.js.map +1 -1
  11. package/cjs/components/AppFrame/AppFrame.js.map +1 -1
  12. package/cjs/components/Avatar/Avatar.js +1 -1
  13. package/cjs/components/Avatar/Avatar.js.map +1 -1
  14. package/cjs/components/Checkbox/Checkbox.js +4 -4
  15. package/cjs/components/Checkbox/Checkbox.js.map +1 -1
  16. package/cjs/components/ColorField/ColorField.js +42 -29
  17. package/cjs/components/ColorField/ColorField.js.map +1 -1
  18. package/cjs/components/DatePicker/DatePicker.js +2 -2
  19. package/cjs/components/DatePicker/DatePicker.js.map +1 -1
  20. package/cjs/components/DropdownCard/components/DropdownCardDropdown.js +6 -5
  21. package/cjs/components/DropdownCard/components/DropdownCardDropdown.js.map +1 -1
  22. package/cjs/components/Field/Field.js +26 -6
  23. package/cjs/components/Field/Field.js.map +1 -1
  24. package/cjs/components/FileField/FileField.js +42 -29
  25. package/cjs/components/FileField/FileField.js.map +1 -1
  26. package/cjs/components/RangeField/RangeField.js +34 -21
  27. package/cjs/components/RangeField/RangeField.js.map +1 -1
  28. package/cjs/components/Select/Select.js +8 -6
  29. package/cjs/components/Select/Select.js.map +1 -1
  30. package/cjs/components/Switch/Switch.js +7 -1
  31. package/cjs/components/Switch/Switch.js.map +1 -1
  32. package/cjs/components/TextField/TextField.js +3 -1
  33. package/cjs/components/TextField/TextField.js.map +1 -1
  34. package/cjs/components/Textarea/Textarea.js +36 -4
  35. package/cjs/components/Textarea/Textarea.js.map +1 -1
  36. package/cjs/components/Tooltip/Tooltip.js +6 -5
  37. package/cjs/components/Tooltip/Tooltip.js.map +1 -1
  38. package/cjs/utils/Slot/index.js +5 -5
  39. package/cjs/utils/Slot/index.js.map +1 -1
  40. package/cjs/utils/useDropdown/DropdownTrigger.js +4 -4
  41. package/cjs/utils/useDropdown/DropdownTrigger.js.map +1 -1
  42. package/cjs/utils/useMergeRefs/index.js +51 -0
  43. package/cjs/utils/useMergeRefs/index.js.map +1 -0
  44. package/esm/components/ActionList/components/ActionListDropdown.js +2 -1
  45. package/esm/components/ActionList/components/ActionListDropdown.js.map +1 -1
  46. package/esm/components/ActionList/components/ActionListItem.js +3 -2
  47. package/esm/components/ActionList/components/ActionListItem.js.map +1 -1
  48. package/esm/components/ActionList/components/ActionListSearch.js +21 -3
  49. package/esm/components/ActionList/components/ActionListSearch.js.map +1 -1
  50. package/esm/components/ActionList/components/ActionListSubmenu.js +2 -1
  51. package/esm/components/ActionList/components/ActionListSubmenu.js.map +1 -1
  52. package/esm/components/ActionList/components/ActionListSwitchItem.js +2 -1
  53. package/esm/components/ActionList/components/ActionListSwitchItem.js.map +1 -1
  54. package/esm/components/AppFrame/AppFrame.js.map +1 -1
  55. package/esm/components/Avatar/Avatar.js +1 -1
  56. package/esm/components/Avatar/Avatar.js.map +1 -1
  57. package/esm/components/Checkbox/Checkbox.js +1 -1
  58. package/esm/components/Checkbox/Checkbox.js.map +1 -1
  59. package/esm/components/ColorField/ColorField.js +42 -29
  60. package/esm/components/ColorField/ColorField.js.map +1 -1
  61. package/esm/components/DatePicker/DatePicker.js +1 -1
  62. package/esm/components/DatePicker/DatePicker.js.map +1 -1
  63. package/esm/components/DropdownCard/components/DropdownCardDropdown.js +2 -1
  64. package/esm/components/DropdownCard/components/DropdownCardDropdown.js.map +1 -1
  65. package/esm/components/Field/Field.js +26 -6
  66. package/esm/components/Field/Field.js.map +1 -1
  67. package/esm/components/FileField/FileField.js +42 -29
  68. package/esm/components/FileField/FileField.js.map +1 -1
  69. package/esm/components/RangeField/RangeField.js +34 -21
  70. package/esm/components/RangeField/RangeField.js.map +1 -1
  71. package/esm/components/Select/Select.js +4 -2
  72. package/esm/components/Select/Select.js.map +1 -1
  73. package/esm/components/Switch/Switch.js +7 -1
  74. package/esm/components/Switch/Switch.js.map +1 -1
  75. package/esm/components/TextField/TextField.js +3 -1
  76. package/esm/components/TextField/TextField.js.map +1 -1
  77. package/esm/components/Textarea/Textarea.js +38 -6
  78. package/esm/components/Textarea/Textarea.js.map +1 -1
  79. package/esm/components/Tooltip/Tooltip.js +2 -1
  80. package/esm/components/Tooltip/Tooltip.js.map +1 -1
  81. package/esm/package.json +4 -1
  82. package/esm/utils/Slot/index.js +1 -1
  83. package/esm/utils/Slot/index.js.map +1 -1
  84. package/esm/utils/useDropdown/DropdownTrigger.js +1 -1
  85. package/esm/utils/useDropdown/DropdownTrigger.js.map +1 -1
  86. package/esm/utils/useMergeRefs/index.js +36 -0
  87. package/esm/utils/useMergeRefs/index.js.map +1 -0
  88. package/lib/components/ActionList/components/ActionListItem.d.ts +4 -1
  89. package/lib/components/ActionList/components/ActionListItem.d.ts.map +1 -1
  90. package/lib/components/ActionList/components/ActionListSearch.d.ts.map +1 -1
  91. package/lib/components/ActionList/components/ActionListSubmenu.d.ts.map +1 -1
  92. package/lib/components/AppFrame/AppFrame.d.ts +5 -1
  93. package/lib/components/AppFrame/AppFrame.d.ts.map +1 -1
  94. package/lib/components/Avatar/Avatar.d.ts +4 -1
  95. package/lib/components/Avatar/Avatar.d.ts.map +1 -1
  96. package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
  97. package/lib/components/ColorField/ColorField.d.ts.map +1 -1
  98. package/lib/components/DatePicker/DatePicker.d.ts.map +1 -1
  99. package/lib/components/DatePicker/utils/index.d.ts +2 -1
  100. package/lib/components/DatePicker/utils/index.d.ts.map +1 -1
  101. package/lib/components/Field/Field.d.ts +13 -7
  102. package/lib/components/Field/Field.d.ts.map +1 -1
  103. package/lib/components/FileField/FileField.d.ts.map +1 -1
  104. package/lib/components/RangeField/RangeField.d.ts.map +1 -1
  105. package/lib/components/Select/Select.d.ts.map +1 -1
  106. package/lib/components/Switch/Switch.d.ts.map +1 -1
  107. package/lib/components/TextField/TextField.d.ts.map +1 -1
  108. package/lib/components/Textarea/Textarea.d.ts +6 -1
  109. package/lib/components/Textarea/Textarea.d.ts.map +1 -1
  110. package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
  111. package/lib/utils/Slot/index.d.ts.map +1 -1
  112. package/lib/utils/index.d.ts +1 -0
  113. package/lib/utils/index.d.ts.map +1 -1
  114. package/lib/utils/useDropdown/DropdownTrigger.d.ts.map +1 -1
  115. package/lib/utils/useMergeRefs/index.d.ts +11 -0
  116. package/lib/utils/useMergeRefs/index.d.ts.map +1 -0
  117. package/package.json +1 -1
  118. package/roaster.css +1 -1
@@ -6,8 +6,9 @@ var react = require('@floating-ui/react');
6
6
  var React = require('react');
7
7
  var reactDom = require('react-dom');
8
8
  var ActionList_context = require('../ActionList.context.js');
9
- var index = require('../../../utils/useMediaQuery/index.js');
10
- var index$1 = require('../../../utils/classNames/index.js');
9
+ var index = require('../../../utils/useMergeRefs/index.js');
10
+ var index$1 = require('../../../utils/useMediaQuery/index.js');
11
+ var index$2 = require('../../../utils/classNames/index.js');
11
12
 
12
13
  function _interopNamespaceDefault(e) {
13
14
  var n = Object.create(null);
@@ -25,8 +26,8 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
25
26
  const ActionListDropdown = React__namespace.forwardRef(
26
27
  ({ className, style, children, sheet = false, ...props }, propRef) => {
27
28
  const { context: floatingContext, ...context } = ActionList_context.useActionListContext();
28
- const ref = react.useMergeRefs([context.refs.setFloating, propRef]);
29
- const asSheet = index.useMediaQuery(index.PHONE_QUERY) && sheet;
29
+ const ref = index.useMergeRefs([context.refs.setFloating, propRef]);
30
+ const asSheet = index$1.useMediaQuery(index$1.PHONE_QUERY) && sheet;
30
31
  const [returnFocus, setReturnFocus] = React__namespace.useState(true);
31
32
  React__namespace.useEffect(() => {
32
33
  if (context.open) setReturnFocus(true);
@@ -49,7 +50,7 @@ const ActionListDropdown = React__namespace.forwardRef(
49
50
  }
50
51
  }
51
52
  }),
52
- className: index$1.classNames(
53
+ className: index$2.classNames(
53
54
  "roaster-action-list",
54
55
  "roaster-action-list--floating",
55
56
  sheet && "roaster-action-list--sheet",
@@ -1 +1 @@
1
- {"version":3,"file":"ActionListDropdown.js","sources":["../../../../../src/components/ActionList/components/ActionListDropdown.tsx"],"sourcesContent":["import { FloatingFocusManager, FloatingList, useMergeRefs } from '@floating-ui/react';\nimport * as React from 'react';\nimport { flushSync } from 'react-dom';\nimport { PHONE_QUERY, classNames, useMediaQuery } from '@/utils';\nimport { useActionListContext } from '../ActionList.context';\n\n/** Every native `<div>` prop (`aria-label`, `className`, `style`...) is accepted and forwarded to the menu. */\nexport interface ActionListDropdownProps extends React.ComponentPropsWithoutRef<'div'> {\n /**\n * On a phone (480px wide at most), the menu rises from the window's bottom as a sheet, its full width, over the\n * dimmed page; on a wider screen it opens under its trigger as usual. Guidance: keep a menu beside its trigger; a\n * sheet suits a long one, such as a list of filters with a search.\n * @defaultValue false\n */\n sheet?: boolean;\n}\n\n/** The menu: its groups, dividers and items. Rendered while the action list is open. */\nexport const ActionListDropdown = React.forwardRef<HTMLDivElement, ActionListDropdownProps>(\n ({ className, style, children, sheet = false, ...props }, propRef) => {\n const { context: floatingContext, ...context } = useActionListContext();\n const ref = useMergeRefs([context.refs.setFloating, propRef]);\n // A sheet on a phone is placed by the CSS, at the window's bottom, not beside its trigger.\n const asSheet = useMediaQuery(PHONE_QUERY) && sheet;\n // Closing gives the focus back to the trigger, except when tabbing away: then it moves on from the trigger.\n const [returnFocus, setReturnFocus] = React.useState(true);\n React.useEffect(() => {\n if (context.open) setReturnFocus(true);\n }, [context.open]);\n if (!context.open) return null;\n\n return (\n // The list navigation moves the focus to the first item.\n <FloatingFocusManager context={floatingContext} modal={false} initialFocus={-1} returnFocus={returnFocus}>\n <div\n ref={ref}\n {...context.getFloatingProps({\n ...props,\n onKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n props.onKeyDown?.(event);\n // Tabbing away closes the menu, and Tab moves on from the trigger, as if the menu weren't there.\n if (event.key === 'Tab') {\n flushSync(() => setReturnFocus(false));\n (context.refs.domReference.current as HTMLElement | null)?.focus();\n context.setOpen(false);\n }\n },\n })}\n // After the spread, so a caller's className and style add to these instead of replacing them.\n className={classNames(\n 'roaster-action-list',\n 'roaster-action-list--floating',\n sheet && 'roaster-action-list--sheet',\n className\n )}\n style={asSheet ? style : { ...context.floatingStyles, ...style }}\n >\n <FloatingList elementsRef={context.elementsRef} labelsRef={context.labelsRef}>\n {children}\n </FloatingList>\n </div>\n </FloatingFocusManager>\n );\n }\n);\n\nActionListDropdown.displayName = 'ActionListDropdown';\n"],"names":["React","useActionListContext","useMergeRefs","useMediaQuery","PHONE_QUERY","jsx","FloatingFocusManager","flushSync","classNames","FloatingList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAOY,MAAC,kBAAkB,GAAGA,gBAAK,CAAC,UAAU;AAClD,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,OAAO,KAAK;AACxE,IAAI,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,EAAE,GAAGC,uCAAoB,EAAE;AAC3E,IAAI,MAAM,GAAG,GAAGC,kBAAY,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AACjE,IAAI,MAAM,OAAO,GAAG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C,cAAc,EAAE,GAAG,KAAK,EAAE;AAC1E,UAAU,QAAQ,kBAAkBH,cAAG,CAACI,kBAAY,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,QAAQ,EAAE;AAClI;AACA,OAAO,EAAE;AACT;AACA,EAAE;AACF;AACA,kBAAkB,CAAC,WAAW,GAAG,oBAAoB;;"}
1
+ {"version":3,"file":"ActionListDropdown.js","sources":["../../../../../src/components/ActionList/components/ActionListDropdown.tsx"],"sourcesContent":["import { FloatingFocusManager, FloatingList } from '@floating-ui/react';\nimport * as React from 'react';\nimport { flushSync } from 'react-dom';\nimport { PHONE_QUERY, classNames, useMediaQuery, useMergeRefs } from '@/utils';\nimport { useActionListContext } from '../ActionList.context';\n\n/** Every native `<div>` prop (`aria-label`, `className`, `style`...) is accepted and forwarded to the menu. */\nexport interface ActionListDropdownProps extends React.ComponentPropsWithoutRef<'div'> {\n /**\n * On a phone (480px wide at most), the menu rises from the window's bottom as a sheet, its full width, over the\n * dimmed page; on a wider screen it opens under its trigger as usual. Guidance: keep a menu beside its trigger; a\n * sheet suits a long one, such as a list of filters with a search.\n * @defaultValue false\n */\n sheet?: boolean;\n}\n\n/** The menu: its groups, dividers and items. Rendered while the action list is open. */\nexport const ActionListDropdown = React.forwardRef<HTMLDivElement, ActionListDropdownProps>(\n ({ className, style, children, sheet = false, ...props }, propRef) => {\n const { context: floatingContext, ...context } = useActionListContext();\n const ref = useMergeRefs([context.refs.setFloating, propRef]);\n // A sheet on a phone is placed by the CSS, at the window's bottom, not beside its trigger.\n const asSheet = useMediaQuery(PHONE_QUERY) && sheet;\n // Closing gives the focus back to the trigger, except when tabbing away: then it moves on from the trigger.\n const [returnFocus, setReturnFocus] = React.useState(true);\n React.useEffect(() => {\n if (context.open) setReturnFocus(true);\n }, [context.open]);\n if (!context.open) return null;\n\n return (\n // The list navigation moves the focus to the first item.\n <FloatingFocusManager context={floatingContext} modal={false} initialFocus={-1} returnFocus={returnFocus}>\n <div\n ref={ref}\n {...context.getFloatingProps({\n ...props,\n onKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n props.onKeyDown?.(event);\n // Tabbing away closes the menu, and Tab moves on from the trigger, as if the menu weren't there.\n if (event.key === 'Tab') {\n flushSync(() => setReturnFocus(false));\n (context.refs.domReference.current as HTMLElement | null)?.focus();\n context.setOpen(false);\n }\n },\n })}\n // After the spread, so a caller's className and style add to these instead of replacing them.\n className={classNames(\n 'roaster-action-list',\n 'roaster-action-list--floating',\n sheet && 'roaster-action-list--sheet',\n className\n )}\n style={asSheet ? style : { ...context.floatingStyles, ...style }}\n >\n <FloatingList elementsRef={context.elementsRef} labelsRef={context.labelsRef}>\n {children}\n </FloatingList>\n </div>\n </FloatingFocusManager>\n );\n }\n);\n\nActionListDropdown.displayName = 'ActionListDropdown';\n"],"names":["React","useActionListContext","useMergeRefs","useMediaQuery","PHONE_QUERY","jsx","FloatingFocusManager","flushSync","classNames","FloatingList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAOY,MAAC,kBAAkB,GAAGA,gBAAK,CAAC,UAAU;AAClD,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,KAAK,EAAE,EAAE,OAAO,KAAK;AACxE,IAAI,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,OAAO,EAAE,GAAGC,uCAAoB,EAAE;AAC3E,IAAI,MAAM,GAAG,GAAGC,kBAAY,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AACjE,IAAI,MAAM,OAAO,GAAGC,qBAAa,CAACC,mBAAW,CAAC,IAAI,KAAK;AACvD,IAAI,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAGJ,gBAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;AAC9D,IAAIA,gBAAK,CAAC,SAAS,CAAC,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AE;AAClI;AACA,OAAO,EAAE;AACT;AACA,EAAE;AACF;AACA,kBAAkB,CAAC,WAAW,GAAG,oBAAoB;;"}
@@ -6,8 +6,9 @@ var react = require('@floating-ui/react');
6
6
  var React = require('react');
7
7
  var Icon = require('../../Icon/Icon.js');
8
8
  var ActionList_context = require('../ActionList.context.js');
9
- var index = require('../../../utils/Slot/index.js');
10
- var index$1 = require('../../../utils/classNames/index.js');
9
+ var index = require('../../../utils/useMergeRefs/index.js');
10
+ var index$1 = require('../../../utils/Slot/index.js');
11
+ var index$2 = require('../../../utils/classNames/index.js');
11
12
 
12
13
  function _interopNamespaceDefault(e) {
13
14
  var n = Object.create(null);
@@ -38,8 +39,8 @@ const ActionListItem = React__namespace.forwardRef(
38
39
  }, propRef) => {
39
40
  const context = ActionList_context.useActionListContext();
40
41
  const item = react.useListItem();
41
- const ref = react.useMergeRefs([item.ref, propRef]);
42
- const Component = asChild ? index.Slot : "button";
42
+ const ref = index.useMergeRefs([item.ref, propRef]);
43
+ const Component = asChild ? index$1.Slot : "button";
43
44
  return /* @__PURE__ */ jsxRuntime.jsx(
44
45
  Component,
45
46
  {
@@ -55,14 +56,14 @@ const ActionListItem = React__namespace.forwardRef(
55
56
  }),
56
57
  ref,
57
58
  tabIndex: context.activeIndex === item.index ? 0 : -1,
58
- className: index$1.classNames(
59
+ className: index$2.classNames(
59
60
  "roaster-action-list__item",
60
61
  { "roaster-action-list__item--danger": tone === "danger" },
61
62
  className
62
63
  ),
63
64
  children: asChild ? children : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
64
65
  children,
65
- checkMark && /* @__PURE__ */ jsxRuntime.jsx(Icon.Icon, { name: "check", className: "roaster-action-list__check" }),
66
+ checkMark && /* @__PURE__ */ jsxRuntime.jsx(Icon.Icon, { name: "check", className: "roaster-action-list__check roaster-action-list__check--end" }),
66
67
  detail != null && detail !== false && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "roaster-action-list__detail", children: detail })
67
68
  ] })
68
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ActionListItem.js","sources":["../../../../../src/components/ActionList/components/ActionListItem.tsx"],"sourcesContent":["import { useListItem, useMergeRefs } from '@floating-ui/react';\nimport * as React from 'react';\nimport { classNames, Slot } from '@/utils';\nimport { Icon } from '../../Icon';\nimport { useActionListContext } from '../ActionList.context';\n\n/** Every native `<button>` prop (`onClick`, `disabled`, ...) is accepted and forwarded to the item. */\nexport interface ActionListItemProps extends React.ComponentPropsWithoutRef<'button'> {\n /** The text of the item, with an optional icon. */\n children: React.ReactNode;\n /** `danger` for a destructive action, such as deleting or logging out. */\n tone?: 'danger';\n /** A short text at the item's end, such as the current choice of a setting. With `asChild`, write it in the child. */\n detail?: React.ReactNode;\n /**\n * Makes the item one of a set of choices (`role=\"menuitemradio\"`), chosen when `true`, such as a sort order. Its\n * icon takes the primary color while it is chosen.\n */\n checked?: boolean;\n /**\n * One of several choices that can be chosen together (`role=\"menuitemcheckbox\"`), such as labels, instead of one of a\n * set. With `checked`.\n */\n multiple?: boolean;\n /**\n * Shows a check at the item's end while it is chosen, such as in a picker whose items carry icons of their own (a\n * status, an avatar). With `checked`.\n */\n checkMark?: boolean;\n /**\n * Renders the child element (such as a link, or a router's Link) as the item, instead of a `<button>`.\n * @defaultValue false\n */\n asChild?: boolean;\n}\n\n/**\n * An item of the menu (`role=\"menuitem\"`, or `menuitemradio` with `checked`): a button, or with `asChild` its child,\n * such as a link. Choosing it closes the menu, after its own `onClick`, unless that calls `event.preventDefault()`.\n */\nexport const ActionListItem = React.forwardRef<HTMLButtonElement, ActionListItemProps>(\n (\n {\n className,\n children,\n tone,\n detail,\n checked,\n multiple,\n checkMark,\n asChild = false,\n onClick,\n type = 'button',\n ...rest\n },\n propRef\n ) => {\n const context = useActionListContext();\n const item = useListItem();\n const ref = useMergeRefs([item.ref, propRef]);\n const Component = asChild ? Slot : 'button';\n\n return (\n <Component\n {...(asChild ? {} : { type })}\n role={checked === undefined ? 'menuitem' : multiple ? 'menuitemcheckbox' : 'menuitemradio'}\n aria-checked={checked}\n {...context.getItemProps({\n ...rest,\n onClick(event: React.MouseEvent<HTMLButtonElement>) {\n onClick?.(event);\n if (!event.defaultPrevented) context.setOpen(false);\n },\n })}\n ref={ref}\n tabIndex={context.activeIndex === item.index ? 0 : -1}\n className={classNames(\n 'roaster-action-list__item',\n { 'roaster-action-list__item--danger': tone === 'danger' },\n className\n )}\n >\n {asChild ? (\n children\n ) : (\n <>\n {children}\n {checkMark && <Icon name=\"check\" className=\"roaster-action-list__check\" />}\n {detail != null && detail !== false && <span className=\"roaster-action-list__detail\">{detail}</span>}\n </>\n )}\n </Component>\n );\n }\n);\nActionListItem.displayName = 'ActionListItem';\n"],"names":["React","useActionListContext","useListItem","useMergeRefs","Slot","jsx","classNames","jsxs","Fragment","Icon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAOY,MAAC,cAAc,GAAGA,gBAAK,CAAC,UAAU;AAC9C,EAAE,CAAC;AACH,IAAI,SAAS;AACb,IAAI,QAAQ;AACZ,IAAI,IAAI;AACR,IAAI,MAAM;AACV,IAAI,OAAO;AACX,IAAI,QAAQ;AACZ,IAAI,SAAS;AACb,IAAI,OAAO,GAAG,KAAK;AACnB,IAAI,OAAO;AACX,IAAI,IAAI,GAAG,QAAQ;AACnB,IAAI,GAAG;AACP,GAAG,EAAE,OAAO,KAAK;AACjB,IAAI,MAAM,OAAO,GAAGC,uCAAoB,EAAE;AAC1C,IAAI,MAAM,IAAI,GAAGC,iBAAW,EAAE;AAC9B,IAAI,MAAM,GAAG,GAAGC,kBAAY,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACjD,IAAI,MAAM,SAAS,GAAG,OAAO,GAAGC,UAAI,GAAG,QAAQ;AAC/C,IAAI,uBAAuBC,cAAG;AAC9B,MAAM,SAAS;AACf,MAAM;AACN,QAAQ,GAAG,OAAO,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE;AAClC,QAAQ,IAAI,EAAE,OAAO,KAAK,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,kBAAkB,GAAG,eAAe;AAC/F,QAAQ,cAAc,EAAE,OAAO;AAC/B,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;AAChC,UAAU,GAAG,IAAI;AACjB,UAAU,OAAO,CAAC,KAAK,EAAE;AACzB,YAAY,OAAO,GAAG,KAAK,CAAC;AAC5B,YAAY,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;AAC/D,UAAU;AACV,SAAS,CAAC;AACV,QAAQ,GAAG;AACX,QAAQ,QAAQ,EAAE,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,EAAE;AAC7D,QAAQ,SAAS,EAAEC,kBAAU;AAC7B,UAAU,2BAA2B;AACrC,UAAU,EAAE,mCAAmC,EAAE,IAAI,KAAK,QAAQ,EAAE;AACpE,UAAU;AACV,SAAS;AACT,QAAQ,QAAQ,EAAE,OAAO,GAAG,QAAQ,mBAAmBC,eAAI,CAACC,mBAAQ,EAAE,EAAE,QAAQ,EAAE;AAClF,UAAU,QAAQ;AAClB,UAAU,SAAS,oBAAoBH,cAAG,CAACI,SAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,4BAA4B,EAAE,CAAC;AAC5G,UAAU,MAAM,IAAI,IAAI,IAAI,MAAM,KAAK,KAAK,oBAAoBJ,cAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,6BAA6B,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC1I,SAAS,EAAE;AACX;AACA,KAAK;AACL,EAAE;AACF;AACA,cAAc,CAAC,WAAW,GAAG,gBAAgB;;"}
1
+ {"version":3,"file":"ActionListItem.js","sources":["../../../../../src/components/ActionList/components/ActionListItem.tsx"],"sourcesContent":["import { useListItem } from '@floating-ui/react';\nimport * as React from 'react';\nimport { classNames, Slot, useMergeRefs } from '@/utils';\nimport { Icon } from '../../Icon';\nimport { useActionListContext } from '../ActionList.context';\n\n/** Every native `<button>` prop (`onClick`, `disabled`, ...) is accepted and forwarded to the item. */\nexport interface ActionListItemProps extends React.ComponentPropsWithoutRef<'button'> {\n /**\n * The text of the item, with an optional icon. An icon after the text goes to the item's end, with the text in a\n * `<span>`: `<span>Privacy</span><Icon name=\"arrow-up-right-from-square\" />`.\n */\n children: React.ReactNode;\n /** `danger` for a destructive action, such as deleting or logging out. */\n tone?: 'danger';\n /** A short text at the item's end, such as the current choice of a setting. With `asChild`, write it in the child. */\n detail?: React.ReactNode;\n /**\n * Makes the item one of a set of choices (`role=\"menuitemradio\"`), chosen when `true`, such as a sort order. Its\n * icon takes the primary color while it is chosen.\n */\n checked?: boolean;\n /**\n * One of several choices that can be chosen together (`role=\"menuitemcheckbox\"`), such as labels, instead of one of a\n * set. With `checked`.\n */\n multiple?: boolean;\n /**\n * Shows a check at the item's end while it is chosen, such as in a picker whose items carry icons of their own (a\n * status, an avatar). With `checked`.\n */\n checkMark?: boolean;\n /**\n * Renders the child element (such as a link, or a router's Link) as the item, instead of a `<button>`.\n * @defaultValue false\n */\n asChild?: boolean;\n}\n\n/**\n * An item of the menu (`role=\"menuitem\"`, or `menuitemradio` with `checked`): a button, or with `asChild` its child,\n * such as a link. Choosing it closes the menu, after its own `onClick`, unless that calls `event.preventDefault()`.\n */\nexport const ActionListItem = React.forwardRef<HTMLButtonElement, ActionListItemProps>(\n (\n {\n className,\n children,\n tone,\n detail,\n checked,\n multiple,\n checkMark,\n asChild = false,\n onClick,\n type = 'button',\n ...rest\n },\n propRef\n ) => {\n const context = useActionListContext();\n const item = useListItem();\n const ref = useMergeRefs([item.ref, propRef]);\n const Component = asChild ? Slot : 'button';\n\n return (\n <Component\n {...(asChild ? {} : { type })}\n role={checked === undefined ? 'menuitem' : multiple ? 'menuitemcheckbox' : 'menuitemradio'}\n aria-checked={checked}\n {...context.getItemProps({\n ...rest,\n onClick(event: React.MouseEvent<HTMLButtonElement>) {\n onClick?.(event);\n if (!event.defaultPrevented) context.setOpen(false);\n },\n })}\n ref={ref}\n tabIndex={context.activeIndex === item.index ? 0 : -1}\n className={classNames(\n 'roaster-action-list__item',\n { 'roaster-action-list__item--danger': tone === 'danger' },\n className\n )}\n >\n {asChild ? (\n children\n ) : (\n <>\n {children}\n {checkMark && <Icon name=\"check\" className=\"roaster-action-list__check roaster-action-list__check--end\" />}\n {detail != null && detail !== false && <span className=\"roaster-action-list__detail\">{detail}</span>}\n </>\n )}\n </Component>\n );\n }\n);\nActionListItem.displayName = 'ActionListItem';\n"],"names":["React","useActionListContext","useListItem","useMergeRefs","Slot","jsx","classNames","jsxs","Fragment","Icon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAOY,MAAC,cAAc,GAAGA,gBAAK,CAAC,UAAU;AAC9C,EAAE,CAAC;AACH,IAAI,SAAS;AACb,IAAI,QAAQ;AACZ,IAAI,IAAI;AACR,IAAI,MAAM;AACV,IAAI,OAAO;AACX,IAAI,QAAQ;AACZ,IAAI,SAAS;AACb,IAAI,OAAO,GAAG,KAAK;AACnB,IAAI,OAAO;AACX,IAAI,IAAI,GAAG,QAAQ;AACnB,IAAI,GAAG;AACP,GAAG,EAAE,OAAO,KAAK;AACjB,IAAI,MAAM,OAAO,GAAGC,uCAAoB,EAAE;AAC1C,IAAI,MAAM,IAAI,GAAGC,iBAAW,EAAE;AAC9B,IAAI,MAAM,GAAG,GAAGC,kBAAY,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACjD,IAAI,MAAM,SAAS,GAAG,OAAO,GAAGC,YAAI,GAAG,QAAQ;AAC/C,IAAI,uBAAuBC,cAAG;AAC9B,MAAM,SAAS;AACf,MAAM;AACN,QAAQ,GAAG,OAAO,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE;AAClC,QAAQ,IAAI,EAAE,OAAO,KAAK,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,kBAAkB,GAAG,eAAe;AAC/F,QAAQ,cAAc,EAAE,OAAO;AAC/B,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;AAChC,UAAU,GAAG,IAAI;AACjB,UAAU,OAAO,CAAC,KAAK,EAAE;AACzB,YAAY,OAAO,GAAG,KAAK,CAAC;AAC5B,YAAY,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;AAC/D,UAAU;AACV,SAAS,CAAC;AACV,QAAQ,GAAG;AACX,QAAQ,QAAQ,EAAE,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,EAAE;AAC7D,QAAQ,SAAS,EAAEC,kBAAU;AAC7B,UAAU,2BAA2B;AACrC,UAAU,EAAE,mCAAmC,EAAE,IAAI,KAAK,QAAQ,EAAE;AACpE,UAAU;AACV,SAAS;AACT,QAAQ,QAAQ,EAAE,OAAO,GAAG,QAAQ,mBAAmBC,eAAI,CAACC,mBAAQ,EAAE,EAAE,QAAQ,EAAE;AAClF,UAAU,QAAQ;AAClB,UAAU,SAAS,oBAAoBH,cAAG,CAACI,SAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,4DAA4D,EAAE,CAAC;AAC5I,UAAU,MAAM,IAAI,IAAI,IAAI,MAAM,KAAK,KAAK,oBAAoBJ,cAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,6BAA6B,EAAE,QAAQ,EAAE,MAAM,EAAE;AAC1I,SAAS,EAAE;AACX;AACA,KAAK;AACL,EAAE;AACF;AACA,cAAc,CAAC,WAAW,GAAG,gBAAgB;;"}
@@ -3,9 +3,9 @@
3
3
 
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var React = require('react');
6
- var react = require('@floating-ui/react');
7
6
  var ActionList_context = require('../ActionList.context.js');
8
- var index = require('../../../utils/classNames/index.js');
7
+ var index = require('../../../utils/useMergeRefs/index.js');
8
+ var index$1 = require('../../../utils/classNames/index.js');
9
9
 
10
10
  function _interopNamespaceDefault(e) {
11
11
  var n = Object.create(null);
@@ -24,19 +24,37 @@ const ActionListSearch = React__namespace.forwardRef(
24
24
  ({ onValueChange, onChange, onKeyDown, shortcut, className, style, autoFocus = true, ...rest }, propRef) => {
25
25
  const context = ActionList_context.useActionListContext();
26
26
  const inputRef = React__namespace.useRef(null);
27
- const ref = react.useMergeRefs([inputRef, propRef]);
27
+ const ref = index.useMergeRefs([inputRef, propRef]);
28
28
  React__namespace.useEffect(() => {
29
- if (!autoFocus) return void 0;
29
+ const input = inputRef.current;
30
+ const menu = input?.closest(".roaster-action-list");
31
+ if (!autoFocus || !input || !menu) return void 0;
32
+ const armed = new AbortController();
30
33
  let inner = 0;
31
34
  const outer = requestAnimationFrame(() => {
32
- inner = requestAnimationFrame(() => inputRef.current?.focus());
35
+ inner = requestAnimationFrame(() => {
36
+ input.focus();
37
+ const disarm = () => armed.abort();
38
+ menu.addEventListener("keydown", disarm, { capture: true, signal: armed.signal });
39
+ menu.addEventListener("pointerdown", disarm, { capture: true, signal: armed.signal });
40
+ menu.addEventListener(
41
+ "focusin",
42
+ (event) => {
43
+ if (event.target === input) return;
44
+ disarm();
45
+ input.focus();
46
+ },
47
+ { signal: armed.signal }
48
+ );
49
+ });
33
50
  });
34
51
  return () => {
35
52
  cancelAnimationFrame(outer);
36
53
  cancelAnimationFrame(inner);
54
+ armed.abort();
37
55
  };
38
56
  }, [autoFocus]);
39
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index.classNames("roaster-action-list__search", className), style, children: [
57
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: index$1.classNames("roaster-action-list__search", className), style, children: [
40
58
  /* @__PURE__ */ jsxRuntime.jsx(
41
59
  "input",
42
60
  {
@@ -1 +1 @@
1
- {"version":3,"file":"ActionListSearch.js","sources":["../../../../../src/components/ActionList/components/ActionListSearch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useMergeRefs } from '@floating-ui/react';\nimport { classNames } from '@/utils';\nimport { useActionListContext } from '../ActionList.context';\n\n/**\n * Every native `<input>` prop (`value`, `onChange`, `placeholder`, ...) is accepted and forwarded to the search field,\n * with the ref. `className` and `style` go to its row.\n */\nexport interface ActionListSearchProps extends Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'style'> {\n /** The search field's name, read by screen readers, such as \"Find a filter\". */\n 'aria-label': string;\n /** Called with the text as the user types: hide the items that don't match it. */\n onValueChange?(value: string): void;\n /** A key hint at the row's end, such as the shortcut that opens the menu. */\n shortcut?: React.ReactNode;\n /** Styles added to the row. */\n style?: React.CSSProperties;\n}\n\n/**\n * A search row at the top of a long menu, such as a list of filters: it takes the focus when the menu opens, and the\n * down arrow goes on to the items. Filter the items from its value.\n */\nexport const ActionListSearch = React.forwardRef<HTMLInputElement, ActionListSearchProps>(\n ({ onValueChange, onChange, onKeyDown, shortcut, className, style, autoFocus = true, ...rest }, propRef) => {\n const context = useActionListContext();\n const inputRef = React.useRef<HTMLInputElement>(null);\n const ref = useMergeRefs([inputRef, propRef]);\n // The menu gives the focus to its first item a frame after it opens; the search takes it back after that.\n React.useEffect(() => {\n if (!autoFocus) return undefined;\n let inner = 0;\n const outer = requestAnimationFrame(() => {\n inner = requestAnimationFrame(() => inputRef.current?.focus());\n });\n return () => {\n cancelAnimationFrame(outer);\n cancelAnimationFrame(inner);\n };\n }, [autoFocus]);\n return (\n <div className={classNames('roaster-action-list__search', className)} style={style}>\n <input\n {...rest}\n ref={ref}\n type=\"search\"\n onChange={(event) => {\n onChange?.(event);\n onValueChange?.(event.currentTarget.value);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n // The menu's own keys move between its items; from the search field, the down arrow goes to the first.\n if (event.key === 'ArrowDown' && !event.defaultPrevented) {\n event.preventDefault();\n context.elementsRef.current.find((element) => element && !element.hidden)?.focus();\n }\n // Typing a letter moves between items elsewhere in the menu; here it is the search.\n event.stopPropagation();\n }}\n />\n {shortcut != null && shortcut !== false && <kbd>{shortcut}</kbd>}\n </div>\n );\n }\n);\nActionListSearch.displayName = 'ActionListSearch';\n"],"names":["React","useActionListContext","useMergeRefs","jsxs","classNames","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAMY,MAAC,gBAAgB,GAAGA,gBAAK,CAAC,UAAU;AAChD,EAAE,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE,OAAO,KAAK;AAC9G,IAAI,MAAM,OAAO,GAAGC,uCAAoB,EAAE;AAC1C,IAAI,MAAM,QAAQ,GAAGD,gBAAK,CAAC,MAAM,CAAC,IAAI,CAAC;AACvC,IAAI,MAAM,GAAG,GAAGE,kBAAY,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACjD,IAAIF,gBAAK,CAAC,SAAS,CAAC,MAAM;AAC1B,MAAM,IAAI,CAAC,SAAS,EAAE,OAAO,MAAM;AACnC,MAAM,IAAI,KAAK,GAAG,CAAC;AACnB,MAAM,MAAM,KAAK,GAAG,qBAAqB,CAAC,MAAM;AAChD,QAAQ,KAAK,GAAG,qBAAqB,CAAC,MAAM,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;AACtE,MAAM,CAAC,CAAC;AACR,MAAM,OAAO,MAAM;AACnB,QAAQ,oBAAoB,CAAC,KAAK,CAAC;AACnC,QAAQ,oBAAoB,CAAC,KAAK,CAAC;AACnC,MAAM,CAAC;AACP,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AACnB,IAAI,uBAAuBG,eAAI,CAAC,KAAK,EAAE,EAAE,SAAS,EAAEC,gBAAU,CAAC,6BAA6B,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE;AAC3H,sBAAsBC,cAAG;AACzB,QAAQ,OAAO;AACf,QAAQ;AACR,UAAU,GAAG,IAAI;AACjB,UAAU,GAAG;AACb,UAAU,IAAI,EAAE,QAAQ;AACxB,UAAU,QAAQ,EAAE,CAAC,KAAK,KAAK;AAC/B,YAAY,QAAQ,GAAG,KAAK,CAAC;AAC7B,YAAY,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC;AACtD,UAAU,CAAC;AACX,UAAU,SAAS,EAAE,CAAC,KAAK,KAAK;AAChC,YAAY,SAAS,GAAG,KAAK,CAAC;AAC9B,YAAY,IAAI,KAAK,CAAC,GAAG,KAAK,WAAW,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;AACtE,cAAc,KAAK,CAAC,cAAc,EAAE;AACpC,cAAc,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE;AAChG,YAAY;AACZ,YAAY,KAAK,CAAC,eAAe,EAAE;AACnC,UAAU;AACV;AACA,OAAO;AACP,MAAM,QAAQ,IAAI,IAAI,IAAI,QAAQ,KAAK,KAAK,oBAAoBA,cAAG,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;AACjG,KAAK,EAAE,CAAC;AACR,EAAE;AACF;AACA,gBAAgB,CAAC,WAAW,GAAG,kBAAkB;;"}
1
+ {"version":3,"file":"ActionListSearch.js","sources":["../../../../../src/components/ActionList/components/ActionListSearch.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useMergeRefs } from '@/utils';\nimport { useActionListContext } from '../ActionList.context';\n\n/**\n * Every native `<input>` prop (`value`, `onChange`, `placeholder`, ...) is accepted and forwarded to the search field,\n * with the ref. `className` and `style` go to its row.\n */\nexport interface ActionListSearchProps extends Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'style'> {\n /** The search field's name, read by screen readers, such as \"Find a filter\". */\n 'aria-label': string;\n /** Called with the text as the user types: hide the items that don't match it. */\n onValueChange?(value: string): void;\n /** A key hint at the row's end, such as the shortcut that opens the menu. */\n shortcut?: React.ReactNode;\n /** Styles added to the row. */\n style?: React.CSSProperties;\n}\n\n/**\n * A search row at the top of a long menu, such as a list of filters: it takes the focus when the menu opens, and the\n * down arrow goes on to the items. Filter the items from its value.\n */\nexport const ActionListSearch = React.forwardRef<HTMLInputElement, ActionListSearchProps>(\n ({ onValueChange, onChange, onKeyDown, shortcut, className, style, autoFocus = true, ...rest }, propRef) => {\n const context = useActionListContext();\n const inputRef = React.useRef<HTMLInputElement>(null);\n const ref = useMergeRefs([inputRef, propRef]);\n // The menu gives the focus to its first item a frame after it opens; the search takes it back after that. On a slow\n // device the menu's can come later still: until a key or a click in the menu, the search takes the focus back from\n // an item, once.\n React.useEffect(() => {\n const input = inputRef.current;\n const menu = input?.closest<HTMLElement>('.roaster-action-list');\n if (!autoFocus || !input || !menu) return undefined;\n const armed = new AbortController();\n let inner = 0;\n const outer = requestAnimationFrame(() => {\n inner = requestAnimationFrame(() => {\n input.focus();\n const disarm = () => armed.abort();\n menu.addEventListener('keydown', disarm, { capture: true, signal: armed.signal });\n menu.addEventListener('pointerdown', disarm, { capture: true, signal: armed.signal });\n menu.addEventListener(\n 'focusin',\n (event) => {\n if (event.target === input) return;\n disarm();\n input.focus();\n },\n { signal: armed.signal }\n );\n });\n });\n return () => {\n cancelAnimationFrame(outer);\n cancelAnimationFrame(inner);\n armed.abort();\n };\n }, [autoFocus]);\n return (\n <div className={classNames('roaster-action-list__search', className)} style={style}>\n <input\n {...rest}\n ref={ref}\n type=\"search\"\n onChange={(event) => {\n onChange?.(event);\n onValueChange?.(event.currentTarget.value);\n }}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n // The menu's own keys move between its items; from the search field, the down arrow goes to the first.\n if (event.key === 'ArrowDown' && !event.defaultPrevented) {\n event.preventDefault();\n context.elementsRef.current.find((element) => element && !element.hidden)?.focus();\n }\n // Typing a letter moves between items elsewhere in the menu; here it is the search.\n event.stopPropagation();\n }}\n />\n {shortcut != null && shortcut !== false && <kbd>{shortcut}</kbd>}\n </div>\n );\n }\n);\nActionListSearch.displayName = 'ActionListSearch';\n"],"names":["React","useActionListContext","useMergeRefs","jsxs","classNames","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAKY,MAAC,gBAAgB,GAAGA,gBAAK,CAAC,UAAU;AAChD,EAAE,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE,OAAO,KAAK;AAC9G,IAAI,MAAM,OAAO,GAAGC,uCAAoB,EAAE;AAC1C,IAAI,MAAM,QAAQ,GAAGD,gBAAK,CAAC,MAAM,CAAC,IAAI,CAAC;AACvC,IAAI,MAAM,GAAG,GAAGE,kBAAY,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACjD,IAAIF,gBAAK,CAAC,SAAS,CAAC,MAAM;AAC1B,MAAM,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO;AACpC,MAAM,MAAM,IAAI,GAAG,KAAK,EAAE,OAAO,CAAC,sBAAsB,CAAC;AACzD,MAAM,IAAI,CAAC,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,OAAO,MAAM;AACtD,MAAM,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE;AACzC,MAAM,IAAI,KAAK,GAAG,CAAC;AACnB,MAAM,MAAM,KAAK,GAAG,qBAAqB,CAAC,MAAM;AAChD,QAAQ,KAAK,GAAG,qBAAqB,CAAC,MAAM;AAC5C,UAAU,KAAK,CAAC,KAAK,EAAE;AACvB,UAAU,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE;AAC5C,UAAU,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;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AAC,gBAAgB,EAAE;AACtE,cAAc,KAAK,CAAC,cAAc,EAAE;AACpC,cAAc,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE;AAChG,YAAY;AACZ,YAAY,KAAK,CAAC,eAAe,EAAE;AACnC,UAAU;AACV;AACA,OAAO;AACP,MAAM,QAAQ,IAAI,IAAI,IAAI,QAAQ,KAAK,KAAK,oBAAoBA,cAAG,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;AACjG,KAAK,EAAE,CAAC;AACR,EAAE;AACF;AACA,gBAAgB,CAAC,WAAW,GAAG,kBAAkB;;"}
@@ -7,7 +7,8 @@ var React = require('react');
7
7
  var Icon = require('../../Icon/Icon.js');
8
8
  var ActionList_context = require('../ActionList.context.js');
9
9
  var index = require('../../../utils/useDropdown/index.js');
10
- var index$1 = require('../../../utils/classNames/index.js');
10
+ var index$1 = require('../../../utils/useMergeRefs/index.js');
11
+ var index$2 = require('../../../utils/classNames/index.js');
11
12
 
12
13
  function _interopNamespaceDefault(e) {
13
14
  var n = Object.create(null);
@@ -78,7 +79,7 @@ const ActionListSubmenu = React__namespace.forwardRef(
78
79
  }),
79
80
  [data, interactions, open, activeIndex, parentSetOpen]
80
81
  );
81
- const triggerRef = react.useMergeRefs([item.ref, data.refs.setReference, propRef]);
82
+ const triggerRef = index$1.useMergeRefs([item.ref, data.refs.setReference, propRef]);
82
83
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
83
84
  /* @__PURE__ */ jsxRuntime.jsxs(
84
85
  "button",
@@ -89,7 +90,7 @@ const ActionListSubmenu = React__namespace.forwardRef(
89
90
  role: "menuitem",
90
91
  "aria-haspopup": "menu",
91
92
  tabIndex: parent.activeIndex === item.index ? 0 : -1,
92
- className: index$1.classNames("roaster-action-list__item", className),
93
+ className: index$2.classNames("roaster-action-list__item", className),
93
94
  children: [
94
95
  label,
95
96
  detail != null && detail !== false && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "roaster-action-list__detail", children: detail }),
@@ -1 +1 @@
1
- {"version":3,"file":"ActionListSubmenu.js","sources":["../../../../../src/components/ActionList/components/ActionListSubmenu.tsx"],"sourcesContent":["import {\n autoUpdate,\n flip,\n FloatingFocusManager,\n FloatingList,\n offset,\n type Placement,\n shift,\n useClick,\n useDismiss,\n useFloating,\n useInteractions,\n useListItem,\n useListNavigation,\n useMergeRefs,\n useRole,\n useTypeahead,\n} from '@floating-ui/react';\nimport * as React from 'react';\nimport { classNames, readLengthToken } from '@/utils';\nimport { Icon } from '../../Icon';\nimport { ActionListProvider, useActionListContext } from '../ActionList.context';\n\n/** Every native `<button>` prop is accepted and forwarded to the item that opens the submenu. */\nexport interface ActionListSubmenuProps extends Omit<React.ComponentPropsWithoutRef<'button'>, 'children'> {\n /** The item that opens the submenu: its text, with an optional icon. */\n label: React.ReactNode;\n /** A short text before the item's chevron, such as the current choice. */\n detail?: React.ReactNode;\n /** The submenu's groups, dividers and items, as in ActionList.Dropdown. */\n children: React.ReactNode;\n /**\n * Where the submenu opens. It moves to the other side when there is no room.\n * @defaultValue 'right-start'\n */\n placement?: Placement;\n}\n\n/**\n * An item that opens a submenu beside it, such as a setting's choices: on click, Enter, or the right arrow (the left\n * arrow and Escape close it). The item names the submenu. Choosing an item of the submenu closes it and its menu.\n */\nexport const ActionListSubmenu = React.forwardRef<HTMLButtonElement, ActionListSubmenuProps>(\n ({ label, detail, children, placement = 'right-start', className, type = 'button', ...rest }, propRef) => {\n const parent = useActionListContext();\n const item = useListItem();\n const [open, setOpen] = React.useState(false);\n const elementsRef = React.useRef<Array<HTMLElement | null>>([]);\n const labelsRef = React.useRef<Array<string | null>>([]);\n const [activeIndex, setActiveIndex] = React.useState<number | null>(null);\n\n const data = useFloating({\n placement,\n strategy: 'fixed',\n transform: false,\n open,\n onOpenChange: setOpen,\n whileElementsMounted: autoUpdate,\n middleware: [\n // As far from its item as the menu is from its button, past the menu's padding.\n offset(\n ({ elements }) =>\n readLengthToken(elements.floating, '--roaster-action-list-offset', 8) +\n readLengthToken(elements.floating, '--roaster-action-list-padding', 0)\n ),\n flip(),\n shift({ padding: 8 }),\n ],\n });\n const { context } = data;\n const interactions = useInteractions([\n useClick(context),\n useRole(context, { role: 'menu' }),\n useDismiss(context),\n useListNavigation(context, {\n listRef: elementsRef,\n activeIndex,\n onNavigate: setActiveIndex,\n loop: true,\n nested: true,\n focusItemOnOpen: true,\n }),\n useTypeahead(context, { listRef: labelsRef, activeIndex, onMatch: open ? setActiveIndex : undefined }),\n ]);\n\n // The submenu's items close it and the menu it came from.\n const parentSetOpen = parent.setOpen;\n const submenu = React.useMemo(\n () => ({\n ...data,\n ...interactions,\n open,\n activeIndex,\n elementsRef,\n labelsRef,\n setOpen: (next: boolean | ((previous: boolean) => boolean)) => {\n const value = typeof next === 'function' ? next(open) : next;\n setOpen(value);\n if (!value) parentSetOpen(false);\n },\n }),\n [data, interactions, open, activeIndex, parentSetOpen]\n );\n\n const triggerRef = useMergeRefs([item.ref, data.refs.setReference, propRef]);\n\n return (\n <>\n <button\n {...parent.getItemProps(interactions.getReferenceProps(rest))}\n ref={triggerRef}\n type={type}\n role=\"menuitem\"\n aria-haspopup=\"menu\"\n tabIndex={parent.activeIndex === item.index ? 0 : -1}\n className={classNames('roaster-action-list__item', className)}\n >\n {label}\n {detail != null && detail !== false && <span className=\"roaster-action-list__detail\">{detail}</span>}\n <Icon name=\"chevron-right\" />\n </button>\n {open && (\n <FloatingFocusManager context={context} modal={false} initialFocus={-1}>\n <div\n ref={data.refs.setFloating}\n {...interactions.getFloatingProps({\n onKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n // Its keys are its own: the menu around it doesn't move, nor close on Escape, which closes only\n // the submenu. Tab goes on to close both.\n if (event.key === 'Tab') return;\n event.stopPropagation();\n if (event.key === 'Escape') {\n setOpen(false);\n (data.refs.domReference.current as HTMLElement | null)?.focus();\n }\n },\n })}\n className=\"roaster-action-list roaster-action-list--submenu roaster-action-list--floating\"\n style={data.floatingStyles}\n >\n <ActionListProvider value={submenu}>\n <FloatingList elementsRef={elementsRef} labelsRef={labelsRef}>\n {children}\n </FloatingList>\n </ActionListProvider>\n </div>\n </FloatingFocusManager>\n )}\n </>\n );\n }\n);\nActionListSubmenu.displayName = 'ActionListSubmenu';\n"],"names":["React","useActionListContext","useListItem","useFloating","autoUpdate","offset","readLengthToken","flip","shift","useInteractions","useClick","useRole","useDismiss","useListNavigation","useTypeahead","useMergeRefs","jsxs","Fragment","classNames","jsx","Icon","FloatingFocusManager","ActionListProvider","FloatingList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBY,MAAC,iBAAiB,GAAGA,gBAAK,CAAC,UAAU;AACjD,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAG,aAAa,EAAE,SAAS,EAAE,IAAI,GAAG,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,OAAO,KAAK;AAC5G,IAAI,MAAM,MAAM,GAAGC,uCAAoB,EAAE;AACzC,IAAI,MAAM,IAAI,GAAGC,iBAAW,EAAE;AAC9B,IAAI,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAGF,gBAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;AACjD,IAAI,MAAM,WAAW,GAAGA,gBAAK,CAAC,MAAM,CAAC,EAAE,CAAC;AACxC,IAAI,MAAM,SAAS,GAAGA,gBAAK,CAAC,MAAM,CAAC,EAAE,CAAC;AACtC,IAAI,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAGA,gBAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;AAC9D,IAAI,MAAM,IAAI,GAAGG,iBAAW,CAAC;AAC7B,MAAM,SAAS;AACf,MAAM,QAAQ,EAAE,OAAO;AACvB,MAAM,SAAS,EAAE,KAAK;AACtB,MAAM,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,IAAI,EAAE,eAAe,EAAE;AAC/D;AACA;AACA,OAAO;AACP,MAAM,IAAI,oBAAoBD,cAAG,CAACE,0BAAoB,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,kBAAkBF,cAAG;AAChI,QAAQ,KAAK;AACb,QAAQ;AACR,UAAU,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW;AACpC,UAAU,GAAG,YAAY,CAAC,gBAAgB,CAAC;AAC3C,YAAY,SAAS,CAAC,KAAK,EAAE;AAC7B,cAAc,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,EAAE;AACvC,cAAc,KAAK,CAAC,eAAe,EAAE;AACrC,cAAc,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE;AAC1C,gBAAgB,OAAO,CAAC,KAAK,CAAC;AAC9B,gBAAgB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE;AACvD,cAAc;AACd,YAAY;AACZ,WAAW,CAAC;AACZ,UAAU,SAAS,EAAE,gFAAgF;AACrG,UAAU,KAAK,EAAE,IAAI,CAAC,cAAc;AACpC,UAAU,QAAQ,kBAAkBA,cAAG,CAACG,qCAAkB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,kBAAkBH,cAAG,CAACI,kBAAY,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE;AACjK;AACA,OAAO,EAAE;AACT,KAAK,EAAE,CAAC;AACR,EAAE;AACF;AACA,iBAAiB,CAAC,WAAW,GAAG,mBAAmB;;"}
1
+ {"version":3,"file":"ActionListSubmenu.js","sources":["../../../../../src/components/ActionList/components/ActionListSubmenu.tsx"],"sourcesContent":["import {\n autoUpdate,\n flip,\n FloatingFocusManager,\n FloatingList,\n offset,\n type Placement,\n shift,\n useClick,\n useDismiss,\n useFloating,\n useInteractions,\n useListItem,\n useListNavigation,\n useRole,\n useTypeahead,\n} from '@floating-ui/react';\nimport * as React from 'react';\nimport { classNames, readLengthToken, useMergeRefs } from '@/utils';\nimport { Icon } from '../../Icon';\nimport { ActionListProvider, useActionListContext } from '../ActionList.context';\n\n/** Every native `<button>` prop is accepted and forwarded to the item that opens the submenu. */\nexport interface ActionListSubmenuProps extends Omit<React.ComponentPropsWithoutRef<'button'>, 'children'> {\n /** The item that opens the submenu: its text, with an optional icon. */\n label: React.ReactNode;\n /** A short text before the item's chevron, such as the current choice. */\n detail?: React.ReactNode;\n /** The submenu's groups, dividers and items, as in ActionList.Dropdown. */\n children: React.ReactNode;\n /**\n * Where the submenu opens. It moves to the other side when there is no room.\n * @defaultValue 'right-start'\n */\n placement?: Placement;\n}\n\n/**\n * An item that opens a submenu beside it, such as a setting's choices: on click, Enter, or the right arrow (the left\n * arrow and Escape close it). The item names the submenu. Choosing an item of the submenu closes it and its menu.\n */\nexport const ActionListSubmenu = React.forwardRef<HTMLButtonElement, ActionListSubmenuProps>(\n ({ label, detail, children, placement = 'right-start', className, type = 'button', ...rest }, propRef) => {\n const parent = useActionListContext();\n const item = useListItem();\n const [open, setOpen] = React.useState(false);\n const elementsRef = React.useRef<Array<HTMLElement | null>>([]);\n const labelsRef = React.useRef<Array<string | null>>([]);\n const [activeIndex, setActiveIndex] = React.useState<number | null>(null);\n\n const data = useFloating({\n placement,\n strategy: 'fixed',\n transform: false,\n open,\n onOpenChange: setOpen,\n whileElementsMounted: autoUpdate,\n middleware: [\n // As far from its item as the menu is from its button, past the menu's padding.\n offset(\n ({ elements }) =>\n readLengthToken(elements.floating, '--roaster-action-list-offset', 8) +\n readLengthToken(elements.floating, '--roaster-action-list-padding', 0)\n ),\n flip(),\n shift({ padding: 8 }),\n ],\n });\n const { context } = data;\n const interactions = useInteractions([\n useClick(context),\n useRole(context, { role: 'menu' }),\n useDismiss(context),\n useListNavigation(context, {\n listRef: elementsRef,\n activeIndex,\n onNavigate: setActiveIndex,\n loop: true,\n nested: true,\n focusItemOnOpen: true,\n }),\n useTypeahead(context, { listRef: labelsRef, activeIndex, onMatch: open ? setActiveIndex : undefined }),\n ]);\n\n // The submenu's items close it and the menu it came from.\n const parentSetOpen = parent.setOpen;\n const submenu = React.useMemo(\n () => ({\n ...data,\n ...interactions,\n open,\n activeIndex,\n elementsRef,\n labelsRef,\n setOpen: (next: boolean | ((previous: boolean) => boolean)) => {\n const value = typeof next === 'function' ? next(open) : next;\n setOpen(value);\n if (!value) parentSetOpen(false);\n },\n }),\n [data, interactions, open, activeIndex, parentSetOpen]\n );\n\n const triggerRef = useMergeRefs([item.ref, data.refs.setReference, propRef]);\n\n return (\n <>\n <button\n {...parent.getItemProps(interactions.getReferenceProps(rest))}\n ref={triggerRef}\n type={type}\n role=\"menuitem\"\n aria-haspopup=\"menu\"\n tabIndex={parent.activeIndex === item.index ? 0 : -1}\n className={classNames('roaster-action-list__item', className)}\n >\n {label}\n {detail != null && detail !== false && <span className=\"roaster-action-list__detail\">{detail}</span>}\n <Icon name=\"chevron-right\" />\n </button>\n {open && (\n <FloatingFocusManager context={context} modal={false} initialFocus={-1}>\n <div\n ref={data.refs.setFloating}\n {...interactions.getFloatingProps({\n onKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n // Its keys are its own: the menu around it doesn't move, nor close on Escape, which closes only\n // the submenu. Tab goes on to close both.\n if (event.key === 'Tab') return;\n event.stopPropagation();\n if (event.key === 'Escape') {\n setOpen(false);\n (data.refs.domReference.current as HTMLElement | null)?.focus();\n }\n },\n })}\n className=\"roaster-action-list roaster-action-list--submenu roaster-action-list--floating\"\n style={data.floatingStyles}\n >\n <ActionListProvider value={submenu}>\n <FloatingList elementsRef={elementsRef} labelsRef={labelsRef}>\n {children}\n </FloatingList>\n </ActionListProvider>\n </div>\n </FloatingFocusManager>\n )}\n </>\n );\n }\n);\nActionListSubmenu.displayName = 'ActionListSubmenu';\n"],"names":["React","useActionListContext","useListItem","useFloating","autoUpdate","offset","readLengthToken","flip","shift","useInteractions","useClick","useRole","useDismiss","useListNavigation","useTypeahead","useMergeRefs","jsxs","Fragment","classNames","jsx","Icon","FloatingFocusManager","ActionListProvider","FloatingList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBY,MAAC,iBAAiB,GAAGA,gBAAK,CAAC,UAAU;AACjD,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAG,aAAa,EAAE,SAAS,EAAE,IAAI,GAAG,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,OAAO,KAAK;AAC5G,IAAI,MAAM,MAAM,GAAGC,uCAAoB,EAAE;AACzC,IAAI,MAAM,IAAI,GAAGC,iBAAW,EAAE;AAC9B,IAAI,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAGF,gBAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;AACjD,IAAI,MAAM,WAAW,GAAGA,gBAAK,CAAC,MAAM,CAAC,EAAE,CAAC;AACxC,IAAI,MAAM,SAAS,GAAGA,gBAAK,CAAC,MAAM,CAAC,EAAE,CAAC;AACtC,IAAI,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAGA,gBAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;AAC9D,IAAI,MAAM,IAAI,GAAGG,iBAAW,CAAC;AAC7B,MAAM,SAAS;AACf,MAAM,QAAQ,EAAE,OAAO;AACvB,MAAM,SAAS,EAAE,KAAK;AACtB,MAAM,IAAI;AACV,MAAM,YAAY,EAAE,OAAO;AAC3B,MAAM,oBAAoB,EAAEC,gBAAU;AACtC,MAAM,UAAU,EAAE;AAClB;AACA,QAAQC,YAAM;AACd,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAKC,qBAAe,CAAC,QAAQ,CAAC,QAAQ,EAAE,8BAA8B,EAAE,CAAC,CAAC,GAAGA,qBAAe,CAAC,QAAQ,CAAC,QAAQ,EAAE,+BAA+B,EAAE,CAAC;AACzK,SAAS;AACT,QAAQC,UAAI,EAAE;AACd,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,CAAC,KAAK,EAAE;AAC7B,cAAc,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,EAAE;AACvC,cAAc,KAAK,CAAC,eAAe,EAAE;AACrC,cAAc,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE;AAC1C,gBAAgB,OAAO,CAAC,KAAK,CAAC;AAC9B,gBAAgB,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE;AACvD,cAAc;AACd,YAAY;AACZ,WAAW,CAAC;AACZ,UAAU,SAAS,EAAE,gFAAgF;AACrG,UAAU,KAAK,EAAE,IAAI,CAAC,cAAc;AACpC,UAAU,QAAQ,kBAAkBA,cAAG,CAACG,qCAAkB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,kBAAkBH,cAAG,CAACI,kBAAY,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE;AACjK;AACA,OAAO,EAAE;AACT,KAAK,EAAE,CAAC;AACR,EAAE;AACF;AACA,iBAAiB,CAAC,WAAW,GAAG,mBAAmB;;"}
@@ -5,8 +5,9 @@ var jsxRuntime = require('react/jsx-runtime');
5
5
  var react = require('@floating-ui/react');
6
6
  var React = require('react');
7
7
  var ActionList_context = require('../ActionList.context.js');
8
- var index = require('../../../utils/useControllableState/index.js');
9
- var index$1 = require('../../../utils/classNames/index.js');
8
+ var index = require('../../../utils/useMergeRefs/index.js');
9
+ var index$1 = require('../../../utils/useControllableState/index.js');
10
+ var index$2 = require('../../../utils/classNames/index.js');
10
11
 
11
12
  function _interopNamespaceDefault(e) {
12
13
  var n = Object.create(null);
@@ -25,13 +26,13 @@ const ActionListSwitchItem = React__namespace.forwardRef(
25
26
  ({ children, checked, defaultChecked, onChange, onCheckedChange, className, style, ...rest }, propRef) => {
26
27
  const context = ActionList_context.useActionListContext();
27
28
  const item = react.useListItem();
28
- const ref = react.useMergeRefs([item.ref, propRef]);
29
- const [on, setOn] = index.useControllableState({
29
+ const ref = index.useMergeRefs([item.ref, propRef]);
30
+ const [on, setOn] = index$1.useControllableState({
30
31
  value: checked,
31
32
  defaultValue: defaultChecked ?? false,
32
33
  onChange: onCheckedChange
33
34
  });
34
- return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: index$1.classNames("roaster-action-list__item", className), style, children: [
35
+ return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: index$2.classNames("roaster-action-list__item", className), style, children: [
35
36
  children,
36
37
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "roaster-switch", children: [
37
38
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1 +1 @@
1
- {"version":3,"file":"ActionListSwitchItem.js","sources":["../../../../../src/components/ActionList/components/ActionListSwitchItem.tsx"],"sourcesContent":["import { useListItem, useMergeRefs } from '@floating-ui/react';\nimport * as React from 'react';\nimport { classNames, useControllableState } from '@/utils';\nimport { useActionListContext } from '../ActionList.context';\n\n/**\n * Every native `<input>` prop (`name`, `aria-*`, ...) is accepted and forwarded to the switch, with the ref.\n * `className` and `style` go to the item.\n */\nexport interface ActionListSwitchItemProps extends Omit<\n React.ComponentPropsWithoutRef<'input'>,\n 'type' | 'children' | 'role'\n> {\n /** The setting's name, with an optional icon before it. */\n children: React.ReactNode;\n /** Called with the new state when the user turns the setting on or off. */\n onCheckedChange?(checked: boolean): void;\n}\n\n/**\n * An on/off setting in the menu (`role=\"menuitemcheckbox\"`), drawn as a switch at the item's end, such as showing a\n * chart. Turning it on or off leaves the menu open.\n */\nexport const ActionListSwitchItem = React.forwardRef<HTMLInputElement, ActionListSwitchItemProps>(\n ({ children, checked, defaultChecked, onChange, onCheckedChange, className, style, ...rest }, propRef) => {\n const context = useActionListContext();\n const item = useListItem();\n const ref = useMergeRefs([item.ref, propRef]);\n const [on, setOn] = useControllableState({\n value: checked,\n defaultValue: defaultChecked ?? false,\n onChange: onCheckedChange,\n });\n\n return (\n <label className={classNames('roaster-action-list__item', className)} style={style}>\n {children}\n <span className=\"roaster-switch\">\n <input\n {...context.getItemProps({\n ...rest,\n onChange(event: React.ChangeEvent<HTMLInputElement>) {\n onChange?.(event);\n setOn(event.target.checked);\n },\n })}\n ref={ref}\n type=\"checkbox\"\n role=\"menuitemcheckbox\"\n checked={on}\n aria-checked={on}\n tabIndex={context.activeIndex === item.index ? 0 : -1}\n className=\"roaster-switch__input\"\n />\n <span className=\"roaster-switch__track\" />\n </span>\n </label>\n );\n }\n);\nActionListSwitchItem.displayName = 'ActionListSwitchItem';\n"],"names":["React","useActionListContext","useListItem","useMergeRefs","useControllableState","jsxs","classNames","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAMY,MAAC,oBAAoB,GAAGA,gBAAK,CAAC,UAAU;AACpD,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,OAAO,KAAK;AAC5G,IAAI,MAAM,OAAO,GAAGC,uCAAoB,EAAE;AAC1C,IAAI,MAAM,IAAI,GAAGC,iBAAW,EAAE;AAC9B,IAAI,MAAM,GAAG,GAAGC,kBAAY,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACjD,IAAI,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,GAAGC,0BAAoB,CAAC;AAC7C,MAAM,KAAK,EAAE,OAAO;AACpB,MAAM,YAAY,EAAE,cAAc,IAAI,KAAK;AAC3C,MAAM,QAAQ,EAAE;AAChB,KAAK,CAAC;AACN,IAAI,uBAAuBC,eAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAEC,kBAAU,CAAC,2BAA2B,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE;AAC3H,MAAM,QAAQ;AACd,sBAAsBD,eAAI,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE;AAC5E,wBAAwBE,cAAG;AAC3B,UAAU,OAAO;AACjB,UAAU;AACV,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AACpC,cAAc,GAAG,IAAI;AACrB,cAAc,QAAQ,CAAC,KAAK,EAAE;AAC9B,gBAAgB,QAAQ,GAAG,KAAK,CAAC;AACjC,gBAAgB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;AAC3C,cAAc;AACd,aAAa,CAAC;AACd,YAAY,GAAG;AACf,YAAY,IAAI,EAAE,UAAU;AAC5B,YAAY,IAAI,EAAE,kBAAkB;AACpC,YAAY,OAAO,EAAE,EAAE;AACvB,YAAY,cAAc,EAAE,EAAE;AAC9B,YAAY,QAAQ,EAAE,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,EAAE;AACjE,YAAY,SAAS,EAAE;AACvB;AACA,SAAS;AACT,wBAAwBA,cAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE;AAC1E,OAAO,EAAE;AACT,KAAK,EAAE,CAAC;AACR,EAAE;AACF;AACA,oBAAoB,CAAC,WAAW,GAAG,sBAAsB;;"}
1
+ {"version":3,"file":"ActionListSwitchItem.js","sources":["../../../../../src/components/ActionList/components/ActionListSwitchItem.tsx"],"sourcesContent":["import { useListItem } from '@floating-ui/react';\nimport * as React from 'react';\nimport { classNames, useControllableState, useMergeRefs } from '@/utils';\nimport { useActionListContext } from '../ActionList.context';\n\n/**\n * Every native `<input>` prop (`name`, `aria-*`, ...) is accepted and forwarded to the switch, with the ref.\n * `className` and `style` go to the item.\n */\nexport interface ActionListSwitchItemProps extends Omit<\n React.ComponentPropsWithoutRef<'input'>,\n 'type' | 'children' | 'role'\n> {\n /** The setting's name, with an optional icon before it. */\n children: React.ReactNode;\n /** Called with the new state when the user turns the setting on or off. */\n onCheckedChange?(checked: boolean): void;\n}\n\n/**\n * An on/off setting in the menu (`role=\"menuitemcheckbox\"`), drawn as a switch at the item's end, such as showing a\n * chart. Turning it on or off leaves the menu open.\n */\nexport const ActionListSwitchItem = React.forwardRef<HTMLInputElement, ActionListSwitchItemProps>(\n ({ children, checked, defaultChecked, onChange, onCheckedChange, className, style, ...rest }, propRef) => {\n const context = useActionListContext();\n const item = useListItem();\n const ref = useMergeRefs([item.ref, propRef]);\n const [on, setOn] = useControllableState({\n value: checked,\n defaultValue: defaultChecked ?? false,\n onChange: onCheckedChange,\n });\n\n return (\n <label className={classNames('roaster-action-list__item', className)} style={style}>\n {children}\n <span className=\"roaster-switch\">\n <input\n {...context.getItemProps({\n ...rest,\n onChange(event: React.ChangeEvent<HTMLInputElement>) {\n onChange?.(event);\n setOn(event.target.checked);\n },\n })}\n ref={ref}\n type=\"checkbox\"\n role=\"menuitemcheckbox\"\n checked={on}\n aria-checked={on}\n tabIndex={context.activeIndex === item.index ? 0 : -1}\n className=\"roaster-switch__input\"\n />\n <span className=\"roaster-switch__track\" />\n </span>\n </label>\n );\n }\n);\nActionListSwitchItem.displayName = 'ActionListSwitchItem';\n"],"names":["React","useActionListContext","useListItem","useMergeRefs","useControllableState","jsxs","classNames","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAMY,MAAC,oBAAoB,GAAGA,gBAAK,CAAC,UAAU;AACpD,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,OAAO,KAAK;AAC5G,IAAI,MAAM,OAAO,GAAGC,uCAAoB,EAAE;AAC1C,IAAI,MAAM,IAAI,GAAGC,iBAAW,EAAE;AAC9B,IAAI,MAAM,GAAG,GAAGC,kBAAY,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACjD,IAAI,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,GAAGC,4BAAoB,CAAC;AAC7C,MAAM,KAAK,EAAE,OAAO;AACpB,MAAM,YAAY,EAAE,cAAc,IAAI,KAAK;AAC3C,MAAM,QAAQ,EAAE;AAChB,KAAK,CAAC;AACN,IAAI,uBAAuBC,eAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAEC,kBAAU,CAAC,2BAA2B,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE;AAC3H,MAAM,QAAQ;AACd,sBAAsBD,eAAI,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE;AAC5E,wBAAwBE,cAAG;AAC3B,UAAU,OAAO;AACjB,UAAU;AACV,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AACpC,cAAc,GAAG,IAAI;AACrB,cAAc,QAAQ,CAAC,KAAK,EAAE;AAC9B,gBAAgB,QAAQ,GAAG,KAAK,CAAC;AACjC,gBAAgB,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;AAC3C,cAAc;AACd,aAAa,CAAC;AACd,YAAY,GAAG;AACf,YAAY,IAAI,EAAE,UAAU;AAC5B,YAAY,IAAI,EAAE,kBAAkB;AACpC,YAAY,OAAO,EAAE,EAAE;AACvB,YAAY,cAAc,EAAE,EAAE;AAC9B,YAAY,QAAQ,EAAE,OAAO,CAAC,WAAW,KAAK,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,EAAE;AACjE,YAAY,SAAS,EAAE;AACvB;AACA,SAAS;AACT,wBAAwBA,cAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE;AAC1E,OAAO,EAAE;AACT,KAAK,EAAE,CAAC;AACR,EAAE;AACF;AACA,oBAAoB,CAAC,WAAW,GAAG,sBAAsB;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AppFrame.js","sources":["../../../../src/components/AppFrame/AppFrame.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\n\n/** Every native `<div>` prop is accepted and forwarded to it. */\nexport type LayoutProps = React.ComponentPropsWithoutRef<'div'>;\n\n/** The page's layout wrapper: it holds the Sidebar (or a HeaderMenu) and the Mainframe. */\nexport const Layout = React.forwardRef<HTMLDivElement, LayoutProps>(({ className, ...others }, ref) => (\n <div {...others} ref={ref} className={classNames('roaster-layout', className)} />\n));\nLayout.displayName = 'Layout';\n\n/** Every native `<div>` prop is accepted and forwarded to it. */\nexport interface MainframeProps extends React.ComponentPropsWithoutRef<'div'> {\n /** The content: the Page, and a Visualizer beside it when `grid` is set. */\n children?: React.ReactNode;\n /** Alerts about the whole app, above the page, such as an outdated payment. */\n alerts?: React.ReactNode;\n /**\n * Makes room for a Visualizer beside the page.\n * @defaultValue false\n */\n grid?: boolean;\n}\n\n/** The frame beside the sidebar: app-wide alerts, then the page (and a Visualizer, with `grid`). */\nexport const Mainframe = React.forwardRef<HTMLDivElement, MainframeProps>(\n ({ children, alerts, grid = false, className, ...others }, ref) => (\n <div\n {...others}\n ref={ref}\n className={classNames('roaster-mainframe', { 'roaster-mainframe--grid': grid }, className)}\n >\n {alerts && <section className=\"roaster-mainframe__alerts\">{alerts}</section>}\n {children}\n </div>\n )\n);\nMainframe.displayName = 'Mainframe';\n\n/** Every native `<header>` prop is accepted and forwarded to it. */\nexport interface HeaderMenuProps extends React.ComponentPropsWithoutRef<'header'> {\n /** The bar's content: a way back (breadcrumbs), the logo, the account menu. */\n children?: React.ReactNode;\n}\n\n/** The sticky bar at the top of pages without a sidebar. */\nexport const HeaderMenu = React.forwardRef<HTMLElement, HeaderMenuProps>(({ className, ...others }, ref) => (\n <header {...others} ref={ref} className={classNames('roaster-header-menu', className)} />\n));\nHeaderMenu.displayName = 'HeaderMenu';\n\n/** Every native `<header>` prop is accepted and forwarded to it. */\nexport interface TopBarProps extends Omit<React.ComponentPropsWithoutRef<'header'>, 'title'> {\n /** The start of the bar, such as a search button (with `className=\"roaster-top-bar__search\"`), or a `Breadcrumbs`. */\n children?: React.ReactNode;\n /**\n * The page's name, on a page without a title of its own: an `<h1>`, with an optional icon before it, at the bar's\n * start, before `children`.\n */\n title?: React.ReactNode;\n /** The end of the bar: buttons, and the account, a `<button className=\"roaster-top-bar__account\">` with an `Avatar`. */\n actions?: React.ReactNode;\n}\n\n/** The bar at the top of the main frame, beside the sidebar: a search, then actions and the account. */\nexport const TopBar = React.forwardRef<HTMLElement, TopBarProps>(\n ({ className, children, title, actions, ...others }, ref) => (\n <header {...others} ref={ref} className={classNames('roaster-top-bar', className)}>\n {title != null && title !== false && <h1 className=\"roaster-top-bar__title\">{title}</h1>}\n {children}\n {actions && <div className=\"roaster-top-bar__actions\">{actions}</div>}\n </header>\n )\n);\nTopBar.displayName = 'TopBar';\n\n/** Every native `<footer>` prop is accepted and forwarded to it. */\nexport interface FooterProps extends React.ComponentPropsWithoutRef<'footer'> {\n /** The bar's content, such as the store's name in `<span className=\"roaster-footer__store\">`. */\n children?: React.ReactNode;\n}\n\n/** The fixed bar at the bottom of the page. */\nexport const Footer = React.forwardRef<HTMLElement, FooterProps>(({ className, ...others }, ref) => (\n <footer {...others} ref={ref} className={classNames('roaster-footer', className)} />\n));\nFooter.displayName = 'Footer';\n"],"names":["React","jsx","classNames","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;AAIY,MAAC,MAAM,GAAGA,gBAAK,CAAC,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,qBAAqBC,cAAG,CAAC,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,SAAS,EAAEC,gBAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAAE,CAAC;AAC5K,MAAM,CAAC,WAAW,GAAG,QAAQ;AACjB,MAAC,SAAS,GAAGF,gBAAK,CAAC,UAAU;AACzC,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,GAAG,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,qBAAqBG,eAAI;AACzF,IAAI,KAAK;AACT,IAAI;AACJ,MAAM,GAAG,MAAM;AACf,MAA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B,MAAC,MAAM,GAAGD,gBAAK,CAAC,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,qBAAqBC,cAAG,CAAC,QAAQ,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,SAAS,EAAEC,gBAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAAE,CAAC;AAC/K,MAAM,CAAC,WAAW,GAAG,QAAQ;;;;;;"}
1
+ {"version":3,"file":"AppFrame.js","sources":["../../../../src/components/AppFrame/AppFrame.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\n\n/** Every native `<div>` prop is accepted and forwarded to it. */\nexport type LayoutProps = React.ComponentPropsWithoutRef<'div'>;\n\n/** The page's layout wrapper: it holds the Sidebar (or a HeaderMenu) and the Mainframe. */\nexport const Layout = React.forwardRef<HTMLDivElement, LayoutProps>(({ className, ...others }, ref) => (\n <div {...others} ref={ref} className={classNames('roaster-layout', className)} />\n));\nLayout.displayName = 'Layout';\n\n/** Every native `<div>` prop is accepted and forwarded to it. */\nexport interface MainframeProps extends React.ComponentPropsWithoutRef<'div'> {\n /** The content: the Page, and a Visualizer beside it when `grid` is set. */\n children?: React.ReactNode;\n /** Alerts about the whole app, above the page, such as an outdated payment. */\n alerts?: React.ReactNode;\n /**\n * Makes room for a Visualizer beside the page.\n * @defaultValue false\n */\n grid?: boolean;\n}\n\n/** The frame beside the sidebar: app-wide alerts, then the page (and a Visualizer, with `grid`). */\nexport const Mainframe = React.forwardRef<HTMLDivElement, MainframeProps>(\n ({ children, alerts, grid = false, className, ...others }, ref) => (\n <div\n {...others}\n ref={ref}\n className={classNames('roaster-mainframe', { 'roaster-mainframe--grid': grid }, className)}\n >\n {alerts && <section className=\"roaster-mainframe__alerts\">{alerts}</section>}\n {children}\n </div>\n )\n);\nMainframe.displayName = 'Mainframe';\n\n/** Every native `<header>` prop is accepted and forwarded to it. */\nexport interface HeaderMenuProps extends React.ComponentPropsWithoutRef<'header'> {\n /**\n * The bar's content: a way back (breadcrumbs), the logo, the account menu. The account opens from a `Button` with a\n * small `Avatar`, the name and a chevron, or from the picture alone, as in the TopBar:\n * `<button className=\"roaster-top-bar__account\">` with an `Avatar`.\n */\n children?: React.ReactNode;\n}\n\n/** The sticky bar at the top of pages without a sidebar. */\nexport const HeaderMenu = React.forwardRef<HTMLElement, HeaderMenuProps>(({ className, ...others }, ref) => (\n <header {...others} ref={ref} className={classNames('roaster-header-menu', className)} />\n));\nHeaderMenu.displayName = 'HeaderMenu';\n\n/** Every native `<header>` prop is accepted and forwarded to it. */\nexport interface TopBarProps extends Omit<React.ComponentPropsWithoutRef<'header'>, 'title'> {\n /** The start of the bar, such as a search button (with `className=\"roaster-top-bar__search\"`), or a `Breadcrumbs`. */\n children?: React.ReactNode;\n /**\n * The page's name, on a page without a title of its own: an `<h1>`, with an optional icon before it, at the bar's\n * start, before `children`.\n */\n title?: React.ReactNode;\n /** The end of the bar: buttons, and the account, a `<button className=\"roaster-top-bar__account\">` with an `Avatar`. */\n actions?: React.ReactNode;\n}\n\n/** The bar at the top of the main frame, beside the sidebar: a search, then actions and the account. */\nexport const TopBar = React.forwardRef<HTMLElement, TopBarProps>(\n ({ className, children, title, actions, ...others }, ref) => (\n <header {...others} ref={ref} className={classNames('roaster-top-bar', className)}>\n {title != null && title !== false && <h1 className=\"roaster-top-bar__title\">{title}</h1>}\n {children}\n {actions && <div className=\"roaster-top-bar__actions\">{actions}</div>}\n </header>\n )\n);\nTopBar.displayName = 'TopBar';\n\n/** Every native `<footer>` prop is accepted and forwarded to it. */\nexport interface FooterProps extends React.ComponentPropsWithoutRef<'footer'> {\n /** The bar's content, such as the store's name in `<span className=\"roaster-footer__store\">`. */\n children?: React.ReactNode;\n}\n\n/** The fixed bar at the bottom of the page. */\nexport const Footer = React.forwardRef<HTMLElement, FooterProps>(({ className, ...others }, ref) => (\n <footer {...others} ref={ref} className={classNames('roaster-footer', className)} />\n));\nFooter.displayName = 'Footer';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,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,qBAAqBG,eAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,SAAS,EAAED,gBAAU,CAAC,iBAAiB,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE;AAC/K,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,oBAAoBD,cAAG,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,wBAAwB,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAC3H,IAAI,QAAQ;AACZ,IAAI,OAAO,oBAAoBA,cAAG,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,0BAA0B,EAAE,QAAQ,EAAE,OAAO,EAAE;AACtG,GAAG,EAAE;AACL;AACA,MAAM,CAAC,WAAW,GAAG,QAAQ;AACjB,MAAC,MAAM,GAAGD,gBAAK,CAAC,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,qBAAqBC,cAAG,CAAC,QAAQ,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,SAAS,EAAEC,gBAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAAE,CAAC;AAC/K,MAAM,CAAC,WAAW,GAAG,QAAQ;;;;;;"}
@@ -40,7 +40,7 @@ const Avatar = React__namespace.forwardRef(
40
40
  ),
41
41
  style: { ...typeof size === "number" && { width: size, height: size }, ...style },
42
42
  children: [
43
- icon ? icon : showFallback ? (initials ?? name.charAt(0)).toUpperCase() : /* @__PURE__ */ jsxRuntime.jsx("img", { src: src ?? void 0, alt: label, onError }),
43
+ icon ? icon : showFallback ? initials ?? name.charAt(0).toUpperCase() : /* @__PURE__ */ jsxRuntime.jsx("img", { src: src ?? void 0, alt: label, onError }),
44
44
  badge != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "roaster-avatar__badge", children: badge })
45
45
  ]
46
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Avatar.js","sources":["../../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useImageFallback } from '@/utils';\n\n/** Every native `<span>` prop (`id`, `aria-*`, `data-*`, ...) is accepted and forwarded to it. */\nexport interface AvatarProps extends React.ComponentPropsWithoutRef<'span'> {\n /** The URL of the picture. Without it, or when it fails to load, the avatar shows the initial of `name`. */\n src?: string | null;\n /**\n * What the avatar says to screen readers. `''` when the name is already written next to it.\n * @defaultValue `name`\n */\n alt?: string;\n /** The name of the person or store. */\n name: string;\n /** The width and height, in pixels, or `small` (28px, such as in a list's rows). */\n size?: number | 'small';\n /** The letters shown without a picture, such as two initials. The first letter of `name` by default. */\n initials?: string;\n /** Fills the initials in one of seven colors, so that neighbors differ, or in gray (`neutral`), for no one. */\n tint?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 'neutral';\n /** An icon in place of the picture and the initials, such as an arrow to a list's other items. */\n icon?: React.ReactNode;\n /** A small mark on the avatar's corner, such as an `Icon` for a linked account. */\n badge?: React.ReactNode;\n}\n\n/** A round picture of a person or a store, showing the initial of the name when there is no picture. */\nexport const Avatar = React.forwardRef<HTMLSpanElement, AvatarProps>(\n ({ src, alt, name, size, initials, tint, icon, badge, className, style, ...others }, ref) => {\n const { showFallback, onError } = useImageFallback(src);\n const label = alt ?? name;\n // The initial is a picture of the name: named like one, or hidden when it is decorative.\n const fallbackProps = label ? { role: 'img', 'aria-label': label } : { 'aria-hidden': true };\n\n return (\n <span\n {...(showFallback ? fallbackProps : {})}\n {...others}\n ref={ref}\n className={classNames(\n 'roaster-avatar',\n {\n [`roaster-avatar--${tint === 'neutral' ? 'neutral' : `tint-${tint}`}`]: tint !== undefined,\n 'roaster-avatar--small': size === 'small',\n },\n className\n )}\n style={{ ...(typeof size === 'number' && { width: size, height: size }), ...style }}\n >\n {icon ? (\n icon\n ) : showFallback ? (\n (initials ?? name.charAt(0)).toUpperCase()\n ) : (\n <img src={src ?? undefined} alt={label} onError={onError} />\n )}\n {badge != null && <span className=\"roaster-avatar__badge\">{badge}</span>}\n </span>\n );\n }\n);\n\nAvatar.displayName = 'Avatar';\n"],"names":["React","useImageFallback","jsxs","classNames","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIY,MAAC,MAAM,GAAGA,gBAAK,CAAC,UAAU;AACtC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,KAAK;AAC/F,IAAI,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,GAAGC,sBAAgB,CAAC,GAAG,CAAC;AAC3D,IAAI,MAAM,KAAK,GAAG,GAAG,IAAI,IAAI;AAC7B,IAAI,MAAM,aAAa,GAAG,KAAK,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE;AAChG,IAAI,uBAAuBC,eAAI;AAC/B,MAAM,MAAM;AACZ,MAAM;AACN,QAAQ,GAAG,YAAY,GAAG,aAAa,GAAG,EAAE;AAC5C,QAAQ,GAAG,MAAM;AACjB,QAAQ,GAAG;AACX,QAAQ,SAAS,EAAEC,kBAAU;AAC7B,UAAU,gBAAgB;AAC1B,UAAU;AACV,YAAY,CAAC,CAAC,gBAAgB,EAAE,IAAI,KAAK,SAAS,GAAG,SAAS,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,MAAM;AACnG,YAAY,uBAAuB,EAAE,IAAI,KAAK;AAC9C,WAAW;AACX,UAAU;AACV,SAAS;AACT,QAAQ,KAAK,EAAE,EAAE,GAAG,OAAO,IAAI,KAAK,QAAQ,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE;AACzF,QAAQ,QAAQ,EAAE;AAClB,UAAU,IAAI,GAAG,IAAI,GAAG,YAAY,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,mBAAmBC,cAAG,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC3J,UAAU,KAAK,IAAI,IAAI,oBAAoBA,cAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE,QAAQ,EAAE,KAAK,EAAE;AAC9G;AACA;AACA,KAAK;AACL,EAAE;AACF;AACA,MAAM,CAAC,WAAW,GAAG,QAAQ;;"}
1
+ {"version":3,"file":"Avatar.js","sources":["../../../../src/components/Avatar/Avatar.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useImageFallback } from '@/utils';\n\n/** Every native `<span>` prop (`id`, `aria-*`, `data-*`, ...) is accepted and forwarded to it. */\nexport interface AvatarProps extends React.ComponentPropsWithoutRef<'span'> {\n /** The URL of the picture. Without it, or when it fails to load, the avatar shows the initial of `name`. */\n src?: string | null;\n /**\n * What the avatar says to screen readers. `''` when the name is already written next to it.\n * @defaultValue `name`\n */\n alt?: string;\n /** The name of the person or store. */\n name: string;\n /** The width and height, in pixels, or `small` (28px, such as in a list's rows). */\n size?: number | 'small';\n /**\n * The letters shown without a picture, such as two initials, as written: a brand's lower-case \"k\" stays one. The first\n * letter of `name`, in capitals, by default.\n */\n initials?: string;\n /** Fills the initials in one of seven colors, so that neighbors differ, or in gray (`neutral`), for no one. */\n tint?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 'neutral';\n /** An icon in place of the picture and the initials, such as an arrow to a list's other items. */\n icon?: React.ReactNode;\n /** A small mark on the avatar's corner, such as an `Icon` for a linked account. */\n badge?: React.ReactNode;\n}\n\n/** A round picture of a person or a store, showing the initial of the name when there is no picture. */\nexport const Avatar = React.forwardRef<HTMLSpanElement, AvatarProps>(\n ({ src, alt, name, size, initials, tint, icon, badge, className, style, ...others }, ref) => {\n const { showFallback, onError } = useImageFallback(src);\n const label = alt ?? name;\n // The initial is a picture of the name: named like one, or hidden when it is decorative.\n const fallbackProps = label ? { role: 'img', 'aria-label': label } : { 'aria-hidden': true };\n\n return (\n <span\n {...(showFallback ? fallbackProps : {})}\n {...others}\n ref={ref}\n className={classNames(\n 'roaster-avatar',\n {\n [`roaster-avatar--${tint === 'neutral' ? 'neutral' : `tint-${tint}`}`]: tint !== undefined,\n 'roaster-avatar--small': size === 'small',\n },\n className\n )}\n style={{ ...(typeof size === 'number' && { width: size, height: size }), ...style }}\n >\n {icon ? (\n icon\n ) : showFallback ? (\n (initials ?? name.charAt(0).toUpperCase())\n ) : (\n <img src={src ?? undefined} alt={label} onError={onError} />\n )}\n {badge != null && <span className=\"roaster-avatar__badge\">{badge}</span>}\n </span>\n );\n }\n);\n\nAvatar.displayName = 'Avatar';\n"],"names":["React","useImageFallback","jsxs","classNames","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAIY,MAAC,MAAM,GAAGA,gBAAK,CAAC,UAAU;AACtC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,KAAK;AAC/F,IAAI,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,GAAGC,sBAAgB,CAAC,GAAG,CAAC;AAC3D,IAAI,MAAM,KAAK,GAAG,GAAG,IAAI,IAAI;AAC7B,IAAI,MAAM,aAAa,GAAG,KAAK,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE;AAChG,IAAI,uBAAuBC,eAAI;AAC/B,MAAM,MAAM;AACZ,MAAM;AACN,QAAQ,GAAG,YAAY,GAAG,aAAa,GAAG,EAAE;AAC5C,QAAQ,GAAG,MAAM;AACjB,QAAQ,GAAG;AACX,QAAQ,SAAS,EAAEC,kBAAU;AAC7B,UAAU,gBAAgB;AAC1B,UAAU;AACV,YAAY,CAAC,CAAC,gBAAgB,EAAE,IAAI,KAAK,SAAS,GAAG,SAAS,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,MAAM;AACnG,YAAY,uBAAuB,EAAE,IAAI,KAAK;AAC9C,WAAW;AACX,UAAU;AACV,SAAS;AACT,QAAQ,KAAK,EAAE,EAAE,GAAG,OAAO,IAAI,KAAK,QAAQ,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE;AACzF,QAAQ,QAAQ,EAAE;AAClB,UAAU,IAAI,GAAG,IAAI,GAAG,YAAY,GAAG,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,mBAAmBC,cAAG,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACzJ,UAAU,KAAK,IAAI,IAAI,oBAAoBA,cAAG,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,uBAAuB,EAAE,QAAQ,EAAE,KAAK,EAAE;AAC9G;AACA;AACA,KAAK;AACL,EAAE;AACF;AACA,MAAM,CAAC,WAAW,GAAG,QAAQ;;"}
@@ -3,13 +3,13 @@
3
3
 
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var React = require('react');
6
- var react = require('@floating-ui/react');
7
6
  var CheckboxGroup = require('./CheckboxGroup/CheckboxGroup.js');
8
7
  var CheckboxGroup_context = require('./CheckboxGroup/CheckboxGroup.context.js');
9
8
  var ChoiceText = require('./ChoiceText.js');
10
9
  var index = require('../../utils/useUid/index.js');
11
10
  var index$1 = require('../../utils/useControllableState/index.js');
12
- var index$2 = require('../../utils/classNames/index.js');
11
+ var index$2 = require('../../utils/useMergeRefs/index.js');
12
+ var index$3 = require('../../utils/classNames/index.js');
13
13
 
14
14
  function _interopNamespaceDefault(e) {
15
15
  var n = Object.create(null);
@@ -50,7 +50,7 @@ const CheckboxBase = React__namespace.forwardRef((props, ref) => {
50
50
  onChange: onCheckedChange
51
51
  });
52
52
  const inputRef = React__namespace.useRef(null);
53
- const mergedRef = react.useMergeRefs([inputRef, ref]);
53
+ const mergedRef = index$2.useMergeRefs([inputRef, ref]);
54
54
  const nested = React__namespace.useMemo(() => children != null ? ChoiceText.leafValues(children) : [], [children]);
55
55
  const parent = ctx != null && nested.length > 0;
56
56
  const nestedChecked = parent ? nested.filter((item) => ctx.value.includes(item)).length : 0;
@@ -70,7 +70,7 @@ const CheckboxBase = React__namespace.forwardRef((props, ref) => {
70
70
  const choice = /* @__PURE__ */ jsxRuntime.jsxs(
71
71
  "label",
72
72
  {
73
- className: index$2.classNames("roaster-choice", { "roaster-choice--card": variant === "card" }, className),
73
+ className: index$3.classNames("roaster-choice", { "roaster-choice--card": variant === "card" }, className),
74
74
  style,
75
75
  children: [
76
76
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.js","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useMergeRefs } from '@floating-ui/react';\nimport { classNames, useControllableState, useUid } from '@/utils';\nimport { CheckboxGroup } from './CheckboxGroup/CheckboxGroup';\nimport { useCheckboxGroupContext } from './CheckboxGroup/CheckboxGroup.context';\nimport { ChoiceText, leafValues } from './ChoiceText';\n\n/**\n * Every native `<input>` prop (`name`, `required`, `onChange`, `aria-*`, ...) is accepted and forwarded to the\n * checkbox, with the ref. `className` and `style` go to its label.\n */\nexport interface CheckboxProps extends Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'value'> {\n /** The value submitted with the form when checked, and the value a `Checkbox.Group` holds. */\n value: string;\n /** The text next to the box. */\n label?: React.ReactNode;\n /** A line under the label, such as what the choice means. */\n description?: React.ReactNode;\n /** A short text at the end of the row, such as the kind of a name (\"Recipient\"). */\n detail?: React.ReactNode;\n /**\n * The checkboxes under this one, in a `Checkbox.Group`: checking it checks them all, and it is checked when they\n * all are, mixed when some are. Their values stand for its own.\n */\n children?: React.ReactNode;\n /** `card` draws the checkbox as a bordered card, highlighted while checked. */\n variant?: 'default' | 'card';\n /** The mixed state: some of the items this checkbox stands for are checked, not all. */\n indeterminate?: boolean;\n /** Called with the new checked state when the user toggles the checkbox. */\n onCheckedChange?(checked: boolean): void;\n}\n\nconst CheckboxBase = React.forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {\n const {\n id,\n label,\n description,\n detail,\n children,\n value,\n variant = 'default',\n indeterminate = false,\n checked,\n defaultChecked,\n onChange,\n onCheckedChange,\n className,\n style,\n ...others\n } = props;\n const ctx = useCheckboxGroupContext();\n const uid = useUid(id);\n // On its own, the checkbox follows `checked`, or keeps its own state from `defaultChecked`.\n const [ownChecked, setOwnChecked] = useControllableState({\n value: checked,\n defaultValue: defaultChecked ?? false,\n onChange: onCheckedChange,\n });\n // `indeterminate` is a DOM property, not an attribute.\n const inputRef = React.useRef<HTMLInputElement>(null);\n const mergedRef = useMergeRefs([inputRef, ref]);\n\n // With checkboxes under it, in a group, it stands for them.\n const nested = React.useMemo(() => (children != null ? leafValues(children) : []), [children]);\n const parent = ctx != null && nested.length > 0;\n const nestedChecked = parent ? nested.filter((item) => ctx.value.includes(item)).length : 0;\n const isIndeterminate = parent ? nestedChecked > 0 && nestedChecked < nested.length : indeterminate;\n React.useEffect(() => {\n if (inputRef.current) inputRef.current.indeterminate = isIndeterminate;\n }, [isIndeterminate]);\n\n const isChecked = parent ? nestedChecked === nested.length : ctx ? ctx.value.includes(value) : ownChecked;\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n if (parent) {\n const others = ctx.value.filter((item) => !nested.includes(item));\n ctx.setValue(event.target.checked ? [...others, ...nested] : others);\n } else if (ctx) ctx.onChange(event);\n else setOwnChecked(event.target.checked);\n };\n\n const choice = (\n <label\n className={classNames('roaster-choice', { 'roaster-choice--card': variant === 'card' }, className)}\n style={style}\n >\n <input\n {...others}\n ref={mergedRef}\n id={uid}\n type=\"checkbox\"\n value={value}\n checked={isChecked}\n onChange={handleChange}\n className=\"roaster-choice__input\"\n />\n <span className=\"roaster-choice__box\" />\n <ChoiceText label={label} description={description} detail={detail} labelId={`${uid}-label`} />\n </label>\n );\n if (children == null) return choice;\n return (\n <>\n {choice}\n <div className=\"roaster-choice-group roaster-choice-group--nested\" role=\"group\" aria-labelledby={`${uid}-label`}>\n {children}\n </div>\n </>\n );\n});\n\nCheckboxBase.displayName = 'Checkbox';\n\n/**\n * A checkbox with a label. Use Checkbox.Group to manage several values together, and `variant=\"card\"` for a\n * card-style option.\n */\nexport const Checkbox = Object.assign(CheckboxBase, { Group: CheckboxGroup });\n"],"names":["React","useCheckboxGroupContext","useUid","useControllableState","useMergeRefs","leafValues","jsxs","classNames","jsx","ChoiceText","Fragment","CheckboxGroup"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,YAAY,GAAGA,gBAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACtD,EAAE,MAAM;AACR,IAAI,EAAE;AACN,IAAI,KAAK;AACT,IAAI,WAAW;AACf,IAAI,MAAM;AACV,IAAI,QAAQ;AACZ,IAAI,KAAK;AACT,IAAI,OAAO,GAAG,SAAS;AACvB,IAAI,aAAa,GAAG,KAAK;AACzB,IAAI,OAAO;AACX,IAAI,cAAc;AAClB,IAAI,QAAQ;AACZ,IAAI,eAAe;AACnB,IAAI,SAAS;AACb,IAAI,KAAK;AACT,IAAI,GAAG;AACP,GAAG,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BAAU,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE;AAC/F;AACA;AACA,GAAG;AACH,EAAE,IAAI,QAAQ,IAAI,IAAI,EAAE,OAAO,MAAM;AACrC,EAAE,uBAAuBH,eAAI,CAACI,mBAAQ,EAAE,EAAE,QAAQ,EAAE;AACpD,IAAI,MAAM;AACV,oBAAoBF,cAAG,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,mDAAmD,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE;AAC7J,GAAG,EAAE,CAAC;AACN,CAAC,CAAC;AACF,YAAY,CAAC,WAAW,GAAG,UAAU;AACzB,MAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,KAAK,EAAEG,2BAAa,EAAE;;"}
1
+ {"version":3,"file":"Checkbox.js","sources":["../../../../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames, useControllableState, useMergeRefs, useUid } from '@/utils';\nimport { CheckboxGroup } from './CheckboxGroup/CheckboxGroup';\nimport { useCheckboxGroupContext } from './CheckboxGroup/CheckboxGroup.context';\nimport { ChoiceText, leafValues } from './ChoiceText';\n\n/**\n * Every native `<input>` prop (`name`, `required`, `onChange`, `aria-*`, ...) is accepted and forwarded to the\n * checkbox, with the ref. `className` and `style` go to its label.\n */\nexport interface CheckboxProps extends Omit<React.ComponentPropsWithoutRef<'input'>, 'type' | 'value'> {\n /** The value submitted with the form when checked, and the value a `Checkbox.Group` holds. */\n value: string;\n /** The text next to the box. */\n label?: React.ReactNode;\n /** A line under the label, such as what the choice means. */\n description?: React.ReactNode;\n /** A short text at the end of the row, such as the kind of a name (\"Recipient\"). */\n detail?: React.ReactNode;\n /**\n * The checkboxes under this one, in a `Checkbox.Group`: checking it checks them all, and it is checked when they\n * all are, mixed when some are. Their values stand for its own.\n */\n children?: React.ReactNode;\n /** `card` draws the checkbox as a bordered card, highlighted while checked. */\n variant?: 'default' | 'card';\n /** The mixed state: some of the items this checkbox stands for are checked, not all. */\n indeterminate?: boolean;\n /** Called with the new checked state when the user toggles the checkbox. */\n onCheckedChange?(checked: boolean): void;\n}\n\nconst CheckboxBase = React.forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {\n const {\n id,\n label,\n description,\n detail,\n children,\n value,\n variant = 'default',\n indeterminate = false,\n checked,\n defaultChecked,\n onChange,\n onCheckedChange,\n className,\n style,\n ...others\n } = props;\n const ctx = useCheckboxGroupContext();\n const uid = useUid(id);\n // On its own, the checkbox follows `checked`, or keeps its own state from `defaultChecked`.\n const [ownChecked, setOwnChecked] = useControllableState({\n value: checked,\n defaultValue: defaultChecked ?? false,\n onChange: onCheckedChange,\n });\n // `indeterminate` is a DOM property, not an attribute.\n const inputRef = React.useRef<HTMLInputElement>(null);\n const mergedRef = useMergeRefs([inputRef, ref]);\n\n // With checkboxes under it, in a group, it stands for them.\n const nested = React.useMemo(() => (children != null ? leafValues(children) : []), [children]);\n const parent = ctx != null && nested.length > 0;\n const nestedChecked = parent ? nested.filter((item) => ctx.value.includes(item)).length : 0;\n const isIndeterminate = parent ? nestedChecked > 0 && nestedChecked < nested.length : indeterminate;\n React.useEffect(() => {\n if (inputRef.current) inputRef.current.indeterminate = isIndeterminate;\n }, [isIndeterminate]);\n\n const isChecked = parent ? nestedChecked === nested.length : ctx ? ctx.value.includes(value) : ownChecked;\n const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n if (parent) {\n const others = ctx.value.filter((item) => !nested.includes(item));\n ctx.setValue(event.target.checked ? [...others, ...nested] : others);\n } else if (ctx) ctx.onChange(event);\n else setOwnChecked(event.target.checked);\n };\n\n const choice = (\n <label\n className={classNames('roaster-choice', { 'roaster-choice--card': variant === 'card' }, className)}\n style={style}\n >\n <input\n {...others}\n ref={mergedRef}\n id={uid}\n type=\"checkbox\"\n value={value}\n checked={isChecked}\n onChange={handleChange}\n className=\"roaster-choice__input\"\n />\n <span className=\"roaster-choice__box\" />\n <ChoiceText label={label} description={description} detail={detail} labelId={`${uid}-label`} />\n </label>\n );\n if (children == null) return choice;\n return (\n <>\n {choice}\n <div className=\"roaster-choice-group roaster-choice-group--nested\" role=\"group\" aria-labelledby={`${uid}-label`}>\n {children}\n </div>\n </>\n );\n});\n\nCheckboxBase.displayName = 'Checkbox';\n\n/**\n * A checkbox with a label. Use Checkbox.Group to manage several values together, and `variant=\"card\"` for a\n * card-style option.\n */\nexport const Checkbox = Object.assign(CheckboxBase, { Group: CheckboxGroup });\n"],"names":["React","useCheckboxGroupContext","useUid","useControllableState","useMergeRefs","leafValues","jsxs","classNames","jsx","ChoiceText","Fragment","CheckboxGroup"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,YAAY,GAAGA,gBAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACtD,EAAE,MAAM;AACR,IAAI,EAAE;AACN,IAAI,KAAK;AACT,IAAI,WAAW;AACf,IAAI,MAAM;AACV,IAAI,QAAQ;AACZ,IAAI,KAAK;AACT,IAAI,OAAO,GAAG,SAAS;AACvB,IAAI,aAAa,GAAG,KAAK;AACzB,IAAI,OAAO;AACX,IAAI,cAAc;AAClB,IAAI,QAAQ;AACZ,IAAI,eAAe;AACnB,IAAI,SAAS;AACb,IAAI,KAAK;AACT,IAAI,GAAG;AACP,GAAG,GAAG,KAAK;AACX,EAAE,MAAM,GAAG,GAAGC,6CAAuB,EAAE;AACvC,EAAE,MAAM,GAAG,GAAGC,YAAM,CAAC,EAAE,CAAC;AACxB,EAAE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAGC,4BAAoB,CAAC;AAC3D,IAAI,KAAK,EAAE,OAAO;AAClB,IAAI,YAAY,EAAE,cAAc,IAAI,KAAK;AACzC,IAAI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AAM;AACV,oBAAoBF,cAAG,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,mDAAmD,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE;AAC7J,GAAG,EAAE,CAAC;AACN,CAAC,CAAC;AACF,YAAY,CAAC,WAAW,GAAG,UAAU;AACzB,MAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,KAAK,EAAEG,2BAAa,EAAE;;"}
@@ -32,6 +32,7 @@ const ColorField = React__namespace.forwardRef((props, ref) => {
32
32
  name,
33
33
  disabled,
34
34
  description,
35
+ keepDescription,
35
36
  error,
36
37
  className,
37
38
  style,
@@ -65,35 +66,47 @@ const ColorField = React__namespace.forwardRef((props, ref) => {
65
66
  const color = toFullHex(typed);
66
67
  if (color) setInternalValue(color);
67
68
  };
68
- return /* @__PURE__ */ jsxRuntime.jsx(Field.Field, { controlId: uid, label, description, error, className, style, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "roaster-merged-inputs", children: [
69
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "roaster-color-swatch roaster-merged-inputs__start", children: [
70
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "roaster-color-swatch__preview", style: { backgroundColor: internalValue } }),
71
- /* @__PURE__ */ jsxRuntime.jsx(
72
- "input",
73
- {
74
- ...others,
75
- ...Field.fieldControlProps(uid, { description, error }, others),
76
- ref,
77
- type: "color",
78
- className: "roaster-color-swatch__input",
79
- name,
80
- disabled,
81
- onChange: handleChange,
82
- value: internalValue
83
- }
84
- )
85
- ] }),
86
- /* @__PURE__ */ jsxRuntime.jsx(
87
- "input",
88
- {
89
- type: "text",
90
- className: "roaster-input roaster-merged-inputs__end",
91
- "aria-label": text.hex,
92
- value: shownHex,
93
- onChange: handleHexChange
94
- }
95
- )
96
- ] }) });
69
+ return /* @__PURE__ */ jsxRuntime.jsx(
70
+ Field.Field,
71
+ {
72
+ controlId: uid,
73
+ label,
74
+ description,
75
+ keepDescription,
76
+ error,
77
+ className,
78
+ style,
79
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "roaster-merged-inputs", children: [
80
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "roaster-color-swatch roaster-merged-inputs__start", children: [
81
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "roaster-color-swatch__preview", style: { backgroundColor: internalValue } }),
82
+ /* @__PURE__ */ jsxRuntime.jsx(
83
+ "input",
84
+ {
85
+ ...others,
86
+ ...Field.fieldControlProps(uid, { description, error, keepDescription }, others),
87
+ ref,
88
+ type: "color",
89
+ className: "roaster-color-swatch__input",
90
+ name,
91
+ disabled,
92
+ onChange: handleChange,
93
+ value: internalValue
94
+ }
95
+ )
96
+ ] }),
97
+ /* @__PURE__ */ jsxRuntime.jsx(
98
+ "input",
99
+ {
100
+ type: "text",
101
+ className: "roaster-input roaster-merged-inputs__end",
102
+ "aria-label": text.hex,
103
+ value: shownHex,
104
+ onChange: handleHexChange
105
+ }
106
+ )
107
+ ] })
108
+ }
109
+ );
97
110
  });
98
111
  ColorField.displayName = "ColorField";
99
112