@economic/taco 1.14.0 → 1.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -85,9 +85,7 @@ const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSin
85
85
  readOnly,
86
86
  tags
87
87
  } = useSelect2Context();
88
- const contentClassName = cn('truncate', {
89
- 'flex gap-1': tags
90
- });
88
+ const contentClassName = cn('truncate flex items-center gap-1');
91
89
  const currentValue = children.find(matchesValue(value));
92
90
  let output;
93
91
  if (currentValue) {
@@ -101,7 +99,6 @@ const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSin
101
99
  }, currentValue.props.children);
102
100
  } else {
103
101
  output = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, currentValue.props.icon ? typeof currentValue.props.icon === 'string' ? /*#__PURE__*/React__default.createElement(Icon, {
104
- className: "mr-1",
105
102
  name: currentValue.props.icon
106
103
  }) : currentValue.props.icon : null, currentValue.props.children);
107
104
  }
@@ -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=\"-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","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,I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AG,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 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 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,oBA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Value !== value && setValue) {
18
18
  if (Array.isArray(value)) {
19
19
  value.forEach(v => {
20
- const option = select.querySelector(`option[value=${v}]`);
20
+ const option = select.querySelector(`option[value='${v}']`);
21
21
  if (option) {
22
22
  option.selected = true;
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BubbleSelect.js","sources":["../../../../../../src/primitives/BubbleSelect.tsx"],"sourcesContent":["import React from 'react';\nimport { usePreviousValue } from '../hooks/usePrevious';\n\n// taken from radix - https://github.com/radix-ui/primitives/blob/main/packages/react/select/src/Select.tsx#L1183-L1224\nexport const BubbleSelect = (props: React.SelectHTMLAttributes<HTMLSelectElement>) => {\n const { value, ...selectProps } = props;\n const ref = React.useRef<HTMLSelectElement>(null);\n const prevValue = usePreviousValue(value);\n\n // Bubble value change to parents (e.g form change event)\n React.useEffect(() => {\n const select = ref.current!;\n const descriptor = Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, 'value') as PropertyDescriptor;\n const setValue = descriptor.set;\n\n if (prevValue !== value && setValue) {\n if (Array.isArray(value)) {\n value.forEach(v => {\n const option: HTMLOptionElement | null = select.querySelector(`option[value=${v}]`);\n\n if (option) {\n option.selected = true;\n }\n });\n } else {\n setValue.call(select, value);\n }\n\n const event = new Event('change', { bubbles: true });\n select.dispatchEvent(event);\n }\n }, [prevValue, value]);\n\n /**\n * We purposefully do not use `type=\"hidden\"` here otherwise forms that\n * wrap it will not be able to access its value via the FormData API.\n *\n * We purposefully do not add the `value` attribute here to allow the value\n * to be set programatically and bubble to any parent form `onChange` event.\n * Adding the `value` will cause React to consider the programatic\n * dispatch a duplicate and it will get swallowed.\n */\n return <select {...selectProps} defaultValue={value} ref={ref} style={{ display: 'none' }} />;\n};\n"],"names":["BubbleSelect","props","value","selectProps","ref","React","useRef","prevValue","usePreviousValue","useEffect","select","current","descriptor","Object","getOwnPropertyDescriptor","window","HTMLSelectElement","prototype","setValue","set","Array","isArray","forEach","v","option","querySelector","selected","call","event","Event","bubbles","dispatchEvent","defaultValue","style","display"],"mappings":";;;AAGA;MACaA,YAAY,GAAIC,KAAoD;EAC7E,MAAM;IAAEC,KAAK;IAAE,GAAGC;GAAa,GAAGF,KAAK;EACvC,MAAMG,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMC,SAAS,GAAGC,gBAAgB,CAACN,KAAK,CAAC;;EAGzCG,cAAK,CAACI,SAAS,CAAC;IACZ,MAAMC,MAAM,GAAGN,GAAG,CAACO,OAAQ;IAC3B,MAAMC,UAAU,GAAGC,MAAM,CAACC,wBAAwB,CAACC,MAAM,CAACC,iBAAiB,CAACC,SAAS,EAAE,OAAO,CAAuB;IACrH,MAAMC,QAAQ,GAAGN,UAAU,CAACO,GAAG;IAE/B,IAAIZ,SAAS,KAAKL,KAAK,IAAIgB,QAAQ,EAAE;MACjC,IAAIE,KAAK,CAACC,OAAO,CAACnB,KAAK,CAAC,EAAE;QACtBA,KAAK,CAACoB,OAAO,CAACC,CAAC;UACX,MAAMC,MAAM,GAA6Bd,MAAM,CAACe,aAAa,iBAAiBF,IAAI,CAAC;UAEnF,IAAIC,MAAM,EAAE;YACRA,MAAM,CAACE,QAAQ,GAAG,IAAI;;SAE7B,CAAC;OACL,MAAM;QACHR,QAAQ,CAACS,IAAI,CAACjB,MAAM,EAAER,KAAK,CAAC;;MAGhC,MAAM0B,KAAK,GAAG,IAAIC,KAAK,CAAC,QAAQ,EAAE;QAAEC,OAAO,EAAE;OAAM,CAAC;MACpDpB,MAAM,CAACqB,aAAa,CAACH,KAAK,CAAC;;GAElC,EAAE,CAACrB,SAAS,EAAEL,KAAK,CAAC,CAAC;;;;;;;;;;EAWtB,oBAAOG,yDAAYF,WAAW;IAAE6B,YAAY,EAAE9B,KAAK;IAAEE,GAAG,EAAEA,GAAG;IAAE6B,KAAK,EAAE;MAAEC,OAAO,EAAE;;KAAY;AACjG;;;;"}
1
+ {"version":3,"file":"BubbleSelect.js","sources":["../../../../../../src/primitives/BubbleSelect.tsx"],"sourcesContent":["import React from 'react';\nimport { usePreviousValue } from '../hooks/usePrevious';\n\n// taken from radix - https://github.com/radix-ui/primitives/blob/main/packages/react/select/src/Select.tsx#L1183-L1224\nexport const BubbleSelect = (props: React.SelectHTMLAttributes<HTMLSelectElement>) => {\n const { value, ...selectProps } = props;\n const ref = React.useRef<HTMLSelectElement>(null);\n const prevValue = usePreviousValue(value);\n\n // Bubble value change to parents (e.g form change event)\n React.useEffect(() => {\n const select = ref.current!;\n const descriptor = Object.getOwnPropertyDescriptor(window.HTMLSelectElement.prototype, 'value') as PropertyDescriptor;\n const setValue = descriptor.set;\n\n if (prevValue !== value && setValue) {\n if (Array.isArray(value)) {\n value.forEach(v => {\n const option: HTMLOptionElement | null = select.querySelector(`option[value='${v}']`);\n\n if (option) {\n option.selected = true;\n }\n });\n } else {\n setValue.call(select, value);\n }\n\n const event = new Event('change', { bubbles: true });\n select.dispatchEvent(event);\n }\n }, [prevValue, value]);\n\n /**\n * We purposefully do not use `type=\"hidden\"` here otherwise forms that\n * wrap it will not be able to access its value via the FormData API.\n *\n * We purposefully do not add the `value` attribute here to allow the value\n * to be set programatically and bubble to any parent form `onChange` event.\n * Adding the `value` will cause React to consider the programatic\n * dispatch a duplicate and it will get swallowed.\n */\n return <select {...selectProps} defaultValue={value} ref={ref} style={{ display: 'none' }} />;\n};\n"],"names":["BubbleSelect","props","value","selectProps","ref","React","useRef","prevValue","usePreviousValue","useEffect","select","current","descriptor","Object","getOwnPropertyDescriptor","window","HTMLSelectElement","prototype","setValue","set","Array","isArray","forEach","v","option","querySelector","selected","call","event","Event","bubbles","dispatchEvent","defaultValue","style","display"],"mappings":";;;AAGA;MACaA,YAAY,GAAIC,KAAoD;EAC7E,MAAM;IAAEC,KAAK;IAAE,GAAGC;GAAa,GAAGF,KAAK;EACvC,MAAMG,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMC,SAAS,GAAGC,gBAAgB,CAACN,KAAK,CAAC;;EAGzCG,cAAK,CAACI,SAAS,CAAC;IACZ,MAAMC,MAAM,GAAGN,GAAG,CAACO,OAAQ;IAC3B,MAAMC,UAAU,GAAGC,MAAM,CAACC,wBAAwB,CAACC,MAAM,CAACC,iBAAiB,CAACC,SAAS,EAAE,OAAO,CAAuB;IACrH,MAAMC,QAAQ,GAAGN,UAAU,CAACO,GAAG;IAE/B,IAAIZ,SAAS,KAAKL,KAAK,IAAIgB,QAAQ,EAAE;MACjC,IAAIE,KAAK,CAACC,OAAO,CAACnB,KAAK,CAAC,EAAE;QACtBA,KAAK,CAACoB,OAAO,CAACC,CAAC;UACX,MAAMC,MAAM,GAA6Bd,MAAM,CAACe,aAAa,kBAAkBF,KAAK,CAAC;UAErF,IAAIC,MAAM,EAAE;YACRA,MAAM,CAACE,QAAQ,GAAG,IAAI;;SAE7B,CAAC;OACL,MAAM;QACHR,QAAQ,CAACS,IAAI,CAACjB,MAAM,EAAER,KAAK,CAAC;;MAGhC,MAAM0B,KAAK,GAAG,IAAIC,KAAK,CAAC,QAAQ,EAAE;QAAEC,OAAO,EAAE;OAAM,CAAC;MACpDpB,MAAM,CAACqB,aAAa,CAACH,KAAK,CAAC;;GAElC,EAAE,CAACrB,SAAS,EAAEL,KAAK,CAAC,CAAC;;;;;;;;;;EAWtB,oBAAOG,yDAAYF,WAAW;IAAE6B,YAAY,EAAE9B,KAAK;IAAEE,GAAG,EAAEA,GAAG;IAAE6B,KAAK,EAAE;MAAEC,OAAO,EAAE;;KAAY;AACjG;;;;"}
@@ -8040,9 +8040,7 @@ const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSin
8040
8040
  readOnly,
8041
8041
  tags
8042
8042
  } = useSelect2Context();
8043
- const contentClassName = cn('truncate', {
8044
- 'flex gap-1': tags
8045
- });
8043
+ const contentClassName = cn('truncate flex items-center gap-1');
8046
8044
  const currentValue = children.find(matchesValue(value));
8047
8045
  let output;
8048
8046
  if (currentValue) {
@@ -8056,7 +8054,6 @@ const Single = /*#__PURE__*/React__default.forwardRef(function Select2TriggerSin
8056
8054
  }, currentValue.props.children);
8057
8055
  } else {
8058
8056
  output = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, currentValue.props.icon ? typeof currentValue.props.icon === 'string' ? /*#__PURE__*/React__default.createElement(Icon, {
8059
- className: "mr-1",
8060
8057
  name: currentValue.props.icon
8061
8058
  }) : currentValue.props.icon : null, currentValue.props.children);
8062
8059
  }
@@ -8203,7 +8200,7 @@ const BubbleSelect = props => {
8203
8200
  if (prevValue !== value && setValue) {
8204
8201
  if (Array.isArray(value)) {
8205
8202
  value.forEach(v => {
8206
- const option = select.querySelector(`option[value=${v}]`);
8203
+ const option = select.querySelector(`option[value='${v}']`);
8207
8204
  if (option) {
8208
8205
  option.selected = true;
8209
8206
  }