@economic/taco 1.13.2 → 1.13.4
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.stories.d.ts +1 -0
- package/dist/components/IconButton/IconButton.stories.d.ts +1 -0
- package/dist/components/Popover/Popover.d.ts +1 -0
- package/dist/esm/packages/taco/src/components/AlertDialog/components/Content.js +2 -1
- package/dist/esm/packages/taco/src/components/AlertDialog/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Popover/Popover.js +8 -4
- package/dist/esm/packages/taco/src/components/Popover/Popover.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js +3 -3
- package/dist/esm/packages/taco/src/components/Select2/components/Edit.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/taco.cjs.development.js +14 -9
- 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/package.json +2 -2
- package/types.json +2 -2
@@ -17,6 +17,7 @@ declare const _default: {
|
|
17
17
|
}>>) => JSX.Element) | undefined;
|
18
18
|
menu?: ((props: Partial<import("../..").MenuProps>) => JSX.Element) | undefined;
|
19
19
|
popover?: ((props: Partial<React.PropsWithChildren<{
|
20
|
+
modal?: boolean | undefined;
|
20
21
|
trigger?: JSX.Element | undefined;
|
21
22
|
}>>) => JSX.Element) | undefined;
|
22
23
|
tooltip?: string | undefined;
|
@@ -12,6 +12,7 @@ declare const _default: {
|
|
12
12
|
icon: import("../..").IconName;
|
13
13
|
menu?: ((props: Partial<import("../..").MenuProps>) => JSX.Element) | undefined;
|
14
14
|
popover?: ((props: Partial<React.PropsWithChildren<{
|
15
|
+
modal?: boolean | undefined;
|
15
16
|
trigger?: JSX.Element | undefined;
|
16
17
|
}>>) => JSX.Element) | undefined;
|
17
18
|
rounded?: boolean | undefined;
|
@@ -12,6 +12,7 @@ export declare type PopoverContentProps = Omit<PopoverPrimitive.PopoverContentPr
|
|
12
12
|
};
|
13
13
|
export declare type PopoverCloseProps = React.HTMLAttributes<HTMLButtonElement>;
|
14
14
|
export declare type PopoverProps = React.PropsWithChildren<{
|
15
|
+
modal?: boolean;
|
15
16
|
/** A trigger to be used for the popover, should not be set if `children` already contains a trigger */
|
16
17
|
trigger?: JSX.Element;
|
17
18
|
}>;
|
@@ -17,7 +17,8 @@ const Content = /*#__PURE__*/forwardRef(function AlertDialogContent(props, ref)
|
|
17
17
|
asChild: true
|
18
18
|
}, /*#__PURE__*/createElement(Backdrop, null, /*#__PURE__*/createElement(Content$1, Object.assign({}, props, {
|
19
19
|
ref: ref,
|
20
|
-
className: className
|
20
|
+
className: className,
|
21
|
+
onEscapeKeyDown: event => event.preventDefault()
|
21
22
|
}), props.children))));
|
22
23
|
});
|
23
24
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Content.js","sources":["../../../../../../../../src/components/AlertDialog/components/Content.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';\nimport cn from 'classnames';\nimport { Backdrop } from '../../Backdrop/Backdrop';\nimport { getDialogPositionClassnames, getDialogSizeClassnames, getDialogStylingClassnames } from '../../Dialog/util';\n\nexport type AlertDialogTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function AlertDialogTitle(\n props: AlertDialogTitleProps,\n ref: React.Ref<HTMLHeadingElement>\n) {\n const className = cn('text-center', props.className);\n return <AlertDialogPrimitive.Title {...props} className={className} ref={ref} />;\n});\n\nexport type AlertDialogContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** An accessible label to be announced when the dialog is opened */\n 'aria-label': string;\n children: React.ReactNode;\n};\nexport const Content = React.forwardRef(function AlertDialogContent(\n props: AlertDialogContentProps,\n ref: React.Ref<HTMLDivElement>\n) {\n const className = cn('p-6', getDialogPositionClassnames(), getDialogStylingClassnames(), getDialogSizeClassnames('dialog'));\n\n return (\n <AlertDialogPrimitive.Portal>\n <AlertDialogPrimitive.Overlay asChild>\n <Backdrop>\n <AlertDialogPrimitive.Content
|
1
|
+
{"version":3,"file":"Content.js","sources":["../../../../../../../../src/components/AlertDialog/components/Content.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';\nimport cn from 'classnames';\nimport { Backdrop } from '../../Backdrop/Backdrop';\nimport { getDialogPositionClassnames, getDialogSizeClassnames, getDialogStylingClassnames } from '../../Dialog/util';\n\nexport type AlertDialogTitleProps = React.HTMLAttributes<HTMLHeadingElement>;\nexport const Title = React.forwardRef(function AlertDialogTitle(\n props: AlertDialogTitleProps,\n ref: React.Ref<HTMLHeadingElement>\n) {\n const className = cn('text-center', props.className);\n return <AlertDialogPrimitive.Title {...props} className={className} ref={ref} />;\n});\n\nexport type AlertDialogContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & {\n /** An accessible label to be announced when the dialog is opened */\n 'aria-label': string;\n children: React.ReactNode;\n};\nexport const Content = React.forwardRef(function AlertDialogContent(\n props: AlertDialogContentProps,\n ref: React.Ref<HTMLDivElement>\n) {\n const className = cn('p-6', getDialogPositionClassnames(), getDialogStylingClassnames(), getDialogSizeClassnames('dialog'));\n\n return (\n <AlertDialogPrimitive.Portal>\n <AlertDialogPrimitive.Overlay asChild>\n <Backdrop>\n <AlertDialogPrimitive.Content\n {...props}\n ref={ref}\n className={className}\n onEscapeKeyDown={event => event.preventDefault()}>\n {props.children}\n </AlertDialogPrimitive.Content>\n </Backdrop>\n </AlertDialogPrimitive.Overlay>\n </AlertDialogPrimitive.Portal>\n );\n});\n"],"names":["Title","React","AlertDialogTitle","props","ref","className","cn","AlertDialogPrimitive","Content","AlertDialogContent","getDialogPositionClassnames","getDialogStylingClassnames","getDialogSizeClassnames","asChild","Backdrop","onEscapeKeyDown","event","preventDefault","children"],"mappings":";;;;;;MAOaA,KAAK,gBAAGC,UAAgB,CAAC,SAASC,gBAAgB,CAC3DC,KAA4B,EAC5BC,GAAkC;EAElC,MAAMC,SAAS,GAAGC,EAAE,CAAC,aAAa,EAAEH,KAAK,CAACE,SAAS,CAAC;EACpD,oBAAOJ,cAACM,OAA0B,oBAAKJ,KAAK;IAAEE,SAAS,EAAEA,SAAS;IAAED,GAAG,EAAEA;KAAO;AACpF,CAAC;MAOYI,OAAO,gBAAGP,UAAgB,CAAC,SAASQ,kBAAkB,CAC/DN,KAA8B,EAC9BC,GAA8B;EAE9B,MAAMC,SAAS,GAAGC,EAAE,CAAC,KAAK,EAAEI,2BAA2B,EAAE,EAAEC,0BAA0B,EAAE,EAAEC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;EAE3H,oBACIX,cAACM,MAA2B,qBACxBN,cAACM,OAA4B;IAACM,OAAO;kBACjCZ,cAACa,QAAQ,qBACLb,cAACM,SAA4B,oBACrBJ,KAAK;IACTC,GAAG,EAAEA,GAAG;IACRC,SAAS,EAAEA,SAAS;IACpBU,eAAe,EAAEC,KAAK,IAAIA,KAAK,CAACC,cAAc;MAC7Cd,KAAK,CAACe,QAAQ,CACY,CACxB,CACgB,CACL;AAEtC,CAAC;;;;"}
|
@@ -41,7 +41,8 @@ const RenderPropWrapper = /*#__PURE__*/forwardRef(function RenderPropWrapper({
|
|
41
41
|
});
|
42
42
|
const Content = /*#__PURE__*/forwardRef(function PopoverContent(props, ref) {
|
43
43
|
const {
|
44
|
-
placement: side
|
44
|
+
placement: side,
|
45
|
+
...popoverContentProps
|
45
46
|
} = props;
|
46
47
|
const className = cn(getPopoverStyleClassnames(), props.className);
|
47
48
|
let output;
|
@@ -52,13 +53,13 @@ const Content = /*#__PURE__*/forwardRef(function PopoverContent(props, ref) {
|
|
52
53
|
} else {
|
53
54
|
output = props.children;
|
54
55
|
}
|
55
|
-
return /*#__PURE__*/createElement(Portal, null, /*#__PURE__*/createElement(Content$1, {
|
56
|
+
return /*#__PURE__*/createElement(Portal, null, /*#__PURE__*/createElement(Content$1, Object.assign({}, popoverContentProps, {
|
56
57
|
className: className,
|
57
58
|
"data-taco": "popover",
|
58
59
|
side: side,
|
59
60
|
sideOffset: 1,
|
60
61
|
ref: ref
|
61
|
-
}, output, /*#__PURE__*/createElement(UnstyledArrow, {
|
62
|
+
}), output, /*#__PURE__*/createElement(UnstyledArrow, {
|
62
63
|
className: "text-white"
|
63
64
|
})));
|
64
65
|
});
|
@@ -69,6 +70,7 @@ const Close = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/createElement
|
|
69
70
|
const Popover = /*#__PURE__*/forwardRef(function Popover(props, ref) {
|
70
71
|
const {
|
71
72
|
children,
|
73
|
+
modal = false,
|
72
74
|
trigger,
|
73
75
|
...otherProps
|
74
76
|
} = props;
|
@@ -78,7 +80,9 @@ const Popover = /*#__PURE__*/forwardRef(function Popover(props, ref) {
|
|
78
80
|
}), [otherProps]);
|
79
81
|
return /*#__PURE__*/createElement(PopoverContext.Provider, {
|
80
82
|
value: context
|
81
|
-
}, /*#__PURE__*/createElement(Root,
|
83
|
+
}, /*#__PURE__*/createElement(Root, {
|
84
|
+
modal: modal
|
85
|
+
}, trigger && /*#__PURE__*/createElement(Trigger, null, trigger), children));
|
82
86
|
});
|
83
87
|
Popover.Trigger = Trigger;
|
84
88
|
Popover.Content = Content;
|
@@ -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 } from './Primitives';\nimport { mergeRefs } from '../../utils/mergeRefs';\nimport { getPopoverStyleClassnames } from './util';\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<HTMLElement>;\nconst Trigger = React.forwardRef(function PopoverAnchor(props: PopoverTriggerProps, externalRef: React.Ref<HTMLElement>) {\n const { ref: parentRef, props: parentProps } = React.useContext(PopoverContext);\n const refCallback = mergeRefs([parentRef, externalRef]);\n\n let children = props.children;\n\n if (React.isValidElement(props.children) && typeof props.children?.type === 'function') {\n console.warn(\n `Popover.Trigger requires its child to forwardRef so that it can attach to the dom element. Did you mean to wrap '${props.children.type.name}' in React.forwardRef()? Taco has wrapped '${props.children.type.name}' in a 'span' to maintain functionality, but this may cause unintended behaviour`\n );\n children = <span>{props.children}</span>;\n }\n\n return <PopoverPrimitive.Trigger {...parentProps} {...props} children={children} ref={refCallback} asChild />;\n});\n\nconst RenderPropWrapper = React.forwardRef(function RenderPropWrapper({ 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<PopoverPrimitive.PopoverContentProps, 'side'> & {\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(function PopoverContent(props: PopoverContentProps, ref: React.Ref<HTMLDivElement>) {\n const { placement: side } = props;\n const className = cn(getPopoverStyleClassnames(), 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 <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content
|
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 } from './Primitives';\nimport { mergeRefs } from '../../utils/mergeRefs';\nimport { getPopoverStyleClassnames } from './util';\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<HTMLElement>;\nconst Trigger = React.forwardRef(function PopoverAnchor(props: PopoverTriggerProps, externalRef: React.Ref<HTMLElement>) {\n const { ref: parentRef, props: parentProps } = React.useContext(PopoverContext);\n const refCallback = mergeRefs([parentRef, externalRef]);\n\n let children = props.children;\n\n if (React.isValidElement(props.children) && typeof props.children?.type === 'function') {\n console.warn(\n `Popover.Trigger requires its child to forwardRef so that it can attach to the dom element. Did you mean to wrap '${props.children.type.name}' in React.forwardRef()? Taco has wrapped '${props.children.type.name}' in a 'span' to maintain functionality, but this may cause unintended behaviour`\n );\n children = <span>{props.children}</span>;\n }\n\n return <PopoverPrimitive.Trigger {...parentProps} {...props} children={children} ref={refCallback} asChild />;\n});\n\nconst RenderPropWrapper = React.forwardRef(function RenderPropWrapper({ 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<PopoverPrimitive.PopoverContentProps, 'side'> & {\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(function PopoverContent(props: PopoverContentProps, ref: React.Ref<HTMLDivElement>) {\n const { placement: side, ...popoverContentProps } = props;\n const className = cn(getPopoverStyleClassnames(), 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 <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n {...popoverContentProps}\n className={className}\n data-taco=\"popover\"\n side={side}\n sideOffset={1}\n ref={ref}>\n {output}\n <UnstyledArrow className=\"text-white\" />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\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<{\n modal?: boolean;\n /** A trigger to be used for the popover, should not be set if `children` already contains a trigger */\n trigger?: JSX.Element;\n}>;\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 Portal: React.FunctionComponent<PopoverPrimitive.PortalProps>;\n};\n\nexport const Popover = React.forwardRef<HTMLElement, PopoverProps>(function Popover(props, ref) {\n const { children, modal = false, trigger, ...otherProps } = props;\n const context = React.useMemo(() => ({ props: otherProps, ref }), [otherProps]);\n\n return (\n <PopoverContext.Provider value={context}>\n <PopoverPrimitive.Root modal={modal}>\n {trigger && <Trigger>{trigger}</Trigger>}\n {children}\n </PopoverPrimitive.Root>\n </PopoverContext.Provider>\n );\n}) as ForwardedPopoverWithStatics;\nPopover.Trigger = Trigger;\nPopover.Content = Content;\nPopover.Close = Close;\nPopover.Portal = PopoverPrimitive.Portal;\n"],"names":["PopoverContext","React","props","ref","Trigger","PopoverAnchor","externalRef","parentRef","parentProps","refCallback","mergeRefs","children","type","console","warn","name","PopoverPrimitive","asChild","RenderPropWrapper","onClick","close","CustomEvent","Content","PopoverContent","placement","side","popoverContentProps","className","cn","getPopoverStyleClassnames","output","sideOffset","UnstyledArrow","Close","Popover","modal","trigger","otherProps","context","Provider","value","Portal"],"mappings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;IAACmB,KAAK,EAAEA;KACzBC,OAAO,iBAAInC,cAACG,OAAO,QAAEgC,OAAO,CAAW,EACvCzB,QAAQ,CACW,CACF;AAElC,CAAC;AACDuB,OAAO,CAAC9B,OAAO,GAAGA,OAAO;AACzB8B,OAAO,CAACZ,OAAO,GAAGA,OAAO;AACzBY,OAAO,CAACD,KAAK,GAAGA,KAAK;AACrBC,OAAO,CAACO,MAAM,GAAGzB,MAAuB;;;;"}
|
@@ -111,8 +111,8 @@ const EditPopover = props => {
|
|
111
111
|
event.stopPropagation();
|
112
112
|
}
|
113
113
|
};
|
114
|
-
return /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps
|
115
|
-
|
114
|
+
return /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps, {
|
115
|
+
modal: true
|
116
116
|
}), /*#__PURE__*/React__default.createElement(Popover.Content, {
|
117
117
|
onCloseAutoFocus: handleCloseAutoFocus,
|
118
118
|
onInteractOutside: handleInteractOutside,
|
@@ -152,7 +152,7 @@ const EditPopover = props => {
|
|
152
152
|
}, /*#__PURE__*/React__default.createElement(Icon, {
|
153
153
|
className: "!h-5 !w-5",
|
154
154
|
name: "delete-permanently"
|
155
|
-
}), " ", texts.select2.delete) : null))))
|
155
|
+
}), " ", texts.select2.delete) : null))));
|
156
156
|
};
|
157
157
|
const Colours = props => {
|
158
158
|
const {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Edit.js","sources":["../../../../../../../../src/components/Select2/components/Edit.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport * as RadioGroup from '@radix-ui/react-radio-group';\nimport { Color, colors } from '../../../utils/colors';\nimport { Button } from '../../Button/Button';\nimport { Input } from '../../Input/Input';\nimport { Popover, PopoverProps } from '../../Popover/Popover';\nimport { Icon } from '../../Icon/Icon';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Field } from '../../Field/Field';\nimport { Group } from '../../Group/Group';\nimport { useLocalization } from '../../Provider/Provider';\n\nconst AVAILABLE_COLORS = Object.keys(colors);\n\nexport type EditPopoverProps = PopoverProps & {\n color?: Color;\n text: string;\n value: Select2OptionValue;\n};\n\nexport const EditPopover = (props: EditPopoverProps) => {\n const { color: initialColor, text: initialName, value, ...popoverProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\n const { onDelete, onEdit, searchRef, ref: selectRef } = useSelect2Context();\n const { texts } = useLocalization();\n const [name, setName] = React.useState(initialName);\n const [color, setColor] = React.useState(initialColor);\n const [validationError, setValidationError] = React.useState<Error | undefined>();\n\n const handleInputChange = event => {\n setName(event.target.value);\n setValidationError(undefined);\n };\n\n const handleInputKeyDown = close => async event => {\n event.stopPropagation();\n\n if (event.key === 'Escape') {\n close();\n } else if (event.key === 'Enter') {\n handleSave(close)(event);\n }\n };\n\n const handleDelete = close => async event => {\n event.stopPropagation();\n close();\n\n if (onDelete) {\n await onDelete(value);\n }\n };\n\n const handleSave = close => async event => {\n if (onEdit && (name !== initialName || color !== initialColor)) {\n try {\n await onEdit(value, name, color);\n close();\n } catch (error) {\n event.preventDefault();\n event.stopPropagation();\n setValidationError(error);\n ref.current?.focus();\n }\n } else {\n close();\n }\n };\n\n const handleCloseAutoFocus = event => {\n event.preventDefault();\n setName(initialName);\n setColor(initialColor);\n setValidationError(undefined);\n\n if (searchRef?.current) {\n searchRef.current?.focus();\n } else {\n selectRef.current?.focus();\n }\n };\n\n const handleInteractOutside = () => {\n setName(initialName);\n setColor(initialColor);\n };\n\n const preventKeyDownPropagation = event => {\n if (event.key !== 'Escape') {\n event.stopPropagation();\n }\n };\n\n return (\n <Popover {...popoverProps}>\n <Popover.Portal>\n <>\n {/* This invisible backdrop prevents clicks outside the Edit popover from also closing the Select2 popover */}\n <div className=\"absolute h-screen w-screen\" />\n <Popover.Content\n onCloseAutoFocus={handleCloseAutoFocus}\n onInteractOutside={handleInteractOutside}\n onClick={event => event.stopPropagation()}\n placement=\"right\"\n tabIndex={-1}\n className=\"focus:!shadow-none\">\n {({ close }) => (\n <>\n <div className=\"flex w-32 flex-col space-y-2\">\n {onEdit ? (\n <>\n <Field\n className={cn('!min-h-fit', { '!pb-0': !validationError })}\n invalid={!!validationError}\n message={validationError?.message}>\n <Input\n invalid={!!validationError}\n onChange={handleInputChange}\n onKeyDown={handleInputKeyDown(close)}\n ref={ref}\n value={name}\n />\n </Field>\n {initialColor ? (\n <>\n <h5>Colours</h5>\n <Colours\n color={color}\n onChangeColor={setColor}\n onKeyDown={preventKeyDownPropagation}\n />\n </>\n ) : null}\n <Group>\n <Button onClick={close}>{texts.select2.cancel}</Button>\n <Button appearance=\"primary\" onClick={handleSave(close)}>\n {texts.select2.save}\n </Button>\n </Group>\n </>\n ) : null}\n {onEdit && onDelete ? <hr /> : null}\n {onDelete ? (\n <button\n className=\"hover:text-grey-darkest flex items-center justify-start gap-1\"\n onClick={handleDelete(close)}\n onKeyDown={preventKeyDownPropagation}>\n <Icon className=\"!h-5 !w-5\" name=\"delete-permanently\" /> {texts.select2.delete}\n </button>\n ) : null}\n </div>\n </>\n )}\n </Popover.Content>\n </>\n </Popover.Portal>\n </Popover>\n );\n};\n\nconst Colours = props => {\n const { color, onChangeColor, onClick, onKeyDown } = props;\n const { texts } = useLocalization();\n\n return (\n <RadioGroup.Root\n aria-label={texts.select2.chooseColor}\n className=\"grid grid-cols-4 gap-2 focus:outline-none\"\n onClick={onClick}\n onKeyDown={onKeyDown}\n onValueChange={color => onChangeColor(color)}\n value={color}>\n {AVAILABLE_COLORS.map((availableColor: string) => (\n <RadioGroup.Item\n aria-label={color}\n className={cn('flex h-6 w-6 cursor-pointer items-center justify-center rounded', colors[availableColor])}\n key={availableColor}\n onFocus={() => onChangeColor(availableColor)}\n value={availableColor}>\n <RadioGroup.Indicator asChild>\n <Icon name=\"tick\" className=\"!h-5 !w-5\" />\n </RadioGroup.Indicator>\n </RadioGroup.Item>\n ))}\n </RadioGroup.Root>\n );\n};\n"],"names":["AVAILABLE_COLORS","Object","keys","colors","EditPopover","props","color","initialColor","text","initialName","value","popoverProps","ref","React","useRef","onDelete","onEdit","searchRef","selectRef","useSelect2Context","texts","useLocalization","name","setName","useState","setColor","validationError","setValidationError","handleInputChange","event","target","undefined","handleInputKeyDown","close","stopPropagation","key","handleSave","handleDelete","error","preventDefault","current","focus","handleCloseAutoFocus","handleInteractOutside","preventKeyDownPropagation","Popover","Portal","className","Content","onCloseAutoFocus","onInteractOutside","onClick","placement","tabIndex","Field","cn","invalid","message","Input","onChange","onKeyDown","Colours","onChangeColor","Group","Button","select2","cancel","appearance","save","Icon","delete","RadioGroup","chooseColor","onValueChange","map","availableColor","onFocus","asChild"],"mappings":";;;;;;;;;;;;;;AAcA,MAAMA,gBAAgB,gBAAGC,MAAM,CAACC,IAAI,CAACC,MAAM,CAAC;MAQ/BC,WAAW,GAAIC,KAAuB;EAC/C,MAAM;IAAEC,KAAK,EAAEC,YAAY;IAAEC,IAAI,EAAEC,WAAW;IAAEC,KAAK;IAAE,GAAGC;GAAc,GAAGN,KAAK;EAChF,MAAMO,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAmB,IAAI,CAAC;EAChD,MAAM;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,SAAS;IAAEL,GAAG,EAAEM;GAAW,GAAGC,iBAAiB,EAAE;EAC3E,MAAM;IAAEC;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGV,cAAK,CAACW,QAAQ,CAACf,WAAW,CAAC;EACnD,MAAM,CAACH,KAAK,EAAEmB,QAAQ,CAAC,GAAGZ,cAAK,CAACW,QAAQ,CAACjB,YAAY,CAAC;EACtD,MAAM,CAACmB,eAAe,EAAEC,kBAAkB,CAAC,GAAGd,cAAK,CAACW,QAAQ,EAAqB;EAEjF,MAAMI,iBAAiB,GAAGC,KAAK;IAC3BN,OAAO,CAACM,KAAK,CAACC,MAAM,CAACpB,KAAK,CAAC;IAC3BiB,kBAAkB,CAACI,SAAS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AEQ,EAAE,CAAC,iEAAiE,EAAEpD,MAAM,CAACwE,cAAc,CAAC,CAAC;IACxGxC,GAAG,EAAEwC,cAAc;IACnBC,OAAO,EAAE,MAAMd,aAAa,CAACa,cAAc,CAAC;IAC5CjE,KAAK,EAAEiE;kBACP9D,6BAAC0D,SAAoB;IAACM,OAAO;kBACzBhE,6BAACwD,IAAI;IAAC/C,IAAI,EAAC,MAAM;IAACyB,SAAS,EAAC;IAAc,CACvB,CAE9B,CAAC,CACY;AAE1B,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"Edit.js","sources":["../../../../../../../../src/components/Select2/components/Edit.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport * as RadioGroup from '@radix-ui/react-radio-group';\nimport { Color, colors } from '../../../utils/colors';\nimport { Button } from '../../Button/Button';\nimport { Input } from '../../Input/Input';\nimport { Popover, PopoverProps } from '../../Popover/Popover';\nimport { Icon } from '../../Icon/Icon';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Field } from '../../Field/Field';\nimport { Group } from '../../Group/Group';\nimport { useLocalization } from '../../Provider/Provider';\n\nconst AVAILABLE_COLORS = Object.keys(colors);\n\nexport type EditPopoverProps = PopoverProps & {\n color?: Color;\n text: string;\n value: Select2OptionValue;\n};\n\nexport const EditPopover = (props: EditPopoverProps) => {\n const { color: initialColor, text: initialName, value, ...popoverProps } = props;\n const ref = React.useRef<HTMLInputElement>(null);\n const { onDelete, onEdit, searchRef, ref: selectRef } = useSelect2Context();\n const { texts } = useLocalization();\n const [name, setName] = React.useState(initialName);\n const [color, setColor] = React.useState(initialColor);\n const [validationError, setValidationError] = React.useState<Error | undefined>();\n\n const handleInputChange = event => {\n setName(event.target.value);\n setValidationError(undefined);\n };\n\n const handleInputKeyDown = close => async event => {\n event.stopPropagation();\n\n if (event.key === 'Escape') {\n close();\n } else if (event.key === 'Enter') {\n handleSave(close)(event);\n }\n };\n\n const handleDelete = close => async event => {\n event.stopPropagation();\n close();\n\n if (onDelete) {\n await onDelete(value);\n }\n };\n\n const handleSave = close => async event => {\n if (onEdit && (name !== initialName || color !== initialColor)) {\n try {\n await onEdit(value, name, color);\n close();\n } catch (error) {\n event.preventDefault();\n event.stopPropagation();\n setValidationError(error);\n ref.current?.focus();\n }\n } else {\n close();\n }\n };\n\n const handleCloseAutoFocus = event => {\n event.preventDefault();\n setName(initialName);\n setColor(initialColor);\n setValidationError(undefined);\n\n if (searchRef?.current) {\n searchRef.current?.focus();\n } else {\n selectRef.current?.focus();\n }\n };\n\n const handleInteractOutside = () => {\n setName(initialName);\n setColor(initialColor);\n };\n\n const preventKeyDownPropagation = event => {\n if (event.key !== 'Escape') {\n event.stopPropagation();\n }\n };\n\n return (\n <Popover {...popoverProps} modal>\n <Popover.Content\n onCloseAutoFocus={handleCloseAutoFocus}\n onInteractOutside={handleInteractOutside}\n onClick={event => event.stopPropagation()}\n placement=\"right\"\n tabIndex={-1}\n className=\"focus:!shadow-none\">\n {({ close }) => (\n <>\n <div className=\"flex w-32 flex-col space-y-2\">\n {onEdit ? (\n <>\n <Field\n className={cn('!min-h-fit', { '!pb-0': !validationError })}\n invalid={!!validationError}\n message={validationError?.message}>\n <Input\n invalid={!!validationError}\n onChange={handleInputChange}\n onKeyDown={handleInputKeyDown(close)}\n ref={ref}\n value={name}\n />\n </Field>\n {initialColor ? (\n <>\n <h5>Colours</h5>\n <Colours\n color={color}\n onChangeColor={setColor}\n onKeyDown={preventKeyDownPropagation}\n />\n </>\n ) : null}\n <Group>\n <Button onClick={close}>{texts.select2.cancel}</Button>\n <Button appearance=\"primary\" onClick={handleSave(close)}>\n {texts.select2.save}\n </Button>\n </Group>\n </>\n ) : null}\n {onEdit && onDelete ? <hr /> : null}\n {onDelete ? (\n <button\n className=\"hover:text-grey-darkest flex items-center justify-start gap-1\"\n onClick={handleDelete(close)}\n onKeyDown={preventKeyDownPropagation}>\n <Icon className=\"!h-5 !w-5\" name=\"delete-permanently\" /> {texts.select2.delete}\n </button>\n ) : null}\n </div>\n </>\n )}\n </Popover.Content>\n </Popover>\n );\n};\n\nconst Colours = props => {\n const { color, onChangeColor, onClick, onKeyDown } = props;\n const { texts } = useLocalization();\n\n return (\n <RadioGroup.Root\n aria-label={texts.select2.chooseColor}\n className=\"grid grid-cols-4 gap-2 focus:outline-none\"\n onClick={onClick}\n onKeyDown={onKeyDown}\n onValueChange={color => onChangeColor(color)}\n value={color}>\n {AVAILABLE_COLORS.map((availableColor: string) => (\n <RadioGroup.Item\n aria-label={color}\n className={cn('flex h-6 w-6 cursor-pointer items-center justify-center rounded', colors[availableColor])}\n key={availableColor}\n onFocus={() => onChangeColor(availableColor)}\n value={availableColor}>\n <RadioGroup.Indicator asChild>\n <Icon name=\"tick\" className=\"!h-5 !w-5\" />\n </RadioGroup.Indicator>\n </RadioGroup.Item>\n ))}\n </RadioGroup.Root>\n );\n};\n"],"names":["AVAILABLE_COLORS","Object","keys","colors","EditPopover","props","color","initialColor","text","initialName","value","popoverProps","ref","React","useRef","onDelete","onEdit","searchRef","selectRef","useSelect2Context","texts","useLocalization","name","setName","useState","setColor","validationError","setValidationError","handleInputChange","event","target","undefined","handleInputKeyDown","close","stopPropagation","key","handleSave","handleDelete","error","preventDefault","current","focus","handleCloseAutoFocus","handleInteractOutside","preventKeyDownPropagation","Popover","modal","Content","onCloseAutoFocus","onInteractOutside","onClick","placement","tabIndex","className","Field","cn","invalid","message","Input","onChange","onKeyDown","Colours","onChangeColor","Group","Button","select2","cancel","appearance","save","Icon","delete","RadioGroup","chooseColor","onValueChange","map","availableColor","onFocus","asChild"],"mappings":";;;;;;;;;;;;;;AAcA,MAAMA,gBAAgB,gBAAGC,MAAM,CAACC,IAAI,CAACC,MAAM,CAAC;MAQ/BC,WAAW,GAAIC,KAAuB;EAC/C,MAAM;IAAEC,KAAK,EAAEC,YAAY;IAAEC,IAAI,EAAEC,WAAW;IAAEC,KAAK;IAAE,GAAGC;GAAc,GAAGN,KAAK;EAChF,MAAMO,GAA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;AAElB;AAEA,MAAMT,OAAO,GAAGxD,KAAK;EACjB,MAAM;IAAEC,KAAK;IAAEwD,aAAa;IAAEZ,OAAO;IAAEU;GAAW,GAAGvD,KAAK;EAC1D,MAAM;IAAEe;GAAO,GAAGC,eAAe,EAAE;EAEnC,oBACIR,6BAAC0D,IAAe;kBACAnD,KAAK,CAAC6C,OAAO,CAACO,WAAW;IACrCnB,SAAS,EAAC,2CAA2C;IACrDH,OAAO,EAAEA,OAAO;IAChBU,SAAS,EAAEA,SAAS;IACpBa,aAAa,EAAEnE,KAAK,IAAIwD,aAAa,CAACxD,KAAK,CAAC;IAC5CI,KAAK,EAAEJ;KACNN,gBAAgB,CAAC0E,GAAG,CAAEC,cAAsB,iBACzC9D,6BAAC0D,IAAe;kBACAjE,KAAK;IACjB+C,SAAS,EAAEE,EAAE,CAAC,iEAAiE,EAAEpD,MAAM,CAACwE,cAAc,CAAC,CAAC;IACxGxC,GAAG,EAAEwC,cAAc;IACnBC,OAAO,EAAE,MAAMd,aAAa,CAACa,cAAc,CAAC;IAC5CjE,KAAK,EAAEiE;kBACP9D,6BAAC0D,SAAoB;IAACM,OAAO;kBACzBhE,6BAACwD,IAAI;IAAC/C,IAAI,EAAC,MAAM;IAAC+B,SAAS,EAAC;IAAc,CACvB,CAE9B,CAAC,CACY;AAE1B,CAAC;;;;"}
|
@@ -71,7 +71,7 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Select2TriggerBut
|
|
71
71
|
type: "button"
|
72
72
|
}), children, /*#__PURE__*/React__default.createElement(Icon, {
|
73
73
|
name: open ? 'chevron-up' : 'chevron-down',
|
74
|
-
className: "-
|
74
|
+
className: "-mr-1 ml-auto"
|
75
75
|
}));
|
76
76
|
});
|
77
77
|
const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSingle(props, ref) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Trigger.js","sources":["../../../../../../../../src/components/Select2/components/Trigger.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Tag } from '../../Tag/Tag';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { Icon } from '../../Icon/Icon';\nimport { Badge } from '../../Badge/Badge';\nimport { getInputClasses } from '../../Input/util';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { getIndexOfFirstChildOverflowingParent } from '../../../utils/dom';\nimport { ScrollArea } from '../../ScrollArea/ScrollArea';\n\ntype Select2TriggerProps = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n children: React.ReactElement<Select2OptionProps>[];\n};\n\nexport const Trigger = React.forwardRef<HTMLButtonElement, Select2TriggerProps>(function Select2Trigger(props, ref) {\n const { multiple, value } = useSelect2Context();\n\n if (Array.isArray(value) || multiple) {\n const values = Array.isArray(value) ? value : value !== undefined ? [value] : undefined;\n return <Multiple {...props} ref={ref} values={values} />;\n }\n\n return <Single {...props} ref={ref} value={value} />;\n});\n\ntype ButtonProps = React.HTMLAttributes<HTMLButtonElement> &\n Omit<Select2TriggerProps, 'children' | 'open' | 'setValue' | 'value'>;\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Select2TriggerButton(props, ref) {\n const { children, onClick, tabIndex = 0, ...otherProps } = props;\n const { disabled, highlighted, invalid, open, readOnly } = useSelect2Context();\n\n const className = cn(\n 'cursor-pointer !px-1.5',\n getInputClasses({ ...props, disabled, highlighted, invalid, readOnly }).replace('w-full ', ''),\n { 'w-full': !props.className?.includes('w-') },\n props.className\n );\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled || readOnly) {\n event.preventDefault();\n return;\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n };\n\n return (\n <button\n {...otherProps}\n aria-invalid={invalid ? true : undefined}\n aria-readonly={readOnly ? true : undefined}\n className={className}\n disabled={disabled}\n onClick={handleClick}\n ref={ref}\n role=\"combobox\"\n tabIndex={disabled || readOnly ? -1 : tabIndex}\n type=\"button\">\n {children}\n <Icon name={open ? 'chevron-up' : 'chevron-down'} className=\"-mx-1 ml-auto\" />\n </button>\n );\n});\n\ntype SingleProps = Omit<Select2TriggerProps, 'value'> & { value?: Select2OptionValue };\n\nconst Single = React.forwardRef<HTMLButtonElement, SingleProps>(function Select2TriggerSingle(props, ref) {\n const { children, value, ...buttonProps } = props;\n const { disabled, readOnly, tags } = useSelect2Context();\n const contentClassName = cn('truncate', {\n 'flex gap-1': tags,\n });\n\n const currentValue = children.find(matchesValue(value));\n\n let output;\n\n if (currentValue) {\n if (tags) {\n output = (\n <Tag\n className=\"truncate\"\n color={currentValue.props.color}\n disabled={disabled}\n icon={currentValue.props.icon}\n readOnly={readOnly}>\n {currentValue.props.children}\n </Tag>\n );\n } else {\n output = (\n <>\n {currentValue.props.icon ? (\n typeof currentValue.props.icon === 'string' ? (\n <Icon className=\"mr-1\" name={currentValue.props.icon} />\n ) : (\n currentValue.props.icon\n )\n ) : null}\n {currentValue.props.children}\n </>\n );\n }\n }\n\n return (\n <Button {...buttonProps} ref={ref}>\n <span className={contentClassName}>{output}</span>\n </Button>\n );\n});\n\ntype MultipleProps = Omit<Select2TriggerProps, 'value'> & {\n values?: Select2OptionValue[];\n};\n\nconst Multiple = React.forwardRef<HTMLButtonElement, MultipleProps>(function Select2TriggerMultiple(props, ref) {\n const { children, values = [], ...buttonProps } = props;\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const contentRef = React.useRef<HTMLSpanElement>(null);\n\n const createClickHandler = tagValue => event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(tagValue);\n }\n };\n const valuesAsChildren = values.map(value =>\n children.find(c => c.props.value === value)\n ) as React.ReactElement<Select2OptionProps>[];\n\n if (open) {\n return (\n <span className=\"relative h-8\">\n <Button {...buttonProps} className={cn('absolute z-20', buttonProps.className)} ref={ref}>\n <ScrollArea className=\"my-1 flex max-h-[5.5rem] flex-col\">\n <span className=\"flex flex-wrap gap-1\">\n {valuesAsChildren.map(child => (\n <Tag\n key={child.props.value}\n className=\"truncate\"\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.icon}\n onDelete={open ? createClickHandler(child.props.value) : undefined}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n ))}\n </span>\n </ScrollArea>\n </Button>\n </span>\n );\n }\n\n const boundaryIndex = contentRef.current ? getIndexOfFirstChildOverflowingParent(contentRef.current, 30) : undefined;\n\n return (\n <Button {...buttonProps} ref={ref}>\n <span className=\"relative flex items-center gap-1 overflow-hidden\">\n <span className=\"flex gap-1 truncate\" ref={contentRef}>\n {valuesAsChildren.map((child, index) => {\n const tag = (\n <Tag\n key={child.props.value}\n className={cn('cursor-pointer', {\n truncate: index === boundaryIndex,\n hidden: boundaryIndex !== undefined && boundaryIndex !== null ? index > boundaryIndex : false,\n })}\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.icon}\n onDelete={open ? createClickHandler(child.props.value) : undefined}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n );\n\n if (index === boundaryIndex) {\n return (\n <Tooltip key={child.props.value} title={String(child.props.children)}>\n {tag}\n </Tooltip>\n );\n }\n\n return tag;\n })}\n </span>\n {boundaryIndex !== undefined && boundaryIndex !== null && boundaryIndex < valuesAsChildren.length - 1 ? (\n <Tooltip\n title={valuesAsChildren\n .slice(boundaryIndex + 1)\n .map(child => (child ? String(child.props.children) : ''))\n .join(', ')}>\n <Badge className=\"flex-shrink-0\">+{valuesAsChildren.length - (boundaryIndex + 1)}</Badge>\n </Tooltip>\n ) : null}\n </span>\n </Button>\n );\n});\n\nconst matchesValue = (value: undefined | any | any[]) => (child: React.ReactElement<any>) => {\n if (Array.isArray(value)) {\n return value.includes(child.props.value);\n }\n\n return child.props.value === value;\n};\n"],"names":["Trigger","React","forwardRef","Select2Trigger","props","ref","multiple","value","useSelect2Context","Array","isArray","values","undefined","Multiple","Single","Button","Select2TriggerButton","children","onClick","tabIndex","otherProps","disabled","highlighted","invalid","open","readOnly","className","cn","getInputClasses","replace","includes","handleClick","event","preventDefault","role","type","Icon","name","Select2TriggerSingle","buttonProps","tags","contentClassName","currentValue","find","matchesValue","output","Tag","color","icon","Select2TriggerMultiple","setValue","contentRef","useRef","createClickHandler","tagValue","stopPropagation","valuesAsChildren","map","c","ScrollArea","child","key","onDelete","boundaryIndex","current","getIndexOfFirstChildOverflowingParent","index","tag","truncate","hidden","Tooltip","title","String","length","slice","join","Badge"],"mappings":";;;;;;;;;;;MAiBaA,OAAO,gBAAGC,cAAK,CAACC,UAAU,CAAyC,SAASC,cAAc,CAACC,KAAK,EAAEC,GAAG;EAC9G,MAAM;IAAEC,QAAQ;IAAEC;GAAO,GAAGC,iBAAiB,EAAE;EAE/C,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAID,QAAQ,EAAE;IAClC,MAAMK,MAAM,GAAGF,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGA,KAAK,GAAGA,KAAK,KAAKK,SAAS,GAAG,CAACL,KAAK,CAAC,GAAGK,SAAS;IACvF,oBAAOX,6BAACY,QAAQ,oBAAKT,KAAK;MAAEC,GAAG,EAAEA,GAAG;MAAEM,MAAM,EAAEA;OAAU;;EAG5D,oBAAOV,6BAACa,MAAM,oBAAKV,KAAK;IAAEC,GAAG,EAAEA,GAAG;IAAEE,KAAK,EAAEA;KAAS;AACxD,CAAC;AAKD,MAAMQ,MAAM,gBAAGd,cAAK,CAACC,UAAU,CAAiC,SAASc,oBAAoB,CAACZ,KAAK,EAAEC,GAAG;;EACpG,MAAM;IAAEY,QAAQ;IAAEC,OAAO;IAAEC,QAAQ,GAAG,CAAC;IAAE,GAAGC;GAAY,GAAGhB,KAAK;EAChE,MAAM;IAAEiB,QAAQ;IAAEC,WAAW;IAAEC,OAAO;IAAEC,IAAI;IAAEC;GAAU,GAAGjB,iBAAiB,EAAE;EAE9E,MAAMkB,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AK,CAACa,QAAQ;SAC9DkD,GAAG,CACE;;IAIlB,OAAOA,GAAG;GACb,CAAC,CACC,EACNJ,aAAa,KAAKnD,SAAS,IAAImD,aAAa,KAAK,IAAI,IAAIA,aAAa,GAAGP,gBAAgB,CAACiB,MAAM,GAAG,CAAC,gBACjGxE,6BAACqE,OAAO;IACJC,KAAK,EAAEf,gBAAgB,CAClBkB,KAAK,CAACX,aAAa,GAAG,CAAC,CAAC,CACxBN,GAAG,CAACG,KAAK,IAAKA,KAAK,GAAGY,MAAM,CAACZ,KAAK,CAACxD,KAAK,CAACa,QAAQ,CAAC,GAAG,EAAG,CAAC,CACzD0D,IAAI,CAAC,IAAI;kBACd1E,6BAAC2E,KAAK;IAAClD,SAAS,EAAC;UAAkB8B,gBAAgB,CAACiB,MAAM,IAAIV,aAAa,GAAG,CAAC,CAAC,CAAS,CACnF,GACV,IAAI,CACL,CACF;AAEjB,CAAC,CAAC;AAEF,MAAMnB,YAAY,GAAIrC,KAA8B,IAAMqD,KAA8B;EACpF,IAAInD,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACuB,QAAQ,CAAC8B,KAAK,CAACxD,KAAK,CAACG,KAAK,CAAC;;EAG5C,OAAOqD,KAAK,CAACxD,KAAK,CAACG,KAAK,KAAKA,KAAK;AACtC,CAAC;;;;"}
|
1
|
+
{"version":3,"file":"Trigger.js","sources":["../../../../../../../../src/components/Select2/components/Trigger.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Tag } from '../../Tag/Tag';\nimport { Tooltip } from '../../Tooltip/Tooltip';\nimport { Icon } from '../../Icon/Icon';\nimport { Badge } from '../../Badge/Badge';\nimport { getInputClasses } from '../../Input/util';\nimport { Select2OptionValue } from '../types';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { getIndexOfFirstChildOverflowingParent } from '../../../utils/dom';\nimport { ScrollArea } from '../../ScrollArea/ScrollArea';\n\ntype Select2TriggerProps = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n children: React.ReactElement<Select2OptionProps>[];\n};\n\nexport const Trigger = React.forwardRef<HTMLButtonElement, Select2TriggerProps>(function Select2Trigger(props, ref) {\n const { multiple, value } = useSelect2Context();\n\n if (Array.isArray(value) || multiple) {\n const values = Array.isArray(value) ? value : value !== undefined ? [value] : undefined;\n return <Multiple {...props} ref={ref} values={values} />;\n }\n\n return <Single {...props} ref={ref} value={value} />;\n});\n\ntype ButtonProps = React.HTMLAttributes<HTMLButtonElement> &\n Omit<Select2TriggerProps, 'children' | 'open' | 'setValue' | 'value'>;\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Select2TriggerButton(props, ref) {\n const { children, onClick, tabIndex = 0, ...otherProps } = props;\n const { disabled, highlighted, invalid, open, readOnly } = useSelect2Context();\n\n const className = cn(\n 'cursor-pointer !px-1.5',\n getInputClasses({ ...props, disabled, highlighted, invalid, readOnly }).replace('w-full ', ''),\n { 'w-full': !props.className?.includes('w-') },\n props.className\n );\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n if (disabled || readOnly) {\n event.preventDefault();\n return;\n }\n\n if (typeof onClick === 'function') {\n onClick(event);\n }\n };\n\n return (\n <button\n {...otherProps}\n aria-invalid={invalid ? true : undefined}\n aria-readonly={readOnly ? true : undefined}\n className={className}\n disabled={disabled}\n onClick={handleClick}\n ref={ref}\n role=\"combobox\"\n tabIndex={disabled || readOnly ? -1 : tabIndex}\n type=\"button\">\n {children}\n <Icon name={open ? 'chevron-up' : 'chevron-down'} className=\"-mr-1 ml-auto\" />\n </button>\n );\n});\n\ntype SingleProps = Omit<Select2TriggerProps, 'value'> & { value?: Select2OptionValue };\n\nconst Single = React.forwardRef<HTMLButtonElement, SingleProps>(function Select2TriggerSingle(props, ref) {\n const { children, value, ...buttonProps } = props;\n const { disabled, readOnly, tags } = useSelect2Context();\n const contentClassName = cn('truncate', {\n 'flex gap-1': tags,\n });\n\n const currentValue = children.find(matchesValue(value));\n\n let output;\n\n if (currentValue) {\n if (tags) {\n output = (\n <Tag\n className=\"truncate\"\n color={currentValue.props.color}\n disabled={disabled}\n icon={currentValue.props.icon}\n readOnly={readOnly}>\n {currentValue.props.children}\n </Tag>\n );\n } else {\n output = (\n <>\n {currentValue.props.icon ? (\n typeof currentValue.props.icon === 'string' ? (\n <Icon className=\"mr-1\" name={currentValue.props.icon} />\n ) : (\n currentValue.props.icon\n )\n ) : null}\n {currentValue.props.children}\n </>\n );\n }\n }\n\n return (\n <Button {...buttonProps} ref={ref}>\n <span className={contentClassName}>{output}</span>\n </Button>\n );\n});\n\ntype MultipleProps = Omit<Select2TriggerProps, 'value'> & {\n values?: Select2OptionValue[];\n};\n\nconst Multiple = React.forwardRef<HTMLButtonElement, MultipleProps>(function Select2TriggerMultiple(props, ref) {\n const { children, values = [], ...buttonProps } = props;\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const contentRef = React.useRef<HTMLSpanElement>(null);\n\n const createClickHandler = tagValue => event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(tagValue);\n }\n };\n const valuesAsChildren = values.map(value =>\n children.find(c => c.props.value === value)\n ) as React.ReactElement<Select2OptionProps>[];\n\n if (open) {\n return (\n <span className=\"relative h-8\">\n <Button {...buttonProps} className={cn('absolute z-20', buttonProps.className)} ref={ref}>\n <ScrollArea className=\"my-1 flex max-h-[5.5rem] flex-col\">\n <span className=\"flex flex-wrap gap-1\">\n {valuesAsChildren.map(child => (\n <Tag\n key={child.props.value}\n className=\"truncate\"\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.icon}\n onDelete={open ? createClickHandler(child.props.value) : undefined}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n ))}\n </span>\n </ScrollArea>\n </Button>\n </span>\n );\n }\n\n const boundaryIndex = contentRef.current ? getIndexOfFirstChildOverflowingParent(contentRef.current, 30) : undefined;\n\n return (\n <Button {...buttonProps} ref={ref}>\n <span className=\"relative flex items-center gap-1 overflow-hidden\">\n <span className=\"flex gap-1 truncate\" ref={contentRef}>\n {valuesAsChildren.map((child, index) => {\n const tag = (\n <Tag\n key={child.props.value}\n className={cn('cursor-pointer', {\n truncate: index === boundaryIndex,\n hidden: boundaryIndex !== undefined && boundaryIndex !== null ? index > boundaryIndex : false,\n })}\n color={tags ? child.props.color : undefined}\n disabled={disabled}\n icon={child.props.icon}\n onDelete={open ? createClickHandler(child.props.value) : undefined}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n );\n\n if (index === boundaryIndex) {\n return (\n <Tooltip key={child.props.value} title={String(child.props.children)}>\n {tag}\n </Tooltip>\n );\n }\n\n return tag;\n })}\n </span>\n {boundaryIndex !== undefined && boundaryIndex !== null && boundaryIndex < valuesAsChildren.length - 1 ? (\n <Tooltip\n title={valuesAsChildren\n .slice(boundaryIndex + 1)\n .map(child => (child ? String(child.props.children) : ''))\n .join(', ')}>\n <Badge className=\"flex-shrink-0\">+{valuesAsChildren.length - (boundaryIndex + 1)}</Badge>\n </Tooltip>\n ) : null}\n </span>\n </Button>\n );\n});\n\nconst matchesValue = (value: undefined | any | any[]) => (child: React.ReactElement<any>) => {\n if (Array.isArray(value)) {\n return value.includes(child.props.value);\n }\n\n return child.props.value === value;\n};\n"],"names":["Trigger","React","forwardRef","Select2Trigger","props","ref","multiple","value","useSelect2Context","Array","isArray","values","undefined","Multiple","Single","Button","Select2TriggerButton","children","onClick","tabIndex","otherProps","disabled","highlighted","invalid","open","readOnly","className","cn","getInputClasses","replace","includes","handleClick","event","preventDefault","role","type","Icon","name","Select2TriggerSingle","buttonProps","tags","contentClassName","currentValue","find","matchesValue","output","Tag","color","icon","Select2TriggerMultiple","setValue","contentRef","useRef","createClickHandler","tagValue","stopPropagation","valuesAsChildren","map","c","ScrollArea","child","key","onDelete","boundaryIndex","current","getIndexOfFirstChildOverflowingParent","index","tag","truncate","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IAAKA,KAAK,GAAGY,MAAM,CAACZ,KAAK,CAACxD,KAAK,CAACa,QAAQ,CAAC,GAAG,EAAG,CAAC,CACzD0D,IAAI,CAAC,IAAI;kBACd1E,6BAAC2E,KAAK;IAAClD,SAAS,EAAC;UAAkB8B,gBAAgB,CAACiB,MAAM,IAAIV,aAAa,GAAG,CAAC,CAAC,CAAS,CACnF,GACV,IAAI,CACL,CACF;AAEjB,CAAC,CAAC;AAEF,MAAMnB,YAAY,GAAIrC,KAA8B,IAAMqD,KAA8B;EACpF,IAAInD,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACuB,QAAQ,CAAC8B,KAAK,CAACxD,KAAK,CAACG,KAAK,CAAC;;EAG5C,OAAOqD,KAAK,CAACxD,KAAK,CAACG,KAAK,KAAKA,KAAK;AACtC,CAAC;;;;"}
|
@@ -132,7 +132,8 @@ const Content = /*#__PURE__*/React.forwardRef(function AlertDialogContent(props,
|
|
132
132
|
asChild: true
|
133
133
|
}, /*#__PURE__*/React.createElement(Backdrop, null, /*#__PURE__*/React.createElement(AlertDialogPrimitive.Content, Object.assign({}, props, {
|
134
134
|
ref: ref,
|
135
|
-
className: className
|
135
|
+
className: className,
|
136
|
+
onEscapeKeyDown: event => event.preventDefault()
|
136
137
|
}), props.children))));
|
137
138
|
});
|
138
139
|
|
@@ -5205,7 +5206,8 @@ const RenderPropWrapper = /*#__PURE__*/React.forwardRef(function RenderPropWrapp
|
|
5205
5206
|
});
|
5206
5207
|
const Content$3 = /*#__PURE__*/React.forwardRef(function PopoverContent(props, ref) {
|
5207
5208
|
const {
|
5208
|
-
placement: side
|
5209
|
+
placement: side,
|
5210
|
+
...popoverContentProps
|
5209
5211
|
} = props;
|
5210
5212
|
const className = cn(getPopoverStyleClassnames(), props.className);
|
5211
5213
|
let output;
|
@@ -5216,13 +5218,13 @@ const Content$3 = /*#__PURE__*/React.forwardRef(function PopoverContent(props, r
|
|
5216
5218
|
} else {
|
5217
5219
|
output = props.children;
|
5218
5220
|
}
|
5219
|
-
return /*#__PURE__*/React.createElement(PopoverPrimitive.Portal, null, /*#__PURE__*/React.createElement(PopoverPrimitive.Content, {
|
5221
|
+
return /*#__PURE__*/React.createElement(PopoverPrimitive.Portal, null, /*#__PURE__*/React.createElement(PopoverPrimitive.Content, Object.assign({}, popoverContentProps, {
|
5220
5222
|
className: className,
|
5221
5223
|
"data-taco": "popover",
|
5222
5224
|
side: side,
|
5223
5225
|
sideOffset: 1,
|
5224
5226
|
ref: ref
|
5225
|
-
}, output, /*#__PURE__*/React.createElement(UnstyledArrow, {
|
5227
|
+
}), output, /*#__PURE__*/React.createElement(UnstyledArrow, {
|
5226
5228
|
className: "text-white"
|
5227
5229
|
})));
|
5228
5230
|
});
|
@@ -5233,6 +5235,7 @@ const Close$1 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React
|
|
5233
5235
|
const Popover = /*#__PURE__*/React.forwardRef(function Popover(props, ref) {
|
5234
5236
|
const {
|
5235
5237
|
children,
|
5238
|
+
modal = false,
|
5236
5239
|
trigger,
|
5237
5240
|
...otherProps
|
5238
5241
|
} = props;
|
@@ -5242,7 +5245,9 @@ const Popover = /*#__PURE__*/React.forwardRef(function Popover(props, ref) {
|
|
5242
5245
|
}), [otherProps]);
|
5243
5246
|
return /*#__PURE__*/React.createElement(PopoverContext.Provider, {
|
5244
5247
|
value: context
|
5245
|
-
}, /*#__PURE__*/React.createElement(PopoverPrimitive.Root,
|
5248
|
+
}, /*#__PURE__*/React.createElement(PopoverPrimitive.Root, {
|
5249
|
+
modal: modal
|
5250
|
+
}, trigger && /*#__PURE__*/React.createElement(Trigger$2, null, trigger), children));
|
5246
5251
|
});
|
5247
5252
|
Popover.Trigger = Trigger$2;
|
5248
5253
|
Popover.Content = Content$3;
|
@@ -7721,8 +7726,8 @@ const EditPopover = props => {
|
|
7721
7726
|
event.stopPropagation();
|
7722
7727
|
}
|
7723
7728
|
};
|
7724
|
-
return /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps
|
7725
|
-
|
7729
|
+
return /*#__PURE__*/React__default.createElement(Popover, Object.assign({}, popoverProps, {
|
7730
|
+
modal: true
|
7726
7731
|
}), /*#__PURE__*/React__default.createElement(Popover.Content, {
|
7727
7732
|
onCloseAutoFocus: handleCloseAutoFocus,
|
7728
7733
|
onInteractOutside: handleInteractOutside,
|
@@ -7762,7 +7767,7 @@ const EditPopover = props => {
|
|
7762
7767
|
}, /*#__PURE__*/React__default.createElement(Icon, {
|
7763
7768
|
className: "!h-5 !w-5",
|
7764
7769
|
name: "delete-permanently"
|
7765
|
-
}), " ", texts.select2.delete) : null))))
|
7770
|
+
}), " ", texts.select2.delete) : null))));
|
7766
7771
|
};
|
7767
7772
|
const Colours = props => {
|
7768
7773
|
const {
|
@@ -7999,7 +8004,7 @@ const Button$2 = /*#__PURE__*/React__default.forwardRef(function Select2TriggerB
|
|
7999
8004
|
type: "button"
|
8000
8005
|
}), children, /*#__PURE__*/React__default.createElement(Icon, {
|
8001
8006
|
name: open ? 'chevron-up' : 'chevron-down',
|
8002
|
-
className: "-
|
8007
|
+
className: "-mr-1 ml-auto"
|
8003
8008
|
}));
|
8004
8009
|
});
|
8005
8010
|
const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSingle(props, ref) {
|