@activecollab/components 2.0.470 → 2.0.471
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/DatePicker/DatePicker.js +4 -2
- package/dist/cjs/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/cjs/components/GlobalStyle.js +1 -1
- package/dist/cjs/components/GlobalStyle.js.map +1 -1
- package/dist/cjs/components/Menu/Menu.js +66 -13
- package/dist/cjs/components/Menu/Menu.js.map +1 -1
- package/dist/cjs/components/PillButton/PillButton.js +75 -0
- package/dist/cjs/components/PillButton/PillButton.js.map +1 -0
- package/dist/cjs/components/PillButton/Styles.js +59 -0
- package/dist/cjs/components/PillButton/Styles.js.map +1 -0
- package/dist/cjs/components/PillButton/index.js +17 -0
- package/dist/cjs/components/PillButton/index.js.map +1 -0
- package/dist/cjs/components/PillGroup/PillGroup.js +42 -0
- package/dist/cjs/components/PillGroup/PillGroup.js.map +1 -0
- package/dist/cjs/components/PillGroup/Styles.js +21 -0
- package/dist/cjs/components/PillGroup/Styles.js.map +1 -0
- package/dist/cjs/components/PillGroup/index.js +17 -0
- package/dist/cjs/components/PillGroup/index.js.map +1 -0
- package/dist/cjs/components/Select/Select.js +5 -3
- package/dist/cjs/components/Select/Select.js.map +1 -1
- package/dist/cjs/components/SelectDate/SelectDate.js +4 -2
- package/dist/cjs/components/SelectDate/SelectDate.js.map +1 -1
- package/dist/cjs/components/Tooltip/Tooltip.js +37 -8
- package/dist/cjs/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/cjs/components/Window/Window.js +4 -2
- package/dist/cjs/components/Window/Window.js.map +1 -1
- package/dist/cjs/components/index.js +22 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/helpers/Portal/Portal.js +5 -1
- package/dist/cjs/helpers/Portal/Portal.js.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.d.ts +2 -0
- package/dist/esm/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js +4 -2
- package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/components/GlobalStyle.d.ts.map +1 -1
- package/dist/esm/components/GlobalStyle.js +1 -1
- package/dist/esm/components/GlobalStyle.js.map +1 -1
- package/dist/esm/components/Menu/Menu.d.ts +2 -0
- package/dist/esm/components/Menu/Menu.d.ts.map +1 -1
- package/dist/esm/components/Menu/Menu.js +64 -13
- package/dist/esm/components/Menu/Menu.js.map +1 -1
- package/dist/esm/components/PillButton/PillButton.d.ts +33 -0
- package/dist/esm/components/PillButton/PillButton.d.ts.map +1 -0
- package/dist/esm/components/PillButton/PillButton.js +66 -0
- package/dist/esm/components/PillButton/PillButton.js.map +1 -0
- package/dist/esm/components/PillButton/Styles.d.ts +15 -0
- package/dist/esm/components/PillButton/Styles.d.ts.map +1 -0
- package/dist/esm/components/PillButton/Styles.js +34 -0
- package/dist/esm/components/PillButton/Styles.js.map +1 -0
- package/dist/esm/components/PillButton/index.d.ts +2 -0
- package/dist/esm/components/PillButton/index.d.ts.map +1 -0
- package/dist/esm/components/PillButton/index.js +2 -0
- package/dist/esm/components/PillButton/index.js.map +1 -0
- package/dist/esm/components/PillGroup/PillGroup.d.ts +19 -0
- package/dist/esm/components/PillGroup/PillGroup.d.ts.map +1 -0
- package/dist/esm/components/PillGroup/PillGroup.js +33 -0
- package/dist/esm/components/PillGroup/PillGroup.js.map +1 -0
- package/dist/esm/components/PillGroup/Styles.d.ts +5 -0
- package/dist/esm/components/PillGroup/Styles.d.ts.map +1 -0
- package/dist/esm/components/PillGroup/Styles.js +10 -0
- package/dist/esm/components/PillGroup/Styles.js.map +1 -0
- package/dist/esm/components/PillGroup/index.d.ts +2 -0
- package/dist/esm/components/PillGroup/index.d.ts.map +1 -0
- package/dist/esm/components/PillGroup/index.js +2 -0
- package/dist/esm/components/PillGroup/index.js.map +1 -0
- package/dist/esm/components/Select/Select.d.ts +2 -0
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +5 -3
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/SelectDate/SelectDate.d.ts +2 -0
- package/dist/esm/components/SelectDate/SelectDate.d.ts.map +1 -1
- package/dist/esm/components/SelectDate/SelectDate.js +4 -2
- package/dist/esm/components/SelectDate/SelectDate.js.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js +36 -9
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/components/Window/Window.d.ts +2 -0
- package/dist/esm/components/Window/Window.d.ts.map +1 -1
- package/dist/esm/components/Window/Window.js +4 -2
- package/dist/esm/components/Window/Window.js.map +1 -1
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +2 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/helpers/Portal/Portal.d.ts.map +1 -1
- package/dist/esm/helpers/Portal/Portal.js +5 -1
- package/dist/esm/helpers/Portal/Portal.js.map +1 -1
- package/dist/index.js +1096 -850
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../../../src/components/Menu/Menu.tsx"],"names":[],"mappings":"AAAA,OAAc,EAEZ,EAAE,EACF,SAAS,EACT,UAAU,
|
|
1
|
+
{"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../../../src/components/Menu/Menu.tsx"],"names":[],"mappings":"AAAA,OAAc,EAEZ,EAAE,EACF,SAAS,EACT,UAAU,EAOV,YAAY,EACZ,GAAG,EACJ,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAW3C,UAAU,cAAc,CAAC,CAAC,CAAE,SAAQ,YAAY;IAC9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C;IACjC,iHAAiH;IACjH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAyGD,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,KAAK,CA6R1B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useState, useCallback, useEffect, useMemo } from "react";
|
|
1
|
+
import React, { useRef, useState, useCallback, useEffect, useLayoutEffect, useMemo } from "react";
|
|
2
2
|
import classnames from "classnames";
|
|
3
3
|
import { MenuContextProvider } from "./context";
|
|
4
4
|
import { StyledMenu } from "./Styles";
|
|
@@ -63,11 +63,25 @@ const offsetToVisibleBox = node => ({
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
+
const TABBABLE = 'a[href], button, input, select, textarea, iframe, [tabindex], [contenteditable="true"]';
|
|
66
67
|
|
|
67
68
|
// A menu opened with the pointer hands the focus back without a focus ring, so its trigger does not stay lit.
|
|
68
69
|
const returnFocusOptions = visible => ({
|
|
69
70
|
focusVisible: visible
|
|
70
71
|
});
|
|
72
|
+
|
|
73
|
+
// Moves the focus where a Tab or Shift+Tab on the trigger would go. The closing menu itself does not count.
|
|
74
|
+
const focusTabNeighbor = (trigger, step, menu) => {
|
|
75
|
+
const nodes = Array.from(document.querySelectorAll(TABBABLE)).filter(node => node === trigger || node.tabIndex >= 0 && !node.disabled && !node.closest("[inert]") && !(menu != null && menu.contains(node)));
|
|
76
|
+
const from = nodes.indexOf(trigger);
|
|
77
|
+
for (let index = from + step; from !== -1 && index >= 0 && index < nodes.length; index += step) {
|
|
78
|
+
nodes[index].focus(returnFocusOptions(true));
|
|
79
|
+
if (document.activeElement === nodes[index]) {
|
|
80
|
+
return nodes[index];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
};
|
|
71
85
|
export const Menu = _ref2 => {
|
|
72
86
|
let children = _ref2.children,
|
|
73
87
|
_ref2$disableFocusLoc = _ref2.disableFocusLock,
|
|
@@ -91,16 +105,16 @@ export const Menu = _ref2 => {
|
|
|
91
105
|
backgroundElementClass = _ref2.backgroundElementClass,
|
|
92
106
|
_ref2$windowAbsolutel = _ref2.windowAbsolutelyPositioned,
|
|
93
107
|
windowAbsolutelyPositioned = _ref2$windowAbsolutel === void 0 ? false : _ref2$windowAbsolutel,
|
|
94
|
-
onPopperOpen = _ref2.onPopperOpen
|
|
108
|
+
onPopperOpen = _ref2.onPopperOpen,
|
|
109
|
+
_ref2$closeOnTab = _ref2.closeOnTab,
|
|
110
|
+
closeOnTab = _ref2$closeOnTab === void 0 ? false : _ref2$closeOnTab;
|
|
95
111
|
const _useState = useState(defaultOpen),
|
|
96
112
|
open = _useState[0],
|
|
97
113
|
setOpen = _useState[1];
|
|
98
114
|
const _useState2 = useState(!defaultOpen),
|
|
99
115
|
exited = _useState2[0],
|
|
100
116
|
setExited = _useState2[1];
|
|
101
|
-
|
|
102
|
-
childNode = _useState3[0],
|
|
103
|
-
setChildNode = _useState3[1];
|
|
117
|
+
// The trigger node lives in a ref. In state it would render every menu of a list again right after it mounts.
|
|
104
118
|
const elementRef = useRef(null);
|
|
105
119
|
const isOpenAtLeastOnce = useRef(false);
|
|
106
120
|
const wasOpen = useRef(open);
|
|
@@ -108,6 +122,8 @@ export const Menu = _ref2 => {
|
|
|
108
122
|
const focusWasVisible = useRef(false);
|
|
109
123
|
const returnFocusTo = useRef(null);
|
|
110
124
|
const popperRef = useRef(null);
|
|
125
|
+
const windowRef = useRef(null);
|
|
126
|
+
const tabOut = useRef(0);
|
|
111
127
|
|
|
112
128
|
// Read on the render that opens the menu, before the focus lock moves the focus inside it.
|
|
113
129
|
if (open && !wasOpen.current && typeof document !== "undefined") {
|
|
@@ -124,7 +140,8 @@ export const Menu = _ref2 => {
|
|
|
124
140
|
}
|
|
125
141
|
}, [open]);
|
|
126
142
|
|
|
127
|
-
// Set on the node itself, so the trigger gets it also through a wrapper such as Tooltip.
|
|
143
|
+
// Set on the node itself, so the trigger gets it also through a wrapper such as Tooltip. It runs after every
|
|
144
|
+
// render, because the trigger node lives in a ref and a new node brings no render of its own.
|
|
128
145
|
const expandedTrigger = useRef(null);
|
|
129
146
|
const checkedTrigger = useRef(null);
|
|
130
147
|
const triggerOwnsExpanded = useRef(false);
|
|
@@ -153,9 +170,19 @@ export const Menu = _ref2 => {
|
|
|
153
170
|
expandedTrigger.current.removeAttribute("aria-expanded");
|
|
154
171
|
expandedTrigger.current = null;
|
|
155
172
|
}
|
|
156
|
-
}
|
|
157
|
-
const
|
|
158
|
-
|
|
173
|
+
});
|
|
174
|
+
const handleRef = useForkRef(target ? target.ref : undefined, elementRef);
|
|
175
|
+
|
|
176
|
+
// The popper needs the node as state, so it is copied only while the menu shows, before the browser paints.
|
|
177
|
+
const _useState3 = useState(null),
|
|
178
|
+
childNode = _useState3[0],
|
|
179
|
+
setChildNode = _useState3[1];
|
|
180
|
+
useLayoutEffect(() => {
|
|
181
|
+
const node = open || !exited ? elementRef.current : null;
|
|
182
|
+
if (node !== childNode) {
|
|
183
|
+
setChildNode(node);
|
|
184
|
+
}
|
|
185
|
+
}, [open, exited, childNode]);
|
|
159
186
|
const popperModifiers = useMemo(() => childNode instanceof HTMLElement ? [offsetToVisibleBox(childNode)] : undefined, [childNode]);
|
|
160
187
|
const handleOpen = useCallback(event => {
|
|
161
188
|
var _target$props;
|
|
@@ -167,11 +194,22 @@ export const Menu = _ref2 => {
|
|
|
167
194
|
}, [onOpen, target == null ? void 0 : target.props]);
|
|
168
195
|
const handleClose = useCallback(() => {
|
|
169
196
|
if (typeof onBeforeClose === "function" && !onBeforeClose()) {
|
|
170
|
-
return;
|
|
197
|
+
return false;
|
|
171
198
|
}
|
|
172
199
|
setOpen(false);
|
|
173
200
|
typeof onClose === "function" && onClose();
|
|
201
|
+
return true;
|
|
174
202
|
}, [onClose, onBeforeClose]);
|
|
203
|
+
const handleTabOut = useCallback(event => {
|
|
204
|
+
if (event.key !== "Tab" || event.defaultPrevented) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
event.preventDefault();
|
|
208
|
+
tabOut.current = event.shiftKey ? -1 : 1;
|
|
209
|
+
if (!handleClose()) {
|
|
210
|
+
tabOut.current = 0;
|
|
211
|
+
}
|
|
212
|
+
}, [handleClose]);
|
|
175
213
|
const childProps = {
|
|
176
214
|
forceClose: handleClose
|
|
177
215
|
};
|
|
@@ -185,9 +223,16 @@ export const Menu = _ref2 => {
|
|
|
185
223
|
isOpenAtLeastOnce.current = true;
|
|
186
224
|
} else if (!open && isOpenAtLeastOnce.current) {
|
|
187
225
|
const previous = focusBeforeOpen.current;
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
226
|
+
const step = tabOut.current;
|
|
227
|
+
const tabbedTo = step && elementRef.current ? focusTabNeighbor(triggerOf(elementRef.current), step, windowRef.current) : null;
|
|
228
|
+
tabOut.current = 0;
|
|
229
|
+
if (tabbedTo) {
|
|
230
|
+
returnFocusTo.current = tabbedTo;
|
|
231
|
+
} else {
|
|
232
|
+
const returnTo = previous instanceof HTMLElement && previous.isConnected ? previous : elementRef.current;
|
|
233
|
+
returnFocusTo.current = returnTo;
|
|
234
|
+
returnTo == null || returnTo.focus(returnFocusOptions(focusWasVisible.current));
|
|
235
|
+
}
|
|
191
236
|
isOpenAtLeastOnce.current = false;
|
|
192
237
|
}
|
|
193
238
|
}, [open]);
|
|
@@ -209,7 +254,13 @@ export const Menu = _ref2 => {
|
|
|
209
254
|
return () => document.removeEventListener("focusin", keepFocusOut, true);
|
|
210
255
|
}, [open, exited]);
|
|
211
256
|
return /*#__PURE__*/React.createElement(React.Fragment, null, target && /*#__PURE__*/React.cloneElement(target, targetProps), open || !exited ? /*#__PURE__*/React.createElement(Window, {
|
|
257
|
+
ref: windowRef,
|
|
212
258
|
onClose: handleClose,
|
|
259
|
+
onKeyDown: closeOnTab && open ? handleTabOut : undefined
|
|
260
|
+
// The lock returns the focus with the props of the render before it turns off, too late to skip a Tab.
|
|
261
|
+
// The menu returns the focus itself, so a menu that closes on Tab leaves the lock out of it.
|
|
262
|
+
,
|
|
263
|
+
disableReturnFocus: closeOnTab,
|
|
213
264
|
disableScrollLock: !handleScroll
|
|
214
265
|
// The menu returns the focus itself at once, so a late returnFocus cannot undo a caller's move.
|
|
215
266
|
,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.js","names":["React","useRef","useState","useCallback","useEffect","useMemo","classnames","MenuContextProvider","StyledMenu","useForkRef","Overlay","Popper","Grow","Window","isFocusVisible","element","Boolean","matches","_unused","TRIGGER","triggerOf","node","_node$querySelector","querySelector","visibleBoxOf","rects","Array","from","children","map","getBoundingClientRect","left","Math","min","rect","right","max","top","bottom","offsetToVisibleBox","name","options","offset","_ref","placement","wrapper","box","_placement$split","split","side","align","vertical","start","end","skidding","distance","returnFocusOptions","visible","focusVisible","Menu","_ref2","_ref2$disableFocusLoc","disableFocusLock","onMenuClick","_ref2$handleScroll","handleScroll","_ref2$mode","mode","_ref2$open","open","defaultOpen","onOpen","onClose","onBeforeClose","_ref2$position","position","target","className","menuClassName","popperClassName","backgroundElementClass","_ref2$windowAbsolutel","windowAbsolutelyPositioned","onPopperOpen","_useState","setOpen","_useState2","exited","setExited","_useState3","childNode","setChildNode","elementRef","isOpenAtLeastOnce","wasOpen","focusBeforeOpen","focusWasVisible","returnFocusTo","popperRef","current","document","activeElement","expandedTrigger","checkedTrigger","triggerOwnsExpanded","trigger","hasAttribute","setAttribute","removeAttribute","handleRefRef","ref","undefined","handleRef","popperModifiers","HTMLElement","handleOpen","event","_target$props","preventDefault","stopPropagation","props","onClick","handleClose","childProps","forceClose","targetProps","previous","returnTo","isConnected","focus","keepFocusOut","_popperRef$current","contains","_returnFocusTo$curren","addEventListener","removeEventListener","createElement","Fragment","cloneElement","disableScrollLock","disableCloseOnEsc","style","tabIndex","disableBackgroundColor","anchorEl","afterWrite","modifiers","transition","_ref3","transitionProps","in","onEnter","onExited","$mode","onMouseDown","pointerEvents","value","displayName"],"sources":["../../../../src/components/Menu/Menu.tsx"],"sourcesContent":["import React, {\n useRef,\n FC,\n ReactNode,\n MouseEvent,\n useState,\n useCallback,\n useEffect,\n useMemo,\n ReactElement,\n Ref,\n} from \"react\";\n\nimport { Placement } from \"@popperjs/core\";\nimport classnames from \"classnames\";\n\nimport { MenuContextProvider } from \"./context\";\nimport { StyledMenu } from \"./Styles\";\nimport useForkRef from \"../../utils/useForkRef\";\nimport { Overlay } from \"../Overlay\";\nimport { Popper } from \"../Popper\";\nimport { Grow } from \"../Transitions\";\nimport { Window } from \"../Window\";\n\ninterface ElementWithRef<T> extends ReactElement {\n ref?: Ref<T>;\n}\n\n// source: https://twitter.com/mattpocockuk/status/1671908303918473217/photo/1\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type MenuMode = \"normal\" | \"wider\" | \"tiny\" | \"widest\";\n\nexport interface IMenu {\n /** Menu content */\n children:\n | ReactNode\n | ((childProps: { forceClose: () => void }) => JSX.Element);\n /** On menu element click */\n onMenuClick?: (event: MouseEvent<HTMLElement>) => void;\n /** Handle scroll bar */\n handleScroll?: boolean;\n /** Disable Focus Lock */\n disableFocusLock?: boolean;\n /** Menu width mode */\n mode?: MenuMode;\n /** Should menu be open when it's mounted */\n open?: boolean;\n /** Callback triggered when modal has been opened */\n onOpen?: () => void;\n /** Callback triggered when modal has been closed */\n onClose?: () => void;\n /** Before close callback */\n onBeforeClose?: () => boolean;\n /** Position Menu */\n position?: Placement;\n /** Target element */\n target?: ElementWithRef<Element>;\n className?: string;\n /** Menu classes */\n menuClassName?: string;\n /** Popper class name*/\n popperClassName?: string;\n /** Background style for clickable element after the menu is open (opacity, color, etc...) */\n backgroundElementClass?: string;\n /** Should Window be positioned absolutely */\n windowAbsolutelyPositioned?: boolean;\n /** Popper on open */\n onPopperOpen?: (...args) => void;\n}\n\nconst isFocusVisible = (element: Element | null) => {\n try {\n return Boolean(element?.matches(\":focus-visible\"));\n } catch {\n return false;\n }\n};\n\nconst TRIGGER = 'button, [role=\"button\"], a[href]';\n\n// A target can wrap its button, as a div around a Tooltip or a CounterButton does.\nconst triggerOf = (node: HTMLElement) =>\n node.matches(TRIGGER)\n ? node\n : node.querySelector<HTMLElement>(TRIGGER) ?? node;\n\nconst visibleBoxOf = (node: HTMLElement) => {\n const rects = [node, ...Array.from(node.children)].map((element) =>\n element.getBoundingClientRect()\n );\n\n return {\n left: Math.min(...rects.map((rect) => rect.left)),\n right: Math.max(...rects.map((rect) => rect.right)),\n top: Math.min(...rects.map((rect) => rect.top)),\n bottom: Math.max(...rects.map((rect) => rect.bottom)),\n };\n};\n\n// A control group pulls a wrapped button out of its wrapper by negative margins, so the menu lines up with the button.\nconst offsetToVisibleBox = (node: HTMLElement) => ({\n name: \"offset\",\n options: {\n offset: ({ placement }: { placement: Placement }): [number, number] => {\n if (triggerOf(node) === node) {\n return [0, 0];\n }\n\n const wrapper = node.getBoundingClientRect();\n const box = visibleBoxOf(node);\n const [side, align] = placement.split(\"-\");\n const vertical = side === \"top\" || side === \"bottom\";\n const start = vertical ? \"left\" : \"top\";\n const end = vertical ? \"right\" : \"bottom\";\n const skidding =\n align === \"start\"\n ? box[start] - wrapper[start]\n : align === \"end\"\n ? box[end] - wrapper[end]\n : (box[start] + box[end] - wrapper[start] - wrapper[end]) / 2;\n const distance = {\n bottom: box.bottom - wrapper.bottom,\n top: wrapper.top - box.top,\n right: box.right - wrapper.right,\n left: wrapper.left - box.left,\n }[side];\n\n return [skidding, distance ?? 0];\n },\n },\n});\n\n// A menu opened with the pointer hands the focus back without a focus ring, so its trigger does not stay lit.\nconst returnFocusOptions = (visible: boolean) =>\n ({ focusVisible: visible } as FocusOptions);\n\nexport const Menu: FC<IMenu> = ({\n children,\n disableFocusLock = false,\n onMenuClick,\n handleScroll = true,\n mode = \"normal\",\n open: defaultOpen = false,\n onOpen,\n onClose,\n onBeforeClose,\n position = \"bottom-start\",\n target,\n className,\n menuClassName,\n popperClassName,\n backgroundElementClass,\n windowAbsolutelyPositioned = false,\n onPopperOpen,\n}) => {\n const [open, setOpen] = useState(defaultOpen);\n const [exited, setExited] = useState(!defaultOpen);\n const [childNode, setChildNode] = useState<Element | null>();\n const elementRef = useRef<HTMLElement | null>(null);\n const isOpenAtLeastOnce = useRef(false);\n const wasOpen = useRef(open);\n const focusBeforeOpen = useRef<Element | null>(null);\n const focusWasVisible = useRef(false);\n const returnFocusTo = useRef<HTMLElement | null>(null);\n const popperRef = useRef<HTMLDivElement | null>(null);\n\n // Read on the render that opens the menu, before the focus lock moves the focus inside it.\n if (open && !wasOpen.current && typeof document !== \"undefined\") {\n focusBeforeOpen.current = document.activeElement;\n focusWasVisible.current = isFocusVisible(document.activeElement);\n }\n wasOpen.current = open;\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n useEffect(() => {\n if (open) {\n setExited(false);\n }\n }, [open]);\n\n // Set on the node itself, so the trigger gets it also through a wrapper such as Tooltip.\n const expandedTrigger = useRef<HTMLElement | null>(null);\n const checkedTrigger = useRef<HTMLElement | null>(null);\n const triggerOwnsExpanded = useRef(false);\n\n useEffect(() => {\n const node = elementRef.current;\n\n if (!node) {\n return;\n }\n\n const trigger = triggerOf(node);\n\n // A trigger that renders its own aria-expanded keeps it, so the menu never clears its \"false\".\n if (checkedTrigger.current !== trigger) {\n checkedTrigger.current = trigger;\n triggerOwnsExpanded.current = trigger.hasAttribute(\"aria-expanded\");\n }\n\n if (!trigger.hasAttribute(\"aria-haspopup\")) {\n trigger.setAttribute(\"aria-haspopup\", \"true\");\n }\n\n if (triggerOwnsExpanded.current) {\n return;\n }\n\n if (open) {\n trigger.setAttribute(\"aria-expanded\", \"true\");\n expandedTrigger.current = trigger;\n } else if (expandedTrigger.current) {\n expandedTrigger.current.removeAttribute(\"aria-expanded\");\n expandedTrigger.current = null;\n }\n }, [open, childNode]);\n\n const handleRefRef = useForkRef(\n target ? target.ref : undefined,\n setChildNode\n );\n const handleRef = useForkRef(handleRefRef, elementRef);\n\n const popperModifiers = useMemo(\n () =>\n childNode instanceof HTMLElement\n ? [offsetToVisibleBox(childNode)]\n : undefined,\n [childNode]\n );\n\n const handleOpen = useCallback(\n (\n event: Pick<MouseEvent<Element>, \"preventDefault\" | \"stopPropagation\">\n ) => {\n event?.preventDefault();\n event?.stopPropagation();\n setOpen(true);\n typeof onOpen === \"function\" && onOpen();\n typeof target?.props?.onClick === \"function\" &&\n target.props.onClick(event);\n },\n [onOpen, target?.props]\n );\n\n const handleClose = useCallback(() => {\n if (typeof onBeforeClose === \"function\" && !onBeforeClose()) {\n return;\n }\n setOpen(false);\n typeof onClose === \"function\" && onClose();\n }, [onClose, onBeforeClose]);\n\n const childProps = {\n forceClose: handleClose,\n };\n\n const targetProps = {\n open,\n ref: handleRef,\n onClick: handleOpen,\n };\n\n useEffect(() => {\n if (open) {\n isOpenAtLeastOnce.current = true;\n } else if (!open && isOpenAtLeastOnce.current) {\n const previous = focusBeforeOpen.current;\n const returnTo =\n previous instanceof HTMLElement && previous.isConnected\n ? previous\n : elementRef.current;\n\n returnFocusTo.current = returnTo;\n returnTo?.focus(returnFocusOptions(focusWasVisible.current));\n isOpenAtLeastOnce.current = false;\n }\n }, [open]);\n\n // A fading menu is already closed. Its content can still reach for the focus, and would take it away\n // with it when it unmounts, so the focus goes straight back to where the menu returned it.\n useEffect(() => {\n if (open || exited) {\n return undefined;\n }\n\n const keepFocusOut = (event: FocusEvent) => {\n if (popperRef.current?.contains(event.target as Node)) {\n returnFocusTo.current?.focus(\n returnFocusOptions(focusWasVisible.current)\n );\n }\n };\n\n document.addEventListener(\"focusin\", keepFocusOut, true);\n\n return () => document.removeEventListener(\"focusin\", keepFocusOut, true);\n }, [open, exited]);\n\n return (\n <>\n {target && React.cloneElement(target, targetProps)}\n {open || !exited ? (\n <Window\n onClose={handleClose}\n disableScrollLock={!handleScroll}\n // The menu returns the focus itself at once, so a late returnFocus cannot undo a caller's move.\n disableFocusLock={disableFocusLock || !open}\n // A fading menu is already closed, so an escape pressed meanwhile belongs to the page behind it.\n disableCloseOnEsc={!open}\n style={{\n position: windowAbsolutelyPositioned ? \"absolute\" : \"fixed\",\n }}\n >\n {/* A closing menu must not swallow the click that lands while it fades out. */}\n {open ? (\n <Overlay\n className={backgroundElementClass}\n onClick={handleClose}\n tabIndex={-1}\n disableBackgroundColor\n />\n ) : null}\n <Popper\n ref={popperRef}\n anchorEl={childNode}\n open={childNode ? open : false}\n placement={position}\n className={popperClassName}\n tabIndex={-1}\n afterWrite={onPopperOpen}\n modifiers={popperModifiers}\n transition\n >\n {({ placement, transitionProps }) => (\n <Grow\n placement={placement}\n in={transitionProps?.in}\n onEnter={transitionProps?.onEnter}\n onExited={() => {\n setExited(true);\n transitionProps?.onExited?.();\n }}\n >\n <StyledMenu\n className={classnames(\n \"c-simple-menu__paper\",\n `c-simple-menu__${mode}`,\n menuClassName,\n className\n )}\n $mode={mode}\n onMouseDown={onMenuClick}\n style={open ? undefined : { pointerEvents: \"none\" }}\n >\n <MenuContextProvider value={{ open, setOpen }}>\n {typeof children === \"function\"\n ? children(childProps)\n : children}\n </MenuContextProvider>\n </StyledMenu>\n </Grow>\n )}\n </Popper>\n </Window>\n ) : null}\n </>\n );\n};\n\nMenu.displayName = \"Menu\";\n"],"mappings":"AAAA,OAAOA,KAAK,IACVC,MAAM,EAINC,QAAQ,EACRC,WAAW,EACXC,SAAS,EACTC,OAAO,QAGF,OAAO;AAGd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,mBAAmB,QAAQ,WAAW;AAC/C,SAASC,UAAU,QAAQ,UAAU;AACrC,OAAOC,UAAU,MAAM,wBAAwB;AAC/C,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,MAAM,QAAQ,WAAW;;AAMlC;AACA;;AAyCA,MAAMC,cAAc,GAAIC,OAAuB,IAAK;EAClD,IAAI;IACF,OAAOC,OAAO,CAACD,OAAO,oBAAPA,OAAO,CAAEE,OA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AAE,gBAEFxJ,KAAA,CAAAwI,aAAA,CAAChI,UAAU;MACTqE,SAAS,EAAEvE,UAAU,CACnB,sBAAsB,sBACJ6D,IAAI,EACtBW,aAAa,EACbD,SACF,CAAE;MACF4E,KAAK,EAAEtF,IAAK;MACZuF,WAAW,EAAE3F,WAAY;MACzB8E,KAAK,EAAExE,IAAI,GAAG0C,SAAS,GAAG;QAAE4C,aAAa,EAAE;MAAO;IAAE,gBAEpD3J,KAAA,CAAAwI,aAAA,CAACjI,mBAAmB;MAACqJ,KAAK,EAAE;QAAEvF,IAAI;QAAEgB;MAAQ;IAAE,GAC3C,OAAOzD,QAAQ,KAAK,UAAU,GAC3BA,QAAQ,CAAC+F,UAAU,CAAC,GACpB/F,QACe,CACX,CACR,CAAC;EAAA,CAEH,CACF,CAAC,GACP,IACJ,CAAC;AAEP,CAAC;AAED+B,IAAI,CAACkG,WAAW,GAAG,MAAM","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Menu.js","names":["React","useRef","useState","useCallback","useEffect","useLayoutEffect","useMemo","classnames","MenuContextProvider","StyledMenu","useForkRef","Overlay","Popper","Grow","Window","isFocusVisible","element","Boolean","matches","_unused","TRIGGER","triggerOf","node","_node$querySelector","querySelector","visibleBoxOf","rects","Array","from","children","map","getBoundingClientRect","left","Math","min","rect","right","max","top","bottom","offsetToVisibleBox","name","options","offset","_ref","placement","wrapper","box","_placement$split","split","side","align","vertical","start","end","skidding","distance","TABBABLE","returnFocusOptions","visible","focusVisible","focusTabNeighbor","trigger","step","menu","nodes","document","querySelectorAll","filter","tabIndex","disabled","closest","contains","indexOf","index","length","focus","activeElement","Menu","_ref2","_ref2$disableFocusLoc","disableFocusLock","onMenuClick","_ref2$handleScroll","handleScroll","_ref2$mode","mode","_ref2$open","open","defaultOpen","onOpen","onClose","onBeforeClose","_ref2$position","position","target","className","menuClassName","popperClassName","backgroundElementClass","_ref2$windowAbsolutel","windowAbsolutelyPositioned","onPopperOpen","_ref2$closeOnTab","closeOnTab","_useState","setOpen","_useState2","exited","setExited","elementRef","isOpenAtLeastOnce","wasOpen","focusBeforeOpen","focusWasVisible","returnFocusTo","popperRef","windowRef","tabOut","current","expandedTrigger","checkedTrigger","triggerOwnsExpanded","hasAttribute","setAttribute","removeAttribute","handleRef","ref","undefined","_useState3","childNode","setChildNode","popperModifiers","HTMLElement","handleOpen","event","_target$props","preventDefault","stopPropagation","props","onClick","handleClose","handleTabOut","key","defaultPrevented","shiftKey","childProps","forceClose","targetProps","previous","tabbedTo","returnTo","isConnected","keepFocusOut","_popperRef$current","_returnFocusTo$curren","addEventListener","removeEventListener","createElement","Fragment","cloneElement","onKeyDown","disableReturnFocus","disableScrollLock","disableCloseOnEsc","style","disableBackgroundColor","anchorEl","afterWrite","modifiers","transition","_ref3","transitionProps","in","onEnter","onExited","$mode","onMouseDown","pointerEvents","value","displayName"],"sources":["../../../../src/components/Menu/Menu.tsx"],"sourcesContent":["import React, {\n useRef,\n FC,\n ReactNode,\n MouseEvent,\n KeyboardEvent,\n useState,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n ReactElement,\n Ref,\n} from \"react\";\n\nimport { Placement } from \"@popperjs/core\";\nimport classnames from \"classnames\";\n\nimport { MenuContextProvider } from \"./context\";\nimport { StyledMenu } from \"./Styles\";\nimport useForkRef from \"../../utils/useForkRef\";\nimport { Overlay } from \"../Overlay\";\nimport { Popper } from \"../Popper\";\nimport { Grow } from \"../Transitions\";\nimport { Window } from \"../Window\";\n\ninterface ElementWithRef<T> extends ReactElement {\n ref?: Ref<T>;\n}\n\n// source: https://twitter.com/mattpocockuk/status/1671908303918473217/photo/1\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type MenuMode = \"normal\" | \"wider\" | \"tiny\" | \"widest\";\n\nexport interface IMenu {\n /** Menu content */\n children:\n | ReactNode\n | ((childProps: { forceClose: () => void }) => JSX.Element);\n /** On menu element click */\n onMenuClick?: (event: MouseEvent<HTMLElement>) => void;\n /** Handle scroll bar */\n handleScroll?: boolean;\n /** Disable Focus Lock */\n disableFocusLock?: boolean;\n /** Menu width mode */\n mode?: MenuMode;\n /** Should menu be open when it's mounted */\n open?: boolean;\n /** Callback triggered when modal has been opened */\n onOpen?: () => void;\n /** Callback triggered when modal has been closed */\n onClose?: () => void;\n /** Before close callback */\n onBeforeClose?: () => boolean;\n /** Position Menu */\n position?: Placement;\n /** Target element */\n target?: ElementWithRef<Element>;\n className?: string;\n /** Menu classes */\n menuClassName?: string;\n /** Popper class name*/\n popperClassName?: string;\n /** Background style for clickable element after the menu is open (opacity, color, etc...) */\n backgroundElementClass?: string;\n /** Should Window be positioned absolutely */\n windowAbsolutelyPositioned?: boolean;\n /** Popper on open */\n onPopperOpen?: (...args) => void;\n /** Tab and Shift+Tab close the menu and move the focus on from the target, as they would on the target itself */\n closeOnTab?: boolean;\n}\n\nconst isFocusVisible = (element: Element | null) => {\n try {\n return Boolean(element?.matches(\":focus-visible\"));\n } catch {\n return false;\n }\n};\n\nconst TRIGGER = 'button, [role=\"button\"], a[href]';\n\n// A target can wrap its button, as a div around a Tooltip or a CounterButton does.\nconst triggerOf = (node: HTMLElement) =>\n node.matches(TRIGGER)\n ? node\n : node.querySelector<HTMLElement>(TRIGGER) ?? node;\n\nconst visibleBoxOf = (node: HTMLElement) => {\n const rects = [node, ...Array.from(node.children)].map((element) =>\n element.getBoundingClientRect()\n );\n\n return {\n left: Math.min(...rects.map((rect) => rect.left)),\n right: Math.max(...rects.map((rect) => rect.right)),\n top: Math.min(...rects.map((rect) => rect.top)),\n bottom: Math.max(...rects.map((rect) => rect.bottom)),\n };\n};\n\n// A control group pulls a wrapped button out of its wrapper by negative margins, so the menu lines up with the button.\nconst offsetToVisibleBox = (node: HTMLElement) => ({\n name: \"offset\",\n options: {\n offset: ({ placement }: { placement: Placement }): [number, number] => {\n if (triggerOf(node) === node) {\n return [0, 0];\n }\n\n const wrapper = node.getBoundingClientRect();\n const box = visibleBoxOf(node);\n const [side, align] = placement.split(\"-\");\n const vertical = side === \"top\" || side === \"bottom\";\n const start = vertical ? \"left\" : \"top\";\n const end = vertical ? \"right\" : \"bottom\";\n const skidding =\n align === \"start\"\n ? box[start] - wrapper[start]\n : align === \"end\"\n ? box[end] - wrapper[end]\n : (box[start] + box[end] - wrapper[start] - wrapper[end]) / 2;\n const distance = {\n bottom: box.bottom - wrapper.bottom,\n top: wrapper.top - box.top,\n right: box.right - wrapper.right,\n left: wrapper.left - box.left,\n }[side];\n\n return [skidding, distance ?? 0];\n },\n },\n});\n\nconst TABBABLE =\n 'a[href], button, input, select, textarea, iframe, [tabindex], [contenteditable=\"true\"]';\n\n// A menu opened with the pointer hands the focus back without a focus ring, so its trigger does not stay lit.\nconst returnFocusOptions = (visible: boolean) =>\n ({ focusVisible: visible } as FocusOptions);\n\n// Moves the focus where a Tab or Shift+Tab on the trigger would go. The closing menu itself does not count.\nconst focusTabNeighbor = (\n trigger: HTMLElement,\n step: 1 | -1,\n menu: HTMLElement | null\n) => {\n const nodes = Array.from(\n document.querySelectorAll<HTMLElement>(TABBABLE)\n ).filter(\n (node) =>\n node === trigger ||\n (node.tabIndex >= 0 &&\n !(node as HTMLButtonElement).disabled &&\n !node.closest(\"[inert]\") &&\n !menu?.contains(node))\n );\n\n const from = nodes.indexOf(trigger);\n\n for (\n let index = from + step;\n from !== -1 && index >= 0 && index < nodes.length;\n index += step\n ) {\n nodes[index].focus(returnFocusOptions(true));\n\n if (document.activeElement === nodes[index]) {\n return nodes[index];\n }\n }\n\n return null;\n};\n\nexport const Menu: FC<IMenu> = ({\n children,\n disableFocusLock = false,\n onMenuClick,\n handleScroll = true,\n mode = \"normal\",\n open: defaultOpen = false,\n onOpen,\n onClose,\n onBeforeClose,\n position = \"bottom-start\",\n target,\n className,\n menuClassName,\n popperClassName,\n backgroundElementClass,\n windowAbsolutelyPositioned = false,\n onPopperOpen,\n closeOnTab = false,\n}) => {\n const [open, setOpen] = useState(defaultOpen);\n const [exited, setExited] = useState(!defaultOpen);\n // The trigger node lives in a ref. In state it would render every menu of a list again right after it mounts.\n const elementRef = useRef<HTMLElement | null>(null);\n const isOpenAtLeastOnce = useRef(false);\n const wasOpen = useRef(open);\n const focusBeforeOpen = useRef<Element | null>(null);\n const focusWasVisible = useRef(false);\n const returnFocusTo = useRef<HTMLElement | null>(null);\n const popperRef = useRef<HTMLDivElement | null>(null);\n const windowRef = useRef<HTMLDivElement | null>(null);\n const tabOut = useRef<1 | -1 | 0>(0);\n\n // Read on the render that opens the menu, before the focus lock moves the focus inside it.\n if (open && !wasOpen.current && typeof document !== \"undefined\") {\n focusBeforeOpen.current = document.activeElement;\n focusWasVisible.current = isFocusVisible(document.activeElement);\n }\n wasOpen.current = open;\n\n useEffect(() => {\n setOpen(defaultOpen);\n }, [defaultOpen]);\n\n useEffect(() => {\n if (open) {\n setExited(false);\n }\n }, [open]);\n\n // Set on the node itself, so the trigger gets it also through a wrapper such as Tooltip. It runs after every\n // render, because the trigger node lives in a ref and a new node brings no render of its own.\n const expandedTrigger = useRef<HTMLElement | null>(null);\n const checkedTrigger = useRef<HTMLElement | null>(null);\n const triggerOwnsExpanded = useRef(false);\n\n useEffect(() => {\n const node = elementRef.current;\n\n if (!node) {\n return;\n }\n\n const trigger = triggerOf(node);\n\n // A trigger that renders its own aria-expanded keeps it, so the menu never clears its \"false\".\n if (checkedTrigger.current !== trigger) {\n checkedTrigger.current = trigger;\n triggerOwnsExpanded.current = trigger.hasAttribute(\"aria-expanded\");\n }\n\n if (!trigger.hasAttribute(\"aria-haspopup\")) {\n trigger.setAttribute(\"aria-haspopup\", \"true\");\n }\n\n if (triggerOwnsExpanded.current) {\n return;\n }\n\n if (open) {\n trigger.setAttribute(\"aria-expanded\", \"true\");\n expandedTrigger.current = trigger;\n } else if (expandedTrigger.current) {\n expandedTrigger.current.removeAttribute(\"aria-expanded\");\n expandedTrigger.current = null;\n }\n });\n\n const handleRef = useForkRef(target ? target.ref : undefined, elementRef);\n\n // The popper needs the node as state, so it is copied only while the menu shows, before the browser paints.\n const [childNode, setChildNode] = useState<HTMLElement | null>(null);\n\n useLayoutEffect(() => {\n const node = open || !exited ? elementRef.current : null;\n\n if (node !== childNode) {\n setChildNode(node);\n }\n }, [open, exited, childNode]);\n\n const popperModifiers = useMemo(\n () =>\n childNode instanceof HTMLElement\n ? [offsetToVisibleBox(childNode)]\n : undefined,\n [childNode]\n );\n\n const handleOpen = useCallback(\n (\n event: Pick<MouseEvent<Element>, \"preventDefault\" | \"stopPropagation\">\n ) => {\n event?.preventDefault();\n event?.stopPropagation();\n setOpen(true);\n typeof onOpen === \"function\" && onOpen();\n typeof target?.props?.onClick === \"function\" &&\n target.props.onClick(event);\n },\n [onOpen, target?.props]\n );\n\n const handleClose = useCallback(() => {\n if (typeof onBeforeClose === \"function\" && !onBeforeClose()) {\n return false;\n }\n setOpen(false);\n typeof onClose === \"function\" && onClose();\n\n return true;\n }, [onClose, onBeforeClose]);\n\n const handleTabOut = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key !== \"Tab\" || event.defaultPrevented) {\n return;\n }\n\n event.preventDefault();\n tabOut.current = event.shiftKey ? -1 : 1;\n\n if (!handleClose()) {\n tabOut.current = 0;\n }\n },\n [handleClose]\n );\n\n const childProps = {\n forceClose: handleClose,\n };\n\n const targetProps = {\n open,\n ref: handleRef,\n onClick: handleOpen,\n };\n\n useEffect(() => {\n if (open) {\n isOpenAtLeastOnce.current = true;\n } else if (!open && isOpenAtLeastOnce.current) {\n const previous = focusBeforeOpen.current;\n const step = tabOut.current;\n const tabbedTo =\n step && elementRef.current\n ? focusTabNeighbor(\n triggerOf(elementRef.current),\n step,\n windowRef.current\n )\n : null;\n\n tabOut.current = 0;\n\n if (tabbedTo) {\n returnFocusTo.current = tabbedTo;\n } else {\n const returnTo =\n previous instanceof HTMLElement && previous.isConnected\n ? previous\n : elementRef.current;\n\n returnFocusTo.current = returnTo;\n returnTo?.focus(returnFocusOptions(focusWasVisible.current));\n }\n isOpenAtLeastOnce.current = false;\n }\n }, [open]);\n\n // A fading menu is already closed. Its content can still reach for the focus, and would take it away\n // with it when it unmounts, so the focus goes straight back to where the menu returned it.\n useEffect(() => {\n if (open || exited) {\n return undefined;\n }\n\n const keepFocusOut = (event: FocusEvent) => {\n if (popperRef.current?.contains(event.target as Node)) {\n returnFocusTo.current?.focus(\n returnFocusOptions(focusWasVisible.current)\n );\n }\n };\n\n document.addEventListener(\"focusin\", keepFocusOut, true);\n\n return () => document.removeEventListener(\"focusin\", keepFocusOut, true);\n }, [open, exited]);\n\n return (\n <>\n {target && React.cloneElement(target, targetProps)}\n {open || !exited ? (\n <Window\n ref={windowRef}\n onClose={handleClose}\n onKeyDown={closeOnTab && open ? handleTabOut : undefined}\n // The lock returns the focus with the props of the render before it turns off, too late to skip a Tab.\n // The menu returns the focus itself, so a menu that closes on Tab leaves the lock out of it.\n disableReturnFocus={closeOnTab}\n disableScrollLock={!handleScroll}\n // The menu returns the focus itself at once, so a late returnFocus cannot undo a caller's move.\n disableFocusLock={disableFocusLock || !open}\n // A fading menu is already closed, so an escape pressed meanwhile belongs to the page behind it.\n disableCloseOnEsc={!open}\n style={{\n position: windowAbsolutelyPositioned ? \"absolute\" : \"fixed\",\n }}\n >\n {/* A closing menu must not swallow the click that lands while it fades out. */}\n {open ? (\n <Overlay\n className={backgroundElementClass}\n onClick={handleClose}\n tabIndex={-1}\n disableBackgroundColor\n />\n ) : null}\n <Popper\n ref={popperRef}\n anchorEl={childNode}\n open={childNode ? open : false}\n placement={position}\n className={popperClassName}\n tabIndex={-1}\n afterWrite={onPopperOpen}\n modifiers={popperModifiers}\n transition\n >\n {({ placement, transitionProps }) => (\n <Grow\n placement={placement}\n in={transitionProps?.in}\n onEnter={transitionProps?.onEnter}\n onExited={() => {\n setExited(true);\n transitionProps?.onExited?.();\n }}\n >\n <StyledMenu\n className={classnames(\n \"c-simple-menu__paper\",\n `c-simple-menu__${mode}`,\n menuClassName,\n className\n )}\n $mode={mode}\n onMouseDown={onMenuClick}\n style={open ? undefined : { pointerEvents: \"none\" }}\n >\n <MenuContextProvider value={{ open, setOpen }}>\n {typeof children === \"function\"\n ? children(childProps)\n : children}\n </MenuContextProvider>\n </StyledMenu>\n </Grow>\n )}\n </Popper>\n </Window>\n ) : null}\n </>\n );\n};\n\nMenu.displayName = \"Menu\";\n"],"mappings":"AAAA,OAAOA,KAAK,IACVC,MAAM,EAKNC,QAAQ,EACRC,WAAW,EACXC,SAAS,EACTC,eAAe,EACfC,OAAO,QAGF,OAAO;AAGd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,mBAAmB,QAAQ,WAAW;AAC/C,SAASC,UAAU,QAAQ,UAAU;AACrC,OAAOC,UAAU,MAAM,wBAAwB;AAC/C,SAASC,OAAO,QAAQ,YAAY;AACpC,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,MAAM,QAAQ,WAAW;;AAMlC;AACA;;AA2CA,MAAMC,cAAc,GAAIC,OAAuB,IAAK;EAClD,IAAI;IACF,OAAOC,OAAO,CAACD,OAAO,oBAAPA,OAAO,CAAEE,OAAO,CAAC,gBAAgB,CAAC,CAAC;EACpD,CAAC,CAAC,OAAAC,OAAA,EAAM;IACN,OAAO,KAAK;EACd;AACF,CAAC;AAED,MAAMC,OAAO,GAAG,kCAAkC;;AAElD;AACA,MAAMC,SAAS,GAAIC,IAAiB;EAAA,IAAAC,mBAAA;EAAA,OAClCD,IAAI,CAACJ,OAAO,CAACE,OAAO,CAAC,GACjBE,IAAI,IAAAC,mBAAA,GACJD,IAAI,CAACE,aAAa,CAAcJ,OAAO,CAAC,YAAAG,mBAAA,GAAID,IAAI;AAAA;AAEtD,MAAMG,YAAY,GAAIH,IAAiB,IAAK;EAC1C,MAAMI,KAAK,GAAG,CAACJ,IAAI,EAAE,GAAGK,KAAK,CAACC,IAAI,CAACN,IAAI,CAACO,QAAQ,CAAC,CAAC,CAACC,GAAG,CAAEd,OAAO,IAC7DA,OAAO,CAACe,q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G,UAAU,EAAElE,YAAa;IACzBmE,SAAS,EAAErC,eAAgB;IAC3BsC,UAAU;EAAA,GAETC,KAAA;IAAA,IAAG9H,SAAS,GAAA8H,KAAA,CAAT9H,SAAS;MAAE+H,eAAe,GAAAD,KAAA,CAAfC,eAAe;IAAA,oBAC5B5K,KAAA,CAAA8J,aAAA,CAACjJ,IAAI;MACHgC,SAAS,EAAEA,SAAU;MACrBgI,EAAE,EAAED,eAAe,oBAAfA,eAAe,CAAEC,EAAG;MACxBC,OAAO,EAAEF,eAAe,oBAAfA,eAAe,CAAEE,OAAQ;MAClCC,QAAQ,EAAEA,CAAA,KAAM;QACdlE,SAAS,CAAC,IAAI,CAAC;QACf+D,eAAe,YAAfA,eAAe,CAAEG,QAAQ,YAAzBH,eAAe,CAAEG,QAAQ,CAAG,CAAC;MAC/B;IAAE,gBAEF/K,KAAA,CAAA8J,aAAA,CAACrJ,UAAU;MACTuF,SAAS,EAAEzF,UAAU,CACnB,sBAAsB,sBACJ+E,IAAI,EACtBW,aAAa,EACbD,SACF,CAAE;MACFgF,KAAK,EAAE1F,IAAK;MACZ2F,WAAW,EAAE/F,WAAY;MACzBmF,KAAK,EAAE7E,IAAI,GAAGwC,SAAS,GAAG;QAAEkD,aAAa,EAAE;MAAO;IAAE,gBAEpDlL,KAAA,CAAA8J,aAAA,CAACtJ,mBAAmB;MAAC2K,KAAK,EAAE;QAAE3F,IAAI;QAAEkB;MAAQ;IAAE,GAC3C,OAAO7E,QAAQ,KAAK,UAAU,GAC3BA,QAAQ,CAACqH,UAAU,CAAC,GACpBrH,QACe,CACX,CACR,CAAC;EAAA,CAEH,CACF,CAAC,GACP,IACJ,CAAC;AAEP,CAAC;AAEDiD,IAAI,CAACsG,WAAW,GAAG,MAAM","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { ComponentPropsWithoutRef, ReactElement, ReactNode } from "react";
|
|
2
|
+
export interface PillButtonProps extends ComponentPropsWithoutRef<"button"> {
|
|
3
|
+
/** Icon shown while the pill has no value. */
|
|
4
|
+
icon?: ReactElement;
|
|
5
|
+
/** Label shown next to the icon while the pill has no value. */
|
|
6
|
+
placeholder?: ReactNode;
|
|
7
|
+
/** Fill of the pill. "ghost" stays empty until hover, focus, open, or hover of a `c-pill-host` ancestor. */
|
|
8
|
+
tone?: "soft" | "alternate" | "ghost" | "outlined";
|
|
9
|
+
/** Selected or pressed state. */
|
|
10
|
+
active?: boolean;
|
|
11
|
+
/** A square-ish pill that holds only its icon, for example a close button. */
|
|
12
|
+
iconOnly?: boolean;
|
|
13
|
+
/** Hide the placeholder and keep the icon, always or only on small screens. */
|
|
14
|
+
compact?: boolean | "mobile";
|
|
15
|
+
/** Height: "medium" is 26px, "small" is 24px like a small Button. */
|
|
16
|
+
size?: "small" | "medium";
|
|
17
|
+
/** Side padding. "tight" suits a value that draws to its own edges, like avatars. */
|
|
18
|
+
inset?: "default" | "tight";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @component PillButton
|
|
22
|
+
* @description
|
|
23
|
+
* A rounded trigger for a field value, for example the assignees, the dates or the label of a task.
|
|
24
|
+
* With no children it shows its icon and placeholder. With children it shows only the children.
|
|
25
|
+
* It forwards its ref and click handler, so a Menu or a Select can use it as a target.
|
|
26
|
+
* Put several pills in a PillGroup to make a segmented control.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* <PillButton icon={<CalendarIcon />} placeholder="Dates" />
|
|
30
|
+
* <PillButton tone="ghost">Sep 24. - 30.</PillButton>
|
|
31
|
+
*/
|
|
32
|
+
export declare const PillButton: React.ForwardRefExoticComponent<PillButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
33
|
+
//# sourceMappingURL=PillButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PillButton.d.ts","sourceRoot":"","sources":["../../../../src/components/PillButton/PillButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAEZ,wBAAwB,EAExB,YAAY,EACZ,SAAS,EACV,MAAM,OAAO,CAAC;AAUf,MAAM,WAAW,eAAgB,SAAQ,wBAAwB,CAAC,QAAQ,CAAC;IACzE,8CAA8C;IAC9C,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,gEAAgE;IAChE,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,4GAA4G;IAC5G,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,GAAG,UAAU,CAAC;IACnD,iCAAiC;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC7B,qEAAqE;IACrE,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1B,qFAAqF;IACrF,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,2FAgEtB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["icon", "placeholder", "tone", "active", "iconOnly", "compact", "size", "inset", "type", "className", "children"];
|
|
4
|
+
import React, { Children, forwardRef } from "react";
|
|
5
|
+
import classnames from "classnames";
|
|
6
|
+
import { StyledPillButton, StyledPillIcon, StyledPillPlaceholder } from "./Styles";
|
|
7
|
+
/**
|
|
8
|
+
* @component PillButton
|
|
9
|
+
* @description
|
|
10
|
+
* A rounded trigger for a field value, for example the assignees, the dates or the label of a task.
|
|
11
|
+
* With no children it shows its icon and placeholder. With children it shows only the children.
|
|
12
|
+
* It forwards its ref and click handler, so a Menu or a Select can use it as a target.
|
|
13
|
+
* Put several pills in a PillGroup to make a segmented control.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* <PillButton icon={<CalendarIcon />} placeholder="Dates" />
|
|
17
|
+
* <PillButton tone="ghost">Sep 24. - 30.</PillButton>
|
|
18
|
+
*/
|
|
19
|
+
export const PillButton = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
20
|
+
var _args$ariaLabel;
|
|
21
|
+
let icon = _ref.icon,
|
|
22
|
+
placeholder = _ref.placeholder,
|
|
23
|
+
_ref$tone = _ref.tone,
|
|
24
|
+
tone = _ref$tone === void 0 ? "soft" : _ref$tone,
|
|
25
|
+
active = _ref.active,
|
|
26
|
+
_ref$iconOnly = _ref.iconOnly,
|
|
27
|
+
iconOnly = _ref$iconOnly === void 0 ? false : _ref$iconOnly,
|
|
28
|
+
_ref$compact = _ref.compact,
|
|
29
|
+
compact = _ref$compact === void 0 ? false : _ref$compact,
|
|
30
|
+
_ref$size = _ref.size,
|
|
31
|
+
size = _ref$size === void 0 ? "medium" : _ref$size,
|
|
32
|
+
_ref$inset = _ref.inset,
|
|
33
|
+
inset = _ref$inset === void 0 ? "default" : _ref$inset,
|
|
34
|
+
_ref$type = _ref.type,
|
|
35
|
+
type = _ref$type === void 0 ? "button" : _ref$type,
|
|
36
|
+
className = _ref.className,
|
|
37
|
+
children = _ref.children,
|
|
38
|
+
args = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
39
|
+
const isEmpty = Children.toArray(children).length === 0;
|
|
40
|
+
const ariaLabel = (_args$ariaLabel = args["aria-label"]) != null ? _args$ariaLabel : isEmpty && compact && typeof placeholder === "string" ? placeholder : undefined;
|
|
41
|
+
return /*#__PURE__*/React.createElement(StyledPillButton, _extends({
|
|
42
|
+
ref: ref,
|
|
43
|
+
type: type,
|
|
44
|
+
className: classnames("c-pill-button", "c-pill-button--" + tone, {
|
|
45
|
+
"c-pill-button--empty": isEmpty,
|
|
46
|
+
"c-pill-button--active": active,
|
|
47
|
+
"c-pill-button--icon-only": iconOnly
|
|
48
|
+
}, className),
|
|
49
|
+
"aria-pressed": active
|
|
50
|
+
}, args, {
|
|
51
|
+
"aria-label": ariaLabel,
|
|
52
|
+
$tone: tone,
|
|
53
|
+
$active: Boolean(active),
|
|
54
|
+
$empty: isEmpty,
|
|
55
|
+
$iconOnly: iconOnly,
|
|
56
|
+
$compact: compact,
|
|
57
|
+
$size: size,
|
|
58
|
+
$inset: inset
|
|
59
|
+
}), isEmpty && icon ? /*#__PURE__*/React.createElement(StyledPillIcon, {
|
|
60
|
+
className: "c-pill-button__icon"
|
|
61
|
+
}, icon) : null, isEmpty && placeholder && !iconOnly ? /*#__PURE__*/React.createElement(StyledPillPlaceholder, {
|
|
62
|
+
className: "c-pill-button__placeholder"
|
|
63
|
+
}, placeholder) : null, isEmpty ? null : children);
|
|
64
|
+
});
|
|
65
|
+
PillButton.displayName = "PillButton";
|
|
66
|
+
//# sourceMappingURL=PillButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PillButton.js","names":["React","Children","forwardRef","classnames","StyledPillButton","StyledPillIcon","StyledPillPlaceholder","PillButton","_ref","ref","_args$ariaLabel","icon","placeholder","_ref$tone","tone","active","_ref$iconOnly","iconOnly","_ref$compact","compact","_ref$size","size","_ref$inset","inset","_ref$type","type","className","children","args","_objectWithoutPropertiesLoose","_excluded","isEmpty","toArray","length","ariaLabel","undefined","createElement","_extends","$tone","$active","Boolean","$empty","$iconOnly","$compact","$size","$inset","displayName"],"sources":["../../../../src/components/PillButton/PillButton.tsx"],"sourcesContent":["import React, {\n Children,\n ComponentPropsWithoutRef,\n forwardRef,\n ReactElement,\n ReactNode,\n} from \"react\";\n\nimport classnames from \"classnames\";\n\nimport {\n StyledPillButton,\n StyledPillIcon,\n StyledPillPlaceholder,\n} from \"./Styles\";\n\nexport interface PillButtonProps extends ComponentPropsWithoutRef<\"button\"> {\n /** Icon shown while the pill has no value. */\n icon?: ReactElement;\n /** Label shown next to the icon while the pill has no value. */\n placeholder?: ReactNode;\n /** Fill of the pill. \"ghost\" stays empty until hover, focus, open, or hover of a `c-pill-host` ancestor. */\n tone?: \"soft\" | \"alternate\" | \"ghost\" | \"outlined\";\n /** Selected or pressed state. */\n active?: boolean;\n /** A square-ish pill that holds only its icon, for example a close button. */\n iconOnly?: boolean;\n /** Hide the placeholder and keep the icon, always or only on small screens. */\n compact?: boolean | \"mobile\";\n /** Height: \"medium\" is 26px, \"small\" is 24px like a small Button. */\n size?: \"small\" | \"medium\";\n /** Side padding. \"tight\" suits a value that draws to its own edges, like avatars. */\n inset?: \"default\" | \"tight\";\n}\n\n/**\n * @component PillButton\n * @description\n * A rounded trigger for a field value, for example the assignees, the dates or the label of a task.\n * With no children it shows its icon and placeholder. With children it shows only the children.\n * It forwards its ref and click handler, so a Menu or a Select can use it as a target.\n * Put several pills in a PillGroup to make a segmented control.\n *\n * @example\n * <PillButton icon={<CalendarIcon />} placeholder=\"Dates\" />\n * <PillButton tone=\"ghost\">Sep 24. - 30.</PillButton>\n */\nexport const PillButton = forwardRef<HTMLButtonElement, PillButtonProps>(\n (\n {\n icon,\n placeholder,\n tone = \"soft\",\n active,\n iconOnly = false,\n compact = false,\n size = \"medium\",\n inset = \"default\",\n type = \"button\",\n className,\n children,\n ...args\n },\n ref\n ) => {\n const isEmpty = Children.toArray(children).length === 0;\n const ariaLabel =\n args[\"aria-label\"] ??\n (isEmpty && compact && typeof placeholder === \"string\"\n ? placeholder\n : undefined);\n\n return (\n <StyledPillButton\n ref={ref}\n type={type}\n className={classnames(\n \"c-pill-button\",\n `c-pill-button--${tone}`,\n {\n \"c-pill-button--empty\": isEmpty,\n \"c-pill-button--active\": active,\n \"c-pill-button--icon-only\": iconOnly,\n },\n className\n )}\n aria-pressed={active}\n {...args}\n aria-label={ariaLabel}\n $tone={tone}\n $active={Boolean(active)}\n $empty={isEmpty}\n $iconOnly={iconOnly}\n $compact={compact}\n $size={size}\n $inset={inset}\n >\n {isEmpty && icon ? (\n <StyledPillIcon className=\"c-pill-button__icon\">\n {icon}\n </StyledPillIcon>\n ) : null}\n {isEmpty && placeholder && !iconOnly ? (\n <StyledPillPlaceholder className=\"c-pill-button__placeholder\">\n {placeholder}\n </StyledPillPlaceholder>\n ) : null}\n {isEmpty ? null : children}\n </StyledPillButton>\n );\n }\n);\n\nPillButton.displayName = \"PillButton\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IACVC,QAAQ,EAERC,UAAU,QAGL,OAAO;AAEd,OAAOC,UAAU,MAAM,YAAY;AAEnC,SACEC,gBAAgB,EAChBC,cAAc,EACdC,qBAAqB,QAChB,UAAU;AAqBjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,gBAAGL,UAAU,CAClC,CAAAM,IAAA,EAeEC,GAAG,KACA;EAAA,IAAAC,eAAA;EAAA,IAdDC,IAAI,GAAAH,IAAA,CAAJG,IAAI;IACJC,WAAW,GAAAJ,IAAA,CAAXI,WAAW;IAAAC,SAAA,GAAAL,IAAA,CACXM,IAAI;IAAJA,IAAI,GAAAD,SAAA,cAAG,MAAM,GAAAA,SAAA;IACbE,MAAM,GAAAP,IAAA,CAANO,MAAM;IAAAC,aAAA,GAAAR,IAAA,CACNS,QAAQ;IAARA,QAAQ,GAAAD,aAAA,cAAG,KAAK,GAAAA,aAAA;IAAAE,YAAA,GAAAV,IAAA,CAChBW,OAAO;IAAPA,OAAO,GAAAD,YAAA,cAAG,KAAK,GAAAA,YAAA;IAAAE,SAAA,GAAAZ,IAAA,CACfa,IAAI;IAAJA,IAAI,GAAAD,SAAA,cAAG,QAAQ,GAAAA,SAAA;IAAAE,UAAA,GAAAd,IAAA,CACfe,KAAK;IAALA,KAAK,GAAAD,UAAA,cAAG,SAAS,GAAAA,UAAA;IAAAE,SAAA,GAAAhB,IAAA,CACjBiB,IAAI;IAAJA,IAAI,GAAAD,SAAA,cAAG,QAAQ,GAAAA,SAAA;IACfE,SAAS,GAAAlB,IAAA,CAATkB,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F,CAAC;AAEvB,CACF,CAAC;AAEDpB,UAAU,CAACuC,WAAW,GAAG,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PillButtonProps } from "./PillButton";
|
|
2
|
+
interface StyledPillButtonProps {
|
|
3
|
+
$tone: NonNullable<PillButtonProps["tone"]>;
|
|
4
|
+
$active: boolean;
|
|
5
|
+
$empty: boolean;
|
|
6
|
+
$iconOnly: boolean;
|
|
7
|
+
$compact: PillButtonProps["compact"];
|
|
8
|
+
$size: NonNullable<PillButtonProps["size"]>;
|
|
9
|
+
$inset: NonNullable<PillButtonProps["inset"]>;
|
|
10
|
+
}
|
|
11
|
+
export declare const StyledPillIcon: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
12
|
+
export declare const StyledPillPlaceholder: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
13
|
+
export declare const StyledPillButton: import("styled-components").StyledComponent<"button", any, StyledPillButtonProps, never>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=Styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/PillButton/Styles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C,UAAU,qBAAqB;IAC7B,KAAK,EAAE,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IACrC,KAAK,EAAE,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5C,MAAM,EAAE,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;CAC/C;AAED,eAAO,MAAM,cAAc,qEAW1B,CAAC;AAIF,eAAO,MAAM,qBAAqB,qEAIjC,CAAC;AAkFF,eAAO,MAAM,gBAAgB,0FA6F5B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import { BoxSizingStyle } from "../BoxSizingStyle";
|
|
3
|
+
import { FontStyle } from "../FontStyle";
|
|
4
|
+
export const StyledPillIcon = styled.span.withConfig({
|
|
5
|
+
displayName: "Styles__StyledPillIcon",
|
|
6
|
+
componentId: "sc-14yhio0-0"
|
|
7
|
+
})(["display:inline-flex;flex-shrink:0;color:var(--color-theme-600);transition:opacity 0.2s ease,color 0.2s ease;svg{width:18px;height:18px;fill:currentColor;}"]);
|
|
8
|
+
StyledPillIcon.displayName = "StyledPillIcon";
|
|
9
|
+
export const StyledPillPlaceholder = styled.span.withConfig({
|
|
10
|
+
displayName: "Styles__StyledPillPlaceholder",
|
|
11
|
+
componentId: "sc-14yhio0-1"
|
|
12
|
+
})(["overflow:hidden;text-overflow:ellipsis;transition:opacity 0.2s ease;"]);
|
|
13
|
+
StyledPillPlaceholder.displayName = "StyledPillPlaceholder";
|
|
14
|
+
const activeStyle = css(["background-color:var(--pill-background-active);color:var(--color-primary);", "{color:var(--color-primary);}"], StyledPillIcon);
|
|
15
|
+
const hoverTextStyle = css(["color:var(--color-theme-900);", "{color:var(--color-theme-900);}"], StyledPillIcon);
|
|
16
|
+
const toneStyle = tone => {
|
|
17
|
+
switch (tone) {
|
|
18
|
+
case "alternate":
|
|
19
|
+
return css(["background-color:var(--color-theme-300);&:hover,&:focus-visible{background-color:var(--color-theme-400);", "}"], hoverTextStyle);
|
|
20
|
+
case "ghost":
|
|
21
|
+
return css(["background-color:transparent;.c-pill-host:hover &.c-pill-button--ghost,&:focus-visible{background-color:var(--pill-background);}.c-pill-host:hover &.c-pill-button--ghost:hover,&:hover{background-color:var(--pill-background-hover);", "}"], hoverTextStyle);
|
|
22
|
+
case "outlined":
|
|
23
|
+
return css(["background-color:transparent;border:1px solid var(--color-theme-700);&:hover,&:focus-visible{border-color:var(--color-primary);color:var(--color-primary);", "{color:var(--color-primary);}}"], StyledPillIcon);
|
|
24
|
+
default:
|
|
25
|
+
return css(["background-color:var(--pill-background);&:hover,&:focus-visible{background-color:var(--pill-background-hover);", "}"], hoverTextStyle);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const compactStyle = css(["", "{display:none;}"], StyledPillPlaceholder);
|
|
29
|
+
export const StyledPillButton = styled.button.withConfig({
|
|
30
|
+
displayName: "Styles__StyledPillButton",
|
|
31
|
+
componentId: "sc-14yhio0-2"
|
|
32
|
+
})(["", " ", " display:inline-flex;align-items:center;justify-content:center;gap:6px;flex-shrink:0;max-width:100%;height:", ";margin:0;padding:0 ", ";border:none;border-radius:var(--ac-br-rounded);font-size:0.875rem;font-weight:500;line-height:1;white-space:nowrap;color:", ";cursor:pointer;user-select:none;transition:background-color 0.2s ease,color 0.2s ease,border-color 0.2s ease;&:focus{outline:none;}&:disabled{cursor:default;opacity:50%;pointer-events:none;}", " ", " ", " ", " ", " ", " &[aria-haspopup][aria-expanded=\"true\"],.c-pill-host:hover &[aria-haspopup][aria-expanded=\"true\"]{", "}"], FontStyle, BoxSizingStyle, props => props.$size === "small" ? "24px" : "26px", props => props.$inset === "tight" ? "6px" : "10px", props => props.$empty ? "var(--color-theme-700)" : "var(--color-theme-800)", props => toneStyle(props.$tone), props => props.$tone === "ghost" && props.$empty && css(["", ",", "{opacity:0;}.c-pill-host:hover &.c-pill-button--ghost,&:hover,&:focus-visible,&[aria-expanded=\"true\"]{", ",", "{opacity:1;}}"], StyledPillIcon, StyledPillPlaceholder, StyledPillIcon, StyledPillPlaceholder), props => props.$iconOnly && css(["width:36px;padding:0;", " svg{width:16px;height:16px;}"], StyledPillIcon), props => props.$compact === true && compactStyle, props => props.$compact === "mobile" && css(["@media (max-width:768px){", "}"], compactStyle), props => props.$active && css(["&,&:hover,&:focus-visible{", "}"], activeStyle), activeStyle);
|
|
33
|
+
StyledPillButton.displayName = "StyledPillButton";
|
|
34
|
+
//# sourceMappingURL=Styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Styles.js","names":["styled","css","BoxSizingStyle","FontStyle","StyledPillIcon","span","withConfig","displayName","componentId","StyledPillPlaceholder","activeStyle","hoverTextStyle","toneStyle","tone","compactStyle","StyledPillButton","button","props","$size","$inset","$empty","$tone","$iconOnly","$compact","$active"],"sources":["../../../../src/components/PillButton/Styles.ts"],"sourcesContent":["import styled, { css } from \"styled-components\";\n\nimport { PillButtonProps } from \"./PillButton\";\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\nimport { FontStyle } from \"../FontStyle\";\n\ninterface StyledPillButtonProps {\n $tone: NonNullable<PillButtonProps[\"tone\"]>;\n $active: boolean;\n $empty: boolean;\n $iconOnly: boolean;\n $compact: PillButtonProps[\"compact\"];\n $size: NonNullable<PillButtonProps[\"size\"]>;\n $inset: NonNullable<PillButtonProps[\"inset\"]>;\n}\n\nexport const StyledPillIcon = styled.span`\n display: inline-flex;\n flex-shrink: 0;\n color: var(--color-theme-600);\n transition: opacity 0.2s ease, color 0.2s ease;\n\n svg {\n width: 18px;\n height: 18px;\n fill: currentColor;\n }\n`;\n\nStyledPillIcon.displayName = \"StyledPillIcon\";\n\nexport const StyledPillPlaceholder = styled.span`\n overflow: hidden;\n text-overflow: ellipsis;\n transition: opacity 0.2s ease;\n`;\n\nStyledPillPlaceholder.displayName = \"StyledPillPlaceholder\";\n\nconst activeStyle = css`\n background-color: var(--pill-background-active);\n color: var(--color-primary);\n\n ${StyledPillIcon} {\n color: var(--color-primary);\n }\n`;\n\nconst hoverTextStyle = css`\n color: var(--color-theme-900);\n\n ${StyledPillIcon} {\n color: var(--color-theme-900);\n }\n`;\n\nconst toneStyle = (tone: StyledPillButtonProps[\"$tone\"]) => {\n switch (tone) {\n case \"alternate\":\n return css`\n background-color: var(--color-theme-300);\n\n &:hover,\n &:focus-visible {\n background-color: var(--color-theme-400);\n ${hoverTextStyle}\n }\n `;\n case \"ghost\":\n return css`\n background-color: transparent;\n\n .c-pill-host:hover &.c-pill-button--ghost,\n &:focus-visible {\n background-color: var(--pill-background);\n }\n\n .c-pill-host:hover &.c-pill-button--ghost:hover,\n &:hover {\n background-color: var(--pill-background-hover);\n ${hoverTextStyle}\n }\n `;\n case \"outlined\":\n return css`\n background-color: transparent;\n border: 1px solid var(--color-theme-700);\n\n &:hover,\n &:focus-visible {\n border-color: var(--color-primary);\n color: var(--color-primary);\n\n ${StyledPillIcon} {\n color: var(--color-primary);\n }\n }\n `;\n default:\n return css`\n background-color: var(--pill-background);\n\n &:hover,\n &:focus-visible {\n background-color: var(--pill-background-hover);\n ${hoverTextStyle}\n }\n `;\n }\n};\n\nconst compactStyle = css`\n ${StyledPillPlaceholder} {\n display: none;\n }\n`;\n\nexport const StyledPillButton = styled.button<StyledPillButtonProps>`\n ${FontStyle}\n ${BoxSizingStyle}\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n flex-shrink: 0;\n max-width: 100%;\n height: ${(props) => (props.$size === \"small\" ? \"24px\" : \"26px\")};\n margin: 0;\n padding: 0 ${(props) => (props.$inset === \"tight\" ? \"6px\" : \"10px\")};\n border: none;\n border-radius: var(--ac-br-rounded);\n font-size: 0.875rem;\n font-weight: 500;\n line-height: 1;\n white-space: nowrap;\n color: ${(props) =>\n props.$empty ? \"var(--color-theme-700)\" : \"var(--color-theme-800)\"};\n cursor: pointer;\n user-select: none;\n transition: background-color 0.2s ease, color 0.2s ease,\n border-color 0.2s ease;\n\n &:focus {\n outline: none;\n }\n\n &:disabled {\n cursor: default;\n opacity: 50%;\n pointer-events: none;\n }\n\n ${(props) => toneStyle(props.$tone)}\n\n ${(props) =>\n props.$tone === \"ghost\" &&\n props.$empty &&\n css`\n ${StyledPillIcon}, ${StyledPillPlaceholder} {\n opacity: 0;\n }\n\n .c-pill-host:hover &.c-pill-button--ghost,\n &:hover,\n &:focus-visible,\n &[aria-expanded=\"true\"] {\n ${StyledPillIcon}, ${StyledPillPlaceholder} {\n opacity: 1;\n }\n }\n `}\n\n ${(props) =>\n props.$iconOnly &&\n css`\n width: 36px;\n padding: 0;\n\n ${StyledPillIcon} svg {\n width: 16px;\n height: 16px;\n }\n `}\n\n ${(props) => props.$compact === true && compactStyle}\n\n ${(props) =>\n props.$compact === \"mobile\" &&\n css`\n @media (max-width: 768px) {\n ${compactStyle}\n }\n `}\n\n /* An active pill keeps its look on hover and focus. */\n ${(props) =>\n props.$active &&\n css`\n &,\n &:hover,\n &:focus-visible {\n ${activeStyle}\n }\n `}\n\n /* Last, so an open trigger shows the active look in every tone. */\n &[aria-haspopup][aria-expanded=\"true\"],\n .c-pill-host:hover &[aria-haspopup][aria-expanded=\"true\"] {\n ${activeStyle}\n }\n`;\n\nStyledPillButton.displayName = \"StyledPillButton\";\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAG/C,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,SAAS,QAAQ,cAAc;AAYxC,OAAO,MAAMC,cAAc,GAAGJ,MAAM,CAACK,IAAI,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,kKAWxC;AAEDJ,cAAc,CAACG,WAAW,GAAG,gBAAgB;AAE7C,OAAO,MAAME,qBAAqB,GAAGT,MAAM,CAACK,IAAI,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,4EAI/C;AAEDC,qBAAqB,CAACF,WAAW,GAAG,uBAAuB;AAE3D,MAAMG,WAAW,GAAGT,GAAG,kHAInBG,cAAc,CAGjB;AAED,MAAMO,cAAc,GAAGV,GAAG,uEAGtBG,cAAc,CAGjB;AAED,MAAMQ,SAAS,GAAIC,IAAoC,IAAK;EAC1D,QAAQA,IAAI;IACV,KAAK,WAAW;MACd,OAAOZ,GAAG,oHAMJU,cAAc;IAGtB,KAAK,OAAO;MACV,OAAOV,GAAG,kPAWJU,cAAc;IAGtB,KAAK,UAAU;MACb,OAAOV,GAAG,mMASJG,cAAc;IAKtB;MACE,OAAOH,GAAG,0HAMJU,cAAc;EAGxB;AACF,CAAC;AAED,MAAMG,YAAY,GAAGb,GAAG,0BACpBQ,qBAAqB,CAGxB;AAED,OAAO,MAAMM,gBAAgB,GAAGf,MAAM,CAACgB,MAAM,CAAAV,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,8lBACzCL,SAAS,EACTD,cAAc,EAOLe,KAAK,IAAMA,KAAK,CAACC,KAAK,KAAK,OAAO,GAAG,MAAM,GAAG,MAAO,EAElDD,KAAK,IAAMA,KAAK,CAACE,MAAM,KAAK,OAAO,GAAG,KAAK,GAAG,MAAO,EAOzDF,KAAK,IACbA,KAAK,CAACG,MAAM,GAAG,wBAAwB,GAAG,wBAAwB,EAgBjEH,KAAK,IAAKL,SAAS,CAACK,KAAK,CAACI,KAAK,CAAC,EAEhCJ,KAAK,IACNA,KAAK,CAACI,KAAK,KAAK,OAAO,IACvBJ,KAAK,CAACG,MAAM,IACZnB,GAAG,8IACCG,cAAc,EAAKK,qBAAqB,EAQtCL,cAAc,EAAKK,qBAAqB,CAI7C,EAEAQ,KAAK,IACNA,KAAK,CAACK,SAAS,IACfrB,GAAG,6DAICG,cAAc,CAIjB,EAEAa,KAAK,IAAKA,KAAK,CAACM,QAAQ,KAAK,IAAI,IAAIT,YAAY,EAEjDG,KAAK,IACNA,KAAK,CAACM,QAAQ,KAAK,QAAQ,IAC3BtB,GAAG,qCAEGa,YAAY,CAEjB,EAGAG,KAAK,IACNA,KAAK,CAACO,OAAO,IACbvB,GAAG,sCAIGS,WAAW,CAEhB,EAKCA,WAAW,CAEhB;AAEDK,gBAAgB,CAACR,WAAW,GAAG,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/PillButton/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/components/PillButton/index.ts"],"sourcesContent":["export * from \"./PillButton\";\n"],"mappings":"AAAA,cAAc,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
export interface PillGroupProps extends ComponentPropsWithoutRef<"div"> {
|
|
3
|
+
/** "soft" joins filled pills with small gaps. "outlined" puts them in one frame with dividers. */
|
|
4
|
+
appearance?: "soft" | "outlined";
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @component PillGroup
|
|
8
|
+
* @description
|
|
9
|
+
* Joins PillButton children into one segmented control. The outer pills keep their round ends.
|
|
10
|
+
* A child may wrap its pill, for example in a Tooltip or a picker, the group still finds it.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <PillGroup aria-label="Task fields">
|
|
14
|
+
* <PillButton icon={<PersonPlusIcon />} placeholder="Assignee" />
|
|
15
|
+
* <PillButton icon={<CalendarIcon />} placeholder="Dates" />
|
|
16
|
+
* </PillGroup>
|
|
17
|
+
*/
|
|
18
|
+
export declare const PillGroup: React.ForwardRefExoticComponent<PillGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
19
|
+
//# sourceMappingURL=PillGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PillGroup.d.ts","sourceRoot":"","sources":["../../../../src/components/PillGroup/PillGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,wBAAwB,EAAc,MAAM,OAAO,CAAC;AAMpE,MAAM,WAAW,cAAe,SAAQ,wBAAwB,CAAC,KAAK,CAAC;IACrE,kGAAkG;IAClG,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;CAClC;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,uFAgBrB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["appearance", "className", "children"];
|
|
4
|
+
import React, { forwardRef } from "react";
|
|
5
|
+
import classnames from "classnames";
|
|
6
|
+
import { StyledPillGroup } from "./Styles";
|
|
7
|
+
/**
|
|
8
|
+
* @component PillGroup
|
|
9
|
+
* @description
|
|
10
|
+
* Joins PillButton children into one segmented control. The outer pills keep their round ends.
|
|
11
|
+
* A child may wrap its pill, for example in a Tooltip or a picker, the group still finds it.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <PillGroup aria-label="Task fields">
|
|
15
|
+
* <PillButton icon={<PersonPlusIcon />} placeholder="Assignee" />
|
|
16
|
+
* <PillButton icon={<CalendarIcon />} placeholder="Dates" />
|
|
17
|
+
* </PillGroup>
|
|
18
|
+
*/
|
|
19
|
+
export const PillGroup = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
20
|
+
let _ref$appearance = _ref.appearance,
|
|
21
|
+
appearance = _ref$appearance === void 0 ? "soft" : _ref$appearance,
|
|
22
|
+
className = _ref.className,
|
|
23
|
+
children = _ref.children,
|
|
24
|
+
args = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
25
|
+
return /*#__PURE__*/React.createElement(StyledPillGroup, _extends({
|
|
26
|
+
ref: ref,
|
|
27
|
+
role: "group",
|
|
28
|
+
className: classnames("c-pill-group", "c-pill-group--" + appearance, className),
|
|
29
|
+
$appearance: appearance
|
|
30
|
+
}, args), children);
|
|
31
|
+
});
|
|
32
|
+
PillGroup.displayName = "PillGroup";
|
|
33
|
+
//# sourceMappingURL=PillGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PillGroup.js","names":["React","forwardRef","classnames","StyledPillGroup","PillGroup","_ref","ref","_ref$appearance","appearance","className","children","args","_objectWithoutPropertiesLoose","_excluded","createElement","_extends","role","$appearance","displayName"],"sources":["../../../../src/components/PillGroup/PillGroup.tsx"],"sourcesContent":["import React, { ComponentPropsWithoutRef, forwardRef } from \"react\";\n\nimport classnames from \"classnames\";\n\nimport { StyledPillGroup } from \"./Styles\";\n\nexport interface PillGroupProps extends ComponentPropsWithoutRef<\"div\"> {\n /** \"soft\" joins filled pills with small gaps. \"outlined\" puts them in one frame with dividers. */\n appearance?: \"soft\" | \"outlined\";\n}\n\n/**\n * @component PillGroup\n * @description\n * Joins PillButton children into one segmented control. The outer pills keep their round ends.\n * A child may wrap its pill, for example in a Tooltip or a picker, the group still finds it.\n *\n * @example\n * <PillGroup aria-label=\"Task fields\">\n * <PillButton icon={<PersonPlusIcon />} placeholder=\"Assignee\" />\n * <PillButton icon={<CalendarIcon />} placeholder=\"Dates\" />\n * </PillGroup>\n */\nexport const PillGroup = forwardRef<HTMLDivElement, PillGroupProps>(\n ({ appearance = \"soft\", className, children, ...args }, ref) => (\n <StyledPillGroup\n ref={ref}\n role=\"group\"\n className={classnames(\n \"c-pill-group\",\n `c-pill-group--${appearance}`,\n className\n )}\n $appearance={appearance}\n {...args}\n >\n {children}\n </StyledPillGroup>\n )\n);\n\nPillGroup.displayName = \"PillGroup\";\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAA8BC,UAAU,QAAQ,OAAO;AAEnE,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,eAAe,QAAQ,UAAU;AAO1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,gBAAGH,UAAU,CACjC,CAAAI,IAAA,EAAwDC,GAAG;EAAA,IAAAC,eAAA,GAAAF,IAAA,CAAxDG,UAAU;IAAVA,UAAU,GAAAD,eAAA,cAAG,MAAM,GAAAA,eAAA;IAAEE,SAAS,GAAAJ,IAAA,CAATI,SAAS;IAAEC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IAAKC,IAAI,GAAAC,6BAAA,CAAAP,IAAA,EAAAQ,SAAA;EAAA,oBAClDb,KAAA,CAAAc,aAAA,CAACX,eAAe,EAAAY,QAAA;IACdT,GAAG,EAAEA,GAAI;IACTU,IAAI,EAAC,OAAO;IACZP,SAAS,EAAEP,UAAU,CACnB,cAAc,qBACGM,UAAU,EAC3BC,SACF,CAAE;IACFQ,WAAW,EAAET;EAAW,GACpBG,IAAI,GAEPD,QACc,CAAC;AAAA,CAEtB,CAAC;AAEDN,SAAS,CAACc,WAAW,GAAG,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Styles.d.ts","sourceRoot":"","sources":["../../../../src/components/PillGroup/Styles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAM7C,eAAO,MAAM,eAAe;iBACb,WAAW,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;SAqDvD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import { BoxSizingStyle } from "../BoxSizingStyle";
|
|
3
|
+
const first = "& > .c-pill-button:first-child, & > :first-child .c-pill-button";
|
|
4
|
+
const last = "& > .c-pill-button:last-child, & > :last-child .c-pill-button";
|
|
5
|
+
export const StyledPillGroup = styled.div.withConfig({
|
|
6
|
+
displayName: "Styles__StyledPillGroup",
|
|
7
|
+
componentId: "sc-1x5hpq8-0"
|
|
8
|
+
})(["", " display:inline-flex;align-items:stretch;flex-shrink:0;max-width:100%;& > *{display:inline-flex;min-width:0;}.c-pill-button{border-radius:0;}", "{border-top-left-radius:var(--ac-br-rounded);border-bottom-left-radius:var(--ac-br-rounded);}", "{border-top-right-radius:var(--ac-br-rounded);border-bottom-right-radius:var(--ac-br-rounded);}", " ", ""], BoxSizingStyle, first, last, props => props.$appearance === "soft" && css(["gap:2px;"]), props => props.$appearance === "outlined" && css(["border:1px solid var(--pill-border);border-radius:var(--ac-br-6);overflow:hidden;.c-pill-button{height:24px;background-color:transparent;}", ",", "{border-radius:0;}& > * + *{border-left:1px solid var(--pill-border);}"], first, last));
|
|
9
|
+
StyledPillGroup.displayName = "StyledPillGroup";
|
|
10
|
+
//# sourceMappingURL=Styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Styles.js","names":["styled","css","BoxSizingStyle","first","last","StyledPillGroup","div","withConfig","displayName","componentId","props","$appearance"],"sources":["../../../../src/components/PillGroup/Styles.ts"],"sourcesContent":["import styled, { css } from \"styled-components\";\n\nimport { PillGroupProps } from \"./PillGroup\";\nimport { BoxSizingStyle } from \"../BoxSizingStyle\";\n\nconst first = \"& > .c-pill-button:first-child, & > :first-child .c-pill-button\";\nconst last = \"& > .c-pill-button:last-child, & > :last-child .c-pill-button\";\n\nexport const StyledPillGroup = styled.div<{\n $appearance: NonNullable<PillGroupProps[\"appearance\"]>;\n}>`\n ${BoxSizingStyle}\n display: inline-flex;\n align-items: stretch;\n flex-shrink: 0;\n max-width: 100%;\n\n & > * {\n display: inline-flex;\n min-width: 0;\n }\n\n .c-pill-button {\n border-radius: 0;\n }\n\n ${first} {\n border-top-left-radius: var(--ac-br-rounded);\n border-bottom-left-radius: var(--ac-br-rounded);\n }\n\n ${last} {\n border-top-right-radius: var(--ac-br-rounded);\n border-bottom-right-radius: var(--ac-br-rounded);\n }\n\n ${(props) =>\n props.$appearance === \"soft\" &&\n css`\n gap: 2px;\n `}\n\n ${(props) =>\n props.$appearance === \"outlined\" &&\n css`\n border: 1px solid var(--pill-border);\n border-radius: var(--ac-br-6);\n overflow: hidden;\n\n .c-pill-button {\n height: 24px;\n background-color: transparent;\n }\n\n ${first}, ${last} {\n border-radius: 0;\n }\n\n & > * + * {\n border-left: 1px solid var(--pill-border);\n }\n `}\n`;\n\nStyledPillGroup.displayName = \"StyledPillGroup\";\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,GAAG,QAAQ,mBAAmB;AAG/C,SAASC,cAAc,QAAQ,mBAAmB;AAElD,MAAMC,KAAK,GAAG,iEAAiE;AAC/E,MAAMC,IAAI,GAAG,+DAA+D;AAE5E,OAAO,MAAMC,eAAe,GAAGL,MAAM,CAACM,GAAG,CAAAC,UAAA;EAAAC,WAAA;EAAAC,WAAA;AAAA,uWAGrCP,cAAc,EAedC,KAAK,EAKLC,IAAI,EAKHM,KAAK,IACNA,KAAK,CAACC,WAAW,KAAK,MAAM,IAC5BV,GAAG,cAEF,EAEAS,KAAK,IACNA,KAAK,CAACC,WAAW,KAAK,UAAU,IAChCV,GAAG,gOAUCE,KAAK,EAAKC,IAAI,CAOjB,CACJ;AAEDC,eAAe,CAACG,WAAW,GAAG,iBAAiB","ignoreList":[]}
|