@economic/taco 0.0.1-alpha.1543 → 0.0.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Button/Button.d.ts +39 -1
- package/dist/components/Button/util.d.ts +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/Dialog/Context.d.ts +1 -0
- package/dist/components/Dialog/Dialog.d.ts +14 -12
- package/dist/components/Hanger/Hanger.d.ts +4 -9
- package/dist/components/IconButton/IconButton.d.ts +38 -1
- package/dist/components/Navigation/Navigation.d.ts +4 -4
- package/dist/components/Popover/Popover.d.ts +5 -9
- package/dist/components/RadioGroup/RadioGroup.d.ts +2 -2
- package/dist/components/Select/Select.d.ts +4 -0
- package/dist/components/Select/useSelect.d.ts +1 -1
- package/dist/components/Table/Table.storyexample.d.ts +1 -1
- package/dist/components/Table/components/PaginatedTable.d.ts +2 -2
- package/dist/components/Table/components/Table.d.ts +2 -2
- package/dist/components/Table/components/WindowedTable.d.ts +2 -2
- package/dist/components/Table/types.d.ts +2 -2
- package/dist/components/Tabs/Tabs.d.ts +2 -2
- package/dist/components/Tooltip/Tooltip.d.ts +11 -1
- package/dist/components/Treeview/Treeview.d.ts +2 -2
- package/dist/esm/index.css +70 -93
- package/dist/esm/src/components/Button/Button.js +6 -9
- package/dist/esm/src/components/Button/Button.js.map +1 -1
- package/dist/esm/src/components/Button/util.js +42 -1
- package/dist/esm/src/components/Button/util.js.map +1 -1
- package/dist/esm/src/components/Calendar/Calendar.js +1 -1
- package/dist/esm/src/components/Checkbox/Checkbox.js +9 -1
- package/dist/esm/src/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/esm/src/components/Combobox/useCombobox.js +1 -1
- package/dist/esm/src/components/Datepicker/Datepicker.js +2 -2
- package/dist/esm/src/components/Dialog/Context.js +1 -0
- package/dist/esm/src/components/Dialog/Context.js.map +1 -1
- package/dist/esm/src/components/Dialog/Dialog.js +5 -4
- package/dist/esm/src/components/Dialog/Dialog.js.map +1 -1
- package/dist/esm/src/components/Dialog/components/Content.js +5 -5
- package/dist/esm/src/components/Dialog/components/Content.js.map +1 -1
- package/dist/esm/src/components/Dialog/components/Trigger.js +2 -1
- package/dist/esm/src/components/Dialog/components/Trigger.js.map +1 -1
- package/dist/esm/src/components/Hanger/Hanger.js +12 -9
- package/dist/esm/src/components/Hanger/Hanger.js.map +1 -1
- package/dist/esm/src/components/IconButton/IconButton.js +9 -11
- package/dist/esm/src/components/IconButton/IconButton.js.map +1 -1
- package/dist/esm/src/components/Listbox/ScrollableList.js +1 -1
- package/dist/esm/src/components/Navigation/Navigation.js +4 -4
- package/dist/esm/src/components/Navigation/Navigation.js.map +1 -1
- package/dist/esm/src/components/Pagination/PageNumbers.js +1 -1
- package/dist/esm/src/components/Pagination/Pagination.js +1 -1
- package/dist/esm/src/components/Popover/Popover.js +9 -6
- package/dist/esm/src/components/Popover/Popover.js.map +1 -1
- package/dist/esm/src/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/src/components/SearchInput/SearchInput.js +7 -7
- package/dist/esm/src/components/Select/Select.js +2 -1
- package/dist/esm/src/components/Select/Select.js.map +1 -1
- package/dist/esm/src/components/Select/useSelect.js +12 -5
- package/dist/esm/src/components/Select/useSelect.js.map +1 -1
- package/dist/esm/src/components/Table/components/PaginatedTable.js.map +1 -1
- package/dist/esm/src/components/Table/components/Table.js.map +1 -1
- package/dist/esm/src/components/Table/components/WindowedTable.js.map +1 -1
- package/dist/esm/src/components/Table/hooks/plugins/useRowActions.js +11 -5
- package/dist/esm/src/components/Table/hooks/plugins/useRowActions.js.map +1 -1
- package/dist/esm/src/components/Table/hooks/plugins/useRowSelect.js +3 -3
- package/dist/esm/src/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
- package/dist/esm/src/components/Table/util/renderColumn.js +4 -3
- package/dist/esm/src/components/Table/util/renderColumn.js.map +1 -1
- package/dist/esm/src/components/Table/util/renderRow.js +4 -3
- package/dist/esm/src/components/Table/util/renderRow.js.map +1 -1
- package/dist/esm/src/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/src/components/Toast/Toast.js +1 -1
- package/dist/esm/src/components/Tooltip/Tooltip.js +11 -10
- package/dist/esm/src/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/src/components/Tour/Tour.js +2 -2
- package/dist/esm/src/components/Treeview/Treeview.js.map +1 -1
- package/dist/esm/src/index.js +7 -7
- package/dist/esm/src/primitives/Button.js +2 -12
- package/dist/esm/src/primitives/Button.js.map +1 -1
- package/dist/esm/src/utils/mergeRefs.js +14 -0
- package/dist/esm/src/utils/mergeRefs.js.map +1 -0
- package/dist/index.css +70 -93
- package/dist/primitives/Button.d.ts +0 -4
- package/dist/taco.cjs.development.js +1629 -1565
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/dist/utils/mergeRefs.d.ts +2 -0
- package/package.json +4 -3
- package/types.json +7309 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Content.js","sources":["../../../../../../src/components/Dialog/components/Content.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { useProxiedRef } from '../../../utils/hooks/useProxiedRef';\nimport { useDraggable } from '../../../utils/hooks/useDraggable';\nimport { useCurrentMenu } from '../../Menu/Context';\nimport { useCurrentDialog } from '../Context';\nimport { useLocalization } from '../../Provider/Provider';\nimport { IconButton } from '../../IconButton/IconButton';\nimport { Group } from '../../Group/Group';\n\nexport type DialogContentRenderProps = {\n close: () => void;\n drawer?: {\n open: boolean;\n toggle: () => void;\n };\n};\n\nexport type DialogTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: DialogTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n return <DialogPrimitive.Title {...props} className=\"text-center\" ref={ref} />;\n});\n\nexport type DialogFooterProps = React.HTMLAttributes<HTMLDivElement>;\nexport const Footer = React.forwardRef(function DialogFooter(props: DialogFooterProps, ref: React.Ref<HTMLDivElement>) {\n return (\n <div {...props} className=\"flex justify-end
|
1
|
+
{"version":3,"file":"Content.js","sources":["../../../../../../src/components/Dialog/components/Content.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { useProxiedRef } from '../../../utils/hooks/useProxiedRef';\nimport { useDraggable } from '../../../utils/hooks/useDraggable';\nimport { useCurrentMenu } from '../../Menu/Context';\nimport { useCurrentDialog } from '../Context';\nimport { useLocalization } from '../../Provider/Provider';\nimport { IconButton } from '../../IconButton/IconButton';\nimport { Group } from '../../Group/Group';\n\nexport type DialogContentRenderProps = {\n close: () => void;\n drawer?: {\n open: boolean;\n toggle: () => void;\n };\n};\n\nexport type DialogTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function DialogTitle(props: DialogTitleProps, ref: React.Ref<HTMLHeadingElement>) {\n return <DialogPrimitive.Title {...props} className=\"text-center\" ref={ref} />;\n});\n\nexport type DialogFooterProps = React.HTMLAttributes<HTMLDivElement>;\nexport const Footer = React.forwardRef(function DialogFooter(props: DialogFooterProps, ref: React.Ref<HTMLDivElement>) {\n return (\n <div {...props} className=\"mt-8 flex justify-end\" ref={ref}>\n <Group>{props.children}</Group>\n </div>\n );\n});\n\nexport type DialogCloseProps = React.HTMLAttributes<HTMLButtonElement>;\n\nexport const Close = React.forwardRef(function DialogClose(props: DialogCloseProps, ref: React.Ref<HTMLButtonElement>) {\n const dialog = useCurrentDialog();\n\n return <DialogPrimitive.Close onClick={dialog.onClose} {...props} ref={ref} asChild />;\n});\n\nexport type DialogContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** An accessible description to be announced when the dialog is opened */\n 'aria-describedby': string;\n children: Omit<React.ReactNode, 'Function'> | ((props: DialogContentRenderProps) => JSX.Element);\n};\nexport const Content = React.forwardRef(function DialogContent(props: DialogContentProps, ref: React.Ref<HTMLDivElement>) {\n const dialog = useCurrentDialog();\n const internalRef = useProxiedRef<HTMLDivElement>(ref);\n const { position, handleProps: dragHandleProps } = useDraggable(internalRef);\n const { texts } = useLocalization();\n\n // if the dialog was opened by a menu, we need to close the menu when the dialog closes\n // the menu is still open (and mounted) because it is the trigger for the dialog\n const menu = useCurrentMenu();\n let handleCloseAutoFocus;\n\n if (menu) {\n handleCloseAutoFocus = () => menu.close();\n }\n\n const className = cn('bg-white rounded mt-16 mx-auto', {\n 'w-128 text-center justify-center': dialog.size === 'dialog',\n 'w-xs': dialog.size === 'xs',\n 'w-sm': dialog.size === 'sm',\n 'w-md': dialog.size === 'md',\n 'w-lg': dialog.size === 'lg',\n });\n\n const containerClassName = cn(\n 'yt-dialog bg-white p-6 rounded relative z-[999]',\n 'shadow-[0_6px_9px_0_rgba(89,85,98,0.3),0_0_1px_0_rgba(89,85,98,0.2)]',\n {\n 'rounded-b-none': !!dialog.elements.extra,\n },\n props.className\n );\n\n const overlayClassName = cn(\n 'fixed inset-0 cursor-default overflow-y-auto bg-[rgba(50,46,62,0.8)] animate-[fade-in_150ms] aria-hidden:hidden'\n );\n\n // the chosen behaviour in taco is that outside clicks do not close the dialog\n const handleInteractOutside = event => event.preventDefault();\n\n let output;\n\n if (typeof props.children === 'function') {\n output = props.children({ drawer: dialog.drawer, close: dialog.close });\n } else {\n output = props.children;\n }\n\n return (\n <DialogPrimitive.Portal>\n <DialogPrimitive.Overlay className={overlayClassName}>\n <DialogPrimitive.Content\n {...props}\n className={className}\n data-taco=\"dialog\"\n onEscapeKeyDown={dialog.onClose}\n onInteractOutside={handleInteractOutside}\n onCloseAutoFocus={handleCloseAutoFocus}\n ref={ref}\n style={{\n ...props.style,\n left: dialog.draggable ? `calc(50% + ${position.x}px)` : undefined,\n top: dialog.draggable ? `calc(50% + ${position.y}px)` : undefined,\n }}\n >\n <div className={containerClassName}>\n {output}\n {dialog.draggable && (\n <div\n {...dragHandleProps}\n aria-label={texts.dialog.drag}\n className=\"yt-dialog__drag absolute-center-x bg-grey-light top-1.5 h-3 w-24 cursor-move rounded text-center\"\n />\n )}\n <DialogPrimitive.Close asChild onClick={dialog.onClose}>\n <IconButton\n appearance=\"discrete\"\n aria-label={texts.dialog.close}\n className=\"absolute top-0 right-0 mt-2 mr-2\"\n icon=\"close\"\n />\n </DialogPrimitive.Close>\n </div>\n {dialog.elements.drawer}\n {dialog.elements.extra}\n </DialogPrimitive.Content>\n </DialogPrimitive.Overlay>\n </DialogPrimitive.Portal>\n );\n});\n"],"names":["Title","React","DialogTitle","props","ref","DialogPrimitive","className","Footer","DialogFooter","Group","children","Close","DialogClose","dialog","useCurrentDialog","onClick","onClose","asChild","Content","DialogContent","internalRef","useProxiedRef","useDraggable","position","dragHandleProps","handleProps","useLocalization","texts","menu","useCurrentMenu","handleCloseAutoFocus","close","cn","size","containerClassName","elements","extra","overlayClassName","handleInteractOutside","event","preventDefault","output","drawer","onEscapeKeyDown","onInteractOutside","onCloseAutoFocus","style","left","draggable","x","undefined","top","y","drag","IconButton","appearance","icon"],"mappings":";;;;;;;;;;;;IAoBaA,KAAK,gBAAGC,UAAA,CAAiB,SAASC,WAAT,CAAqBC,KAArB,EAA8CC,GAA9C;AAClC,SAAOH,aAAA,CAACI,OAAD,oBAA2BF;AAAOG,IAAAA,SAAS,EAAC;AAAcF,IAAAA,GAAG,EAAEA;IAA/D,CAAP;AACH,CAFoB;IAKRG,MAAM,gBAAGN,UAAA,CAAiB,SAASO,YAAT,CAAsBL,KAAtB,EAAgDC,GAAhD;AACnC,SACIH,aAAA,MAAA,oBAASE;AAAOG,IAAAA,SAAS,EAAC;AAAwBF,IAAAA,GAAG,EAAEA;IAAvD,EACIH,aAAA,CAACQ,KAAD,MAAA,EAAQN,KAAK,CAACO,QAAd,CADJ,CADJ;AAKH,CANqB;IAUTC,KAAK,gBAAGV,UAAA,CAAiB,SA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,CAHR,EASIL,aAAA,CAACI,OAAD;AAAuBY,IAAAA,OAAO;AAACF,IAAAA,OAAO,EAAEF,MAAM,CAACG;GAA/C,EACIf,aAAA,CAACqD,UAAD;AACIC,IAAAA,UAAU,EAAC;kBACC5B,KAAK,CAACd,MAAN,CAAakB;AACzBzB,IAAAA,SAAS,EAAC;AACVkD,IAAAA,IAAI,EAAC;GAJT,CADJ,CATJ,CAdJ,EAgCK3C,MAAM,CAACsB,QAAP,CAAgBO,MAhCrB,EAiCK7B,MAAM,CAACsB,QAAP,CAAgBC,KAjCrB,CADJ,CADJ,CADJ;AAyCH,CAxFsB;;;;"}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
import { forwardRef, createElement } from 'react';
|
2
|
+
import mergeRefs from '../../../utils/mergeRefs.js';
|
2
3
|
import { Trigger as Trigger$1 } from '@radix-ui/react-dialog';
|
3
4
|
import { useCurrentDialog } from '../Context.js';
|
4
5
|
|
5
6
|
var Trigger = /*#__PURE__*/forwardRef(function DialogTrigger(props, ref) {
|
6
7
|
var dialog = useCurrentDialog();
|
7
8
|
return createElement(Trigger$1, Object.assign({}, dialog.props, props, {
|
8
|
-
ref: ref,
|
9
|
+
ref: mergeRefs([dialog.ref, ref]),
|
9
10
|
asChild: true
|
10
11
|
}));
|
11
12
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Trigger.js","sources":["../../../../../../src/components/Dialog/components/Trigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { useCurrentDialog } from '../Context';\n\nexport type DialogTriggerProps = React.HTMLAttributes<HTMLButtonElement>;\n\nexport const Trigger = React.forwardRef(function DialogTrigger(props: DialogTriggerProps, ref: React.Ref<HTMLButtonElement>) {\n const dialog = useCurrentDialog();\n return <DialogPrimitive.Trigger {...dialog.props} {...props} ref={ref} asChild />;\n});\n"],"names":["Trigger","React","DialogTrigger","props","ref","dialog","useCurrentDialog","DialogPrimitive","asChild"],"mappings":"
|
1
|
+
{"version":3,"file":"Trigger.js","sources":["../../../../../../src/components/Dialog/components/Trigger.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { useCurrentDialog } from '../Context';\nimport mergeRefs from '../../../utils/mergeRefs';\n\nexport type DialogTriggerProps = React.HTMLAttributes<HTMLButtonElement>;\n\nexport const Trigger = React.forwardRef(function DialogTrigger(props: DialogTriggerProps, ref: React.Ref<HTMLButtonElement>) {\n const dialog = useCurrentDialog();\n return <DialogPrimitive.Trigger {...dialog.props} {...props} ref={mergeRefs([dialog.ref, ref])} asChild />;\n});\n"],"names":["Trigger","React","DialogTrigger","props","ref","dialog","useCurrentDialog","DialogPrimitive","mergeRefs","asChild"],"mappings":";;;;;IAOaA,OAAO,gBAAGC,UAAA,CAAiB,SAASC,aAAT,CAAuBC,KAAvB,EAAkDC,GAAlD;AACpC,MAAMC,MAAM,GAAGC,gBAAgB,EAA/B;AACA,SAAOL,aAAA,CAACM,SAAD,oBAA6BF,MAAM,CAACF,OAAWA;AAAOC,IAAAA,GAAG,EAAEI,SAAS,CAAC,CAACH,MAAM,CAACD,GAAR,EAAaA,GAAb,CAAD;AAAqBK,IAAAA,OAAO;IAAhG,CAAP;AACH,CAHsB;;;;"}
|
@@ -1,19 +1,21 @@
|
|
1
1
|
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
2
|
-
import { useMemo, createElement, createContext,
|
2
|
+
import { forwardRef, useMemo, createElement, createContext, useContext } from 'react';
|
3
3
|
import cn from 'classnames';
|
4
|
-
import { IconButton } from '../IconButton/IconButton.js';
|
5
|
-
import { useLocalization } from '../Provider/Provider.js';
|
6
4
|
import { Root, Anchor as Anchor$1, Close } from '@radix-ui/react-popover';
|
7
5
|
import { UnstyledContent, UnstyledArrow } from '../Popover/Primitives.js';
|
6
|
+
import { useLocalization } from '../Provider/Provider.js';
|
7
|
+
import mergeRefs from '../../utils/mergeRefs.js';
|
8
|
+
import { IconButton } from '../IconButton/IconButton.js';
|
8
9
|
|
9
10
|
var _excluded = ["children"];
|
10
11
|
var HangerContext = /*#__PURE__*/createContext({
|
11
|
-
props: {}
|
12
|
+
props: {},
|
13
|
+
ref: null
|
12
14
|
});
|
13
15
|
var Anchor = /*#__PURE__*/forwardRef(function (props, ref) {
|
14
16
|
var context = useContext(HangerContext);
|
15
17
|
return createElement(Anchor$1, Object.assign({}, context.props, props, {
|
16
|
-
ref: ref,
|
18
|
+
ref: mergeRefs([context.ref, ref]),
|
17
19
|
asChild: true
|
18
20
|
}));
|
19
21
|
});
|
@@ -40,18 +42,19 @@ var Content = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
40
42
|
}, createElement(IconButton, {
|
41
43
|
appearance: "primary",
|
42
44
|
"aria-label": texts.hanger.close,
|
43
|
-
className: "
|
45
|
+
className: "absolute top-0 right-0 ml-2 mr-2 mt-2 text-white",
|
44
46
|
icon: "close",
|
45
47
|
onClick: props.onClose
|
46
48
|
})));
|
47
49
|
});
|
48
|
-
var Hanger = function
|
50
|
+
var Hanger = /*#__PURE__*/forwardRef(function (props, ref) {
|
49
51
|
var children = props.children,
|
50
52
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
51
53
|
|
52
54
|
var context = useMemo(function () {
|
53
55
|
return {
|
54
|
-
props: otherProps
|
56
|
+
props: otherProps,
|
57
|
+
ref: ref
|
55
58
|
};
|
56
59
|
}, [otherProps]);
|
57
60
|
return createElement(HangerContext.Provider, {
|
@@ -60,7 +63,7 @@ var Hanger = function Hanger(props) {
|
|
60
63
|
children: children,
|
61
64
|
defaultOpen: true
|
62
65
|
}));
|
63
|
-
};
|
66
|
+
});
|
64
67
|
Hanger.Anchor = Anchor;
|
65
68
|
Hanger.Content = Content;
|
66
69
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Hanger.js","sources":["../../../../../src/components/Hanger/Hanger.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { IconButton } from '../IconButton/IconButton';\nimport { Placement } from '../..';\nimport { UnstyledArrow, UnstyledContent } from '../Popover/Primitives';\nimport { useLocalization } from '../Provider/Provider';\nimport './Hanger.css';\n\nconst HangerContext = React.createContext({\n props: {},\n});\n\nexport type HangerTexts = {\n /** Aria-label for the close icon button of hanger */\n close: string;\n};\n\nexport type HangerAnchorProps = React.HTMLAttributes<HTMLDivElement>;\nconst Anchor = React.forwardRef((props: HangerAnchorProps, ref: React.Ref<HTMLDivElement>) => {\n const context = React.useContext(HangerContext);\n return <PopoverPrimitive.Anchor {...context.props} {...props} ref={ref} asChild />;\n});\n\nexport type CloseHandler = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | undefined;\nexport type HangerContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Handler called when user closes the hanger */\n onClose?: CloseHandler;\n /** Set the position of the Hanger relative to its achor. Default value is `bottom` */\n placement?: Placement;\n};\n\nconst Content = React.forwardRef((props: HangerContentProps, ref: React.Ref<HTMLDivElement>) => {\n const { texts } = useLocalization();\n const className = cn(\n 'wcag-blue border border-transparent rounded p-3 pr-12 yt-shadow z-[996] focus:border-transparent',\n props.className\n );\n const handleInteractOutside = (event: CustomEvent): void => {\n event.preventDefault();\n };\n\n return (\n <UnstyledContent\n className={className}\n data-taco=\"hanger\"\n onInteractOutside={handleInteractOutside}\n placement={props.placement}\n ref={ref}\n >\n {props.children}\n <UnstyledArrow className=\"text-blue\" />\n <PopoverPrimitive.Close asChild>\n <IconButton\n appearance=\"primary\"\n aria-label={texts.hanger.close}\n className=\"
|
1
|
+
{"version":3,"file":"Hanger.js","sources":["../../../../../src/components/Hanger/Hanger.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { IconButton } from '../IconButton/IconButton';\nimport { Placement } from '../..';\nimport { UnstyledArrow, UnstyledContent } from '../Popover/Primitives';\nimport { useLocalization } from '../Provider/Provider';\nimport './Hanger.css';\nimport mergeRefs from '../../utils/mergeRefs';\n\ntype HangerContextValue = {\n props: any;\n ref: React.Ref<HTMLElement>;\n};\nconst HangerContext = React.createContext<HangerContextValue>({\n props: {},\n ref: null,\n});\n\nexport type HangerTexts = {\n /** Aria-label for the close icon button of hanger */\n close: string;\n};\n\nexport type HangerAnchorProps = React.HTMLAttributes<HTMLDivElement>;\nconst Anchor = React.forwardRef((props: HangerAnchorProps, ref: React.Ref<HTMLDivElement>) => {\n const context = React.useContext(HangerContext);\n return <PopoverPrimitive.Anchor {...context.props} {...props} ref={mergeRefs([context.ref, ref])} asChild />;\n});\n\nexport type CloseHandler = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | undefined;\nexport type HangerContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Handler called when user closes the hanger */\n onClose?: CloseHandler;\n /** Set the position of the Hanger relative to its achor. Default value is `bottom` */\n placement?: Placement;\n};\n\nconst Content = React.forwardRef((props: HangerContentProps, ref: React.Ref<HTMLDivElement>) => {\n const { texts } = useLocalization();\n const className = cn(\n 'wcag-blue border border-transparent rounded p-3 pr-12 yt-shadow z-[996] focus:border-transparent',\n props.className\n );\n const handleInteractOutside = (event: CustomEvent): void => {\n event.preventDefault();\n };\n\n return (\n <UnstyledContent\n className={className}\n data-taco=\"hanger\"\n onInteractOutside={handleInteractOutside}\n placement={props.placement}\n ref={ref}\n >\n {props.children}\n <UnstyledArrow className=\"text-blue\" />\n <PopoverPrimitive.Close asChild>\n <IconButton\n appearance=\"primary\"\n aria-label={texts.hanger.close}\n className=\"absolute top-0 right-0 ml-2 mr-2 mt-2 text-white\"\n icon=\"close\"\n onClick={props.onClose}\n />\n </PopoverPrimitive.Close>\n </UnstyledContent>\n );\n});\n\nexport type HangerProps = React.PropsWithChildren<{}>;\n\nexport type ForwardedHangerWithStatics = React.ForwardRefExoticComponent<HangerProps & React.RefAttributes<HTMLElement>> & {\n Anchor: React.ForwardRefExoticComponent<HangerAnchorProps>;\n Content: React.ForwardRefExoticComponent<HangerContentProps>;\n};\n\nexport const Hanger = React.forwardRef((props: HangerProps, ref: React.Ref<HTMLElement>): JSX.Element => {\n const { children, ...otherProps } = props;\n\n const context = React.useMemo(() => ({ props: otherProps, ref }), [otherProps]);\n\n return (\n <HangerContext.Provider value={context}>\n <PopoverPrimitive.Root children={children} defaultOpen />\n </HangerContext.Provider>\n );\n}) as ForwardedHangerWithStatics;\nHanger.Anchor = Anchor;\nHanger.Content = Content;\n"],"names":["HangerContext","React","props","ref","Anchor","context","PopoverPrimitive","mergeRefs","asChild","Content","useLocalization","texts","className","cn","handleInteractOutside","event","preventDefault","UnstyledContent","onInteractOutside","placement","children","UnstyledArrow","IconButton","appearance","hanger","close","icon","onClick","onClose","Hanger","otherProps","Provider","value","defaultOpen"],"mappings":";;;;;;;;;;AAcA,IAAMA,aAAa,gBAAGC,aAAA,CAAwC;AAC1DC,EAAAA,KAAK,EAAE,EADmD;AAE1DC,EAAAA,GAAG,EAAE;AAFqD,CAAxC,CAAtB;AAWA,IAAMC,MAAM,gBAAGH,UAAA,CAAiB,UAACC,KAAD,EAA2BC,GAA3B;AAC5B,MAAME,OAAO,GAAGJ,UAAA,CAAiBD,aAAjB,CAAhB;AACA,SAAOC,aAAA,CAACK,QAAD,oBAA6BD,OAAO,CAACH,OAAWA;AAAOC,IAAAA,GAAG,EAAEI,SAAS,CAAC,CAACF,OAAO,CAACF,GAAT,EAAcA,GAAd,CAAD;AAAsBK,IAAAA,OAAO;IAAlG,CAAP;AACH,CAHc,CAAf;AAaA,IAAMC,OAAO,gBAAGR,UAAA,CAAiB,UAACC,KAAD,EAA4BC,GAA5B;AAC7B,yBAAkBO,eAAe,EAAjC;AAAA,MAAQC,KAAR,oBAAQA,KAAR;;AACA,MAAMC,SAAS,GAAGC,EAAE,CAChB,kGADgB,EAEhBX,KAAK,CAACU,SAFU,CAApB;;AAIA,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,OAAjB;;;;"}
|
@@ -1,9 +1,8 @@
|
|
1
|
-
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
1
|
+
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
2
2
|
import { forwardRef, createElement } from 'react';
|
3
3
|
import cn from 'classnames';
|
4
4
|
import { Icon } from '../Icon/Icon.js';
|
5
|
-
import {
|
6
|
-
import { getButtonClasses, getAppearanceClasses } from '../Button/util.js';
|
5
|
+
import { getButtonClasses, getAppearanceClasses, createButton } from '../Button/util.js';
|
7
6
|
|
8
7
|
var _excluded = ["appearance", "icon", "rounded"];
|
9
8
|
var IconButton = /*#__PURE__*/forwardRef(function IconButton(props, ref) {
|
@@ -24,14 +23,13 @@ var IconButton = /*#__PURE__*/forwardRef(function IconButton(props, ref) {
|
|
24
23
|
return null;
|
25
24
|
}
|
26
25
|
|
27
|
-
return
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
}));
|
26
|
+
return createButton(_extends({}, otherProps, {
|
27
|
+
children: createElement(Icon, {
|
28
|
+
name: icon,
|
29
|
+
className: "m-0 p-0"
|
30
|
+
}),
|
31
|
+
'data-taco': 'icon-button'
|
32
|
+
}), className, ref);
|
35
33
|
});
|
36
34
|
|
37
35
|
export { IconButton };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"IconButton.js","sources":["../../../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { getAppearanceClasses, getButtonClasses } from '../Button/util';\nimport { Appearance } from '../../types';\n\nexport type IconButtonProps = Omit<ButtonPrimitive.ButtonProps, 'children'> & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /** Set which icon should be rendered within button */\n icon: IconName; // this dynamic type causes the type extraction for props to fail\n /**\n * Set whether the button is rounded.\n * Default value is `false`\n */\n rounded?: boolean;\n};\n\nexport const IconButton = React.forwardRef(function IconButton(props: IconButtonProps, ref: React.Ref<HTMLButtonElement>) {\n const { appearance, icon, rounded = false, ...otherProps } = props;\n\n const className = cn(\n getButtonClasses(),\n getAppearanceClasses(appearance, true),\n {\n 'rounded-full': rounded,\n rounded: !rounded,\n 'cursor-not-allowed opacity-50': props.disabled,\n 'focus:yt-focus active:focus:yt-focus': !props.disabled,\n },\n props.className\n );\n\n if (!icon) {\n return null;\n }\n\n return (\n
|
1
|
+
{"version":3,"file":"IconButton.js","sources":["../../../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { getAppearanceClasses, getButtonClasses, createButton } from '../Button/util';\nimport { Appearance } from '../../types';\nimport { DialogProps, HangerProps, PopoverProps } from '../..';\n\nexport type IconButtonProps = Omit<ButtonPrimitive.ButtonProps, 'children'> & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /**\n * Dialog component associated with the button, clicking the button will open the dialog.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated dialog when clicked.\n */\n dialog?: React.ReactElement<DialogProps>;\n /** Set which icon should be rendered within button */\n icon: IconName; // this dynamic type causes the type extraction for props to fail\n /** Hanger component associated with the button. */\n hanger?: React.ReactElement<HangerProps>;\n /**\n * Popover component associated with the button, clicking the button will open the popover.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated popover when clicked.\n */\n popover?: React.ReactElement<PopoverProps>;\n /**\n * Set whether the button is rounded.\n * Default value is `false`\n */\n rounded?: boolean;\n /** A tooltip to show when hovering over the button */\n tooltip?: string;\n};\n\nexport const IconButton = React.forwardRef(function IconButton(props: IconButtonProps, ref: React.Ref<HTMLButtonElement>) {\n const { appearance, icon, rounded = false, ...otherProps } = props;\n\n const className = cn(\n getButtonClasses(),\n getAppearanceClasses(appearance, true),\n {\n 'rounded-full': rounded,\n rounded: !rounded,\n 'cursor-not-allowed opacity-50': props.disabled,\n 'focus:yt-focus active:focus:yt-focus': !props.disabled,\n },\n props.className\n );\n\n if (!icon) {\n return null;\n }\n\n return createButton(\n { ...otherProps, children: <Icon name={icon} className=\"m-0 p-0\" />, 'data-taco': 'icon-button' },\n className,\n ref\n );\n});\n"],"names":["IconButton","React","props","ref","appearance","icon","rounded","otherProps","className","cn","getButtonClasses","getAppearanceClasses","disabled","createButton","children","Icon","name"],"mappings":";;;;;;;IAoCaA,UAAU,gBAAGC,UAAA,CAAiB,SAASD,UAAT,CAAoBE,KAApB,EAA4CC,GAA5C;AACvC,MAAQC,UAAR,GAA6DF,KAA7D,CAAQE,UAAR;AAAA,MAAoBC,IAApB,GAA6DH,KAA7D,CAAoBG,IAApB;AAAA,uBAA6DH,KAA7D,CAA0BI,OAA1B;AAAA,MAA0BA,OAA1B,+BAAoC,KAApC;AAAA,MAA8CC,UAA9C,iCAA6DL,KAA7D;;AAEA,MAAMM,SAAS,GAAGC,EAAE,CAChBC,gBAAgB,EADA,EAEhBC,oBAAoB,CAACP,UAAD,EAAa,IAAb,CAFJ,EAGhB;AACI,oBAAgBE,OADpB;AAEIA,IAAAA,OAAO,EAAE,CAACA,OAFd;AAGI,qCAAiCJ,KAAK,CAACU,QAH3C;AAII,4CAAwC,CAACV,KAAK,CAACU;AAJnD,GAHgB,EAShBV,KAAK,CAACM,SATU,CAApB;;AAYA,MAAI,CAACH,IAAL,EAAW;AACP,WAAO,IAAP;AACH;;AAED,SAAOQ,YAAY,cACVN,UADU;AACEO,IAAAA,QAAQ,EAAEb,aAAA,CAACc,IAAD;AAAMC,MAAAA,IAAI,EAAEX;AAAMG,MAAAA,SAAS,EAAC;KAA5B,CADZ;AACsD,iBAAa;AADnE,MAEfA,SAFe,EAGfL,GAHe,CAAnB;AAKH,CAxByB;;;;"}
|
@@ -3,8 +3,8 @@ import { forwardRef, useMemo, createRef, useEffect, createElement } from 'react'
|
|
3
3
|
import cn from 'classnames';
|
4
4
|
import { Spinner } from '../Spinner/Spinner.js';
|
5
5
|
import { useLocalization } from '../Provider/Provider.js';
|
6
|
-
import { Checkbox } from '../Checkbox/Checkbox.js';
|
7
6
|
import { useProxiedRef } from '../../utils/hooks/useProxiedRef.js';
|
7
|
+
import { Checkbox } from '../Checkbox/Checkbox.js';
|
8
8
|
import { getInputClasses } from '../Input/util.js';
|
9
9
|
import { getNextIndexFromKeycode } from '../../utils/hooks/useListKeyboardNavigation.js';
|
10
10
|
import { useListScrollTo } from '../../utils/hooks/useListScrollTo.js';
|
@@ -49,7 +49,7 @@ var Item = /*#__PURE__*/React__default.forwardRef(function Item(props, ref) {
|
|
49
49
|
}), prefix && React__default.createElement("span", {
|
50
50
|
className: "yt-navigation__item__prefix flex items-center"
|
51
51
|
}, prefix), React__default.createElement("a", Object.assign({}, otherProps, {
|
52
|
-
className: "flex-grow
|
52
|
+
className: "block flex-grow truncate",
|
53
53
|
ref: proxyRef
|
54
54
|
}), children), postfix && React__default.createElement("span", {
|
55
55
|
className: "yt-navigation__item__postfix ml-1"
|
@@ -57,7 +57,7 @@ var Item = /*#__PURE__*/React__default.forwardRef(function Item(props, ref) {
|
|
57
57
|
});
|
58
58
|
var Panel = /*#__PURE__*/React__default.forwardRef(function Panel(props, ref) {
|
59
59
|
return React__default.createElement("div", Object.assign({}, props, {
|
60
|
-
className: cn('bg-white p-3
|
60
|
+
className: cn('w-full bg-white p-3', props.className),
|
61
61
|
ref: ref
|
62
62
|
}));
|
63
63
|
});
|
@@ -105,11 +105,11 @@ var Menu = /*#__PURE__*/React__default.forwardRef(function Menu(props, ref) {
|
|
105
105
|
return scrollableAreas;
|
106
106
|
}, [props.children]);
|
107
107
|
return React__default.createElement(Treeview, Object.assign({}, props, {
|
108
|
-
className: cn('
|
108
|
+
className: cn('divide-grey-light flex flex-grow flex-col divide-y-2 overflow-y-auto', props.className),
|
109
109
|
ref: ref
|
110
110
|
}), scrollableAreas.map(function (area, i) {
|
111
111
|
return Array.isArray(area) ? React__default.createElement("div", {
|
112
|
-
className: "flex
|
112
|
+
className: "divide-grey-light flex h-0 flex-auto flex-shrink-0 flex-grow flex-col divide-y-2 overflow-y-auto",
|
113
113
|
key: i
|
114
114
|
}, area) : area;
|
115
115
|
}));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Navigation.js","sources":["../../../../../src/components/Navigation/Navigation.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { TreeviewProps, Treeview, TreeviewGroupProps, TreeviewItemProps } from '../Treeview/Treeview';\nimport { Icon } from '../Icon/Icon';\nimport { useDropTarget } from '../../utils/hooks/useDropTarget';\nimport './Navigation.css';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\n\n// Item\nexport type NavigationItemProps = Omit<TreeviewItemProps, 'prefix'> & {\n /** Change the style to indicate the link is selected */\n active?: boolean;\n /** Handler to be used when dropping a dragged element over the navigation link */\n onDrop?: React.DragEventHandler;\n /**\n * Small amount of information placed next to the text of the link.\n * This can be any valid react element, for e.g. a `span`.\n * Should be used to indicate a relevant information of the link,\n * for e.g. the number of unread notifications\n */\n postfix?: React.ReactNode;\n /**\n * Small amount of information placed before the text of the link.\n * This can be any valid react element, for e.g. a `span`.\n * Should be used to indicate a feedback for user,\n * for e.g. display some sort of visual informational state or a relevant icon.\n */\n prefix?: React.ReactNode;\n /** Target of the link */\n target?: string;\n};\n\nconst Item = React.forwardRef(function Item(props: NavigationItemProps, ref: React.Ref<HTMLAnchorElement>) {\n const { active, children, onDrop, postfix, prefix, role, ...otherProps } = props;\n const proxyRef = useProxiedRef<HTMLAnchorElement>(ref);\n const [isDraggedOver, dropTargetProps] = useDropTarget(onDrop);\n const isTreeitem = role === 'treeitem';\n const className = cn(\n 'yt-navigation__item cursor-pointer',\n {\n 'w-full mb-px py-1 px-3 flex items-center hover:bg-grey-dark': isTreeitem,\n 'bg-white w-full h-10 px-3 flex-shrink-0 flex items-center justify-between cursor-pointer': !isTreeitem,\n 'yt-navigation__item--active': active && !isDraggedOver,\n 'bg-grey-dark': isTreeitem && active && !isDraggedOver,\n 'yt-navigation__item--dropping bg-blue': isDraggedOver,\n },\n props.className\n );\n\n const handleClick = (event: React.MouseEvent<HTMLSpanElement>): void => {\n if (event.target instanceof HTMLAnchorElement || event.target instanceof HTMLButtonElement) {\n return;\n }\n\n if (proxyRef.current) {\n proxyRef.current.click();\n }\n };\n\n return (\n <span {...dropTargetProps} className={className} onClick={handleClick} role={role}>\n {prefix && <span className=\"yt-navigation__item__prefix flex items-center\">{prefix}</span>}\n <a {...otherProps} className=\"flex-grow block truncate\" ref={proxyRef}>\n {children}\n </a>\n {postfix && <span className=\"yt-navigation__item__postfix ml-1\">{postfix}</span>}\n </span>\n );\n});\n\n// Panel\nexport type NavigationPanelProps = React.HTMLAttributes<HTMLDivElement>;\n\nconst Panel = React.forwardRef(function Panel(props: NavigationPanelProps, ref: React.Ref<HTMLDivElement>) {\n return <div {...props} className={cn('bg-white p-3 w-full', props.className)} ref={ref} />;\n});\n\n// Group\nexport type NavigationMenuGroupProps = TreeviewGroupProps;\n\nconst MenuGroup = React.forwardRef(function MenuGroup(props: NavigationMenuGroupProps, ref: React.Ref<HTMLDivElement>) {\n const className = cn(\n 'flex-shrink-0 space-y-1 outline-none',\n {\n 'bg-white pb-2': props.fixed,\n },\n props.className\n );\n const title = (expanded: boolean): JSX.Element => {\n const className = cn('bg-white h-10 pl-3 pr-1 flex items-center justify-between w-full', {\n 'mb-1': expanded,\n 'cursor-pointer hover:text-blue': !props.fixed,\n });\n\n return (\n <span className={className}>\n {typeof props.title === 'function' ? props.title(expanded) : props.title}\n {!props.fixed && <Icon name={expanded ? 'chevron-up' : 'chevron-down'} />}\n </span>\n );\n };\n\n return <Treeview.Group {...props} className={className} title={title} ref={ref} />;\n});\n\n// Menu\nexport type NavigationMenuProps = React.PropsWithChildren<TreeviewProps>;\n\nexport type FowardedNavigationMenuWithStatics = React.ForwardRefExoticComponent<\n NavigationMenuProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Expandable region reprezenting a group of related links */\n Group: React.ForwardRefExoticComponent<NavigationMenuGroupProps & React.RefAttributes<HTMLDivElement>>;\n};\n\nconst Menu = React.forwardRef(function Menu(props: NavigationMenuProps, ref: React.Ref<HTMLDivElement>) {\n const scrollableAreas = React.useMemo(() => {\n const scrollableAreas: any[] = [];\n\n React.Children.toArray(props.children)\n .filter(child => !!child)\n .map((child: React.ReactElement<NavigationMenuGroupProps>) => {\n if (child.props.fixed) {\n scrollableAreas.push(child);\n } else {\n const x = scrollableAreas[scrollableAreas.length - 1];\n if (Array.isArray(x)) {\n x.push(child);\n } else {\n scrollableAreas.push([child]);\n }\n }\n });\n\n return scrollableAreas;\n }, [props.children]);\n\n return (\n <Treeview\n {...props}\n className={cn('flex flex-col flex-grow overflow-y-auto divide-y-2 divide-grey-light', props.className)}\n ref={ref}\n >\n {scrollableAreas.map((area, i) =>\n Array.isArray(area) ? (\n <div\n className=\"flex flex-col flex-auto flex-shrink-0 flex-grow overflow-y-auto divide-y-2 divide-grey-light h-0\"\n key={i}\n >\n {area}\n </div>\n ) : (\n area\n )\n )}\n </Treeview>\n );\n}) as FowardedNavigationMenuWithStatics;\n\nMenu.Group = MenuGroup;\n\n// Navigation\nexport type NavigationProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport type FowardedNavigationWithStatics = React.ForwardRefExoticComponent<\n NavigationProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Navigation link */\n Item: React.ForwardRefExoticComponent<NavigationItemProps & React.RefAttributes<HTMLAnchorElement>>;\n /**\n * Container for the expandable groups that hold navigation links.\n * Should be used as a direct child of Navigation component, e.g. `Navigation.Menu`.\n * Should have the menu groups as a direct child, e.g. `Navigation.Menu.Group`\n */\n Menu: FowardedNavigationMenuWithStatics;\n /**\n * Isolated container within the Navigation.\n * This can be used to create a region in the Navigation that is usually not scrollable, nor expandable,\n * containing useful information for user and quick actions\n */\n Panel: React.ForwardRefExoticComponent<NavigationPanelProps & React.RefAttributes<HTMLDivElement>>;\n};\n\nexport const Navigation = React.forwardRef(function Navigation(props: NavigationProps, ref: React.Ref<HTMLDivElement>) {\n const { children, ...otherProps } = props;\n const className = cn('h-full flex flex-col bg-grey-light divide-y-2 divide-grey-light', props.className);\n\n return (\n <div {...otherProps} className={className} ref={ref}>\n {children}\n </div>\n );\n}) as FowardedNavigationWithStatics;\n\nNavigation.Menu = Menu;\nNavigation.Item = Item;\nNavigation.Panel = Panel;\n"],"names":["Item","React","forwardRef","props","ref","active","children","onDrop","postfix","prefix","role","otherProps","proxyRef","useProxiedRef","useDropTarget","isDraggedOver","dropTargetProps","isTreeitem","className","cn","handleClick","event","target","HTMLAnchorElement","HTMLButtonElement","current","click","onClick","Panel","MenuGroup","fixed","title","expanded","Icon","name","Treeview","Group","Menu","scrollableAreas","useMemo","Children","toArray","filter","child","map","push","x","length","Array","isArray","area","i","key","Navigation"],"mappings":";;;;;;;;;;AAgCA,IAAMA,IAAI,gBAAGC,cAAK,CAACC,UAAN,CAAiB,SAASF,IAAT,CAAcG,KAAd,EAA0CC,GAA1C;AAC1B,MAAQC,MAAR,GAA2EF,KAA3E,CAAQE,MAAR;AAAA,MAAgBC,QAAhB,GAA2EH,KAA3E,CAAgBG,QAAhB;AAAA,MAA0BC,MAA1B,GAA2EJ,KAA3E,CAA0BI,MAA1B;AAAA,MAAkCC,OAAlC,GAA2EL,KAA3E,CAAkCK,OAAlC;AAAA,MAA2CC,MAA3C,GAA2EN,KAA3E,CAA2CM,MAA3C;AAAA,MAAmDC,IAAnD,GAA2EP,KAA3E,CAAmDO,IAAnD;AAAA,MAA4DC,UAA5D,iCAA2ER,KAA3E;;AACA,MAAMS,QAAQ,GAAGC,aAAa,CAAoBT,GAApB,CAA9B;;AACA,uBAAyCU,aAAa,CAACP,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,QAAR;AAAA,MAAqBK,UAArB,iCAAoCR,KAApC;;AACA,MAAMe,SAAS,GAAGC,EAAE,CAAC,iEAAD,EAAoEhB,KAAK,CAACe,SAA1E,CAApB;AAEA,SACIjB,4BAAA,MAAA,oBAASU;AAAYO,IAAAA,SAAS,EAAEA;AAAWd,IAAAA,GAAG,EAAEA;IAAhD,EACKE,QADL,CADJ;AAKH,CATyB;AAW1B+C,UAAU,CAAChB,IAAX,GAAkBA,IAAlB;AACAgB,UAAU,CAACrD,IAAX,GAAkBA,IAAlB;AACAqD,UAAU,CAACzB,KAAX,GAAmBA,KAAnB;;;;"}
|
1
|
+
{"version":3,"file":"Navigation.js","sources":["../../../../../src/components/Navigation/Navigation.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { TreeviewProps, Treeview, TreeviewGroupProps, TreeviewItemProps } from '../Treeview/Treeview';\nimport { Icon } from '../Icon/Icon';\nimport { useDropTarget } from '../../utils/hooks/useDropTarget';\nimport './Navigation.css';\nimport { useProxiedRef } from '../../utils/hooks/useProxiedRef';\n\n// Item\nexport type NavigationItemProps = Omit<TreeviewItemProps, 'prefix'> & {\n /** Change the style to indicate the link is selected */\n active?: boolean;\n /** Handler to be used when dropping a dragged element over the navigation link */\n onDrop?: React.DragEventHandler;\n /**\n * Small amount of information placed next to the text of the link.\n * This can be any valid react element, for e.g. a `span`.\n * Should be used to indicate a relevant information of the link,\n * for e.g. the number of unread notifications\n */\n postfix?: React.ReactNode;\n /**\n * Small amount of information placed before the text of the link.\n * This can be any valid react element, for e.g. a `span`.\n * Should be used to indicate a feedback for user,\n * for e.g. display some sort of visual informational state or a relevant icon.\n */\n prefix?: React.ReactNode;\n /** Target of the link */\n target?: string;\n};\n\nconst Item = React.forwardRef(function Item(props: NavigationItemProps, ref: React.Ref<HTMLAnchorElement>) {\n const { active, children, onDrop, postfix, prefix, role, ...otherProps } = props;\n const proxyRef = useProxiedRef<HTMLAnchorElement>(ref);\n const [isDraggedOver, dropTargetProps] = useDropTarget(onDrop);\n const isTreeitem = role === 'treeitem';\n const className = cn(\n 'yt-navigation__item cursor-pointer',\n {\n 'w-full mb-px py-1 px-3 flex items-center hover:bg-grey-dark': isTreeitem,\n 'bg-white w-full h-10 px-3 flex-shrink-0 flex items-center justify-between cursor-pointer': !isTreeitem,\n 'yt-navigation__item--active': active && !isDraggedOver,\n 'bg-grey-dark': isTreeitem && active && !isDraggedOver,\n 'yt-navigation__item--dropping bg-blue': isDraggedOver,\n },\n props.className\n );\n\n const handleClick = (event: React.MouseEvent<HTMLSpanElement>): void => {\n if (event.target instanceof HTMLAnchorElement || event.target instanceof HTMLButtonElement) {\n return;\n }\n\n if (proxyRef.current) {\n proxyRef.current.click();\n }\n };\n\n return (\n <span {...dropTargetProps} className={className} onClick={handleClick} role={role}>\n {prefix && <span className=\"yt-navigation__item__prefix flex items-center\">{prefix}</span>}\n <a {...otherProps} className=\"block flex-grow truncate\" ref={proxyRef}>\n {children}\n </a>\n {postfix && <span className=\"yt-navigation__item__postfix ml-1\">{postfix}</span>}\n </span>\n );\n});\n\n// Panel\nexport type NavigationPanelProps = React.HTMLAttributes<HTMLDivElement>;\n\nconst Panel = React.forwardRef(function Panel(props: NavigationPanelProps, ref: React.Ref<HTMLDivElement>) {\n return <div {...props} className={cn('w-full bg-white p-3', props.className)} ref={ref} />;\n});\n\n// Group\nexport type NavigationMenuGroupProps = TreeviewGroupProps;\n\nconst MenuGroup = React.forwardRef(function MenuGroup(props: NavigationMenuGroupProps, ref: React.Ref<HTMLDivElement>) {\n const className = cn(\n 'flex-shrink-0 space-y-1 outline-none',\n {\n 'bg-white pb-2': props.fixed,\n },\n props.className\n );\n const title = (expanded: boolean): JSX.Element => {\n const className = cn('bg-white h-10 pl-3 pr-1 flex items-center justify-between w-full', {\n 'mb-1': expanded,\n 'cursor-pointer hover:text-blue': !props.fixed,\n });\n\n return (\n <span className={className}>\n {typeof props.title === 'function' ? props.title(expanded) : props.title}\n {!props.fixed && <Icon name={expanded ? 'chevron-up' : 'chevron-down'} />}\n </span>\n );\n };\n\n return <Treeview.Group {...props} className={className} title={title} ref={ref} />;\n});\n\n// Menu\nexport type NavigationMenuProps = React.PropsWithChildren<TreeviewProps>;\n\nexport type ForwardedNavigationMenuWithStatics = React.ForwardRefExoticComponent<\n NavigationMenuProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Expandable region reprezenting a group of related links */\n Group: React.ForwardRefExoticComponent<NavigationMenuGroupProps & React.RefAttributes<HTMLDivElement>>;\n};\n\nconst Menu = React.forwardRef(function Menu(props: NavigationMenuProps, ref: React.Ref<HTMLDivElement>) {\n const scrollableAreas = React.useMemo(() => {\n const scrollableAreas: any[] = [];\n\n React.Children.toArray(props.children)\n .filter(child => !!child)\n .map((child: React.ReactElement<NavigationMenuGroupProps>) => {\n if (child.props.fixed) {\n scrollableAreas.push(child);\n } else {\n const x = scrollableAreas[scrollableAreas.length - 1];\n if (Array.isArray(x)) {\n x.push(child);\n } else {\n scrollableAreas.push([child]);\n }\n }\n });\n\n return scrollableAreas;\n }, [props.children]);\n\n return (\n <Treeview\n {...props}\n className={cn('divide-grey-light flex flex-grow flex-col divide-y-2 overflow-y-auto', props.className)}\n ref={ref}\n >\n {scrollableAreas.map((area, i) =>\n Array.isArray(area) ? (\n <div\n className=\"divide-grey-light flex h-0 flex-auto flex-shrink-0 flex-grow flex-col divide-y-2 overflow-y-auto\"\n key={i}\n >\n {area}\n </div>\n ) : (\n area\n )\n )}\n </Treeview>\n );\n}) as ForwardedNavigationMenuWithStatics;\n\nMenu.Group = MenuGroup;\n\n// Navigation\nexport type NavigationProps = React.HTMLAttributes<HTMLDivElement>;\n\nexport type ForwardedNavigationWithStatics = React.ForwardRefExoticComponent<\n NavigationProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Navigation link */\n Item: React.ForwardRefExoticComponent<NavigationItemProps & React.RefAttributes<HTMLAnchorElement>>;\n /**\n * Container for the expandable groups that hold navigation links.\n * Should be used as a direct child of Navigation component, e.g. `Navigation.Menu`.\n * Should have the menu groups as a direct child, e.g. `Navigation.Menu.Group`\n */\n Menu: ForwardedNavigationMenuWithStatics;\n /**\n * Isolated container within the Navigation.\n * This can be used to create a region in the Navigation that is usually not scrollable, nor expandable,\n * containing useful information for user and quick actions\n */\n Panel: React.ForwardRefExoticComponent<NavigationPanelProps & React.RefAttributes<HTMLDivElement>>;\n};\n\nexport const Navigation = React.forwardRef(function Navigation(props: NavigationProps, ref: React.Ref<HTMLDivElement>) {\n const { children, ...otherProps } = props;\n const className = cn('h-full flex flex-col bg-grey-light divide-y-2 divide-grey-light', props.className);\n\n return (\n <div {...otherProps} className={className} ref={ref}>\n {children}\n </div>\n );\n}) as ForwardedNavigationWithStatics;\n\nNavigation.Menu = Menu;\nNavigation.Item = Item;\nNavigation.Panel = Panel;\n"],"names":["Item","React","forwardRef","props","ref","active","children","onDrop","postfix","prefix","role","otherProps","proxyRef","useProxiedRef","useDropTarget","isDraggedOver","dropTargetProps","isTreeitem","className","cn","handleClick","event","target","HTMLAnchorElement","HTMLButtonElement","current","click","onClick","Panel","MenuGroup","fixed","title","expanded","Icon","name","Treeview","Group","Menu","scrollableAreas","useMemo","Children","toArray","filter","child","map","push","x","length","Array","isArray","area","i","key","Navigation"],"mappings":";;;;;;;;;;AAgCA,IAAMA,IAAI,gBAAGC,cAAK,CAACC,UAAN,CAAiB,SAASF,IAAT,CAAcG,KAAd,EAA0CC,GAA1C;AAC1B,MAAQC,MAAR,GAA2EF,KAA3E,CAAQE,MAAR;AAAA,MAAgBC,QAAhB,GAA2EH,KAA3E,CAAgBG,QAAhB;AAAA,MAA0BC,MAA1B,GAA2EJ,KAA3E,CAA0BI,MAA1B;AAAA,MAAkCC,OAAlC,GAA2EL,KAA3E,CAAkCK,OAAlC;AAAA,MAA2CC,MAA3C,GAA2EN,KAA3E,CAA2CM,MAA3C;AAAA,MAAmDC,IAAnD,GAA2EP,KAA3E,CAAmDO,IAAnD;AAAA,MAA4DC,UAA5D,iCAA2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N,CAAiB,SAASmD,UAAT,CAAoBlD,KAApB,EAA4CC,GAA5C;AACvC,MAAQE,QAAR,GAAoCH,KAApC,CAAQG,QAAR;AAAA,MAAqBK,UAArB,iCAAoCR,KAApC;;AACA,MAAMe,SAAS,GAAGC,EAAE,CAAC,iEAAD,EAAoEhB,KAAK,CAACe,SAA1E,CAApB;AAEA,SACIjB,4BAAA,MAAA,oBAASU;AAAYO,IAAAA,SAAS,EAAEA;AAAWd,IAAAA,GAAG,EAAEA;IAAhD,EACKE,QADL,CADJ;AAKH,CATyB;AAW1B+C,UAAU,CAAChB,IAAX,GAAkBA,IAAlB;AACAgB,UAAU,CAACrD,IAAX,GAAkBA,IAAlB;AACAqD,UAAU,CAACzB,KAAX,GAAmBA,KAAnB;;;;"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { createElement, Fragment } from 'react';
|
2
|
-
import { Button } from '../Button/Button.js';
|
3
2
|
import { useLocalization } from '../Provider/Provider.js';
|
3
|
+
import { Button } from '../Button/Button.js';
|
4
4
|
|
5
5
|
var createPageRange = function createPageRange(pageCount, pageNumber) {
|
6
6
|
var lowerLimit = Math.min(pageNumber, pageCount);
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
2
2
|
import { forwardRef, createElement } from 'react';
|
3
3
|
import cn from 'classnames';
|
4
|
-
import { IconButton } from '../IconButton/IconButton.js';
|
5
4
|
import { useLocalization } from '../Provider/Provider.js';
|
6
5
|
import { Group } from '../Group/Group.js';
|
6
|
+
import { IconButton } from '../IconButton/IconButton.js';
|
7
7
|
import { PageNumbers } from './PageNumbers.js';
|
8
8
|
import { Select } from '../Select/Select.js';
|
9
9
|
import { usePaginationShortcuts } from './usePaginationShortcuts.js';
|
@@ -1,17 +1,19 @@
|
|
1
1
|
import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
2
|
-
import { useMemo, createElement, createContext,
|
2
|
+
import { forwardRef, useMemo, createElement, createContext, useContext } from 'react';
|
3
3
|
import cn from 'classnames';
|
4
4
|
import { Root, Trigger as Trigger$1, Close as Close$1 } from '@radix-ui/react-popover';
|
5
5
|
import { UnstyledContent, UnstyledArrow } from './Primitives.js';
|
6
|
+
import mergeRefs from '../../utils/mergeRefs.js';
|
6
7
|
|
7
8
|
var _excluded = ["children"];
|
8
9
|
var PopoverContext = /*#__PURE__*/createContext({
|
9
|
-
props: {}
|
10
|
+
props: {},
|
11
|
+
ref: null
|
10
12
|
});
|
11
13
|
var Trigger = /*#__PURE__*/forwardRef(function (props, ref) {
|
12
14
|
var context = useContext(PopoverContext);
|
13
15
|
return createElement(Trigger$1, Object.assign({}, context.props, props, {
|
14
|
-
ref: ref,
|
16
|
+
ref: mergeRefs([context.ref, ref]),
|
15
17
|
asChild: true
|
16
18
|
}));
|
17
19
|
});
|
@@ -54,13 +56,14 @@ var Close = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
54
56
|
asChild: true
|
55
57
|
}));
|
56
58
|
});
|
57
|
-
var Popover = function
|
59
|
+
var Popover = /*#__PURE__*/forwardRef(function (props, ref) {
|
58
60
|
var children = props.children,
|
59
61
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
60
62
|
|
61
63
|
var context = useMemo(function () {
|
62
64
|
return {
|
63
|
-
props: otherProps
|
65
|
+
props: otherProps,
|
66
|
+
ref: ref
|
64
67
|
};
|
65
68
|
}, [otherProps]);
|
66
69
|
return createElement(PopoverContext.Provider, {
|
@@ -68,7 +71,7 @@ var Popover = function Popover(props) {
|
|
68
71
|
}, createElement(Root, {
|
69
72
|
children: children
|
70
73
|
}));
|
71
|
-
};
|
74
|
+
});
|
72
75
|
Popover.Trigger = Trigger;
|
73
76
|
Popover.Content = Content;
|
74
77
|
Popover.Close = Close;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Popover.js","sources":["../../../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { Placement } from '../..';\nimport { UnstyledArrow, UnstyledContent } from './Primitives';\n\nconst PopoverContext = React.createContext({\n props: {},\n});\n\nexport type PopoverTriggerProps = React.HTMLAttributes<HTMLButtonElement>;\nconst Trigger = React.forwardRef((props: PopoverTriggerProps, ref: React.Ref<HTMLButtonElement>) => {\n const context = React.useContext(PopoverContext);\n return <PopoverPrimitive.Trigger {...context.props} {...props} ref={ref} asChild />;\n});\nconst RenderPropWrapper = React.forwardRef(({ children, onClick }: any, ref) => {\n const close = () => {\n onClick(new CustomEvent('hide'));\n };\n\n return children({ close, ref });\n});\n\nexport type PopoverContentRenderProps = { close: () => void };\nexport type PopoverContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n children: React.ReactNode | ((props: PopoverContentRenderProps) => React.ReactNode);\n /** Set the position of the Popover relative to its trigger. Default value is `bottom` */\n placement?: Placement;\n};\nconst Content = React.forwardRef((props: PopoverContentProps, ref: React.Ref<HTMLDivElement>) => {\n const className = cn('bg-white focus:border-blue-light', props.className);\n\n let output;\n\n if (typeof props.children === 'function') {\n output = (\n <PopoverPrimitive.Close asChild>\n <RenderPropWrapper>{props.children}</RenderPropWrapper>\n </PopoverPrimitive.Close>\n );\n } else {\n output = props.children;\n }\n\n return (\n <UnstyledContent className={className} placement={props.placement} ref={ref}>\n {output}\n <UnstyledArrow className=\"text-white\" />\n </UnstyledContent>\n );\n});\n\nexport type PopoverCloseProps = React.HTMLAttributes<HTMLButtonElement>;\nconst Close = React.forwardRef(\n (props: PopoverCloseProps, ref: React.Ref<HTMLButtonElement>): JSX.Element => (\n <PopoverPrimitive.Close {...props} ref={ref} asChild />\n )\n);\n\nexport type PopoverProps = React.PropsWithChildren<{}>;\nexport const Popover = (props: PopoverProps): JSX.Element => {\n const { children, ...otherProps } = props;\n\n const context = React.useMemo(() => ({ props: otherProps }), [otherProps]);\n\n return (\n <PopoverContext.Provider value={context}>\n <PopoverPrimitive.Root children={children} />\n </PopoverContext.Provider>\n );\n};\nPopover.Trigger = Trigger;\nPopover.Content = Content;\nPopover.Close = Close;\n"],"names":["PopoverContext","React","props","
|
1
|
+
{"version":3,"file":"Popover.js","sources":["../../../../../src/components/Popover/Popover.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport { Placement } from '../..';\nimport { UnstyledArrow, UnstyledContent } from './Primitives';\nimport mergeRefs from '../../utils/mergeRefs';\n\ntype PopoverContextValue = { props: any; ref: React.Ref<HTMLElement> };\n\nconst PopoverContext = React.createContext<PopoverContextValue>({\n props: {},\n ref: null,\n});\n\nexport type PopoverTriggerProps = React.HTMLAttributes<HTMLButtonElement>;\nconst Trigger = React.forwardRef((props: PopoverTriggerProps, ref: React.Ref<HTMLButtonElement>) => {\n const context = React.useContext(PopoverContext);\n return <PopoverPrimitive.Trigger {...context.props} {...props} ref={mergeRefs([context.ref, ref])} asChild />;\n});\nconst RenderPropWrapper = React.forwardRef(({ children, onClick }: any, ref) => {\n const close = () => {\n onClick(new CustomEvent('hide'));\n };\n\n return children({ close, ref });\n});\n\nexport type PopoverContentRenderProps = { close: () => void };\nexport type PopoverContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n children: React.ReactNode | ((props: PopoverContentRenderProps) => React.ReactNode);\n /** Set the position of the Popover relative to its trigger. Default value is `bottom` */\n placement?: Placement;\n};\nconst Content = React.forwardRef((props: PopoverContentProps, ref: React.Ref<HTMLDivElement>) => {\n const className = cn('bg-white focus:border-blue-light', props.className);\n\n let output;\n\n if (typeof props.children === 'function') {\n output = (\n <PopoverPrimitive.Close asChild>\n <RenderPropWrapper>{props.children}</RenderPropWrapper>\n </PopoverPrimitive.Close>\n );\n } else {\n output = props.children;\n }\n\n return (\n <UnstyledContent className={className} placement={props.placement} ref={ref}>\n {output}\n <UnstyledArrow className=\"text-white\" />\n </UnstyledContent>\n );\n});\n\nexport type PopoverCloseProps = React.HTMLAttributes<HTMLButtonElement>;\nconst Close = React.forwardRef(\n (props: PopoverCloseProps, ref: React.Ref<HTMLButtonElement>): JSX.Element => (\n <PopoverPrimitive.Close {...props} ref={ref} asChild />\n )\n);\n\nexport type PopoverProps = React.PropsWithChildren<{}>;\nexport type ForwardedPopoverWithStatics = React.ForwardRefExoticComponent<PopoverProps & React.RefAttributes<HTMLElement>> & {\n Trigger: React.ForwardRefExoticComponent<PopoverTriggerProps>;\n Content: React.ForwardRefExoticComponent<PopoverContentProps>;\n Close: React.ForwardRefExoticComponent<PopoverCloseProps>;\n};\n\nexport const Popover = React.forwardRef((props: PopoverProps, ref: React.Ref<HTMLElement>): JSX.Element => {\n const { children, ...otherProps } = props;\n\n const context = React.useMemo(() => ({ props: otherProps, ref }), [otherProps]);\n\n return (\n <PopoverContext.Provider value={context}>\n <PopoverPrimitive.Root children={children} />\n </PopoverContext.Provider>\n );\n}) as ForwardedPopoverWithStatics;\nPopover.Trigger = Trigger;\nPopover.Content = Content;\nPopover.Close = Close;\n"],"names":["PopoverContext","React","props","ref","Trigger","context","PopoverPrimitive","mergeRefs","asChild","RenderPropWrapper","children","onClick","close","CustomEvent","Content","className","cn","output","UnstyledContent","placement","UnstyledArrow","Close","Popover","otherProps","Provider","value"],"mappings":";;;;;;;;AASA,IAAMA,cAAc,gBAAGC,aAAA,CAAyC;AAC5DC,EAAAA,KAAK,EAAE,EADqD;AAE5DC,EAAAA,GAAG,EAAE;AAFuD,CAAzC,CAAvB;AAMA,IAAMC,OAAO,gBAAGH,UAAA,CAAiB,UAACC,KAAD,EAA6BC,GAA7B;AAC7B,MAAME,OAAO,GAAGJ,UAAA,CAAiBD,cAAjB,CAAhB;AACA,SAAOC,aAAA,CAACK,SAAD,oBAA8BD,OAAO,CAACH,OAAWA;AAAOC,IAAAA,GAAG,EAAEI,SAAS,CAAC,CAACF,OAAO,CAACF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EA;AAAKK,IAAAA,OAAO;IAApD,CADJ;AAAA,CADU,CAAd;IAaac,OAAO,gBAAGrB,UAAA,CAAiB,UAACC,KAAD,EAAsBC,GAAtB;AACpC,MAAQO,QAAR,GAAoCR,KAApC,CAAQQ,QAAR;AAAA,MAAqBa,UAArB,iCAAoCrB,KAApC;;AAEA,MAAMG,OAAO,GAAGJ,OAAA,CAAc;AAAA,WAAO;AAAEC,MAAAA,KAAK,EAAEqB,UAAT;AAAqBpB,MAAAA,GAAG,EAAHA;AAArB,KAAP;AAAA,GAAd,EAAkD,CAACoB,UAAD,CAAlD,CAAhB;AAEA,SACItB,aAAA,CAACD,cAAc,CAACwB,QAAhB;AAAyBC,IAAAA,KAAK,EAAEpB;GAAhC,EACIJ,aAAA,CAACK,IAAD;AAAuBI,IAAAA,QAAQ,EAAEA;GAAjC,CADJ,CADJ;AAKH,CAVsB;AAWvBY,OAAO,CAAClB,OAAR,GAAkBA,OAAlB;AACAkB,OAAO,CAACR,OAAR,GAAkBA,OAAlB;AACAQ,OAAO,CAACD,KAAR,GAAgBA,KAAhB;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","sources":["../../../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport { Orientation } from '../../types';\n\nexport type RadioGroupItemValue = string | number | boolean | undefined;\n\nexport const getRadioGroupItemValueAsString = (value: RadioGroupItemValue): string =>\n value === undefined || value === null ? '' : String(value);\n\nexport const findByValue = (values: RadioGroupItemValue[], valueAsString: string): RadioGroupItemValue | undefined =>\n values.find(value => getRadioGroupItemValueAsString(value) === valueAsString);\n\nconst RadioGroupContext = React.createContext({ disabled: false, invalid: false });\n\nexport type RadioGroupItemProps<T = HTMLButtonElement> = Omit<\n React.ButtonHTMLAttributes<T>,\n 'children' | 'onSelect' | 'value'\n> & {\n /** Label for the radio group item */\n children: React.ReactNode;\n /* Whether the radio group item is disabled */\n disabled?: boolean;\n /** Value of the radio button */\n value: RadioGroupItemValue;\n};\n\nconst RadioGroupItem = React.forwardRef(function RadioGroupItem(props: RadioGroupItemProps, ref: React.Ref<HTMLButtonElement>) {\n const context = React.useContext(RadioGroupContext);\n const { children, value, ...otherProps } = props;\n\n const disabled = context.disabled || props.disabled;\n\n const className = cn('flex items-center justify-center h-4 w-4 mr-2 rounded-full bg-white border-2 ', {\n 'border-grey-dark focus:border-blue focus:yt-focus aria-checked:bg-blue aria-checked:border-blue':\n !disabled && !context.invalid,\n 'border-grey cursor-not-allowed aria-checked:bg-grey-dark aria-checked:border-grey-dark': disabled,\n 'border-red text-red focus:border-red focus:yt-focus-red aria-checked:bg-red aria-checked:border-red':\n context.invalid && !disabled,\n });\n const labelClassName = cn('flex items-center cursor-pointer', {\n 'cursor-not-allowed text-grey-dark': disabled,\n });\n\n return (\n <label className={labelClassName}>\n <RadioGroupPrimitive.Item\n {...otherProps}\n className={className}\n disabled={disabled}\n ref={ref}\n value={getRadioGroupItemValueAsString(value)}\n >\n <RadioGroupPrimitive.Indicator className=\"h-2 w-2 rounded-full bg-white\" />\n </RadioGroupPrimitive.Item>\n {children}\n </label>\n );\n});\n\ntype RadioGroupBaseProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n children: React.ReactElement<RadioGroupItemProps>[];\n /* Whether the radio group is disabled */\n disabled?: boolean;\n /* Whether the radio group is in an invalid state */\n invalid?: boolean;\n /** The name of the radio group, used when submitting an HTML form */\n name?: string;\n /**\n * Orientation of the radio group\n * @defaultValue vertical\n */\n orientation?: Orientation;\n /* Whether the radio group requires user input */\n required?: boolean;\n};\n\ninterface UncontrolledRadioGroupProps extends RadioGroupBaseProps {\n /* The default value (uncontrolled) */\n defaultValue?: RadioGroupItemValue;\n onChange?: never;\n value?: never;\n}\n\ninterface ControlledRadioGroupProps extends RadioGroupBaseProps {\n defaultValue?: never;\n /** Handler called when the value changes */\n onChange: (value: RadioGroupItemValue) => void;\n /** The current value (controlled) */\n value: RadioGroupItemValue;\n}\n\nexport type RadioGroupProps = UncontrolledRadioGroupProps | ControlledRadioGroupProps;\n\nexport type
|
1
|
+
{"version":3,"file":"RadioGroup.js","sources":["../../../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport { Orientation } from '../../types';\n\nexport type RadioGroupItemValue = string | number | boolean | undefined;\n\nexport const getRadioGroupItemValueAsString = (value: RadioGroupItemValue): string =>\n value === undefined || value === null ? '' : String(value);\n\nexport const findByValue = (values: RadioGroupItemValue[], valueAsString: string): RadioGroupItemValue | undefined =>\n values.find(value => getRadioGroupItemValueAsString(value) === valueAsString);\n\nconst RadioGroupContext = React.createContext({ disabled: false, invalid: false });\n\nexport type RadioGroupItemProps<T = HTMLButtonElement> = Omit<\n React.ButtonHTMLAttributes<T>,\n 'children' | 'onSelect' | 'value'\n> & {\n /** Label for the radio group item */\n children: React.ReactNode;\n /* Whether the radio group item is disabled */\n disabled?: boolean;\n /** Value of the radio button */\n value: RadioGroupItemValue;\n};\n\nconst RadioGroupItem = React.forwardRef(function RadioGroupItem(props: RadioGroupItemProps, ref: React.Ref<HTMLButtonElement>) {\n const context = React.useContext(RadioGroupContext);\n const { children, value, ...otherProps } = props;\n\n const disabled = context.disabled || props.disabled;\n\n const className = cn('flex items-center justify-center h-4 w-4 mr-2 rounded-full bg-white border-2 ', {\n 'border-grey-dark focus:border-blue focus:yt-focus aria-checked:bg-blue aria-checked:border-blue':\n !disabled && !context.invalid,\n 'border-grey cursor-not-allowed aria-checked:bg-grey-dark aria-checked:border-grey-dark': disabled,\n 'border-red text-red focus:border-red focus:yt-focus-red aria-checked:bg-red aria-checked:border-red':\n context.invalid && !disabled,\n });\n const labelClassName = cn('flex items-center cursor-pointer', {\n 'cursor-not-allowed text-grey-dark': disabled,\n });\n\n return (\n <label className={labelClassName}>\n <RadioGroupPrimitive.Item\n {...otherProps}\n className={className}\n disabled={disabled}\n ref={ref}\n value={getRadioGroupItemValueAsString(value)}\n >\n <RadioGroupPrimitive.Indicator className=\"h-2 w-2 rounded-full bg-white\" />\n </RadioGroupPrimitive.Item>\n {children}\n </label>\n );\n});\n\ntype RadioGroupBaseProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n children: React.ReactElement<RadioGroupItemProps>[];\n /* Whether the radio group is disabled */\n disabled?: boolean;\n /* Whether the radio group is in an invalid state */\n invalid?: boolean;\n /** The name of the radio group, used when submitting an HTML form */\n name?: string;\n /**\n * Orientation of the radio group\n * @defaultValue vertical\n */\n orientation?: Orientation;\n /* Whether the radio group requires user input */\n required?: boolean;\n};\n\ninterface UncontrolledRadioGroupProps extends RadioGroupBaseProps {\n /* The default value (uncontrolled) */\n defaultValue?: RadioGroupItemValue;\n onChange?: never;\n value?: never;\n}\n\ninterface ControlledRadioGroupProps extends RadioGroupBaseProps {\n defaultValue?: never;\n /** Handler called when the value changes */\n onChange: (value: RadioGroupItemValue) => void;\n /** The current value (controlled) */\n value: RadioGroupItemValue;\n}\n\nexport type RadioGroupProps = UncontrolledRadioGroupProps | ControlledRadioGroupProps;\n\nexport type ForwardedRadioGroupWithStatics = React.ForwardRefExoticComponent<\n RadioGroupProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Item component rendered in a `RadioGroup` component */\n Item: React.ForwardRefExoticComponent<RadioGroupItemProps>;\n};\n\nexport const useRadioGroup = (props: RadioGroupProps) => {\n const { children, defaultValue, disabled, invalid, onChange, orientation = 'vertical', value, ...otherProps } = props;\n\n const values = React.useMemo<RadioGroupItemValue[]>(\n () => React.Children.map(children, (child: React.ReactElement<RadioGroupItemProps>) => child.props.value) ?? [],\n [children]\n );\n\n const context = React.useMemo(() => ({ disabled: disabled ?? false, invalid: invalid ?? false }), [disabled, invalid]);\n\n let valueProps;\n\n if (defaultValue) {\n valueProps = {\n defaultValue: getRadioGroupItemValueAsString(defaultValue) || undefined,\n };\n } else {\n const handleChange = onChange ? (value: string): void => onChange(findByValue(values, value)) : undefined;\n\n valueProps = {\n onValueChange: handleChange,\n value: getRadioGroupItemValueAsString(value) || undefined,\n };\n }\n\n return {\n context,\n props: {\n ...otherProps,\n ...valueProps,\n children,\n orientation,\n },\n };\n};\n\nexport const RadioGroup = React.forwardRef(function RadioGroup(props: RadioGroupProps, ref: React.Ref<HTMLDivElement>) {\n const { context, props: otherProps } = useRadioGroup(props);\n const className = cn(\n 'flex items-start',\n {\n 'flex-wrap space-x-4': props.orientation === 'horizontal',\n 'flex-col space-y-2': props.orientation === 'vertical',\n },\n props.className\n );\n\n return (\n <RadioGroupContext.Provider value={context}>\n <RadioGroupPrimitive.Root {...otherProps} className={className} data-taco=\"radio-group\" ref={ref} />\n </RadioGroupContext.Provider>\n );\n}) as ForwardedRadioGroupWithStatics;\nRadioGroup.Item = RadioGroupItem;\n"],"names":["getRadioGroupItemValueAsString","value","undefined","String","findByValue","values","valueAsString","find","RadioGroupContext","React","disabled","invalid","RadioGroupItem","props","ref","context","children","otherProps","className","cn","labelClassName","RadioGroupPrimitive","useRadioGroup","defaultValue","onChange","orientation","map","child","valueProps","handleChange","onValueChange","RadioGroup","Provider","Item"],"mappings":";;;;;;;IAOaA,8BAA8B,GAAG,SAAjCA,8BAAiC,CAACC,KAAD;AAAA,SAC1CA,KAAK,KAAKC,SAAV,IAAuBD,KAAK,KAAK,IAAjC,GAAwC,EAAxC,GAA6CE,MAAM,CAACF,KAAD,CADT;AAAA;IAGjCG,WAAW,GAAG,SAAdA,WAAc,CAACC,MAAD,EAAgCC,aAAhC;AAAA,SACvBD,MAAM,CAACE,IAAP,CAAY,UAAAN,KAAK;AAAA,WAAID,8BAA8B,CAACC,KAAD,CAA9B,KAA0CK,aAA9C;AAAA,GAAjB,CADuB;AAAA;AAG3B,IAAME,iBAAiB,gBAAGC,aA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A,KAAK,EAAED,8BAA8B,CAACC,KAAD,CAA9B,IAAyCC;AAFvC,KAAb;AAIH;;AAED,SAAO;AACHa,IAAAA,OAAO,EAAPA,OADG;AAEHF,IAAAA,KAAK,eACEI,UADF,EAEEW,UAFF;AAGDZ,MAAAA,QAAQ,EAARA,QAHC;AAIDS,MAAAA,WAAW,EAAXA;AAJC;AAFF,GAAP;AASH;IAEYM,UAAU,gBAAGtB,UAAA,CAAiB,SAASsB,UAAT,CAAoBlB,KAApB,EAA4CC,GAA5C;AACvC,uBAAuCQ,aAAa,CAACT,KAAD,CAApD;AAAA,MAAQE,OAAR,kBAAQA,OAAR;AAAA,MAAwBE,UAAxB,kBAAiBJ,KAAjB;;AACA,MAAMK,SAAS,GAAGC,EAAE,CAChB,kBADgB,EAEhB;AACI,2BAAuBN,KAAK,CAACY,WAAN,KAAsB,YADjD;AAEI,0BAAsBZ,KAAK,CAACY,WAAN,KAAsB;AAFhD,GAFgB,EAMhBZ,KAAK,CAACK,SANU,CAApB;AASA,SACIT,aAAA,CAACD,iBAAiB,CAACwB,QAAnB;AAA4B/B,IAAAA,KAAK,EAAEc;GAAnC,EACIN,aAAA,CAACY,IAAD,oBAA8BJ;AAAYC,IAAAA,SAAS,EAAEA;iBAAqB;AAAcJ,IAAAA,GAAG,EAAEA;IAA7F,CADJ,CADJ;AAKH,CAhByB;AAiB1BiB,UAAU,CAACE,IAAX,GAAkBrB,cAAlB;;;;"}
|
@@ -6,12 +6,16 @@ import '../Accordion/Accordion.js';
|
|
6
6
|
import '../VisuallyHidden/VisuallyHidden.js';
|
7
7
|
import '../Badge/Badge.js';
|
8
8
|
import '../Tooltip/Tooltip.js';
|
9
|
-
import { IconButton } from '../IconButton/IconButton.js';
|
10
|
-
import '../Banner/Banner.js';
|
11
|
-
import '../Button/Button.js';
|
12
9
|
import '../Spinner/Spinner.js';
|
13
10
|
import '../Toast/Toaster.js';
|
14
11
|
import { useLocalization } from '../Provider/Provider.js';
|
12
|
+
import '../Hanger/Hanger.js';
|
13
|
+
import '../Group/Group.js';
|
14
|
+
import '../Dialog/Dialog.js';
|
15
|
+
import '../Popover/Popover.js';
|
16
|
+
import { IconButton } from '../IconButton/IconButton.js';
|
17
|
+
import '../Banner/Banner.js';
|
18
|
+
import '../Button/Button.js';
|
15
19
|
import '../Calendar/Calendar.js';
|
16
20
|
import '../Checkbox/Checkbox.js';
|
17
21
|
import { Input } from '../Input/Input.js';
|
@@ -20,12 +24,8 @@ import '../../utils/hooks/useListKeyboardNavigation.js';
|
|
20
24
|
import '../../utils/hooks/useListScrollTo.js';
|
21
25
|
import '../Combobox/Combobox.js';
|
22
26
|
import '../../utils/date.js';
|
23
|
-
import '../Popover/Popover.js';
|
24
27
|
import '../Datepicker/Datepicker.js';
|
25
|
-
import '../Group/Group.js';
|
26
|
-
import '../Dialog/Dialog.js';
|
27
28
|
import '../Form/Form.js';
|
28
|
-
import '../Hanger/Hanger.js';
|
29
29
|
import '../Label/Label.js';
|
30
30
|
import '../Listbox/Listbox.js';
|
31
31
|
import '../RadioGroup/RadioGroup.js';
|
@@ -71,8 +71,9 @@ var BaseSelect = /*#__PURE__*/forwardRef(function BaseSelect(props, ref) {
|
|
71
71
|
}), props.multiselect ? renderMultiSelection() : createElement("span", {
|
72
72
|
className: "flex-grow"
|
73
73
|
}, text), createElement("span", {
|
74
|
-
className: "h-8 w-8
|
74
|
+
className: "flex h-8 w-8 items-center justify-center"
|
75
75
|
}, createElement(Icon, {
|
76
|
+
className: "group-hover:text-grey-darkest text-black",
|
76
77
|
name: popover.visible ? 'chevron-up' : 'chevron-down'
|
77
78
|
})));
|
78
79
|
}), !otherProps.disabled && createElement(Popover, Object.assign({}, base, container), props.multiselect ? createElement(MultiListbox, Object.assign({}, commonListboxProps)) : createElement(Listbox, Object.assign({}, commonListboxProps))));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Select.js","sources":["../../../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Popover as BasePopover, PopoverDisclosure } from 'reakit/Popover';\n\nimport { Icon } from '../Icon/Icon';\nimport { Listbox, MultiListbox, ListboxProps } from '../Listbox/Listbox';\nimport { useBoundingClientRectListener } from '../../utils/hooks/useBoundingClientRectListener';\nimport { useSelect } from './useSelect';\nimport { Combobox, ComboboxProps } from '../Combobox/Combobox';\nimport './Select.css';\nimport { Badge } from '../Badge/Badge';\nimport { getInputClasses } from '../Input/util';\n\nexport type SelectTexts = {\n /**\n * The text displayed when all options are selected when multiselect mode in on.\n */\n allOptionsSelected: string;\n};\n\nexport type BaseSelectProps = ListboxProps &\n Omit<ComboboxProps, 'inline'> & {\n /**\n * Allows to select multiple values.\n * All the selected values will be combined in a comma-seperated string as the value of the input.\n */\n multiselect?: boolean;\n };\n\nexport type SelectProps = BaseSelectProps & {\n /**\n * Creates an editable select.\n * Setting this will render a inline Combobox which will display the provided data on click/focus,\n * even if there is no value in the input.\n * After user starts typing, matching data will be displayed.\n */\n editable?: boolean;\n};\n\nconst BaseSelect = React.forwardRef(function BaseSelect(props: BaseSelectProps, ref: React.Ref<HTMLInputElement>) {\n const { autoFocus, className: externalClassName, highlighted, style, ...otherProps } = props;\n const { button, listbox, popover, text, more = 0 } = useSelect(otherProps, ref);\n const { container, ...base } = popover;\n const internalRef = React.useRef<HTMLButtonElement>(null);\n const selectDimensions = useBoundingClientRectListener(internalRef);\n const className = cn('inline-flex relative w-full', { 'yt-select--readonly': props.readOnly }, externalClassName);\n const inputClassname = cn(getInputClasses(props), 'text-left pr-0');\n\n React.useEffect(() => {\n if (autoFocus && internalRef.current) {\n internalRef.current.focus();\n }\n }, []);\n\n const renderMultiSelection = (): React.ReactNode => {\n return (\n <>\n <span>{text}</span>\n {more > 0 && <Badge className=\"ml-2\">{`+${more}`}</Badge>}\n </>\n );\n };\n\n const commonListboxProps = {\n ...listbox,\n className: 'w-auto',\n style: { minWidth: selectDimensions?.width },\n tabIndex: popover.visible ? 0 : -1,\n };\n\n return (\n <span className={className} data-taco=\"select\" style={style}>\n <PopoverDisclosure {...base} ref={internalRef}>\n {({ ref: disclosureRef }) => (\n <button ref={disclosureRef} {...button} className={inputClassname}>\n {props.multiselect ? renderMultiSelection() : <span className=\"flex-grow\">{text}</span>}\n <span className=\"h-8 w-8
|
1
|
+
{"version":3,"file":"Select.js","sources":["../../../../../src/components/Select/Select.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Popover as BasePopover, PopoverDisclosure } from 'reakit/Popover';\n\nimport { Icon } from '../Icon/Icon';\nimport { Listbox, MultiListbox, ListboxProps } from '../Listbox/Listbox';\nimport { useBoundingClientRectListener } from '../../utils/hooks/useBoundingClientRectListener';\nimport { useSelect } from './useSelect';\nimport { Combobox, ComboboxProps } from '../Combobox/Combobox';\nimport './Select.css';\nimport { Badge } from '../Badge/Badge';\nimport { getInputClasses } from '../Input/util';\n\nexport type SelectTexts = {\n /**\n * The text displayed when all options are selected when multiselect mode in on.\n */\n allOptionsSelected: string;\n};\n\nexport type BaseSelectProps = ListboxProps &\n Omit<ComboboxProps, 'inline'> & {\n /**\n * Allows to select multiple values.\n * All the selected values will be combined in a comma-seperated string as the value of the input.\n */\n multiselect?: boolean;\n /** Optionally shows the icon for the selected option */\n showSelectedIcon?: boolean;\n };\n\nexport type SelectProps = BaseSelectProps & {\n /**\n * Creates an editable select.\n * Setting this will render a inline Combobox which will display the provided data on click/focus,\n * even if there is no value in the input.\n * After user starts typing, matching data will be displayed.\n */\n editable?: boolean;\n};\n\nconst BaseSelect = React.forwardRef(function BaseSelect(props: BaseSelectProps, ref: React.Ref<HTMLInputElement>) {\n const { autoFocus, className: externalClassName, highlighted, style, ...otherProps } = props;\n const { button, listbox, popover, text, more = 0 } = useSelect(otherProps, ref);\n const { container, ...base } = popover;\n const internalRef = React.useRef<HTMLButtonElement>(null);\n const selectDimensions = useBoundingClientRectListener(internalRef);\n const className = cn('inline-flex relative w-full', { 'yt-select--readonly': props.readOnly }, externalClassName);\n const inputClassname = cn(getInputClasses(props), 'text-left pr-0');\n\n React.useEffect(() => {\n if (autoFocus && internalRef.current) {\n internalRef.current.focus();\n }\n }, []);\n\n const renderMultiSelection = (): React.ReactNode => {\n return (\n <>\n <span>{text}</span>\n {more > 0 && <Badge className=\"ml-2\">{`+${more}`}</Badge>}\n </>\n );\n };\n\n const commonListboxProps = {\n ...listbox,\n className: 'w-auto',\n style: { minWidth: selectDimensions?.width },\n tabIndex: popover.visible ? 0 : -1,\n };\n\n return (\n <span className={className} data-taco=\"select\" style={style}>\n <PopoverDisclosure {...base} ref={internalRef}>\n {({ ref: disclosureRef }) => (\n <button ref={disclosureRef} {...button} className={inputClassname}>\n {props.multiselect ? renderMultiSelection() : <span className=\"flex-grow\">{text}</span>}\n <span className=\"flex h-8 w-8 items-center justify-center\">\n <Icon\n className=\"group-hover:text-grey-darkest text-black\"\n name={popover.visible ? 'chevron-up' : 'chevron-down'}\n />\n </span>\n </button>\n )}\n </PopoverDisclosure>\n {!otherProps.disabled && (\n <BasePopover {...base} {...container}>\n {props.multiselect ? <MultiListbox {...commonListboxProps} /> : <Listbox {...commonListboxProps} />}\n </BasePopover>\n )}\n </span>\n );\n});\n\nexport const Select = React.forwardRef(function Select(props: SelectProps, ref: React.Ref<HTMLInputElement>) {\n const { editable, ...otherProps } = props;\n\n if (editable) {\n return <Combobox {...otherProps} inline ref={ref} />;\n }\n\n return <BaseSelect {...otherProps} ref={ref} />;\n});\n"],"names":["BaseSelect","React","props","ref","autoFocus","externalClassName","className","style","otherProps","useSelect","button","listbox","popover","text","more","container","base","internalRef","selectDimensions","useBoundingClientRectListener","cn","readOnly","inputClassname","getInputClasses","current","focus","renderMultiSelection","Badge","commonListboxProps","minWidth","width","tabIndex","visible","PopoverDisclosure","disclosureRef","multiselect","Icon","name","disabled","BasePopover","MultiListbox","Listbox","Select","editable","Combobox","inline"],"mappings":";;;;;;;;;;;;;;;AAyCA,IAAMA,UAAU,gBAAGC,UAAA,CAAiB,SAASD,UA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