@trellixio/roaster-react 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +383 -0
- package/LICENSE.md +38 -2
- package/README.md +10 -10
- package/cjs/components/ActionList/components/ActionListDropdown.js +6 -5
- package/cjs/components/ActionList/components/ActionListDropdown.js.map +1 -1
- package/cjs/components/ActionList/components/ActionListItem.js +9 -7
- package/cjs/components/ActionList/components/ActionListItem.js.map +1 -1
- package/cjs/components/ActionList/components/ActionListSearch.js +24 -6
- package/cjs/components/ActionList/components/ActionListSearch.js.map +1 -1
- package/cjs/components/ActionList/components/ActionListSubmenu.js +7 -5
- package/cjs/components/ActionList/components/ActionListSubmenu.js.map +1 -1
- package/cjs/components/ActionList/components/ActionListSwitchItem.js +6 -5
- package/cjs/components/ActionList/components/ActionListSwitchItem.js.map +1 -1
- package/cjs/components/Alert/Alert.js +3 -2
- package/cjs/components/Alert/Alert.js.map +1 -1
- package/cjs/components/AppFrame/AppFrame.js.map +1 -1
- package/cjs/components/Avatar/Avatar.js +1 -1
- package/cjs/components/Avatar/Avatar.js.map +1 -1
- package/cjs/components/Button/Button.js +3 -2
- package/cjs/components/Button/Button.js.map +1 -1
- package/cjs/components/ButtonIcon/ButtonIcon.js.map +1 -1
- package/cjs/components/Checkbox/Checkbox.js +4 -4
- package/cjs/components/Checkbox/Checkbox.js.map +1 -1
- package/cjs/components/ColorField/ColorField.js +42 -29
- package/cjs/components/ColorField/ColorField.js.map +1 -1
- package/cjs/components/DatePicker/DatePicker.js +2 -2
- package/cjs/components/DatePicker/DatePicker.js.map +1 -1
- package/cjs/components/DatePicker/components/Calendar/Calendar.js +4 -3
- package/cjs/components/DatePicker/components/Calendar/Calendar.js.map +1 -1
- package/cjs/components/DropdownCard/components/DropdownCardDropdown.js +6 -5
- package/cjs/components/DropdownCard/components/DropdownCardDropdown.js.map +1 -1
- package/cjs/components/DropdownCard/components/DropdownCardTabs.js +3 -2
- package/cjs/components/DropdownCard/components/DropdownCardTabs.js.map +1 -1
- package/cjs/components/Field/Field.js +26 -6
- package/cjs/components/Field/Field.js.map +1 -1
- package/cjs/components/FileField/FileField.js +47 -33
- package/cjs/components/FileField/FileField.js.map +1 -1
- package/cjs/components/Icon/Icon.js.map +1 -1
- package/cjs/components/Icon/RoasterIcon.js +12 -0
- package/cjs/components/Icon/RoasterIcon.js.map +1 -0
- package/cjs/components/IconBadge/IconBadge.js.map +1 -1
- package/cjs/components/Modal/Modal.js +3 -2
- package/cjs/components/Modal/Modal.js.map +1 -1
- package/cjs/components/Pagination/Pagination.js +4 -3
- package/cjs/components/Pagination/Pagination.js.map +1 -1
- package/cjs/components/RangeField/RangeField.js +34 -21
- package/cjs/components/RangeField/RangeField.js.map +1 -1
- package/cjs/components/Select/Select.js +8 -6
- package/cjs/components/Select/Select.js.map +1 -1
- package/cjs/components/Sidebar/Sidebar.js +4 -3
- package/cjs/components/Sidebar/Sidebar.js.map +1 -1
- package/cjs/components/Sidebar/components/Back.js +7 -3
- package/cjs/components/Sidebar/components/Back.js.map +1 -1
- package/cjs/components/StatCard/StatCard.js +3 -2
- package/cjs/components/StatCard/StatCard.js.map +1 -1
- package/cjs/components/Switch/Switch.js +7 -1
- package/cjs/components/Switch/Switch.js.map +1 -1
- package/cjs/components/Table/components/TableHeadCell.js +4 -3
- package/cjs/components/Table/components/TableHeadCell.js.map +1 -1
- package/cjs/components/Tag/Tag.js +3 -2
- package/cjs/components/Tag/Tag.js.map +1 -1
- package/cjs/components/TextField/TextField.js +3 -1
- package/cjs/components/TextField/TextField.js.map +1 -1
- package/cjs/components/Textarea/Textarea.js +36 -4
- package/cjs/components/Textarea/Textarea.js.map +1 -1
- package/cjs/components/Thumbnail/Thumbnail.js +3 -2
- package/cjs/components/Thumbnail/Thumbnail.js.map +1 -1
- package/cjs/components/Toast/Toast.js +3 -2
- package/cjs/components/Toast/Toast.js.map +1 -1
- package/cjs/components/Tooltip/Tooltip.js +6 -5
- package/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/cjs/components/Tooltip/TooltipCallout.js +3 -2
- package/cjs/components/Tooltip/TooltipCallout.js.map +1 -1
- package/cjs/components/Visualizer/Visualizer.js +4 -3
- package/cjs/components/Visualizer/Visualizer.js.map +1 -1
- package/cjs/utils/Slot/index.js +5 -5
- package/cjs/utils/Slot/index.js.map +1 -1
- package/cjs/utils/useDropdown/DropdownTrigger.js +4 -4
- package/cjs/utils/useDropdown/DropdownTrigger.js.map +1 -1
- package/cjs/utils/useMergeRefs/index.js +51 -0
- package/cjs/utils/useMergeRefs/index.js.map +1 -0
- package/esm/components/ActionList/components/ActionListDropdown.js +2 -1
- package/esm/components/ActionList/components/ActionListDropdown.js.map +1 -1
- package/esm/components/ActionList/components/ActionListItem.js +5 -3
- package/esm/components/ActionList/components/ActionListItem.js.map +1 -1
- package/esm/components/ActionList/components/ActionListSearch.js +21 -3
- package/esm/components/ActionList/components/ActionListSearch.js.map +1 -1
- package/esm/components/ActionList/components/ActionListSubmenu.js +5 -3
- package/esm/components/ActionList/components/ActionListSubmenu.js.map +1 -1
- package/esm/components/ActionList/components/ActionListSwitchItem.js +2 -1
- package/esm/components/ActionList/components/ActionListSwitchItem.js.map +1 -1
- package/esm/components/Alert/Alert.js +3 -2
- package/esm/components/Alert/Alert.js.map +1 -1
- package/esm/components/AppFrame/AppFrame.js.map +1 -1
- package/esm/components/Avatar/Avatar.js +1 -1
- package/esm/components/Avatar/Avatar.js.map +1 -1
- package/esm/components/Button/Button.js +3 -2
- package/esm/components/Button/Button.js.map +1 -1
- package/esm/components/ButtonIcon/ButtonIcon.js.map +1 -1
- package/esm/components/Checkbox/Checkbox.js +1 -1
- package/esm/components/Checkbox/Checkbox.js.map +1 -1
- package/esm/components/ColorField/ColorField.js +42 -29
- package/esm/components/ColorField/ColorField.js.map +1 -1
- package/esm/components/DatePicker/DatePicker.js +1 -1
- package/esm/components/DatePicker/DatePicker.js.map +1 -1
- package/esm/components/DatePicker/components/Calendar/Calendar.js +4 -3
- package/esm/components/DatePicker/components/Calendar/Calendar.js.map +1 -1
- package/esm/components/DropdownCard/components/DropdownCardDropdown.js +2 -1
- package/esm/components/DropdownCard/components/DropdownCardDropdown.js.map +1 -1
- package/esm/components/DropdownCard/components/DropdownCardTabs.js +3 -2
- package/esm/components/DropdownCard/components/DropdownCardTabs.js.map +1 -1
- package/esm/components/Field/Field.js +26 -6
- package/esm/components/Field/Field.js.map +1 -1
- package/esm/components/FileField/FileField.js +47 -33
- package/esm/components/FileField/FileField.js.map +1 -1
- package/esm/components/Icon/Icon.js.map +1 -1
- package/esm/components/Icon/RoasterIcon.js +10 -0
- package/esm/components/Icon/RoasterIcon.js.map +1 -0
- package/esm/components/IconBadge/IconBadge.js.map +1 -1
- package/esm/components/Modal/Modal.js +3 -2
- package/esm/components/Modal/Modal.js.map +1 -1
- package/esm/components/Pagination/Pagination.js +4 -3
- package/esm/components/Pagination/Pagination.js.map +1 -1
- package/esm/components/RangeField/RangeField.js +34 -21
- package/esm/components/RangeField/RangeField.js.map +1 -1
- package/esm/components/Select/Select.js +4 -2
- package/esm/components/Select/Select.js.map +1 -1
- package/esm/components/Sidebar/Sidebar.js +4 -3
- package/esm/components/Sidebar/Sidebar.js.map +1 -1
- package/esm/components/Sidebar/components/Back.js +7 -3
- package/esm/components/Sidebar/components/Back.js.map +1 -1
- package/esm/components/StatCard/StatCard.js +3 -2
- package/esm/components/StatCard/StatCard.js.map +1 -1
- package/esm/components/Switch/Switch.js +7 -1
- package/esm/components/Switch/Switch.js.map +1 -1
- package/esm/components/Table/components/TableHeadCell.js +4 -3
- package/esm/components/Table/components/TableHeadCell.js.map +1 -1
- package/esm/components/Tag/Tag.js +3 -2
- package/esm/components/Tag/Tag.js.map +1 -1
- package/esm/components/TextField/TextField.js +3 -1
- package/esm/components/TextField/TextField.js.map +1 -1
- package/esm/components/Textarea/Textarea.js +38 -6
- package/esm/components/Textarea/Textarea.js.map +1 -1
- package/esm/components/Thumbnail/Thumbnail.js +3 -2
- package/esm/components/Thumbnail/Thumbnail.js.map +1 -1
- package/esm/components/Toast/Toast.js +3 -2
- package/esm/components/Toast/Toast.js.map +1 -1
- package/esm/components/Tooltip/Tooltip.js +2 -1
- package/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/esm/components/Tooltip/TooltipCallout.js +3 -2
- package/esm/components/Tooltip/TooltipCallout.js.map +1 -1
- package/esm/components/Visualizer/Visualizer.js +4 -3
- package/esm/components/Visualizer/Visualizer.js.map +1 -1
- package/esm/package.json +4 -1
- package/esm/utils/Slot/index.js +1 -1
- package/esm/utils/Slot/index.js.map +1 -1
- package/esm/utils/useDropdown/DropdownTrigger.js +1 -1
- package/esm/utils/useDropdown/DropdownTrigger.js.map +1 -1
- package/esm/utils/useMergeRefs/index.js +36 -0
- package/esm/utils/useMergeRefs/index.js.map +1 -0
- package/lib/components/ActionList/components/ActionListItem.d.ts +4 -1
- package/lib/components/ActionList/components/ActionListItem.d.ts.map +1 -1
- package/lib/components/ActionList/components/ActionListSearch.d.ts.map +1 -1
- package/lib/components/ActionList/components/ActionListSubmenu.d.ts.map +1 -1
- package/lib/components/AppFrame/AppFrame.d.ts +5 -1
- package/lib/components/AppFrame/AppFrame.d.ts.map +1 -1
- package/lib/components/Avatar/Avatar.d.ts +4 -1
- package/lib/components/Avatar/Avatar.d.ts.map +1 -1
- package/lib/components/ButtonIcon/ButtonIcon.d.ts +1 -1
- package/lib/components/ButtonIcon/ButtonIcon.d.ts.map +1 -1
- package/lib/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/components/ColorField/ColorField.d.ts.map +1 -1
- package/lib/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/lib/components/DatePicker/utils/index.d.ts +2 -1
- package/lib/components/DatePicker/utils/index.d.ts.map +1 -1
- package/lib/components/Field/Field.d.ts +13 -7
- package/lib/components/Field/Field.d.ts.map +1 -1
- package/lib/components/FileField/FileField.d.ts.map +1 -1
- package/lib/components/Icon/Icon.d.ts +13 -2
- package/lib/components/Icon/Icon.d.ts.map +1 -1
- package/lib/components/Icon/RoasterIcon.d.ts +13 -0
- package/lib/components/Icon/RoasterIcon.d.ts.map +1 -0
- package/lib/components/Icon/index.d.ts +2 -0
- package/lib/components/Icon/index.d.ts.map +1 -1
- package/lib/components/IconBadge/IconBadge.d.ts +2 -2
- package/lib/components/RangeField/RangeField.d.ts.map +1 -1
- package/lib/components/Select/Select.d.ts.map +1 -1
- package/lib/components/Sidebar/components/Back.d.ts.map +1 -1
- package/lib/components/Switch/Switch.d.ts.map +1 -1
- package/lib/components/TextField/TextField.d.ts.map +1 -1
- package/lib/components/Textarea/Textarea.d.ts +6 -1
- package/lib/components/Textarea/Textarea.d.ts.map +1 -1
- package/lib/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/lib/utils/Slot/index.d.ts.map +1 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/useDropdown/DropdownTrigger.d.ts.map +1 -1
- package/lib/utils/useMergeRefs/index.d.ts +11 -0
- package/lib/utils/useMergeRefs/index.d.ts.map +1 -0
- package/package.json +2 -2
- package/roaster.css +2 -1
- package/themes/azoth.css +1 -1
- package/themes/coffee.css +1 -1
- package/themes/scalar.css +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionListItem.js","sources":["../../../../../src/components/ActionList/components/ActionListItem.tsx"],"sourcesContent":["import { useListItem
|
|
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 { RoasterIcon } 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><i className=\"fa-regular fa-arrow-up-right-from-square\" aria-hidden=\"true\" />`.\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 && (\n <RoasterIcon name=\"check\" className=\"roaster-action-list__check roaster-action-list__check--end\" />\n )}\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","RoasterIcon"],"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,uBAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,4DAA4D,EAAE,CAAC;AACnJ,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/
|
|
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 =
|
|
27
|
+
const ref = index.useMergeRefs([inputRef, propRef]);
|
|
28
28
|
React__namespace.useEffect(() => {
|
|
29
|
-
|
|
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(() =>
|
|
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 '
|
|
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,G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AAC,SAAS,CAAC,CAAC;AACnB,IAAI,uBAAuBG,eAAI,CAAC,KAAK,EAAE,EAAE,SAAS,EAAEC,kBAAU,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;;"}
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var react = require('@floating-ui/react');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
|
|
7
|
+
require('../../Icon/Icon.js');
|
|
8
|
+
var RoasterIcon = require('../../Icon/RoasterIcon.js');
|
|
8
9
|
var ActionList_context = require('../ActionList.context.js');
|
|
9
10
|
var index = require('../../../utils/useDropdown/index.js');
|
|
10
|
-
var index$1 = require('../../../utils/
|
|
11
|
+
var index$1 = require('../../../utils/useMergeRefs/index.js');
|
|
12
|
+
var index$2 = require('../../../utils/classNames/index.js');
|
|
11
13
|
|
|
12
14
|
function _interopNamespaceDefault(e) {
|
|
13
15
|
var n = Object.create(null);
|
|
@@ -78,7 +80,7 @@ const ActionListSubmenu = React__namespace.forwardRef(
|
|
|
78
80
|
}),
|
|
79
81
|
[data, interactions, open, activeIndex, parentSetOpen]
|
|
80
82
|
);
|
|
81
|
-
const triggerRef =
|
|
83
|
+
const triggerRef = index$1.useMergeRefs([item.ref, data.refs.setReference, propRef]);
|
|
82
84
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
83
85
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
84
86
|
"button",
|
|
@@ -89,11 +91,11 @@ const ActionListSubmenu = React__namespace.forwardRef(
|
|
|
89
91
|
role: "menuitem",
|
|
90
92
|
"aria-haspopup": "menu",
|
|
91
93
|
tabIndex: parent.activeIndex === item.index ? 0 : -1,
|
|
92
|
-
className: index$
|
|
94
|
+
className: index$2.classNames("roaster-action-list__item", className),
|
|
93
95
|
children: [
|
|
94
96
|
label,
|
|
95
97
|
detail != null && detail !== false && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "roaster-action-list__detail", children: detail }),
|
|
96
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
98
|
+
/* @__PURE__ */ jsxRuntime.jsx(RoasterIcon.RoasterIcon, { name: "chevron-right" })
|
|
97
99
|
]
|
|
98
100
|
}
|
|
99
101
|
),
|
|
@@ -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
|
|
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 { RoasterIcon } 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 <RoasterIcon 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","RoasterIcon","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;AACt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AAE,EAAE,IAAI,EAAE,eAAe,EAAE;AACtE;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;;"}
|
|
@@ -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/
|
|
9
|
-
var index$1 = require('../../../utils/
|
|
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 =
|
|
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$
|
|
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
|
|
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,I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C;AACR,EAAE;AACF;AACA,oBAAoB,CAAC,WAAW,GAAG,sBAAsB;;"}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var ButtonIcon = require('../ButtonIcon/ButtonIcon.js');
|
|
7
|
-
|
|
7
|
+
require('../Icon/Icon.js');
|
|
8
|
+
var RoasterIcon = require('../Icon/RoasterIcon.js');
|
|
8
9
|
var index = require('../../utils/classNames/index.js');
|
|
9
10
|
|
|
10
11
|
function _interopNamespaceDefault(e) {
|
|
@@ -34,7 +35,7 @@ const Alert = React__namespace.forwardRef((props, ref) => {
|
|
|
34
35
|
children: [
|
|
35
36
|
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "roaster-alert__icon", children: icon }),
|
|
36
37
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "roaster-alert__content", children }),
|
|
37
|
-
closable && /* @__PURE__ */ jsxRuntime.jsx(ButtonIcon.ButtonIcon, { className: "roaster-alert__close", "aria-label": text.close, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
38
|
+
closable && /* @__PURE__ */ jsxRuntime.jsx(ButtonIcon.ButtonIcon, { className: "roaster-alert__close", "aria-label": text.close, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(RoasterIcon.RoasterIcon, { name: "x" }) })
|
|
38
39
|
]
|
|
39
40
|
}
|
|
40
41
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","sources":["../../../../src/components/Alert/Alert.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\nimport { ButtonIcon } from '../ButtonIcon';\nimport {
|
|
1
|
+
{"version":3,"file":"Alert.js","sources":["../../../../src/components/Alert/Alert.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\nimport { ButtonIcon } from '../ButtonIcon';\nimport { RoasterIcon } from '@/components/Icon';\n\n/** The tones of an alert: its color, icon, and how urgently screen readers announce it. */\nexport type AlertTone = 'info' | 'success' | 'warning' | 'danger' | 'primary';\n\n/** The text of the alert, for other languages. */\nexport interface AlertLabels {\n /** The name of the close button, read by screen readers. */\n close: string;\n}\n\nconst defaultAlertLabels: AlertLabels = { close: 'Close' };\n\n/** Every native `<div>` prop (`id`, `aria-*`, `data-*`, ...) is accepted and forwarded to it. */\nexport interface AlertProps extends React.ComponentPropsWithoutRef<'div'> {\n /** The message: text, links, or blocks such as a list. */\n children: React.ReactNode;\n /**\n * The tone. `danger` and `warning` are announced at once (`role=\"alert\"`), `info`, `success` and `primary`\n * politely (`role=\"status\"`). `primary` is a prompt that asks for a decision, with its buttons in the message.\n * @defaultValue 'info'\n */\n tone?: AlertTone;\n /** An icon in place of the tone's, such as an `Icon`. */\n icon?: React.ReactNode;\n /** Shows a close button, which calls `onClose`. */\n closable?: boolean;\n /** Called when the close button is clicked. */\n onClose?(): void;\n /** The text of the alert, in English by default. */\n labels?: Partial<AlertLabels>;\n}\n\n/** A message banner in a tone (info, success, warning, danger, or primary for a prompt), with an optional close button. */\nexport const Alert = React.forwardRef<HTMLDivElement, AlertProps>((props, ref) => {\n const { children, closable = false, tone = 'info', icon, onClose, labels, className, ...others } = props;\n const text = { ...defaultAlertLabels, ...labels };\n\n return (\n <div\n role={tone === 'danger' || tone === 'warning' ? 'alert' : 'status'}\n {...others}\n ref={ref}\n className={classNames('roaster-alert', `roaster-alert--${tone}`, className)}\n >\n {icon && <span className=\"roaster-alert__icon\">{icon}</span>}\n <div className=\"roaster-alert__content\">{children}</div>\n {closable && (\n <ButtonIcon className=\"roaster-alert__close\" aria-label={text.close} onClick={onClose}>\n <RoasterIcon name=\"x\" />\n </ButtonIcon>\n )}\n </div>\n );\n});\n\nAlert.displayName = 'Alert';\n"],"names":["React","jsxs","classNames","jsx","ButtonIcon","RoasterIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM,kBAAkB,GAAG,EAAE,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","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
|
|
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';\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,MAAM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,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 ?
|
|
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
|
|
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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AQ,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,7 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var React = require('react');
|
|
6
|
-
|
|
6
|
+
require('../Icon/Icon.js');
|
|
7
|
+
var RoasterIcon = require('../Icon/RoasterIcon.js');
|
|
7
8
|
var index = require('../../utils/classNames/index.js');
|
|
8
9
|
var index$1 = require('../../utils/Slot/index.js');
|
|
9
10
|
|
|
@@ -62,7 +63,7 @@ const Button = React__namespace.forwardRef((props, ref) => {
|
|
|
62
63
|
}
|
|
63
64
|
return /* @__PURE__ */ jsxRuntime.jsxs("button", { ...others, ...loadingProps, ref, type, className: classes, onClick: handleClick, children: [
|
|
64
65
|
children,
|
|
65
|
-
caret && /* @__PURE__ */ jsxRuntime.jsx(
|
|
66
|
+
caret && /* @__PURE__ */ jsxRuntime.jsx(RoasterIcon.RoasterIcon, { name: "chevron-down", className: "roaster-button__caret" })
|
|
66
67
|
] });
|
|
67
68
|
});
|
|
68
69
|
Button.displayName = "Button";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../../../../src/components/Button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { RoasterIcon } from '../Icon';\nimport { classNames, Slot } from '@/utils';\n\n/** Every native `<button>` prop (`type`, `name`, `aria-*`, ...) is accepted and forwarded to it. */\nexport interface ButtonProps extends React.ComponentPropsWithoutRef<'button'> {\n /** The button's content: its text, and an `Icon` if any. */\n children: React.ReactNode;\n /**\n * The look of the button:\n * - `primary`: filled, for the main action\n * - `secondary`: for other actions: outlined in coffee, filled in Azoth\n * - `plain`: a link-like text button\n * - `ghost`: no background or border, such as an icon in a toolbar\n * - `chip`: a filter or a toggle, such as the filters above a table; `aria-pressed` turns it on. It looks like\n * `secondary` in the coffee theme\n * @defaultValue 'primary'\n */\n variant?: 'primary' | 'secondary' | 'plain' | 'ghost' | 'chip';\n /**\n * A status color: `success` for positive actions, `danger` for destructive ones. `neutral`, for a `plain` button: a\n * quiet action in the text's secondary color, such as one under a form.\n */\n tone?: 'success' | 'danger' | 'neutral';\n /**\n * `large` for the buttons of full-page flows and a few prominent calls to action. Buttons in a modal's footer and in\n * `FormActions` are large without it. `small` for smaller text, such as a quiet action under a field. The sizes look\n * the same in the coffee theme.\n * @defaultValue 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n /** A square button holding only an icon. Name it with `aria-label`. */\n iconOnly?: boolean;\n /** A chevron after the text, for a button that opens a menu, such as a filter chip. Not with `asChild`. */\n caret?: boolean;\n /** Takes the whole width of its container. */\n fullWidth?: boolean;\n /** Its label lines up with the text before it, its padding hanging out of its place, such as a period picker. */\n flush?: boolean;\n /**\n * A value in a column of rows, such as a property in a page's side column: its icon nearer the start, its text cut\n * short with an ellipsis when it doesn't fit.\n */\n row?: boolean;\n /** Shows a spinner in place of the content, and ignores clicks, while an action runs. */\n loading?: boolean;\n /**\n * Render the element your child is, such as a link (`<Button asChild><a href=\"/new\">New</a></Button>`), with the\n * button's look.\n */\n asChild?: boolean;\n}\n\n/**\n * A button in the primary, secondary, plain, ghost or chip style, optionally in the success, danger or (plain) neutral\n * tone, and in the small, medium or large size. It is\n * `type=\"button\"` unless you say otherwise, so it never submits a form by accident.\n */\nexport const Button = React.forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {\n const {\n children,\n variant = 'primary',\n tone,\n size = 'medium',\n iconOnly,\n caret,\n fullWidth,\n flush,\n row,\n loading,\n asChild,\n className,\n onClick,\n type = 'button',\n ...others\n } = props;\n\n const classes = classNames(\n 'roaster-button',\n `roaster-button--${variant}`,\n tone && `roaster-button--${tone}`,\n {\n 'roaster-button--small': size === 'small',\n 'roaster-button--large': size === 'large',\n 'roaster-button--icon-only': iconOnly,\n 'roaster-button--full-width': fullWidth,\n 'roaster-button--flush': flush,\n 'roaster-button--row': row,\n },\n className\n );\n const loadingProps = loading ? { 'aria-busy': true, 'aria-disabled': true } : {};\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n // A loading button stays focusable, so a click can still reach it from the keyboard.\n if (loading) event.preventDefault();\n else onClick?.(event);\n };\n\n if (asChild) {\n return (\n <Slot {...others} {...loadingProps} ref={ref as React.Ref<HTMLElement>} className={classes} onClick={handleClick}>\n {children}\n </Slot>\n );\n }\n return (\n <button {...others} {...loadingProps} ref={ref} type={type} className={classes} onClick={handleClick}>\n {children}\n {caret && <RoasterIcon name=\"chevron-down\" className=\"roaster-button__caret\" />}\n </button>\n );\n});\n\nButton.displayName = 'Button';\n"],"names":["React","classNames","jsx","Slot","jsxs","RoasterIcon"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAKY,MAAC,MAAM,GAAGA,gBAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AACvD,EAAE,MAAM;AACR,IAAI,QAAQ;AACZ,IAAI,OAAO,GAAG,SAAS;AACvB,IAAI,IAAI;AACR,IAAI,IAAI,GAAG,QAAQ;AACnB,IAAI,QAAQ;AACZ,IAAI,KAAK;AACT,IAAI,SAAS;AACb,IAAI,KAAK;AACT,IAAI,GAAG;AACP,IAAI,OAAO;AACX,IAAI,OAAO;AACX,IAAI,SAAS;AACb,IAAI,OAAO;AACX,IAAI,IAAI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Ac,EAAE,SAAS,EAAE,uBAAuB,EAAE;AAC1G,GAAG,EAAE,CAAC;AACN,CAAC;AACD,MAAM,CAAC,WAAW,GAAG,QAAQ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonIcon.js","sources":["../../../../src/components/ButtonIcon/ButtonIcon.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\n\ninterface ButtonIconBaseProps extends Omit<React.ComponentPropsWithoutRef<'button'>, 'aria-label' | 'aria-labelledby'> {\n /** The icon, such as `<
|
|
1
|
+
{"version":3,"file":"ButtonIcon.js","sources":["../../../../src/components/ButtonIcon/ButtonIcon.tsx"],"sourcesContent":["import * as React from 'react';\nimport { classNames } from '@/utils';\n\ninterface ButtonIconBaseProps extends Omit<React.ComponentPropsWithoutRef<'button'>, 'aria-label' | 'aria-labelledby'> {\n /** The icon, such as Roaster's cross: `<i className=\"roaster-icon roaster-icon--x\" aria-hidden=\"true\" />`. */\n children: React.ReactNode;\n /**\n * The size of the icon: `small` (alerts, toasts, tags) or `medium` (modals).\n * @defaultValue 'small'\n */\n size?: 'small' | 'medium';\n}\n\n/**\n * A small icon-only button, such as the close button of an alert, a tag or a modal. It has no text, so it needs a\n * name: `aria-label`, or `aria-labelledby` pointing at text on the page. Every native `<button>` prop is accepted.\n */\nexport type ButtonIconProps = ButtonIconBaseProps &\n ({ 'aria-label': string; 'aria-labelledby'?: string } | { 'aria-label'?: string; 'aria-labelledby': string });\n\n/** A small icon-only button, such as the close button of an alert, a tag or a modal. Name it with `aria-label`. */\nexport const ButtonIcon = React.forwardRef<HTMLButtonElement, ButtonIconProps>((props, ref) => {\n const { children, size = 'small', className, type = 'button', ...others } = props;\n\n return (\n <button\n {...others}\n ref={ref}\n type={type}\n className={classNames('roaster-icon-button', { 'roaster-icon-button--medium': size === 'medium' }, className)}\n >\n {children}\n </button>\n );\n});\n\nButtonIcon.displayName = 'ButtonIcon';\n"],"names":["React","jsx","classNames"],"mappings":";;;;;;;;;;;;;;;;;;;;AAIY,MAAC,UAAU,GAAGA,gBAAK,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AAC3D,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,OAAO,EAAE,SAAS,EAAE,IAAI,GAAG,QAAQ,EAAE,GAAG,MAAM,EAAE,GAAG,KAAK;AACnF,EAAE,uBAAuBC,cAAG;AAC5B,IAAI,QAAQ;AACZ,IAAI;AACJ,MAAM,GAAG,MAAM;AACf,MAAM,GAAG;AACT,MAAM,IAAI;AACV,MAAM,SAAS,EAAEC,gBAAU,CAAC,qBAAqB,EAAE,EAAE,6BAA6B,EAAE,IAAI,KAAK,QAAQ,EAAE,EAAE,SAAS,CAAC;AACnH,MAAM;AACN;AACA,GAAG;AACH,CAAC;AACD,UAAU,CAAC,WAAW,GAAG,YAAY;;"}
|
|
@@ -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/
|
|
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 =
|
|
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$
|
|
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 {
|
|
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,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