@economic/taco 1.17.3 → 1.17.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/Select2/components/Edit.d.ts +2 -2
- package/dist/components/Tag/Tag.d.ts +13 -2
- package/dist/esm/packages/taco/src/components/Input/util.js +1 -1
- package/dist/esm/packages/taco/src/components/Input/util.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 +7 -7
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Tag/Tag.js +13 -3
- package/dist/esm/packages/taco/src/components/Tag/Tag.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +1 -1
- package/dist/taco.cjs.development.js +22 -22
- 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 +15 -3
- package/dist/esm/packages/taco/src/utils/colors.js +0 -14
- package/dist/esm/packages/taco/src/utils/colors.js.map +0 -1
@@ -1,9 +1,9 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { Color } from '../../../utils/colors';
|
3
2
|
import { PopoverProps } from '../../Popover/Popover';
|
4
3
|
import { Select2OptionValue } from '../types';
|
4
|
+
import { TagColor } from '../../Tag/Tag';
|
5
5
|
export declare type EditPopoverProps = PopoverProps & {
|
6
|
-
color?:
|
6
|
+
color?: TagColor;
|
7
7
|
text: string;
|
8
8
|
value: Select2OptionValue;
|
9
9
|
};
|
@@ -1,9 +1,20 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { Color } from '../../utils/colors';
|
3
2
|
import { IconName, IconProps } from '../Icon/Icon';
|
3
|
+
export declare const TAG_COLORS: {
|
4
|
+
green: string;
|
5
|
+
yellow: string;
|
6
|
+
red: string;
|
7
|
+
blue: string;
|
8
|
+
purple: string;
|
9
|
+
orange: string;
|
10
|
+
brown: string;
|
11
|
+
pink: string;
|
12
|
+
grey: string;
|
13
|
+
};
|
14
|
+
export declare type TagColor = keyof typeof TAG_COLORS;
|
4
15
|
export declare type TagProps = Omit<React.HTMLAttributes<HTMLSpanElement>, 'children'> & {
|
5
16
|
children: string;
|
6
|
-
color?:
|
17
|
+
color?: TagColor;
|
7
18
|
disabled?: boolean;
|
8
19
|
icon?: React.ReactElement<IconProps> | IconName;
|
9
20
|
readOnly?: boolean;
|
@@ -4,7 +4,7 @@ const getInputClasses = props => {
|
|
4
4
|
const disabled = props.disabled || !!props['aria-disabled'];
|
5
5
|
const readOnly = props.readOnly || !!props['aria-readonly'];
|
6
6
|
const invalid = props.invalid || !!props['aria-invalid'];
|
7
|
-
return cn('peer bg-white text-black text-sm border font-normal not-italic no-underline rounded
|
7
|
+
return cn('peer bg-white text-black text-sm border font-normal not-italic no-underline rounded flex items-center leading-6 px-2 relative w-full text-ellipsis transition-colors transition-opacity ease-in min-h-[theme(spacing.8)]', {
|
8
8
|
// default
|
9
9
|
'border-grey-300 focus:border-blue-300 focus:yt-focus': !invalid,
|
10
10
|
'hover:shadow-[0_0_0.1rem_theme(colors.grey.500)] active:border-blue-700': !invalid && !disabled,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"util.js","sources":["../../../../../../../src/components/Input/util.ts"],"sourcesContent":["import cn from 'classnames';\n\nexport const getInputClasses = props => {\n const disabled = props.disabled || !!props['aria-disabled'];\n const readOnly = props.readOnly || !!props['aria-readonly'];\n const invalid = props.invalid || !!props['aria-invalid'];\n\n return cn(\n 'peer bg-white text-black text-sm border font-normal not-italic no-underline rounded
|
1
|
+
{"version":3,"file":"util.js","sources":["../../../../../../../src/components/Input/util.ts"],"sourcesContent":["import cn from 'classnames';\n\nexport const getInputClasses = props => {\n const disabled = props.disabled || !!props['aria-disabled'];\n const readOnly = props.readOnly || !!props['aria-readonly'];\n const invalid = props.invalid || !!props['aria-invalid'];\n\n return cn(\n 'peer bg-white text-black text-sm border font-normal not-italic no-underline rounded flex items-center leading-6 px-2 relative w-full text-ellipsis transition-colors transition-opacity ease-in min-h-[theme(spacing.8)]',\n {\n // default\n 'border-grey-300 focus:border-blue-300 focus:yt-focus': !invalid,\n 'hover:shadow-[0_0_0.1rem_theme(colors.grey.500)] active:border-blue-700': !invalid && !disabled,\n // disabled\n 'border-grey-200 text-opacity-25 cursor-not-allowed placeholder:text-grey-700': disabled,\n // highlighted\n 'bg-[rgba(255,255,0,0.075)]': props.highlighted && disabled,\n 'bg-[rgba(255,255,0,0.2)]': props.highlighted && !disabled,\n // invalid\n 'border-red focus:border-red-300 focus:yt-focus-red active:border-red-700': invalid,\n 'hover:shadow-[0_0_0.15rem_theme(colors.red.500)]': invalid && !disabled,\n // readOnly\n 'cursor-not-allowed text-black bg-grey-200': readOnly,\n }\n );\n};\n\nexport const getButtonStateClasses = (invalid: boolean | undefined): string => {\n if (invalid) {\n return 'border !border-red-500 group-peer-focus:!border-red-300 focus:yt-focus-red group-focus:group-active:!border-red-300 transition-colors ease-in';\n }\n\n return 'border border-grey-300 focus:!border-blue-300 group-peer-focus:!border-blue-300 group-peer-focus:group-peer-active:!border-blue-700 transition-colors transition-opacity ease-in';\n};\n"],"names":["getInputClasses","props","disabled","readOnly","invalid","cn","highlighted","getButtonStateClasses"],"mappings":";;MAEaA,eAAe,GAAGC,KAAK;EAChC,MAAMC,QAAQ,GAAGD,KAAK,CAACC,QAAQ,IAAI,CAAC,CAACD,KAAK,CAAC,eAAe,CAAC;EAC3D,MAAME,QAAQ,GAAGF,KAAK,CAACE,QAAQ,IAAI,CAAC,CAACF,KAAK,CAAC,eAAe,CAAC;EAC3D,MAAMG,OAAO,GAAGH,KAAK,CAACG,OAAO,IAAI,CAAC,CAACH,KAAK,CAAC,cAAc,CAAC;EAExD,OAAOI,EAAE,CACL,0NAA0N,EAC1N;;IAEI,sDAAsD,EAAE,CAACD,OAAO;IAChE,yEAAyE,EAAE,CAACA,OAAO,IAAI,CAACF,QAAQ;;IAEhG,8EAA8E,EAAEA,QAAQ;;IAExF,4BAA4B,EAAED,KAAK,CAACK,WAAW,IAAIJ,QAAQ;IAC3D,0BAA0B,EAAED,KAAK,CAACK,WAAW,IAAI,CAACJ,QAAQ;;IAE1D,0EAA0E,EAAEE,OAAO;IACnF,kDAAkD,EAAEA,OAAO,IAAI,CAACF,QAAQ;;IAExE,2CAA2C,EAAEC;GAChD,CACJ;AACL;MAEaI,qBAAqB,GAAIH,OAA4B;EAC9D,IAAIA,OAAO,EAAE;IACT,OAAO,+IAA+I;;EAG1J,OAAO,kLAAkL;AAC7L;;;;"}
|
@@ -8,11 +8,11 @@ import { Popover } from '../../Popover/Popover.js';
|
|
8
8
|
import { Field } from '../../Field/Field.js';
|
9
9
|
import { Group } from '../../Group/Group.js';
|
10
10
|
import { Root, Item, Indicator } from '@radix-ui/react-radio-group';
|
11
|
-
import {
|
11
|
+
import { TAG_COLORS } from '../../Tag/Tag.js';
|
12
12
|
import { useSelect2Context } from './Context.js';
|
13
13
|
import { _catch } from '../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
|
14
14
|
|
15
|
-
const AVAILABLE_COLORS = /*#__PURE__*/Object.keys(
|
15
|
+
const AVAILABLE_COLORS = /*#__PURE__*/Object.keys(TAG_COLORS);
|
16
16
|
const EditPopover = props => {
|
17
17
|
const {
|
18
18
|
color: initialColor,
|
@@ -173,7 +173,7 @@ const Colours = props => {
|
|
173
173
|
value: color
|
174
174
|
}, AVAILABLE_COLORS.map(availableColor => /*#__PURE__*/React__default.createElement(Item, {
|
175
175
|
"aria-label": color,
|
176
|
-
className: cn('flex h-6 w-6 cursor-pointer items-center justify-center rounded',
|
176
|
+
className: cn('flex h-6 w-6 cursor-pointer items-center justify-center rounded', TAG_COLORS[availableColor]),
|
177
177
|
key: availableColor,
|
178
178
|
onFocus: () => onChangeColor(availableColor),
|
179
179
|
value: availableColor
|
@@ -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/Localization';\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 as 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-700 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,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;EAC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AAEA,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;;;;"}
|
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 { 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/Localization';\nimport { TagColor, TAG_COLORS } from '../../Tag/Tag';\n\nconst AVAILABLE_COLORS = Object.keys(TAG_COLORS);\n\nexport type EditPopoverProps = PopoverProps & {\n color?: TagColor;\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 as 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-700 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', TAG_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","TAG_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","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,gBACLF;IACIwC,SAAS,EAAC,2DAA2D;IACrEH,OAAO,EAAEb,YAAY,CAACJ,KAAK,CAAC;IAC5B2B,SAAS,EAAEhB;kBACX/B,6BAACwD,IAAI;IAAChB,SAAS,EAAC,WAAW;IAAC/B,IAAI,EAAC;IAAuB,OAAEF,KAAK,CAAC6C,OAAO,CAACK,MAAM,CACzE,GACT,IAAI,CACN,CAEb,CACa,CACZ;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,UAAU,CAACwE,cAAc,CAAC,CAAC;IAC5GxC,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;;;;"}
|
@@ -86,7 +86,7 @@ const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSin
|
|
86
86
|
readOnly,
|
87
87
|
tags
|
88
88
|
} = useSelect2Context();
|
89
|
-
const contentClassName = cn('truncate
|
89
|
+
const contentClassName = cn('truncate items-center gap-1');
|
90
90
|
const currentValue = children.find(matchesValue(value));
|
91
91
|
let output;
|
92
92
|
if (currentValue) {
|
@@ -106,7 +106,7 @@ const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSin
|
|
106
106
|
}
|
107
107
|
return /*#__PURE__*/React__default.createElement(Button, Object.assign({}, buttonProps, {
|
108
108
|
ref: ref
|
109
|
-
}), /*#__PURE__*/React__default.createElement("
|
109
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
110
110
|
className: contentClassName
|
111
111
|
}, output));
|
112
112
|
});
|
@@ -131,10 +131,10 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
|
|
131
131
|
className
|
132
132
|
} = buttonProps;
|
133
133
|
if (open) {
|
134
|
-
className = cn('absolute z-20', buttonProps.className);
|
134
|
+
className = cn('!absolute z-20', buttonProps.className);
|
135
135
|
content = /*#__PURE__*/React__default.createElement(ScrollArea, {
|
136
136
|
className: "my-1 flex max-h-[5.5rem] flex-col"
|
137
|
-
}, /*#__PURE__*/React__default.createElement("
|
137
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
138
138
|
className: "flex flex-wrap gap-1"
|
139
139
|
}, valuesAsChildren.map(child => /*#__PURE__*/React__default.createElement(Tag, {
|
140
140
|
key: child.props.value,
|
@@ -157,7 +157,7 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
|
|
157
157
|
valuesAsChildren: valuesAsChildren
|
158
158
|
});
|
159
159
|
}
|
160
|
-
return /*#__PURE__*/React__default.createElement("
|
160
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
161
161
|
className: cn('relative inline-flex flex-grow', {
|
162
162
|
'h-8': open
|
163
163
|
}),
|
@@ -188,9 +188,9 @@ const MultipleValue = ({
|
|
188
188
|
setValue(tagValue);
|
189
189
|
}
|
190
190
|
};
|
191
|
-
return /*#__PURE__*/React__default.createElement("
|
191
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
192
192
|
className: "relative flex items-center gap-1 overflow-hidden"
|
193
|
-
}, /*#__PURE__*/React__default.createElement("
|
193
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
194
194
|
className: "flex gap-1 truncate",
|
195
195
|
ref: el => setContentRef(el)
|
196
196
|
}, valuesAsChildren.map((child, index) => {
|
@@ -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';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\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=\"pointer-events-none -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 flex items-center gap-1');\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 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 buttonRef = useMergedRef<HTMLButtonElement>(ref);\n\n const valuesAsChildren = values.map(value =>\n children.find(c => c.props.value === value)\n ) as React.ReactElement<Select2OptionProps>[];\n\n let content;\n let { className } = buttonProps;\n\n if (open) {\n className = cn('absolute z-20', buttonProps.className);\n content = (\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={event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(child.props.value);\n }\n }}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n ))}\n </span>\n </ScrollArea>\n );\n } else {\n content = <MultipleValue key={String(open)} valuesAsChildren={valuesAsChildren} />;\n }\n\n return (\n <span\n className={cn('relative inline-flex flex-grow', { 'h-8': open })}\n style={{ width: open ? buttonRef.current?.offsetWidth : undefined }}>\n <Button {...buttonProps} className={className} ref={buttonRef}>\n {content}\n </Button>\n </span>\n );\n});\n\nconst MultipleValue = ({ valuesAsChildren }) => {\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const [contentRef, setContentRef] = React.useState<HTMLSpanElement | null>(null);\n const boundaryIndex = contentRef ? getIndexOfFirstChildOverflowingParent(contentRef, 30) : undefined;\n\n const createClickHandler = tagValue => event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(tagValue);\n }\n };\n\n return (\n <span className=\"relative flex items-center gap-1 overflow-hidden\">\n <span className=\"flex gap-1 truncate\" ref={el => setContentRef(el)}>\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 );\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","buttonRef","useMergedRef","valuesAsChildren","map","c","content","ScrollArea","child","key","onDelete","stopPropagation","MultipleValue","String","style","width","current","offsetWidth","contentRef","setContentRef","useState","boundaryIndex","getIndexOfFirstChildOverflowingParent","createClickHandler","tagValue","el","index","tag","truncate","hidden","Tooltip","title","length","slice","join","Badge"],"mappings":";;;;;;;;;;;;MAkBaA,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,CA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CAACtD,KAAK,CAACa,QAAQ,CAE5B;IAED,IAAI2D,KAAK,KAAKL,aAAa,EAAE;MACzB,oBACItE,6BAAC+E,OAAO;QAACrB,GAAG,EAAED,KAAK,CAACtD,KAAK,CAACG,KAAK;QAAE0E,KAAK,EAAElB,MAAM,CAACL,KAAK,CAACtD,KAAK,CAACa,QAAQ;SAC9D4D,GAAG,CACE;;IAIlB,OAAOA,GAAG;GACb,CAAC,CACC,EACNN,aAAa,KAAK3D,SAAS,IAAI2D,aAAa,KAAK,IAAI,IAAIA,aAAa,GAAGlB,gBAAgB,CAAC6B,MAAM,GAAG,CAAC,gBACjGjF,6BAAC+E,OAAO;IACJC,KAAK,EAAE5B,gBAAgB,CAClB8B,KAAK,CAACZ,aAAa,GAAG,CAAC,CAAC,CACxBjB,GAAG,CAACI,KAAK,IAAKA,KAAK,GAAGK,MAAM,CAACL,KAAK,CAACtD,KAAK,CAACa,QAAQ,CAAC,GAAG,EAAG,CAAC,CACzDmE,IAAI,CAAC,IAAI;kBACdnF,6BAACoF,KAAK;IAAC3D,SAAS,EAAC;UAAkB2B,gBAAgB,CAAC6B,MAAM,IAAIX,aAAa,GAAG,CAAC,CAAC,CAAS,CACnF,GACV,IAAI,CACL;AAEf,CAAC;AAED,MAAM3B,YAAY,GAAIrC,KAA8B,IAAMmD,KAA8B;EACpF,IAAIjD,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACuB,QAAQ,CAAC4B,KAAK,CAACtD,KAAK,CAACG,KAAK,CAAC;;EAG5C,OAAOmD,KAAK,CAACtD,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';\nimport { useMergedRef } from '../../../hooks/useMergedRef';\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=\"pointer-events-none -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 items-center gap-1');\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 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 <div className={contentClassName}>{output}</div>\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 buttonRef = useMergedRef<HTMLButtonElement>(ref);\n\n const valuesAsChildren = values.map(value =>\n children.find(c => c.props.value === value)\n ) as React.ReactElement<Select2OptionProps>[];\n\n let content;\n let { className } = buttonProps;\n\n if (open) {\n className = cn('!absolute z-20', buttonProps.className);\n content = (\n <ScrollArea className=\"my-1 flex max-h-[5.5rem] flex-col\">\n <div 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={event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(child.props.value);\n }\n }}\n readOnly={readOnly}>\n {child.props.children}\n </Tag>\n ))}\n </div>\n </ScrollArea>\n );\n } else {\n content = <MultipleValue key={String(open)} valuesAsChildren={valuesAsChildren} />;\n }\n\n return (\n <div\n className={cn('relative inline-flex flex-grow', { 'h-8': open })}\n style={{ width: open ? buttonRef.current?.offsetWidth : undefined }}>\n <Button {...buttonProps} className={className} ref={buttonRef}>\n {content}\n </Button>\n </div>\n );\n});\n\nconst MultipleValue = ({ valuesAsChildren }) => {\n const { disabled, open, readOnly, setValue, tags } = useSelect2Context();\n const [contentRef, setContentRef] = React.useState<HTMLDivElement | null>(null);\n const boundaryIndex = contentRef ? getIndexOfFirstChildOverflowingParent(contentRef, 30) : undefined;\n\n const createClickHandler = tagValue => event => {\n event?.stopPropagation();\n event?.preventDefault();\n\n if (!disabled && !readOnly) {\n setValue(tagValue);\n }\n };\n\n return (\n <div className=\"relative flex items-center gap-1 overflow-hidden\">\n <div className=\"flex gap-1 truncate\" ref={el => setContentRef(el)}>\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 </div>\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 </div>\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","buttonRef","useMergedRef","valuesAsChildren","map","c","content","ScrollArea","child","key","onDelete","stopPropagation","MultipleValue","String","style","width","current","offsetWidth","contentRef","setContentRef","useState","boundaryIndex","getIndexOfFirstChildOverflowingParent","createClickHandler","tagValue","el","index","tag","truncate","hidden","Tooltip","title","length","slice","join","Badge"],"mappings":";;;;;;;;;;;;MAkBaA,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,C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E5B,gBAAgB,CAClB8B,KAAK,CAACZ,aAAa,GAAG,CAAC,CAAC,CACxBjB,GAAG,CAACI,KAAK,IAAKA,KAAK,GAAGK,MAAM,CAACL,KAAK,CAACtD,KAAK,CAACa,QAAQ,CAAC,GAAG,EAAG,CAAC,CACzDmE,IAAI,CAAC,IAAI;kBACdnF,6BAACoF,KAAK;IAAC3D,SAAS,EAAC;UAAkB2B,gBAAgB,CAAC6B,MAAM,IAAIX,aAAa,GAAG,CAAC,CAAC,CAAS,CACnF,GACV,IAAI,CACN;AAEd,CAAC;AAED,MAAM3B,YAAY,GAAIrC,KAA8B,IAAMmD,KAA8B;EACpF,IAAIjD,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACuB,QAAQ,CAAC4B,KAAK,CAACtD,KAAK,CAACG,KAAK,CAAC;;EAG5C,OAAOmD,KAAK,CAACtD,KAAK,CAACG,KAAK,KAAKA,KAAK;AACtC,CAAC;;;;"}
|
@@ -1,8 +1,18 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import cn from 'classnames';
|
3
3
|
import { Icon } from '../Icon/Icon.js';
|
4
|
-
import { colors } from '../../utils/colors.js';
|
5
4
|
|
5
|
+
const TAG_COLORS = {
|
6
|
+
green: 'wcag-green-100',
|
7
|
+
yellow: 'wcag-yellow-100',
|
8
|
+
red: 'wcag-red-100',
|
9
|
+
blue: 'wcag-blue-100',
|
10
|
+
purple: 'wcag-purple-100',
|
11
|
+
orange: 'wcag-orange-100',
|
12
|
+
brown: 'wcag-brown-100',
|
13
|
+
pink: 'wcag-pink-100',
|
14
|
+
grey: 'wcag-grey-200'
|
15
|
+
};
|
6
16
|
const Tag = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
7
17
|
const {
|
8
18
|
children,
|
@@ -19,7 +29,7 @@ const Tag = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
19
29
|
'hover:bg-opacity-75': !disabled,
|
20
30
|
'cursor-pointer': !!otherProps.onClick,
|
21
31
|
'pointer-events-none': disabled || readOnly
|
22
|
-
}, color ?
|
32
|
+
}, color ? TAG_COLORS[color] : TAG_COLORS.grey, props.className);
|
23
33
|
return /*#__PURE__*/React__default.createElement("span", Object.assign({}, otherProps, {
|
24
34
|
className: className,
|
25
35
|
ref: ref
|
@@ -38,5 +48,5 @@ const Tag = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
38
48
|
}) : null);
|
39
49
|
});
|
40
50
|
|
41
|
-
export { Tag };
|
51
|
+
export { TAG_COLORS, Tag };
|
42
52
|
//# sourceMappingURL=Tag.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tag.js","sources":["../../../../../../../src/components/Tag/Tag.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport {
|
1
|
+
{"version":3,"file":"Tag.js","sources":["../../../../../../../src/components/Tag/Tag.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Icon, IconName, IconProps } from '../Icon/Icon';\n\nexport const TAG_COLORS = {\n green: 'wcag-green-100',\n yellow: 'wcag-yellow-100',\n red: 'wcag-red-100',\n blue: 'wcag-blue-100',\n purple: 'wcag-purple-100',\n orange: 'wcag-orange-100',\n brown: 'wcag-brown-100',\n pink: 'wcag-pink-100',\n grey: 'wcag-grey-200',\n};\n\nexport type TagColor = keyof typeof TAG_COLORS;\n\nexport type TagProps = Omit<React.HTMLAttributes<HTMLSpanElement>, 'children'> & {\n children: string;\n color?: TagColor;\n disabled?: boolean;\n icon?: React.ReactElement<IconProps> | IconName;\n readOnly?: boolean;\n onDelete?: (event: React.MouseEvent<SVGSVGElement>) => void;\n};\n\nexport const Tag = React.forwardRef<HTMLSpanElement, TagProps>((props, ref) => {\n const { children, color, disabled, icon, readOnly, onDelete, ...otherProps } = props;\n const textRef = React.useRef<HTMLDivElement>(null);\n\n const className = cn(\n 'inline-flex items-center rounded h-6 cursor-default',\n {\n 'opacity-50': disabled,\n 'hover:bg-opacity-75': !disabled,\n 'cursor-pointer': !!otherProps.onClick,\n 'pointer-events-none': disabled || readOnly,\n },\n color ? TAG_COLORS[color] : TAG_COLORS.grey,\n props.className\n );\n\n return (\n <span {...otherProps} className={className} ref={ref}>\n <span className=\"truncate px-2\" ref={textRef}>\n {icon ? (\n typeof icon === 'string' ? (\n <Icon name={icon} className=\"mr-1 -ml-1 -mt-0.5 !h-5 !w-5\" />\n ) : (\n React.cloneElement(icon, { className: 'mr-1 -ml-1 -mt-0.5 !h-5 !w-5' })\n )\n ) : null}\n {children}\n </span>\n {onDelete ? (\n <Icon\n name=\"close\"\n onClick={onDelete}\n className=\"-ml-1.5 !h-6 !w-5 flex-shrink-0 cursor-pointer rounded-r p-0.5 hover:bg-black/5\"\n />\n ) : null}\n </span>\n );\n});\n"],"names":["TAG_COLORS","green","yellow","red","blue","purple","orange","brown","pink","grey","Tag","React","forwardRef","props","ref","children","color","disabled","icon","readOnly","onDelete","otherProps","textRef","useRef","className","cn","onClick","Icon","name","cloneElement"],"mappings":";;;;MAIaA,UAAU,GAAG;EACtBC,KAAK,EAAE,gBAAgB;EACvBC,MAAM,EAAE,iBAAiB;EACzBC,GAAG,EAAE,cAAc;EACnBC,IAAI,EAAE,eAAe;EACrBC,MAAM,EAAE,iBAAiB;EACzBC,MAAM,EAAE,iBAAiB;EACzBC,KAAK,EAAE,gBAAgB;EACvBC,IAAI,EAAE,eAAe;EACrBC,IAAI,EAAE;;MAcGC,GAAG,gBAAGC,cAAK,CAACC,UAAU,CAA4B,CAACC,KAAK,EAAEC,GAAG;EACtE,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,QAAQ;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGR,KAAK;EACpF,MAAMS,OAAO,GAAGX,cAAK,CAACY,MAAM,CAAiB,IAAI,CAAC;EAElD,MAAMC,SAAS,GAAGC,EAAE,CAChB,qDAAqD,EACrD;IACI,YAAY,EAAER,QAAQ;IACtB,qBAAqB,EAAE,CAACA,QAAQ;IAChC,gBAAgB,EAAE,CAAC,CAACI,UAAU,CAACK,OAAO;IACtC,qBAAqB,EAAET,QAAQ,IAAIE;GACtC,EACDH,KAAK,GAAGhB,UAAU,CAACgB,KAAK,CAAC,GAAGhB,UAAU,CAACS,IAAI,EAC3CI,KAAK,CAACW,SAAS,CAClB;EAED,oBACIb,uDAAUU,UAAU;IAAEG,SAAS,EAAEA,SAAS;IAAEV,GAAG,EAAEA;mBAC7CH;IAAMa,SAAS,EAAC,eAAe;IAACV,GAAG,EAAEQ;KAChCJ,IAAI,GACD,OAAOA,IAAI,KAAK,QAAQ,gBACpBP,6BAACgB,IAAI;IAACC,IAAI,EAAEV,IAAI;IAAEM,SAAS,EAAC;IAAiC,gBAE7Db,cAAK,CAACkB,YAAY,CAACX,IAAI,EAAE;IAAEM,SAAS,EAAE;GAAgC,CACzE,GACD,IAAI,EACPT,QAAQ,CACN,EACNK,QAAQ,gBACLT,6BAACgB,IAAI;IACDC,IAAI,EAAC,OAAO;IACZF,OAAO,EAAEN,QAAQ;IACjBI,SAAS,EAAC;IACZ,GACF,IAAI,CACL;AAEf,CAAC;;;;"}
|
@@ -43,7 +43,7 @@ export { Pagination } from './components/Pagination/Pagination.js';
|
|
43
43
|
export { Progress } from './components/Progress/Progress.js';
|
44
44
|
export { ToastProvider, useToast } from './components/Toast/Toaster.js';
|
45
45
|
export { Provider } from './components/Provider/Provider.js';
|
46
|
-
export { Tag } from './components/Tag/Tag.js';
|
46
|
+
export { TAG_COLORS, Tag } from './components/Tag/Tag.js';
|
47
47
|
export { Select2 } from './components/Select2/Select2.js';
|
48
48
|
export { Table } from './components/Table/components/Table.js';
|
49
49
|
export { PaginatedTable } from './components/Table/components/PaginatedTable.js';
|
@@ -3886,7 +3886,7 @@ const getInputClasses = props => {
|
|
3886
3886
|
const disabled = props.disabled || !!props['aria-disabled'];
|
3887
3887
|
const readOnly = props.readOnly || !!props['aria-readonly'];
|
3888
3888
|
const invalid = props.invalid || !!props['aria-invalid'];
|
3889
|
-
return cn('peer bg-white text-black text-sm border font-normal not-italic no-underline rounded
|
3889
|
+
return cn('peer bg-white text-black text-sm border font-normal not-italic no-underline rounded flex items-center leading-6 px-2 relative w-full text-ellipsis transition-colors transition-opacity ease-in min-h-[theme(spacing.8)]', {
|
3890
3890
|
// default
|
3891
3891
|
'border-grey-300 focus:border-blue-300 focus:yt-focus': !invalid,
|
3892
3892
|
'hover:shadow-[0_0_0.1rem_theme(colors.grey.500)] active:border-blue-700': !invalid && !disabled,
|
@@ -7678,18 +7678,17 @@ const Title$3 = /*#__PURE__*/React__default.forwardRef(function Listbox2Group(pr
|
|
7678
7678
|
}));
|
7679
7679
|
});
|
7680
7680
|
|
7681
|
-
const
|
7682
|
-
green: '
|
7683
|
-
yellow: '
|
7684
|
-
red: '
|
7685
|
-
blue: '
|
7686
|
-
purple: '
|
7687
|
-
orange: '
|
7688
|
-
brown: '
|
7689
|
-
pink: '
|
7690
|
-
grey: '
|
7681
|
+
const TAG_COLORS = {
|
7682
|
+
green: 'wcag-green-100',
|
7683
|
+
yellow: 'wcag-yellow-100',
|
7684
|
+
red: 'wcag-red-100',
|
7685
|
+
blue: 'wcag-blue-100',
|
7686
|
+
purple: 'wcag-purple-100',
|
7687
|
+
orange: 'wcag-orange-100',
|
7688
|
+
brown: 'wcag-brown-100',
|
7689
|
+
pink: 'wcag-pink-100',
|
7690
|
+
grey: 'wcag-grey-200'
|
7691
7691
|
};
|
7692
|
-
|
7693
7692
|
const Tag$1 = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
7694
7693
|
const {
|
7695
7694
|
children,
|
@@ -7706,7 +7705,7 @@ const Tag$1 = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
7706
7705
|
'hover:bg-opacity-75': !disabled,
|
7707
7706
|
'cursor-pointer': !!otherProps.onClick,
|
7708
7707
|
'pointer-events-none': disabled || readOnly
|
7709
|
-
}, color ?
|
7708
|
+
}, color ? TAG_COLORS[color] : TAG_COLORS.grey, props.className);
|
7710
7709
|
return /*#__PURE__*/React__default.createElement("span", Object.assign({}, otherProps, {
|
7711
7710
|
className: className,
|
7712
7711
|
ref: ref
|
@@ -7748,7 +7747,7 @@ function _catch(body, recover) {
|
|
7748
7747
|
return result;
|
7749
7748
|
}
|
7750
7749
|
|
7751
|
-
const AVAILABLE_COLORS = /*#__PURE__*/Object.keys(
|
7750
|
+
const AVAILABLE_COLORS = /*#__PURE__*/Object.keys(TAG_COLORS);
|
7752
7751
|
const EditPopover = props => {
|
7753
7752
|
const {
|
7754
7753
|
color: initialColor,
|
@@ -7909,7 +7908,7 @@ const Colours = props => {
|
|
7909
7908
|
value: color
|
7910
7909
|
}, AVAILABLE_COLORS.map(availableColor => /*#__PURE__*/React__default.createElement(RadioGroupPrimitive.Item, {
|
7911
7910
|
"aria-label": color,
|
7912
|
-
className: cn('flex h-6 w-6 cursor-pointer items-center justify-center rounded',
|
7911
|
+
className: cn('flex h-6 w-6 cursor-pointer items-center justify-center rounded', TAG_COLORS[availableColor]),
|
7913
7912
|
key: availableColor,
|
7914
7913
|
onFocus: () => onChangeColor(availableColor),
|
7915
7914
|
value: availableColor
|
@@ -8139,7 +8138,7 @@ const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSin
|
|
8139
8138
|
readOnly,
|
8140
8139
|
tags
|
8141
8140
|
} = useSelect2Context();
|
8142
|
-
const contentClassName = cn('truncate
|
8141
|
+
const contentClassName = cn('truncate items-center gap-1');
|
8143
8142
|
const currentValue = children.find(matchesValue(value));
|
8144
8143
|
let output;
|
8145
8144
|
if (currentValue) {
|
@@ -8159,7 +8158,7 @@ const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSin
|
|
8159
8158
|
}
|
8160
8159
|
return /*#__PURE__*/React__default.createElement(Button$2, Object.assign({}, buttonProps, {
|
8161
8160
|
ref: ref
|
8162
|
-
}), /*#__PURE__*/React__default.createElement("
|
8161
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
8163
8162
|
className: contentClassName
|
8164
8163
|
}, output));
|
8165
8164
|
});
|
@@ -8184,10 +8183,10 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
|
|
8184
8183
|
className
|
8185
8184
|
} = buttonProps;
|
8186
8185
|
if (open) {
|
8187
|
-
className = cn('absolute z-20', buttonProps.className);
|
8186
|
+
className = cn('!absolute z-20', buttonProps.className);
|
8188
8187
|
content = /*#__PURE__*/React__default.createElement(ScrollArea, {
|
8189
8188
|
className: "my-1 flex max-h-[5.5rem] flex-col"
|
8190
|
-
}, /*#__PURE__*/React__default.createElement("
|
8189
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
8191
8190
|
className: "flex flex-wrap gap-1"
|
8192
8191
|
}, valuesAsChildren.map(child => /*#__PURE__*/React__default.createElement(Tag$1, {
|
8193
8192
|
key: child.props.value,
|
@@ -8210,7 +8209,7 @@ const Multiple = /*#__PURE__*/React__default.forwardRef(function Select2TriggerM
|
|
8210
8209
|
valuesAsChildren: valuesAsChildren
|
8211
8210
|
});
|
8212
8211
|
}
|
8213
|
-
return /*#__PURE__*/React__default.createElement("
|
8212
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
8214
8213
|
className: cn('relative inline-flex flex-grow', {
|
8215
8214
|
'h-8': open
|
8216
8215
|
}),
|
@@ -8241,9 +8240,9 @@ const MultipleValue = ({
|
|
8241
8240
|
setValue(tagValue);
|
8242
8241
|
}
|
8243
8242
|
};
|
8244
|
-
return /*#__PURE__*/React__default.createElement("
|
8243
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
8245
8244
|
className: "relative flex items-center gap-1 overflow-hidden"
|
8246
|
-
}, /*#__PURE__*/React__default.createElement("
|
8245
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
8247
8246
|
className: "flex gap-1 truncate",
|
8248
8247
|
ref: el => setContentRef(el)
|
8249
8248
|
}, valuesAsChildren.map((child, index) => {
|
@@ -10520,6 +10519,7 @@ exports.Select = Select;
|
|
10520
10519
|
exports.Select2 = Select2;
|
10521
10520
|
exports.Spinner = Spinner$1;
|
10522
10521
|
exports.Switch = Switch;
|
10522
|
+
exports.TAG_COLORS = TAG_COLORS;
|
10523
10523
|
exports.Table = Table;
|
10524
10524
|
exports.Tabs = Tabs;
|
10525
10525
|
exports.Tag = Tag$1;
|