@economic/taco 1.37.0 → 1.38.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. package/dist/components/Checkbox/Checkbox.d.ts +0 -1
  2. package/dist/components/Input/util.d.ts +1 -1
  3. package/dist/components/Table2/hooks/useColumnDefinitions.d.ts +1 -1
  4. package/dist/components/Table2/types.d.ts +1 -1
  5. package/dist/components/Tabs/Tabs.d.ts +0 -1
  6. package/dist/esm/index.css +0 -20
  7. package/dist/esm/packages/taco/src/components/Button/Button.js +0 -2
  8. package/dist/esm/packages/taco/src/components/Button/Button.js.map +1 -1
  9. package/dist/esm/packages/taco/src/components/Button/util.js +7 -7
  10. package/dist/esm/packages/taco/src/components/Button/util.js.map +1 -1
  11. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js +7 -8
  12. package/dist/esm/packages/taco/src/components/Checkbox/Checkbox.js.map +1 -1
  13. package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js +5 -8
  14. package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js.map +1 -1
  15. package/dist/esm/packages/taco/src/components/Drawer/components/Content.js +6 -5
  16. package/dist/esm/packages/taco/src/components/Drawer/components/Content.js.map +1 -1
  17. package/dist/esm/packages/taco/src/components/Field/Field.js +1 -1
  18. package/dist/esm/packages/taco/src/components/Field/Field.js.map +1 -1
  19. package/dist/esm/packages/taco/src/components/Header/components/Button.js +1 -1
  20. package/dist/esm/packages/taco/src/components/Header/components/Button.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Header/components/Link.js +2 -2
  22. package/dist/esm/packages/taco/src/components/Header/components/Link.js.map +1 -1
  23. package/dist/esm/packages/taco/src/components/IconButton/IconButton.js +1 -3
  24. package/dist/esm/packages/taco/src/components/IconButton/IconButton.js.map +1 -1
  25. package/dist/esm/packages/taco/src/components/Input/Input.js +1 -1
  26. package/dist/esm/packages/taco/src/components/Input/Input.js.map +1 -1
  27. package/dist/esm/packages/taco/src/components/Input/util.js +11 -11
  28. package/dist/esm/packages/taco/src/components/Input/util.js.map +1 -1
  29. package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js +6 -4
  30. package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
  31. package/dist/esm/packages/taco/src/components/Select2/components/Create.js +14 -6
  32. package/dist/esm/packages/taco/src/components/Select2/components/Create.js.map +1 -1
  33. package/dist/esm/packages/taco/src/components/Select2/components/Option.js +1 -2
  34. package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
  35. package/dist/esm/packages/taco/src/components/Switch/Switch.js +3 -3
  36. package/dist/esm/packages/taco/src/components/Switch/Switch.js.map +1 -1
  37. package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js +4 -2
  38. package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js.map +1 -1
  39. package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js +4 -3
  40. package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js.map +1 -1
  41. package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js +3 -1
  42. package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js.map +1 -1
  43. package/dist/esm/packages/taco/src/components/Table2/types.js.map +1 -1
  44. package/dist/esm/packages/taco/src/components/Tabs/Tabs.js +21 -8
  45. package/dist/esm/packages/taco/src/components/Tabs/Tabs.js.map +1 -1
  46. package/dist/index.css +0 -20
  47. package/dist/taco.cjs.development.js +96 -77
  48. package/dist/taco.cjs.development.js.map +1 -1
  49. package/dist/taco.cjs.production.min.js +1 -1
  50. package/dist/taco.cjs.production.min.js.map +1 -1
  51. package/package.json +2 -2
  52. package/plugins/tailwindcss-aria-attributes.js +20 -36
  53. package/tailwind.config.js +6 -2
  54. package/types.json +7 -4
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.js","sources":["../../../../../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { getAppearanceClasses, getButtonClasses, createButtonWithTooltip, createButtonWithOverlays } from '../Button/util';\nimport { Appearance } from '../../types';\nimport { DialogProps, HangerProps, MenuProps, PopoverProps } from '../..';\n\nexport type IconButtonProps = Omit<ButtonPrimitive.ButtonProps, 'children'> & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /**\n * Dialog component associated with the button, clicking the button will open the dialog.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated dialog when clicked.\n */\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n /** Hanger component associated with the button. */\n hanger?: (props: Partial<HangerProps>) => JSX.Element;\n /** Set which icon should be rendered within button */\n icon: IconName; // this dynamic type causes the type extraction for props to fail\n /** Menu component associated with the button. */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n /**\n * Popover component associated with the button, clicking the button will open the popover.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated popover when clicked.\n */\n popover?: (props: Partial<PopoverProps>) => JSX.Element;\n /**\n * Set whether the button is rounded.\n * Default value is `false`\n */\n rounded?: boolean;\n /** A tooltip to show when hovering over the button */\n tooltip?: string;\n};\n\nexport const Base = React.forwardRef(function IconButtonBase(\n props: IconButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) {\n const { icon, rounded = false, ...otherProps } = props;\n\n const className = cn(\n 'w-8',\n getButtonClasses(),\n getAppearanceClasses(otherProps.appearance, true),\n {\n 'rounded-full': rounded,\n rounded: !rounded,\n 'cursor-not-allowed opacity-50': props.disabled,\n 'focus:yt-focus active:focus:yt-focus': !props.disabled,\n },\n props.className\n );\n\n if (!icon) {\n return null;\n }\n\n return createButtonWithTooltip(\n { ...otherProps, children: <Icon name={icon} className=\"m-0 p-0\" />, 'data-taco': 'icon-button' },\n className,\n ref\n );\n});\n\nexport const IconButton = React.forwardRef(function Button(\n props: IconButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) {\n const { dialog, hanger, menu, popover, ...buttonProps } = props;\n const button = <Base {...buttonProps} ref={ref} />;\n\n return createButtonWithOverlays({ dialog, hanger, menu, popover }, button);\n});\n"],"names":["Base","React","IconButtonBase","props","ref","icon","rounded","otherProps","className","cn","getButtonClasses","getAppearanceClasses","appearance","disabled","createButtonWithTooltip","children","Icon","name","IconButton","Button","dialog","hanger","menu","popover","buttonProps","button","createButtonWithOverlays"],"mappings":";;;;;MAsCaA,IAAI,gBAAGC,UAAgB,CAAC,SAASC,cAAc,CACxDC,KAAsB,EACtBC,GAAqD;EAErD,MAAM;IAAEC,IAAI;IAAEC,OAAO,GAAG,KAAK;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAEtD,MAAMK,SAAS,GAAGC,EAAE,CAChB,KAAK,EACLC,gBAAgB,EAAE,EAClBC,oBAAoB,CAACJ,UAAU,CAACK,UAAU,EAAE,IAAI,CAAC,EACjD;IACI,cAAc,EAAEN,OAAO;IACvBA,OAAO,EAAE,CAACA,OAAO;IACjB,+BAA+B,EAAEH,KAAK,CAACU,QAAQ;IAC/C,sCAAsC,EAAE,CAACV,KAAK,CAACU;GAClD,EACDV,KAAK,CAACK,SAAS,CAClB;EAED,IAAI,CAACH,IAAI,EAAE;IACP,OAAO,IAAI;;EAGf,OAAOS,uBAAuB,CAC1B;IAAE,GAAGP,UAAU;IAAEQ,QAAQ,eAAEd,cAACe,IAAI;MAACC,IAAI,EAAEZ,IAAI;MAAEG,SAAS,EAAC;MAAY;IAAE,WAAW,EAAE;GAAe,EACjGA,SAAS,EACTJ,GAAG,CACN;AACL,CAAC;MAEYc,UAAU,gBAAGjB,UAAgB,CAAC,SAASkB,MAAM,CACtDhB,KAAsB,EACtBC,GAAqD;EAErD,MAAM;IAAEgB,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAE,GAAGC;GAAa,GAAGrB,KAAK;EAC/D,MAAMsB,MAAM,gBAAGxB,cAACD,IAAI,oBAAKwB,WAAW;IAAEpB,GAAG,EAAEA;KAAO;EAElD,OAAOsB,wBAAwB,CAAC;IAAEN,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC;GAAS,EAAEE,MAAM,CAAC;AAC9E,CAAC;;;;"}
1
+ {"version":3,"file":"IconButton.js","sources":["../../../../../../../src/components/IconButton/IconButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as ButtonPrimitive from '../../primitives/Button';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { getAppearanceClasses, getButtonClasses, createButtonWithTooltip, createButtonWithOverlays } from '../Button/util';\nimport { Appearance } from '../../types';\nimport { DialogProps, HangerProps, MenuProps, PopoverProps } from '../..';\n\nexport type IconButtonProps = Omit<ButtonPrimitive.ButtonProps, 'children'> & {\n /** Appearance will change the style of the button */\n appearance?: Appearance;\n /**\n * Dialog component associated with the button, clicking the button will open the dialog.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated dialog when clicked.\n */\n dialog?: (props: Partial<DialogProps>) => JSX.Element;\n /** Hanger component associated with the button. */\n hanger?: (props: Partial<HangerProps>) => JSX.Element;\n /** Set which icon should be rendered within button */\n icon: IconName; // this dynamic type causes the type extraction for props to fail\n /** Menu component associated with the button. */\n menu?: (props: Partial<MenuProps>) => JSX.Element;\n /**\n * Popover component associated with the button, clicking the button will open the popover.\n * *Note* that `onClick` event on button won't be handled, as in this case, the purpose of\n * the button should be only to open the associated popover when clicked.\n */\n popover?: (props: Partial<PopoverProps>) => JSX.Element;\n /**\n * Set whether the button is rounded.\n * Default value is `false`\n */\n rounded?: boolean;\n /** A tooltip to show when hovering over the button */\n tooltip?: string;\n};\n\nexport const Base = React.forwardRef(function IconButtonBase(\n props: IconButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) {\n const { icon, rounded = false, ...otherProps } = props;\n\n const className = cn(\n 'w-8',\n getButtonClasses(),\n getAppearanceClasses(otherProps.appearance, true),\n {\n 'rounded-full': rounded,\n rounded: !rounded,\n },\n props.className\n );\n\n if (!icon) {\n return null;\n }\n\n return createButtonWithTooltip(\n { ...otherProps, children: <Icon name={icon} className=\"m-0 p-0\" />, 'data-taco': 'icon-button' },\n className,\n ref\n );\n});\n\nexport const IconButton = React.forwardRef(function Button(\n props: IconButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>\n) {\n const { dialog, hanger, menu, popover, ...buttonProps } = props;\n const button = <Base {...buttonProps} ref={ref} />;\n\n return createButtonWithOverlays({ dialog, hanger, menu, popover }, button);\n});\n"],"names":["Base","React","IconButtonBase","props","ref","icon","rounded","otherProps","className","cn","getButtonClasses","getAppearanceClasses","appearance","createButtonWithTooltip","children","Icon","name","IconButton","Button","dialog","hanger","menu","popover","buttonProps","button","createButtonWithOverlays"],"mappings":";;;;;MAsCaA,IAAI,gBAAGC,UAAgB,CAAC,SAASC,cAAc,CACxDC,KAAsB,EACtBC,GAAqD;EAErD,MAAM;IAAEC,IAAI;IAAEC,OAAO,GAAG,KAAK;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAEtD,MAAMK,SAAS,GAAGC,EAAE,CAChB,KAAK,EACLC,gBAAgB,EAAE,EAClBC,oBAAoB,CAACJ,UAAU,CAACK,UAAU,EAAE,IAAI,CAAC,EACjD;IACI,cAAc,EAAEN,OAAO;IACvBA,OAAO,EAAE,CAACA;GACb,EACDH,KAAK,CAACK,SAAS,CAClB;EAED,IAAI,CAACH,IAAI,EAAE;IACP,OAAO,IAAI;;EAGf,OAAOQ,uBAAuB,CAC1B;IAAE,GAAGN,UAAU;IAAEO,QAAQ,eAAEb,cAACc,IAAI;MAACC,IAAI,EAAEX,IAAI;MAAEG,SAAS,EAAC;MAAY;IAAE,WAAW,EAAE;GAAe,EACjGA,SAAS,EACTJ,GAAG,CACN;AACL,CAAC;MAEYa,UAAU,gBAAGhB,UAAgB,CAAC,SAASiB,MAAM,CACtDf,KAAsB,EACtBC,GAAqD;EAErD,MAAM;IAAEe,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAE,GAAGC;GAAa,GAAGpB,KAAK;EAC/D,MAAMqB,MAAM,gBAAGvB,cAACD,IAAI,oBAAKuB,WAAW;IAAEnB,GAAG,EAAEA;KAAO;EAElD,OAAOqB,wBAAwB,CAAC;IAAEN,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC;GAAS,EAAEE,MAAM,CAAC;AAC9E,CAAC;;;;"}
@@ -101,7 +101,7 @@ const Input = /*#__PURE__*/forwardRef(function LegacyInput(props, ref) {
101
101
  let postfix;
102
102
  if (button) {
103
103
  const disabled = button.props.disabled || attributes.disabled;
104
- const buttonClassName = cn('items-center focus:z-10 flex justify-center rounded-l-none rounded-r h-full focus:rounded focus:outline-none', getButtonStateClasses(attributes.invalid), button.props.className);
104
+ const buttonClassName = cn('items-center focus:z-10 flex justify-center rounded-l-none rounded-r h-full focus:rounded focus:outline-none', getButtonStateClasses(attributes.invalid, disabled), button.props.className);
105
105
  postfix = /*#__PURE__*/cloneElement(button, {
106
106
  className: buttonClassName,
107
107
  disabled
@@ -1 +1 @@
1
- {"version":3,"file":"Input.js","sources":["../../../../../../../src/components/Input/Input.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { getButtonStateClasses, getInputClasses } from './util';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { useMergedRef } from '../../hooks/useMergedRef';\n\nexport type InputWithoutDeprecatedFeaturesProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'prefix'> & {\n /** Draws attention to the input by changing its style and making it visually prominent */\n highlighted?: boolean;\n /* Whether the input is in an invalid state */\n invalid?: boolean;\n postfix?: string | JSX.Element;\n prefix?: string | JSX.Element;\n};\n\nconst validSetSelectionRangeTypes = ['text', 'search', 'url', 'tel', 'password'];\n\nconst InputWithoutDeprecatedFeatures = React.forwardRef(function InputWithoutDeprecatedFeatures(\n props: InputWithoutDeprecatedFeaturesProps,\n ref: React.Ref<HTMLInputElement>\n) {\n const { highlighted, invalid, onKeyDown, postfix, prefix, type = 'text', ...attributes } = props;\n const internalRef = useMergedRef<HTMLInputElement>(ref);\n\n let handleKeyDown = onKeyDown;\n\n // home and end keys only navigate to the start/end of input value if the input container does not scroll\n // if it has scroll height then the browser reverts to native scrolling behaviour only\n // so we manually override it to ensure _our_ desired behaviour remains intact\n // only the 'text', 'search', 'url', 'tel', 'password' input types support setSelectionRange\n if (validSetSelectionRangeTypes.includes(type)) {\n handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (!event.shiftKey && (event.key === 'Home' || event.key === 'End')) {\n event.preventDefault();\n const position = event.key === 'End' ? event.currentTarget.value.length : 0;\n event.currentTarget.setSelectionRange(position, position);\n }\n\n if (typeof onKeyDown === 'function') {\n onKeyDown(event);\n }\n };\n }\n\n const prefixRef = React.useRef<HTMLDivElement>(null);\n const prefixRect = useBoundingClientRectListener(prefixRef);\n const postfixRef = React.useRef<HTMLDivElement>(null);\n const postfixRect = useBoundingClientRectListener(postfixRef);\n\n const className = cn(\n getInputClasses(props),\n {\n 'pl-8': !!prefix,\n 'pr-8': !!postfix,\n },\n attributes.className\n );\n\n return (\n <div className=\"relative inline-flex w-full\" data-taco=\"input-container\" style={{ opacity: 0.999 }}>\n <input\n {...attributes}\n className={className}\n data-taco=\"input\"\n onKeyDown={handleKeyDown}\n aria-invalid={invalid}\n data-highlighted={highlighted}\n ref={internalRef}\n style={{\n paddingLeft: prefixRect ? `${prefixRect.width - 1}px` : undefined,\n paddingRight: postfixRect ? `${postfixRect.width - 1}px` : undefined,\n }}\n type={type}\n />\n {prefix ? <Affix type=\"prefix\" children={prefix} disabled={attributes.disabled} ref={prefixRef} /> : null}\n {postfix ? <Affix type=\"postfix\" children={postfix} disabled={attributes.disabled} ref={postfixRef} /> : null}\n </div>\n );\n});\n\ntype AffixProps = {\n children: string | JSX.Element;\n disabled?: boolean;\n type: 'prefix' | 'postfix';\n};\nconst Affix = React.memo(\n React.forwardRef(function Affix(props: AffixProps, ref: React.Ref<HTMLDivElement>) {\n const { children, disabled, type } = props;\n\n return (\n <div\n className={cn(\n 'group absolute top-0 flex h-full items-center justify-center px-2',\n // icon\n '[&_[data-taco=\"icon\"]]:!h-5 [&_[data-taco=\"icon\"]]:!w-5',\n {\n 'text-grey-300': disabled,\n 'text-grey-700': !disabled,\n 'left-0 [&>button]:!-ml-2': type === 'prefix',\n 'right-0 [&>button]:!-mr-2': type === 'postfix',\n }\n )}\n data-affix-type={type}\n ref={ref}>\n {children}\n </div>\n );\n })\n);\n\nexport type InputProps = InputWithoutDeprecatedFeaturesProps & {\n /** Shows a button within the input field */\n button?: React.ReactElement;\n /** Shows an icon within the input field */\n icon?: IconName | JSX.Element;\n};\n\nexport const Input = React.forwardRef(function LegacyInput(props: InputProps, ref: React.Ref<HTMLInputElement>) {\n const { button, icon, ...attributes } = props;\n\n let postfix;\n\n if (button) {\n const disabled = button.props.disabled || attributes.disabled;\n const buttonClassName = cn(\n 'items-center focus:z-10 flex justify-center rounded-l-none rounded-r h-full focus:rounded focus:outline-none',\n getButtonStateClasses(attributes.invalid),\n button.props.className\n );\n postfix = React.cloneElement(button, {\n className: buttonClassName,\n disabled,\n });\n } else if (icon) {\n postfix = typeof icon === 'string' ? <Icon name={icon} /> : icon;\n }\n\n return <InputWithoutDeprecatedFeatures {...attributes} postfix={attributes.postfix ?? postfix} ref={ref} />;\n});\n"],"names":["validSetSelectionRangeTypes","InputWithoutDeprecatedFeatures","React","props","ref","highlighted","invalid","onKeyDown","postfix","prefix","type","attributes","internalRef","useMergedRef","handleKeyDown","includes","event","shiftKey","key","preventDefault","position","currentTarget","value","length","setSelectionRange","prefixRef","prefixRect","useBoundingClientRectListener","postfixRef","postfixRect","className","cn","getInputClasses","style","opacity","paddingLeft","width","undefined","paddingRight","Affix","children","disabled","Input","LegacyInput","button","icon","buttonClassName","get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EAAE,CAACA,QAAQ;MAC1B,0BAA0B,EAAE/B,IAAI,KAAK,QAAQ;MAC7C,2BAA2B,EAAEA,IAAI,KAAK;KACzC,CACJ;uBACgBA,IAAI;IACrBN,GAAG,EAAEA;KACJoC,QAAQ,CACP;AAEd,CAAC,CAAC,CACL;MASYE,KAAK,gBAAGxC,UAAgB,CAAC,SAASyC,WAAW,CAACxC,KAAiB,EAAEC,GAAgC;;EAC1G,MAAM;IAAEwC,MAAM;IAAEC,IAAI;IAAE,GAAGlC;GAAY,GAAGR,KAAK;EAE7C,IAAIK,OAAO;EAEX,IAAIoC,MAAM,EAAE;IACR,MAAMH,QAAQ,GAAGG,MAAM,CAACzC,KAAK,CAACsC,QAAQ,IAAI9B,UAAU,CAAC8B,QAAQ;IAC7D,MAAMK,eAAe,GAAGf,EAAE,CACtB,8GAA8G,EAC9GgB,qBAAqB,CAACpC,UAAU,CAACL,OAAO,CAAC,EACzCsC,MAAM,CAACzC,KAAK,CAAC2B,SAAS,CACzB;IACDtB,OAAO,gBAAGN,YAAkB,CAAC0C,MAAM,EAAE;MACjCd,SAAS,EAAEgB,eAAe;MAC1BL;KACH,CAAC;GACL,MAAM,IAAII,IAAI,EAAE;IACbrC,OAAO,GAAG,OAAOqC,IAAI,KAAK,QAAQ,gBAAG3C,cAAC8C,IAAI;MAACC,IAAI,EAAEJ;MAAQ,GAAGA,IAAI;;EAGpE,oBAAO3C,cAACD,8BAA8B,oBAAKU,UAAU;IAAEH,OAAO,yBAAEG,UAAU,CAACH,OAAO,qEAAIA,OAAO;IAAEJ,GAAG,EAAEA;KAAO;AAC/G,CAAC;;;;"}
1
+ {"version":3,"file":"Input.js","sources":["../../../../../../../src/components/Input/Input.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport { Icon, IconName } from '../Icon/Icon';\nimport { getButtonStateClasses, getInputClasses } from './util';\nimport { useBoundingClientRectListener } from '../../hooks/useBoundingClientRectListener';\nimport { useMergedRef } from '../../hooks/useMergedRef';\n\nexport type InputWithoutDeprecatedFeaturesProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'prefix'> & {\n /** Draws attention to the input by changing its style and making it visually prominent */\n highlighted?: boolean;\n /* Whether the input is in an invalid state */\n invalid?: boolean;\n postfix?: string | JSX.Element;\n prefix?: string | JSX.Element;\n};\n\nconst validSetSelectionRangeTypes = ['text', 'search', 'url', 'tel', 'password'];\n\nconst InputWithoutDeprecatedFeatures = React.forwardRef(function InputWithoutDeprecatedFeatures(\n props: InputWithoutDeprecatedFeaturesProps,\n ref: React.Ref<HTMLInputElement>\n) {\n const { highlighted, invalid, onKeyDown, postfix, prefix, type = 'text', ...attributes } = props;\n const internalRef = useMergedRef<HTMLInputElement>(ref);\n\n let handleKeyDown = onKeyDown;\n\n // home and end keys only navigate to the start/end of input value if the input container does not scroll\n // if it has scroll height then the browser reverts to native scrolling behaviour only\n // so we manually override it to ensure _our_ desired behaviour remains intact\n // only the 'text', 'search', 'url', 'tel', 'password' input types support setSelectionRange\n if (validSetSelectionRangeTypes.includes(type)) {\n handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (!event.shiftKey && (event.key === 'Home' || event.key === 'End')) {\n event.preventDefault();\n const position = event.key === 'End' ? event.currentTarget.value.length : 0;\n event.currentTarget.setSelectionRange(position, position);\n }\n\n if (typeof onKeyDown === 'function') {\n onKeyDown(event);\n }\n };\n }\n\n const prefixRef = React.useRef<HTMLDivElement>(null);\n const prefixRect = useBoundingClientRectListener(prefixRef);\n const postfixRef = React.useRef<HTMLDivElement>(null);\n const postfixRect = useBoundingClientRectListener(postfixRef);\n\n const className = cn(\n getInputClasses(props),\n {\n 'pl-8': !!prefix,\n 'pr-8': !!postfix,\n },\n attributes.className\n );\n\n return (\n <div className=\"relative inline-flex w-full\" data-taco=\"input-container\" style={{ opacity: 0.999 }}>\n <input\n {...attributes}\n className={className}\n data-taco=\"input\"\n onKeyDown={handleKeyDown}\n aria-invalid={invalid}\n data-highlighted={highlighted}\n ref={internalRef}\n style={{\n paddingLeft: prefixRect ? `${prefixRect.width - 1}px` : undefined,\n paddingRight: postfixRect ? `${postfixRect.width - 1}px` : undefined,\n }}\n type={type}\n />\n {prefix ? <Affix type=\"prefix\" children={prefix} disabled={attributes.disabled} ref={prefixRef} /> : null}\n {postfix ? <Affix type=\"postfix\" children={postfix} disabled={attributes.disabled} ref={postfixRef} /> : null}\n </div>\n );\n});\n\ntype AffixProps = {\n children: string | JSX.Element;\n disabled?: boolean;\n type: 'prefix' | 'postfix';\n};\nconst Affix = React.memo(\n React.forwardRef(function Affix(props: AffixProps, ref: React.Ref<HTMLDivElement>) {\n const { children, disabled, type } = props;\n\n return (\n <div\n className={cn(\n 'group absolute top-0 flex h-full items-center justify-center px-2',\n // icon\n '[&_[data-taco=\"icon\"]]:!h-5 [&_[data-taco=\"icon\"]]:!w-5',\n {\n 'text-grey-300': disabled,\n 'text-grey-700': !disabled,\n 'left-0 [&>button]:!-ml-2': type === 'prefix',\n 'right-0 [&>button]:!-mr-2': type === 'postfix',\n }\n )}\n data-affix-type={type}\n ref={ref}>\n {children}\n </div>\n );\n })\n);\n\nexport type InputProps = InputWithoutDeprecatedFeaturesProps & {\n /** Shows a button within the input field */\n button?: React.ReactElement;\n /** Shows an icon within the input field */\n icon?: IconName | JSX.Element;\n};\n\nexport const Input = React.forwardRef(function LegacyInput(props: InputProps, ref: React.Ref<HTMLInputElement>) {\n const { button, icon, ...attributes } = props;\n\n let postfix;\n\n if (button) {\n const disabled = button.props.disabled || attributes.disabled;\n const buttonClassName = cn(\n 'items-center focus:z-10 flex justify-center rounded-l-none rounded-r h-full focus:rounded focus:outline-none',\n getButtonStateClasses(attributes.invalid, disabled),\n button.props.className\n );\n postfix = React.cloneElement(button, {\n className: buttonClassName,\n disabled,\n });\n } else if (icon) {\n postfix = typeof icon === 'string' ? <Icon name={icon} /> : icon;\n }\n\n return <InputWithoutDeprecatedFeatures {...attributes} postfix={attributes.postfix ?? postfix} ref={ref} />;\n});\n"],"names":["validSetSelectionRangeTypes","InputWithoutDeprecatedFeatures","React","props","ref","highlighted","invalid","onKeyDown","postfix","prefix","type","attributes","internalRef","useMergedRef","handleKeyDown","includes","event","shiftKey","key","preventDefault","position","currentTarget","value","length","setSelectionRange","prefixRef","prefixRect","useBoundingClientRectListener","postfixRef","postfixRect","className","cn","getInputClasses","style","opacity","paddingLeft","width","undefined","paddingRight","Affix","children","disabled","Input","LegacyInput","button","icon","buttonClassName","getButtonStateClasses","Icon","name"],"mappings":";;;;;;;AAgBA,MAAMA,2BAA2B,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC;AAEhF,MAAMC,8BAA8B,gBAAGC,UAAgB,CAAC,SAASD,8BAA8B,CAC3FE,KAA0C,EAC1CC,GAAgC;EAEhC,MAAM;IAAEC,WAAW;IAAEC,OAAO;IAAEC,SAAS;IAAEC,OAAO;IAAEC,MAAM;IAAEC,IAAI,GAAG,MAAM;IAAE,GAAGC;GAAY,GAAGR,KAAK;EAChG,MAAMS,WAAW,GAAGC,YAAY,CAAmBT,GAAG,CAAC;EAEvD,IAAIU,aAAa,GAAGP,SAAS;;;;;EAM7B,IAAIP,2BAA2B,CAACe,QAAQ,CAACL,IAAI,CAAC,EAAE;IAC5CI,aAAa,GAAIE,KAA4C;MACzD,IAAI,CAACA,KAAK,CAACC,QAAQ,KAAKD,KAAK,CAACE,GAAG,KAAK,MAAM,IAAIF,KAAK,CAACE,GAAG,KAAK,KAAK,CAAC,EAAE;QAClEF,KAAK,CAACG,cAAc,EAAE;QACtB,MAAMC,QAAQ,GAAGJ,KAAK,CAACE,GAAG,KAAK,KAAK,GAAGF,KAAK,CAACK,aAAa,CAACC,KAAK,CAACC,MAAM,GAAG,CAAC;QAC3EP,KAAK,CAACK,aAAa,CAACG,iBAAiB,CAACJ,QAAQ,EAAEA,QAAQ,CAAC;;MAG7D,IAAI,OAAOb,SAAS,KAAK,UAAU,EAAE;QACjC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G,UAAU,CAACH,OAAO,qEAAIA,OAAO;IAAEJ,GAAG,EAAEA;KAAO;AAC/G,CAAC;;;;"}
@@ -4,28 +4,28 @@ 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 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)]', {
7
+ return cn('peer 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)] focus-visible:yt-focus', {
8
8
  'bg-white': !props.highlighted && !readOnly,
9
9
  // default
10
- 'border-grey-300 focus:border-blue-300 focus:yt-focus': !invalid,
11
- 'hover:shadow-[0_0_0.1rem_theme(colors.grey.500)] active:border-blue-700': !invalid && !disabled,
10
+ 'border-grey-300 enabled:hover:border-grey-500 disabled:border-grey-200': !invalid,
12
11
  // disabled
13
- 'border-grey-200 text-opacity-25 cursor-not-allowed placeholder:text-grey-700': disabled,
12
+ 'text-opacity-25 cursor-not-allowed placeholder:text-grey-700': disabled,
14
13
  // highlighted
15
- 'bg-[rgba(255,255,0,0.075)]': props.highlighted && disabled,
16
- 'bg-[rgba(255,255,0,0.2)]': props.highlighted && !disabled,
14
+ 'bg-yellow-100/50': props.highlighted && disabled,
15
+ 'bg-yellow-100': props.highlighted && !disabled,
17
16
  // invalid
18
- 'border-red focus:border-red-300 focus:yt-focus-red active:border-red-700': invalid,
19
- 'hover:shadow-[0_0_0.15rem_theme(colors.red.500)]': invalid && !disabled,
17
+ 'border-red-500 enabled:hover:border-red-700 disabled:border-red-500/50': invalid,
20
18
  // readOnly
21
19
  'cursor-not-allowed text-black bg-grey-200': readOnly
22
20
  });
23
21
  };
24
- const getButtonStateClasses = invalid => {
22
+ const getButtonStateClasses = (invalid, disabled = false) => {
25
23
  if (invalid) {
26
- 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';
24
+ return cn('border border-red-500 group-peer-hover:enabled:border-red-700 transition-colors ease-in', {
25
+ 'border-red-500/30': disabled
26
+ });
27
27
  }
28
- 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';
28
+ return 'border border-grey-300 group-peer-hover:enabled:border-grey-500 transition-colors transition-opacity ease-in';
29
29
  };
30
30
 
31
31
  export { getButtonStateClasses, getInputClasses };
@@ -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 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 'bg-white': !props.highlighted && !readOnly,\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,iNAAiN,EACjN;IACI,UAAU,EAAE,CAACJ,KAAK,CAACK,WAAW,IAAI,CAACH,QAAQ;;IAE3C,sDAAsD,EAAE,CAACC,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;;;;"}
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 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)] focus-visible:yt-focus',\n {\n 'bg-white': !props.highlighted && !readOnly,\n // default\n 'border-grey-300 enabled:hover:border-grey-500 disabled:border-grey-200': !invalid,\n // disabled\n 'text-opacity-25 cursor-not-allowed placeholder:text-grey-700': disabled,\n // highlighted\n 'bg-yellow-100/50': props.highlighted && disabled,\n 'bg-yellow-100': props.highlighted && !disabled,\n // invalid\n 'border-red-500 enabled:hover:border-red-700 disabled:border-red-500/50': invalid,\n // readOnly\n 'cursor-not-allowed text-black bg-grey-200': readOnly,\n }\n );\n};\n\nexport const getButtonStateClasses = (invalid: boolean | undefined, disabled = false): string => {\n if (invalid) {\n return cn('border border-red-500 group-peer-hover:enabled:border-red-700 transition-colors ease-in', {\n 'border-red-500/30': disabled,\n });\n }\n\n return 'border border-grey-300 group-peer-hover:enabled:border-grey-500 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,wOAAwO,EACxO;IACI,UAAU,EAAE,CAACJ,KAAK,CAACK,WAAW,IAAI,CAACH,QAAQ;;IAE3C,wEAAwE,EAAE,CAACC,OAAO;;IAElF,8DAA8D,EAAEF,QAAQ;;IAExE,kBAAkB,EAAED,KAAK,CAACK,WAAW,IAAIJ,QAAQ;IACjD,eAAe,EAAED,KAAK,CAACK,WAAW,IAAI,CAACJ,QAAQ;;IAE/C,wEAAwE,EAAEE,OAAO;;IAEjF,2CAA2C,EAAED;GAChD,CACJ;AACL;MAEaI,qBAAqB,GAAG,CAACH,OAA4B,EAAEF,QAAQ,GAAG,KAAK;EAChF,IAAIE,OAAO,EAAE;IACT,OAAOC,EAAE,CAAC,yFAAyF,EAAE;MACjG,mBAAmB,EAAEH;KACxB,CAAC;;EAGN,OAAO,8GAA8G;AACzH;;;;"}
@@ -16,10 +16,12 @@ const RadioGroupItem = /*#__PURE__*/forwardRef(function RadioGroupItem(props, re
16
16
  ...otherProps
17
17
  } = props;
18
18
  const isDisabled = context.disabled || props.disabled;
19
- const className = cn('flex flex-shrink-0 self-start items-center justify-center h-4 w-4 mt-[0.2rem] rounded-full bg-white border-2', {
20
- 'border-grey-300 hover:border-4 focus:yt-focus aria-checked:bg-blue-500 aria-checked:border-blue-500 hover:aria-checked:border-blue-300': !isDisabled && !context.invalid,
21
- 'border-grey-200 cursor-not-allowed aria-checked:bg-blue-300 aria-checked:border-blue-300 ': isDisabled,
22
- 'border-red-500 hover:border-4 text-red-500 focus:border-red-500 focus:yt-focus-red aria-checked:bg-red-500 aria-checked:border-red': context.invalid && !isDisabled
19
+ const className = cn('flex flex-shrink-0 self-start items-center justify-center h-4 w-4 mt-[0.2rem] rounded-full bg-white border-2 focus-visible:yt-focus disabled:cursor-not-allowed hover:border-4', context.invalid ? {
20
+ 'border-red-500 hover:border-red-700 aria-checked:bg-red-500 aria-checked:border-red-500 hover:aria-checked:border-red-700': !isDisabled,
21
+ 'border-red-500/50 aria-checked:bg-red-500/50 aria-checked:border-red-500/50': isDisabled
22
+ } : {
23
+ 'border-grey-500 hover:border-grey-700 aria-checked:bg-blue-500 aria-checked:border-blue-500 hover:aria-checked:border-blue-700': !isDisabled,
24
+ 'border-grey-500/50 aria-checked:bg-blue-500/50 aria-checked:border-blue-500/50': isDisabled
23
25
  });
24
26
  const labelClassName = cn('flex items-center gap-2', {
25
27
  'cursor-pointer': !isDisabled,
@@ -1 +1 @@
1
- {"version":3,"file":"RadioGroup.js","sources":["../../../../../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport { Orientation } from '../../types';\n\nexport type RadioGroupItemValue = string | number | boolean | null;\n\nexport const getRadioGroupItemValueAsString = (value: RadioGroupItemValue): string => String(value ?? '');\n\nexport const findByValue = (values: RadioGroupItemValue[], valueAsString: string): RadioGroupItemValue =>\n values.find(value => getRadioGroupItemValueAsString(value) === valueAsString) as RadioGroupItemValue;\n\nconst RadioGroupContext = React.createContext({ disabled: false, invalid: false });\n\nexport type RadioGroupItemProps<T = HTMLButtonElement> = Omit<\n React.ButtonHTMLAttributes<T>,\n 'children' | 'onSelect' | 'value'\n> & {\n /** Label for the radio group item */\n children: React.ReactNode;\n /* Whether the radio group item is disabled */\n disabled?: boolean;\n /** Value of the radio button */\n value: RadioGroupItemValue;\n};\n\nconst RadioGroupItem = React.forwardRef(function RadioGroupItem(props: RadioGroupItemProps, ref: React.Ref<HTMLButtonElement>) {\n const context = React.useContext(RadioGroupContext);\n const { children, value, ...otherProps } = props;\n\n const isDisabled = context.disabled || props.disabled;\n\n const className = cn(\n 'flex flex-shrink-0 self-start items-center justify-center h-4 w-4 mt-[0.2rem] rounded-full bg-white border-2',\n {\n 'border-grey-300 hover:border-4 focus:yt-focus aria-checked:bg-blue-500 aria-checked:border-blue-500 hover:aria-checked:border-blue-300':\n !isDisabled && !context.invalid,\n 'border-grey-200 cursor-not-allowed aria-checked:bg-blue-300 aria-checked:border-blue-300 ': isDisabled,\n 'border-red-500 hover:border-4 text-red-500 focus:border-red-500 focus:yt-focus-red aria-checked:bg-red-500 aria-checked:border-red':\n context.invalid && !isDisabled,\n }\n );\n const labelClassName = cn(\n 'flex items-center gap-2',\n {\n 'cursor-pointer': !isDisabled,\n 'cursor-not-allowed text-grey-300': isDisabled,\n },\n props.className\n );\n\n return (\n <label className={labelClassName}>\n <RadioGroupPrimitive.Item\n {...otherProps}\n className={className}\n disabled={isDisabled}\n ref={ref}\n value={getRadioGroupItemValueAsString(value)}>\n <RadioGroupPrimitive.Indicator className=\"h-2 w-2 rounded-full bg-white\" />\n </RadioGroupPrimitive.Item>\n {children}\n </label>\n );\n});\n\ntype ReactGroupBaseChild = React.ReactElement<RadioGroupItemProps> | boolean | null;\n\ntype RadioGroupBaseProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n children: ReactGroupBaseChild[];\n /* Whether the radio group is disabled */\n disabled?: boolean;\n /* Whether the radio group is in an invalid state */\n invalid?: boolean;\n /** The name of the radio group, used when submitting an HTML form */\n name?: string;\n /**\n * Orientation of the radio group\n * @defaultValue vertical\n */\n orientation?: Orientation;\n /* Whether the radio group requires user input */\n required?: boolean;\n};\n\ninterface UncontrolledRadioGroupProps extends RadioGroupBaseProps {\n /* The default value (uncontrolled) */\n defaultValue?: RadioGroupItemValue;\n onChange?: never;\n value?: never;\n}\n\ninterface ControlledRadioGroupProps extends RadioGroupBaseProps {\n defaultValue?: never;\n /** Handler called when the value changes */\n onChange: (value: RadioGroupItemValue) => void;\n /** The current value (controlled) */\n value?: RadioGroupItemValue;\n}\n\nexport type RadioGroupProps = UncontrolledRadioGroupProps | ControlledRadioGroupProps;\n\nexport type ForwardedRadioGroupWithStatics = React.ForwardRefExoticComponent<\n RadioGroupProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Item component rendered in a `RadioGroup` component */\n Item: React.ForwardRefExoticComponent<RadioGroupItemProps>;\n};\n\nexport const useRadioGroup = (props: RadioGroupProps) => {\n const { children, defaultValue, disabled, invalid, onChange, orientation = 'vertical', value, ...otherProps } = props;\n\n const values = React.useMemo<RadioGroupItemValue[]>(() => {\n const radioGroupItemValues: RadioGroupItemValue[] = [];\n\n React.Children.forEach(children, child => {\n if (React.isValidElement(child)) {\n radioGroupItemValues.push(child.props.value);\n }\n });\n\n return radioGroupItemValues;\n }, [children]);\n\n const context = React.useMemo(() => ({ disabled: disabled ?? false, invalid: invalid ?? false }), [disabled, invalid]);\n\n let valueProps;\n\n if (onChange !== undefined) {\n const handleChange = (value: string): void => onChange(findByValue(values, value));\n\n valueProps = {\n onValueChange: handleChange,\n value: value !== undefined ? getRadioGroupItemValueAsString(value) : undefined,\n };\n } else {\n valueProps = {\n defaultValue: defaultValue !== undefined ? getRadioGroupItemValueAsString(defaultValue) : undefined,\n };\n }\n\n return {\n context,\n props: {\n ...otherProps,\n ...valueProps,\n children,\n disabled,\n orientation,\n },\n };\n};\n\nexport const RadioGroup = React.forwardRef(function RadioGroup(props: RadioGroupProps, ref: React.Ref<HTMLDivElement>) {\n const { context, props: otherProps } = useRadioGroup(props);\n const className = cn(\n 'flex items-start gap-y-2',\n {\n 'flex-wrap gap-x-4 ': otherProps.orientation === 'horizontal',\n 'flex-col': otherProps.orientation === 'vertical',\n },\n otherProps.className\n );\n\n return (\n <RadioGroupContext.Provider value={context}>\n <RadioGroupPrimitive.Root {...otherProps} className={className} data-taco=\"radio-group\" ref={ref} />\n </RadioGroupContext.Provider>\n );\n}) as ForwardedRadioGroupWithStatics;\nRadioGroup.Item = RadioGroupItem;\n"],"names":["getRadioGroupItemValueAsString","value","String","findByValue","values","valueAsString","find","RadioGroupContext","React","disabled","invalid","RadioGroupItem","props","ref","context","children","otherProps","isDisabled","className","cn","labelClassName","RadioGroupPrimitive","useRadioGroup","defaultValue","onChange","orientation","radioGroupItemValues","forEach","child","push","valueProps","undefined","handleChange","onValueChange","RadioGroup","Provider","Item"],"mappings":";;;;MAOaA,8BAA8B,GAAIC,KAA0B,IAAaC,MAAM,CAACD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;MAE3FE,WAAW,GAAG,CAACC,MAA6B,EAAEC,aAAqB,KAC5ED,MA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,MAAM;IAAEC,OAAO;IAAEF,KAAK,EAAEI;GAAY,GAAGM,aAAa,CAACV,KAAK,CAAC;EAC3D,MAAMM,SAAS,GAAGC,EAAE,CAChB,0BAA0B,EAC1B;IACI,oBAAoB,EAAEH,UAAU,CAACS,WAAW,KAAK,YAAY;IAC7D,UAAU,EAAET,UAAU,CAACS,WAAW,KAAK;GAC1C,EACDT,UAAU,CAACE,SAAS,CACvB;EAED,oBACIV,cAACD,iBAAiB,CAAC4B,QAAQ;IAAClC,KAAK,EAAEa;kBAC/BN,cAACa,IAAwB,oBAAKL,UAAU;IAAEE,SAAS,EAAEA,SAAS;iBAAY,aAAa;IAACL,GAAG,EAAEA;KAAO,CAC3E;AAErC,CAAC;AACDqB,UAAU,CAACE,IAAI,GAAGzB,cAAc;;;;"}
1
+ {"version":3,"file":"RadioGroup.js","sources":["../../../../../../../src/components/RadioGroup/RadioGroup.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as RadioGroupPrimitive from '@radix-ui/react-radio-group';\nimport { Orientation } from '../../types';\n\nexport type RadioGroupItemValue = string | number | boolean | null;\n\nexport const getRadioGroupItemValueAsString = (value: RadioGroupItemValue): string => String(value ?? '');\n\nexport const findByValue = (values: RadioGroupItemValue[], valueAsString: string): RadioGroupItemValue =>\n values.find(value => getRadioGroupItemValueAsString(value) === valueAsString) as RadioGroupItemValue;\n\nconst RadioGroupContext = React.createContext({ disabled: false, invalid: false });\n\nexport type RadioGroupItemProps<T = HTMLButtonElement> = Omit<\n React.ButtonHTMLAttributes<T>,\n 'children' | 'onSelect' | 'value'\n> & {\n /** Label for the radio group item */\n children: React.ReactNode;\n /* Whether the radio group item is disabled */\n disabled?: boolean;\n /** Value of the radio button */\n value: RadioGroupItemValue;\n};\n\nconst RadioGroupItem = React.forwardRef(function RadioGroupItem(props: RadioGroupItemProps, ref: React.Ref<HTMLButtonElement>) {\n const context = React.useContext(RadioGroupContext);\n const { children, value, ...otherProps } = props;\n\n const isDisabled = context.disabled || props.disabled;\n\n const className = cn(\n 'flex flex-shrink-0 self-start items-center justify-center h-4 w-4 mt-[0.2rem] rounded-full bg-white border-2 focus-visible:yt-focus disabled:cursor-not-allowed hover:border-4',\n context.invalid\n ? {\n 'border-red-500 hover:border-red-700 aria-checked:bg-red-500 aria-checked:border-red-500 hover:aria-checked:border-red-700':\n !isDisabled,\n 'border-red-500/50 aria-checked:bg-red-500/50 aria-checked:border-red-500/50': isDisabled,\n }\n : {\n 'border-grey-500 hover:border-grey-700 aria-checked:bg-blue-500 aria-checked:border-blue-500 hover:aria-checked:border-blue-700':\n !isDisabled,\n 'border-grey-500/50 aria-checked:bg-blue-500/50 aria-checked:border-blue-500/50': isDisabled,\n }\n );\n const labelClassName = cn(\n 'flex items-center gap-2',\n {\n 'cursor-pointer': !isDisabled,\n 'cursor-not-allowed text-grey-300': isDisabled,\n },\n props.className\n );\n\n return (\n <label className={labelClassName}>\n <RadioGroupPrimitive.Item\n {...otherProps}\n className={className}\n disabled={isDisabled}\n ref={ref}\n value={getRadioGroupItemValueAsString(value)}>\n <RadioGroupPrimitive.Indicator className=\"h-2 w-2 rounded-full bg-white\" />\n </RadioGroupPrimitive.Item>\n {children}\n </label>\n );\n});\n\ntype ReactGroupBaseChild = React.ReactElement<RadioGroupItemProps> | boolean | null;\n\ntype RadioGroupBaseProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'defaultValue' | 'onChange' | 'value'> & {\n children: ReactGroupBaseChild[];\n /* Whether the radio group is disabled */\n disabled?: boolean;\n /* Whether the radio group is in an invalid state */\n invalid?: boolean;\n /** The name of the radio group, used when submitting an HTML form */\n name?: string;\n /**\n * Orientation of the radio group\n * @defaultValue vertical\n */\n orientation?: Orientation;\n /* Whether the radio group requires user input */\n required?: boolean;\n};\n\ninterface UncontrolledRadioGroupProps extends RadioGroupBaseProps {\n /* The default value (uncontrolled) */\n defaultValue?: RadioGroupItemValue;\n onChange?: never;\n value?: never;\n}\n\ninterface ControlledRadioGroupProps extends RadioGroupBaseProps {\n defaultValue?: never;\n /** Handler called when the value changes */\n onChange: (value: RadioGroupItemValue) => void;\n /** The current value (controlled) */\n value?: RadioGroupItemValue;\n}\n\nexport type RadioGroupProps = UncontrolledRadioGroupProps | ControlledRadioGroupProps;\n\nexport type ForwardedRadioGroupWithStatics = React.ForwardRefExoticComponent<\n RadioGroupProps & React.RefAttributes<HTMLDivElement>\n> & {\n /** Item component rendered in a `RadioGroup` component */\n Item: React.ForwardRefExoticComponent<RadioGroupItemProps>;\n};\n\nexport const useRadioGroup = (props: RadioGroupProps) => {\n const { children, defaultValue, disabled, invalid, onChange, orientation = 'vertical', value, ...otherProps } = props;\n\n const values = React.useMemo<RadioGroupItemValue[]>(() => {\n const radioGroupItemValues: RadioGroupItemValue[] = [];\n\n React.Children.forEach(children, child => {\n if (React.isValidElement(child)) {\n radioGroupItemValues.push(child.props.value);\n }\n });\n\n return radioGroupItemValues;\n }, [children]);\n\n const context = React.useMemo(() => ({ disabled: disabled ?? false, invalid: invalid ?? false }), [disabled, invalid]);\n\n let valueProps;\n\n if (onChange !== undefined) {\n const handleChange = (value: string): void => onChange(findByValue(values, value));\n\n valueProps = {\n onValueChange: handleChange,\n value: value !== undefined ? getRadioGroupItemValueAsString(value) : undefined,\n };\n } else {\n valueProps = {\n defaultValue: defaultValue !== undefined ? getRadioGroupItemValueAsString(defaultValue) : undefined,\n };\n }\n\n return {\n context,\n props: {\n ...otherProps,\n ...valueProps,\n children,\n disabled,\n orientation,\n },\n };\n};\n\nexport const RadioGroup = React.forwardRef(function RadioGroup(props: RadioGroupProps, ref: React.Ref<HTMLDivElement>) {\n const { context, props: otherProps } = useRadioGroup(props);\n const className = cn(\n 'flex items-start gap-y-2',\n {\n 'flex-wrap gap-x-4 ': otherProps.orientation === 'horizontal',\n 'flex-col': otherProps.orientation === 'vertical',\n },\n otherProps.className\n );\n\n return (\n <RadioGroupContext.Provider value={context}>\n <RadioGroupPrimitive.Root {...otherProps} className={className} data-taco=\"radio-group\" ref={ref} />\n </RadioGroupContext.Provider>\n );\n}) as ForwardedRadioGroupWithStatics;\nRadioGroup.Item = RadioGroupItem;\n"],"names":["getRadioGroupItemValueAsString","value","String","findByValue","values","valueAsString","find","RadioGroupContext","React","disabled","invalid","RadioGroupItem","props","ref","context","children","otherProps","isDisabled","className","cn","labelClassName","RadioGroupPrimitive","useRadioGroup","defaultValue","onChange","orientation","radioGroupItemValues","forEach","child","push","valueProps","undefined","handleChange","onValueChange","RadioGroup","Provider","Item"],"mappings":";;;;MAOaA,8BAA8B,GAAIC,KAA0B,IAAaC,MAAM,CAACD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE;MAE3FE,WAAW,GAAG,CAACC,MAA6B,EAAEC,aAAqB,KAC5ED,MAAM,CAACE,IAAI,CAACL,KAAK,IAAID,8BAA8B,CAACC,KAAK,CAAC,KAAKI,aAAa;AAEhF,MAAME,iBAAiB,gBAAGC,aAAmB,CAAC;EAAEC,QAAQ,EAAE,KAAK;EAAEC,OAAO,EAAE;CAAO,CAAC;AAclF,MAAMC,cAAc,gBAAGH,UAAgB,CAAC,SAASG,cAAc,CAACC,KAA0B,EAAEC,GAAiC;EACzH,MAAMC,OAAO,GAAGN,UAAgB,CAACD,iBAAiB,CAAC;EACnD,MAAM;IAAEQ,QAAQ;IAAEd,KAAK;IAAE,GAAGe;GAAY,GAAGJ,KAAK;EAEhD,MAAMK,UAAU,GAAGH,OAAO,CAACL,QAAQ,IAAIG,KAAK,CAACH,QAAQ;EAErD,MAAMS,SAAS,GAAGC,EAAE,CAChB,gLAAgL,EAChLL,OAAO,CAACJ,OAAO,GACT;IACI,2HAA2H,EACvH,CAACO,UAAU;IACf,6EAA6E,EAAEA;GAClF,GACD;IACI,gIAAgI,EAC5H,CAACA,UAAU;IACf,gFAAgF,EAAEA;GACrF,CACV;EACD,MAAMG,cAAc,GAAGD,EAAE,CACrB,yBAAyB,EACzB;IACI,gBAAgB,EAAE,CAACF,UAAU;IAC7B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CAAC;IAElF6B,UAAU,GAAG;MACTG,aAAa,EAAED,YAAY;MAC3B/B,KAAK,EAAEA,KAAK,KAAK8B,SAAS,GAAG/B,8BAA8B,CAACC,KAAK,CAAC,GAAG8B;KACxE;GACJ,MAAM;IACHD,UAAU,GAAG;MACTP,YAAY,EAAEA,YAAY,KAAKQ,SAAS,GAAG/B,8BAA8B,CAACuB,YAAY,CAAC,GAAGQ;KAC7F;;EAGL,OAAO;IACHjB,OAAO;IACPF,KAAK,EAAE;MACH,GAAGI,UAAU;MACb,GAAGc,UAAU;MACbf,QAAQ;MACRN,QAAQ;MACRgB;;GAEP;AACL;MAEaS,UAAU,gBAAG1B,UAAgB,CAAC,SAAS0B,UAAU,CAACtB,KAAsB,EAAEC,GAA8B;EACjH,MAAM;IAAEC,OAAO;IAAEF,KAAK,EAAEI;GAAY,GAAGM,aAAa,CAACV,KAAK,CAAC;EAC3D,MAAMM,SAAS,GAAGC,EAAE,CAChB,0BAA0B,EAC1B;IACI,oBAAoB,EAAEH,UAAU,CAACS,WAAW,KAAK,YAAY;IAC7D,UAAU,EAAET,UAAU,CAACS,WAAW,KAAK;GAC1C,EACDT,UAAU,CAACE,SAAS,CACvB;EAED,oBACIV,cAACD,iBAAiB,CAAC4B,QAAQ;IAAClC,KAAK,EAAEa;kBAC/BN,cAACa,IAAwB,oBAAKL,UAAU;IAAEE,SAAS,EAAEA,SAAS;iBAAY,aAAa;IAACL,GAAG,EAAEA;KAAO,CAC3E;AAErC,CAAC;AACDqB,UAAU,CAACE,IAAI,GAAGzB,cAAc;;;;"}
@@ -1,5 +1,6 @@
1
1
  import React__default from 'react';
2
2
  import cn from 'classnames';
3
+ import { AVAILABLE_COLORS } from '../../../utils/tailwind.js';
3
4
  import { useLocalization } from '../../Provider/Localization.js';
4
5
  import { isAriaSelectionKey } from '../../../utils/aria.js';
5
6
  import { Tag } from '../../Tag/Tag.js';
@@ -8,15 +9,22 @@ import { useSelect2Context } from './Context.js';
8
9
  import { _catch } from '../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
9
10
 
10
11
  const getNextColor = options => {
11
- const occurences = options.reduce((occurences, option) => {
12
+ let occurrences = {};
13
+ AVAILABLE_COLORS.filter(color => color !== 'transparent').forEach(color => {
14
+ occurrences = {
15
+ ...occurrences,
16
+ [color]: 0
17
+ };
18
+ });
19
+ options.reduce((occurrences, option) => {
12
20
  if (option.props.color) {
13
- occurences[option.props.color] = occurences[option.props.color] ? occurences[option.props.color] + 1 : 1;
21
+ occurrences[option.props.color] = occurrences[option.props.color] ? occurrences[option.props.color] + 1 : 1;
14
22
  }
15
- return occurences;
16
- }, {});
17
- const colors = Object.keys(occurences);
23
+ return occurrences;
24
+ }, occurrences);
25
+ const colors = Object.keys(occurrences);
18
26
  if (colors.length) {
19
- return colors.sort((a, b) => occurences[a] - occurences[b])[0];
27
+ return colors.sort((a, b) => occurrences[a] - occurrences[b])[0];
20
28
  }
21
29
  return undefined;
22
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Create.js","sources":["../../../../../../../../src/components/Select2/components/Create.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { isAriaSelectionKey } from '../../../utils/aria';\nimport { Tag } from '../../Tag/Tag';\nimport { createOptionClassName } from '../utilities';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { useLocalization } from '../../Provider/Localization';\nimport { Color } from '../../../types';\n\nexport type CreateProps = {\n onCreate: (name: string, color: Color | undefined) => Promise<Select2OptionProps>;\n options: React.ReactElement<Select2OptionProps>[];\n};\n\nexport const getNextColor = (options: React.ReactElement<Select2OptionProps>[]): Color | undefined => {\n const occurences = options.reduce((occurences, option) => {\n if (option.props.color) {\n occurences[option.props.color] = occurences[option.props.color] ? occurences[option.props.color] + 1 : 1;\n }\n return occurences;\n }, {});\n\n const colors = Object.keys(occurences);\n\n if (colors.length) {\n return colors.sort((a, b) => occurences[a] - occurences[b])[0] as Color;\n }\n\n return undefined;\n};\n\nexport const Create = (props: CreateProps) => {\n const { onCreate: handleCreate, options } = props;\n const { multiple, searchQuery, setOpen, setSearchQuery, setValidationError, setValue } = useSelect2Context();\n const { texts } = useLocalization();\n\n // determine what the next color tag should be based on color occurences\n const nextColor = React.useMemo(() => getNextColor(options), [options]);\n\n if (!searchQuery) {\n return null;\n }\n\n const handleClick = async () => {\n try {\n const item = await handleCreate(searchQuery, nextColor);\n setValue(item.value);\n\n if (multiple) {\n setSearchQuery('');\n } else {\n setOpen(false);\n }\n } catch (error) {\n setValidationError(error as Error);\n }\n };\n\n const handleKeyDown = event => {\n if (isAriaSelectionKey(event)) {\n event.currentTarget.click();\n }\n };\n\n const className = cn('!w-[calc(100%_-_theme(spacing.3))] ml-1.5', createOptionClassName());\n return (\n <button className={className} onClick={handleClick} onKeyDown={handleKeyDown}>\n <span className=\"flex items-center gap-1.5\">\n {texts.select2.create}\n <Tag color={nextColor} className=\"cursor-pointer\">\n {searchQuery}\n </Tag>\n </span>\n </button>\n );\n};\n"],"names":["getNextColor","options","occurences","reduce","option","props","color","colors","Object","keys","length","sort","a","b","undefined","Create","onCreate","handleCreate","multiple","searchQuery","setOpen","setSearchQuery","setValidationError","setValue","useSelect2Context","texts","useLocalization","nextColor","React","useMemo","handleClick","item","value","error","handleKeyDown","event","isAriaSelectionKey","currentTarget","click","className","cn","createOptionClassName","onClick","onKeyDown","select2","create","Tag"],"mappings":";;;;;;;;;MAeaA,YAAY,GAAIC,OAAiD;EAC1E,MAAMC,UAAU,GAAGD,OAAO,CAACE,MAAM,CAAC,CAACD,UAAU,EAAEE,MAAM;IACjD,IAAIA,MAAM,CAACC,KAAK,CAACC,KAAK,EAAE;MACpBJ,UAAU,CAACE,MAAM,CAACC,KAAK,CAACC,KAAK,CAAC,GAAGJ,UAAU,CAACE,MAAM,CAACC,KAAK,CAACC,KAAK,CAAC,GAAGJ,UAAU,CAACE,MAAM,CAACC,KAAK,CAACC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;;IA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,EAAEC,qBAAqB,EAAE,CAAC;EAC1F,oBACIb;IAAQW,SAAS,EAAEA,SAAS;IAAEG,OAAO,EAAEZ,WAAW;IAAEa,SAAS,EAAET;kBAC3DN;IAAMW,SAAS,EAAC;KACXd,KAAK,CAACmB,OAAO,CAACC,MAAM,eACrBjB,6BAACkB,GAAG;IAACxC,KAAK,EAAEqB,SAAS;IAAEY,SAAS,EAAC;KAC5BpB,WAAW,CACV,CACH,CACF;AAEjB;;;;"}
1
+ {"version":3,"file":"Create.js","sources":["../../../../../../../../src/components/Select2/components/Create.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { isAriaSelectionKey } from '../../../utils/aria';\nimport { Tag } from '../../Tag/Tag';\nimport { createOptionClassName } from '../utilities';\nimport { useSelect2Context } from './Context';\nimport { Select2OptionProps } from './Option';\nimport { useLocalization } from '../../Provider/Localization';\nimport { Color } from '../../../types';\nimport { AVAILABLE_COLORS } from '../../../utils/tailwind';\n\nexport type CreateProps = {\n onCreate: (name: string, color: Color | undefined) => Promise<Select2OptionProps>;\n options: React.ReactElement<Select2OptionProps>[];\n};\n\nexport const getNextColor = (options: React.ReactElement<Select2OptionProps>[]): Color | undefined => {\n let occurrences = {};\n AVAILABLE_COLORS.filter(color => color !== 'transparent').forEach((color: Color) => {\n occurrences = { ...occurrences, [color]: 0 };\n });\n\n options.reduce((occurrences, option) => {\n if (option.props.color) {\n occurrences[option.props.color] = occurrences[option.props.color] ? occurrences[option.props.color] + 1 : 1;\n }\n return occurrences;\n }, occurrences);\n\n const colors = Object.keys(occurrences);\n\n if (colors.length) {\n return colors.sort((a, b) => occurrences[a] - occurrences[b])[0] as Color;\n }\n\n return undefined;\n};\n\nexport const Create = (props: CreateProps) => {\n const { onCreate: handleCreate, options } = props;\n const { multiple, searchQuery, setOpen, setSearchQuery, setValidationError, setValue } = useSelect2Context();\n const { texts } = useLocalization();\n\n // determine what the next color tag should be based on color occurences\n const nextColor = React.useMemo(() => getNextColor(options), [options]);\n\n if (!searchQuery) {\n return null;\n }\n\n const handleClick = async () => {\n try {\n const item = await handleCreate(searchQuery, nextColor);\n setValue(item.value);\n\n if (multiple) {\n setSearchQuery('');\n } else {\n setOpen(false);\n }\n } catch (error) {\n setValidationError(error as Error);\n }\n };\n\n const handleKeyDown = event => {\n if (isAriaSelectionKey(event)) {\n event.currentTarget.click();\n }\n };\n\n const className = cn('!w-[calc(100%_-_theme(spacing.3))] ml-1.5', createOptionClassName());\n return (\n <button className={className} onClick={handleClick} onKeyDown={handleKeyDown}>\n <span className=\"flex items-center gap-1.5\">\n {texts.select2.create}\n <Tag color={nextColor} className=\"cursor-pointer\">\n {searchQuery}\n </Tag>\n </span>\n </button>\n );\n};\n"],"names":["getNextColor","options","occurrences","AVAILABLE_COLORS","filter","color","forEach","reduce","option","props","colors","Object","keys","length","sort","a","b","undefined","Create","onCreate","handleCreate","multiple","searchQuery","setOpen","setSearchQuery","setValidationError","setValue","useSelect2Context","texts","useLocalization","nextColor","React","useMemo","handleClick","item","value","error","handleKeyDown","event","isAriaSelectionKey","currentTarget","click","className","cn","createOptionClassName","onClick","onKeyDown","select2","create","Tag"],"mappings":";;;;;;;;;;MAgBaA,YAAY,GAAIC,OAAiD;EAC1E,IAAIC,WAAW,GAAG,EAAE;EACpBC,gBAAgB,CAACC,MAAM,CAACC,KAAK,IAAIA,KAAK,KAAK,aAAa,CAAC,CAACC,OAAO,CAAED,KAAY;IAC3EH,WAAW,GAAG;MAAE,GAAGA,WAAW;MAAE,CAACG,KAAK,GAAG;KAAG;GAC/C,CAAC;EAEFJ,OAAO,CAACM,MAAM,CAAC,CAACL,WAAW,EAAEM,MAAM;IAC/B,IAAIA,MAAM,CAACC,KAAK,CAACJ,KAAK,EAAE;MACpBH,WAAW,CAACM,MAAM,CAACC,KAAK,CAACJ,KAAK,CAAC,GAAGH,WAAW,CAACM,MAAM,CAACC,KAAK,CAACJ,KAAK,CAAC,GAAGH,WAAW,CAACM,MAAM,CAACC,KAAK,CAACJ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;EAED,MAAMC,SAAS,GAAGC,EAAE,CAAC,2CAA2C,EAAEC,qBAAqB,EAAE,CAAC;EAC1F,oBACIb;IAAQW,SAAS,EAAEA,SAAS;IAAEG,OAAO,EAAEZ,WAAW;IAAEa,SAAS,EAAET;kBAC3DN;IAAMW,SAAS,EAAC;KACXd,KAAK,CAACmB,OAAO,CAACC,MAAM,eACrBjB,6BAACkB,GAAG;IAAC5C,KAAK,EAAEyB,SAAS;IAAEY,SAAS,EAAC;KAC5BpB,WAAW,CACV,CACH,CACF;AAEjB;;;;"}
@@ -81,10 +81,9 @@ const Option = /*#__PURE__*/React__default.forwardRef(function Select2Option(pro
81
81
  }, /*#__PURE__*/React__default.createElement("span", null, children), description ? /*#__PURE__*/React__default.createElement("span", {
82
82
  className: "text-grey-700 -mt-1.5 mb-1.5 text-xs"
83
83
  }, description) : null)), popover ? /*#__PURE__*/React__default.createElement(IconButton, {
84
- rounded: true,
85
84
  icon: "ellipsis-vertical",
86
85
  appearance: "discrete",
87
- className: cn('group-aria-current:visible invisible ml-auto -mr-2 focus:!shadow-none group-hover:visible', {
86
+ className: cn('group-aria-current:visible invisible -mr-1 ml-auto !h-5 min-h-[theme(spacing.6)] !w-5 min-w-[theme(spacing.6)] hover:!bg-black/[.08] focus:!shadow-none group-hover:visible', {
88
87
  '!visible': isMobileDevice((_window = window) === null || _window === void 0 ? void 0 : _window.navigator)
89
88
  }),
90
89
  onClick: event => {
@@ -1 +1 @@
1
- {"version":3,"file":"Option.js","sources":["../../../../../../../../src/components/Select2/components/Option.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Icon, IconName, IconProps } from '../../Icon/Icon';\nimport { Tag } from '../../Tag/Tag';\nimport { isAriaSelectionKey } from '../../../utils/aria';\nimport * as ListboxPrimitive from '../../../primitives/Listbox2/Listbox2';\nimport { createOptionClassName } from '../utilities';\nimport { useSelect2Context } from './Context';\nimport { IconButton } from '../../IconButton/IconButton';\nimport { EditPopover } from './Edit';\nimport { isMobileDevice } from '../../../utils/device';\nimport { Color } from '../../../types';\n\nexport type Select2OptionProps = Omit<ListboxPrimitive.Listbox2OptionProps, 'children'> & {\n children: string;\n color?: Color;\n description?: string;\n icon?: React.ReactElement<IconProps> | IconName;\n textValue?: string;\n};\n\nexport const Option = React.forwardRef<HTMLDivElement, Select2OptionProps>(function Select2Option(props, ref) {\n const { children, color, description, icon, className: cName, ...otherProps } = props;\n const {\n onDelete,\n onEdit,\n listboxRef,\n multiple,\n ref: selectRef,\n setOpen,\n shouldPauseHoverState,\n tags,\n value,\n } = useSelect2Context();\n const className = cn(createOptionClassName(shouldPauseHoverState), cName);\n\n const hasValue = Array.isArray(value) ? !!value.length : value !== undefined;\n const isTag = tags && !!color;\n\n const handleClick = () => {\n if (!multiple) {\n setOpen(false);\n } else {\n selectRef.current?.focus();\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (isAriaSelectionKey(event)) {\n if (!multiple || event.key === 'Tab') {\n setOpen(false);\n }\n }\n };\n\n const isEmptyOption = children !== '';\n\n const popover =\n isEmptyOption && (onEdit || onDelete)\n ? popoverProps => (\n <EditPopover\n {...popoverProps}\n color={props.color}\n key={props.textValue ?? String(props.children)}\n text={props.textValue ?? String(props.children)}\n value={props.value}\n />\n )\n : undefined;\n\n return (\n <ListboxPrimitive.Option {...otherProps} className={className} onClick={handleClick} onKeyDown={handleKeyDown} ref={ref}>\n {hasValue ? (\n <Icon name=\"tick\" className=\"pointer-events-none invisible -mx-0.5 !h-4 !w-4 group-aria-selected:visible\" />\n ) : null}\n\n {isTag ? (\n <Tag className=\"pointer-events-none my-1\" color={color} icon={icon}>\n {children}\n </Tag>\n ) : (\n <>\n {icon ? typeof icon === 'string' ? <Icon name={icon} /> : icon : null}\n <span className=\"flex flex-col\">\n <span>{children}</span>\n {description ? <span className=\"text-grey-700 -mt-1.5 mb-1.5 text-xs\">{description}</span> : null}\n </span>\n </>\n )}\n {popover ? (\n <IconButton\n rounded\n icon=\"ellipsis-vertical\"\n appearance=\"discrete\"\n className={cn('group-aria-current:visible invisible ml-auto -mr-2 focus:!shadow-none group-hover:visible', {\n '!visible': isMobileDevice(window?.navigator),\n })}\n onClick={event => {\n event.stopPropagation();\n listboxRef?.current?.setActiveIndex(event.currentTarget.parentElement as HTMLDivElement);\n }}\n popover={popover}\n tabIndex={-1}\n />\n ) : null}\n </ListboxPrimitive.Option>\n );\n});\n"],"names":["Option","React","forwardRef","Select2Option","props","ref","children","color","description","icon","className","cName","otherProps","onDelete","onEdit","listboxRef","multiple","selectRef","setOpen","shouldPauseHoverState","tags","value","useSelect2Context","cn","createOptionClassName","hasValue","Array","isArray","length","undefined","isTag","handleClick","current","focus","handleKeyDown","event","isAriaSelectionKey","key","isEmptyOption","popover","popoverProps","EditPopover","textValue","String","text","ListboxPrimitive","onClick","onKeyDown","Icon","name","Tag","IconButton","rounded","appearance","isMobileDevice","window","navigator","stopPropagation","setActiveIndex","currentTarget","parentElement","tabIndex"],"mappings":";;;;;;;;;;;;;;;MAqBaA,MAAM,gBAAGC,cAAK,CAACC,UAAU,CAAqC,SAASC,aAAa,CAACC,KAAK,EAAEC,GAAG;;EACxG,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,WAAW;IAAEC,IAAI;IAAEC,SAAS,EAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGR,KAAK;EACrF,MAAM;IACFS,QAAQ;IACRC,MAAM;IACNC,UAAU;IACVC,QAAQ;IACRX,GAAG,EAAEY,SAAS;IACdC,OAAO;IACPC,qBAAqB;IACrBC,IAAI;IACJC;GACH,GAAGC,iBAAiB,EAAE;EACvB,MAAMZ,SAAS,GAAGa,EAAE,CAACC,qBAAqB,CAACL,qBAAqB,CAAC,EAAER,KAAK,CAAC;EAEzE,MAAMc,QAAQ,GAAGC,KAAK,CAACC,OAAO,CAACN,KAAK,CAAC,GAAG,CAAC,CAACA,KAAK,CAACO,MAAM,GAAGP,KAAK,KAAKQ,SAAS;EAC5E,MAAMC,KA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A;KACzDH,QAAQ,CACP,gBAENL,4DACKQ,IAAI,GAAG,OAAOA,IAAI,KAAK,QAAQ,gBAAGR,6BAAC+C,IAAI;IAACC,IAAI,EAAExC;IAAQ,GAAGA,IAAI,GAAG,IAAI,eACrER;IAAMS,SAAS,EAAC;kBACZT,2CAAOK,QAAQ,CAAQ,EACtBE,WAAW,gBAAGP;IAAMS,SAAS,EAAC;KAAwCF,WAAW,CAAQ,GAAG,IAAI,CAC9F,CAEd,EACA+B,OAAO,gBACJtC,6BAACkD,UAAU;IACPC,OAAO;IACP3C,IAAI,EAAC,mBAAmB;IACxB4C,UAAU,EAAC,UAAU;IACrB3C,SAAS,EAAEa,EAAE,CAAC,2FAA2F,EAAE;MACvG,UAAU,EAAE+B,cAAc,YAACC,MAAM,4CAAN,QAAQC,SAAS;KAC/C,CAAC;IACFV,OAAO,EAAEX,KAAK;;MACVA,KAAK,CAACsB,eAAe,EAAE;MACvB1C,UAAU,aAAVA,UAAU,8CAAVA,UAAU,CAAEiB,OAAO,wDAAnB,oBAAqB0B,cAAc,CAACvB,KAAK,CAACwB,aAAa,CAACC,aAA+B,CAAC;KAC3F;IACDrB,OAAO,EAAEA,OAAO;IAChBsB,QAAQ,EAAE,CAAC;IACb,GACF,IAAI,CACc;AAElC,CAAC;;;;"}
1
+ {"version":3,"file":"Option.js","sources":["../../../../../../../../src/components/Select2/components/Option.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { Icon, IconName, IconProps } from '../../Icon/Icon';\nimport { Tag } from '../../Tag/Tag';\nimport { isAriaSelectionKey } from '../../../utils/aria';\nimport * as ListboxPrimitive from '../../../primitives/Listbox2/Listbox2';\nimport { createOptionClassName } from '../utilities';\nimport { useSelect2Context } from './Context';\nimport { IconButton } from '../../IconButton/IconButton';\nimport { EditPopover } from './Edit';\nimport { isMobileDevice } from '../../../utils/device';\nimport { Color } from '../../../types';\n\nexport type Select2OptionProps = Omit<ListboxPrimitive.Listbox2OptionProps, 'children'> & {\n children: string;\n color?: Color;\n description?: string;\n icon?: React.ReactElement<IconProps> | IconName;\n textValue?: string;\n};\n\nexport const Option = React.forwardRef<HTMLDivElement, Select2OptionProps>(function Select2Option(props, ref) {\n const { children, color, description, icon, className: cName, ...otherProps } = props;\n const {\n onDelete,\n onEdit,\n listboxRef,\n multiple,\n ref: selectRef,\n setOpen,\n shouldPauseHoverState,\n tags,\n value,\n } = useSelect2Context();\n const className = cn(createOptionClassName(shouldPauseHoverState), cName);\n\n const hasValue = Array.isArray(value) ? !!value.length : value !== undefined;\n const isTag = tags && !!color;\n\n const handleClick = () => {\n if (!multiple) {\n setOpen(false);\n } else {\n selectRef.current?.focus();\n }\n };\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (isAriaSelectionKey(event)) {\n if (!multiple || event.key === 'Tab') {\n setOpen(false);\n }\n }\n };\n\n const isEmptyOption = children !== '';\n\n const popover =\n isEmptyOption && (onEdit || onDelete)\n ? popoverProps => (\n <EditPopover\n {...popoverProps}\n color={props.color}\n key={props.textValue ?? String(props.children)}\n text={props.textValue ?? String(props.children)}\n value={props.value}\n />\n )\n : undefined;\n\n return (\n <ListboxPrimitive.Option {...otherProps} className={className} onClick={handleClick} onKeyDown={handleKeyDown} ref={ref}>\n {hasValue ? (\n <Icon name=\"tick\" className=\"pointer-events-none invisible -mx-0.5 !h-4 !w-4 group-aria-selected:visible\" />\n ) : null}\n\n {isTag ? (\n <Tag className=\"pointer-events-none my-1\" color={color} icon={icon}>\n {children}\n </Tag>\n ) : (\n <>\n {icon ? typeof icon === 'string' ? <Icon name={icon} /> : icon : null}\n <span className=\"flex flex-col\">\n <span>{children}</span>\n {description ? <span className=\"text-grey-700 -mt-1.5 mb-1.5 text-xs\">{description}</span> : null}\n </span>\n </>\n )}\n {popover ? (\n <IconButton\n icon=\"ellipsis-vertical\"\n appearance=\"discrete\"\n className={cn(\n 'group-aria-current:visible invisible -mr-1 ml-auto !h-5 min-h-[theme(spacing.6)] !w-5 min-w-[theme(spacing.6)] hover:!bg-black/[.08] focus:!shadow-none group-hover:visible',\n {\n '!visible': isMobileDevice(window?.navigator),\n }\n )}\n onClick={event => {\n event.stopPropagation();\n listboxRef?.current?.setActiveIndex(event.currentTarget.parentElement as HTMLDivElement);\n }}\n popover={popover}\n tabIndex={-1}\n />\n ) : null}\n </ListboxPrimitive.Option>\n );\n});\n"],"names":["Option","React","forwardRef","Select2Option","props","ref","children","color","description","icon","className","cName","otherProps","onDelete","onEdit","listboxRef","multiple","selectRef","setOpen","shouldPauseHoverState","tags","value","useSelect2Context","cn","createOptionClassName","hasValue","Array","isArray","length","undefined","isTag","handleClick","current","focus","handleKeyDown","event","isAriaSelectionKey","key","isEmptyOption","popover","popoverProps","EditPopover","textValue","String","text","ListboxPrimitive","onClick","onKeyDown","Icon","name","Tag","IconButton","appearance","isMobileDevice","window","navigator","stopPropagation","setActiveIndex","currentTarget","parentElement","tabIndex"],"mappings":";;;;;;;;;;;;;;;MAqBaA,MAAM,gBAAGC,cAAK,CAACC,UAAU,CAAqC,SAASC,aAAa,CAACC,KAAK,EAAEC,GAAG;;EACxG,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,WAAW;IAAEC,IAAI;IAAEC,SAAS,EAAEC,KAAK;IAAE,GAAGC;GAAY,GAAGR,KAAK;EACrF,MAAM;IACFS,QAAQ;IACRC,MAAM;IACNC,UAAU;IACVC,QAAQ;IACRX,GAAG,EAAEY,SAAS;IACdC,OAAO;IACPC,qBAAqB;IACrBC,IAAI;IACJC;GACH,GAAGC,iBAAiB,EAAE;EACvB,MAAMZ,SAAS,GAAGa,EAAE,CAACC,qBAAqB,CAACL,qBAAqB,CAAC,EAAER,KAAK,CAAC;EAEzE,MAAMc,QAAQ,GAAGC,KAAK,CAACC,OAAO,CAACN,KAAK,CAAC,GAAG,CAAC,CAACA,KAAK,CAACO,MAAM,GAAGP,KAAK,KAAKQ,SAAS;EAC5E,MAAMC,KAAK,GAAGV,IAAI,IAAI,CAAC,CAACb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Q,IAAI,GAAG,OAAOA,IAAI,KAAK,QAAQ,gBAAGR,6BAAC+C,IAAI;IAACC,IAAI,EAAExC;IAAQ,GAAGA,IAAI,GAAG,IAAI,eACrER;IAAMS,SAAS,EAAC;kBACZT,2CAAOK,QAAQ,CAAQ,EACtBE,WAAW,gBAAGP;IAAMS,SAAS,EAAC;KAAwCF,WAAW,CAAQ,GAAG,IAAI,CAC9F,CAEd,EACA+B,OAAO,gBACJtC,6BAACkD,UAAU;IACP1C,IAAI,EAAC,mBAAmB;IACxB2C,UAAU,EAAC,UAAU;IACrB1C,SAAS,EAAEa,EAAE,CACT,6KAA6K,EAC7K;MACI,UAAU,EAAE8B,cAAc,YAACC,MAAM,4CAAN,QAAQC,SAAS;KAC/C,CACJ;IACDT,OAAO,EAAEX,KAAK;;MACVA,KAAK,CAACqB,eAAe,EAAE;MACvBzC,UAAU,aAAVA,UAAU,8CAAVA,UAAU,CAAEiB,OAAO,wDAAnB,oBAAqByB,cAAc,CAACtB,KAAK,CAACuB,aAAa,CAACC,aAA+B,CAAC;KAC3F;IACDpB,OAAO,EAAEA,OAAO;IAChBqB,QAAQ,EAAE,CAAC;IACb,GACF,IAAI,CACc;AAElC,CAAC;;;;"}
@@ -10,10 +10,10 @@ const Switch = /*#__PURE__*/forwardRef(function Switch(props, ref) {
10
10
  ...otherProps
11
11
  } = props;
12
12
  const id = useId(props.id);
13
- const className = cn('group h-5 w-9 flex flex-shrink-0 rounded-full inline-flex', {
13
+ const className = cn('group h-5 w-9 flex flex-shrink-0 rounded-full inline-flex focus-visible:yt-focus', {
14
14
  'mr-2': !!label,
15
- 'bg-grey-500 hover:bg-grey-300 aria-checked:bg-blue-500 aria-checked:hover:bg-blue-300 focus:yt-focus': !props.disabled,
16
- 'bg-grey-100 cursor-not-allowed aria-checked:bg-blue-300': props.disabled
15
+ 'bg-grey-500 hover:bg-grey-700 aria-checked:bg-blue-500 aria-checked:hover:bg-blue-700': !props.disabled,
16
+ 'bg-grey-500/50 aria-checked:bg-blue-500/50 cursor-not-allowed': props.disabled
17
17
  }, props.className);
18
18
  let labelledByProps = null;
19
19
  if (label) {
@@ -1 +1 @@
1
- {"version":3,"file":"Switch.js","sources":["../../../../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PrimitiveSwitch from '@radix-ui/react-switch';\nimport { useId } from '../../hooks/useId';\n\ntype SwitchBaseProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onChange'> & {\n /** Label for the switch */\n label?: React.ReactNode;\n /* Whether user input is required */\n required?: boolean;\n};\n\ninterface UncontrolledSwitchProps extends SwitchBaseProps {\n checked?: never;\n onChange?: never;\n /* The default checked state (uncontrolled) */\n defaultChecked?: boolean;\n}\n\ninterface ControlledSwitchProps extends SwitchBaseProps {\n defaultChecked?: never;\n /* The current checked state (controlled) */\n checked: boolean;\n /* Handler called when the checked state changes */\n onChange: (checked: boolean) => void;\n}\n\nexport type SwitchProps = UncontrolledSwitchProps | ControlledSwitchProps;\n\nexport const Switch = React.forwardRef(function Switch(props: SwitchProps, ref: React.Ref<HTMLButtonElement>) {\n const { label, onChange, ...otherProps } = props;\n const id = useId(props.id);\n\n const className = cn(\n 'group h-5 w-9 flex flex-shrink-0 rounded-full inline-flex',\n {\n 'mr-2': !!label,\n 'bg-grey-500 hover:bg-grey-300 aria-checked:bg-blue-500 aria-checked:hover:bg-blue-300 focus:yt-focus':\n !props.disabled,\n 'bg-grey-100 cursor-not-allowed aria-checked:bg-blue-300': props.disabled,\n },\n props.className\n );\n\n let labelledByProps: Record<string, string> | null = null;\n\n if (label) {\n labelledByProps = {\n 'aria-labelledby': `${id}-label`,\n id,\n };\n }\n\n const element = (\n <PrimitiveSwitch.Root {...otherProps} {...labelledByProps} className={className} onCheckedChange={onChange} ref={ref}>\n <PrimitiveSwitch.Thumb className=\"'will-change-transform mt-0.5 h-4 w-4 translate-x-[0.15rem] rounded-full bg-white transition-transform group-disabled:opacity-50 group-aria-checked:translate-x-[1.1rem]\" />\n </PrimitiveSwitch.Root>\n );\n\n if (label) {\n const labelContainerClassName = cn('flex self-start cursor-pointer', {\n 'cursor-not-allowed text-grey-300': props.disabled,\n });\n\n return (\n <span className={labelContainerClassName}>\n {element}\n <label htmlFor={id} id={`${id}-label`}>\n {label}\n </label>\n </span>\n );\n }\n\n return element;\n});\nSwitch.displayName = 'Switch';\n"],"names":["Switch","React","props","ref","label","onChange","otherProps","id","useId","className","cn","disabled","labelledByProps","element","PrimitiveSwitch","onCheckedChange","labelContainerClassName","htmlFor","displayName"],"mappings":";;;;;MA6BaA,MAAM,gBAAGC,UAAgB,CAAC,SAASD,MAAM,CAACE,KAAkB,EAAEC,GAAiC;EACxG,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAChD,MAAMK,EAAE,GAAGC,KAAK,CAACN,KAAK,CAACK,EAAE,CAAC;EAE1B,MAAME,SAAS,GAAGC,EAAE,CAChB,2DAA2D,EAC3D;IACI,MAAM,EAAE,CAAC,CAACN,KAAK;IACf,sGAAsG,EAClG,CAACF,KAAK,CAACS,QAAQ;IACnB,yDAAyD,EAAET,KAAK,CAACS;GACpE,EACDT,KAAK,CAACO,SAAS,CAClB;EAED,IAAIG,eAAe,GAAkC,IAAI;EAEzD,IAAIR,KAAK,EAAE;IACPQ,eAAe,GAAG;MACd,iBAAiB,KAAKL,UAAU;MAChCA;KACH;;EAGL,MAAMM,OAAO,gBACTZ,cAACa,IAAoB,oBAAKR,UAAU,EAAMM,eAAe;IAAEH,SAAS,EAAEA,SAAS;IAAEM,eAAe,EAAEV,QAAQ;IAAEF,GAAG,EAAEA;mBAC7GF,cAACa,KAAqB;IAACL,SAAS,EAAC;IAA6K,CAErN;EAED,IAAIL,KAAK,EAAE;IACP,MAAMY,uBAAuB,GAAGN,EAAE,CAAC,gCAAgC,EAAE;MACjE,kCAAkC,EAAER,KAAK,CAACS;KAC7C,CAAC;IAEF,oBACIV;MAAMQ,SAAS,EAAEO;OACZH,OAAO,eACRZ;MAAOgB,OAAO,EAAEV,EAAE;MAAEA,EAAE,KAAKA;OACtBH,KAAK,CACF,CACL;;EAIf,OAAOS,OAAO;AAClB,CAAC;AACDb,MAAM,CAACkB,WAAW,GAAG,QAAQ;;;;"}
1
+ {"version":3,"file":"Switch.js","sources":["../../../../../../../src/components/Switch/Switch.tsx"],"sourcesContent":["import * as React from 'react';\nimport cn from 'classnames';\nimport * as PrimitiveSwitch from '@radix-ui/react-switch';\nimport { useId } from '../../hooks/useId';\n\ntype SwitchBaseProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onChange'> & {\n /** Label for the switch */\n label?: React.ReactNode;\n /* Whether user input is required */\n required?: boolean;\n};\n\ninterface UncontrolledSwitchProps extends SwitchBaseProps {\n checked?: never;\n onChange?: never;\n /* The default checked state (uncontrolled) */\n defaultChecked?: boolean;\n}\n\ninterface ControlledSwitchProps extends SwitchBaseProps {\n defaultChecked?: never;\n /* The current checked state (controlled) */\n checked: boolean;\n /* Handler called when the checked state changes */\n onChange: (checked: boolean) => void;\n}\n\nexport type SwitchProps = UncontrolledSwitchProps | ControlledSwitchProps;\n\nexport const Switch = React.forwardRef(function Switch(props: SwitchProps, ref: React.Ref<HTMLButtonElement>) {\n const { label, onChange, ...otherProps } = props;\n const id = useId(props.id);\n\n const className = cn(\n 'group h-5 w-9 flex flex-shrink-0 rounded-full inline-flex focus-visible:yt-focus',\n {\n 'mr-2': !!label,\n 'bg-grey-500 hover:bg-grey-700 aria-checked:bg-blue-500 aria-checked:hover:bg-blue-700': !props.disabled,\n 'bg-grey-500/50 aria-checked:bg-blue-500/50 cursor-not-allowed': props.disabled,\n },\n props.className\n );\n\n let labelledByProps: Record<string, string> | null = null;\n\n if (label) {\n labelledByProps = {\n 'aria-labelledby': `${id}-label`,\n id,\n };\n }\n\n const element = (\n <PrimitiveSwitch.Root {...otherProps} {...labelledByProps} className={className} onCheckedChange={onChange} ref={ref}>\n <PrimitiveSwitch.Thumb className=\"'will-change-transform mt-0.5 h-4 w-4 translate-x-[0.15rem] rounded-full bg-white transition-transform group-disabled:opacity-50 group-aria-checked:translate-x-[1.1rem]\" />\n </PrimitiveSwitch.Root>\n );\n\n if (label) {\n const labelContainerClassName = cn('flex self-start cursor-pointer', {\n 'cursor-not-allowed text-grey-300': props.disabled,\n });\n\n return (\n <span className={labelContainerClassName}>\n {element}\n <label htmlFor={id} id={`${id}-label`}>\n {label}\n </label>\n </span>\n );\n }\n\n return element;\n});\nSwitch.displayName = 'Switch';\n"],"names":["Switch","React","props","ref","label","onChange","otherProps","id","useId","className","cn","disabled","labelledByProps","element","PrimitiveSwitch","onCheckedChange","labelContainerClassName","htmlFor","displayName"],"mappings":";;;;;MA6BaA,MAAM,gBAAGC,UAAgB,CAAC,SAASD,MAAM,CAACE,KAAkB,EAAEC,GAAiC;EACxG,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAE,GAAGC;GAAY,GAAGJ,KAAK;EAChD,MAAMK,EAAE,GAAGC,KAAK,CAACN,KAAK,CAACK,EAAE,CAAC;EAE1B,MAAME,SAAS,GAAGC,EAAE,CAChB,kFAAkF,EAClF;IACI,MAAM,EAAE,CAAC,CAACN,KAAK;IACf,uFAAuF,EAAE,CAACF,KAAK,CAACS,QAAQ;IACxG,+DAA+D,EAAET,KAAK,CAACS;GAC1E,EACDT,KAAK,CAACO,SAAS,CAClB;EAED,IAAIG,eAAe,GAAkC,IAAI;EAEzD,IAAIR,KAAK,EAAE;IACPQ,eAAe,GAAG;MACd,iBAAiB,KAAKL,UAAU;MAChCA;KACH;;EAGL,MAAMM,OAAO,gBACTZ,cAACa,IAAoB,oBAAKR,UAAU,EAAMM,eAAe;IAAEH,SAAS,EAAEA,SAAS;IAAEM,eAAe,EAAEV,QAAQ;IAAEF,GAAG,EAAEA;mBAC7GF,cAACa,KAAqB;IAACL,SAAS,EAAC;IAA6K,CAErN;EAED,IAAIL,KAAK,EAAE;IACP,MAAMY,uBAAuB,GAAGN,EAAE,CAAC,gCAAgC,EAAE;MACjE,kCAAkC,EAAER,KAAK,CAACS;KAC7C,CAAC;IAEF,oBACIV;MAAMQ,SAAS,EAAEO;OACZH,OAAO,eACRZ;MAAOgB,OAAO,EAAEV,EAAE;MAAEA,EAAE,KAAKA;OACtBH,KAAK,CACF,CACL;;EAIf,OAAOS,OAAO;AAClB,CAAC;AACDb,MAAM,CAACkB,WAAW,GAAG,QAAQ;;;;"}
@@ -64,7 +64,9 @@ const Header = function Header(props) {
64
64
  const nextSizes = {
65
65
  ...sizes
66
66
  };
67
- if (size) {
67
+ if (size === 'grow') {
68
+ nextSizes[header.id] = '1fr';
69
+ } else if (typeof size === 'number') {
68
70
  nextSizes[header.id] = !isInternalFrozenColumn(header.id) && size < MIN_COLUMN_SIZE ? MIN_COLUMN_SIZE : size;
69
71
  } else {
70
72
  delete nextSizes[header.id];
@@ -168,7 +170,7 @@ const HeaderMenu = ({
168
170
  '!flex': open
169
171
  });
170
172
  const menuItems = [];
171
- if (table.options.enableHiding) {
173
+ if (table.options.enableHiding && header.column.getCanHide()) {
172
174
  // we do this in the next tick, otherwise the menu closes and react throws a "state update on unmounted component" error
173
175
  const handleClick = () => setTimeout(() => header.column.toggleVisibility(), 1);
174
176
  menuItems.push( /*#__PURE__*/React__default.createElement(Menu.Item, {
@@ -1 +1 @@
1
- {"version":3,"file":"Header.js","sources":["../../../../../../../../../src/components/Table2/components/column/Header.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { flexRender, Header as RTHeader, TableMeta, Table as RTTable } from '@tanstack/react-table';\nimport { Icon } from '../../../Icon/Icon';\nimport { ColumnBase, ColumnBaseProps } from './Base';\nimport { Tooltip } from '../../../Tooltip/Tooltip';\nimport { isInternalColumn, isInternalFrozenColumn, MIN_COLUMN_SIZE } from '../../utilities/columns';\nimport { isOverflowing } from '../../../../utils/dom';\nimport { getCellAlignmentClasses, getCellSizingClasses } from '../../utilities/cell';\nimport { IconButton } from '../../../IconButton/IconButton';\nimport { Menu } from '../../../Menu/Menu';\nimport { useLocalization } from '../../../Provider/Localization';\n\ntype HeaderProps<TType = unknown> = Omit<ColumnBaseProps<TType>, 'column' | 'isEditing'> & {\n header: RTHeader<TType, unknown>;\n index: number;\n isLastColumn: boolean;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nexport const Header = function Header<TType = unknown>(props: HeaderProps<TType>) {\n const { header, index, isLastColumn, table, tableRef, ...columnProps } = props;\n const textRef = React.useRef<HTMLDivElement>(null);\n const frozen = !!header.column.getIsPinned();\n const isOtherColumnBeingResized =\n table.getState().columnSizingInfo.isResizingColumn && table.getState().columnSizingInfo.isResizingColumn !== header.id;\n\n const { enableColumnFreezing } = table.options.meta as TableMeta<TType>;\n\n const className = cn(\n 'group/header sticky top-0 bg-white border-b-2 relative font-bold z-[5] hover:z-[6]',\n {\n 'z-[6]': header.column.getIsResizing(),\n 'z-[7]': frozen, // frozen headers should show above cells and other headers, so we assign a higher z-index\n 'cursor-pointer select-none': header.column.getCanSort(),\n 'hover:bg-grey-100': header.column.getCanSort() || header.column.getCanResize() || header.column.columnDef.meta?.menu,\n 'pointer-events-none': isOtherColumnBeingResized,\n },\n getCellSizingClasses('normal'),\n header.column.columnDef.meta?.headerClassName,\n props.className\n );\n\n // set the column size after the first render (after auto layout with 'max-content') has run\n // this way columns default to fit their content, then we save that size for resizing\n const refCallback = (node: HTMLDivElement) => {\n if (node && !table.getState().columnSizing[header.id]) {\n const size = Math.ceil(node.getBoundingClientRect().width);\n table.setColumnSizing(sizes => ({\n ...sizes,\n [header.id]: !isInternalFrozenColumn(header.id) && size < MIN_COLUMN_SIZE ? MIN_COLUMN_SIZE : size,\n }));\n }\n };\n\n // we use mousedown because clicking and dragging resize and then letting go over the\n // column, results in sorting being applied\n const handleMouseDown = header.column.getCanSort()\n ? (event: React.MouseEvent) => {\n // only detect left clicks\n if (event.button === 0) {\n event.preventDefault();\n table.resetRowSelection();\n header.column.toggleSorting();\n tableRef.current?.focus();\n }\n }\n : undefined;\n\n const handleResizerDoubleClick = () => {\n const size = header.column.columnDef.meta?.defaultWidth;\n table.setColumnSizing(sizes => {\n const nextSizes = { ...sizes };\n\n if (size) {\n nextSizes[header.id] = !isInternalFrozenColumn(header.id) && size < MIN_COLUMN_SIZE ? MIN_COLUMN_SIZE : size;\n } else {\n delete nextSizes[header.id];\n }\n\n return nextSizes;\n });\n };\n\n const handleResizerClick = event => {\n event.stopPropagation();\n event.preventDefault();\n };\n\n const handleResize = event => {\n // prevent the parent onMouseDown propagating\n event.stopPropagation();\n header.getResizeHandler()(event);\n };\n\n const content = (\n <div className=\"truncate\" ref={textRef}>\n {flexRender(header.column.columnDef.header, header.getContext())}\n </div>\n );\n\n const { texts } = useLocalization();\n\n return (\n <ColumnBase\n {...columnProps}\n // base props\n column={header.column}\n table={table}\n // other props\n aria-sort={\n {\n asc: 'ascending',\n desc: 'descending',\n }[header.column.getIsSorted() as any] ?? 'none'\n }\n className={className}\n onMouseDown={handleMouseDown}\n ref={refCallback}\n role=\"columnheader\"\n // helper props\n data-column-index={index}>\n {isInternalFrozenColumn(header.id) ? (\n flexRender(header.column.columnDef.header, header.getContext())\n ) : (\n <>\n <div\n className={cn(\n 'flex flex-grow overflow-hidden',\n {\n 'group-hover/header:-ml-2': !!header.column.getIsSorted() && !!header.column.columnDef.meta?.menu,\n },\n getCellAlignmentClasses(header.column.columnDef.meta?.align)\n )}>\n {isOverflowing(textRef.current) ? (\n <Tooltip title={header.column.columnDef.meta?.tooltip ?? content} placement=\"top\">\n {content}\n </Tooltip>\n ) : (\n content\n )}\n {{\n asc: <Icon name=\"chevron-up-solid\" className=\"pointer-events-none -my-0.5\" />,\n desc: <Icon name=\"chevron-down-solid\" className=\"pointer-events-none -my-0.5\" />,\n }[header.column.getIsSorted() as string] ?? null}\n </div>\n {!isInternalColumn(header.column.id) && (header.column.columnDef.meta?.menu || enableColumnFreezing) ? (\n <HeaderMenu header={header} table={table} columnIndex={index} />\n ) : null}\n </>\n )}\n {header.column.getCanResize() ? (\n <Tooltip placement=\"top\" title={texts.table2.columns.resize.tooltip}>\n <div\n className={cn(\n 'invisible absolute right-0 top-0 flex h-full cursor-col-resize touch-none select-none rounded py-0.5 group-hover/header:visible',\n {\n '-mr-2.5 w-5 justify-center': !isLastColumn,\n 'w-2': isLastColumn,\n '!visible': header.column.getIsResizing(),\n }\n )}\n onDoubleClick={handleResizerDoubleClick}\n onMouseDown={handleResize}\n onTouchStart={handleResize}\n // this prevents sort handlers being activated\n onClick={handleResizerClick}>\n <div\n className={cn('h-full w-1 rounded', {\n '!bg-blue-500': header.column.getIsResizing(),\n 'bg-grey-500 hover:bg-grey-700': !header.column.getIsResizing(),\n })}\n />\n </div>\n </Tooltip>\n ) : null}\n </ColumnBase>\n );\n};\n\ntype HeaderMenuProps = {\n header: RTHeader<any, unknown>;\n table: RTTable<any>;\n columnIndex: number;\n};\n\nconst HeaderMenu = ({ header, table, columnIndex }: HeaderMenuProps) => {\n const [open, setOpen] = React.useState(false);\n const { texts } = useLocalization();\n const menu = header.column.columnDef.meta?.menu;\n const meta = table.options.meta as TableMeta<any>;\n const { frozenColumnsCount, setFrozenColumnsCount } = meta;\n\n const columns = table.getVisibleLeafColumns();\n const { columnVisibility, columnOrder } = table.getState();\n const visibleInternalColumnsCount = React.useMemo(\n () => columns.filter(column => isInternalFrozenColumn(column.id)).length,\n [columns]\n );\n\n const className = cn(\n '-my-0.5 -mr-1 -ml-0.5 hidden !h-6 !min-h-[theme(spacing.6)] !w-6 !min-w-[theme(spacing.6)] flex-shrink-0 justify-end group-hover/header:flex',\n {\n '!flex': open,\n }\n );\n\n const menuItems: JSX.Element[] = [];\n\n if (table.options.enableHiding) {\n // we do this in the next tick, otherwise the menu closes and react throws a \"state update on unmounted component\" error\n const handleClick = () => setTimeout(() => header.column.toggleVisibility(), 1);\n\n menuItems.push(\n <Menu.Item icon=\"eye-off\" onClick={handleClick}>\n {texts.table2.columns.menu.hideColumn}\n </Menu.Item>\n );\n }\n\n if (meta.enableColumnFreezing) {\n const columnPosition = columnIndex + 1;\n const externalFrozenColumnsCount = columnPosition - visibleInternalColumnsCount;\n const isSomeExternalColumnFrozen = frozenColumnsCount !== 0;\n const freeAllColumns = () => {\n setFrozenColumnsCount(0);\n };\n const freezeColumns = () => {\n setFrozenColumnsCount(externalFrozenColumnsCount);\n };\n\n menuItems.push(\n <Menu.Item icon=\"column-freeze\" onClick={freezeColumns} key=\"_freeze-columns_\">\n {texts.table2.columns.menu.freezeColumns(externalFrozenColumnsCount)}\n </Menu.Item>\n );\n\n if (isSomeExternalColumnFrozen) {\n menuItems.push(\n <Menu.Item icon=\"column-unfreeze\" onClick={freeAllColumns} key=\"_unfreeze-columns_\">\n {texts.table2.columns.menu.unfreezeColumns}\n </Menu.Item>\n );\n }\n }\n\n React.useEffect(() => {\n // Update column pinning/freezing whenever frozen columns count changes, or column order or visiblity changes\n const totalFrozenColumnsCount = visibleInternalColumnsCount + frozenColumnsCount;\n\n table.setColumnPinning({ left: columns.slice(0, totalFrozenColumnsCount).map(column => column.id), right: [] });\n }, [frozenColumnsCount, columnVisibility, columnOrder, visibleInternalColumnsCount]);\n\n const menuProps = {\n trigger: <IconButton className={className} icon=\"more\" />,\n open: open,\n onChange: setOpen,\n };\n\n if (menu) {\n const customMenu = menu({ trigger: undefined });\n const customItems = React.Children.toArray(customMenu.props.children.props.children) as JSX.Element[];\n\n if (customItems.length) {\n if (menuItems.length) {\n menuItems.push(<Menu.Separator />);\n }\n\n menuItems.push(...customItems);\n }\n }\n\n const menuComponent = (\n <Menu {...menuProps}>\n <Menu.Content>{menuItems.map((item, key) => React.cloneElement(item, { key }))}</Menu.Content>\n </Menu>\n );\n\n // This div catches the mousedown events from menu item and menu trigger and prevents\n // mousedown event from bubbling up to the Header component to prevent toggling sorting\n return menuComponent ? <div onMouseDown={event => event.stopPropagation()}>{menuComponent}</div> : null;\n};\n"],"names":["Header","props","header","index","isLastColumn","table","tableRef","columnProps","textRef","React","useRef","frozen","column","getIsPinned","isOtherColumnBeingResized","getState","columnSizingInfo","isResizingColumn","id","enableColumnFreezing","options","meta","className","cn","getIsResizing","getCanSort","getCanResize","columnDef","menu","getCellSizingClasses","headerClassName","refCallback","node","columnSizing","size","Math","ceil","getBoundingClientRect","width","setColumnSizing","sizes","isInternalFrozenColumn","MIN_COLUMN_SIZE","handleMouseDown","event","button","preventDefault","resetRowSelection","toggleSorting","current","focus","undefined","handleResizerDoubleClick","defaultWidth","nextSizes","handleResizerClick","stopPropagation","handleResize","getResizeHandler","content","ref","flexRender","getContext","texts","useLocalization","ColumnBase","asc","desc","getIsSorted","onMouseDown","role","getCellAlignmentClasses","align","isOverflowing","Tooltip","title","tooltip","placement","Icon","name","isInternalColumn","HeaderMenu","columnIndex","table2","columns","resize","onDoubleClick","onTouchStart","onClick","open","setOpen","useState","frozenColumnsCount","setFrozenColumnsCount","getVisibleLeafColumns","columnVisibility","columnOrder","visibleInternalColumnsCount","useMemo","filter","length","menuItems","enableHiding","handleClick","setTimeout","toggleVisibility","push","Menu","Item","icon","hideColumn","columnPosition","externalFrozenColumnsCount","isSomeExternalColumnFrozen","freeAllColumns","freezeColumns","key","unfreezeColumns","useEffect","totalFrozenColumnsCount","setColumnPinning","left","slice","map","right","menuProps","trigger","IconButton","onChange","customMenu","customItems","Children","toArray","children","Separator","menuComponent","Content","item","cloneElement"],"mappings":";;;;;;;;;;;;;MAoBaA,MAAM,GAAG,SAASA,MAAM,CAAkBC,KAAyB;;EAC5E,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC,YAAY;IAAEC,KAAK;IAAEC,QAAQ;IAAE,GAAGC;GAAa,GAAGN,KAAK;EAC9E,MAAMO,OAAO,GAAGC,cAAK,CAACC,MAAM,CAAiB,IAAI,CAAC;EAClD,MAAMC,MAAM,GAAG,CAAC,CAACT,MAAM,CAACU,MAAM,CAACC,WAAW,EAAE;EAC5C,MAAMC,yBAAyB,GAC3BT,KAAK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;IACN,MAAMqG,UAAU,GAAGrG,IAAI,CAAC;MAAEkG,OAAO,EAAE3E;KAAW,CAAC;IAC/C,MAAM+E,WAAW,GAAGzH,cAAK,CAAC0H,QAAQ,CAACC,OAAO,CAACH,UAAU,CAAChI,KAAK,CAACoI,QAAQ,CAACpI,KAAK,CAACoI,QAAQ,CAAkB;IAErG,IAAIH,WAAW,CAAC9B,MAAM,EAAE;MACpB,IAAIC,SAAS,CAACD,MAAM,EAAE;QAClBC,SAAS,CAACK,IAAI,eAACjG,6BAACkG,IAAI,CAAC2B,SAAS,OAAG,CAAC;;MAGtCjC,SAAS,CAACK,IAAI,CAAC,GAAGwB,WAAW,CAAC;;;EAItC,MAAMK,aAAa,gBACf9H,6BAACkG,IAAI,oBAAKkB,SAAS,gBACfpH,6BAACkG,IAAI,CAAC6B,OAAO,QAAEnC,SAAS,CAACsB,GAAG,CAAC,CAACc,IAAI,EAAErB,GAAG,kBAAK3G,cAAK,CAACiI,YAAY,CAACD,IAAI,EAAE;IAAErB;GAAK,CAAC,CAAC,CAAgB,CAErG;;;EAID,OAAOmB,aAAa,gBAAG9H;IAAK4D,WAAW,EAAEzB,KAAK,IAAIA,KAAK,CAACY,eAAe;KAAK+E,aAAa,CAAO,GAAG,IAAI;AAC3G,CAAC;;;;"}
1
+ {"version":3,"file":"Header.js","sources":["../../../../../../../../../src/components/Table2/components/column/Header.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { flexRender, Header as RTHeader, TableMeta, Table as RTTable } from '@tanstack/react-table';\nimport { Icon } from '../../../Icon/Icon';\nimport { ColumnBase, ColumnBaseProps } from './Base';\nimport { Tooltip } from '../../../Tooltip/Tooltip';\nimport { isInternalColumn, isInternalFrozenColumn, MIN_COLUMN_SIZE } from '../../utilities/columns';\nimport { isOverflowing } from '../../../../utils/dom';\nimport { getCellAlignmentClasses, getCellSizingClasses } from '../../utilities/cell';\nimport { IconButton } from '../../../IconButton/IconButton';\nimport { Menu } from '../../../Menu/Menu';\nimport { useLocalization } from '../../../Provider/Localization';\n\ntype HeaderProps<TType = unknown> = Omit<ColumnBaseProps<TType>, 'column' | 'isEditing'> & {\n header: RTHeader<TType, unknown>;\n index: number;\n isLastColumn: boolean;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nexport const Header = function Header<TType = unknown>(props: HeaderProps<TType>) {\n const { header, index, isLastColumn, table, tableRef, ...columnProps } = props;\n const textRef = React.useRef<HTMLDivElement>(null);\n const frozen = !!header.column.getIsPinned();\n const isOtherColumnBeingResized =\n table.getState().columnSizingInfo.isResizingColumn && table.getState().columnSizingInfo.isResizingColumn !== header.id;\n\n const { enableColumnFreezing } = table.options.meta as TableMeta<TType>;\n\n const className = cn(\n 'group/header sticky top-0 bg-white border-b-2 relative font-bold z-[5] hover:z-[6]',\n {\n 'z-[6]': header.column.getIsResizing(),\n 'z-[7]': frozen, // frozen headers should show above cells and other headers, so we assign a higher z-index\n 'cursor-pointer select-none': header.column.getCanSort(),\n 'hover:bg-grey-100': header.column.getCanSort() || header.column.getCanResize() || header.column.columnDef.meta?.menu,\n 'pointer-events-none': isOtherColumnBeingResized,\n },\n getCellSizingClasses('normal'),\n header.column.columnDef.meta?.headerClassName,\n props.className\n );\n\n // set the column size after the first render (after auto layout with 'max-content') has run\n // this way columns default to fit their content, then we save that size for resizing\n const refCallback = (node: HTMLDivElement) => {\n if (node && !table.getState().columnSizing[header.id]) {\n const size = Math.ceil(node.getBoundingClientRect().width);\n table.setColumnSizing(sizes => ({\n ...sizes,\n [header.id]: !isInternalFrozenColumn(header.id) && size < MIN_COLUMN_SIZE ? MIN_COLUMN_SIZE : size,\n }));\n }\n };\n\n // we use mousedown because clicking and dragging resize and then letting go over the\n // column, results in sorting being applied\n const handleMouseDown = header.column.getCanSort()\n ? (event: React.MouseEvent) => {\n // only detect left clicks\n if (event.button === 0) {\n event.preventDefault();\n table.resetRowSelection();\n header.column.toggleSorting();\n tableRef.current?.focus();\n }\n }\n : undefined;\n\n const handleResizerDoubleClick = () => {\n const size = header.column.columnDef.meta?.defaultWidth;\n\n table.setColumnSizing(sizes => {\n const nextSizes = { ...sizes };\n\n if (size === 'grow') {\n nextSizes[header.id] = '1fr' as any;\n } else if (typeof size === 'number') {\n nextSizes[header.id] = !isInternalFrozenColumn(header.id) && size < MIN_COLUMN_SIZE ? MIN_COLUMN_SIZE : size;\n } else {\n delete nextSizes[header.id];\n }\n\n return nextSizes;\n });\n };\n\n const handleResizerClick = event => {\n event.stopPropagation();\n event.preventDefault();\n };\n\n const handleResize = event => {\n // prevent the parent onMouseDown propagating\n event.stopPropagation();\n header.getResizeHandler()(event);\n };\n\n const content = (\n <div className=\"truncate\" ref={textRef}>\n {flexRender(header.column.columnDef.header, header.getContext())}\n </div>\n );\n\n const { texts } = useLocalization();\n\n return (\n <ColumnBase\n {...columnProps}\n // base props\n column={header.column}\n table={table}\n // other props\n aria-sort={\n {\n asc: 'ascending',\n desc: 'descending',\n }[header.column.getIsSorted() as any] ?? 'none'\n }\n className={className}\n onMouseDown={handleMouseDown}\n ref={refCallback}\n role=\"columnheader\"\n // helper props\n data-column-index={index}>\n {isInternalFrozenColumn(header.id) ? (\n flexRender(header.column.columnDef.header, header.getContext())\n ) : (\n <>\n <div\n className={cn(\n 'flex flex-grow overflow-hidden',\n {\n 'group-hover/header:-ml-2': !!header.column.getIsSorted() && !!header.column.columnDef.meta?.menu,\n },\n getCellAlignmentClasses(header.column.columnDef.meta?.align)\n )}>\n {isOverflowing(textRef.current) ? (\n <Tooltip title={header.column.columnDef.meta?.tooltip ?? content} placement=\"top\">\n {content}\n </Tooltip>\n ) : (\n content\n )}\n {{\n asc: <Icon name=\"chevron-up-solid\" className=\"pointer-events-none -my-0.5\" />,\n desc: <Icon name=\"chevron-down-solid\" className=\"pointer-events-none -my-0.5\" />,\n }[header.column.getIsSorted() as string] ?? null}\n </div>\n {!isInternalColumn(header.column.id) && (header.column.columnDef.meta?.menu || enableColumnFreezing) ? (\n <HeaderMenu header={header} table={table} columnIndex={index} />\n ) : null}\n </>\n )}\n {header.column.getCanResize() ? (\n <Tooltip placement=\"top\" title={texts.table2.columns.resize.tooltip}>\n <div\n className={cn(\n 'invisible absolute right-0 top-0 flex h-full cursor-col-resize touch-none select-none rounded py-0.5 group-hover/header:visible',\n {\n '-mr-2.5 w-5 justify-center': !isLastColumn,\n 'w-2': isLastColumn,\n '!visible': header.column.getIsResizing(),\n }\n )}\n onDoubleClick={handleResizerDoubleClick}\n onMouseDown={handleResize}\n onTouchStart={handleResize}\n // this prevents sort handlers being activated\n onClick={handleResizerClick}>\n <div\n className={cn('h-full w-1 rounded', {\n '!bg-blue-500': header.column.getIsResizing(),\n 'bg-grey-500 hover:bg-grey-700': !header.column.getIsResizing(),\n })}\n />\n </div>\n </Tooltip>\n ) : null}\n </ColumnBase>\n );\n};\n\ntype HeaderMenuProps = {\n header: RTHeader<any, unknown>;\n table: RTTable<any>;\n columnIndex: number;\n};\n\nconst HeaderMenu = ({ header, table, columnIndex }: HeaderMenuProps) => {\n const [open, setOpen] = React.useState(false);\n const { texts } = useLocalization();\n const menu = header.column.columnDef.meta?.menu;\n const meta = table.options.meta as TableMeta<any>;\n const { frozenColumnsCount, setFrozenColumnsCount } = meta;\n\n const columns = table.getVisibleLeafColumns();\n const { columnVisibility, columnOrder } = table.getState();\n const visibleInternalColumnsCount = React.useMemo(\n () => columns.filter(column => isInternalFrozenColumn(column.id)).length,\n [columns]\n );\n\n const className = cn(\n '-my-0.5 -mr-1 -ml-0.5 hidden !h-6 !min-h-[theme(spacing.6)] !w-6 !min-w-[theme(spacing.6)] flex-shrink-0 justify-end group-hover/header:flex',\n {\n '!flex': open,\n }\n );\n\n const menuItems: JSX.Element[] = [];\n\n if (table.options.enableHiding && header.column.getCanHide()) {\n // we do this in the next tick, otherwise the menu closes and react throws a \"state update on unmounted component\" error\n const handleClick = () => setTimeout(() => header.column.toggleVisibility(), 1);\n\n menuItems.push(\n <Menu.Item icon=\"eye-off\" onClick={handleClick}>\n {texts.table2.columns.menu.hideColumn}\n </Menu.Item>\n );\n }\n\n if (meta.enableColumnFreezing) {\n const columnPosition = columnIndex + 1;\n const externalFrozenColumnsCount = columnPosition - visibleInternalColumnsCount;\n const isSomeExternalColumnFrozen = frozenColumnsCount !== 0;\n const freeAllColumns = () => {\n setFrozenColumnsCount(0);\n };\n const freezeColumns = () => {\n setFrozenColumnsCount(externalFrozenColumnsCount);\n };\n\n menuItems.push(\n <Menu.Item icon=\"column-freeze\" onClick={freezeColumns} key=\"_freeze-columns_\">\n {texts.table2.columns.menu.freezeColumns(externalFrozenColumnsCount)}\n </Menu.Item>\n );\n\n if (isSomeExternalColumnFrozen) {\n menuItems.push(\n <Menu.Item icon=\"column-unfreeze\" onClick={freeAllColumns} key=\"_unfreeze-columns_\">\n {texts.table2.columns.menu.unfreezeColumns}\n </Menu.Item>\n );\n }\n }\n\n React.useEffect(() => {\n // Update column pinning/freezing whenever frozen columns count changes, or column order or visiblity changes\n const totalFrozenColumnsCount = visibleInternalColumnsCount + frozenColumnsCount;\n\n table.setColumnPinning({ left: columns.slice(0, totalFrozenColumnsCount).map(column => column.id), right: [] });\n }, [frozenColumnsCount, columnVisibility, columnOrder, visibleInternalColumnsCount]);\n\n const menuProps = {\n trigger: <IconButton className={className} icon=\"more\" />,\n open: open,\n onChange: setOpen,\n };\n\n if (menu) {\n const customMenu = menu({ trigger: undefined });\n const customItems = React.Children.toArray(customMenu.props.children.props.children) as JSX.Element[];\n\n if (customItems.length) {\n if (menuItems.length) {\n menuItems.push(<Menu.Separator />);\n }\n\n menuItems.push(...customItems);\n }\n }\n\n const menuComponent = (\n <Menu {...menuProps}>\n <Menu.Content>{menuItems.map((item, key) => React.cloneElement(item, { key }))}</Menu.Content>\n </Menu>\n );\n\n // This div catches the mousedown events from menu item and menu trigger and prevents\n // mousedown event from bubbling up to the Header component to prevent toggling sorting\n return menuComponent ? <div onMouseDown={event => event.stopPropagation()}>{menuComponent}</div> : null;\n};\n"],"names":["Header","props","header","index","isLastColumn","table","tableRef","columnProps","textRef","React","useRef","frozen","column","getIsPinned","isOtherColumnBeingResized","getState","columnSizingInfo","isResizingColumn","id","enableColumnFreezing","options","meta","className","cn","getIsResizing","getCanSort","getCanResize","columnDef","menu","getCellSizingClasses","headerClassName","refCallback","node","columnSizing","size","Math","ceil","getBoundingClientRect","width","setColumnSizing","sizes","isInternalFrozenColumn","MIN_COLUMN_SIZE","handleMouseDown","event","button","preventDefault","resetRowSelection","toggleSorting","current","focus","undefined","handleResizerDoubleClick","defaultWidth","nextSizes","handleResizerClick","stopPropagation","handleResize","getResizeHandler","content","ref","flexRender","getContext","texts","useLocalization","ColumnBase","asc","desc","getIsSorted","onMouseDown","role","getCellAlignmentClasses","align","isOverflowing","Tooltip","title","tooltip","placement","Icon","name","isInternalColumn","HeaderMenu","columnIndex","table2","columns","resize","onDoubleClick","onTouchStart","onClick","open","setOpen","useState","frozenColumnsCount","setFrozenColumnsCount","getVisibleLeafColumns","columnVisibility","columnOrder","visibleInternalColumnsCount","useMemo","filter","length","menuItems","enableHiding","getCanHide","handleClick","setTimeout","toggleVisibility","push","Menu","Item","icon","hideColumn","columnPosition","externalFrozenColumnsCount","isSomeExternalColumnFrozen","freeAllColumns","freezeColumns","key","unfreezeColumns","useEffect","totalFrozenColumnsCount","setColumnPinning","left","slice","map","right","menuProps","trigger","IconButton","onChange","customMenu","customItems","Children","toArray","children","Separator","menuComponent","Content","item","cloneElement"],"mappings":";;;;;;;;;;;;;MAoBaA,MAAM,GAAG,SAASA,MAAM,CAAkBC,KAAyB;;EAC5E,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC,YAAY;IAAEC,KAAK;IAAEC,QAAQ;IAAE,GAAGC;GAAa,GAAGN,KAAK;EAC9E,MAAMO,OAAO,GAAGC,cAAK,CAACC,MAAM,CAAiB,IAAI,CAAC;EAClD,MAAMC,MAAM,GAAG,CAAC,CAACT,MAAM,CAACU,MAAM,CAACC,WAAW,EAAE;EAC5C,MAAMC,yBAAy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pF,MAAM6B,SAAS,GAAG;IACdC,OAAO,eAAEtH,6BAACuH,UAAU;MAAC1G,SAAS,EAAEA,SAAS;MAAEwF,IAAI,EAAC;MAAS;IACzDrB,IAAI,EAAEA,IAAI;IACVwC,QAAQ,EAAEvC;GACb;EAED,IAAI9D,IAAI,EAAE;IACN,MAAMsG,UAAU,GAAGtG,IAAI,CAAC;MAAEmG,OAAO,EAAE5E;KAAW,CAAC;IAC/C,MAAMgF,WAAW,GAAG1H,cAAK,CAAC2H,QAAQ,CAACC,OAAO,CAACH,UAAU,CAACjI,KAAK,CAACqI,QAAQ,CAACrI,KAAK,CAACqI,QAAQ,CAAkB;IAErG,IAAIH,WAAW,CAAC/B,MAAM,EAAE;MACpB,IAAIC,SAAS,CAACD,MAAM,EAAE;QAClBC,SAAS,CAACM,IAAI,eAAClG,6BAACmG,IAAI,CAAC2B,SAAS,OAAG,CAAC;;MAGtClC,SAAS,CAACM,IAAI,CAAC,GAAGwB,WAAW,CAAC;;;EAItC,MAAMK,aAAa,gBACf/H,6BAACmG,IAAI,oBAAKkB,SAAS,gBACfrH,6BAACmG,IAAI,CAAC6B,OAAO,QAAEpC,SAAS,CAACuB,GAAG,CAAC,CAACc,IAAI,EAAErB,GAAG,kBAAK5G,cAAK,CAACkI,YAAY,CAACD,IAAI,EAAE;IAAErB;GAAK,CAAC,CAAC,CAAgB,CAErG;;;EAID,OAAOmB,aAAa,gBAAG/H;IAAK4D,WAAW,EAAEzB,KAAK,IAAIA,KAAK,CAACY,eAAe;KAAKgF,aAAa,CAAO,GAAG,IAAI;AAC3G,CAAC;;;;"}
@@ -21,8 +21,9 @@ function useColumnDefinitions(children, options, tableRef) {
21
21
  React__default.Children.toArray(children).filter(child => !!child).forEach(child => {
22
22
  if ( /*#__PURE__*/React__default.isValidElement(child)) {
23
23
  var _child$props$minWidth;
24
- if (child.props.defaultWidth) {
25
- defaultColumnSizing[child.props.accessor] = child.props.defaultWidth;
24
+ const defaultWidth = child.props.defaultWidth === 'grow' ? '1fr' : child.props.defaultWidth;
25
+ if (defaultWidth) {
26
+ defaultColumnSizing[child.props.accessor] = defaultWidth;
26
27
  }
27
28
  if (child.props.defaultHidden && options.enableColumnHiding) {
28
29
  defaultColumnVisibility[child.props.accessor] = false;
@@ -58,7 +59,7 @@ function useColumnDefinitions(children, options, tableRef) {
58
59
  className: child.props.className,
59
60
  control: child.props.control,
60
61
  dataType: child.props.dataType,
61
- defaultWidth: child.props.defaultWidth,
62
+ defaultWidth,
62
63
  disableReordering: child.props.disableReordering,
63
64
  menu: child.props.menu,
64
65
  tooltip: child.props.tooltip